countProduct()) > 1) { if (OrderReturn::deleteOrderReturnDetail($id_order_return, $id_order_detail, (int)(Tools::getValue('id_customization', 0)))){ Tools::redirectAdmin($currentIndex.'&conf=4token='.$this->token); } else { HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred while deleting an order return detail.')); } } else { HelperFormBootstrap::displayErrors(Tools::displayError('You need at least one product.')); } } else { HelperFormBootstrap::displayErrors(Tools::displayError('The order return is invalid.')); } } else { HelperFormBootstrap::displayErrors(Tools::displayError('The order return detail is invalid.')); } } elseif (Tools::isSubmit('submitAddorder_return')) { if (($id_order_return = (int)(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return)) { $orderReturn = new OrderReturn($id_order_return); $order = new Order($orderReturn->id_order); $customer = new Customer($orderReturn->id_customer); $orderReturn->state = (int)(Tools::getValue('state')); if ($orderReturn->save()) { $orderReturnState = new OrderReturnState($orderReturn->state); $vars = array( '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order_return}' => $id_order_return, '{state_order_return}' => (isset($orderReturnState->name[(int)$order->id_lang]) ? $orderReturnState->name[(int)$order->id_lang] : $orderReturnState->name[(int)Configuration::get('PS_LANG_DEFAULT')])); 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&ok=2&token='.$this->token); } } else { HelperFormBootstrap::displayErrors(Tools::displayError('No order return ID.')); } } elseif (Tools::isSubmit('submitReply')) { if (($id_order_return = (int)(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return)) { if (($id_customer_thread = (int)(Tools::getValue('id_customer_thread'))) AND Validate::isUnsignedId($id_customer_thread)) { $ct = new CustomerThread($id_customer_thread); $cm = new CustomerMessage(); $cm->id_employee = (int)$cookie->id_employee; $cm->id_customer_thread = $ct->id; $cm->message = Tools::htmlentitiesutf8(nl2br2(Tools::getValue('reply_message'))); $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']); if (isset($_FILES) AND !empty($_FILES['joinFile']['name']) AND $_FILES['joinFile']['error'] != 0) { HelperFormBootstrap::displayErrors(Tools::displayError('An error occurred with the file upload.')); } elseif ($cm->add()) { $fileAttachment = NULL; if (!empty($_FILES['joinFile']['name'])) { $cm->file_name = $_FILES['joinFile']['name']; $fileAttachment['content'] = file_get_contents($_FILES['joinFile']['tmp_name']); $fileAttachment['name'] = $_FILES['joinFile']['name']; $fileAttachment['mime'] = $_FILES['joinFile']['type']; } if($ct->id_contact == 9 || $ct->id_contact == 1) { $id_reason = Db::getInstance()->getValue(' SELECT sr.`id_reason` FROM `'._DB_PREFIX_.'support_reason` sr LEFT JOIN `'._DB_PREFIX_.'support_reason_customerthread` src ON (src.id_reason = sr.id_reason) WHERE `id_customer_thread` = '.(int)($ct->id) ); $link_reply = ($ct->id_lang == 3 ? str_replace('com','es',Tools::getShopDomain(true).__PS_BASE_URI__):Tools::getShopDomain(true).__PS_BASE_URI__).'modules/ant_support_form/support.php?id_customer_thread='.(int)($ct->id).'&token='.$ct->token.(($ct->id_contact == 9 || $ct->id_contact == 1)?'&id_contact='.$ct->id_contact : '').((isset($id_reason) && $id_reason)?'&id_reason='.(int)$id_reason : ''); } else { $link_reply = $link->getPageLink('contact-form.php', true).'?id_customer_thread='.(int)($ct->id).'&token='.$ct->token; if($ct->id_lang == 3) { $link_reply = str_replace('com','es',$link_reply); } } $params = array( '{reply}' => nl2br2(Tools::getValue('reply_message')), '{link}' => $link_reply); if (Mail::Send($ct->id_lang, 'reply_msg', Mail::l('An answer to your message is available'), $params, Tools::getValue('msg_email'), NULL, NULL, NULL, $fileAttachment, NULL, _PS_MAIL_DIR_, true)) { $ct->status = 'closed'; $ct->update(); $cm->update(); } 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.')); } } else { HelperFormBootstrap::displayErrors(Tools::displayError('No conversation ID.')); } } else { HelperFormBootstrap::displayErrors(Tools::displayError('No order return ID.')); } } elseif(Tools::getValue('send_return_instruction') && Tools::getValue('id_order_return')) { $id_order = (int) Tools::getValue('id_order'); $id_order_return = (int) Tools::getValue('id_order_return'); if(Validate::isLoadedObject($order = new Order($id_order))) { $customer = new Customer($order->id_customer); $return_link = Db::getInstance()->getRow(' SELECT `return_number`, `link` FROM `'._DB_PREFIX_.'order_return_link` WHERE `id_order_return` = '.(int) $id_order_return.' '); $products = Db::getInstance()->ExecuteS(' SELECT `id_order_detail`, `product_quantity` FROM `'._DB_PREFIX_.'order_return_detail` WHERE `id_order_return` = '.(int) $id_order_return.' '); $product_list = ''; Mail::Send( intval($order->id_lang), 'order_return_2', $subject[(int) $order->id_lang], array( '{id_order}' => $order->id, '{return_link}' => $return_link['link'], '{product_list}' => $product_list, '{product_list_txt}' => implode("\r\n", $product_list_txt), ), $customer->email, $customer->firstname.' '.$customer->lastname ); 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').' '.$orderDetail->product_name.''); } 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.').' '.$orderDetail->product_name.''); } 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 .= " ". $details_refund->product_name . " " . Tools::displayPrice($tprice) . " ". (int)$qty ." " . Tools::displayPrice(($tprice * (int)$qty)) . " "; $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 .= " Frais de port " . Tools::displayPrice($order->total_shipping) . " "; } $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é'); } } } public function display() { global $cookie, $currentIndex; if($return_number = Tools::getValue('return_number')) { if($return = Db::getInstance()->getRow(' SELECT * FROM `'._DB_PREFIX_.'order_return_link` WHERE `return_number` = "'.pSQL($return_number).'" ')) { header('Location: /adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&updateorder_return&token='.Tools::getValue('token')); exit; } } if($return_order = Tools::getValue('return_order')) { if($returns = Db::getInstance()->executeS(' SELECT * FROM `'._DB_PREFIX_.'order_return` WHERE `id_order` = "'.(int)($return_order).'" ')) { if($returns && count($returns) ==1) { header('Location: /adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $returns[0]['id_order_return'].'&updateorder_return&token='.Tools::getValue('token')); exit; } } } 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 '

