From 6330105f81ce3dcd25d9bb0d87cfa463d5e792ed Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Thu, 9 Nov 2017 14:51:48 +0100 Subject: [PATCH 1/4] big inte of adminOrder view --- adm/helpers/includes/css/custom.css | 65 +- adm/tabs/AdminOrders.php | 1058 +++++++++++++++++ .../AdminAntReturnprocess.php | 3 +- modules/fraud/fraud.php | 42 + 4 files changed, 1166 insertions(+), 2 deletions(-) diff --git a/adm/helpers/includes/css/custom.css b/adm/helpers/includes/css/custom.css index 47292bb2..0bee49c7 100644 --- a/adm/helpers/includes/css/custom.css +++ b/adm/helpers/includes/css/custom.css @@ -30,6 +30,9 @@ ul#menu li a { .text-purple-dark{ color: #504d8b!important; } +.text-grey-light{ + color: #EFEFEF!important; +} #content { background-color: #f5f5f9; } @@ -73,7 +76,6 @@ a:active, color: #fff; background: #504d8b; border-color: #504d8b;} - .btn-success { background: #26B99A; border: 1px solid #169F85;} @@ -83,6 +85,46 @@ a:active, .btn-success.active, .open .dropdown-toggle.btn-success { background: #169F85;} +.btn-green-light { + background: rgba(38, 185, 154, 0.6); + border: 1px solid #169F85; + color:#fff;} +.btn-green-light:hover, +.btn-green-light:focus, +.btn-green-light:active, +.btn-green-light.active, +.open .dropdown-toggle.btn-green-light { + background: #169F85;} +.btn-grey { + background: #efefef; + border: 1px solid #CCCCCC; + color:#333333;} +.btn-grey:hover, +.btn-grey:focus, +.btn-grey:active, +.btn-grey.active, +.open .dropdown-toggle.btn-grey { + background: #CCCCCC;} +.btn-red { + background: rgba(217, 83, 79, 0.3); + border: 1px solid #d43f3a; + color:#d43f3a;} +.btn-red:hover, +.btn-red:focus, +.btn-red:active, +.btn-red.active, +.open .dropdown-toggle.btn-red { + background: #d43f3a;} +.btn-warning-more { + color: #eea236; + background-color: rgba(240, 173, 78, 0.2); + border-color: #eea236;} +.btn-warning-more:hover, +.btn-warning-more:focus, +.btn-warning-more:active, +.btn-warning-more.active, +.open .dropdown-toggle.btn-warning-more { + background: #eea236;} h2 { font-size: 18px; @@ -139,6 +181,13 @@ form label{ white-space: nowrap; color: #504d8b; } +.panel h2.high_title{ + margin: 5px 0 6px; + font-weight: bold; + text-overflow: ellipsis; + overflow: hidden; + color: #504d8b; +} .div-title h4{ font-size: 15px; } @@ -296,6 +345,16 @@ div.tagsinput span.tag a { background-color: #FFA74E; border: 1px solid #FFA74E; } +#content .alert-warning-light { + color: #fc9732; + background-color: rgba(255, 167, 78, 0.3); + border: 1px solid #FFA74E; +} +#content .alert-info { + color: #31708f; + background-color: #d9edf7; + border-color: #bce8f1; +} #content .alter-warning i.glyphicon, #content .alert-warning span.glyphicon, #content .alert-warning i.anticon, @@ -389,6 +448,10 @@ table.table tr th { background: #504d8b; color: #fff; } +table.table.th-grey tr th { + background: #efefef; + color: #504d8b; +} .table tr td { color: #000; } diff --git a/adm/tabs/AdminOrders.php b/adm/tabs/AdminOrders.php index d0c98a7f..4ea18354 100755 --- a/adm/tabs/AdminOrders.php +++ b/adm/tabs/AdminOrders.php @@ -24,6 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ +require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php'); class AdminOrders extends AdminTab { @@ -1027,8 +1028,935 @@ class AdminOrders extends AdminTab return $content; } + public function _viewDetails() { + global $currentIndex, $cookie, $link; + $irow = 0; + if (!($order = $this->loadObject())) + return; + + $tokenCatalog = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)); + $customer = new Customer($order->id_customer); + $customerStats = $customer->getStats(); + $addressInvoice = new Address($order->id_address_invoice, (int)($cookie->id_lang)); + if (Validate::isLoadedObject($addressInvoice) AND $addressInvoice->id_state) + $invoiceState = new State((int)($addressInvoice->id_state)); + $addressDelivery = new Address($order->id_address_delivery, (int)($cookie->id_lang)); + if (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state) + $deliveryState = new State((int)($addressDelivery->id_state)); + $carrier = new Carrier($order->id_carrier); + $history = $order->getHistory($cookie->id_lang); + $products = $order->getProducts(); + $customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart)); + Product::addCustomizationPrice($products, $customizedDatas); + $discounts = $order->getDiscounts(); + $messages = Message::getMessagesByOrderId($order->id, true); + $states = OrderState::getOrderStates((int)($cookie->id_lang)); + $currency = new Currency($order->id_currency); + $currentLanguage = new Language((int)($cookie->id_lang)); + $currentState = OrderHistory::getLastOrderState($order->id); + $sources = ConnectionsSource::getOrderSources($order->id); + $cart = Cart::getCartByOrderId($order->id); + $data = $this->_getOrderDetail($cart,(int)$cart->id_lang,$order); + $carriers_socol = explode(',', Configuration::get('ANT_CARRIERS_SOCOL')); + $carriers_mr = explode(',', Configuration::get('ANT_CARRIERS_MR')); + $currentStateTab = $order->getCurrentStateFull($cookie->id_lang); + + $shipping_numbers = array(); + foreach(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 + ) as $row){ + $shipping_numbers[$row['shipping_number']] = $row; + } + foreach(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 + ) as $row){ + $shipping_numbers[$row['shipping_number']] = $row; + } + foreach(Db::getInstance()->ExecuteS(' + SELECT DISTINCT mrp.`shipping_number`, mrp.`date_add` + FROM `'._DB_PREFIX_.'mondialrelay_parcel` mrp + LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = mrp.`id_order_detail`) + WHERE od.`id_order` ='. (int)$order->id + ) as $row){ + $shipping_numbers[$row['shipping_number']] = $row; + } + foreach(Db::getInstance()->ExecuteS(' + SELECT DISTINCT drp.`shipping_number`, drp.`date_add` + FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` drp + LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = drp.`id_order_detail`) + WHERE od.`id_order` ='. (int)$order->id.' + GROUP BY drp.`shipping_number`' + ) as $row){ + $shipping_numbers[$row['shipping_number']] = $row; + } + if(!empty($order->shipping_number) && !isset($shipping_numbers[$order->shipping_number])){ + $shipping_numbers[$order->shipping_number] = array( + 'shipping_number' => $order->shipping_number + ); + } + + $row = array_shift($history); + + $product_psale = array(); + $products_ids = array(); + foreach(Db::getInstance()->ExecuteS(' + SELECT DISTINCT `product_id` + FROM `'._DB_PREFIX_.'order_detail` + WHERE `id_order` = '.(int) $order->id.' + ') as $r) { + $products_ids[] = (int) $r['product_id']; + } + foreach(Db::getInstance()->ExecuteS(' + SELECT * + FROM `'._DB_PREFIX_.'product_ps_cache` + WHERE `id_product` IN ('.implode(', ', $products_ids).') + ') as $r) { + $product_psale[(int) $r['id_product']] = (int) $r['id_sale']; + } + + $helper = new HelperFormBootstrap(); + $helper->_select2 = true; + $helper->_inputMask = true; + $html = $helper->renderStyle(); + + if ($prevOrder = Db::getInstance()->getValue('SELECT id_order FROM '._DB_PREFIX_.'orders WHERE id_order < '.(int)$order->id.' ORDER BY id_order DESC')) + $prevOrder = ''; + if ($nextOrder = Db::getInstance()->getValue('SELECT id_order FROM '._DB_PREFIX_.'orders WHERE id_order > '.(int)$order->id.' ORDER BY id_order ASC')) + $nextOrder = ''; + + + if ($order->total_paid != $order->total_paid_real) { + $html.= '
'.$this->l('Warning:').' '.Tools::displayPrice($order->total_paid_real, $currency, false).' '.$this->l('paid instead of').' '.Tools::displayPrice($order->total_paid, $currency, false).' !


