Merge branch 'ticket-10133' into develop

This commit is contained in:
Marion Muszynski 2016-09-15 10:25:14 +02:00
commit 1128f0583c

View File

@ -161,14 +161,14 @@ class AdminOrders extends AdminTab
'{bankwire_owner}' => (Configuration::get('BANK_WIRE_OWNER') ? Configuration::get('BANK_WIRE_OWNER') : ''),
'{bankwire_details}' => (Configuration::get('BANK_WIRE_DETAILS') ? nl2br(Configuration::get('BANK_WIRE_DETAILS')) : ''),
'{bankwire_address}' => (Configuration::get('BANK_WIRE_ADDRESS') ? nl2br(Configuration::get('BANK_WIRE_ADDRESS')) : ''));
if (Tools::getValue('noSendMail')) {
if ($history->add())
Tools::redirectAdmin($currentIndex.'&id_order='.$id_order.'&vieworder'.'&token='.$this->token);
} else {
if ($history->addWithemail(true, $templateVars))
Tools::redirectAdmin($currentIndex.'&id_order='.$id_order.'&vieworder'.'&token='.$this->token);
}
}
$this->_errors[] = Tools::displayError('An error occurred while changing the status or was unable to send e-mail to the customer.');
}
}
@ -356,13 +356,13 @@ class AdminOrders extends AdminTab
$tprice = $details_refund->product_price * (1 - $details_refund->reduction_percent / 100) - $details_refund->reduction_amount;
$tprice = $tprice * ( 1+ $details_refund->tax_rate / 100 );
$products_refund .= "
$products_refund .= "
<tr>
<td>". $details_refund->product_name . "</td>
<td style='text-align:right;'>" . Tools::displayPrice($tprice) . " </td>
<td style='text-align:right;'>". (int)$full_quantity_list[$id_order_detail] ."</td>
<td style='text-align:right;'>" . Tools::displayPrice(($tprice * (int)$full_quantity_list[$id_order_detail])) . "</td>
<td style='text-align:right;'>" . Tools::displayPrice(($tprice * (int)$full_quantity_list[$id_order_detail])) . "</td>
</tr>
";
$total_refund = $total_refund + ($tprice * (int)$full_quantity_list[$id_order_detail]);
@ -370,7 +370,7 @@ class AdminOrders extends AdminTab
$params['{products}'] = $products_refund;
$params['{total_products}'] = Tools::displayPrice($total_refund);
$fraisport = "";
if(isset($_POST['shippingBack']))
{
@ -401,7 +401,7 @@ class AdminOrders extends AdminTab
// @Mail::Send((int)($order->id_lang), 'voucher', Mail::l('New voucher regarding your order'),
// $params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
// NULL, _PS_MAIL_DIR_, true);
/* MODIF MAIL ANTADIS */
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
@ -426,7 +426,123 @@ class AdminOrders extends AdminTab
_PS_MAIL_DIR_, true);
}
}
// update order state if it's partial
if($order->getCurrentState() == 17) {
$partial = true;
$to_send = Db::getInstance()->ExecuteS('
SELECT `id_order_detail`, (`product_quantity` - IF(`product_quantity_return` > 0, `product_quantity_return`, `product_quantity_refunded`)) AS `quantity`, `product_id`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int) $order->id.'
AND (`product_quantity` - IF(`product_quantity_return` > 0, `product_quantity_return`, `product_quantity_refunded`)) > 0
');
if(count($to_send) == 0) {
$partial = false;
} else {
// include_once dirname(__FILE__).'/../../modules/privatesales/Sale.php';
// $quantities_sent = array();
// $product_ids = array();
// foreach(Db::getInstance()->ExecuteQ('
// SELECT `product_id`
// FROM `'._DB_PREFIX_.'order_detail`
// WHERE `id_order` = '.(int) $order->id.'
// ') as $row) {
// $product_ids[] = (int) $row['product_id'];
// }
//
// /**
// * @Override Philea
// */
// if(Db::getInstance()->getRow('
// SELECT *
// FROM `'._DB_PREFIX_.'philea_parcel`
// WHERE `id_order` = '.(int) $order->id.'
// ')) {
// foreach(Db::getInstance()->ExecuteS('
// SELECT c.`id_product`
// FROM `'._DB_PREFIX_.'product_ps_cache` c
// WHERE c.`id_product` IN ('.implode(', ', $products_ids).')
// ') as $row) {
// $quantities_sent[(int) $row['id_product']] = -1;
// }
// }
// $parcel_quantities = array();
// foreach($to_send as $ts) {
// if(!isset($quantities_sent[(int) $ts['product_id']])) {
// $parcel_quantities[(int) $ts['id_order_detail']] = $ts;
// }
// }
// if(count($parcel_quantities) > 0) {
// $partial = false;
// $sent_logistics = array();
// foreach(Db::getInstance()->ExecuteS('
// SELECT SUM(`quantity`) AS `quantity`, `id_order_detail`
// FROM `'._DB_PREFIX_.'lapostews`
// WHERE `id_order_detail` IN ('.implode(', ', array_keys($parcel_quantities)).')
// GROUP BY `id_order_detail`
// ') as $row) {
// $sent_logistics[(int) $row['id_order_detail']] = (int) $row['quantity'];
// }
// foreach(Db::getInstance()->ExecuteS('
// SELECT SUM(`quantity`) AS `quantity`, `id_order_detail`
// FROM `'._DB_PREFIX_.'exapaqws`
// WHERE `id_order_detail` IN ('.implode(', ', array_keys($parcel_quantities)).')
// GROUP BY `id_order_detail`
// ') as $row) {
// $sent_logistics[(int) $row['id_order_detail']] = (int) $row['quantity'];
// }
// if(count($sent_logistics) == 0) {
// $partial = true;
// } else {
// foreach($parcel_quantities as $k => $v) {
// if(!isset($sent_logistics[(int) $k])) {
// $partial = true;
// break;
// } else {
// if($sent_logistics[(int) $k] < $v['quantity']) {
// $partial = true;
// break;
// }
// }
// }
// }
// } else {
// $partial = false;
// }
}
if(!$partial) {
global $cookie;
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'order_history`
VALUES (
DEFAULT,
'.(int) $cookie->id_employee.',
'.(int) $order->id.',
'.Configuration::get('PS_OS_SHIPPING').',
NOW()
)
');
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'order_state_current`
VALUES (
'.(int) $order->id.',
'.Configuration::get('PS_OS_SHIPPING').',
NOW()
)
ON DUPLICATE KEY UPDATE
`id_order_state` = '.Configuration::get('PS_OS_SHIPPING').',
`date_upd` = NOW()
');
$newOS = new OrderState((int)(Configuration::get('PS_OS_SHIPPING')), $order->id_lang);
Module::hookExec('updateOrderStatus', array('newOrderStatus' => $newOS, 'id_order' => (int)($order->id)));
}
}
}
else
$this->_errors[] = Tools::displayError('No product or quantity selected.');
@ -751,9 +867,9 @@ class AdminOrders extends AdminTab
$shippings = Db::getInstance()->ExecuteS('
SELECT p.*
FROM `'._DB_PREFIX_.'lapostews` p
LEFT JOIN `'._DB_PREFIX_.'order_detail` o ON o.`id_order_detail` = p.`id_order_detail`
WHERE o.id_order = ' .(int)$order->id . '
FROM `'._DB_PREFIX_.'lapostews` p
LEFT JOIN `'._DB_PREFIX_.'order_detail` o ON o.`id_order_detail` = p.`id_order_detail`
WHERE o.id_order = ' .(int)$order->id . '
GROUP BY p.`shipping_number`
ORDER BY `date_add`
');
@ -771,7 +887,7 @@ class AdminOrders extends AdminTab
</tr>';
foreach ($shippings as $key => $shipping) {
echo '<tr>
<td>'.date('d/m/Y', strtotime($shipping['date_add'])).'</td>
<td>'.date('d/m/Y', strtotime($shipping['date_add'])).'</td>
<td>'. $shipping['shipping_number'] .'</td>
<td><a onclick="window.open(this.href); return false;" href="http://www.colissimo.fr/portail_colissimo/suivreResultat.do?parcelnumber='.$shipping['shipping_number'].'">'.$this->l('Voir').'</a></td>
</tr>';
@ -784,7 +900,7 @@ class AdminOrders extends AdminTab
echo '
<br />
<fieldset style="width: 400px">
<legend><img src="../img/admin/details.gif" /> '.$this->l('Order details').'</legend>
<legend><img src="../img/admin/details.gif" /> '.$this->l('Order details').'</legend>
<label>'.$this->l('Original cart:').' </label>
<div style="margin: 2px 0 1em 190px;"><a href="?tab=AdminCarts&id_cart='.$cart->id.'&viewcart&token='.Tools::getAdminToken('AdminCarts'.(int)(Tab::getIdFromClassName('AdminCarts')).(int)($cookie->id_employee)).'">'.$this->l('Cart #').sprintf('%06d', $cart->id).'</a></div>
<label>'.$this->l('Payment mode:').' </label>