'.$this->l('Back to list').'
'; } else { $this->displaylist(); } } public function displayForm() { global $cookie, $currentIndex; if (($id_order_return = (int)(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return)) { $orderReturn = new OrderReturn($id_order_return); if (!Validate::isLoadedObject($orderReturn)) { die(Tools::displayError()); } } $order = new Order($orderReturn->id_order); $cart = new Cart((int)$order->id_cart); $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'))); $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 LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = lpws.`id_order_detail`) WHERE `id_order` ='. (int)$order->id ); $shipping_numbers2 = Db::getInstance()->ExecuteS(' SELECT DISTINCT ppp.`shipping_number`, ppp.`date_add` FROM `'._DB_PREFIX_.'philea_parcel` ppp LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = ppp.`id_order_detail`) WHERE od.`id_order` ='. (int)$order->id ); $query_thread = Db::getInstance()->getValue(' SELECT `id_customer_thread` FROM `'._DB_PREFIX_.'customer_thread` WHERE id_customer ='.(int)$order->id_customer.' AND id_order = '.(int)$order->id.' '); if($query_thread) { $thread = new CustomerThread((int)$query_thread); $last_message = Db::getInstance()->getRow(' SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name, CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname FROM '._DB_PREFIX_.'customer_thread ct LEFT JOIN '._DB_PREFIX_.'customer_message cm ON (ct.id_customer_thread = cm.id_customer_thread) LEFT JOIN '._DB_PREFIX_.'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = '.(int)$cookie->id_lang.') LEFT JOIN '._DB_PREFIX_.'employee e ON e.id_employee = cm.id_employee LEFT JOIN '._DB_PREFIX_.'customer c ON (IFNULL(ct.id_customer, ct.email) = IFNULL(c.id_customer, c.email)) WHERE ct.id_customer_thread = '.(int)($thread->id).' ORDER BY cm.date_add DESC' ); } $tokenCatalog = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)); $returnProducts = OrderReturn::getOrdersReturnProducts($orderReturn->id, $order); $orderReturnState = new OrderReturnState($orderReturn->state); $other_returnProducts = Db::getInstance()->ExecuteS(' SELECT a.*, orsl.`name`, ord.`id_order_detail`, ord.`qty` FROM '._DB_PREFIX_.'order_return a LEFT JOIN '._DB_PREFIX_.'order_return_detail_qty ord ON (ord.`id_order_return` = a.`id_order_return`) LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)($cookie->id_lang).') WHERE a.id_order='.(int)$order->id.' AND a.id_order_return != '.(int)$orderReturn->id.' '); $colorStates = array( 1 => "anticon anticon-hour-glass text-orange", 2 => "anticon anticon-hour-glass text-orange", 3 => "anticon anticon-box-add text-orange", 4 => "anticon anticon-cross text-rose", 5 => "anticon anticon-checkmark text-green-light", ); $helper = new HelperFormBootstrap(); $helper->_select2 = true; $helper->_inputMask = true; $html = $helper->renderStyle(); $html .= '