'; + } + + $html .= ' +
+
+
+
+

+ '.$prevOrder.' + '.(Validate::isLoadedObject($customer) ? $customer->firstname.' '.$customer->lastname.' - ' : '').''.$this->l('Order #').sprintf('%06d', $order->id).' + '.$nextOrder.' +

+
+
+
+
+
'; + + $html.=' +
+
+
+
+

'.$this->_displayStateIcon($currentStateTab['id_order_state'],stripslashes($row['ostate_name'])).' ('.Tools::displayDate($row['date_add'], (int)($cookie->id_lang), true).' '.((!empty($row['employee_lastname'])) ? ' - '.stripslashes(Tools::substr($row['employee_firstname'], 0, 1)).'. '.stripslashes($row['employee_lastname']).'' : '').')

+
+
+
+ Voir historique +
+ + + + + + + '; + foreach ($history AS $row) + { + $html.= ' + + + + + '; + } + $html.= ' +
'.Tools::displayDate($row['date_add'], (int)($cookie->id_lang), true).''.stripslashes($row['ostate_name']).''.((!empty($row['employee_lastname'])) ? '('.stripslashes(Tools::substr($row['employee_firstname'], 0, 1)).'. '.stripslashes($row['employee_lastname']).')' : '').'
'.Tools::displayDate($row['date_add'], (int)($cookie->id_lang), true).''.stripslashes($row['ostate_name']).''.((!empty($row['employee_lastname'])) ? '('.stripslashes(Tools::substr($row['employee_firstname'], 0, 1)).'. '.stripslashes($row['employee_lastname']).')' : '').'
+
+
+
+ +
+
+ +
+ + +
+
+
+
'; + /* Display customer information */ + if (Validate::isLoadedObject($customer)){ + $html.= ' +
+
+
+

'.$this->l('Customer information').'

+
+
+
+

