731 lines
47 KiB
PHP
731 lines
47 KiB
PHP
<?php
|
|
if(!defined('_PS_VERSION_')) {
|
|
exit;
|
|
}
|
|
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
|
|
|
|
class AdminAntReturnprocess extends AdminTab
|
|
{
|
|
public function postProcess()
|
|
{
|
|
global $currentIndex, $cookie;
|
|
|
|
if (Tools::isSubmit('deleteorder_return_detail'))
|
|
{
|
|
if (($id_order_detail = (int)(Tools::getValue('id_order_detail'))) AND Validate::isUnsignedId($id_order_detail)) {
|
|
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());
|
|
}
|
|
|
|
if ((int)($orderReturn->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&conf=4&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&conf=4&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.'));
|
|
}
|
|
}
|
|
}
|
|
|
|
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']))
|
|
{
|
|
|
|
$this->displayForm();
|
|
echo '<br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
|
|
}
|
|
else
|
|
{
|
|
$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')));
|
|
$currentState = OrderHistory::getLastOrderState((int)$orderReturn->id_order);
|
|
$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'
|
|
);
|
|
}
|
|
|
|
$returnProducts = OrderReturn::getOrdersReturnProducts($orderReturn->id, $order);
|
|
$orderReturnState = new OrderReturnState($orderReturn->state);
|
|
|
|
$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 .= '
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="panel">
|
|
<div class="panel-title">
|
|
<h2 style="font-size:24px;"><span class="anticon anticon-loop" style="font-size:24px;"></span> Retour #'.$id_order_return.'</h2>
|
|
<p class="pull-right">'.$orderReturnState->name[(int)$cookie->id_lang].' <span style="font-size:24px;" class="'.$colorStates[$orderReturn->state].'"></span></p>
|
|
<div class="clearfix"></div>
|
|
</div>
|
|
<div class="panel-content">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>'.$this->l('Produit').'</th>
|
|
<th align="center">'.$this->l('Qté').'</th>
|
|
<th align="center">'.$this->l('Action').'</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>';
|
|
$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 .='
|
|
<tr>
|
|
<td style="vertical-align:middle;color:#444;font-weight:bold;">
|
|
<a style="display: block;color:#444;" target="_blank" href="index.php?tab=AdminCatalog&id_product='.(int)($product['product_id']).'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" title="'.$this->l('View product').'">
|
|
<img style="display:inline-block;" width="50" src="'.(isset($img_path)?_THEME_PROD_DIR_.$img_path.'-small.jpg':'').'"/><span style="font-weight:bold;display:inline-block;margin-left:5px;width:210px;vertical-align:middle;">'.mb_strimwidth($product['product_name'], 0, 55, "...").'</span>
|
|
<div class="clearfix"></div>
|
|
</a>
|
|
</td>
|
|
<td align="center" style="vertical-align:middle;color:#444;">'.$product['product_quantity'].'</td>
|
|
<td align="center" style="vertical-align:middle;color:#444;"><a style="color:#504d8b;" href="'.$currentIndex.'&deleteorder_return_detail&id_order_detail='.$product['id_order_detail'].'&id_order_return='.$orderReturn->id.'&token='.$this->token.'"><span class="anticon anticon-bin"></span></a></td>
|
|
</tr>';
|
|
}
|
|
}
|
|
$html .='</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-offset-2 col-md-4">
|
|
<form action="'.$currentIndex.'&submitAddorder_return=1&token='.$this->token.'" method="post">
|
|
'.($orderReturn->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$orderReturn->id.'" />' : '').'
|
|
<input type="hidden" name="id_order" value="'.$orderReturn->id_order.'" />
|
|
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
|
<input type="hidden" name="id_customer" value="'.$orderReturn->id_customer.'" />
|
|
<div class="form-group">
|
|
<label>'.$this->l('Statut').'</label>
|
|
<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 text-right">
|
|
<input type="submit" class="btn btn-primary" name="submitAddorder_return" value="Mettre à jour">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>';
|
|
|
|
$html .= '
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<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>
|
|
<div class="clearfix"></div>
|
|
</div>
|
|
<div class="panel-content">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="row"/>
|
|
<div class="col-md-6">
|
|
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;"><span class="anticon anticon-credit-card"></span> Détails paiement</h5>
|
|
<div style="text-align:center;">'.Tools::substr($order->payment, 0, 32).' '.($order->module ? '('.$order->module.')' : '').'</div>
|
|
<div style="padding:10px 30px;">
|
|
<table class="table table-condensed" width="100%;" cellspacing="0" cellpadding="0">
|
|
<tr style="font-size: 13px"><td class="text-purple-dark">'.$this->l('Products').'</td><td align="right" class="text-purple-dark">'.Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency, false).'</td></tr>
|
|
'.($order->total_discounts > 0 ? '<tr style="font-size: 13px"><td class="text-purple-dark">'.$this->l('Discounts').'</td><td align="right" class="text-purple-dark">-'.Tools::displayPrice($order->total_discounts, $currency, false).'</td></tr>' : '').'
|
|
'.($order->total_wrapping > 0 ? '<tr style="font-size: 13px"><td class="text-purple-dark">'.$this->l('Wrapping').'</td><td align="right" class="text-purple-dark">'.Tools::displayPrice($order->total_wrapping, $currency, false).'</td></tr>' : '').'
|
|
<tr style="font-size: 13px"><td class="text-purple-dark">'.$this->l('Shipping').'</td><td align="right" class="text-purple-dark">'.Tools::displayPrice($order->total_shipping, $currency, false).'</td></tr>
|
|
<tr style="font-size: 16px"><td>'.$this->l('Total').'</td><td align="right" class="text-rose">'.Tools::displayPrice($order->total_paid, $currency, false).($order->total_paid != $order->total_paid_real ? '<br /><font color="red">('.$this->l('Paid:').' '.Tools::displayPrice($order->total_paid_real, $currency, false, false).')</font>' : '').'</td></tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;"><span class="anticon anticon-truck"></span> Transporteur</h5>
|
|
<p class="text-center">'.$data['carrier_name'].'</p>
|
|
<ul class="">';
|
|
if(count($shipping_numbers) > 0){
|
|
foreach ($shipping_numbers as $key => $number) {
|
|
$date = new DateTime($number['date_add']);
|
|
$html .= '<li><strong>'. $number['shipping_number'] .'</strong> ajouté le '. $date->format('d/m/Y') .'</li>';
|
|
}
|
|
}
|
|
if(count($shipping_numbers2) > 0){
|
|
foreach ($shipping_numbers2 as $key => $number) {
|
|
$date = new DateTime($number['date_add']);
|
|
$html .= '<li><strong>'. $number['shipping_number'] .'</strong> ajouté le '. $date->format('d/m/Y') .'</li>';
|
|
}
|
|
}
|
|
$html .= '</ul>
|
|
</div>
|
|
</div>
|
|
<div class="row"/>
|
|
<div class="col-md-6">
|
|
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Adresse Facturation</h5>
|
|
<p style="padding:5px 20px;background:#efefef;">'.$data['order_invoice_address'].'</p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Adresse Livraison</h5>
|
|
<p style="padding:5px 20px;background:#efefef;">'.$data['order_address'].'</p>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix"></div>
|
|
<div class="ln_solid"></div>
|
|
<div class="panel-content">
|
|
<div class="table-responsive">
|
|
<table class="table table-custombordered">
|
|
<thead>
|
|
<tr>
|
|
<th><span class="anticon anticon-cart"></span> '.$this->l('Produit').'</th>
|
|
<th>'.$this->l('Prix U').'</th>
|
|
<th>'.$this->l('Qté').'</th>
|
|
'.($order->hasBeenPaid() ?'<th>'.$this->l('Remb').'</th>':'').'
|
|
'.($order->hasBeenDelivered() ?'<th>'.$this->l('Retour').'</th>':'').'
|
|
<th>'.$this->l('Stock').'</th>
|
|
<th>'.$this->l('Total').'</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>';
|
|
foreach ($order->getProducts() as $key => $product) {
|
|
if ($order->getTaxCalculationMethod() == PS_TAX_EXC) {
|
|
$product_price = $product['product_price'] + $product['ecotax'];
|
|
} else {
|
|
$product_price = $product['product_price_wt'];
|
|
}
|
|
|
|
if ($product['product_quantity'] > $product['customizationQuantityTotal'])
|
|
{
|
|
$quantity = $product['product_quantity'] - $product['customizationQuantityTotal'];
|
|
|
|
$html .='
|
|
<tr>
|
|
<td style="vertical-align:middle;color:#444;">
|
|
<a style="color:#444;" href="index.php?tab=AdminCatalog&id_product='.$product['product_id'].'&updateproduct&token='.$tokenCatalog.'">
|
|
<span style="font-weight:bold;" class="productName">'.$product['product_name'].'</span><br />
|
|
'.($product['product_reference'] ? '<span style="font-size:10px">'.$this->l('Ref:').' '.$product['product_reference'].'</span><br />' : '')
|
|
.($product['product_supplier_reference'] ? '<span style="font-size:10px">'.$this->l('Ref Supplier:').' '.$product['product_supplier_reference'].'</span>' : '')
|
|
.'</a>
|
|
</td>
|
|
<td style="vertical-align:middle;color:#444;">'.Tools::displayPrice($product_price,$currency).'</td>
|
|
<td style="vertical-align:middle;color:#444;">'.$quantity.'</td>
|
|
'.($order->hasBeenPaid() ? '<td style="vertical-align:middle;color:#444;" align="center" class="productQuantity">'.(int)($product['product_quantity_refunded']).'</td>' : '').'
|
|
'.($order->hasBeenDelivered() ? '<td style="vertical-align:middle;color:#444;" align="center" class="productQuantity">'.(int)($product['product_quantity_return']).'</td>' : '').'
|
|
<td style="vertical-align:middle;color:#444;" align="center" class="productQuantity">'.(int)$stock['quantity'].'</td>
|
|
<td style="vertical-align:middle;color:#444;" align="center">'.Tools::displayPrice(Tools::ps_round($product_price, 2) * ((int)($product['product_quantity']) - $product['customizationQuantityTotal']), $currency, false).'</td>
|
|
</tr>';
|
|
}
|
|
}
|
|
$html .= '</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="row">
|
|
<div class="panel col-md-12">
|
|
<div class="panel-title">
|
|
<h2><span class="anticon anticon-bubbles2"></span> SAV '.(isset($thread)?'<a href="index.php?tab=AdminCustomerThreads&id_customer_thread='.(int)($thread->id).'&viewcustomer_thread&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'" title=Voir la conversation"> Conversation #'.(int)($thread->id).'</a>':'').'</h2>
|
|
<div class="clearfix"></div>
|
|
</div>
|
|
<div class="panel-content">
|
|
<div class="row">
|
|
<div class="col-md-12">';
|
|
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 .='<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Produit(s) Concerné(s)</h5>';
|
|
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 .='
|
|
<a style="background:#EFEFEF;padding:5px;display: block;color:#444;" target="_blank" href="index.php?tab=AdminCatalog&id_product='.(int)($product['id_product']).'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" title="'.$this->l('View product').'">
|
|
<img style="display:inline-block;" width="62" src="'.(isset($img_path)?_THEME_PROD_DIR_.$img_path.'-small.jpg':'').'"/><span style="font-weight:bold;display:inline-block;margin-left:5px;width:210px;vertical-align:middle;">'.mb_strimwidth($product['name'], 0, 55, "...").'</span>
|
|
<div class="clearfix"></div>
|
|
</a>';
|
|
}
|
|
}
|
|
if($last_message){
|
|
$html .='<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Dernier Message</h5>';
|
|
$last_message['message'] = preg_replace('/(https?:\/\/[a-z0-9#%&_=\(\)\.\? \+\-@\/]{6,1000})([\s\n<])/Uui', '<a href="\1">\1</a>\2', html_entity_decode($last_message['message'], ENT_NOQUOTES, 'UTF-8'));
|
|
|
|
if(!empty($last_message['employee_name'])) {
|
|
$html .='
|
|
<div>
|
|
<p class="text-center"><span class="anticon anticon-user-tie"></span> Bébé Boutik - ('.Tools::displayDate($last_message['date_add'], (int)($cookie->id_lang), true).')</p>
|
|
<p style="padding:5px 20px;background:#efefef;">
|
|
"'.$last_message['message'].'"
|
|
</p>
|
|
</div>';
|
|
} else {
|
|
$html .='
|
|
<div>
|
|
<p class="text-center"><span class="anticon anticon-user"></span> '.$customer->firstname.' '.$customer->lastname.' - ('.Tools::displayDate($last_message['date_add'], (int)($cookie->id_lang), true).')</p>
|
|
<p style="padding:5px 20px;background:#efefef;">
|
|
"'.$last_message['message'].'"
|
|
</p>
|
|
</div>';
|
|
}
|
|
|
|
$orderMessages = OrderMessage::getOrderMessages((int)($last_message['id_lang']));
|
|
$html .='
|
|
<div>
|
|
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Envoyer un message</h5>
|
|
<form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
|
|
<div class="form-group">
|
|
<select class="form-control" name="order_message" id="order_message" onchange="savOverwriteMessage(this, \''.$this->l('Do you want to overwrite your existing message?').'\', \''.(int)($last_message['id_customer_message']).'\')">
|
|
<option value="0" selected="selected">-- '.$this->l('Choose a standard message').' --</option>';
|
|
foreach ($orderMessages AS $orderMessage) {
|
|
$html .= '<option value="'.htmlentities($orderMessage['message'], ENT_COMPAT, 'UTF-8').'">'.$orderMessage['name'].'</option>';
|
|
}
|
|
$html .= '
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<input class="form-control" type="file" name="joinFile"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<textarea rows="5" class="form-control" id="txt_msg_'.(int)($last_message['id_customer_message']).'" name="reply_message">'.str_replace('\r\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', $last_message['id_lang'])).'</textarea>
|
|
</div>
|
|
<div style="text-align: right;">
|
|
<input type="hidden" name="id_customer_thread" value="'.(int)($last_message['id_customer_thread']).'" />
|
|
<input type="hidden" name="msg_email" value="'.$last_message['email'].'" />
|
|
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
|
|
<input type="submit" class="btn btn-primary" name="submitReply" value="'.$this->l('Envoyer').'" style="margin-top:20px;" />
|
|
</div>
|
|
</form>
|
|
</div>';
|
|
}
|
|
} else {
|
|
$html .='<p>Pas de conversation en rapport avec cette commande !</p>';
|
|
}
|
|
$html .='</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>';
|
|
$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).')'
|
|
);
|
|
|
|
$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 .= '
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="panel">
|
|
<div class="panel-title">
|
|
<h2><span class="glyphicon glyphicon-barcode"></span> Rechercher par code barre</h2>
|
|
<div class="clearfix"></div>
|
|
</div>
|
|
<div class="panel-content">
|
|
<div class="input-group">
|
|
<input type="text" class="form-control" placeholder="Search for..." id="return_number_input" value="" autocomplete="off">
|
|
<span class="input-group-btn">
|
|
<button class="btn btn-default" type="button"><i class="glyphicon glyphicon-search" onclick="getReturnByNumber();"></i> Search</button>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="panel">
|
|
<div class="panel-title">
|
|
<h2><span class="glyphicon glyphicon-tag"></span> Rechercher par commande</h2>
|
|
<div class="clearfix"></div>
|
|
</div>
|
|
<div class="panel-content">
|
|
<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">
|
|
<button class="btn btn-default" id="return_order_submit" type="button"><i class="glyphicon glyphicon-search"></i> Search</button>
|
|
</span>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<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>
|
|
<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 ($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>n° '.$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>
|
|
<div class="clearfix"></div>';
|
|
|
|
$helper->_js .= '
|
|
<script type="text/javascript">
|
|
function getReturnByNumber() {
|
|
var val = $("#return_number_input").val().trim();
|
|
if(val != "" && val.length == 15) {
|
|
document.location.href = "/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'&return_number=" + val;
|
|
}
|
|
}
|
|
function getReturnByOrder() {
|
|
var val = $("#return_order_input").val().trim();
|
|
if(val != "") {
|
|
document.location.href = "/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'&return_order=" + val;
|
|
}
|
|
}
|
|
$(function() {
|
|
$("#return_number_input").bind("keydown", function(e) {
|
|
if(e.which == 13) {
|
|
getReturnByNumber();
|
|
return false;
|
|
}
|
|
});
|
|
$("#return_order_submit").click(function(){
|
|
getReturnByOrder();
|
|
return false;
|
|
});
|
|
});
|
|
</script>';
|
|
$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,
|
|
);
|
|
}
|
|
}
|