Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop
This commit is contained in:
commit
5808f9a300
@ -52,7 +52,7 @@ class AdminAntReturnprocess extends AdminTab
|
||||
Mail::Send((int)$order->id_lang, 'order_return_state', Mail::l('Your order return state has changed', (int)$order->id_lang),
|
||||
$vars, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
|
||||
NULL, _PS_MAIL_DIR_, true);
|
||||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&conf=4&token='.$this->token);
|
||||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&ok=2&token='.$this->token);
|
||||
}
|
||||
} else {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('No order return ID.'));
|
||||
@ -104,7 +104,7 @@ class AdminAntReturnprocess extends AdminTab
|
||||
$ct->update();
|
||||
$cm->update();
|
||||
}
|
||||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&conf=4&token='.$this->token);
|
||||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&ok=3&token='.$this->token);
|
||||
} else {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred, your message was not sent. Please contact your system administrator.'));
|
||||
}
|
||||
@ -154,10 +154,336 @@ class AdminAntReturnprocess extends AdminTab
|
||||
$customer->email,
|
||||
$customer->firstname.' '.$customer->lastname
|
||||
);
|
||||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&conf=4&token='.$this->token);
|
||||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&ok=4&token='.$this->token);
|
||||
} else {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('Order ID missing.'));
|
||||
}
|
||||
} elseif (Tools::isSubmit('submitOrderState') && Tools::getValue('id_order_return') && ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order))) {
|
||||
|
||||
$id_order_return = (int) Tools::getValue('id_order_return');
|
||||
if (!$newOrderStatusId = (int)(Tools::getValue('id_order_state'))) {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('Invalid new order status'));
|
||||
} else {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int)$id_order;
|
||||
$history->id_employee = (int)($cookie->id_employee);
|
||||
$history->changeIdOrderState((int)($newOrderStatusId), (int)($id_order));
|
||||
$order = new Order((int)$order->id);
|
||||
$carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang));
|
||||
|
||||
$templateVars = array();
|
||||
if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') AND $order->shipping_number) {
|
||||
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
|
||||
} elseif ($history->id_order_state == Configuration::get('PS_OS_CHEQUE')) {
|
||||
$templateVars = array(
|
||||
'{cheque_name}' => (Configuration::get('CHEQUE_NAME') ? Configuration::get('CHEQUE_NAME') : ''),
|
||||
'{cheque_address_html}' => (Configuration::get('CHEQUE_ADDRESS') ? nl2br(Configuration::get('CHEQUE_ADDRESS')) : ''));
|
||||
} elseif ($history->id_order_state == Configuration::get('PS_OS_BANKWIRE')) {
|
||||
$templateVars = array(
|
||||
'{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_return='.(int)$id_order_return.'&updateorder_return&ok=5&token='.$this->token);
|
||||
}
|
||||
} else {
|
||||
if ($history->addWithemail(true, $templateVars)) {
|
||||
Tools::redirectAdmin($currentIndex.'&id_order_return='.(int)$id_order_return.'&updateorder_return&ok=5&token='.$this->token);
|
||||
}
|
||||
}
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred while changing the status or was unable to send e-mail to the customer.'));
|
||||
}
|
||||
} elseif(Tools::isSubmit('submitCancelProduct') && Tools::getValue('id_order_return') && ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order))) {
|
||||
$_POST['generateCreditSlip'] = 1;
|
||||
$customer = new Customer($order->id_customer);
|
||||
|
||||
$productList = Tools::getValue('cancelQuantity');
|
||||
$id_order_details = array();
|
||||
$refund_quantities = array();
|
||||
foreach ($productList as $id_order_detail => $qty) {
|
||||
if((int)$qty ==0) {
|
||||
unset($productList[$id_order_detail]);
|
||||
}
|
||||
$id_order_details[$id_order_detail] = $id_order_detail;
|
||||
$refund_quantities[$id_order_detail] = $qty;
|
||||
}
|
||||
$errors = 0;
|
||||
|
||||
$id_cart = Cart::getCartIdByOrderId($order->id);
|
||||
foreach ($productList AS $id_order_detail => $qty)
|
||||
{
|
||||
$qtyCancelProduct = abs($qty);
|
||||
if (!$qtyCancelProduct) {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('No quantity selected for product.'));
|
||||
$errors++;
|
||||
}
|
||||
|
||||
// check actionable quantity
|
||||
$order_detail = new OrderDetail($id_order_detail);
|
||||
$customization_quantity = 0;
|
||||
if (array_key_exists($order_detail->product_id, $customization_quantities) && array_key_exists($order_detail->product_attribute_id, $customization_quantities[$order_detail->product_id])) {
|
||||
$customization_quantity = (int) $customization_quantities[$order_detail->product_id][$order_detail->product_attribute_id];
|
||||
}
|
||||
|
||||
if (($order_detail->product_quantity - $customization_quantity - $order_detail->product_quantity_refunded - $order_detail->product_quantity_return) < $qtyCancelProduct) {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('Invalid quantity selected for product.'));
|
||||
$errors++;
|
||||
}
|
||||
}
|
||||
if ($errors == 0 AND $productList) {
|
||||
foreach ($productList AS $id_order_detail => $qty) {
|
||||
$qtyCancelProduct = abs($qty);
|
||||
$orderDetail = new OrderDetail((int)($id_order_detail));
|
||||
|
||||
//@Addition Antadis - prevent reinjection when the product is sent by Philea
|
||||
$is_philea = DB::getInstance()->getValue('
|
||||
SELECT p.`id_sale`
|
||||
FROM `'._DB_PREFIX_.'philea_sync` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` ps ON (ps.`id_sale` = p.`id_sale`)
|
||||
WHERE ps.`id_product`='.$orderDetail->product_id
|
||||
);
|
||||
// @Addition Antadis - prevent reinjection when the product is in Braderie
|
||||
$is_braderie = (int)DB::getInstance()->getValue('
|
||||
SELECT p.`braderie`
|
||||
FROM `'._DB_PREFIX_.'privatesale` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` ps ON (ps.`id_sale` = p.`id_sale`)
|
||||
WHERE ps.`id_product`='.$orderDetail->product_id
|
||||
);
|
||||
// $is_philea = false; // dev
|
||||
// $is_braderie = false; // dev
|
||||
// Reinject product
|
||||
if (
|
||||
!$order->hasBeenDelivered()
|
||||
OR ($order->hasBeenDelivered() AND Tools::isSubmit('reinjectQuantities') AND !$is_philea AND !$is_braderie)
|
||||
){
|
||||
if(
|
||||
(($is_philea || $is_braderie) && !$order->hasBeenShipped() && !$order->hasBeenDelivered())
|
||||
|| (!$is_philea && !$is_braderie)
|
||||
){
|
||||
$reinjectableQuantity = (int)($orderDetail->product_quantity) - (int)($orderDetail->product_quantity_reinjected);
|
||||
$quantityToReinject = $qtyCancelProduct > $reinjectableQuantity ? $reinjectableQuantity : $qtyCancelProduct;
|
||||
|
||||
if (!Product::reinjectQuantities($orderDetail, $quantityToReinject)) {
|
||||
$errors++;
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('Cannot re-stock product').' <span class="bold">'.$orderDetail->product_name.'</span>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$updProductAttributeID = !empty($orderDetail->product_attribute_id) ? (int)($orderDetail->product_attribute_id) : NULL;
|
||||
$newProductQty = Product::getQuantity((int)($orderDetail->product_id), $updProductAttributeID);
|
||||
$product = get_object_vars(new Product((int)($orderDetail->product_id), false, (int)($cookie->id_lang)));
|
||||
if (!empty($orderDetail->product_attribute_id))
|
||||
{
|
||||
$updProduct['quantity_attribute'] = (int)($newProductQty);
|
||||
$product['quantity_attribute'] = $updProduct['quantity_attribute'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$updProduct['stock_quantity'] = (int)($newProductQty);
|
||||
$product['stock_quantity'] = $updProduct['stock_quantity'];
|
||||
}
|
||||
Hook::updateQuantity($product, $order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete product
|
||||
if (!$order->deleteProduct($order, $orderDetail, $qtyCancelProduct)) {
|
||||
$errors++;
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred during deletion of the product.').' <span class="bold">'.$orderDetail->product_name.'</span>');
|
||||
}
|
||||
Module::hookExec('cancelProduct', array('order' => $order, 'id_order_detail' => $id_order_detail));
|
||||
}
|
||||
|
||||
$params['{lastname}'] = $customer->lastname;
|
||||
$params['{firstname}'] = $customer->firstname;
|
||||
$params['{id_order}'] = $order->id;
|
||||
|
||||
/* PRODUIT REMBOURSE */
|
||||
$products_refund = "";
|
||||
$total_refund = 0;
|
||||
foreach ($productList as $id_order_detail => $qty) {
|
||||
$details_refund = new OrderDetail($id_order_detail);
|
||||
|
||||
$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 .= "
|
||||
<tr>
|
||||
<td>". $details_refund->product_name . "</td>
|
||||
<td style='text-align:right;'>" . Tools::displayPrice($tprice) . " </td>
|
||||
<td style='text-align:right;'>". (int)$qty ."</td>
|
||||
<td style='text-align:right;'>" . Tools::displayPrice(($tprice * (int)$qty)) . "</td>
|
||||
</tr>
|
||||
";
|
||||
$total_refund = $total_refund + ($tprice * (int)$qty);
|
||||
}
|
||||
|
||||
$params['{products}'] = $products_refund;
|
||||
$params['{total_products}'] = Tools::displayPrice($total_refund);
|
||||
|
||||
$fraisport = "";
|
||||
if(isset($_POST['shippingBack']))
|
||||
{
|
||||
$order = new Order($details_refund->id_order);
|
||||
Module::hookExec('cancelShipping', array('order' => $order));
|
||||
$fraisport .= "
|
||||
<tr style='text-align:right;'>
|
||||
<td colspan='3' style='background-color:#e2e2e1; padding:0.6em 0.4em;'>Frais de port</td>
|
||||
<td style='background-color:#e2e2e1; padding:0.6em 0.4em;'>" . Tools::displayPrice($order->total_shipping) . "</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
$params['{fraisport}'] = $fraisport;
|
||||
|
||||
if (isset($_POST['generateCreditSlip']) AND $errors==0)
|
||||
{
|
||||
if (!OrderSlip::createOrderSlip($order, $full_product_list, $full_quantity_list, isset($_POST['shippingBack']))) {
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('Cannot generate credit slip'));
|
||||
$errors++;
|
||||
} else {
|
||||
Module::hookExec('orderSlip', array('order' => $order, 'productList' => $id_order_details, 'qtyList' => $refund_quantities));
|
||||
|
||||
@Mail::Send((int)$order->id_lang, 'credit_slip', Mail::l('New credit slip regarding your order', $order->id_lang),
|
||||
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL,
|
||||
_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()->ExecuteS('
|
||||
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_.'mondialrelay_parcel`
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
HelperFormBootstrap::displaySuccess('Remboursement Effectué');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,14 +515,31 @@ class AdminAntReturnprocess extends AdminTab
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['updateorder_return']))
|
||||
{
|
||||
if (isset($_GET['updateorder_return'])) {
|
||||
|
||||
if(isset($_GET['ok'])){
|
||||
switch ($_GET['ok']) {
|
||||
case '2':
|
||||
$success_mess = 'Mise à jour enregistrée';
|
||||
break;
|
||||
case '3':
|
||||
$success_mess = 'Votre message a bien été envoyé';
|
||||
break;
|
||||
case '4':
|
||||
$success_mess = 'Les instructions on été renvoyées';
|
||||
break;
|
||||
case '5':
|
||||
$success_mess = 'Le nouveau statut de le commande a bien été enregistré';
|
||||
break;
|
||||
default:
|
||||
$success_mess = 'Mise à jour enregistrée';
|
||||
break;
|
||||
}
|
||||
HelperFormBootstrap::displaySuccess($success_mess);
|
||||
}
|
||||
$this->displayForm();
|
||||
echo '<br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->displaylist();
|
||||
}
|
||||
}
|
||||
@ -216,7 +559,7 @@ class AdminAntReturnprocess extends AdminTab
|
||||
$customer = new Customer((int)$order->id_customer);
|
||||
$data = $this->getOrderDetail($cart,(int)$cart->id_lang,$order);
|
||||
$currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
|
||||
$currentState = OrderHistory::getLastOrderState((int)$orderReturn->id_order);
|
||||
$orderStates = OrderState::getOrderStates((int)($cookie->id_lang));
|
||||
$shipping_numbers = Db::getInstance()->ExecuteS('
|
||||
SELECT DISTINCT lpws.`shipping_number`, lpws.`date_add`
|
||||
FROM `'._DB_PREFIX_.'lapostews` lpws
|
||||
@ -248,6 +591,7 @@ class AdminAntReturnprocess extends AdminTab
|
||||
);
|
||||
}
|
||||
|
||||
$tokenCatalog = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee));
|
||||
$returnProducts = OrderReturn::getOrdersReturnProducts($orderReturn->id, $order);
|
||||
$orderReturnState = new OrderReturnState($orderReturn->state);
|
||||
|
||||
@ -334,7 +678,7 @@ class AdminAntReturnprocess extends AdminTab
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-offset-2 col-md-4">
|
||||
<form action="'.$currentIndex.'&submitAddorder_return=1&token='.$this->token.'" method="post">
|
||||
<form action="'.$currentIndex.'&submitAddorder_return=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
|
||||
'.($orderReturn->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$orderReturn->id.'" />' : '').'
|
||||
<input type="hidden" name="id_order" value="'.$orderReturn->id_order.'" />
|
||||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||||
@ -464,59 +808,126 @@ class AdminAntReturnprocess extends AdminTab
|
||||
<div class="clearfix"></div>
|
||||
<div class="ln_solid"></div>
|
||||
<div class="panel-content">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-custombordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><span class="anticon anticon-cart"></span> '.$this->l('Produit').'</th>
|
||||
<th>'.$this->l('Prix U').'</th>
|
||||
<th>'.$this->l('Qté').'</th>
|
||||
'.($order->hasBeenPaid() ?'<th>'.$this->l('Remb').'</th>':'').'
|
||||
'.($order->hasBeenDelivered() ?'<th>'.$this->l('Retour').'</th>':'').'
|
||||
<th>'.$this->l('Stock').'</th>
|
||||
<th>'.$this->l('Total').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($order->getProducts() as $key => $product) {
|
||||
if ($order->getTaxCalculationMethod() == PS_TAX_EXC) {
|
||||
$product_price = $product['product_price'] + $product['ecotax'];
|
||||
} else {
|
||||
$product_price = $product['product_price_wt'];
|
||||
}
|
||||
|
||||
if ($product['product_quantity'] > $product['customizationQuantityTotal'])
|
||||
{
|
||||
$quantity = $product['product_quantity'] - $product['customizationQuantityTotal'];
|
||||
$stock = Db::getInstance()->getRow('
|
||||
SELECT '.($product['product_attribute_id'] ? 'pa' : 'p').'.quantity
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
'.($product['product_attribute_id'] ? 'LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON p.id_product = pa.id_product' : '').'
|
||||
WHERE p.id_product = '.(int)($product['product_id']).'
|
||||
'.($product['product_attribute_id'] ? 'AND pa.id_product_attribute = '.(int)($product['product_attribute_id']) : '')
|
||||
);
|
||||
|
||||
$html .='
|
||||
<form action="'.$currentIndex.'&submitCancelProduct=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-custombordered" style="margin-bottom:0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<td style="vertical-align:middle;color:#444;">
|
||||
<a style="color:#444;" href="index.php?tab=AdminCatalog&id_product='.$product['product_id'].'&updateproduct&token='.$tokenCatalog.'">
|
||||
<span style="font-weight:bold;" class="productName">'.$product['product_name'].'</span><br />
|
||||
'.($product['product_reference'] ? '<span style="font-size:10px">'.$this->l('Ref:').' '.$product['product_reference'].'</span><br />' : '')
|
||||
.($product['product_supplier_reference'] ? '<span style="font-size:10px">'.$this->l('Ref Supplier:').' '.$product['product_supplier_reference'].'</span>' : '')
|
||||
.'</a>
|
||||
</td>
|
||||
<td style="vertical-align:middle;color:#444;">'.Tools::displayPrice($product_price,$currency).'</td>
|
||||
<td style="vertical-align:middle;color:#444;">'.$quantity.'</td>
|
||||
'.($order->hasBeenPaid() ? '<td style="vertical-align:middle;color:#444;" align="center" class="productQuantity">'.(int)($product['product_quantity_refunded']).'</td>' : '').'
|
||||
'.($order->hasBeenDelivered() ? '<td style="vertical-align:middle;color:#444;" align="center" class="productQuantity">'.(int)($product['product_quantity_return']).'</td>' : '').'
|
||||
<td style="vertical-align:middle;color:#444;" align="center" class="productQuantity">'.(int)$stock['quantity'].'</td>
|
||||
<td style="vertical-align:middle;color:#444;" align="center">'.Tools::displayPrice(Tools::ps_round($product_price, 2) * ((int)($product['product_quantity']) - $product['customizationQuantityTotal']), $currency, false).'</td>
|
||||
</tr>';
|
||||
<th><span class="anticon anticon-cart"></span> '.$this->l('Produit').'</th>
|
||||
<th>'.$this->l('Prix U').'</th>
|
||||
<th>'.$this->l('Qté').'</th>
|
||||
'.($order->hasBeenPaid() ?'<th>'.$this->l('Remb').'*</th>':'').'
|
||||
<th>'.$this->l('Stock').'</th>
|
||||
<th>'.$this->l('Total').'</th>
|
||||
<th class="text-center">'.($order->module ? ($order->module=="paybox"?'<span class="anticon anticon-credit-card"></span> ':'<span class="anticon anticon-paypal"></span> ') : '').'<span class="anticon anticon-redo2"></span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($order->getProducts() as $key => $product) {
|
||||
if ($order->getTaxCalculationMethod() == PS_TAX_EXC) {
|
||||
$product_price = $product['product_price'] + $product['ecotax'];
|
||||
} else {
|
||||
$product_price = $product['product_price_wt'];
|
||||
}
|
||||
|
||||
if ($product['product_quantity'] > $product['customizationQuantityTotal'])
|
||||
{
|
||||
$quantity = $product['product_quantity'] - $product['customizationQuantityTotal'];
|
||||
$stock = Db::getInstance()->getRow('
|
||||
SELECT '.($product['product_attribute_id'] ? 'pa' : 'p').'.quantity
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
'.($product['product_attribute_id'] ? 'LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON p.id_product = pa.id_product' : '').'
|
||||
WHERE p.id_product = '.(int)($product['product_id']).'
|
||||
'.($product['product_attribute_id'] ? 'AND pa.id_product_attribute = '.(int)($product['product_attribute_id']) : '')
|
||||
);
|
||||
|
||||
$html .='
|
||||
<tr>
|
||||
<td style="vertical-align:middle;color:#444;">
|
||||
<a style="color:#444;" href="index.php?tab=AdminCatalog&id_product='.$product['product_id'].'&updateproduct&token='.$tokenCatalog.'">
|
||||
<span style="font-weight:bold;font-size:11px" class="productName">'.$product['product_name'].'</span><br />
|
||||
'.($product['product_reference'] ? '<span style="font-size:10px">'.$this->l('Ref:').' '.$product['product_reference'].'</span><br />' : '')
|
||||
.($product['product_supplier_reference'] ? '<span style="font-size:10px">'.$this->l('Ref Supplier:').' '.$product['product_supplier_reference'].'</span>' : '')
|
||||
.'</a>
|
||||
</td>
|
||||
<td style="vertical-align:middle;color:#444;">'.Tools::displayPrice($product_price,$currency).'</td>
|
||||
<td style="vertical-align:middle;color:#444;">'.$quantity.'</td>
|
||||
'.($order->hasBeenPaid() ? '<td style="vertical-align:middle;color:#444;" align="center" class="productQuantity"><span class="text-rose">'.(int)($product['product_quantity_refunded']).'</span> | <span class="text-rose">'.(int)($product['product_quantity_return']).'</span></td>' : '').'
|
||||
<td style="vertical-align:middle;color:#444;" align="center" class="productQuantity">'.(int)$stock['quantity'].'</td>
|
||||
<td style="vertical-align:middle;color:#444;" align="center">'.Tools::displayPrice(Tools::ps_round($product_price, 2) * ((int)($product['product_quantity']) - $product['customizationQuantityTotal']), $currency, false).'</td>
|
||||
<td width="70" style="vertical-align:middle;color:#444;">
|
||||
<input class="form-control" type="number" id="cancelQuantity_'.(int)($product['id_order_detail']).'" name="cancelQuantity['.(int)($product['id_order_detail']).']" min="0" max="'.((int)($product['product_quantity']) - (int)($product['product_quantity_return'] + $product['product_quantity_refunded'])).'" value="0" '.(((int)($product['product_quantity_return'] + $product['product_quantity_refunded']) >= (int)($product['product_quantity'])) ? 'disabled="disabled" ' : '').'/>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$html .= '</tbody>
|
||||
</table>
|
||||
$html .= '</tbody>
|
||||
</table>
|
||||
<p class="col-md-12" style="font-size:11px; margin:0 0 10px 0;"><i>* Le chiffre de gauche correspond à la quantité remboursée pré-envoi et celui de droite post-envoi</i></p>
|
||||
<div class="form-inline text-center">
|
||||
<select name="typeReason" class="form-control form-control-sm">
|
||||
<option value="0">Raison du Remboursement</option>
|
||||
<option value="2">CLIENT: Rétractaction post-envoi</option>
|
||||
<option value="4">BBB: Problème SAV</option>
|
||||
<option value="5">BBB: Produit manquant</option>
|
||||
<option value="3">BBB: Erreur Achat / Prod</option>
|
||||
<option value="6">BBB: Erreur Logistique</option>
|
||||
<option value="12">BBB: Suspicion de fraude</option>
|
||||
<option value="9">TRANS: Colis détruit</option>
|
||||
<option value="10">TRANS: Colis perdu</option>
|
||||
<option value="7">Autre</option>
|
||||
</select>
|
||||
<div class="checkbox">
|
||||
<label style="min-height:0px;">
|
||||
<input style="margin:0;" type="checkbox" value="1" name="shippingBack"> Inclure Frais de port
|
||||
<Label>
|
||||
</div>
|
||||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||||
<input class="btn btn-primary" type="submit" name="submitCancelProduct" value="Générer un remboursement"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="ln_solid"></div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">'.$this->l('Changer le statut de la commande').'</h5>
|
||||
<form style="padding:10px 20px;background:#efefef;" class="text-center center" action="'.$currentIndex.'&submitOrderState=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
|
||||
<div class="form-group">
|
||||
<select class="form-control" name="id_order_state">';
|
||||
$currentStateTab = $order->getCurrentStateFull($cookie->id_lang);
|
||||
foreach ($orderStates AS $state){
|
||||
$html .= '<option value="'.$state['id_order_state'].'"'.(($state['id_order_state'] == $currentStateTab['id_order_state']) ? ' selected="selected"' : '').'>'.stripslashes($state['name']).'</option>';
|
||||
}
|
||||
$html .= '
|
||||
</select>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label style="min-height:0px;">
|
||||
<input type="checkbox" value="1" name="noSendMail" /> Ne pas envoyer de mail
|
||||
</label>
|
||||
</div>
|
||||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||||
<input type="submit" name="submitOrderState" value="'.$this->l('Change').'" class="btn btn-primary btn-block" />
|
||||
</form>
|
||||
</div>
|
||||
<!--div class="col-md-6">
|
||||
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">'.$this->l('Remboursement de la commande').'</h5>
|
||||
<form style="padding:10px 20px;background:#efefef;" class="text-center center" action="'.$currentIndex.'&submitRefund=1&token='.$this->token.'" method="post">
|
||||
<div class="form-group">
|
||||
<select class="form-control" name="refund_type">
|
||||
<option value="1">Paypal</option>
|
||||
<option value="2">CB</option>
|
||||
</select>
|
||||
</div>
|
||||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||||
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
||||
<input type="submit" name="submitRefund" value="'.$this->l('Rembourser').'" class="btn btn-primary btn-block" />
|
||||
</form>
|
||||
</div-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user