+ '.$customer->firstname.' '.$customer->lastname.' ('.$this->l('#').$customer->id.')
+ ('.$customer->email.') +

'; + if ($customer->isGuest()) + { + $html.= ' + '.$this->l('This order has been placed by a').' '.$this->l('guest').''; + if (!Customer::customerExists($customer->email)) + { + $html.= ' +
+ +

+ '.$this->l('This feature will generate a random password and send an e-mail to the customer').' +
'; + } + else + $html.= '
'.$this->l('A registered customer account exists with the same email address').'
'; + } + else + { + $html.='

'.$this->l('Account registered:').' '.Tools::displayDate($customer->date_add, (int)($cookie->id_lang), true).'
+ '.$this->l('Valid orders placed:').' '.$customerStats['nb_orders'].'
+ '.$this->l('Total paid since registration:').' '.Tools::displayPrice(Tools::ps_round(Tools::convertPrice($customerStats['total_orders'], $currency), 2), $currency, false).'

'; + } + $html.= ' +
+
+
'; + } + $html.= ' +
'; + + // $html.= '
+ //
'; + // // display bar code if module enabled + // $hook = Module::hookExec('invoice', array('id_order' => $order->id)); + // if ($hook !== false) + // { + // $html.= '
'; + // $html.= $hook; + // $html.= '

'; + // } + // $html.=' + //
+ //
'; + $html.= '
'; + // display hook specified to this page : AdminOrder + if (($hook = Module::hookExec('adminOrderNew', array('id_order' => $order->id))) !== false){ + $html.= $hook; + } + $html.=' +
'; + $html.='
+
+
+
+

Résumé Commande

+ + '.(($currentState->delivery OR $order->delivery_number) + ? '' + : '').' + '.((($currentState->invoice OR $order->invoice_number) AND count($products)) + ? '' + : '').' +
+
+
+
+
+
+
+
Détails paiement
+
+
+
+

'.Tools::substr($order->payment, 0, 32).' '.($order->module ? '('.$order->module.')' : '').'

+

'.$this->l('Cart #').sprintf('%06d', $cart->id).'

+

'.$this->l('Recycled package').'

+

'.(!empty($order->gift_message) ? ' '.$this->l('Gift wrapping').'':$this->l('Gift wrapping')).'

+
+
+
+ + + '.($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).')' : '').'
+
+ '.(!empty($order->gift_message) ? '
'.$this->l('Message:').'
'.nl2br2($order->gift_message).'
' : '').' +
+
+
+
Transporteur
'; + // carrier info + $html .= ' +
+
+
+

'.$order->printCarrier($order->id_carrier,array()).' '.($carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name).'

+

'.number_format($order->getTotalWeight(), 3).' '.Configuration::get('PS_WEIGHT_UNIT').'

'; + + // delivery delay + if (Module::isInstalled('privatesales_delay')) { + if (!class_exists('SaleDelay')) { + require_once _PS_ROOT_DIR_.'/modules/privatesales_delay/saledelay.php'; + } + $delay_products = SaleDelay::associateDelay($products); + $delays = array_keys($delay_products); + $date = new DateTime($order->date_add); + $delivery_date = SaleDelay::getDeliveryDate($delays, null, $date, true); + + foreach($delivery_date as $k => $date) { + if($k == 1) { + $html .= '

+ '.$date['date_start']->format('d/m/Y').' - '.$date['date_end']->format('d/m/Y').' +

'; + } elseif ($k == 5){ + $html .= '

'.$this->l('avant le 24/12').'

'; + } elseif ($k == 8){ + $html .= '

'.$this->l('envoi en 48h').'

'; + } elseif ($k == 9){ + $html .= '

'.$this->l('Delai indiqué sur la fiche produit').'

'; + } + } + } + $html.='
+
'; + + // shipping numbers + $html.=' +
+ + + + + + '; + foreach($shipping_numbers as $number){ + $link =''; + if(isset($number['link']) && !empty($number['link'])){ + $link = $number['link']; + } else { + $link = str_replace('@', $number['shipping_number'],$carrier->url); + } + $html.=' + + + + '; + } + $html .= ' +
'.$this->l('Date').''.$this->l('Numéro de suivi').'
'.(isset($number['date_add'])?date('d/m/Y',strtotime($number['date_add'])):'/').''.$number['shipping_number'].'
'; + + /* Display shipping number field */ + if ($carrier->url && $order->hasBeenShipped()){ + $html .= ' +
+ + + +
'; + } + + /* Carrier module */ + // if ($carrier->is_module == 1) + // { + // $module = Module::getInstanceByName($carrier->external_module_name); + // if (method_exists($module, 'displayInfoByCart')) + // $html .= call_user_func(array($module, 'displayInfoByCart'), $order->id_cart); + // } + $html .= '
+
+
+
+
+
+
+
+
+ Adresse Facturation (Presta) + +
+

'.$data['order_invoice_address'].'

+
+
+
+ Adresse Livraison (Presta) + +
+

'.$data['order_delivery_address'].'

+
+
+
+ '.$order->printCarrier($order->id_carrier,array()).' Adresse Livraison + '.($cart->id_carrier!=(int)Configuration::get('ANT_CARRIER_DOM') && in_array($cart->id_carrier,$carriers_socol)?'':'').' + '.(in_array($cart->id_carrier,$carriers_mr)?'':'').' +
+

