Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
root 2017-06-21 14:44:52 +02:00
commit 42378a8756
2 changed files with 221 additions and 103 deletions

View File

@ -928,6 +928,7 @@ class AdminAntReturnprocess extends AdminTab
</thead>
<tbody>';
$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 .='
<tr>
<td style="vertical-align:middle;color:#444;font-weight:bold;">
@ -969,54 +971,6 @@ class AdminAntReturnprocess extends AdminTab
$html .='</tbody>
</table>
</div>
<div class="col-md-offset-1 col-md-4">';
if($return_history && !empty($return_history)) {
$html .= '
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">
'.$this->l('Statut').'
<a class="pull-right" style="color:#fff;" role="button" data-toggle="collapse" href="#collapseHistory" aria-expanded="false" aria-controls="collapseHistory">
<i class="anticon anticon-info"></i>
</a>
</h5>
<p class="text-center">
<b>'.$return_history[0]['state'].' <span style="font-size:24px;" class="'.$colorStates[$orderReturn->state].'"></span></b><br>('.$return_history[0]['employee'].' - '.date('d/m/Y H:i',strtotime($return_history[0]['date_add'])).')
</p>
<div class="collapse" id="collapseHistory">
<div class="well">
<table class="table">';
foreach ($return_history as $key => $history) {
$html .= '
<tr>
<td style="font-size:11px;">'.date('d/m/Y H:i',strtotime($history['date_add'])).'</td>
<td style="font-size:11px;font-weight:bold">'.$history['state'].'</td>
<td style="font-size:11px;">'.$history['employee'].'</td>
</tr>';
}
$html .= '
</table>
</div>
</div>';
}
$html .= '
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">'.$this->l('Changer le statut du retour').'</h5>
<form style="padding:10px 20px;background:#efefef;" action="'.$currentIndex.'&submitAddorder_return=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
<input type="hidden" name="id_order" value="'.$orderReturn->id_order.'" />
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
<input type="hidden" name="id_customer" value="'.$orderReturn->id_customer.'" />
<div class="form-group">
<select class="form-control" name="state">';
$states = OrderReturnState::getOrderReturnStates($cookie->id_lang);
foreach ($states as $state) {
$html .= '<option value="'.$state['id_order_return_state'].'"'.($orderReturn->state == $state['id_order_return_state'] ? ' selected="selected"' : '').'>'.$state['name'].'</option>';
}
$html .= '</select>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary btn-block" name="submitAddorder_return" value="Mettre à jour">
</div>
</form>
</div>
</div>';
if($other_returnProducts && !empty($other_returnProducts)){
$html .= '
@ -1077,9 +1031,12 @@ class AdminAntReturnprocess extends AdminTab
<div class="panel">
<div class="panel-title">
<h2><span class="glyphicon glyphicon-tag"></span> Résumé Commande <a target="_blank" href="?tab=AdminOrders&id_order='.(int)$order->id.'&vieworder&token='.(Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee))).'">(#'.(int)$order->id.')</a> - '.$customer->firstname.' '.$customer->lastname.' <a href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee)).'">('.$this->l('#').$customer->id.')</a></h2>
<a class="pull-right text-purple-dark" style="color:#fff;" role="button" data-toggle="collapse" href="#collapseOrder" aria-expanded="false" aria-controls="collapseOrder">
<i style="font-size:20px;" class="anticon anticon-info"></i>
</a>
<div class="clearfix"></div>
</div>
<div class="panel-content">
<div class="panel-content collapse" id="collapseOrder">
<div class="row">
<div class="col-md-12">
<div class="row"/>
@ -1197,16 +1154,16 @@ class AdminAntReturnprocess extends AdminTab
<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>
<option value="0" '.($reason_selected == 0?'selected':'').'>Raison du Remboursement</option>
<option value="2" '.($reason_selected == 2?'selected':'').'>CLIENT: Rétractaction post-envoi</option>
<option value="4" '.($reason_selected == 4?'selected':'').'>BBB: Problème SAV</option>
<option value="5" '.($reason_selected == 5?'selected':'').'>BBB: Produit manquant</option>
<option value="3" '.($reason_selected == 3?'selected':'').'>BBB: Erreur Achat / Prod</option>
<option value="6" '.($reason_selected == 6?'selected':'').'>BBB: Erreur Logistique</option>
<option value="12" '.($reason_selected == 12?'selected':'').'>BBB: Suspicion de fraude</option>
<option value="9" '.($reason_selected == 9?'selected':'').'>TRANS: Colis détruit</option>
<option value="10" '.($reason_selected == 10?'selected':'').'>TRANS: Colis perdu</option>
<option value="7" '.($reason_selected == 7?'selected':'').'>Autre</option>
</select>
<div class="checkbox">
<label style="min-height:0px;">
@ -1222,6 +1179,46 @@ class AdminAntReturnprocess extends AdminTab
</div>
<div class="clearfix"></div>
<div class="ln_solid"></div>
<div class="row">
<div class="col-md-12">
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">'.($order->module ? ($order->module=="paybox"?'<span class="anticon anticon-credit-card"></span> ':'<span class="anticon anticon-paypal"></span> ') : '').' Info Remboursement</h5>
<div style="padding:10px 20px;background:#efefef;font-size: 12px;" class="">';
if($order->module && $order->module=="paybox"){
require_once dirname(__FILE__).'/../../modules/paybox/paybox.php';
$refundsPaybox = Paybox::getAllRefundbyOrder($order->id);
if (sizeof($refundsPaybox))
{
$html .='<table class="table table-condensed" width="100%;" cellspacing="0" cellpadding="0">';
foreach ($refundsPaybox as $refund) {
$html .='
<tr>
<td><b>'.(!empty($refund['product_name'])?$refund['product_name']:'Frais de port').'</b></td>
<td>'. $refund['amount'] / 100 . '</td>
</tr>';
}
$html .='</table>';
} else {
$html .= '<p class="text-center">Pas de remboursement</p>';
}
} 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 .= '<p>('.date('d/m/Y',strtotime($message['message'])).'):<br>'.$message['message'].'</p>';
}
}
}
$html .='</div>
</div>
</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>
@ -1245,43 +1242,53 @@ class AdminAntReturnprocess extends AdminTab
<input type="submit" name="submitOrderState" value="'.$this->l('Change').'" class="btn btn-primary btn-block" />
</form>
</div>
<div class="col-md-6">';
if($return_history && !empty($return_history)) {
$html .= '
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">
'.$this->l('Statut').'
<a class="pull-right" style="color:#fff;" role="button" data-toggle="collapse" href="#collapseHistory" aria-expanded="false" aria-controls="collapseHistory">
<i class="anticon anticon-info"></i>
</a>
</h5>
<p class="text-center">
<b>'.$return_history[0]['state'].' <span style="font-size:24px;" class="'.$colorStates[$orderReturn->state].'"></span></b><br>('.$return_history[0]['employee'].' - '.date('d/m/Y H:i',strtotime($return_history[0]['date_add'])).')
</p>
<div class="col-md-6">
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">'.($order->module ? ($order->module=="paybox"?'<span class="anticon anticon-credit-card"></span> ':'<span class="anticon anticon-paypal"></span> ') : '').' Info Remboursement</h5>
<div style="padding:10px 20px;background:#efefef;font-size: 12px;" class="">';
if($order->module && $order->module=="paybox"){
require_once dirname(__FILE__).'/../../modules/paybox/paybox.php';
$refundsPaybox = Paybox::getAllRefundbyOrder($order->id);
if (sizeof($refundsPaybox))
{
$html .='<table class="table table-condensed" width="100%;" cellspacing="0" cellpadding="0">';
foreach ($refundsPaybox as $refund) {
$html .='
<tr>
<td><b>'.(!empty($refund['product_name'])?$refund['product_name']:'Frais de port').'</b></td>
<td>'. $refund['amount'] / 100 . '</td>
</tr>';
}
$html .='</table>';
} else {
$html .= '<p>Pas de remboursement</p>';
}
} 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 .= '<p>('.date('d/m/Y',strtotime($message['message'])).'):<br>'.$message['message'].'</p>';
}
}
<div class="collapse" id="collapseHistory">
<div class="well">
<table class="table">';
foreach ($return_history as $key => $history) {
$html .= '
<tr>
<td style="font-size:11px;">'.date('d/m/Y H:i',strtotime($history['date_add'])).'</td>
<td style="font-size:11px;font-weight:bold">'.$history['state'].'</td>
<td style="font-size:11px;">'.$history['employee'].'</td>
</tr>';
}
$html .= '
</table>
</div>
</div>';
}
$html .='</div>
$html .= '
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">'.$this->l('Changer le statut du retour').'</h5>
<form style="padding:10px 20px;background:#efefef;" action="'.$currentIndex.'&submitAddorder_return=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
<input type="hidden" name="id_order" value="'.$orderReturn->id_order.'" />
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
<input type="hidden" name="id_customer" value="'.$orderReturn->id_customer.'" />
<div class="form-group">
<select class="form-control" name="state">';
$states = OrderReturnState::getOrderReturnStates($cookie->id_lang);
foreach ($states as $state) {
$html .= '<option value="'.$state['id_order_return_state'].'"'.($orderReturn->state == $state['id_order_return_state'] ? ' selected="selected"' : '').'>'.$state['name'].'</option>';
}
$html .= '</select>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary btn-block" name="submitAddorder_return" value="Mettre à jour">
</div>
</form>
</div>
</div>
</div>
@ -1388,6 +1395,8 @@ class AdminAntReturnprocess extends AdminTab
}
$html .= '</tbody>
</table>';
} else {
$html .='<p class="text-center">Aucun renvoi effectué depuis ce retour</p>';
}
$html .='
</div>
@ -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 .= '
<div class="row">
<div class="col-md-12">
<div class="panel">
<div class="panel-content">
<a class="btn btn-warning" style="pointer-events: none;" role="button">En attente de colis <span class="badge">'.$waiting_return_count.'</span></a>
<a class="btn btn-primary" style="pointer-events: none;" role="button">Colis reçu <span class="badge">'.$received_return_count.'</span></a>
<a class="btn btn-danger" style="pointer-events: none;" role="button">Retour non receptionné <span class="badge">'.$nonreceived_return_count.'</span></a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="panel">
@ -1617,7 +1650,7 @@ class AdminAntReturnprocess extends AdminTab
<div class="clearfix"></div>
</div>
<div class="panel-content">
<form>
<form id="return_order_form">
<div class="input-group">
<input id="return_order_input" type="text" class="form-control form-control-sm" placeholder="Search for...">
<span class="input-group-btn">
@ -1630,16 +1663,18 @@ class AdminAntReturnprocess extends AdminTab
</div>
</div>';
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.='
<div class="row">
<div class="col-md-12">
<div class="panel">
<div class="panel-title">
<h2><span class="anticon anticon-loop"></span> Liste des Retours</h2>
'.(Tools::getValue('return_order')?
'<a href="/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Les retours en cours</a>'
:'<a href="/adm/index.php?tab=AdminAntReturnprocess&show_history=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Voir retours terminés</a>'
'<a href="/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours en cours <span class="'.$colorStates[2].'"></span></a>'
:'<a href="/adm/index.php?tab=AdminAntReturnprocess&show_history=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default" style="margin-left:5px;">Retours terminés <span class="'.$colorStates[5].'"></span></a>
<a href="/adm/index.php?tab=AdminAntReturnprocess&show_non_received=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours non reçus <span class="'.$colorStates[6].'"></span></a>'
).'
<div class="clearfix"></div>
</div>
@ -1683,7 +1718,61 @@ class AdminAntReturnprocess extends AdminTab
</div>';
}
if(!empty($ended_order_returns) && (Tools::getValue('show_history') || Tools::getValue('return_order'))) {
if(Tools::getValue('show_non_received') || Tools::getValue('return_order')) {
$html.='
<div class="row">
<div class="col-md-12">
<div class="panel">
<div class="panel-title">
<h2><span class="anticon anticon-loop"></span> Liste des Retours non reçus</h2>
'.(Tools::getValue('return_order')?
'<a href="/adm/index.php?tab=AdminAntReturnprocess&show_non_received=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours non reçus <span class="'.$colorStates[6].'"></span></a>'
:'<a href="/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'" class="pull-right btn btn-default" style="margin-left:5px;">Retours en cours <span class="'.$colorStates[2].'"></span></a>
<a href="/adm/index.php?tab=AdminAntReturnprocess&show_history=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours terminés <span class="'.$colorStates[5].'"></span></a>'
).'
<div class="clearfix"></div>
</div>
<div class="panel-content">
<div class="table-responsive">
<table class="table table-custombordered">
<thead>
<tr>
<th>'.$this->l('#').'</th>
<th>'.$this->l('# Order').'</th>
<th>'.$this->l('# Customer').'</th>
<th>'.$this->l('Status').'</th>
<th>'.$this->l('Date').'</th>
<th class="text-center">'.$this->l('Action').'</th>
</tr>
</thead>
<tbody>';
foreach ($nonreceived_order_returns as $key => $return) {
$html .= '
<tr '.(Tools::getValue('return_order') == $return['id_order']? 'class="info"':'').'>
<td><strong>'.$return['id_order_return'].'</strong></td>
<td><strong> '.$return['id_order'].'</strong></td>
<td><strong>'.$return['id_customer'].'</strong></td>
<td><span class="'.$colorStates[$return['state']].'"></span> '.$return['name'].'</td>
<td>'.date('d/m/Y H:i',strtotime($return['date_add'])).'</td>
<td align="center">
<div class="input-group-btn" role="group">
<a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&updateorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-edit"></span></a>
<!--a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&deleteorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-trash"></span></a-->
</div>
</td>
</tr>
';
}
$html .= '</tbody>
</table>
</div>
</div>
</div>
<div>
</div>';
}
if(Tools::getValue('show_history') || Tools::getValue('return_order')) {
$html.='
<div class="row">
<div class="col-md-12">
@ -1691,8 +1780,9 @@ class AdminAntReturnprocess extends AdminTab
<div class="panel-title">
<h2><span class="anticon anticon-loop"></span> Retours Terminés</h2>
'.(Tools::getValue('return_order')?
'<a href="/adm/index.php?tab=AdminAntReturnprocess&show_history=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Les retours terminés</a>'
:'<a href="/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Voir retours en cours</a>'
'<a href="/adm/index.php?tab=AdminAntReturnprocess&show_history=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours terminés <span class="'.$colorStates[5].'"></span></a>'
:'<a href="/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'" class="pull-right btn btn-default" style="margin-left:5px;">Retours en cours <span class="'.$colorStates[2].'"></span></a>
<a href="/adm/index.php?tab=AdminAntReturnprocess&show_non_received=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Retours non reçus <span class="'.$colorStates[6].'"></span></a>'
).'
<div class="clearfix"></div>
</div>
@ -1762,6 +1852,10 @@ class AdminAntReturnprocess extends AdminTab
getReturnByOrder();
return false;
});
$("#return_order_form").submit(function(){
getReturnByOrder();
return false;
});
});
</script>';
$html .= $helper->renderScript();

View File

@ -0,0 +1,24 @@
<?php
if(isset($_SERVER['REMOTE_ADDR'])) exit;
$_SERVER['SERVER_PORT'] = 80;
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
include(dirname(__FILE__).'/../../config/config.inc.php');
include dirname(__FILE__).'/../../init.php';
// Cleaning returns of 3 month and still in state 2
$order_returns = Db::getInstance()->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;