diff --git a/modules/ant_logistic/AdminAntLogistic.php b/modules/ant_logistic/AdminAntLogistic.php index fe527e53..a08b61ff 100644 --- a/modules/ant_logistic/AdminAntLogistic.php +++ b/modules/ant_logistic/AdminAntLogistic.php @@ -1,5 +1,5 @@ ';var_dump($data);echo '';die(); - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/OptionInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/AbstractOption.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/PrefixableCommandInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/CommandInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/AbstractCommand.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/PrefixableCommand.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/PubSubPublish.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/ConnectionInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/SingleConnectionInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/AbstractConnection.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/StreamConnection.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/ConnectionParametersInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/ConnectionParameters.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/ConnectionFactoryInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/ConnectionFactory.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Profile/ServerProfileInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Profile/ServerProfile.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Profile/ServerVersion26.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientCluster.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientPrefix.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientExceptions.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientReplication.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientConnectionFactory.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientProfile.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientOptionsInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientOptions.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/BasicClientInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/ClientInterface.php'; - require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Client.php'; $redis = new Predis\Client(); @@ -144,13 +117,15 @@ class AdminAntLogistic extends AdminTab { return TRUE; } - public function postProcess() { + public function postProcess() + { global $cookie, $logistics_carriers; - if( - ((int) $cookie->profile == 1 || (int) $cookie->profile == 9 || (int) $cookie->profile == 7 || (int) $cookie->profile == 14) - && ($delete_number = Tools::getValue('delete_number')) - ){ + // Delete number + if(( in_array((int)$cookie->profile, array(1,9,7,13,14)) ) + && ( $delete_number = Tools::getValue('delete_number') )) { + + // Suppression LAPOSTE if($delete = (int) Tools::getValue('delete_laposte')) { Db::getInstance()->ExecuteS(' DELETE FROM `'._DB_PREFIX_.'lapostews` @@ -172,7 +147,9 @@ class AdminAntLogistic extends AdminTab { AND `shipping_number` = "'.pSQL($delete_number).'" '); } - } elseif($delete = (int) Tools::getValue('delete_exapaq')) { + } + // Suppression EXAPAQ + elseif ($delete = (int) Tools::getValue('delete_exapaq')) { Db::getInstance()->ExecuteS(' DELETE FROM `'._DB_PREFIX_.'exapaqws` WHERE `id_order_detail` = '.$delete.' @@ -190,7 +167,9 @@ class AdminAntLogistic extends AdminTab { AND `shipping_number` = "'.pSQL($delete_number).'" '); } - } elseif($delete = (int) Tools::getValue('delete_mondialrelay')) { + } + // Suppression MONDIAL RELAY + elseif ($delete = (int) Tools::getValue('delete_mondialrelay')) { Db::getInstance()->ExecuteS(' DELETE FROM `'._DB_PREFIX_.'mondialrelay_parcel` WHERE `id_order_detail` = '.$delete.' @@ -209,7 +188,28 @@ class AdminAntLogistic extends AdminTab { '); } } + // Suppression PHILEA + elseif ($delete = (int) Tools::getValue('delete_philea')) { + Db::getInstance()->ExecuteS(' + DELETE FROM `'._DB_PREFIX_.'philea_parcel` + WHERE `id_order_detail` = '.$delete.' + AND `shipping_number` = "'.pSQL($delete_number).'" + '); + if(!Db::getInstance()->getRow(' + SELECT `shipping_number` + FROM `'._DB_PREFIX_.'philea_parcel` + WHERE `shipping_number` = "'.pSQL($delete_number).'" + ')) { + Db::getInstance()->ExecuteS(' + DELETE FROM `'._DB_PREFIX_.'shipping_history` + WHERE `id_order` = '.(int) Tools::getValue('id_order').' + AND `shipping_number` = "'.pSQL($delete_number).'" + '); + } + } + + // Pour les commandes et les articles mise à jours en commande non envoyé, simplement payé $id_order_details = array(); foreach(Db::getInstance()->ExecuteS(' SELECT `id_order_detail` @@ -250,7 +250,7 @@ class AdminAntLogistic extends AdminTab { // Generate a new shipping number for product sent with many parcels if( (Tools::isSubmit('submitReprintShip')) - && ((int) $cookie->profile == 1 || (int) $cookie->profile == 9 || (int) $cookie->profile == 7 || (int) $cookie->profile == 14) + && in_array((int)$cookie->profile, array(1,9,7,13,14)) && ( ($id_order = Tools::getValue('id_order_reprint')) && ($products = Tools::getValue('products_reprint')) @@ -260,8 +260,8 @@ class AdminAntLogistic extends AdminTab { $weight = 0.24; $order = new Order((int) $id_order); if(Validate::isLoadedObject($order)) { - $parcel_carrier == 'laposte'? $weight = 0.24: TRUE; - if($parcel_carrier == "laposte" || $parcel_carrier == "mondialrelay") { + $parcel_carrier == 'laposte' ? $weight = 0.24 : true; + if ($parcel_carrier == 'laposte' || $parcel_carrier == 'mondialrelay') { $result = $logistics_carriers[$parcel_carrier]->registerParcel($order, $products, $weight); if($result[0] != '') { $this->_html .= $result[0]; diff --git a/modules/ant_logistic/ajax.php b/modules/ant_logistic/ajax.php index 1154a4ff..cbe3cced 100644 --- a/modules/ant_logistic/ajax.php +++ b/modules/ant_logistic/ajax.php @@ -1,5 +1,5 @@ 'SO à domicile', @@ -44,9 +44,10 @@ $laposte_carriers = array_map('intval',explode(',', Configuration::get('ANT_CARR $ooh = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_OOH'))); if(($id_order = (int) Tools::getValue('id_order')) -&& (Tools::getValue('token') === Tools::getAdminToken('AdminAntLogistic'.(int) Tab::getIdFromClassName('AdminAntLogistic').(int) Tools::getValue('id_employee')))) { + && (Tools::getValue('token') === Tools::getAdminToken('AdminAntLogistic'.(int) Tab::getIdFromClassName('AdminAntLogistic').(int) Tools::getValue('id_employee')))) { + + $profile = Tools::getValue('id_profile'); $order = new Order($id_order); - $profile = Tools::getValue('id_profil'); if(Validate::isLoadedObject($order)) { $locked_products = array(); $_locked_products = Configuration::get('LOGISTICS_LOCK'); @@ -89,9 +90,7 @@ if(($id_order = (int) Tools::getValue('id_order')) AND cl.`id_lang` = 2 '); } elseif(in_array((int) $order->id_carrier, $mr_carriers)) { - /** - * @Override MondialRelay - */ + // MondialRelay $delivery_infos_mr = Db::getInstance()->getRow(' SELECT mr_s.*, mr_m.*, cl.`name` AS `country_name` FROM `'._DB_PREFIX_.'mr_selected` mr_s @@ -109,7 +108,6 @@ if(($id_order = (int) Tools::getValue('id_order')) WHERE s.`id_cart` = '.(int) $order->id_cart.' '); } - // $delivery_infos_laposte = FALSE; } $delivery_infos_exapaq = Db::getInstance()->getRow(' @@ -151,41 +149,39 @@ if(($id_order = (int) Tools::getValue('id_order')) $link = new Link(2); $products = array(); foreach($order->getProductsDetail() as $p) { + // --- Get quantity sent + // LaPoste $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'].' '); + // Exapaq $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 - */ + // MondialRelay $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' SELECT IFNULL(SUM(`quantity`), 0) FROM `'._DB_PREFIX_.'mondialrelay_parcel` WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . ' '); - /** - * @Override Philea - */ + // 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 - */ + // 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'] . ' '); + // Image $p['id_image'] = 0; if((int) $p['product_attribute_id'] != 0) { @@ -237,45 +233,42 @@ if(($id_order = (int) Tools::getValue('id_order')) $p['carriers'] = $sales_carriers[(int) $p['id_sale']]; - $p['location'] = isset($locations[(int) $p['product_id'].'-'.(int) $p['product_attribute_id']])? $locations[(int) $p['product_id'].'-'.(int) $p['product_attribute_id']]: ''; - + // --- Get Shipping Numbers $shipping_numbers = array(); + // Philea foreach(Db::getInstance()->ExecuteS(' SELECT l.`shipping_number` - FROM `'._DB_PREFIX_.'lapostews` l + 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']).'"'; } + // LaPoste foreach(Db::getInstance()->ExecuteS(' - SELECT e.`shipping_number` - FROM `'._DB_PREFIX_.'exapaqws` e - LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = e.`id_order_detail`) + SELECT l.`shipping_number` + FROM `'._DB_PREFIX_.'lapostews` 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']).'"'; } - /* - * @Override MondialRelay - */ + // Exapaq foreach(Db::getInstance()->ExecuteS(' - SELECT l.`shipping_number` - FROM `'._DB_PREFIX_.'mondialrelay_parcel` l - LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`) + SELECT e.`shipping_number` + FROM `'._DB_PREFIX_.'exapaqws` e + LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = e.`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']).'"'; } - /* - * @Override Philea - */ + // MondialRelay foreach(Db::getInstance()->ExecuteS(' SELECT l.`shipping_number` - FROM `'._DB_PREFIX_.'philea_parcel` l + FROM `'._DB_PREFIX_.'mondialrelay_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.' @@ -283,15 +276,15 @@ if(($id_order = (int) Tools::getValue('id_order')) $shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"'; } - if(((int) $p['product_quantity_sent'] === 0) - && Db::getInstance()->getRow(' + if(((int) $p['product_quantity_sent'] === 0) && Db::getInstance()->getRow(' SELECT h.`id_sale` FROM `'._DB_PREFIX_.'shipping_history` h WHERE h.`id_sale` = '.((int) $p['id_sale'] === 999999? 0: (int) $p['id_sale']).' AND h.`id_order` = '.(int) $order->id.' '.(count($shipping_numbers) > 0? 'AND h.`shipping_number` NOT IN ('.implode(', ', $shipping_numbers).')': '').' ')) { - $p['product_quantity_sent'] = $p['product_quantity'] - ($p['product_quantity_return'] > 0? $p['product_quantity_return']: $p['product_quantity_refunded']); + $p['product_quantity_sent'] = $p['product_quantity'] - ( $p['product_quantity_return'] > 0 ? + $p['product_quantity_return']: $p['product_quantity_refunded'] ); } /* Pack */ @@ -317,64 +310,78 @@ if(($id_order = (int) Tools::getValue('id_order')) $carriers[(int) $row['id_carrier']] = $row['name']; } - if(count($id_order_details) > 0) { + if (count($id_order_details) > 0) { $logs = array(); + // Send by PHILEA if($l = Db::getInstance()->ExecuteS(' - SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, e.`firstname`, e.`lastname`, "laposte" AS `carrier` - FROM `'._DB_PREFIX_.'lapostews` l + SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, "Philea" as firstname, + (CASE c.`external_module_name` WHEN "soflexibilite" THEN "laposte" ELSE c.`external_module_name` END) as carrier, + "1" as philea + 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); + } + + // Send by LAPOSTE + if($l = Db::getInstance()->ExecuteS(' + SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, + e.`firstname`, e.`lastname`, "laposte" as carrier, "0" as philea + FROM `'._DB_PREFIX_.'lapostews` l LEFT JOIN `'._DB_PREFIX_.'employee` e ON l.`id_employee` = e.`id_employee` 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 `ps_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); } + + // Send by EXAPAQ if($l = Db::getInstance()->ExecuteS(' - SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, e.`firstname`, e.`lastname`, "exapaq" AS `carrier` - FROM `'._DB_PREFIX_.'exapaqws` l + SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, + e.`firstname`, e.`lastname`, "exapaq" as carrier, "0" as philea + FROM `'._DB_PREFIX_.'exapaqws` l LEFT JOIN `'._DB_PREFIX_.'employee` e ON l.`id_employee` = e.`id_employee` 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); } - /* - * @Override MondialRelay - */ + + // Send by MONDIAL RELAY if($l = Db::getInstance()->ExecuteS(' - SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, e.`firstname`, e.`lastname`, "mondialrelay" AS `carrier` - FROM `'._DB_PREFIX_.'mondialrelay_parcel` l - LEFT JOIN `'._DB_PREFIX_.'employee` e ON l.`id_employee` = e.`id_employee` + SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, + e.`firstname`, e.`lastname`, "mondialrelay" as carrier, "0" as philea + FROM `'._DB_PREFIX_.'mondialrelay_parcel` l + LEFT JOIN `'._DB_PREFIX_.'employee` e ON l.`id_employee` = e.`id_employee` 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 `ps_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); } - /* - * @Override Dropshipping - */ + + // Send by DROPSHIPPING if($l = Db::getInstance()->ExecuteS(' - SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, "Dropshipping" as firstname - FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` l - LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`id_order_detail` = l.`id_order_detail` - 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); - } - /* - * @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 + SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, + "Dropshipping" as firstname, "0" as philea + FROM `'._DB_PREFIX_.'ant_dropshipping_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` @@ -452,20 +459,20 @@ if(($id_order = (int) Tools::getValue('id_order')) $html_products = ''; foreach($products as $key => $p) { $html_products.=' - 0 ? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']) - $products[$key]['product_quantity_sent'] > 0) && (in_array((int)($products[$key]['id_sale']), $sales_list)) ? '' : 'grey') + .(max(in_array($products[$key]['product_id'], $locked_products)? 0: ($products[$key]['product_quantity'] - ($products[$key]['product_quantity_refunded'] > 0? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']) - $products[$key]['product_quantity_sent']), 0) > 1 ? ' blue' : '') + .'"'; if(isset($p['items_pack'])){ foreach($p['items_pack'] as $item){ $html_products.='data-pack_'.$item['id_product'].'="'.$item['pack_quantity'].'"'; } } $html_products.=' - > + > '.(isset($p['items_pack'])?'LOT':'').' '.str_replace(' - ','
',$products[$key]['product_name']).'
'.($products[$key]['product_reference']? $products[$key]['product_reference'].'
': '').($products[$key]['product_ean13']? $products[$key]['product_ean13']: '').($products[$key]['location']?'
'.$products[$key]['location'].'': '').' @@ -476,7 +483,7 @@ if(($id_order = (int) Tools::getValue('id_order')) '; if ($products[$key]['id_shipping'] != 2 - || ($products[$key]['id_shipping'] == 2 && ($profile == 1 || $profile == 7)) + || ($products[$key]['id_shipping'] == 2 && in_array((int)$profile, array(1,7))) ) { if(isset($p['items_pack'])){ $html_products.=''; @@ -514,7 +521,7 @@ if(($id_order = (int) Tools::getValue('id_order')) '; if ($products[$key]['id_shipping'] != 2 - || ($products[$key]['id_shipping'] == 2 && ($profile == 1 || $profile == 7)) + || ($products[$key]['id_shipping'] == 2 && in_array((int)$profile, array(1,7))) ) { $html_products.='+-'; } @@ -538,18 +545,18 @@ if(($id_order = (int) Tools::getValue('id_order')) '.$logs[$key]['product_supplier_reference'].' '.$logs[$key]['shipping_number'].' '.(($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ? $carrier_names[$logs[$key]['carrier']] : $logs[$key]['carrier']) .' - '.(((int) $profile == 1 || (int) $profile == 9 || (int) $profile == 7 || (int) $profile == 14)? - (($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ?'': ''):'').' - '.(((int) $profile == 1 || (int) $profile == 9 || (int) $profile == 7 || (int) $profile == 14)? - (($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ?'",$logs[$key]['product_name']).'" data-weight="'.((float)$logs[$key]['weight']>0?(float)$logs[$key]['weight']:0.24).'" data-ref="'.$logs[$key]['product_reference'] .'" data-id_order="'.$order->id.'" data-carrier="'.$logs[$key]['carrier'].'" data-id_order_detail="'.$logs[$key]['id_order_detail'].'">': ''):'').' + '.(( in_array((int)$profile, array(1,9,7,13,14)) ) ? + (($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ? '': ''):'').' + '.(( in_array((int)$profile, array(1,9,7,13,14)) )? + (($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ? '",$logs[$key]['product_name']).'" data-weight="'.((float)$logs[$key]['weight']>0?(float)$logs[$key]['weight']:0.24).'" data-ref="'.$logs[$key]['product_reference'] .'" data-id_order="'.$order->id.'" data-carrier="'.$logs[$key]['carrier'].'" data-id_order_detail="'.$logs[$key]['id_order_detail'].'">': ''):'').' '; } $html_form ='
'; - if( - (in_array($order->id_carrier, $laposte_carriers) || in_array($order->id_carrier, $mr_carriers)) - && in_array((int)($delivery_address->id_country), array(1, 2, 3, 6, 8, 10, 12, 13, 15, 17, 26, 40, 148, 245)) - ){ + if((in_array($order->id_carrier, $laposte_carriers) + || in_array($order->id_carrier, $mr_carriers)) + && in_array((int)($delivery_address->id_country), + array(1, 2, 3, 6, 8, 10, 12, 13, 15, 17, 26, 40, 148, 245)) ){ $html_form.= '
@@ -571,13 +578,13 @@ if(($id_order = (int) Tools::getValue('id_order'))
'; echo json_encode(array( - 'errors' => FALSE, - 'html_detail' => (String)$html_detail, - 'html_invoice_address' => (String)$html_invoice_address, - 'html_delivery_address' => (String)$html_delivery_address, - 'html_products' => (String)$html_products, - 'html_logs' => (String)$html_logs, - 'html_form' => (String)$html_form, + 'errors' => false, + 'html_detail' => (string)$html_detail, + 'html_invoice_address' => (string)$html_invoice_address, + 'html_delivery_address' => (string)$html_delivery_address, + 'html_products' => (string)$html_products, + 'html_logs' => (string)$html_logs, + 'html_form' => (string)$html_form, 'order' => $order, 'products' => $products, 'status' => $status['name'], diff --git a/modules/ant_logistic/script.js b/modules/ant_logistic/script.js index ee88e4ca..a8c3a03a 100644 --- a/modules/ant_logistic/script.js +++ b/modules/ant_logistic/script.js @@ -234,32 +234,32 @@ function checkEAN() { clearTimeout(ean_timeout); ean_timeout = setTimeout(function() { var eanval = $("#eaninput").val(); - if(eanval != "") { - var eanval_item = $("#button_form tbody tr").filter(function() { - if($(this).attr("rel") != eanval) { + if (eanval != "") { + /* Select simple product */ + var eanval_item = $("#button_form tbody tr").filter(function() { + if ($(this).attr("rel") != eanval) { return $(this).attr("rel") == '0'+eanval; } return $(this).attr("rel") == eanval; }); - - if(eanval_item.length > 0) { + if (eanval_item.length > 0) { $(eanval_item).each(function(id, el) { var current_val = parseInt($(el).find(".shipped input").val()); var max_val = parseInt($(el).find(".toship strong").text()); - if(current_val < max_val) { + if (current_val < max_val) { qtyUp($(el).find(".shipped a")[0], max_val); } else { var eanval_item_pack = $("#button_form tbody tr").filter(function() { - if($(this).attr("rel") != eanval+'_pack') { + if ($(this).attr("rel") != eanval+'_pack') { return $(this).attr("rel") == '0'+eanval+'_pack'; } return $(this).attr("rel") == eanval+'_pack'; }); - if(eanval_item_pack.length > 0) { + if (eanval_item_pack.length > 0) { $(eanval_item_pack).each(function(id_pack, el_pack) { var current_val = parseInt($(el_pack).find(".shipped input").val()); var max_val = parseInt($(el_pack).find(".toship strong").text()); - if(current_val < max_val) { + if (current_val < max_val) { qtyUp($(el_pack).find(".shipped a")[0], max_val); } else { confirm("Quantité à envoyer déjà atteinte pour ce produit"); @@ -270,18 +270,20 @@ function checkEAN() { } } }); - } else { + } + /* Select pack product */ + else { var eanval_item_pack = $("#button_form tbody tr").filter(function() { - if($(this).attr("rel") != eanval+'_pack') { + if ($(this).attr("rel") != eanval+'_pack') { return $(this).attr("rel") == '0'+eanval+'_pack'; } return $(this).attr("rel") == eanval+'_pack'; - }); - if(eanval_item_pack.length > 0) { + }); + if (eanval_item_pack.length > 0) { $(eanval_item_pack).each(function(id_pack, el_pack) { var current_val = parseInt($(el_pack).find(".shipped input").val()); var max_val = parseInt($(el_pack).find(".toship strong").text()); - if(current_val < max_val) { + if (current_val < max_val) { qtyUp($(el_pack).find(".shipped a")[0], max_val); } else { confirm("Quantité à envoyer déjà atteinte pour ce produit"); diff --git a/modules/logistics/AdminLogistics.php b/modules/logistics/AdminLogistics.php index 7a69d321..89051286 100644 --- a/modules/logistics/AdminLogistics.php +++ b/modules/logistics/AdminLogistics.php @@ -1,22 +1,18 @@ publish( Configuration::get('LOGISTICS_QUEUE_'.(int) $cookie->id_employee), json_encode(array('data' => base64_encode( - /*chr(2).'n'."\n" // Inch mode - .chr(2).'O0100'."\n" // Start position - .chr(2).'L'."\n" - .'C0000'."\n" - .'D11'."\n" - .chr(2).'L'."\n" - .$this->isoreplace($data) - .'Q0001'."\n" // Number of labels to print - .'E'."\n" // End*/ - $data + $data ))) ); } @@ -325,24 +312,12 @@ class AdminLogistics extends AdminTab $logistics_carriers[$parcel_carrier]->addOrderHistory($result[1], $order, $products_sent); } } else { - $this->html .= '

'.$this->l('An error happened during the label rendering').'


'; + $this->_html .= '

'.$this->l('An error happened during the label rendering').'


'; } } - // elseif($parcel_carrier=='mondialrelay' - // && ( - // ($id_order_detail = Tools::getValue('id_order_detail_reprint')) - // && ($weight = Tools::getValue('weight_reprint')) - // ) - // ){ - // $result = $logistics_carriers['mondialrelay']->_getRegisteredParcel(new Order($id_order), $id_order_detail, $products, $weight); - // $render = $logistics_carriers['mondialrelay']->renderLabel(new Order($id_order), $weight, $result[1]); - // $this->printLabel($render,true); - // } } - //$this->printLabel($logistics_carriers['laposte']->renderLabel(new Order((int) $id_order), $weight, $reprint_number)); } elseif(Tools::isSubmit('submitTestLaposte')) { $this->_html .= '

'.$this->l('Registration complete, label sent to printer').'


'; - //$this->printLabel($logistics_carriers['laposte']->renderLabel(new Order(23336), 0.24, '6A12345123451')); $this->printLabel($logistics_carriers['laposte']->renderLabel(new Order(223001), 0.24, '6J12345123451')); } elseif(Tools::isSubmit('submitTestExapaq')) { $this->_html .= '

'.$this->l('Registration complete, label sent to printer').'


'; @@ -500,10 +475,6 @@ class AdminLogistics extends AdminTab public function display() { global $cookie, $logistics_carriers; - /*if(!in_array($cookie->id_employee, array(1, 2, 3, 10, 68, 70, 89, 91))) { - echo 'Fonctionnalité indisponible actuellement'; return; - }*/ - $unavailable_carriers = array(); foreach($logistics_carriers as $name => $class) { diff --git a/modules/logistics/ajax.php b/modules/logistics/ajax.php index ffe20b7a..c4b70cfa 100644 --- a/modules/logistics/ajax.php +++ b/modules/logistics/ajax.php @@ -1,5 +1,5 @@ 'SO à domicile', @@ -42,8 +42,9 @@ function stripaccents($str) { $mr_carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_MR'))); if(($id_order = (int) Tools::getValue('id_order')) -&& (Tools::getValue('token') === Tools::getAdminToken('AdminLogistics'.(int) Tab::getIdFromClassName('AdminLogistics').(int) Tools::getValue('id_employee')))) { - $order = new Order($id_order); + && (Tools::getValue('token') === Tools::getAdminToken('AdminLogistics'.(int) Tab::getIdFromClassName('AdminLogistics').(int) Tools::getValue('id_employee')))) { + + $order = new Order($id_order); if(Validate::isLoadedObject($order)) { $customer = Db::getInstance()->getRow(' @@ -68,9 +69,7 @@ if(($id_order = (int) Tools::getValue('id_order')) AND cl.`id_lang` = 2 '); } elseif(in_array((int) $order->id_carrier, $mr_carriers)) { - /** - * @Override MondialRelay - */ + // MondialRelay $delivery_infos_mr = Db::getInstance()->getRow(' SELECT mr_s.*, mr_m.*, cl.`name` AS `country_name` FROM `'._DB_PREFIX_.'mr_selected` mr_s @@ -88,7 +87,6 @@ if(($id_order = (int) Tools::getValue('id_order')) WHERE s.`id_cart` = '.(int) $order->id_cart.' '); } - // $delivery_infos_laposte = FALSE; } $delivery_infos_exapaq = Db::getInstance()->getRow(' @@ -387,7 +385,7 @@ if(($id_order = (int) Tools::getValue('id_order')) ); echo json_encode(array( - 'errors' => FALSE, + 'errors' => false, 'order' => $order, 'products' => $products, 'status' => $status['name'],