'.$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']; + } + + $image = array(); + if (isset($product['product_attribute_id']) AND (int)($product['product_attribute_id'])){ + $image = Db::getInstance()->getRow(' + SELECT id_image + FROM '._DB_PREFIX_.'product_attribute_image + WHERE id_product_attribute = '.(int)($product['product_attribute_id'])); + } + if (!isset($image['id_image']) OR !$image['id_image']) { + $image = Db::getInstance()->getRow(' + SELECT id_image + FROM '._DB_PREFIX_.'image + WHERE id_product = '.(int)($product['product_id']).' AND cover = 1'); + } + if (isset($image['id_image'])){ + $target = _PS_TMP_IMG_DIR_.'product_mini_'.(int)($product['product_id']).(isset($product['product_attribute_id']) ? '_'.(int)($product['product_attribute_id']) : '').'.jpg'; + if (file_exists($target)){ + $products[$k]['image_size'] = getimagesize($target); + } + } + + if ($product['product_quantity'] > $product['customizationQuantityTotal']) + { + $imageObj = new Image($image['id_image']); + $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() ? '' : '').' + + + + '; + } + } + if (sizeof($discounts)) + { + foreach ($discounts as $discount){ + $html .= ' + + + + + '; + } + } + $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"?' ':' ') : '').'
+ '.(isset($image['id_image']) ? cacheImage(_PS_IMG_DIR_.'p/'.$imageObj->getExistingImgPath().'.jpg','product_mini_'.(int)($product['product_id']).(isset($product['product_attribute_id']) ? '_'.(int)($product['product_attribute_id']) : '').'.jpg', 45, 'jpg') : '--').' + + '.$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" ' : '').'/> +
'.$this->l('Bon réduction').'
'.$discount['name'].'
'.($discount['value'] != 0.00 ? '- ' : '').Tools::displayPrice($discount['value'], $currency, false).'
+

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

'; + + $html .= ' +
'; + if ($order->hasBeenDelivered() AND Configuration::get('PS_ORDER_RETURN')){ + $html .= ' 
'; + } + if ((!$order->hasBeenDelivered() AND $order->hasBeenPaid()) OR ($order->hasBeenDelivered() AND Configuration::get('PS_ORDER_RETURN'))) { + $html .= ' +  
+  
+  
+ '; + } + if (!$order->hasBeenDelivered() OR ($order->hasBeenDelivered() AND Configuration::get('PS_ORDER_RETURN'))){ + $html .= '
'; + } + + $html .= ' +
'; + $html .= ' +
+
'; + if($order->module && $order->module=="paypal"){ + $html.=' +
+
+ + +
+
'; + } + $html.=' +
+
+
+
+
+
'.($order->module ? ($order->module=="paybox"?' ':' ') : '').' Info Remboursement
'; + $slips = OrderSlip::getOrdersSlip($order->id_customer, $order->id); + if (sizeof($slips)){ + $html .= '
'; + foreach ($slips as $slip){ + $html .= ''.Tools::displayDate($slip['date_upd'], $cookie->id_lang).' : '.$this->l('#').sprintf('%06d', $slip['id_order_slip']).'
'; + $html .= ''; + } + $html .= '
'; + } + $html .= '
'; + if($order->module && $order->module=="paybox"){ + require_once dirname(__FILE__).'/../../modules/paybox/paybox.php'; + $refundsPaybox = Paybox::getAllRefundbyOrder($order->id); + if (sizeof($refundsPaybox)) + { + $html .=''; + foreach ($refundsPaybox as $refund) { + $html .=' + + + + '; + } + $html .='
'.(!empty($refund['product_name'])?$refund['product_name']:'Frais de port').''. $refund['amount'] / 100 . '€
'; + } else { + $html .= '

Pas de remboursement

'; + } + } elseif($order->module && $order->module=="paypal") { + $messages = Db::getInstance()->ExecuteS(' + SELECT `message`, `date_add` + FROM `ps_message` + WHERE `id_order` = '.$order->id.' + AND (`message` LIKE "%Refund operation%" || `message` LIKE "%Cancel products%") + ORDER BY `date_add` DESC + '); + if($messages && !empty($messages)) { + foreach ($messages as $message) { + $html .= '

('.date('d/m/Y',strtotime($message['message'])).'):
'.$message['message'].'

'; + } + } + if(empty($messages)){ + $html .= '

Pas de remboursement

'; + } + + } + $html .='
+
+
+
+
+
+
+
+
'; + + /* Display send a message to customer & returns/supplier demands*/ + $returns = OrderReturn::getOrdersReturn($order->id_customer, $order->id); + $html.= ' +
+
+
+
+

Nouveau Message

+
+
+
+
+ +
+ +

+ '.$this->l('Display to consumer?').' + '.$this->l('Yes').' + '.$this->l('No').' +

+

+ + + +
+ +
+
+
+
+
'; + /* Display list of messages */ + + $html.=' +
+
+
+

'.$this->l('Messages').'

+
+
+
'; + if (sizeof($messages)) { + foreach ($messages as $message) + { + $html.= ''; + } + $html.= '

'.$this->l('When you read a message, please click on the green check.').'

