add module ant logistic for test

This commit is contained in:
Marion Muszynski 2017-11-29 14:46:02 +01:00 committed by Michael RICOIS
parent c13496d8e1
commit c978c25373
304 changed files with 107648 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,600 @@
<?php
include_once dirname(__FILE__).'/../../config/config.inc.php';
$laposte_modes = array(
'DOM' => 'SO à domicile',
'RDV' => 'SO sur RDV',
'BPR' => 'SO en bureau de poste',
'ACP' => 'SO en agence ColiPoste',
'CDI' => 'SO en centre de distribution',
'A2P' => 'SO en commerce de proximité',
'MRL' => 'SO à domicile (+?)',
'CIT' => 'SO en espace Cityssimo',
'DOS' => 'SO à domicile contre signature',
'COLI' => 'Colissimo Expert Inter',
'COL' => 'Colissimo Expert France',
'COM' => 'Colissimo Access OM',
'COLD' => 'Colissimo Access France',
'COE' => 'Colissimo Eco OM',
'CORE' => 'Colissimo Service France',
'CDS' => 'Colissimo Expert OM',
'COP' => 'Colissimo Expert Interne',
);
$mr_modes = array(
'24R' => '24R : Livraison dans un Point Relais',
'24L' => '24L : Livraison dans un Point Relais XL',
'24X' => '24X : Livraison dans un Point Relais XXL',
'DRI' => 'DRI : Livraison Colis Drive',
'LD1' => 'LD1 : Livraison à domicile RDC (1 personne)',
'LDS' => 'LDS : Livraison à domicile spécialisée (2 personnes)',
'HOM' => 'HOM : Livraison à domicile spécialisée',
);
function stripaccents($str) {
return preg_replace(
'~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);~i',
'$1',
htmlentities($str, ENT_NOQUOTES, 'UTF-8')
);
}
$mr_carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_MR')));
$laposte_carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_SOCOL')));
$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')))) {
$order = new Order($id_order);
$profile = Tools::getValue('id_profil');
if(Validate::isLoadedObject($order)) {
$locked_products = array();
$_locked_products = Configuration::get('LOGISTICS_LOCK');
if($_locked_products === FALSE || $_locked_products == 0 || $_locked_products == 's:8:"s:1:"0"' || empty($_locked_products)) {
$_locked_products = serialize(array());
}
foreach(unserialize($_locked_products) as $id_s) {
$_s = new Sale($id_s);
foreach($_s->getProducts() as $p) {
$locked_products[] = $p;
}
}
$sales_list = array();
if(isset($_COOKIE['logistics_sales'])) {
foreach(explode('-', $_COOKIE['logistics_sales']) as $chunk) {
$sales_list[] = (int) $chunk;
}
}
$customer = Db::getInstance()->getRow('
SELECT `firstname`, `lastname`, `email`
FROM `'._DB_PREFIX_.'customer`
WHERE `id_customer` = '.(int) $order->id_customer.'
');
$delivery_infos_laposte = FALSE;
$delivery_infos_exapaq = FALSE;
$delivery_infos_mr = FALSE;
if($order->id_carrier == Configuration::get('SOCOLISSIMO_CARRIER_ID')) {
$delivery_infos_laposte = Db::getInstance()->getRow('
SELECT i.*, cl.`name` AS `country_name`
FROM `'._DB_PREFIX_.'socolissimo_delivery_info` i
LEFT JOIN `'._DB_PREFIX_.'country` c
ON i.`cecountry` = c.`iso_code`
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl
ON c.`id_country` = cl.`id_country`
WHERE i.`id_cart` = '.(int) $order->id_cart.'
AND cl.`id_lang` = 2
');
} elseif(in_array((int) $order->id_carrier, $mr_carriers)) {
/**
* @Override MondialRelay
*/
$delivery_infos_mr = Db::getInstance()->getRow('
SELECT mr_s.*, mr_m.*, cl.`name` AS `country_name`
FROM `'._DB_PREFIX_.'mr_selected` mr_s
LEFT JOIN `'._DB_PREFIX_.'country` c ON (mr_s.`MR_Selected_Pays` = c.`iso_code`)
LEFT JOIN `'._DB_PREFIX_.'mr_method` mr_m ON (mr_m.`id_mr_method` = mr_s.`id_method`)
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
WHERE mr_s.`id_cart` = '.(int) $order->id_cart.'
AND cl.`id_lang` = 2
');
if(!$delivery_infos_mr || empty($delivery_infos_mr)) {
$delivery_infos_mr = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'mr_selected` s
INNER JOIN `'._DB_PREFIX_.'mr_method` m ON (m.`id_mr_method` = s.`id_method`)
WHERE s.`id_cart` = '.(int) $order->id_cart.'
');
}
// $delivery_infos_laposte = FALSE;
}
$delivery_infos_exapaq = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'icirelais_selected`
WHERE `id_cart` = '.(int) $order->id_cart.'
');
$status = Db::getInstance()->getRow('
SELECT `name`
FROM `'._DB_PREFIX_.'order_state_lang`
WHERE `id_order_state` = '.(int) $order->getCurrentState().'
AND `id_lang` = 2
');
$locations = array();
foreach(Db::getInstance()->ExecuteS('
SELECT d.`product_id`, d.`product_attribute_id`, IF(IFNULL(a.`location`, "") = "", p.`location`, a.`location`) AS `location`
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'product` p
ON p.`id_product` = d.`product_id`
LEFT JOIN `'._DB_PREFIX_.'product_attribute` a
ON a.`id_product_attribute` = d.`product_attribute_id`
WHERE d.`id_order` = '.(int) $order->id.'
') as $row) {
$locations[(int) $row['product_id'].'-'.(int) $row['product_attribute_id']] = $row['location'];
}
$invoice_address = new Address($order->id_address_invoice);
$delivery_address = new Address($order->id_address_delivery);
$france_address_error = FALSE;
$france_address_suggestions = array();
$id_order_details = array();
$sales_carriers = array();
$link = new Link(2);
$products = array();
foreach($order->getProductsDetail() as $p) {
$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'].'
');
$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)
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;
if((int) $p['product_attribute_id'] != 0) {
$img = Db::getInstance()->getRow('
SELECT `id_image`
FROM `'._DB_PREFIX_.'product_attribute_image`
WHERE `id_product_attribute` = '.(int) $p['product_attribute_id'].'
');
$p['id_image'] = $img['id_image'];
}
if($p['id_image'] == 0) {
$img = Db::getInstance()->getRow('
SELECT `id_image`
FROM `'._DB_PREFIX_.'image`
WHERE `cover` = 1
AND `id_product` = '.(int) $p['product_id'].'
');
$p['id_image'] = $img['id_image'];
}
$p['image'] = '//'.$link->getImageLink('image', $p['product_id'].'-'.$p['id_image'], 'home');
$p['id_shipping'] = 1;
$p['id_sale'] = (int) Db::getInstance()->getValue('
SELECT `id_sale`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_product` = '.(int) $p['product_id'].'
');
$p['is_pending'] = Db::getInstance()->getValue('
SELECT COUNT(id_product)
FROM `'._DB_PREFIX_.'logistics_pending`
WHERE `id_product` = '.(int) $p['product_id'].' AND id_order = '.(int)$id_order
);
if(!isset($sales_carriers[(int) $p['id_sale']])) {
$sales_carriers[(int) $p['id_sale']] = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `id_carrier`
FROM `'._DB_PREFIX_.'privatesale_carrier`
WHERE `id_sale` = '.(int) $p['id_sale'].'
') as $row) {
$sales_carriers[(int) $p['id_sale']][] = (int) $row['id_carrier'];
}
}
$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']]: '';
$shipping_numbers = array();
foreach(Db::getInstance()->ExecuteS('
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']).'"';
}
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`)
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
*/
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`)
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
*/
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('
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']);
}
/* Pack */
if(Pack::isPack($p['product_id'])){
$p['items_pack'] = Pack::getCompleteSimplePack((int) $p['product_id']);
}
$products[] = $p;
$id_order_details[] = (int) $p['id_order_detail'];
}
$id_carriers = array((int) $order->id_carrier);
foreach(array_values($sales_carriers) as $c) {
$id_carriers = array_merge($id_carriers, $c);
}
$carriers = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `id_carrier`, `name`
FROM `'._DB_PREFIX_.'carrier`
WHERE `id_carrier` IN ('.implode(', ', array_unique($id_carriers)).')
') as $row) {
$carriers[(int) $row['id_carrier']] = $row['name'];
}
if(count($id_order_details) > 0) {
$logs = array();
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
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`
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);
}
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
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`
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
*/
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`
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 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
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();
}
// Carriers
$_carriers = $carriers[$order->id_carrier].($delivery_infos_laposte
? ' ('.$laposte_modes[$delivery_infos_laposte['delivery_mode']].')'
: ($delivery_infos_exapaq
? ' (ICI Relais)'
: ($delivery_infos_mr
? ' ('.$mr_modes[$delivery_infos_mr['dlv_mode']].')'
: ''
)
)
);
$html_detail = '<ul class="list-unstyled">
<li style="margin-bottom:5px;" class="text-center"><strong>'.$status['name'].'</strong></li>
<li><span class="anticon anticon-cart"></span> '.$order->id_cart.'</li>
<li><span class="anticon anticon-user"></span> '.$customer['firstname'].' '.$customer['lastname'].' ('.$customer['email'].')'.'</li>
<li><span class="anticon anticon-calendar"></span> '.date('d/m/Y H:i:s',strtotime($order->date_add)).'</li>
<li><span class="anticon anticon-'.($order->payment=='Paybox'?'credit-card':'paypal').'"></span> '.$order->payment.'</li>
<li><span class="anticon anticon-truck"></span> '.$_carriers.'</li>
</ul>';
$html_invoice_address = ($invoice_address->company? $invoice_address->company.'<br />':'')
.$invoice_address->firstname.' '.$invoice_address->lastname.'<br />'
.($invoice_address->address1? $invoice_address->address1.'<br />': '')
.($invoice_address->address2? $invoice_address->address2.'<br />': '')
.$invoice_address->postcode.' '.$invoice_address->city.'<br />'
.($invoice_address->country? $invoice_address->country.'<br />':'')
.($invoice_address->phone? $invoice_address->phone.'<br />':'')
.($invoice_address->phone_mobile? $invoice_address->phone_mobile.'<br />':'');
if(in_array((int) $order->id_carrier,$ooh) && in_array((int) $order->id_carrier,$mr_carriers)){
$html_delivery_address = ($delivery_address->company? $delivery_address->company.'<br />':'')
.$delivery_address->firstname.' '.$delivery_address->lastname.'<br />'
.($delivery_infos_mr['MR_Selected_LgAdr1']?$delivery_infos_mr['MR_Selected_LgAdr1'].'<br />':'')
.($delivery_infos_mr['MR_Selected_LgAdr2']?$delivery_infos_mr['MR_Selected_LgAdr2'].'<br />':'')
.($delivery_infos_mr['MR_Selected_LgAdr3']?$delivery_infos_mr['MR_Selected_LgAdr3'].'<br />':'')
.($delivery_infos_mr['MR_Selected_LgAdr4']?$delivery_infos_mr['MR_Selected_LgAdr4'].'<br />':'')
.$delivery_infos_mr['MR_Selected_CP'].' '.$delivery_infos_mr['MR_Selected_Ville'].'<br />'
.$delivery_infos_mr['MR_Selected_Pays'].'<br />';
} elseif (in_array((int) $order->id_carrier,$ooh) && in_array((int) $order->id_carrier,$laposte_carriers) && $delivery_infos_laposte){
$html_delivery_address = ($delivery_infos_laposte['prcompladress']? $delivery_infos_laposte['prcompladress'].'<br />': '')
.$delivery_infos_laposte['prfirstname'].' '.$delivery_infos_laposte['prname'].'<br />'
.$delivery_infos_laposte['cefirstname'].' '.$delivery_infos_laposte['cename'].'<br />'
.($delivery_infos_laposte['pradress1']? $delivery_infos_laposte['pradress1'].'<br />': '')
.($delivery_infos_laposte['pradress2']? $delivery_infos_laposte['pradress2'].'<br />': '')
.($delivery_infos_laposte['pradress3']? $delivery_infos_laposte['pradress3'].'<br />': '')
.($delivery_infos_laposte['pradress4']? $delivery_infos_laposte['pradress4'].'<br />': '')
.$delivery_infos_laposte['przipcode'].' '.$delivery_infos_laposte['prtown'].'<br />'
.$delivery_infos_laposte['country_name'].'<br />'
.($delivery_infos_laposte['cephonenumber']? $delivery_infos_laposte['cephonenumber'].'<br />':'');
} else {
$html_delivery_address = ($delivery_address->company? $delivery_address->company.'<br />':'')
.$delivery_address->firstname.' '.$delivery_address->lastname.'<br />'
.($delivery_address->address1? $delivery_address->address1.'<br />':'')
.($delivery_address->address2? $delivery_address->address2.'<br />':'')
.$delivery_address->postcode.' '.$delivery_address->city.'<br />'
.($delivery_address->country? $delivery_address->country.'<br />':'')
.($delivery_address->phone? $delivery_address->phone.'<br />':'')
.($delivery_address->phone_mobile? $delivery_address->phone_mobile.'<br />':'');
}
$html_products = '';
foreach($products as $key => $p) {
$html_products.='
<tr data-weight="'.((float)($products[$key]['product_weight']) == 0.001? 0.24: $products[$key]['product_weight']).'" data-carrier="'.implode(',',$products[$key]['carriers']).'" rel="'.($products[$key]['product_ean13']? $products[$key]['product_ean13']: '').'"
class="'
.($products[$key]['id_shipping'] == 2? 'fed_ship': '')
.(in_array($products[$key]['product_id'], $locked_products)? 'blocked': '')
.(($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) && (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.='
>
<td>'.(isset($p['items_pack'])?'<strong>LOT</strong>':'<img src="'.$products[$key]['image'].'" alt="" width="200" height="200" />').'</td>
<td style="font-size:16px;"><strong>'.str_replace(' - ','<br>',$products[$key]['product_name']).'</strong></td>
<td class="right">'.($products[$key]['product_reference']? $products[$key]['product_reference'].'<br />': '').($products[$key]['product_ean13']? $products[$key]['product_ean13']: '').($products[$key]['location']?'<br /><span class="location">'.$products[$key]['location'].'</span>': '').'</td>
<td class="right" style="display: none;">'.($products[$key]['product_supplier_reference']? $products[$key]['product_supplier_reference']: '').'</td>
<td class="center"><span style="font-size:18px;opacity:0.4">'.$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'].'</span></td>
<td style="font-size:18px;" class=" center toship'.($products[$key]['product_quantity'] - $products[$key]['product_quantity_return'] - $products[$key]['product_quantity_sent'] == 0? ' bg-danger': '').'"><strong>'.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).'</strong></td>
<td class="center"><input type="checkbox" name="product_ids[]" value="'.$products[$key]['product_id'].'" '.($products[$key]['is_pending']>0?'checked disabled':'').'/></td>
<td class="shipped text-center">';
if ($products[$key]['id_shipping'] != 2
|| ($products[$key]['id_shipping'] == 2 && ($profile == 1 || $profile == 7))
) {
if(isset($p['items_pack'])){
$html_products.='<input class="input_quantity" readonly="true" onchange="checkParcelCarrier($(this));" name="shipped['.$products[$key]['id_order_detail'].']" type="text" value="0" autocomplete="off" />';
} else {
$html_products.='<input class="input_quantity" readonly="true" onchange="checkParcelCarrier($(this));" name="shipped['.$products[$key]['id_order_detail'].']" type="text" value="0" autocomplete="off" /><span class="qtyblock"><a onclick="qtyUp($(this), '.(in_array($products[$key]['product_id'], $locked_products)? 0: max(($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)).'); return false;">+</a><a class="qty_down" onclick="qtyDown($(this)); return false;">-</a></span>';
}
}
$html_products.='
</td>
</tr>';
if(isset($p['items_pack'])){
foreach($p['items_pack'] as $item){
$link = new Link(2);
$img = Db::getInstance()->getRow('
SELECT `id_image`
FROM `'._DB_PREFIX_.'image`
WHERE `cover` = 1
AND `id_product` = '.(int) $item['id_product'].'
');
$id_image = $img?$img['id_image']:0;
$quantity = ($p['product_quantity']*$item['pack_quantity']) - ($p['product_quantity_return']*$item['pack_quantity']) - ($p['product_quantity_sent']*$item['pack_quantity']);
$html_products.='
<tr class="pack_'.$p['id_order_detail'].' pack_item '
.(in_array($products[$key]['product_id'], $locked_products)? 'blocked': '')
.(($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) && (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': '').'"
data-weight="'.((float)($item['weight']) == 0.001? 0.24: $item['weight']*$item['pack_quantity']).'" rel="'.($item['ean13']? $item['ean13'].'_pack': '').'"
>
<td><img src="'.'//'.$link->getImageLink('image', $item['id_product'].'-'.$id_image, 'home').'"/></td>
<td style="font-size:16px;"><strong>'.str_replace(' - ','<br>',$item['name']).'</strong></td>
<td class="right">'.($item['reference']? $item['reference'].'<br />': '').($item['ean13']? $item['ean13']: '').($item['location']?'<br /><span class="location">'.$item['location'].'</span>': '').'</td>
<td class="right" style="display: none;">'.($item['supplier_reference']? $item['supplier_reference']: '').'</td>
<td></td>
<td style="font-size:18px;" class=" center toship'.($quantity == 0? ' bg-danger': '').'"><strong>'.max(in_array($p['product_id'], $locked_products)? '0': (($p['product_quantity']*$item['pack_quantity']) - (($p['product_quantity_refunded']*$item['pack_quantity']) > 0? $p['product_quantity_refunded']*$item['pack_quantity']: ($p['product_quantity_return']*$item['pack_quantity'])) - ($p['product_quantity_sent']*$item['pack_quantity'])), 0).'</strong></td>
<td></td>
<td class="shipped text-center">';
if ($products[$key]['id_shipping'] != 2
|| ($products[$key]['id_shipping'] == 2 && ($profile == 1 || $profile == 7))
) {
$html_products.='<input data-item="'.$item['id_product'].'" class="input_quantity" readonly="true" onchange="checkQuantityPack($(this),'.$item['id_product'].','.$p['id_order_detail'].','.$item['pack_quantity'].','.(in_array($products[$key]['product_id'], $locked_products)? 0: max(($products[$key]['product_quantity']*$item['pack_quantity'] - ($products[$key]['product_quantity_refunded']*$item['pack_quantity'] > 0? $products[$key]['product_quantity_refunded']*$item['pack_quantity']: $products[$key]['product_quantity_return']*$item['pack_quantity']) - $products[$key]['product_quantity_sent']*$item['pack_quantity']), 0)).');" type="text" value="0" autocomplete="off" /><span class="qtyblock"><a onclick="qtyUp($(this), '.(in_array($products[$key]['product_id'], $locked_products)? 0: max(($products[$key]['product_quantity']*$item['pack_quantity'] - ($products[$key]['product_quantity_refunded']*$item['pack_quantity'] > 0? $products[$key]['product_quantity_refunded']*$item['pack_quantity']: $products[$key]['product_quantity_return']*$item['pack_quantity']) - $products[$key]['product_quantity_sent']*$item['pack_quantity']), 0)).'); return false;">+</a><a class="qty_down" onclick="qtyDown($(this)); return false;">-</a></span>';
}
$html_products.='
</td>
</tr>';
}
}
}
$carrier_names = array('laposte' => 'La Poste', 'mondialrelay' => 'Mondial Relay');
$html_logs = '';
foreach($logs as $key => $log){
$html_logs .=
'<tr>
<td>'.str_replace(" ", "<br />",date('d/m/Y H:i:s',strtotime($logs[$key]['date_add']))).'</td>\
<td>'.(!isset($logs[$key]['lastname'])? $logs[$key]['firstname'] : $logs[$key]['firstname'] .' '.$logs[$key]['lastname']) .'</td>
<td class="text-center">'.$logs[$key]['quantity'].'</td>
<td>'.str_replace(" - ", "<br />",$logs[$key]['product_name']).'</td>\
<td>'.$logs[$key]['product_reference'].'</td>
<td>'.$logs[$key]['product_supplier_reference'].'</td>
<td>'.$logs[$key]['shipping_number'].'</td>
<td>'.(($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ? $carrier_names[$logs[$key]['carrier']] : $logs[$key]['carrier']) .'</td>
'.(((int) $profile == 1 || (int) $profile == 9 || (int) $profile == 7 || (int) $profile == 14)?
(($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ?'<td><a class="need_token" href="/adm/index.php?tab=AdminAntLogistic&id_order='.$order->id.'&delete_'.$logs[$key]['carrier'].'='.$logs[$key]['id_order_detail'].'&delete_number='.$logs[$key]['shipping_number'].'"><span class="anticon anticon-bin"></span></a></td>': '<td></td>'):'<td></td>').'
'.(((int) $profile == 1 || (int) $profile == 9 || (int) $profile == 7 || (int) $profile == 14)?
(($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ?'<td><a title="Re print" data-toggle="modal" data-target="#modalRePrint" class="reprint" data-product="'.str_replace(" - ", "<br />",$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'].'"><span class="anticon anticon-printer"></span></a></td>': '<td></td>'):'<td></td>').'
</tr>';
}
$html_form ='<div class="form-inline">';
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.=
'<div class="form-group">
<label for="parcel_carrier">Transporteur :</label>
<select class="form-control input-sm" onchange="changeCarrier();" id="parcel_carrier" name="parcel_carrier">
<option value="laposte">La Poste</option>
<option value="mondialrelay">Mondial Relay</option>
</select>
</div>';
}
$html_form .= '
<div class="form-group">
<label for="weight">Poids :</label>
<div class="input-group">
<input style="width:60px;" class="form-control input-sm" type="text" value="0" name="weight" id="weight" />
<div class="input-group-addon">kg</div>
</div>
</div>
<input id="button4" onclick="checkPrinting(); return false;" type="submit" class="pull-right btn btn-primary btn-sm" name="submitShip" value="[F1] Enregistrer le colis et imprimer l\'étiquette">
</div>';
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,
'order' => $order,
'products' => $products,
'status' => $status['name'],
'carrier' => $_carriers,
'carriers' => $carriers,
'customer' => $customer['firstname'].' '.$customer['lastname'].' ('.$customer['email'].')',
'invoice_address' => $invoice_address,
'delivery_address' => $delivery_address,
'delivery_infos_laposte' => $delivery_infos_laposte,
'delivery_infos_exapaq' => $delivery_infos_exapaq,
'delivery_infos_mr' => $delivery_infos_mr,
'weight' => $order->getTotalWeight(),
'logs' => $logs,
'france_address_error' => $france_address_error,
'france_address_suggestions' => $france_address_suggestions,
));
} else {
echo json_encode(array('errors' => 'not found'));
}
}

View File

@ -0,0 +1,30 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
class Ant_Logistic extends Module
{
public function __construct()
{
$this->name = 'ant_logistic';
$this->tab = 'administration';
$this->author = 'Antadis';
$this->version = '1.0';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Logistic manager');
$this->description = $this->l('Manager of logistic to send parcel for orders');
}
public function install()
{
# Register hooks
if(!(parent::install())) {
return false;
}
return true;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,108 @@
<?php
if(isset($_SERVER['REMOTE_ADDR'])) {
exit;
}
$_SERVER['HTTP_PORT'] = 80;
include dirname(__FILE__).'/../../../../config/config.inc.php';
$count = (int) Configuration::get('EXAPAQWS_CRONCOUNT') + 1;
if($count > 99) {
Configuration::updateValue('EXAPAQWS_CRONCOUNT', 0);
$count = 1;
}
function stripaccents($str) {
return preg_replace(
'~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);~i',
'$1',
htmlentities($str, ENT_QUOTES, 'UTF-8')
);
}
$csv = fopen(dirname(__FILE__).'/summaries/'.strtolower(str_replace(' ', '', trim(stripaccents(Configuration::get('EXAPAQWS_EXP_COMPANY'))))).date('dmHis').sprintf('%02d', $count).'.txt', 'w');
foreach(Db::getInstance()->ExecuteS('
SELECT *
FROM `'._DB_PREFIX_.'exapaqws_parcel_route`
WHERE `date_add` >= "'.pSQL($lastsummary = Configuration::get('EXAPAQWS_LASTSUMMARY')? $lastsummary: '0000-00-00 00:00:00').'"
ORDER BY `date_add` ASC
') as $row) {
$order = new Order((int) $row['id_order']);
if(!Validate::isLoadedObject($order)) {
// TODO
continue;
}
$delivery_infos = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'icirelais_selected`
WHERE `id_cart` = '.(int) $order->id_cart.'
');
$customer = new Customer((int) $order->id_customer);
$delivery_address = new Address($order->id_address_delivery);
fputcsv($csv, array(
substr($row['shipping_number'], 0, 18), // exapass
number_format($row['weight'], 2, '.', ''), // weight
substr('EXP'.(int) $order->id, 0, 35), // ref 1
'', // ref 2
'', // order id
'', // consolidation
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_EXP_COMPANY'))), 0, 12)), // exp company
date('d.m.Y', strtotime($row['date_add'])), // exp date
date('H:i:s', strtotime($row['date_add'])), // exp time
substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_'.($delivery_infos? 'B2C': 'B2B').'_COUNTRY_RETURN'))), 0, 6), // exp country
substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $row['ac'])), 0, 3), // ac
substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $row['tour'])), 0, 3), // tour
'', // value
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? $delivery_address->lastname.' '.$delivery_address->firstname: ($delivery_address->company != ''? $delivery_address->company.' ': '').$delivery_address->lastname.' '.$delivery_address->firstname)), 0, 35)), // dest name
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? $delivery_infos['address1']: $delivery_address->address1)), 0, 35)), // dest addr 1
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? $delivery_infos['address2']: $delivery_address->address2)), 0, 35)), // dest addr 2
'', // dest addr 3
'', // dest addr 4
'', // dest addr 5
'', // dest addr 6
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? $delivery_infos['postcode']: $delivery_address->postcode)), 0, 10)), // dest postcode
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? $delivery_infos['city']: $delivery_address->city)), 0, 35)), // dest city
substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $row['lpfx'])), 0, 3), // dest country
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_address->phone)), 0, 35)), // dest phone
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_EXP_COMPANY'))), 0, 35)), // exp company
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_EXP_ADDR1'))), 0, 35)), // exp addr 1
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_EXP_ADDR2'))), 0, 35)), // exp addr 2
'', // exp addr 3
'', // exp addr 4
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_EXP_POSTALCODE'))), 0, 10)), // exp postcode
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_EXP_CITY'))), 0, 35)), // exp city
strtoupper(Country::getIsoById((int) Configuration::get('EXAPAQWS_EXP_COUNTRY'))), // exp country
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_EXP_PHONE'))), 0, 30)), // exp phone
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_EXP_EMAIL'))), 0, 80)), // exp email
'', // exp mobile
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $customer->email)), 0, 80)), // dest email
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_address->phone_mobile)), 0, 35)), // dest mobile
'', // consolidation
substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_'.($delivery_infos? 'B2C': 'B2B').'_COUNTRY_AGENCY'))), 0, 6), // country + agency
'', // exasanté
$delivery_infos? 101: 1, // notification options
$delivery_infos? 2: 1, // service type
substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_'.($delivery_infos? 'B2C': 'B2B').'_CHARGING_ACCOUNT'))), 0, 6), // charging account
trim(str_replace(array("\n", "\r", '~', ';', '|'), '', substr($delivery_address->lastname, 0, 30))), // dest lastname
trim(str_replace(array("\n", "\r", '~', ';', '|'), '', substr($delivery_address->firstname, 0, 20))), // dest firstname
trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? substr($delivery_infos['relay_id'], 0, 20): '')), // relay id
trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? substr($delivery_infos['company'], 0, 50): '')), // relay company
trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? substr($delivery_infos['address1'], 0, 40): '')), // relay addr 1
trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? substr($delivery_infos['address2'], 0, 40): '')), // relay addr 2
'', // relay addr 3
trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? substr($delivery_infos['postcode'], 0, 5): '')), // relay postcode
trim(str_replace(array("\n", "\r", '~', ';', '|'), '', $delivery_infos? substr($delivery_infos['city'], 0, 30): '')), // relay city
10, // keeping duration
stripaccents(mb_substr(trim(str_replace(array("\n", "\r", '~', ';', '|'), '', Configuration::get('EXAPAQWS_EXP_COMPANY'))), 0, 35)), // company name
), '|', '"');
}
fclose($csv);