Retour #'.$id_order_return.'

'.$orderReturnState->name[(int)$cookie->id_lang].'

'; $return_link = Db::getInstance()->getRow(' SELECT `return_number`, `link` FROM `'._DB_PREFIX_.'order_return_link` WHERE `id_order_return` = '.(int) $id_order_return.' '); $html .= '

Lien retour Etiquette MR : '.($return_link? ''.$return_link['return_number'].' ':'Pas de lien retour').'

'; $html .='

'; $productReturned = array(); foreach ($returnProducts AS $k => $product) { $productReturned[] = $product['product_id']; $img_path = ''; $img = Db::getInstance()->getRow(' SELECT id_image FROM `'._DB_PREFIX_.'image` i WHERE i.`id_product` = '.(int)$product['product_id'].' AND i.`cover` = 1' ); if (isset($img['id_image']) && !empty($img['id_image'])) { $image_obj = new Image((int)$img['id_image']); $img_path = (isset($image_obj)?$image_obj->getExistingImgPath():''); } if (!isset($quantityDisplayed[(int)($product['id_order_detail'])]) OR (int)($product['product_quantity']) > (int)($quantityDisplayed[(int)($product['id_order_detail'])])) { $html .=' '; } } $html .='
'.$this->l('Produit').' '.$this->l('Qté').' '.$this->l('Action').'
'.mb_strimwidth($product['product_name'], 0, 55, "...").'
'.$product['product_quantity'].'
'.($orderReturn->id ? '' : '').'
'; if($other_returnProducts && !empty($other_returnProducts)){ $html .= '

Autre(s) produit(s) en retour pour cette commande :

'; foreach ($other_returnProducts as $key => $return_product) { $order_detail = new OrderDetail((int)$return_product['id_order_detail']); $img_path = ''; $img = Db::getInstance()->getRow(' SELECT id_image FROM `'._DB_PREFIX_.'image` i WHERE i.`id_product` = '.(int)$order_detail->product_id.' AND i.`cover` = 1' ); if (isset($img['id_image']) && !empty($img['id_image'])) { $image_obj = new Image((int)$img['id_image']); $img_path = (isset($image_obj)?$image_obj->getExistingImgPath():''); } $html .= ' '; } $html .= '
# Retour '.$this->l('Produit').' '.$this->l('Qté').' '.$this->l('Statut').' '.$this->l('Action').'
'.(int) $return_product['id_order_return'].' '.mb_strimwidth($order_detail->product_name, 0, 55, "...").'
'.$return_product['qty'].' '.$return_product['name'].'
'; } $html .='
'; $html .= '