'; + } else { + $html.= '
'.$this->l('No Message for this order.').'
'; + } + $html.= '
+
+
'; + $html.= ' +
'; // + + $html.= ' +
+
+
+
+

'.$this->l('Merchandise returns').'

+
+
+
'; + if (!sizeof($returns)){ + $html.= ' +
'.$this->l('Create a product return').'
+
'.$this->l('No merchandise return for this order.').'
'; + } else { + $html.=' + + + + + + + + + '; + foreach ($returns as $key => $return) { + $state = new OrderReturnState($return['state']); + /* Mondial relay return */ + $return_link = FALSE; + if($state->id == 2) { + $return_link = Db::getInstance()->getRow(' + SELECT `return_number`, `link` + FROM `'._DB_PREFIX_.'order_return_link` + WHERE `id_order_return` = '.(int) $return['id_order_return'].' + '); + } + $html.= ' + + + + + + + '; + } + $html.=' +
'.$this->l('Date').''.$this->l('ID').''.$this->l('Status').''.$this->l('Link').''.$this->l('Resend').'
'.Tools::displayDate($return['date_upd'], $cookie->id_lang).''.$this->l('#').sprintf('%06d', $return['id_order_return']).''.$state->name[$cookie->id_lang].''.($return_link?''.$return_link['return_number'].'': '').''.($return_link?'': '').'
'; + + if(in_array($addressDelivery->id_country, array(3, 6, 8))) { + $returnable = array(); + foreach ($products as $k => $product) { + $product['id_sale'] = $product_psale[(int) $product['product_id']]; + $qty = OrderReturn::getOrderDetailReturnQty($product, $currentState->id); + if($qty > 0) { + $returnable[$product['id_order_detail']] = array($product['product_name'], $qty); + } + } + if(count($returnable) > 0) { + $instructions = array( + 1 => 'Remboursement + Mise en stock', + 2 => 'Échange', + 3 => 'Défectueux', + 4 => 'Commande à ré-expédier', + 5 => 'Commande à rembourser', + ); + $reasons = array( + // 1 => 'CLIENT : Annulation pré-envoi', + 2 => 'CLIENT : Rétractation post-envoi', + 11 => 'CLIENT : Annulation pour ré-achat', + 4 => 'FEUR : Problème SAV', + 5 => 'FEUR : Produit manquant', + 3 => 'BBB : Erreur Achat / Prod', + 6 => 'BBB : Erreur Logistique ', + 8 => 'BBB : Pbme Site / Paiment', + 12 => 'BBB : Suspicion de fraude', + 9 => 'TRANS : Colis détruit', + 10 => 'TRANS : Colis perdu', + 7 => 'Autre' + ); + + $helper->_js .= ''; + + $html.= ' +
+
'.$this->l('Create a product return').'
+
+
    '; + foreach($returnable as $id_order_detail => $product) { + $html.= ' +
  • x '.$product[0]. '
  • +
  • '; + for($i = 1; $i <= $product[1]; $i++) { + $html.= ' +
    + + + + +
    +
    '; + } + $html.= '
  • '; + } + $html.= '
+

+ + +

+

+ + +

+
+ +
+
+
'; + } else { + $html.= ' +
'.$this->l('Create a product return').'
+
'.$this->l('No product can currently be returned on this order').'
'; + } + } + } + $html.= '
+
+
'; + + if(!class_exists('SupplierDemand')){ + require_once(_PS_MODULE_DIR_.'ant_supplierdemand/models/SupplierDemand.php'); + + $supplierDemands = SupplierDemand::getDemands(array(),'sd.id_order='.$order->id); + $alreadyDemand = array(); + $html .= ' +
+
+
+

'.$this->l('Supplier demands').'

+
+
+
'; + $demand_product = 0; + if (!sizeof($supplierDemands)) { + $html .= '
'.$this->l('No Supplier demands for this order.').'
'; + } else { + $html .= ' + + + + + + + + '; + foreach ($supplierDemands as $demand) { + $alreadyDemand[] = $demand['id_order_detail']; + $demandStates = SupplierDemand::$states; + $demandProduct = SupplierDemand::getProductStatic((int)$demand['id_supplier_demand']); + $html .= ' + + + + + + '; + } + $html .= ' +
'.$this->l('Date').''.$this->l('ID').''.$this->l('Status').''.$this->l('Product').'
'.Tools::displayDate($demand['date_upd'], $cookie->id_lang).''.$this->l('#').sprintf('%06d', $demand['id_supplier_demand']).''.$demandStates[$demand['id_state']]['name'].''.$demandProduct['product_name'].'
'; + } + $html .= ' +
+
'.$this->l('Make a supplier demand').'
+
+

+ + +

'; + if ($demand_product==0){ + $html .= '

'.$this->l('All products are in demand').'

'; + } else { + $html .= ' +

+ + +

+

+ + +