View File

@ -0,0 +1,45 @@
<?php
if(isset($_SERVER['REMOTE_ADDR'])) {
exit;
}
$_SERVER['HTTP_PORT'] = 80;
include dirname(__FILE__).'/../../../../config/config.inc.php';
$file = gzopen(dirname(__FILE__).'/plan2.gz', 'r');
fgets($file);
Db::getInstance()->ExecuteS('
DELETE FROM `'._DB_PREFIX_.'exapaqws_route`
');
while($line = fgets($file)) {
if($line == 'F') {
break;
}
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'exapaqws_route`
VALUES (
"'.pSQL(substr($line, 0, 2)).'",
"'.pSQL(substr($line, 2, 3)).'",
"'.pSQL(substr($line, 5, 10)).'",
"'.pSQL(substr($line, 15, 10)).'",
"'.pSQL(substr($line, 25, 1)).'",
"'.pSQL(substr($line, 26, 2)).'",
"'.pSQL(substr($line, 28, 1)).'",
"'.pSQL(substr($line, 29, 2)).'",
"'.pSQL(substr($line, 32, 3)).'",
"'.pSQL(substr($line, 35, 3)).'",
"'.pSQL(substr($line, 38, 3)).'",
"'.pSQL(substr($line, 41, 3)).'",
"'.pSQL(substr($line, 51, 3)).'",
"'.pSQL(substr($line, 54, 4)).'",
"'.pSQL(substr($line, 58, 1)).'"
)
');
}
gzclose($file);

View File

@ -0,0 +1,746 @@
<?php
if(!defined('_PS_VERSION_')) {
exit;
}
global $exapaq_formats;
$exapaq_formats = array(
'DOM' => '191100005670040Soumis aux conditions générales de vente de la FFOCT et aux conditions
191100005610040particulières de prestation d\'EXAPAQ. Notre responsabilité est contractuellement
191100005540040limitée à EUR 23,00 par KG transporté.
211200005500335EXAPAQ 6
211200005500322FR-06580 PEGOMAS
1Y1100002900320{EXASANTE}
1d0309204560100{EXAPASS_BARCODE}
1X1100005470100l01800003
1X1100004530100l01800003
1X1100002620040b0245018900010001
1X1100002620255l00010188
1X1100000070186b0165025300020002
1e230080000{SHIPPING_ALIGN}{SHIPPING_BC}
1X1100000070113b0071025300010001
1X1100000070040b0040025300010001'
/*FB+
292200203840295G 1/2
FB-*/
.'291100704480250{TOURPRINT}
2911007{TOURALIGN}0250{TOUR}
291100702870250{SMALL}
291100704150215{TRI1}
2911004{LIGNE1_ALIGN}0200{LIGNE1}
291100703150215{TRI2}
2911004{LIGNE2_ALIGN}0200{LIGNE2}
{PRETRI1}
2911008{ACPRINT_ALIGN}0150{ACPRINT}
{PRETRI2}
2e2309203980060C{CBTRI}
191100304330097{EXAPASS_PARCEL}
291100203800042{WEIGHT} kg
291100203200042{DATE}
291100504500010{MSG}
291100102550338Destinataire
291100201950338Tél.: {DADDR_0}
291100302550321{DADDR_1}
291100302550306{DADDR_2}
291100302550291{DADDR_3}
291100302550276{DADDR_4}
291100302550261{DADDR_5}
291100302550246{DADDR_6}
291100302550231{DADDR_7}
FB+
2911A1802550205{LPFX}-{DADDR_8}
FB-
291200202550187{DADDR_9}
291100202550171Expéditeur Tél.: {SADDR_0}
291100202550160{SADDR_1}
291100202550149{SADDR_2}
291100202550138{SADDR_3}
291100202550127{SADDR_4}
291100202550115F-{SADDR_5}
1X1100000070100b0013010000010001
FB+
2911A0801030101Nb.:
2911A08003201011 / 1
FB-
291100202550098N'.chr(248).' réf.:
291100202550085EXP{REFERENCE}
291100202550065{DADDR_INSTR1}
291100202550045{DADDR_INSTR2}
',
'ICI' => '191100005740040ICI Colis est un produit d\'ICI relais, marque appartenant à Exapaq SAS.
191100005670040Soumis aux conditions générales de vente de la FFOCT et aux conditions
191100005610040particulières de prestation d\'EXAPAQ. Notre responsabilité est contractuellement
191100005540040limitée à EUR 23,00 par KG transporté.
291100105780342ICI COLIS
291100105780335www.icirelais.com
1Y1100003400290ICICOLIS
1d0309204560100{EXAPASS_BARCODE}
1X1100005470100l01800003
1X1100004530100l01800003
1X1100002620040b0245018900010001
1X1100002620255l00010188
1X1100000070186b0165025300020002
1e230080000{SHIPPING_ALIGN}{SHIPPING_BC}
1X1100000070113b0071025300010001
1X1100000070040b0040025300010001
291100704480250{TOURPRINT}
2911007{TOURALIGN}0250{TOUR}
291100702870250{SMALL}
291100704150215{TRI1}
2911004{LIGNE1_ALIGN}0200{LIGNE1}
291100703150215{TRI2}
2911004{LIGNE2_ALIGN}0200{LIGNE2}
{PRETRI1}
2911008{ACPRINT_ALIGN}0150{ACPRINT}
{PRETRI2}
2e2309203980060C{CBTRI}
191100304330097{EXAPASS_PARCEL}
291100203800042{WEIGHT} kg
291100203200042{DATE}
291100102550338Destinataire
FB+
2911A1402550315RELAIS : {PR}
FB-
2X1100000090313l00020250
291100102550304Pour :
291100302550290{DADDR_3}
291100302550276{DADDR_4}
2X1100000090274l00020250
291100302550258{DADDR_0}
291100302550244{DADDR_1}
291100302550230F-{DADDR_2}
FB+
2911A0802520213POUR RETOUR CONTACTER L\'EXPEDITEUR
FB-
A5
1X1100000090206l00250249
A2
291100202550171Expéditeur Tél.: {SADDR_0}
291100202550160{SADDR_1}
291100202550149{SADDR_2}
291100202550138{SADDR_3}
291100202550127{SADDR_4}
291100202550115F-{SADDR_5}
1X1100000070100b0013010000010001
FB+
2911A0801030101Nb.:
2911A08003201011 / 1
FB-
291100202550098N'.chr(248).' réf.:
291100202550085EXP{REFERENCE}
291100202550067ICI-PASS
FB+
2911A1202300045{EXAPASS}
FB-
',
);
class ExapaqCarrier {
public $displayName = 'Exapaq';
public function checkavailability() {
return TRUE;
}
public function __toString() {
return $this->displayName;
}
private function stripaccents($str) {
return preg_replace(
'~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);~i',
'$1',
htmlentities($str, ENT_NOQUOTES, 'UTF-8')
);
}
public function registerParcel($order, $products, $weight) {
if((int) Db::getInstance()->getValue('
SELECT `id_cart`
FROM `'._DB_PREFIX_.'icirelais_selected`
WHERE `id_cart` = (
SELECT `id_cart`
FROM `'._DB_PREFIX_.'orders`
WHERE `id_order` = '.(int) $order->id.'
LIMIT 1
)
')) {
$delivery_mode = 'b2c';
} else {
$delivery_mode = 'b2b';
}
$shipping_number = sprintf('%09d', $this->getShippingNumber((int) $order->id));
$exapass = '250'.sprintf('%03d', Configuration::get('EXAPAQWS_'.strtoupper($delivery_mode).'_AGENCYCODE')).$shipping_number;
$key1 = sprintf('%02d', (98 - ((int) $exapass * 100 % 97)) % 97);
$exapass .= $key1;
$i = (int) substr($exapass, 0, 1) + (int) substr($exapass, 2, 1) + (int) substr($exapass, 4, 1) + (int) substr($exapass, 6, 1) + (int) substr($exapass, 8, 1) + (int) substr($exapass, 10, 1) + (int) substr($exapass, 12, 1) + (int) substr($exapass, 14, 1) + (int) substr($exapass, 16, 1);
$p = (int) substr($exapass, 1, 1) + (int) substr($exapass, 3, 1) + (int) substr($exapass, 5, 1) + (int) substr($exapass, 7, 1) + (int) substr($exapass, 9, 1) + (int) substr($exapass, 11, 1) + (int) substr($exapass, 13, 1) + (int) substr($exapass, 15, 1);
$t = ($i * 3) + $p;
$m = ceil($t / 10) * 10;
$key2 = (($m - $t) + 1) % 10;
$exapass .= $key2;
if($_SERVER['REMOTE_ADDR'] != '109.190.53.175' && $_SERVER['REMOTE_ADDR'] != '78.226.56.137' && $_SERVER['REMOTE_ADDR'] != '88.163.22.223') {
$order->shipping_number = $exapass;
$order->id_carrier_shipping = (int) Configuration::get('ICIRELAIS_ID_CARRIER');
$order->update();
}
return array('', array(
'exapass' => $exapass,
'shipping_number' => $shipping_number,
));
}
public function getShippingNumber($id_order) {
if((int) Db::getInstance()->getValue('
SELECT `id_cart`
FROM `'._DB_PREFIX_.'icirelais_selected`
WHERE `id_cart` = (
SELECT `id_cart`
FROM `'._DB_PREFIX_.'orders`
WHERE `id_order` = '.(int) $id_order.'
LIMIT 1
)
')) {
$delivery_mode = 'b2c';
} else {
$delivery_mode = 'b2b';
}
Db::getInstance()->Execute('SET AUTOCOMMIT = 0');
Db::getInstance()->Execute('START TRANSACTION');
$res = Db::getInstance()->ExecuteS('
SELECT `value`
FROM `'._DB_PREFIX_.'logistics_shipping`
WHERE `carrier` = "exapaq"
AND `delivery_mode` = "'.pSQL($delivery_mode).'"
FOR UPDATE
');
$shipping_number = (int) $res[0]['value'] + 1;
Db::getInstance()->ExecuteS('
UPDATE `'._DB_PREFIX_.'logistics_shipping`
SET `value` = "'.(int) $shipping_number.'"
WHERE `carrier` = "exapaq"
AND `delivery_mode` = "'.pSQL($delivery_mode).'"
');
Db::getInstance()->Execute('COMMIT');
Db::getInstance()->Execute('SET AUTOCOMMIT = 1');
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'exapaqws_shippingnumber`
VALUES (
'.(int) $shipping_number.',
'.(int) $id_order.'
)
');
if((int) $shipping_number + 2000 >= (int) Configuration::get('EXAPAQWS_'.strtoupper($delivery_mode).'_SHIPPINGHIGH')) { // TODO: Move to cron
mail('perron@antadis.com', '[PSS] Renouvellement Plage '.strtoupper($delivery_mode).' Exapaq', $shipping_number);
}
return $shipping_number;
}
public function renderLabel($order, $weight, $shipping_data) {
global $cookie, $exapaq_formats;
$exp_firstname = Configuration::get('EXAPAQWS_EXP_FIRSTNAME');
$exp_lastname = Configuration::get('EXAPAQWS_EXP_LASTNAME');
$exp_company = Configuration::get('EXAPAQWS_EXP_COMPANY');
if(!empty($exp_firstname)) {
$sender_lines[] = $exp_firstname.' '.$exp_lastname;
}
if(!empty($exp_company)) {
$sender_lines[] = $exp_company;
}
$sender_lines[] = Configuration::get('EXAPAQWS_EXP_ADDR1');
$sender_lines[] = Configuration::get('EXAPAQWS_EXP_ADDR2');
$sender_line1 = isset($sender_lines[0])? $sender_lines[0]: '';
$sender_line2 = isset($sender_lines[1])? $sender_lines[1]: '';
$sender_line3 = isset($sender_lines[2])? $sender_lines[2]: '';
$sender_line4 = isset($sender_lines[3])? $sender_lines[3]: '';
$sender_postal = Configuration::get('EXAPAQWS_EXP_POSTALCODE');
$sender_city = Configuration::get('EXAPAQWS_EXP_CITY');
$sender_phone = Configuration::get('EXAPAQWS_EXP_PHONE');
if($delivery_infos = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'icirelais_selected`
WHERE `id_cart` = '.(int) $order->id_cart.'
')) {
$delivery_address = new Address((int) $order->id_address_delivery);
if(!Validate::isLoadedObject($delivery_address) || strtoupper(Country::getIsoById($delivery_address->id_country)) != 'FR') {
return FALSE;
}
$route = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'exapaqws_route`
WHERE `iso_code` = "FR"
AND (
("'.pSQL($delivery_infos['postcode']).'" BETWEEN `postcode_start` AND `postcode_end`)
OR (`postcode_start` IS NULL)
OR (`postcode_start` = "")
)
');
if(!$route) {
return 'route_error';
}
$shipping_number = $shipping_data['shipping_number'];
$exapass = $shipping_data['exapass'];
$exapass_legend = substr($exapass, 0, 15);
$i = (int) substr($exapass_legend, 0, 1) + (int) substr($exapass_legend, 2, 1) + (int) substr($exapass_legend, 4, 1) + (int) substr($exapass_legend, 6, 1) + (int) substr($exapass_legend, 8, 1) + (int) substr($exapass_legend, 10, 1) + (int) substr($exapass_legend, 12, 1) + (int) substr($exapass_legend, 14, 1);
$p = (int) substr($exapass_legend, 1, 1) + (int) substr($exapass_legend, 3, 1) + (int) substr($exapass_legend, 5, 1) + (int) substr($exapass_legend, 7, 1) + (int) substr($exapass_legend, 9, 1) + (int) substr($exapass_legend, 11, 1) + (int) substr($exapass_legend, 13, 1);
$t = ($i * 3) + $p;
$m = ceil($t / 10) * 10;
$key3 = $m - $t;
$exapass_legend .= $key3;
$dest_name0 = '';
$dest_name1 = '';
if($delivery_address->company == '') {
$dest_name0 = mb_substr($delivery_address->lastname, 0, 32);
$dest_name1 = mb_substr($delivery_address->firstname, 0, 32);
} else {
$dest_name0 = mb_substr($delivery_address->lastname, 0, 32);
$dest_name1 = mb_substr($delivery_address->company, 0, 32);
}
$shipping_bc = mb_substr(mb_strtoupper($this->stripaccents(str_replace(
array(' ', '', '', '', '“', '”', '„', '†', '‡', '‰', '', '', '♠', '♣', '♥', '♦', '‾', '←', '↑', '→', '↓', '™', '', '!', '“', '#', '$', '%', '&', '', '(', ')', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', ']', '_', '`', '{', '|', '', '}', '~', '', '—', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯', ),
'',
trim($delivery_infos['relay_id'])
))), 0, 12);
$format = str_replace(
array(
'{EXAPASS_BARCODE}',
'{SHIPPING_BC}',
'{SHIPPING_ALIGN}',
'{TOURPRINT}',
'{TOUR}',
'{TOURALIGN}',
'{SMALL}',
'{TRI1}',
'{LIGNE1}',
'{LIGNE1_ALIGN}',
'{TRI2}',
'{LIGNE2}',
'{LIGNE2_ALIGN}',
'{ACPRINT}',
'{ACPRINT_ALIGN}',
'{PRETRI1}',
'{PRETRI2}',
'{CBTRI}',
'{EXAPASS_PARCEL}',
'{WEIGHT}',
'{DATE}',
'{PR}',
'{DADDR_0}',
'{DADDR_1}',
'{DADDR_2}',
'{DADDR_3}',
'{DADDR_4}',
'{SADDR_0}',
'{SADDR_1}',
'{SADDR_2}',
'{SADDR_3}',
'{SADDR_4}',
'{SADDR_5}',
'{REFERENCE}',
'{EXAPASS}',
),
array(
$exapass,
$shipping_bc,
strlen($shipping_bc) == 12? '0103': (strlen($shipping_bc) == 11? '0118': (strlen($shipping_bc) == 10? '0136': (strlen($shipping_bc) == 9? '0153': (strlen($shipping_bc) == 8? '0168': (strlen($shipping_bc) == 7? '0183': (strlen($shipping_bc) == 6? '0198': (strlen($shipping_bc) == 5? '0212': (strlen($shipping_bc) == 4? '0233': (strlen($shipping_bc) == 3? '0248': '0263'))))))))),
trim($route['tourprint']),
trim($route['tour']),
strlen(trim($route['tour'])) == 1? '0368': (strlen(trim($route['tour'])) == 2? '0376': '0384'),
(float) $weight <= 1.0? 'P': '',
trim($route['tri1']),
trim($route['ligne1']),
strlen(trim($route['tri1'])) == 1? '0409': '0413',
trim($route['tri2']),
trim($route['ligne2']),
strlen(trim($route['tri2'])) == 1? '0309': '0313',
trim($route['acprint']),
strlen(trim($route['acprint'])) == 1? '0366': (strlen(trim($route['acprint'])) == 2? '0378': '0390'),
strtoupper(trim($route['pretri'])) == 'BOX'? '1X1100003950162l00250032': '',
strtoupper(trim($route['pretri'])) == 'BOX'? '1X1100002850162l00250032': '',
trim($route['cbtri']),
substr($exapass_legend, 3, 3).' '.substr($exapass_legend, 6, 9).' '.substr($exapass_legend, 15, 1),
number_format($weight * 0.8, 2, '.', ''),
date('d.m.Y'),
$delivery_infos['relay_id'],
mb_substr(mb_strtoupper($this->stripaccents($delivery_infos['company'])), 0, 32),
mb_substr(mb_strtoupper($this->stripaccents($delivery_infos['address1'])), 0, 32),
mb_substr(mb_strtoupper($this->stripaccents($delivery_infos['postcode'].' '.$delivery_infos['city'])), 0, 32),
mb_strtoupper($this->stripaccents($dest_name0)),
mb_strtoupper($this->stripaccents($dest_name1)),
$sender_phone,
$sender_line1,
$sender_line3,
$sender_line4,
$sender_line2,
$sender_postal.' '.$sender_city,
$order->id,
substr($exapass, 0, 3).' '.substr($exapass, 3, 3).' '.substr($exapass, 6, 9).' '.substr($exapass, 15),
),
$exapaq_formats['ICI']
);
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'exapaqws_parcel_route` VALUES (
"'.pSQL($exapass).'",
'.(int) $order->id.',
'.((float) $weight * 0.8).',
"'.pSQL($route['iso_code']).'",
"'.pSQL($route['lpfx']).'",
"'.pSQL($route['tri1']).'",
"'.pSQL($route['ligne1']).'",
"'.pSQL($route['tri2']).'",
"'.pSQL($route['ligne2']).'",
"'.pSQL($route['ac']).'",
"'.pSQL($route['acprint']).'",
"'.pSQL($route['tour']).'",
"'.pSQL($route['tourprint']).'",
"'.pSQL($route['pretri']).'",
"'.pSQL($route['cbtri']).'",
"'.pSQL($route['msg'] == 1? 'EXPORT A REETIQUETER': ($route['msg'] == 2? 'EXPORT A REETIQUETER AU TRI': '')).'"
)
');
return $format;
} else {
$delivery_address = new Address((int) $order->id_address_delivery);
if(!Validate::isLoadedObject($delivery_address)/* || strtoupper(Country::getIsoById($delivery_address->id_country)) != 'FR'*/) {
return FALSE;
}
$route = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'exapaqws_route`
WHERE `iso_code` = "'.pSQL(strtoupper(Country::getIsoById($delivery_address->id_country))).'"
AND (
("'.pSQL($delivery_address->postcode).'" BETWEEN `postcode_start` AND `postcode_end`)
OR (`postcode_start` IS NULL)
OR (`postcode_start` = "")
)
');
if(!$route) {
return 'route_error';
}
$shipping_number = $shipping_data['shipping_number'];
$exapass = $shipping_data['exapass'];
$exapass_legend = substr($exapass, 0, 15);
$i = (int) substr($exapass_legend, 0, 1) + (int) substr($exapass_legend, 2, 1) + (int) substr($exapass_legend, 4, 1) + (int) substr($exapass_legend, 6, 1) + (int) substr($exapass_legend, 8, 1) + (int) substr($exapass_legend, 10, 1) + (int) substr($exapass_legend, 12, 1) + (int) substr($exapass_legend, 14, 1);
$p = (int) substr($exapass_legend, 1, 1) + (int) substr($exapass_legend, 3, 1) + (int) substr($exapass_legend, 5, 1) + (int) substr($exapass_legend, 7, 1) + (int) substr($exapass_legend, 9, 1) + (int) substr($exapass_legend, 11, 1) + (int) substr($exapass_legend, 13, 1);
$t = ($i * 3) + $p;
$m = ceil($t / 10) * 10;
$key3 = $m - $t;
$exapass_legend .= $key3;
$dest_lines = array();
if($delivery_address->company != '') {
$dest_lines[] = trim(mb_substr($delivery_address->company, 0, 32));
}
if(mb_strlen($delivery_address->lastname.' '.$delivery_address->firstname) > 32) {
$dest_lines[] = trim(mb_substr($delivery_address->lastname, 0, 32));
$dest_lines[] = trim(mb_substr($delivery_address->firstname, 0, 32));
} else {
$dest_lines[] = trim(mb_substr($delivery_address->lastname.' '.$delivery_address->firstname, 0, 32));
}
if(mb_strlen($delivery_address->address1) > 32) {
$dest_lines[] = trim(mb_substr($delivery_address->address1, 0, 32));
$dest_lines[] = trim(mb_substr($delivery_address->address1, 32));
} else {
$dest_lines[] = trim($delivery_address->address1);
}
if(mb_strlen($delivery_address->address2) > 32) {
$dest_lines[] = trim(mb_substr($delivery_address->address2, 0, 32));
$dest_lines[] = trim(mb_substr($delivery_address->address2, 32));
} else {
$dest_lines[] = trim($delivery_address->address2);
}
$shipping_bc = mb_substr(mb_strtoupper($this->stripaccents(str_replace(
array(' ', '', '', '', '“', '”', '„', '†', '‡', '‰', '', '', '♠', '♣', '♥', '♦', '‾', '←', '↑', '→', '↓', '™', '', '!', '“', '#', '$', '%', '&', '', '(', ')', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', ']', '_', '`', '{', '|', '', '}', '~', '', '—', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯', ),
'',
trim($delivery_address->company != ''? $delivery_address->company: $delivery_address->lastname.' '.$delivery_address->firstname)
))), 0, 12);
$format = str_replace(
array(
'{EXASANTE}',
'{EXAPASS_BARCODE}',
'{SHIPPING_BC}',
'{SHIPPING_ALIGN}',
'{TOURPRINT}',
'{TOUR}',
'{TOURALIGN}',
'{SMALL}',
'{TRI1}',
'{LIGNE1}',
'{LIGNE1_ALIGN}',
'{TRI2}',
'{LIGNE2}',
'{LIGNE2_ALIGN}',
'{ACPRINT}',
'{ACPRINT_ALIGN}',
'{PRETRI1}',
'{PRETRI2}',
'{CBTRI}',
'{EXAPASS_PARCEL}',
'{WEIGHT}',
'{DATE}',
'{MSG}',
'{DADDR_0}',
'{DADDR_1}',
'{DADDR_2}',
'{DADDR_3}',
'{DADDR_4}',
'{DADDR_5}',
'{DADDR_6}',
'{DADDR_7}',
'{DADDR_8}',
'{DADDR_9}',
'{SADDR_0}',
'{SADDR_1}',
'{SADDR_2}',
'{SADDR_3}',
'{SADDR_4}',
'{SADDR_5}',
'{REFERENCE}',
'{DADDR_INSTR1}',
'{DADDR_INSTR2}',
'{LPFX}',
),
array(
(int) Configuration::get('EXPAQWS_EXASANTE')? 'EXASANTE': '',
$exapass,
$shipping_bc,
strlen($shipping_bc) == 12? '0103': (strlen($shipping_bc) == 11? '0118': (strlen($shipping_bc) == 10? '0136': (strlen($shipping_bc) == 9? '0153': (strlen($shipping_bc) == 8? '0168': (strlen($shipping_bc) == 7? '0183': (strlen($shipping_bc) == 6? '0198': (strlen($shipping_bc) == 5? '0212': (strlen($shipping_bc) == 4? '0233': (strlen($shipping_bc) == 3? '0248': '0263'))))))))),
trim($route['tourprint']),
trim($route['tour']),
strlen(trim($route['tour'])) == 1? '0368': (strlen(trim($route['tour'])) == 2? '0376': '0384'),
(float) $weight <= 1.0? 'P': '',
trim($route['tri1']),
trim($route['ligne1']),
strlen(trim($route['tri1'])) == 1? '0409': '0413',
trim($route['tri2']),
trim($route['ligne2']),
strlen(trim($route['tri2'])) == 1? '0309': '0313',
trim($route['acprint']),
strlen(trim($route['acprint'])) == 1? '0366': (strlen(trim($route['acprint'])) == 2? '0378': '0390'),
strtoupper(trim($route['pretri'])) == 'BOX'? '1X1100003950162l00250032': '',
strtoupper(trim($route['pretri'])) == 'BOX'? '1X1100002850162l00250032': '',
trim($route['cbtri']),
substr($exapass_legend, 3, 3).' '.substr($exapass_legend, 6, 9).' '.substr($exapass_legend, 15, 1),
number_format($weight * 0.8, 2, '.', ''),
date('d.m.Y'),
(int) $route['msg'] == 1? 'EXPORT A REETIQUETER': ((int) $route['msg'] == 2? 'EXPORT A REETIQUETER AU TRI': ''),
$delivery_address->phone_mobile != ''? $delivery_address->phone_mobile: $delivery_address->phone,
isset($dest_lines[0])? $dest_lines[0]: '',
isset($dest_lines[1])? $dest_lines[1]: '',
isset($dest_lines[2])? $dest_lines[2]: '',
isset($dest_lines[3])? $dest_lines[3]: '',
isset($dest_lines[4])? $dest_lines[4]: '',
isset($dest_lines[5])? $dest_lines[5]: '',
isset($dest_lines[6])? $dest_lines[6]: '',
$delivery_address->postcode,
mb_substr(mb_strtoupper($this->stripaccents($delivery_address->city)), 0, 42),
$sender_phone,
$sender_line1,
$sender_line3,
$sender_line4,
$sender_line2,
$sender_postal.' '.$sender_city,
$order->id,
mb_substr($delivery_address->other, 0, 32),
mb_substr($delivery_address->other, 32, 32),
trim($route['lpfx']),
),
$exapaq_formats['DOM']
);
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'exapaqws_parcel_route` VALUES (
"'.pSQL($exapass).'",
'.(int) $order->id.',
'.((float) $weight * 0.8).',
"'.pSQL($route['iso_code']).'",
"'.pSQL($route['lpfx']).'",
"'.pSQL($route['tri1']).'",
"'.pSQL($route['ligne1']).'",
"'.pSQL($route['tri2']).'",
"'.pSQL($route['ligne2']).'",
"'.pSQL($route['ac']).'",
"'.pSQL($route['acprint']).'",
"'.pSQL($route['tour']).'",
"'.pSQL($route['tourprint']).'",
"'.pSQL($route['pretri']).'",
"'.pSQL($route['cbtri']).'",
"'.pSQL($route['msg'] == 1? 'EXPORT A REETIQUETER': ($route['msg'] == 2? 'EXPORT A REETIQUETER AU TRI': '')).'"
)
');
return $format;
}
return FALSE;
}
public function logParcel($shipping_data, $products) {
global $cookie;
foreach($products as $k => $v) {
if($v > 0) {
Db::getInstance()->ExecuteS('
INSERT `'._DB_PREFIX_.'exapaqws` VALUES (
'.(int) $k.',
'.(int) $cookie->id_employee.',
'.(int) $v.',
"'.pSQL($shipping_data['exapass']).'",
NOW()
)
');
}
}
}
public function addOrderHistory($shipping_data, $order, $products_sent) {
global $cookie;
$exapaq_carrier_id = unserialize(Configuration::get('EXAPAQWS_CARRIERS'));
$exapaq_carrier_id = (int) array_pop($exapaq_carrier_id);
$carrier = new Carrier($exapaq_carrier_id? $exapaq_carrier_id: (int) Configuration::get('ICIRELAIS_ID_CARRIER'), (int) $cookie->id_lang);
$customer = new Customer((int) $order->id_customer);
$templateVars = array(
'{followup}' => str_replace('@', $shipping_data['exapass'], $carrier->url),
'{firstname}' => $customer->firstname,
'{lastname}' => $customer->lastname,
'{id_order}' => (int) $order->id,
'{product_list}' => !empty($products_sent)? '<strong>Contenu du colis :</strong>'.$products_sent: '',
'{product_list_txt}' => !empty($products_sent)? 'Contenu du colis :'.strip_tags($products_sent): '',
);
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$fully_sent = TRUE;
$products_sent = array();
foreach(Db::getInstance()->ExecuteS('
SELECT d.`id_order_detail`, IF(
(d.`product_quantity` - IF(
d.`product_quantity_return` > 0, d.`product_quantity_return`, d.`product_quantity_refunded`
) - IFNULL(SUM(s.`quantity`), 0)) > 0, 1, 0
) AS `remain`
FROM `'._DB_PREFIX_.'order_detail` d
LEFT OUTER JOIN `'._DB_PREFIX_.'exapaqws` s
ON s.`id_order_detail` = d.`id_order_detail`
WHERE d.`id_order` = '.(int) $order->id.'
GROUP BY d.`id_order_detail`
') as $quantity_remain) {
if((int) $quantity_remain['remain'] > 0) {
$fully_sent = FALSE;
break;
} else {
$products_sent[] = (int) $quantity_remain['id_order_detail'];
}
}
$order_sales = array();
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT `id_sale`
FROM `'._DB_PREFIX_.'privatesale`
WHERE `id_category` IN (
SELECT `id_category_default`
FROM `'._DB_PREFIX_.'product`
WHERE `id_product` IN (
SELECT `product_id`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int) $order->id.'
'.(count($products_sent) > 0? ' AND `id_order_detail` NOT IN ('.implode(', ', $products_sent).')': '').'
)
)
') as $order_sale) {
$order_sales[] = (int) $order_sale['id_sale'];
}
if(Db::getInstance()->getRow('
SELECT `product_id`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int) $order->id.'
'.(count($products_sent) > 0? ' AND `id_order_detail` NOT IN ('.implode(', ', $products_sent).')': '').'
AND `product_id` IN (
SELECT `id_product` FROM `'._DB_PREFIX_.'product_ps_cache` WHERE `id_sale` = 0
)
')) {
$order_sales[] = 999999;
}
if(count($order_sales) > 0) {
$cpt = array(1 => 0, 2 => 0);
foreach(Db::getInstance()->ExecuteS('
SELECT `id_shipping`, COUNT(`id_sale`) AS `sale_count`
FROM `'._DB_PREFIX_.'privatesale_shipping_sale`
WHERE `id_sale` IN ('.implode(', ', $order_sales).')
AND `id_sale` NOT IN (
SELECT `id_sale`
FROM `'._DB_PREFIX_.'shipping_history`
WHERE `id_order` = '.(int) $order->id.'
AND `id_sale` IN ('.implode(', ', $order_sales).')
)
GROUP BY `id_shipping`
') as $cpt_sale) {
$cpt[(int) $cpt_sale['id_shipping']] = (int) $cpt_sale['sale_count'];
}
if($cpt[1] == 0 && $cpt[2] == 0) {
$fully_sent = TRUE;
}
}
$history->changeIdOrderState(($fully_sent? Configuration::get('PS_OS_SHIPPING'): 17), (int) $order->id);
$history->id_employee = (int) $cookie->id_employee;
$history->addWithemail(TRUE, $templateVars);
global $_LANGMAIL;
$subject = 'Package in transit';
Mail::Send(
intval($order->id_lang),
'in_transit',
(
(is_array($_LANGMAIL) && key_exists($subject, $_LANGMAIL))
? $_LANGMAIL[$subject]
: $subject
),
$templateVars,
$customer->email,
$customer->firstname.' '.$customer->lastname
);
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
<?php
include dirname(__FILE__).'/../../../../config/config.inc.php';
if(($date = Tools::getValue('date'))
&& (Tools::getValue('token') === Tools::getAdminToken('AdminLaPosteSummary'.(int) Tab::getIdFromClassName('AdminLaPosteSummary').(int) Tools::getValue('id_employee')))) {
$carts = array();
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT o.`id_cart`
FROM `'._DB_PREFIX_.'lapostews` w, `'._DB_PREFIX_.'order_detail` d, `'._DB_PREFIX_.'orders` o
WHERE w.`id_order_detail` = d.`id_order_detail`
AND d.`id_order` = o.`id_order`
AND w.`date_add` > "'.pSQL(date('Y-m-d 00:00:00', strtotime($date))).'"
AND w.`date_add` <= "'.pSQL(date('Y-m-d 23:59:59', strtotime($date))).'"
') as $cart) {
$carts[] = (int) $cart['id_cart'];
}
$modes = array();
$dom = Db::getInstance()->getRow('
SELECT COUNT(o.*) AS `total`
FROM `'._DB_PREFIX_.'orders` o
WHERE o.`id_cart` IN ('.implode(', ', $carts).'
AND o.`id_cart` NOT IN (
SELECT i.`id_cart`
FROM `'._DB_PREFIX_.'socolissimo_delivery_info` i
)
');
if($dom['total'] > 0) {
$modes[] = 'dom';
}
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT `delivery_mode`
FROM `'._DB_PREFIX_.'socolissimo_delivery_info`
WHERE `id_cart` IN ('.implode(', ', $carts).')
') as $dm) {
$modes[] = strtolower($dm['delivery_mode']);
}
echo json_encode(array_unique($modes));
}

View File

@ -0,0 +1,39 @@
<?php
if(isset($_SERVER['REMOTE_ADDR'])) {
exit;
}
$_SERVER['HTTP_PORT'] = 80;
include dirname(__FILE__).'/../../../../config/config.inc.php';
$f = fopen(dirname(__FILE__).'/PDR.csv', 'r');
fgetcsv($f);
Db::getInstance()->ExecuteS('
DELETE FROM `'._DB_PREFIX_.'lapostews_pr`
');
while($line = fgetcsv($f, 0, ';')) {
if($line[0] == 'PR') {
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'lapostews_pr`
VALUES (
"'.pSQL($line[1]).'",
"'.pSQL($line[2]).'",
"'.pSQL($line[3]).'",
"'.pSQL($line[4]).'",
"'.pSQL($line[5]).'",
"'.pSQL($line[6]).'",
"'.pSQL($line[7]).'",
"'.pSQL($line[8]).'",
"'.pSQL($line[9]).'",
"'.pSQL($line[10]).'",
"'.pSQL($line[12]).'",
"'.pSQL($line[14]).'",
"'.pSQL($line[15]).'"
)
');
}
}
fclose($f);

View File

@ -0,0 +1,19 @@
<?php
include dirname(__FILE__).'/../../../../config/config.inc.php';
if((Tools::getValue('token') === Tools::getAdminToken('AdminLaPosteSummary'.(int) Tab::getIdFromClassName('AdminLaPosteSummary').(int) Tools::getValue('id_employee')))
&& ($pdf_date = Tools::getValue('date')) && ($pdf_dm = Tools::getValue('dm')) && in_array($pdf_dm, array('dom', 'cit', 'acp', 'cdi', 'col', 'a2p', 'dos', 'rdv', 'bpr', 'cold'))) {
$pdf_date = (string) (int) $pdf_date;
$pdf_date = substr($pdf_date, 0, 4).'-'.substr($pdf_date, 4, 2).'-'.substr($pdf_date, 6);
if(is_file(dirname(__FILE__).'/summaries/'.$pdf_date.'_'.$pdf_dm.'.pdf')) {
header('Content-type: application/pdf');
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Content-disposition: inline; filename="'.$pdf_date.'_'.$pdf_dm.'.pdf"');
readfile(dirname(__FILE__).'/summaries/'.$pdf_date.'_'.$pdf_dm.'.pdf');
} else {
echo 'ERROR - File not found';
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,192 @@
<html>
<head>
<style type="text/css">{literal}
body {
margin: 0px;
padding: 0px;
font-family: sans-serif;
font-size: 11px;
line-height: 16px;
}
table {
border-collapse: collapse;
width: 100%;
}
td {
vertical-align: top;
}
thead th, .bar {
background: #cccccc;
text-align: left;
font-weight: normal;
}
thead th, tbody td {
padding: 2px 4px;
}
.right {
text-align: right;
}
.strong {
font-weight: bold;
}
.width1 {
width: 100px;
}
.width0 {
width: 20px;
}
.border td {
width: 250px;
border: 1px solid #000000;
padding: 10px;
}
{/literal}</style>
</head>
<body>
{literal}
<!--mpdf
<htmlpagefooter name="myfooter">
<div style="text-align: right;">
Page {PAGENO}/{nb}
</div>
</htmlpagefooter>
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->
{/literal}
<table>
<tr>
<td>SITE DE PRISE EN CHARGE : {$site_code}</td>
<td class="right strong">BORDEREAU DE REMISE Offre Entreprises So Colissimo</td>
</tr>
<tr>
<td colspan="2">LIBELLE SITE DE PRISE EN CHARGE : {$site}</td>
</tr>
</table>
<table>
<tr>
<td class="width1">N° CLIENT</td><td class="width0">:</td><td>{$contract}</td>
<td class="right">EDITE LE {$date}</td>
</tr>
<tr>
<td class="width1">LIBELLE CLIENT</td><td class="width0">:</td>
<td colspan="2">{foreach $sender_lines as $line}{$line}<br />{/foreach}
{$sender_postal} {$sender_city}<br /><br /><br /><br /></td>
</tr>
<tr>
<td class="width1">N° BORDEREAU</td><td class="width0">:</td><td colspan="2">{$summary_number} du {$date}</td>
</tr>
<tr>
<td class="strong" colspan="3"><br />{$title} - Compte de facturation : {$contract}</td>
</tr>
</table>
{assign var=i value=1}
<table>
<thead>
<tr>
<th>Ref exped</th><th>Adresse destinataire</th><th>N° colis</th><th>CPOST</th><th>CPAYS</th><th>Poids</th><th>N</th><th>CRBT</th><th>VA</th>
</th>
</thead>
<tfoot>
<tr><td class="bar" colspan="9"></td></tr>
<tr>
<td colspan="9">
<br />
NOMBRE DES COLIS DE LA PAGE : {if $count_orders <= 46}
{$count_orders}
{else}
46
{/if}
<br />
POIDS DES COLIS DE LA PAGE : {if $count_orders <= 46}
{$total_weight|number_format:2:',':''}
{else}
{(0.24*46)|number_format:2:',':''}
{/if} KG<br />
TOTAL CRBT DE LA PAGE : 0,00 EUR<br />
</td>
</tr>
</tfoot>
<tbody>
{foreach $orders as $order name=orders}
<tr>
<td>EXP{$order.id_order}</td>
<td>{$order.lastname|cat:' - '|cat:$order.address1|truncate:60:''}</td>
<td>{$order.shipping_number}</td>
<td>{$order.postcode}</td>
<td>FR</td>
<td>0,24</td>
<td>0</td>
<td>000.00</td>
<td>00</td>
</tr>
{if $smarty.foreach.orders.iteration % 46 == 0 && $smarty.foreach.orders.iteration != $smarty.foreach.orders.total}
{assign var=i value=$i+1}
</tbody>
</table>
<formfeed />
<table>
<thead>
<tr>
<th>Ref exped</th><th>Adresse destinataire</th><th>N° colis</th><th>CPOST</th><th>CPAYS</th><th>Poids</th><th>N</th><th>CRBT</th><th>VA</th>
</th>
</thead>
<tfoot>
<tr><td class="bar" colspan="9"></td></tr>
<tr>
<td colspan="9">
<br />
NOMBRE DES COLIS DE LA PAGE : {if $smarty.foreach.orders.iteration + 46 > $smarty.foreach.orders.total}
{$smarty.foreach.orders.total - $smarty.foreach.orders.iteration}
{else}
46
{/if}<br />
POIDS DES COLIS DE LA PAGE : {if $smarty.foreach.orders.iteration + 46 > $smarty.foreach.orders.total}
{(($smarty.foreach.orders.total - $smarty.foreach.orders.iteration)*0.24)|number_format:2:',':''}
{else}
{(46*0.24)|number_format:2:',':''}
{/if} KG<br />
TOTAL CRBT DE LA PAGE : 0,00 EUR<br />
</td>
</tr>
</tfoot>
<tbody>
{/if}
{/foreach}
</tbody>
</table>
<br /><br /><br />
<table>
<tr>
<td>
<br /><br />
NOMBRE TOTAL DE COLIS : {$count_orders}<br />
POIDS TOTAL DE COLIS : {$total_weight|number_format:2:',':''} KG<br />
TOTAL CRBT : 0,00 EUR<br />
<br />
Nombre de pages : {literal} <!--mpdf {nb} mpdf--> {/literal}
</td>
<td class="right">
<table class="border"><tr><td>
SIGNATURE DE L'AGENT (*)<br />
<br /><br /><br /><br />
DATE<br /><br />
</td></tr></table>
<br /><br /><br />
* Cette signature ne vaut pas validation des données indiquées par le client
</td>
</tr>
</table>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More