diff --git a/modules/emarsys_rss/flux.php b/modules/emarsys_rss/flux.php index 0b8e632e..35670dfe 100755 --- a/modules/emarsys_rss/flux.php +++ b/modules/emarsys_rss/flux.php @@ -30,6 +30,9 @@ class Catalog public function setContent($version = 'fr') { + // Flush to load the good sales + CacheRedis::getInstance()->clear('sale*'); + $test_for_tomorrow = (int)Tools::getValue('tomorrow',0); $sales_today = array(); diff --git a/modules/logistics/AdminLogistics.php b/modules/logistics/AdminLogistics.php index 85e448af..e2ca0a6c 100644 --- a/modules/logistics/AdminLogistics.php +++ b/modules/logistics/AdminLogistics.php @@ -813,7 +813,7 @@ class AdminLogistics extends AdminTab { for(var i=0; i < loaded.logs.length; i++) { content += \'\ \' + loaded.logs[i].date_add + \'\ - \' + (loaded.logs[i].firstname == "Dropshipping"? "Dropshipping" : loaded.logs[i].firstname + \' \' + loaded.logs[i].lastname) + \'\ + \' + (loaded.logs[i].lastname == undefined? loaded.logs[i].firstname : loaded.logs[i].firstname + \' \' + loaded.logs[i].lastname) + \'\ \' + loaded.logs[i].quantity + \'\ \' + loaded.logs[i].product_name.replace(" - ", "
") + \'\ \' + loaded.logs[i].product_reference + \'\ diff --git a/modules/logistics/ajax.php b/modules/logistics/ajax.php index 0fa4aa81..7b822805 100644 --- a/modules/logistics/ajax.php +++ b/modules/logistics/ajax.php @@ -227,24 +227,40 @@ if(($id_order = (int) Tools::getValue('id_order')) $link = new Link(2); $products = array(); foreach($order->getProductsDetail() as $p) { - $p['product_quantity_sent'] = (int) Db::getInstance()->getValue(' - SELECT IFNULL(SUM(`quantity`), 0) AS `total` + $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' + SELECT IFNULL(SUM(`quantity`), 0) FROM `'._DB_PREFIX_.'lapostews` WHERE `id_order_detail` = '.(int) $p['id_order_detail'].' - ') + (int) Db::getInstance()->getValue(' - SELECT IFNULL(SUM(`quantity`), 0) AS `total` + '); + $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' + SELECT IFNULL(SUM(`quantity`), 0) FROM `'._DB_PREFIX_.'exapaqws` WHERE `id_order_detail` = '.(int) $p['id_order_detail'].' '); - /** * @Override MondialRelay */ $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' - SELECT IFNULL(SUM(`quantity`), 0) AS `total` + SELECT IFNULL(SUM(`quantity`), 0) FROM `'._DB_PREFIX_.'mondialrelay_parcel` WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . ' '); + /** + * @Override Philea + */ + $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' + SELECT IFNULL(SUM(`quantity`), 0) + FROM `'._DB_PREFIX_.'philea_parcel` + WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . ' + '); + /** + * @Override Dropshipping + */ + $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' + SELECT IFNULL(SUM(`quantity`), 0) + FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` + WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . ' + '); $p['id_image'] = 0; @@ -345,6 +361,18 @@ if(($id_order = (int) Tools::getValue('id_order')) ') as $row) { $shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"'; } + /* + * @Override Philea + */ + foreach(Db::getInstance()->ExecuteS(' + SELECT l.`shipping_number` + FROM `'._DB_PREFIX_.'philea_parcel` l + LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`) + LEFT JOIN `'._DB_PREFIX_.'order_history` h ON (h.`id_order` = d.`id_order`) + WHERE h.`id_order` = '.(int) $order->id.' + ') as $row) { + $shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"'; + } if(((int) $p['product_quantity_sent'] === 0) && Db::getInstance()->getRow(' @@ -427,6 +455,21 @@ if(($id_order = (int) Tools::getValue('id_order')) ')) { $logs = array_merge($logs, $l); } + /* + * @Override Philea + */ + if($l = Db::getInstance()->ExecuteS(' + SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, "Philea" as firstname, c.`name` as carrier + FROM `'._DB_PREFIX_.'philea_parcel` l + LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`id_order_detail` = l.`id_order_detail` + LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order` + LEFT JOIN `'._DB_PREFIX_.'carrier` c ON c.`id_carrier` = o.`id_carrier` + WHERE l.`id_order_detail` IN ('.implode(', ', $id_order_details).') + AND l.`quantity` > 0 + ORDER BY l.`date_add` DESC + ')) { + $logs = array_merge($logs, $l); + } } else { $logs = array(); } diff --git a/modules/philea_magistor/AdminPhileaMagistor.php b/modules/philea_magistor/AdminPhileaMagistor.php index f0cddf6b..f0e88641 100644 --- a/modules/philea_magistor/AdminPhileaMagistor.php +++ b/modules/philea_magistor/AdminPhileaMagistor.php @@ -10,7 +10,25 @@ class AdminPhileaMagistor extends AdminTab { static $_crrlist_cache = NULL; public function postProcess() { - if(Tools::isSubmit('submitProductSaleCache')) { + if(Tools::getIsset('send_to_philea') && Tools::getValue('id_sale')) { + $id_sale = (int)Tools::getValue('id_sale'); + if(Db::getInstance()->getRow(' + SELECT * + FROM `'._DB_PREFIX_.'philea_sync` + WHERE `id_sale` = '.(int) $id_sale.' + AND `status` = 7 + ')) { + Db::getInstance()->ExecuteS(' + UPDATE `'._DB_PREFIX_.'philea_sync` + SET `status` = 8 + WHERE id_sale = '.(int) $id_sale.' + LIMIT 1 + '); + echo '

'.$this->l('CDC for this Sale added to queue successfully').'


'; + } else { + echo '

'.$this->l('Sale is not ready').'


'; + } + } elseif(Tools::isSubmit('submitProductSaleCache')) { global $cookie; $fileName = 'cron_sale_cache.php'; $output = shell_exec("ps -ax | grep $fileName | wc -l"); @@ -167,6 +185,37 @@ class AdminPhileaMagistor extends AdminTab { $filename = Tools::getValue('filename'); $this->exportCsv((int) $id_sale, $filename); } + elseif(Tools::isSubmit('addNoPhileaSale') && Tools::getValue('id_sale')){ + $id_sale = (int) Tools::getValue('id_sale'); + $existing_id = Db::getInstance()->getValue(' + SELECT `id_sale` + FROM `'._DB_PREFIX_.'privatesale` + WHERE `id_sale` = '.(int) $id_sale.' + '); + if($id_sale && $id_sale == (int)$existing_id) { + if(!Db::getInstance()->getRow(' + SELECT * + FROM `'._DB_PREFIX_.'philea_sync` + WHERE `id_sale` = '.(int) $id_sale.' + ')) { + Db::getInstance()->execute(' + INSERT INTO `'._DB_PREFIX_.'philea_sync` + VALUES ( + DEFAULT, + '.(int) $id_sale.', + 5, + NOW(), + 0 + ) + '); + echo '

'.$this->l('Sale added to queue successfully').'


'; + } else { + echo '

'.$this->l('Sync already in progress for this sale').'


'; + } + } else { + echo '

'.$this->l('Invalid sale id').'


'; + } + } elseif(Tools::isSubmit('philea_archive_submit')){ $id_sales = Tools::getValue('id_sales'); if (count($id_sales)){ @@ -405,6 +454,9 @@ class AdminPhileaMagistor extends AdminTab { .table td .button{ padding: 5px 2px; } + .table td i.glyphicon{ + margin-right: 8px; + } .div_report_overlay{ background: rgb(181,189,200); /* Old browsers */ background: -moz-linear-gradient(top, rgba(181,189,200,0.4) 0%, rgba(130,140,149,0.4) 36%, rgba(40,52,59,0.4) 100%); /* FF3.6+ */ @@ -478,6 +530,23 @@ class AdminPhileaMagistor extends AdminTab { ); } + $id_non_philea_sales = array(); + foreach(Db::getInstance()->ExecuteS(' + SELECT p.`id_sale`, c.`name`, c.`id_category` + FROM `'._DB_PREFIX_.'privatesale` p + LEFT JOIN `'._DB_PREFIX_.'category_lang` c ON (c.`id_category` = p.`id_category`) + WHERE c.`id_lang` = '.$cookie->id_lang.' + AND p.`id_sale` NOT IN ('.implode(',',$philea_sales).') + AND p.`date_start` > DATE_SUB(NOW(), INTERVAL 3 MONTH) + ORDER BY p.`id_sale` DESC + ') as $row) { + $extrafields = Category::getSalesInfos(array((int) $row['id_category'])); + $id_non_philea_sales[] = array( + 'label' => (int) $row['id_sale'].' - '.$row['name'].(empty($extrafields[(int) $row['id_category']]['sales'][1])?'':' - '.$extrafields[(int) $row['id_category']]['sales'][1]) , + 'value' => (int) $row['id_sale'] + ); + } + $helperForm = new HelperFormBootstrap(); $helperForm->_select2 = true; $helperForm->_inputMask = true; @@ -602,6 +671,17 @@ class AdminPhileaMagistor extends AdminTab { $form .= '

Ventes Philéa

+
+
+ + + +
+
@@ -643,12 +723,13 @@ class AdminPhileaMagistor extends AdminTab { $auto_sync = (isset($CRR['auto_sync_active']) && $CRR['auto_sync_active']) ? true : false; $title = ($auto_sync ? $this->l('Désactiver l\'envoi automatique pour la vente') : $this->l('Activer l\'envoi automatique pour la vente') ); - if (isset($CRR['date_end']) && $CRR['date_end'] >= $now) + if (isset($CRR['date_end']) && $CRR['date_end'] >= $now && isset($CRR['id_shipping']) && $CRR['id_shipping']==1){ $auto_sync_btn = ''; - else + }else{ $auto_sync_btn = ''; + } - $submit_link = $upload_link;// . '&id_sale=' . (int) $CRR['id_sale'] . '&addCDC=1'; + $submit_link = (isset($CRR['id_shipping']) && $CRR['id_shipping']==1)?$upload_link:$upload_link.'&id_sale=' . (int) $CRR['id_sale'] . '&send_to_philea=1'; $art_reports = Db::getInstance()->executeS(' SELECT `report_data`, `report_date`, `id_sale` @@ -702,7 +783,7 @@ class AdminPhileaMagistor extends AdminTab { } $form .= ' - '.$auto_sync_btn.' + '.$auto_sync_btn.' @@ -800,6 +881,11 @@ class AdminPhileaMagistor extends AdminTab {