+ + +
'; + } + $html .= ' + +
+
+
+
'; + } + $html .=' + '; + + $helper->_js .= ' + '; + + $html .= $helper->renderScript(); + + echo $html; + } + public function viewDetails() { + return $this->_viewDetails(); + global $currentIndex, $cookie, $link; $irow = 0; if (!($order = $this->loadObject())) @@ -1882,4 +2810,134 @@ class AdminOrders extends AdminTab } return $total; } + + public function _displayStateIcon($id_order_state,$name) + { + switch ($id_order_state) { + case '1': // En attente de paiement par cheque + case '10': // En attente de paiement par virement bancaire + case '11': // En attente de paiement par Paypal + return ' '.$name.''; + break; + + case '2': // Paiement accepté + case '12': // Paiement à distance accepté + return ' '.$name.''; + break; + + case '13': // Autorisation accepté Paypal + return ' '.$name.''; + break; + + case '14': // Ne pas expédié + case '20': // Problème adresse + return ' '.$name.''; + break; + + case '8': // Erreur de paiement + return ' '.$name.''; + break; + + case '15': // Commande frauduleuse + return ' '.$name.''; + break; + + case '19': // Commande en attente + return ' '.$name.''; + break; + + case '3': // Préparation en cours + return ' '.$name.''; + break; + + case '4': // Commande expédiée + return ' '.$name.''; + break; + + case '17': // Commande partiellement expédiée + return ' '.$name.''; + break; + + case '7': // Commande remboursée + return ' '.$name.''; + break; + + case '18': // Commande remboursée + return ' '.$name.''; + break; + + default: + return ''.$name.''; + break; + } + } + + 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($socol && (int)$cart->id_carrier != (int)Configuration::get('ANT_CARRIER_DOM')) { + $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 . ' + AND `MR_Selected_Num` IS NOT NULL + '); + 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', + 'Point Relais : '.$mr['MR_Selected_Num'] + )))); + } 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))); + } + + return array( + 'order_invoice_address' => nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_invoice))), + 'order_delivery_address' => nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_delivery))), + 'order_address' => $order_address, + ); + } } diff --git a/modules/ant_returnprocess/AdminAntReturnprocess.php b/modules/ant_returnprocess/AdminAntReturnprocess.php index 48dc83ad..1b599f06 100644 --- a/modules/ant_returnprocess/AdminAntReturnprocess.php +++ b/modules/ant_returnprocess/AdminAntReturnprocess.php @@ -2237,12 +2237,12 @@ class AdminAntReturnprocess extends AdminTab SELECT COUNT(*) FROM `'._DB_PREFIX_.'mr_method` WHERE `id_carrier` = '.(int) $cart->id_carrier.' - AND `MR_Selected_Num` IS NOT NULL ')) { $mr = Db::getInstance()->getRow(' SELECT mr_s.* FROM `' . _DB_PREFIX_ . 'mr_selected` mr_s WHERE `id_cart` = ' . (int) $cart->id . ' + AND `MR_Selected_Num` IS NOT NULL '); if($mr) { $order_address = nl2br(preg_replace("/(\r\n){2,}/", "\r\n", implode("\r\n", array( @@ -2251,6 +2251,7 @@ class AdminAntReturnprocess extends AdminTab $mr['MR_Selected_LgAdr3'] . ' ' . $mr['MR_Selected_LgAdr4'], $mr['MR_Selected_CP'] . ' ' . $mr['MR_Selected_Ville'], 'FRANCE', + '('.$mr['MR_Selected_Num'].')', )))); } else { $order_address = nl2br(AddressFormat::generateAddress(new Address((int) $order->id_address_delivery))); diff --git a/modules/fraud/fraud.php b/modules/fraud/fraud.php index 873b6875..ec2d4ff9 100755 --- a/modules/fraud/fraud.php +++ b/modules/fraud/fraud.php @@ -97,6 +97,48 @@ class Fraud extends Module { } } + public function hookAdminOrderNew($params) { + global $currentIndex; + $data .= ''; + $reputation = FraudCore::getReputationOrder((int) $params['id_order']); + if ($reputation) { + $data .= ' +
+
+
+

'.$this->l('Suspect Order').''.($reputation['pass']!=0?' ('.$this->l('Order validate manually').')':'').'

+
+
+
'; + if (Tools::getIsset('validFraud')) { + $id_order = Tools::getValue('id_order'); + if (!FraudCore::validOrder($id_order)) { + $data .= '

'.$this->l('Update impossible').'

'; + } else { + $data .= '

'.$this->l('Valid order with success').'

'; + } + } + if ($reputation['score'] >= 100) { + $info = json_decode($reputation['report']); + $data .= ' + + '.$this->l('Score : ').' '.$reputation['score'].' + +
+

'.$this->l('Details : ').'

+

'.implode('
', $info).'

