Merge branch 'ticket-philea'
This commit is contained in:
commit
5b3ac86cc5
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||||
include dirname(__FILE__).'/../../config/config.inc.php';
|
include dirname(__FILE__).'/../../config/config.inc.php';
|
||||||
|
die('test');
|
||||||
if(isset($_SERVER['REMOTE_ADDR'])) {
|
if(isset($_SERVER['REMOTE_ADDR'])) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -39,11 +39,11 @@ if($row = Db::getInstance()->getRow('
|
|||||||
ORDER BY `date_add` ASC
|
ORDER BY `date_add` ASC
|
||||||
')) {
|
')) {
|
||||||
// SEND CDC02
|
// SEND CDC02
|
||||||
/*Db::getInstance()->ExecuteS('
|
Db::getInstance()->ExecuteS('
|
||||||
UPDATE `'._DB_PREFIX_.'philea_sync`
|
UPDATE `'._DB_PREFIX_.'philea_sync`
|
||||||
SET `status` = 4
|
SET `status` = 4
|
||||||
WHERE `id_sync` = '.(int) $row['id_sync'].'
|
WHERE `id_sync` = '.(int) $row['id_sync'].'
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
');
|
');
|
||||||
system('cd '.dirname(__FILE__).'/script && php send_commande.php '.(int) $row['id_sale']);*/
|
system('cd '.dirname(__FILE__).'/script && php send_commande.php '.(int) $row['id_sale']);
|
||||||
}
|
}
|
@ -24,6 +24,8 @@
|
|||||||
'NO_EXPEDITION' => array(189,50),
|
'NO_EXPEDITION' => array(189,50),
|
||||||
'DATE_EXPED' => array(239,8),
|
'DATE_EXPED' => array(239,8),
|
||||||
'TRANSPORTEUR' => array(247,50),
|
'TRANSPORTEUR' => array(247,50),
|
||||||
|
'CODE_ART' => array(297, 50),
|
||||||
|
'QTE' => array(347, 10),
|
||||||
);
|
);
|
||||||
|
|
||||||
$tab_conversion_carrier = philea_magistor::getTabState();
|
$tab_conversion_carrier = philea_magistor::getTabState();
|
||||||
@ -49,7 +51,7 @@
|
|||||||
|
|
||||||
$format = $CRE;
|
$format = $CRE;
|
||||||
if($magistorModule->active) {
|
if($magistorModule->active) {
|
||||||
require_once('connection_ftp.php');
|
//require_once('connection_ftp.php');
|
||||||
@set_time_limit(0);
|
@set_time_limit(0);
|
||||||
|
|
||||||
// Checking for ".bal" files with a "CRE" prefix that has an equivalent ".dat" file and process them...
|
// Checking for ".bal" files with a "CRE" prefix that has an equivalent ".dat" file and process them...
|
||||||
@ -67,8 +69,13 @@
|
|||||||
$content = file_get_contents($datFile);
|
$content = file_get_contents($datFile);
|
||||||
$lines = preg_split('@\n@',$content);
|
$lines = preg_split('@\n@',$content);
|
||||||
|
|
||||||
|
|
||||||
|
$id_order_details = array();
|
||||||
|
$shipping_numbers = array();
|
||||||
|
$parcel_carrier = array();
|
||||||
if(!empty($lines)) {
|
if(!empty($lines)) {
|
||||||
foreach( $lines as $line ) {
|
foreach( $lines as $line ) {
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach($format as $field=>$value) {
|
foreach($format as $field=>$value) {
|
||||||
$data[] = substr($line, ($value[0]-1), $value[1]);
|
$data[] = substr($line, ($value[0]-1), $value[1]);
|
||||||
@ -91,14 +98,21 @@
|
|||||||
$id_order = (int) $id_order;
|
$id_order = (int) $id_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$order = new Order((int) $id_order);
|
||||||
|
|
||||||
|
$code_art = explode("_", trim($data[9]));
|
||||||
|
if(count($code_art)>1) {
|
||||||
|
list($id_product, $id_attribute) = $code_art;
|
||||||
|
} else {
|
||||||
|
$id_product = $code_art[0];
|
||||||
|
$id_attribute = 0;
|
||||||
|
}
|
||||||
if($detail = Db::getInstance()->getRow('
|
if($detail = Db::getInstance()->getRow('
|
||||||
SELECT `id_order_detail`, `product_quantity` - GREATEST(`product_quantity_return`, `product_quantity_refunded`) AS `quantity`
|
SELECT `id_order_detail`, `product_quantity` - GREATEST(`product_quantity_return`, `product_quantity_refunded`) AS `quantity`
|
||||||
FROM `'._DB_PREFIX_.'order_detail`
|
FROM `'._DB_PREFIX_.'order_detail`
|
||||||
WHERE `id_order` = '.(int) $id_order.'
|
WHERE `id_order` = '.(int) $id_order.'
|
||||||
AND (
|
AND `product_id` = '.(int) $id_product.'
|
||||||
`product_ean13` = "'.pSQL($data[9]).'"
|
AND `product_attribute_id` = '.(int) $id_attribute.'
|
||||||
OR `product_supplier_reference` = "'.pSQL($data[9]).'"
|
|
||||||
)
|
|
||||||
')) {
|
')) {
|
||||||
$sent = (int) Db::getInstance()->getValue('
|
$sent = (int) Db::getInstance()->getValue('
|
||||||
SELECT SUM(`quantity`)
|
SELECT SUM(`quantity`)
|
||||||
@ -123,6 +137,10 @@
|
|||||||
$id_order_details[] = (int) $detail['id_order_detail'];
|
$id_order_details[] = (int) $detail['id_order_detail'];
|
||||||
$shipping_numbers[] = '"'.pSQL(trim($data[5])).'"';
|
$shipping_numbers[] = '"'.pSQL(trim($data[5])).'"';
|
||||||
|
|
||||||
|
// GET CARRIER ID
|
||||||
|
$carrier_found = false;
|
||||||
|
$id_active_carrier = false;
|
||||||
|
$id_inactive_carrier = false;
|
||||||
if (isset($data[8]) && $data[8]){
|
if (isset($data[8]) && $data[8]){
|
||||||
$carrier_name = trim($data[8]);
|
$carrier_name = trim($data[8]);
|
||||||
$carriers = philea_magistor::getCarriersIdByRef($carrier_name);
|
$carriers = philea_magistor::getCarriersIdByRef($carrier_name);
|
||||||
@ -137,20 +155,29 @@
|
|||||||
if ($carrier['active'] == 0 && $carrier['deleted'] == 0) {
|
if ($carrier['active'] == 0 && $carrier['deleted'] == 0) {
|
||||||
$id_inactive_carrier = (int) $carrier['id_carrier'];
|
$id_inactive_carrier = (int) $carrier['id_carrier'];
|
||||||
}
|
}
|
||||||
// if ((int) $order->id_carrier == (int) $carrier['id_carrier']){
|
if ((int) $order->id_carrier == (int) $carrier['id_carrier']){
|
||||||
// $carrier_found = (int) $order->id_carrier;
|
$carrier_found = (int) $order->id_carrier;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($id_active_carrier) && $id_active_carrier) {
|
if ($carrier_found)
|
||||||
$parcel_carrier[(int) $id_order.'|'.trim($data[5])] = $carriers[$data[8]];
|
$id_carrier = (int) $carrier_found;
|
||||||
|
elseif ($id_active_carrier)
|
||||||
|
$id_carrier = (int) $id_active_carrier;
|
||||||
|
elseif ($id_inactive_carrier)
|
||||||
|
$id_carrier = (int) $id_inactive_carrier;
|
||||||
|
else
|
||||||
|
$id_carrier = (int) $order->id_carrier;
|
||||||
|
|
||||||
|
if(isset($id_carrier) && $id_carrier) {
|
||||||
|
$parcel_carrier[(int) $id_order.'|'.trim($data[5])] = $id_carrier;
|
||||||
} else { // MISSING CARRIER
|
} else { // MISSING CARRIER
|
||||||
$errors[] = array(
|
$errors[] = array(
|
||||||
$data[3],
|
$data[3],
|
||||||
$data[8], // carrier name
|
$data[8], // carrier name
|
||||||
$data[9],
|
$data[9], // code article productId_attributeId
|
||||||
$data[10], // quantity
|
$data[10], // quantity
|
||||||
$data[5], // shipping number
|
$data[5], // shipping number
|
||||||
$data[7],
|
$data[7],
|
||||||
@ -201,11 +228,10 @@
|
|||||||
$id_orders = array();
|
$id_orders = array();
|
||||||
$orders_infos = array();
|
$orders_infos = array();
|
||||||
|
|
||||||
foreach(Db::getInstance()->ExecuteQ('
|
foreach(Db::getInstance()->ExecuteS('
|
||||||
SELECT d.`id_order`, p.`shipping_number`, p.`date_add`
|
SELECT d.`id_order`, p.`shipping_number`, p.`date_add`
|
||||||
FROM `'._DB_PREFIX_.'philea_parcel` p
|
FROM `'._DB_PREFIX_.'philea_parcel` p
|
||||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
|
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (p.`id_order_detail` = d.`id_order_detail`)
|
||||||
ON p.`id_order_detail` = d.`id_order_detail`
|
|
||||||
WHERE d.`id_order_detail` IN ('.implode(', ', $id_order_details).')
|
WHERE d.`id_order_detail` IN ('.implode(', ', $id_order_details).')
|
||||||
AND p.`shipping_number` IN ('.implode(', ', $shipping_numbers).')
|
AND p.`shipping_number` IN ('.implode(', ', $shipping_numbers).')
|
||||||
GROUP BY d.`id_order`, p.`shipping_number`
|
GROUP BY d.`id_order`, p.`shipping_number`
|
||||||
@ -230,16 +256,15 @@
|
|||||||
|
|
||||||
$id_orders = array_unique($id_orders);
|
$id_orders = array_unique($id_orders);
|
||||||
|
|
||||||
$products = Db::getInstance()->ExecuteQ('
|
$products = Db::getInstance()->ExecuteS('
|
||||||
SELECT d.`id_order_detail`, d.`id_order`, c.`id_sale`, d.`product_quantity` - GREATEST(d.`product_quantity_refunded`, d.`product_quantity_return`) AS `quantity`
|
SELECT d.`id_order_detail`, d.`id_order`, c.`id_sale`, d.`product_quantity` - GREATEST(d.`product_quantity_refunded`, d.`product_quantity_return`) AS `quantity`
|
||||||
FROM ps_order_detail d
|
FROM ps_order_detail d
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` c
|
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` c ON (d.`product_id` = c.`id_product`)
|
||||||
ON d.`product_id` = c.`id_product`
|
|
||||||
WHERE d.`id_order` IN ('.implode(', ', $id_orders).')
|
WHERE d.`id_order` IN ('.implode(', ', $id_orders).')
|
||||||
');
|
');
|
||||||
|
|
||||||
$sent_sales = array();
|
$sent_sales = array();
|
||||||
foreach(Db::getInstance()->ExecuteQ('
|
foreach(Db::getInstance()->ExecuteS('
|
||||||
SELECT `id_order`, `id_sale`
|
SELECT `id_order`, `id_sale`
|
||||||
FROM `'._DB_PREFIX_.'shipping_history`
|
FROM `'._DB_PREFIX_.'shipping_history`
|
||||||
WHERE `id_order` IN ('.implode(', ', $id_orders).')
|
WHERE `id_order` IN ('.implode(', ', $id_orders).')
|
||||||
@ -264,21 +289,19 @@
|
|||||||
unset($products);
|
unset($products);
|
||||||
|
|
||||||
$sent_products = array();
|
$sent_products = array();
|
||||||
foreach(Db::getInstance()->ExecuteQ('
|
foreach(Db::getInstance()->ExecuteS('
|
||||||
SELECT l.`id_order_detail`, SUM(l.`quantity`) AS `quantity`
|
SELECT l.`id_order_detail`, SUM(l.`quantity`) AS `quantity`
|
||||||
FROM `'._DB_PREFIX_.'lapostews` l
|
FROM `'._DB_PREFIX_.'lapostews` l
|
||||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
|
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (l.`id_order_detail` = d.`id_order_detail`)
|
||||||
ON l.`id_order_detail` = d.`id_order_detail`
|
|
||||||
WHERE d.`id_order` IN ('.implode(', ', $id_orders).')
|
WHERE d.`id_order` IN ('.implode(', ', $id_orders).')
|
||||||
GROUP BY l.`id_order_detail`
|
GROUP BY l.`id_order_detail`
|
||||||
') as $row) {
|
') as $row) {
|
||||||
$sent_products[(int) $row['id_order_detail']] = (int) $row['quantity'];
|
$sent_products[(int) $row['id_order_detail']] = (int) $row['quantity'];
|
||||||
}
|
}
|
||||||
foreach(Db::getInstance()->ExecuteQ('
|
foreach(Db::getInstance()->ExecuteS('
|
||||||
SELECT l.`id_order_detail`, SUM(l.`quantity`) AS `quantity`
|
SELECT l.`id_order_detail`, SUM(l.`quantity`) AS `quantity`
|
||||||
FROM `'._DB_PREFIX_.'philea_parcel` l
|
FROM `'._DB_PREFIX_.'philea_parcel` l
|
||||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
|
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (l.`id_order_detail` = d.`id_order_detail`)
|
||||||
ON l.`id_order_detail` = d.`id_order_detail`
|
|
||||||
WHERE d.`id_order` IN ('.implode(', ', $id_orders).')
|
WHERE d.`id_order` IN ('.implode(', ', $id_orders).')
|
||||||
GROUP BY l.`id_order_detail`
|
GROUP BY l.`id_order_detail`
|
||||||
') as $row) {
|
') as $row) {
|
||||||
@ -322,7 +345,7 @@
|
|||||||
SELECT `id_order_state`
|
SELECT `id_order_state`
|
||||||
FROM `'._DB_PREFIX_.'order_history`
|
FROM `'._DB_PREFIX_.'order_history`
|
||||||
WHERE `id_order` = '.(int) $order.'
|
WHERE `id_order` = '.(int) $order.'
|
||||||
ORDER BY `date_add` DESC
|
ORDER BY `date_add` DESC LIMIT 1
|
||||||
') != 4) {
|
') != 4) {
|
||||||
$status_sent[] = (int) $order;
|
$status_sent[] = (int) $order;
|
||||||
}
|
}
|
||||||
@ -334,8 +357,8 @@
|
|||||||
SELECT `id_order_state`
|
SELECT `id_order_state`
|
||||||
FROM `'._DB_PREFIX_.'order_history`
|
FROM `'._DB_PREFIX_.'order_history`
|
||||||
WHERE `id_order` = '.(int) $order.'
|
WHERE `id_order` = '.(int) $order.'
|
||||||
ORDER BY `date_add` DESC
|
ORDER BY `date_add` DESC LIMIT 1
|
||||||
'), array(4, 17, 9))) {
|
'), array(4, 17, 9, 19))) {
|
||||||
$status_partially_sent[] = (int) $order;
|
$status_partially_sent[] = (int) $order;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,11 +376,10 @@
|
|||||||
|
|
||||||
$products_names = array();
|
$products_names = array();
|
||||||
|
|
||||||
foreach(Db::getInstance()->ExecuteQ('
|
foreach(Db::getInstance()->ExecuteS('
|
||||||
SELECT d.`id_order_detail`, d.`product_name`, SUM(p.`quantity`) AS `quantity`
|
SELECT d.`id_order_detail`, d.`product_name`, SUM(p.`quantity`) AS `quantity`
|
||||||
FROM `'._DB_PREFIX_.'philea_parcel` p
|
FROM `'._DB_PREFIX_.'philea_parcel` p
|
||||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
|
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (p.`id_order_detail` = d.`id_order_detail`)
|
||||||
ON p.`id_order_detail` = d.`id_order_detail`
|
|
||||||
WHERE d.`id_order` = '.(int) $id_order.'
|
WHERE d.`id_order` = '.(int) $id_order.'
|
||||||
AND p.`shipping_number` = "'.pSQL($parcel[0]).'"
|
AND p.`shipping_number` = "'.pSQL($parcel[0]).'"
|
||||||
AND p.`date_add` = "'.pSQL($parcel[1]).'"
|
AND p.`date_add` = "'.pSQL($parcel[1]).'"
|
||||||
@ -369,7 +391,7 @@
|
|||||||
$carrier = new Carrier($parcel[2], (int) $order->id_lang);
|
$carrier = new Carrier($parcel[2], (int) $order->id_lang);
|
||||||
|
|
||||||
if((int) $order->id_lang == 3) {
|
if((int) $order->id_lang == 3) {
|
||||||
if(in_array((int) $carrier->id, array(145, 152, 103))) {
|
if(preg_match('/colissimo/i', $carrier->name)) {
|
||||||
$carrier->url .= '&language=es_ES';
|
$carrier->url .= '&language=es_ES';
|
||||||
}
|
}
|
||||||
$content_html = '<strong>Contenido del paquete:</strong>';
|
$content_html = '<strong>Contenido del paquete:</strong>';
|
||||||
@ -392,12 +414,12 @@
|
|||||||
$history = new OrderHistory();
|
$history = new OrderHistory();
|
||||||
$history->id_order = (int) $order->id;
|
$history->id_order = (int) $order->id;
|
||||||
$history->changeIdOrderState(4, (int) $order->id);
|
$history->changeIdOrderState(4, (int) $order->id);
|
||||||
$history->addWithemail(TRUE, $templateVars);
|
$history->addWithemail(true, $templateVars);
|
||||||
} elseif(in_array($order->id, $status_partially_sent)) {
|
} elseif(in_array($order->id, $status_partially_sent)) {
|
||||||
$history = new OrderHistory();
|
$history = new OrderHistory();
|
||||||
$history->id_order = (int) $order->id;
|
$history->id_order = (int) $order->id;
|
||||||
$history->changeIdOrderState(17, (int) $order->id);
|
$history->changeIdOrderState(17, (int) $order->id);
|
||||||
$history->addWithemail(TRUE, $templateVars);
|
$history->addWithemail(true, $templateVars);
|
||||||
}
|
}
|
||||||
|
|
||||||
$subjects = array(
|
$subjects = array(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||||
$_SERVER['HTTP_HOST'] = 'www.bricoprive.com';
|
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||||
include('../../../config/settings.inc.php');
|
include('../../../config/settings.inc.php');
|
||||||
include('../../../config/config.inc.php');
|
include('../../../config/config.inc.php');
|
||||||
|
|
||||||
|
@ -48,6 +48,23 @@ if($magistorModule->active) {
|
|||||||
$db = Db::getInstance();
|
$db = Db::getInstance();
|
||||||
$id_order_state = 2;
|
$id_order_state = 2;
|
||||||
|
|
||||||
|
// for dev
|
||||||
|
// $include_orders = array();
|
||||||
|
// foreach($db->ExecuteS('
|
||||||
|
// SELECT DISTINCT d.`id_order`
|
||||||
|
// FROM `'._DB_PREFIX_.'order_detail` d
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` c ON d.`product_id` = c.`id_product`
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'philea_sent` pms ON (pms.`id_sale` = c.`id_sale` AND pms.`id_order` = d.`id_order`)
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = d.`id_order`)
|
||||||
|
// WHERE oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = d.`id_order` GROUP BY moh.`id_order`)
|
||||||
|
// AND oh.`id_order_state` IN (2, 3, 4, 13, 17, 9, 18, 19)
|
||||||
|
// AND c.`id_sale` = '.(int) $id_sale.'
|
||||||
|
// AND pms.`id_order` IS NULL
|
||||||
|
// AND d.`product_quantity` - d.`product_quantity_refunded` > 0
|
||||||
|
// ') as $row) {
|
||||||
|
// $include_orders[] = (int) $row['id_order'];
|
||||||
|
// }
|
||||||
|
|
||||||
$include_orders = array();
|
$include_orders = array();
|
||||||
foreach($db->ExecuteS('
|
foreach($db->ExecuteS('
|
||||||
SELECT DISTINCT o.`id_order`
|
SELECT DISTINCT o.`id_order`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user