From 805d22584074259f6bff4f6bb891c2e67f55b621 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Wed, 21 Jun 2017 14:44:10 +0200 Subject: [PATCH] ergo changement and cleaning cron --- .../AdminAntReturnprocess.php | 300 ++++++++++++------ modules/ant_returnprocess/cron.php | 24 ++ 2 files changed, 221 insertions(+), 103 deletions(-) create mode 100644 modules/ant_returnprocess/cron.php diff --git a/modules/ant_returnprocess/AdminAntReturnprocess.php b/modules/ant_returnprocess/AdminAntReturnprocess.php index 24a22f25..96fd37ee 100644 --- a/modules/ant_returnprocess/AdminAntReturnprocess.php +++ b/modules/ant_returnprocess/AdminAntReturnprocess.php @@ -928,6 +928,7 @@ class AdminAntReturnprocess extends AdminTab '; $productReturned = array(); + $reason_selected = 0; foreach ($returnProducts AS $k => $product) { $productReturned[] = $product['product_id']; $img_path = ''; @@ -949,6 +950,7 @@ class AdminAntReturnprocess extends AdminTab AND id_order_detail = '.(int)$product['id_order_detail'] ); if (!isset($quantityDisplayed[(int)($product['id_order_detail'])]) OR (int)($product['product_quantity']) > (int)($quantityDisplayed[(int)($product['id_order_detail'])])) { + $reason_selected = (int)$return_details['reason']; $html .=' @@ -969,54 +971,6 @@ class AdminAntReturnprocess extends AdminTab $html .=' -
'; - if($return_history && !empty($return_history)) { - $html .= ' -
- '.$this->l('Statut').' - -
-

- '.$return_history[0]['state'].'
('.$return_history[0]['employee'].' - '.date('d/m/Y H:i',strtotime($return_history[0]['date_add'])).') -

- -
-
- '; - foreach ($return_history as $key => $history) { - $html .= ' - - - - - '; - } - $html .= ' -
'.date('d/m/Y H:i',strtotime($history['date_add'])).''.$history['state'].''.$history['employee'].'
-
-
'; - } - $html .= ' -
'.$this->l('Changer le statut du retour').'
-
- - - -
- -
-
- -
-
-
'; if($other_returnProducts && !empty($other_returnProducts)){ $html .= ' @@ -1077,9 +1031,12 @@ class AdminAntReturnprocess extends AdminTab

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

+
-
+
@@ -1197,16 +1154,16 @@ class AdminAntReturnprocess extends AdminTab

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

+
+
+
'.($order->module ? ($order->module=="paybox"?' ':' ') : '').' Info Remboursement
+
'; + 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'].'

'; + } + } + + } + $html .='
+
+
+
'.$this->l('Changer le statut de la commande').'
@@ -1245,43 +1242,53 @@ class AdminAntReturnprocess extends AdminTab
+
'; + if($return_history && !empty($return_history)) { + $html .= ' +
+ '.$this->l('Statut').' + +
+

+ '.$return_history[0]['state'].'
('.$return_history[0]['employee'].' - '.date('d/m/Y H:i',strtotime($return_history[0]['date_add'])).') +

-
-
'.($order->module ? ($order->module=="paybox"?' ':' ') : '').' Info Remboursement
-
'; - 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'].'

