72 lines
2.1 KiB
PHP
Executable File
72 lines
2.1 KiB
PHP
Executable File
<?php
|
|
|
|
class TrustedShopBbbAsync extends ObjectModel
|
|
{
|
|
public $id_order;
|
|
public $processed;
|
|
public $date_add;
|
|
public $date_upd;
|
|
|
|
protected $fieldsValidate = array(
|
|
'id_order' => 'isUnsignedId',
|
|
'processed' => 'isBool',
|
|
'date_add' => 'isDate',
|
|
'date_upd' => 'isDate',
|
|
);
|
|
|
|
public function getFields()
|
|
{
|
|
parent::validateFields();
|
|
|
|
$fields['id_order'] = (int)$this->id_order;
|
|
$fields['processed'] = (int)$this->processed;
|
|
$fields['date_add'] = pSQL($this->date_add);
|
|
$fields['date_upd'] = pSQL($this->date_upd);
|
|
|
|
return $fields;
|
|
}
|
|
|
|
protected $table = 'trustedshop_bbb_async';
|
|
protected $identifier = 'id_trustedshop_bbb_async';
|
|
|
|
/**
|
|
* Get Order To Process
|
|
* @return Array Order to process
|
|
*/
|
|
public static function getOrderToProcess()
|
|
{
|
|
return Db::getInstance()->ExecuteS('
|
|
SELECT tba.`id_order`, o.`id_lang`, l.`iso_code`
|
|
FROM `' . _DB_PREFIX_ . 'trustedshop_bbb_async` tba
|
|
JOIN `' . _DB_PREFIX_ . 'orders` o ON o.`id_order` = tba.`id_order`
|
|
JOIN `' . _DB_PREFIX_ . 'lang` l ON o.`id_lang` = l.`id_lang`
|
|
WHERE tba.`processed` = 0
|
|
LIMIT 0,1000;
|
|
');
|
|
}
|
|
|
|
public static function saveOrUpdate($id_order, $processed = NULL)
|
|
{
|
|
$trustedShopBbbAsync = NULL;
|
|
|
|
if ($id_trustedshop_bbb_async = Db::getInstance()->getValue('
|
|
SELECT tba.`id_trustedshop_bbb_async`
|
|
FROM `' . _DB_PREFIX_ . 'trustedshop_bbb_async` tba
|
|
WHERE tba.`id_order` = ' . (int)$id_order)
|
|
) {
|
|
$trustedShopBbbAsync = new TrustedShopBbbAsync((int)$id_trustedshop_bbb_async);
|
|
} else {
|
|
$trustedShopBbbAsync = new TrustedShopBbbAsync();
|
|
$trustedShopBbbAsync->id_order = (int)$id_order;
|
|
}
|
|
if (isset($trustedShopBbbAsync)) {
|
|
if (isset($processed)) {
|
|
$trustedShopBbbAsync->processed = $processed;
|
|
}
|
|
$trustedShopBbbAsync->save();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
} |