Résumé Commande (#'.(int)$order->id.') - '.$customer->firstname.' '.$customer->lastname.' ('.$this->l('#').$customer->id.')

Détails paiement
'.Tools::substr($order->payment, 0, 32).' '.($order->module ? '('.$order->module.')' : '').'
'.($order->total_discounts > 0 ? '' : '').' '.($order->total_wrapping > 0 ? '' : '').'
'.$this->l('Products').''.Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency, false).'
'.$this->l('Discounts').'-'.Tools::displayPrice($order->total_discounts, $currency, false).'
'.$this->l('Wrapping').''.Tools::displayPrice($order->total_wrapping, $currency, false).'
'.$this->l('Shipping').''.Tools::displayPrice($order->total_shipping, $currency, false).'
'.$this->l('Total').''.Tools::displayPrice($order->total_paid, $currency, false).($order->total_paid != $order->total_paid_real ? '
('.$this->l('Paid:').' '.Tools::displayPrice($order->total_paid_real, $currency, false, false).')' : '').'
Transporteur

'.$data['carrier_name'].'

    '; if(count($shipping_numbers) > 0){ foreach ($shipping_numbers as $key => $number) { $date = new DateTime($number['date_add']); $html .= '
  • '. $number['shipping_number'] .' ajouté le '. $date->format('d/m/Y') .'
  • '; } } if(count($shipping_numbers2) > 0){ foreach ($shipping_numbers2 as $key => $number) { $date = new DateTime($number['date_add']); $html .= '
  • '. $number['shipping_number'] .' ajouté le '. $date->format('d/m/Y') .'
  • '; } } $html .= '
Adresse Facturation

'.$data['order_invoice_address'].'

Adresse Livraison

'.$data['order_address'].'

'.($order->hasBeenPaid() ?'':'').' '; 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 .=' '.($order->hasBeenPaid() ? '' : '').' '; } } $html .= '
'.$this->l('Produit').' '.$this->l('Prix U').' '.$this->l('Qté').''.$this->l('Remb').'*'.$this->l('Stock').' '.$this->l('Total').' '.($order->module ? ($order->module=="paybox"?' ':' ') : '').'
'.$product['product_name'].'
'.($product['product_reference'] ? ''.$this->l('Ref:').' '.$product['product_reference'].'
' : '') .($product['product_supplier_reference'] ? ''.$this->l('Ref Supplier:').' '.$product['product_supplier_reference'].'' : '') .'
'.Tools::displayPrice($product_price,$currency).' '.$quantity.''.(int)($product['product_quantity_refunded']).' | '.(int)($product['product_quantity_return']).''.(int)$stock['quantity'].' '.Tools::displayPrice(Tools::ps_round($product_price, 2) * ((int)($product['product_quantity']) - $product['customizationQuantityTotal']), $currency, false).' = (int)($product['product_quantity'])) ? 'disabled="disabled" ' : '').'/>

* Le chiffre de gauche correspond à la quantité remboursée pré-envoi et celui de droite post-envoi

'.$this->l('Changer le statut de la commande').'

SAV '.(isset($thread)?' Conversation #'.(int)($thread->id).'':'').'

'; if(isset($thread)){ $products = Db::getInstance()->ExecuteS(' SELECT spc.*, pl.`name` FROM `'._DB_PREFIX_.'support_product_customerthread` spc LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = spc.`id_product`) WHERE spc.`id_customer_thread` = '.(int)$thread->id.' AND pl.`id_lang` = 2' ); if($products && !empty($products)) { $html .='
Produit(s) Concerné(s)
'; foreach ($products as $product) { $img_path = ''; $img = Db::getInstance()->getRow(' SELECT id_image FROM `'._DB_PREFIX_.'image` i WHERE i.`id_product` = '.(int)$product['id_product'].' AND i.`cover` = 1' ); if (isset($img['id_image']) && !empty($img['id_image'])) { $image_obj = new Image((int)$img['id_image']); $img_path = (isset($image_obj)?$image_obj->getExistingImgPath():''); } $html .=' '.mb_strimwidth($product['name'], 0, 55, "...").'
'; } } if($last_message){ $html .='
Dernier Message
'; $last_message['message'] = preg_replace('/(https?:\/\/[a-z0-9#%&_=\(\)\.\? \+\-@\/]{6,1000})([\s\n<])/Uui', '\1\2', html_entity_decode($last_message['message'], ENT_NOQUOTES, 'UTF-8')); if(!empty($last_message['employee_name'])) { $html .='

Bébé Boutik - ('.Tools::displayDate($last_message['date_add'], (int)($cookie->id_lang), true).')

"'.$last_message['message'].'"

'; } else { $html .='

'.$customer->firstname.' '.$customer->lastname.' - ('.Tools::displayDate($last_message['date_add'], (int)($cookie->id_lang), true).')

"'.$last_message['message'].'"

'; } $orderMessages = OrderMessage::getOrderMessages((int)($last_message['id_lang'])); $html .='
Envoyer un message
'; } } else { $html .='

Pas de conversation en rapport avec cette commande !

'; } $html .='
'; $html .= $helper->renderScript(); echo $html; } public function displaylist() { global $cookie, $currentIndex; $order_returns = Db::getInstance()->ExecuteS(' SELECT a.*, orsl.`name` FROM '._DB_PREFIX_.'order_return a LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)($cookie->id_lang).') '.(Tools::getValue('return_order')?' WHERE a.id_order='.Tools::getValue('return_order'):'') ); $colorStates = array( 1 => "anticon anticon-hour-glass text-orange", 2 => "anticon anticon-hour-glass text-orange", 3 => "anticon anticon-box-add text-orange", 4 => "anticon anticon-cross text-rose", 5 => "anticon anticon-checkmark text-green-light", ); $helper = new HelperFormBootstrap(); $helper->_select2 = true; $helper->_inputMask = true; $html = $helper->renderStyle(); $html .= '