+
'; + if ($reputation['pass'] == 0) { + $data .= ''.$this->l('Valid Order').''; + } + } + $data .= '
+
+
'; + } + return $data; + } + /* This method is called after the response returned by paybox */ public function testPaybox($id_order, $ip_country) { From 3a9f7ef77cf8944149f3670582fce3b586bac60a Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Mon, 13 Nov 2017 17:13:07 +0100 Subject: [PATCH 2/4] part 2 of inte --- adm/tabs/AdminOrders.php | 164 ++++++++++-------- .../AdminAntConfigurations.php | 11 ++ modules/refundreason/refundreason.php | 26 +++ 3 files changed, 130 insertions(+), 71 deletions(-) diff --git a/adm/tabs/AdminOrders.php b/adm/tabs/AdminOrders.php index 4ea18354..c8922813 100755 --- a/adm/tabs/AdminOrders.php +++ b/adm/tabs/AdminOrders.php @@ -1066,7 +1066,8 @@ class AdminOrders extends AdminTab 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 + WHERE `id_order` ='. (int)$order->id.' + GROUP BY lpws.`shipping_number`' ) as $row){ $shipping_numbers[$row['shipping_number']] = $row; } @@ -1074,7 +1075,8 @@ class AdminOrders extends AdminTab 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 + WHERE od.`id_order` ='. (int)$order->id.' + GROUP BY ppp.`shipping_number`' ) as $row){ $shipping_numbers[$row['shipping_number']] = $row; } @@ -1082,7 +1084,8 @@ class AdminOrders extends AdminTab SELECT DISTINCT mrp.`shipping_number`, mrp.`date_add` FROM `'._DB_PREFIX_.'mondialrelay_parcel` mrp LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = mrp.`id_order_detail`) - WHERE od.`id_order` ='. (int)$order->id + WHERE od.`id_order` ='. (int)$order->id.' + GROUP BY mrp.`shipping_number`' ) as $row){ $shipping_numbers[$row['shipping_number']] = $row; } @@ -1345,8 +1348,9 @@ class AdminOrders extends AdminTab // shipping numbers $html.=' -
- +
'; + if(!empty($shipping_numbers)){ + $html .= '
@@ -1365,8 +1369,10 @@ class AdminOrders extends AdminTab '; } - $html .= ' + $html .= ' +
'.$this->l('Date').''.$number['shipping_number'].'
'; + } /* Display shipping number field */ if ($carrier->url && $order->hasBeenShipped()){ @@ -1410,7 +1416,7 @@ class AdminOrders extends AdminTab
'.$order->printCarrier($order->id_carrier,array()).' Adresse Livraison '.($cart->id_carrier!=(int)Configuration::get('ANT_CARRIER_DOM') && in_array($cart->id_carrier,$carriers_socol)?'':'').' - '.(in_array($cart->id_carrier,$carriers_mr)?'':'').' + '.(in_array($cart->id_carrier,$carriers_mr)?'':'').'

'.$data['order_address'].'

@@ -1496,7 +1502,8 @@ class AdminOrders extends AdminTab '.(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" ' : '').'/> + = (int)($product['product_quantity'])) ? 'disabled="disabled" ' : '').'/> + '.(((int)($product['product_quantity_return'] + $product['product_quantity_refunded']) >= (int)($product['product_quantity'])) ? '' : '').' '; } @@ -1532,7 +1539,7 @@ class AdminOrders extends AdminTab $html .= '
'; } - $html .= ' + $html .= ' '; $html .= ' @@ -1555,12 +1562,31 @@ class AdminOrders extends AdminTab
'.($order->module ? ($order->module=="paybox"?' ':' ') : '').' Info Remboursement
'; $slips = OrderSlip::getOrdersSlip($order->id_customer, $order->id); if (sizeof($slips)){ - $html .= '
'; - foreach ($slips as $slip){ - $html .= ''.Tools::displayDate($slip['date_upd'], $cookie->id_lang).' : '.$this->l('#').sprintf('%06d', $slip['id_order_slip']).'
'; - $html .= ''; - } - $html .= '
'; + $html .= '
+ + + + + + + '; + foreach ($slips as $slip){ + $reason = Db::getInstance()->getRow(' + SELECT * + FROM `'._DB_PREFIX_.'order_slip` s + LEFT JOIN `'._DB_PREFIX_.'refundreason` r ON s.`id_order_slip` = r.`id_order_slip` + WHERE s.`id_order_slip` ='.(int)$slip['id_order_slip'] + ); + $html .= ' + + + + + '; + } + $html .= ' +
DateIDRaison
'.Tools::displayDate($slip['date_upd'], $cookie->id_lang).''.$this->l('#').sprintf('%06d', $slip['id_order_slip']).''.($reason?$this->l('#'.$reason['id_reason']):'').'
+
'; } $html .= '
'; if($order->module && $order->module=="paybox"){ @@ -1613,7 +1639,7 @@ class AdminOrders extends AdminTab $html.= '
-
+

Nouveau Message

@@ -1646,47 +1672,38 @@ class AdminOrders extends AdminTab
-
-
'; - /* Display list of messages */ - - $html.=' -
-
-
-

'.$this->l('Messages').'

-
-
'; - if (sizeof($messages)) { - foreach ($messages as $message) - { - $html.= ''; +
+
+

'.$this->l('Messages').'

+
+
+
'; + if (sizeof($messages)) { + foreach ($messages as $message) + { + $html.= ''; + } + $html.= '

'.$this->l('When you read a message, please click on the green check.').'

'; + } else { + $html.= '
'.$this->l('No Message for this order.').'
'; } - $html.= '

'.$this->l('When you read a message, please click on the green check.').'

