changement for pack gestion

This commit is contained in:
Marion Muszynski 2016-12-07 14:29:33 +01:00
parent 0a9afab232
commit 7cb36d6b0d

View File

@ -100,7 +100,9 @@
$id_order = (int) $id_order;
}
if(!isset($details[(int)$id_order])){
$details[(int)$id_order] = array();
}
$code_art = explode("_", trim($data[9]));
if(count($code_art)>1) {
@ -110,6 +112,8 @@
$id_attribute = 0;
}
$order = new Order((int) $id_order);
// GET CARRIER ID
$carrier_found = false;
$id_active_carrier = false;
@ -163,10 +167,11 @@
'quantity' => (int) trim($data[10])
);
$order = new Order((int) $id_order);
if(!isset($order_details[(int)$id_order])){
$order_details[(int)$id_order] = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `id_order_detail`, `product_id`, `product_attribute_id`, `product_quantity` - GREATEST(`product_quantity_return`, `product_quantity_refunded`) AS `quantity`
SELECT DISTINCT `id_order_detail`, `product_id`, `product_attribute_id`, `product_quantity` - GREATEST(`product_quantity_return`, `product_quantity_refunded`) AS `quantity`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int) $id_order.'
') as $key => $row) {
@ -176,12 +181,11 @@
WHERE `id_order_detail` = '.(int) $row['id_order_detail'].'
');
$id_order_details[] = (int) $row['id_order_detail'];
if(Pack::isPack((int)$row['product_id'])) {
$items = Pack::getSimplePack($row['product_id']);
foreach($items as $item) {
if(!isset($order_details[$id_order][$item['id_product_item'].'_0'])) {
$order_details[$id_order][$item['id_product_item'].'_0'] = array(
if(!isset($order_details[(int)$id_order][$item['id_product_item'].'_0'])) {
$order_details[(int)$id_order][$item['id_product_item'].'_0'] = array(
'id_order_details' => array(),
'quantity_to_sent' => 0
);
@ -193,24 +197,26 @@
);
}
} else {
if(!isset($order_details[$id_order][$row['product_id'].'_'.$row['product_attribute_id']])) {
$order_details[$id_order][$row['product_id'].'_'.$row['product_attribute_id']] = array(
if(!isset($order_details[(int)$id_order][$row['product_id'].'_'.$row['product_attribute_id']])) {
$order_details[(int)$id_order][$row['product_id'].'_'.$row['product_attribute_id']] = array(
'id_order_details' => array(),
'quantity_to_sent' => 0
);
}
$order_details[$id_order][$row['product_id'].'_'.$row['product_attribute_id']]['quantity_to_sent'] += ($row['quantity'] - $sent);
$order_details[$id_order][$item['id_product_item'].'_0']['id_order_details'][$row['id_order_detail']] = array(
$order_details[(int)$id_order][$row['product_id'].'_'.$row['product_attribute_id']]['quantity_to_sent'] += ($row['quantity'] - $sent);
$order_details[(int)$id_order][$row['product_id'].'_'.$row['product_attribute_id']]['id_order_details'][$row['id_order_detail']] = array(
'detail_quantity' => ($row['quantity'] - $sent),
'id_order_detail' => $row['id_order_detail']
);
}
}
}
} // end foreach lines
foreach($order_details as $order => $order_detail){
foreach ($order_detail as $key => $product) {
if(isset($details[(int)$order][$key]) && $details[(int)$order][$key]['quantity'] <= $product['quantity_to_sent']) {
if(isset($details[(int)$order][$key])) {
if($details[(int)$order][$key]['quantity'] <= $product['quantity_to_sent']) {
if(count($details[(int)$order][$key]['shipping_numbers'])>1) {
foreach($details[(int)$order][$key]['shipping_numbers'] as $shipping_number) {
foreach($product['id_order_details'] as $id_order_detail => $row) {
@ -238,10 +244,18 @@
');
}
}
} else {
$message = "Commande : ".$order."\r\n Produit : ".$key."\r\n Quantity to sent : ".$product['quantity_to_sent']."\r\n Quantity : ".$details[(int)$order][$key]['quantity'];
mail('marion@antadis.com', '[BBB] Erreurs quantity expe Philea', $message);
}
} else {
$message = "Commande : ".$order."\r\n Produit : ".$key."\r\n Produit non présent dans le fichier expe philea";
mail('marion@antadis.com', '[BBB] Erreurs produit expe Philea', $message);
}
}
}
unset($details);
unset($order_details);
} // end if lines
$id_order_details = array_unique($id_order_details);
@ -440,12 +454,14 @@
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$history->changeIdOrderState(4, (int) $order->id);
$history->addWithemail(true, $templateVars);
//$history->addWithemail(true, $templateVars);
$history->add();
} elseif(in_array($order->id, $status_partially_sent)) {
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$history->changeIdOrderState(17, (int) $order->id);
$history->addWithemail(true, $templateVars);
//$history->addWithemail(true, $templateVars);
$history->add();
}
$subjects = array(
@ -476,9 +492,9 @@
mkdir($repo_archive);
}
copy($datFile, $repo_archive . preg_replace( '@BAL$@', 'DAT', $fileinfo->getFilename() ));
unlink($inFolder.$fileinfo->getFilename());
unlink($datFile);
// copy($datFile, $repo_archive . preg_replace( '@BAL$@', 'DAT', $fileinfo->getFilename() ));
// unlink($inFolder.$fileinfo->getFilename());
// unlink($datFile);
}
}