'; - } - } - +
+
+ '; + foreach ($return_history as $key => $history) { + $html .= ' + + + + + '; + } + $html .= ' +
'.date('d/m/Y H:i',strtotime($history['date_add'])).''.$history['state'].''.$history['employee'].'
+
+
'; } - $html .='
+ $html .= ' +
'.$this->l('Changer le statut du retour').'
+
+ + + +
+ +
+
+ +
+
@@ -1388,6 +1395,8 @@ class AdminAntReturnprocess extends AdminTab } $html .= ' '; + } else { + $html .='

Aucun renvoi effectué depuis ce retour

'; } $html .='
@@ -1558,11 +1567,14 @@ class AdminAntReturnprocess extends AdminTab { global $cookie, $currentIndex; + $waiting_return_count = Db::getInstance()->getValue('SELECT COUNT(id_order_return) FROM '._DB_PREFIX_.'order_return WHERE state = 2'); + $received_return_count = Db::getInstance()->getValue('SELECT COUNT(id_order_return) FROM '._DB_PREFIX_.'order_return WHERE state = 3'); + $nonreceived_return_count = Db::getInstance()->getValue('SELECT COUNT(id_order_return) FROM '._DB_PREFIX_.'order_return WHERE state = 6'); $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).') - WHERE a.state != 5 + WHERE a.state != 5 AND a.state != 6 '.(Tools::getValue('return_order')?' AND a.id_order='.(int)Tools::getValue('return_order'):'').' ORDER BY a.date_add DESC' ); @@ -1576,7 +1588,16 @@ class AdminAntReturnprocess extends AdminTab ORDER BY a.date_add DESC' ); - if(Tools::getValue('return_order') && empty($order_returns) && empty($ended_order_returns)) { + $nonreceived_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).') + WHERE a.state = 6 + '.(Tools::getValue('return_order')?' AND a.id_order='.(int)Tools::getValue('return_order'):'').' + ORDER BY a.date_add DESC' + ); + + if(Tools::getValue('return_order') && empty($order_returns) && empty($ended_order_returns) && empty($nonreceived_order_returns)) { HelperFormBootstrap::displayWarning('Aucun retour trouvé'); } @@ -1586,6 +1607,7 @@ class AdminAntReturnprocess extends AdminTab 3 => "anticon anticon-box-add text-orange", 4 => "anticon anticon-cross text-rose", 5 => "anticon anticon-checkmark text-green-light", + 6 => "anticon anticon-warning text-danger", ); $helper = new HelperFormBootstrap(); @@ -1593,6 +1615,17 @@ class AdminAntReturnprocess extends AdminTab $helper->_inputMask = true; $html = $helper->renderStyle(); $html .= ' +
@@ -1617,7 +1650,7 @@ class AdminAntReturnprocess extends AdminTab
-
+
@@ -1630,16 +1663,18 @@ class AdminAntReturnprocess extends AdminTab
'; - if(!empty($order_returns) && (!Tools::getValue('show_history') || Tools::getValue('return_order'))) { + if((!Tools::getValue('show_history') && !Tools::getValue('show_non_received')) || Tools::getValue('return_order')) { $html.='

Liste des Retours

+ '.(Tools::getValue('return_order')? - 'Les retours en cours' - :'Voir retours terminés' + 'Retours en cours ' + :'Retours terminés + Retours non reçus ' ).'
@@ -1683,7 +1718,61 @@ class AdminAntReturnprocess extends AdminTab
'; } - if(!empty($ended_order_returns) && (Tools::getValue('show_history') || Tools::getValue('return_order'))) { + if(Tools::getValue('show_non_received') || Tools::getValue('return_order')) { + $html.=' +
+
+
+
+

Liste des Retours non reçus

+ '.(Tools::getValue('return_order')? + 'Retours non reçus ' + :'Retours en cours + Retours terminés ' + ).' +
+
+
+
+ + + + + + + + + + + + '; + foreach ($nonreceived_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'])).' +
+ + +
+
+
+
+
+
+
'; + } + + if(Tools::getValue('show_history') || Tools::getValue('return_order')) { $html.='
@@ -1691,8 +1780,9 @@ class AdminAntReturnprocess extends AdminTab

Retours Terminés

'.(Tools::getValue('return_order')? - 'Les retours terminés' - :'Voir retours en cours' + 'Retours terminés ' + :'Retours en cours + Retours non reçus ' ).'
@@ -1762,6 +1852,10 @@ class AdminAntReturnprocess extends AdminTab getReturnByOrder(); return false; }); + $("#return_order_form").submit(function(){ + getReturnByOrder(); + return false; + }); }); '; $html .= $helper->renderScript(); diff --git a/modules/ant_returnprocess/cron.php b/modules/ant_returnprocess/cron.php new file mode 100644 index 00000000..a6b0ea5c --- /dev/null +++ b/modules/ant_returnprocess/cron.php @@ -0,0 +1,24 @@ +ExecuteS(' + SELECT r.`id_order_return` + FROM '._DB_PREFIX_.'order_return r + WHERE r.state = 2 + AND r.date_upd < DATE_SUB(NOW(), INTERVAL 3 MONTH)' +); + +$id_to_update = array(); +foreach ($order_returns as $return) { + $id_to_update[] = (int)$return['id_order_return']; + Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'order_return_history VALUES (DEFAULT,1,'.(int)$return['id_order_return'].',6,NOW())'); +} +Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'order_return SET state = 6 WHERE id_order_return IN ('.implode(',', $id_to_update).')'); + +exit;