'; - } else { - $html.= '
'.$this->l('No Message for this order.').'
'; - } - $html.= '
+ $html.= '
+
-
'; - $html.= ' -
'; // - $html.= ' -
@@ -1696,8 +1713,8 @@ class AdminOrders extends AdminTab
'; if (!sizeof($returns)){ $html.= ' -
'.$this->l('Create a product return').'
-
'.$this->l('No merchandise return for this order.').'
'; +
'.$this->l('Create a product return').'
+
'.$this->l('No merchandise return for this order.').'
'; } else { $html.=' @@ -1725,8 +1742,8 @@ class AdminOrders extends AdminTab - - + + '; } $html.=' @@ -1788,8 +1805,8 @@ class AdminOrders extends AdminTab $html.= '
-
'.$this->l('Create a product return').'
-
+
'.$this->l('Create a product return').'
+
    '; foreach($returnable as $id_order_detail => $product) { $html.= ' @@ -1836,14 +1853,14 @@ class AdminOrders extends AdminTab
'; } else { $html.= ' -
'.$this->l('Create a product return').'
-
'.$this->l('No product can currently be returned on this order').'
'; +
'.$this->l('Create a product return').'
+
'.$this->l('No product can currently be returned on this order').'
'; } } } $html.= ' - '; + '; if(!class_exists('SupplierDemand')){ require_once(_PS_MODULE_DIR_.'ant_supplierdemand/models/SupplierDemand.php'); @@ -1851,17 +1868,14 @@ class AdminOrders extends AdminTab $supplierDemands = SupplierDemand::getDemands(array(),'sd.id_order='.$order->id); $alreadyDemand = array(); $html .= ' -
-

'.$this->l('Supplier demands').'

+

'.$this->l('Supplier demands').'

'; $demand_product = 0; - if (!sizeof($supplierDemands)) { - $html .= '
'.$this->l('No Supplier demands for this order.').'
'; - } else { + if(sizeof($supplierDemands)) { $html .= '
'.Tools::displayDate($return['date_upd'], $cookie->id_lang).' '.$this->l('#').sprintf('%06d', $return['id_order_return']).' '.$state->name[$cookie->id_lang].''.($return_link?''.$return_link['return_number'].'': '').''.($return_link?'': '').''.($return_link?''.$return_link['return_number'].'': '/').''.($return_link?'': '/').'
@@ -1878,7 +1892,7 @@ class AdminOrders extends AdminTab $html .= ' - + '; @@ -1888,8 +1902,8 @@ class AdminOrders extends AdminTab } $html .= '
-
'.$this->l('Make a supplier demand').'
- +
'.$this->l('Make a supplier demand').'
+

- + '.($order->hasBeenPaid() ? '' : '').' diff --git a/modules/paypal/paypal.php b/modules/paypal/paypal.php index 6a1c373a..bd72da81 100755 --- a/modules/paypal/paypal.php +++ b/modules/paypal/paypal.php @@ -670,6 +670,14 @@ class PayPal extends PaymentModule return $this->_html; } + public function hookAdminOrderNew($params) + { + if (Tools::isSubmit('submitPayPalRefund')){ + echo '
';var_dump('test');echo '
';die(); + $this->_doTotalRefund($params['id_order']); + } + } + public function hookCancelProduct($params) { // if (Tools::isSubmit('generateDiscount') || !$this->isPayPalAPIAvailable()) From b1b63b937dc59f98f0ffd368404ee4335bcbf020 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Tue, 21 Nov 2017 14:28:24 +0100 Subject: [PATCH 4/4] order comes from appli information --- adm/tabs/AdminOrders.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adm/tabs/AdminOrders.php b/adm/tabs/AdminOrders.php index 03541bc3..19e2ba31 100755 --- a/adm/tabs/AdminOrders.php +++ b/adm/tabs/AdminOrders.php @@ -1159,7 +1159,7 @@ class AdminOrders extends AdminTab
-

'.$this->_displayStateIcon($currentStateTab['id_order_state'],stripslashes($row['ostate_name'])).' ('.Tools::displayDate($row['date_add'], (int)($cookie->id_lang), true).' '.((!empty($row['employee_lastname'])) ? ' - '.stripslashes(Tools::substr($row['employee_firstname'], 0, 1)).'. '.stripslashes($row['employee_lastname']).'' : '').')

+

'.$this->_displayStateIcon($currentStateTab['id_order_state'],stripslashes($row['ostate_name'])).' ('.Tools::displayDate($row['date_add'], (int)($cookie->id_lang), true).''.((!empty($row['employee_lastname'])) ? ' - '.stripslashes(Tools::substr($row['employee_firstname'], 0, 1)).'. '.stripslashes($row['employee_lastname']).'' : '').')

@@ -1291,7 +1291,7 @@ class AdminOrders extends AdminTab
- '.($order->appli?'

'.$this->l('Commande faite via l\'appli').'

':'').' + '.($order->appli?'

'.$this->l('Commande faite via l\'appli').'

':'').'

'.Tools::substr($order->payment, 0, 32).' '.($order->module ? '('.$order->module.')' : '').'

'.$this->l('Cart #').sprintf('%06d', $cart->id).'

'.$this->l('Recycled package').'

'.Tools::displayDate($demand['date_upd'], $cookie->id_lang).''.$this->l('#').sprintf('%06d', $demand['id_supplier_demand']).''.$this->l('#').sprintf('%06d', $demand['id_supplier_demand']).' '.$demandStates[$demand['id_state']]['name'].' '.$demandProduct['product_name'].'
'.Tools::displayPrice($product_price,$currency).''.$quantity.''.$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).'