Rechercher par code barre

Rechercher par commande

Liste des Retours

'; foreach ($order_returns as $key => $return) { $html .= ' '; } $html .= '
'.$this->l('#').' '.$this->l('# Order').' '.$this->l('# Customer').' '.$this->l('Status').' '.$this->l('Date').' '.$this->l('Action').'
'.$return['id_order_return'].' n° '.$return['id_order'].' '.$return['id_customer'].' '.$return['name'].' '.date('d/m/Y H:i',strtotime($return['date_add'])).'
'; $helper->_js .= ' '; $html .= $helper->renderScript(); echo $html; } public function getOrderDetail($cart, $id_lang, $order){ if(Db::getInstance()->getValue(' SELECT `id_carrier` FROM `'._DB_PREFIX_.'carrier` WHERE `id_carrier` = '.(int) $cart->id_carrier.' AND `name` LIKE "%colissimo%" ')) { $socol = Db::getInstance()->getRow(' SELECT * FROM `'._DB_PREFIX_.'socolissimo_delivery_info` WHERE `id_cart` = '.(int) $cart->id.' AND `cecountry` IN ("FR","BE","ES") AND (`pradress1`!= "" OR `pradress2`!= "" OR `pradress3`!= "" OR `pradress4`!= "") '); if((int) $cart->id_carrier == (int)Configuration::get('ANT_CARRIER_DOM')) { $DOM_front = true; } else { $DOM_front = false; } if($socol && !$DOM_front) { $order_address = nl2br(preg_replace("/(\r\n){2,}/", "\r\n", implode("\r\n", array( $socol['cefirstname'].' '.$socol['cename'], $socol['cecompanyname'], $socol['prname'], $socol['prcompladress'], $socol['pradress1'], $socol['pradress2'], $socol['pradress3'], $socol['pradress4'], $socol['przipcode'].' '.$socol['prtown'], $socol['cecountry'], $socol['cephonenumber'], !empty($socol['cedoorcode1'])? 'Code porte 1 : '.$socol['cedoorcode1']: '', !empty($socol['cedoorcode2'])? 'Code porte 2 : '.$socol['cedoorcode2']: '', $socol['cedeliveryinformation'], )))); } else { $order_address = nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_delivery))); } } elseif(Db::getInstance()->getValue(' SELECT COUNT(*) FROM `'._DB_PREFIX_.'mr_method` WHERE `id_carrier` = '.(int) $cart->id_carrier.' ')) { $mr = Db::getInstance()->getRow(' SELECT mr_s.* FROM `' . _DB_PREFIX_ . 'mr_selected` mr_s WHERE `id_cart` = ' . (int) $cart->id . ' '); if($mr) { $order_address = nl2br(preg_replace("/(\r\n){2,}/", "\r\n", implode("\r\n", array( $mr['MR_Selected_LgAdr1'], $mr['MR_Selected_LgAdr2'], $mr['MR_Selected_LgAdr3'] . ' ' . $mr['MR_Selected_LgAdr4'], $mr['MR_Selected_CP'] . ' ' . $mr['MR_Selected_Ville'], 'FRANCE', )))); } else { $order_address = nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_delivery))); } } else { $order_address = nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_delivery))); } $carrier_name = Db::getInstance()->getValue(' SELECT `name` FROM `'._DB_PREFIX_.'carrier` WHERE `id_carrier` = '.(int) $cart->id_carrier.' '); return array( 'order_invoice_address' => nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_invoice))), 'order_address' => $order_address, 'carrier_name' => $carrier_name, ); } }