start refund sav page
This commit is contained in:
parent
bcffb2088f
commit
27a62959a6
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@ -30,14 +30,14 @@ class AdminCustomerThreads extends AdminTab
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
|
||||
$this->table = 'customer_thread';
|
||||
$this->lang = false;
|
||||
$this->className = 'CustomerThread';
|
||||
$this->edit = false;
|
||||
$this->view = true;
|
||||
$this->edit = false;
|
||||
$this->view = true;
|
||||
$this->delete = true;
|
||||
|
||||
|
||||
$this->_select = 'CONCAT(c.firstname," ",c.lastname) as customer, cl.name as contact, l.name as language, group_concat(message) as messages, (
|
||||
SELECT IFNULL(CONCAT(LEFT(e.firstname, 1),". ",e.lastname), "--")
|
||||
FROM '._DB_PREFIX_.'customer_message cm2 INNER JOIN '._DB_PREFIX_.'employee e ON e.id_employee = cm2.id_employee
|
||||
@ -49,31 +49,31 @@ class AdminCustomerThreads extends AdminTab
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer_message` cm ON cm.`id_customer_thread` = a.`id_customer_thread`
|
||||
LEFT JOIN `'._DB_PREFIX_.'lang` l ON l.`id_lang` = a.`id_lang`
|
||||
LEFT JOIN `'._DB_PREFIX_.'contact_lang` cl ON (cl.`id_contact` = a.`id_contact` AND cl.`id_lang` = '.(int)$cookie->id_lang.')';
|
||||
|
||||
|
||||
$contactArray = array();
|
||||
$contacts = Contact::getContacts($cookie->id_lang);
|
||||
foreach ($contacts AS $contact)
|
||||
$contactArray[$contact['id_contact']] = $contact['name'];
|
||||
|
||||
|
||||
$languageArray = array();
|
||||
$languages = Language::getLanguages(FALSE);
|
||||
foreach ($languages AS $language)
|
||||
$languageArray[$language['id_lang']] = $language['name'];
|
||||
|
||||
|
||||
$statusArray = array(
|
||||
'open' => $this->l('Open'),
|
||||
'closed' => $this->l('Closed'),
|
||||
'pending1' => $this->l('Pending 1'),
|
||||
'pending2' => $this->l('Pending 2')
|
||||
);
|
||||
|
||||
|
||||
$imagesArray = array(
|
||||
'open' => 'status_green.gif',
|
||||
'closed' => 'status_red.gif',
|
||||
'pending1' => 'status_orange.gif',
|
||||
'pending2' => 'status_orange.gif'
|
||||
);
|
||||
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_customer_thread' => array('title' => $this->l('ID'), 'width' => 25),
|
||||
'customer' => array('title' => $this->l('Customer'), 'width' => 100, 'filter_key' => 'customer', 'tmpTableFilter' => true),
|
||||
@ -88,11 +88,11 @@ class AdminCustomerThreads extends AdminTab
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex, $cookie, $link;
|
||||
|
||||
|
||||
if ($id_customer_thread = (int)Tools::getValue('id_customer_thread'))
|
||||
{
|
||||
if (($id_contact = (int)Tools::getValue('id_contact')))
|
||||
@ -104,7 +104,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
}
|
||||
if (isset($_POST['id_employee_forward']))
|
||||
{
|
||||
// Todo: need to avoid doubles
|
||||
// Todo: need to avoid doubles
|
||||
$messages = Db::getInstance()->ExecuteS('
|
||||
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
|
||||
@ -117,7 +117,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
$output = '';
|
||||
foreach ($messages AS $message)
|
||||
$output .= $this->displayMsg($message, true, (int)Tools::getValue('id_employee_forward'));
|
||||
|
||||
|
||||
$cm = new CustomerMessage();
|
||||
$cm->id_employee = (int)$cookie->id_employee;
|
||||
$cm->id_customer_thread = (int)Tools::getValue('id_customer_thread');
|
||||
@ -126,7 +126,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
|
||||
/* ANTADIS */
|
||||
$message_en_cours = new CustomerThread((int)Tools::getValue('id_customer_thread'));
|
||||
|
||||
|
||||
if($message_en_cours->id_customer == 0){
|
||||
$objet_mail = Mail::l('Fwd: Customer message') . ' - ' . $message_en_cours->email;
|
||||
}else{
|
||||
@ -189,8 +189,8 @@ class AdminCustomerThreads extends AdminTab
|
||||
$params = array(
|
||||
'{reply}' => nl2br2(Tools::getValue('reply_message')),
|
||||
'{link}' => $link->getPageLink('contact-form.php', true).'?id_customer_thread='.(int)($ct->id).'&token='.$ct->token);
|
||||
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,
|
||||
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';
|
||||
@ -205,7 +205,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $cookie;
|
||||
@ -220,7 +220,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
$this->displayList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function displayListHeader($token = NULL)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
@ -231,7 +231,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
FROM '._DB_PREFIX_.'customer_thread ct2
|
||||
WHERE status = "open" AND ct.id_contact = ct2.id_contact
|
||||
ORDER BY date_upd ASC
|
||||
LIMIT 1
|
||||
LIMIT 1
|
||||
) as id_customer_thread
|
||||
FROM '._DB_PREFIX_.'customer_thread ct
|
||||
LEFT JOIN '._DB_PREFIX_.'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = '.$cookie->id_lang.')
|
||||
@ -254,17 +254,17 @@ class AdminCustomerThreads extends AdminTab
|
||||
{
|
||||
$totalThread = $tmp2['total'];
|
||||
$id_customer_thread = $tmp2['id_customer_thread'];
|
||||
break;
|
||||
break;
|
||||
}
|
||||
echo '<div style="background-color:#EFEFEF;float:left;margin:0 10px 10px 0;width:'.($dim > 6 ? '200' : '300').'px;border:1px solid #CFCFCF" >
|
||||
<h3 style="overflow:hidden;line-height:25px;color:#812143;height:25px;margin:0;"> '.$val['name'].'</h3>'.
|
||||
($dim > 6 ? '' : '<p style="overflow:hidden;line-height:15px;height:45px;margin:0;padding:0 5px;">'.$val['description'].'</p>').
|
||||
($totalThread == 0 ? '<h3 style="padding:0 5px;margin:0;height:23px;line-height:23px;background-color:#DEDEDE">'.$this->l('No new message').'</h3>'
|
||||
($totalThread == 0 ? '<h3 style="padding:0 5px;margin:0;height:23px;line-height:23px;background-color:#DEDEDE">'.$this->l('No new message').'</h3>'
|
||||
: '<a href="'.$currentIndex.'&token='.Tools::getValue('token').'&id_customer_thread='.$id_customer_thread.'&viewcustomer_thread" style="padding:0 5px;display:block;height:23px;line-height:23px;border:0;" class="button">'.$totalThread.' '.($totalThread > 1 ? $this->l('new messages'): $this->l('new message')).'</a>').'
|
||||
</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
|
||||
$params = array(
|
||||
$this->l('Total threads') => $all = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'customer_thread'),
|
||||
$this->l('Threads pending') => $pending = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'customer_thread WHERE status LIKE "%pending%"'),
|
||||
@ -283,11 +283,11 @@ class AdminCustomerThreads extends AdminTab
|
||||
</div><p class="clear"> </p>';
|
||||
parent::displayListHeader($token);
|
||||
}
|
||||
|
||||
|
||||
private function openUploadedFile()
|
||||
{
|
||||
$filename = $_GET['filename'];
|
||||
|
||||
|
||||
$extensions = array('.txt' => 'text/plain', '.rtf' => 'application/rtf', '.doc' => 'application/msword', '.docx'=> 'application/msword',
|
||||
'.pdf' => 'application/pdf', '.zip' => 'multipart/x-zip', '.png' => 'image/png', '.jpeg' => 'image/jpeg', '.gif' => 'image/gif', '.jpg' => 'image/jpeg');
|
||||
|
||||
@ -311,7 +311,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
|
||||
$customersToken = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee));
|
||||
$contacts = Contact::getContacts($cookie->id_lang);
|
||||
|
||||
|
||||
if (!$email)
|
||||
{
|
||||
if (!empty($message['id_product']) AND empty($message['employee_name']))
|
||||
@ -322,7 +322,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
WHERE o.id_customer = '.(int)$message['id_customer'].'
|
||||
AND od.product_id = '.(int)$message['id_product'].'
|
||||
ORDER BY o.date_add DESC');
|
||||
|
||||
|
||||
$output = '
|
||||
<fieldset style="'.(!empty($message['employee_name']) ? 'background: rgb(255,236,242);' : '').'width:600px;margin-top:10px">
|
||||
<legend '.(empty($message['employee_name']) ? '' : 'style="background:rgb(255,210,225)"').'>'.(
|
||||
@ -375,7 +375,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
.((!empty($message['id_product']) AND empty($message['employee_name'])) ? '<br /><b>'.$this->l('Product #').':</b> '.(int)($message['id_product']).'<br />' : '')
|
||||
.'<br /><b>'.$this->l('Subject:').'</b> '.$message['subject'];
|
||||
}
|
||||
|
||||
|
||||
// Adding Antadis - linking with ant_support_form module
|
||||
if (Module::isInstalled('ant_support_form')) {
|
||||
$result = Db::getInstance()->getRow('
|
||||
@ -400,7 +400,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
<b>'.$this->l('Message:').'</b><br />
|
||||
'.$message['message'].'
|
||||
</div>';
|
||||
|
||||
|
||||
if (!$email)
|
||||
{
|
||||
if (empty($message['employee_name']))
|
||||
@ -424,24 +424,24 @@ class AdminCustomerThreads extends AdminTab
|
||||
<input type="submit" class="button" name="submitReply" value="'.$this->l('Send my reply').'" style="margin-top:20px;" />
|
||||
<input type="hidden" name="id_customer_thread" value="'.(int)($message['id_customer_thread']).'" />
|
||||
<input type="hidden" name="msg_email" value="'.$message['email'].'" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>';
|
||||
$output .= '
|
||||
</fieldset>';
|
||||
}
|
||||
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
public function viewcustomer_thread()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
|
||||
if (!($thread = $this->loadObject()))
|
||||
return;
|
||||
$cookie->{'customer_threadFilter_cl!id_contact'} = $thread->id_contact;
|
||||
|
||||
|
||||
$employees = Db::getInstance()->ExecuteS('
|
||||
SELECT e.id_employee, e.firstname, e.lastname FROM '._DB_PREFIX_.'employee e
|
||||
WHERE e.active = 1 ORDER BY e.lastname ASC');
|
||||
@ -450,7 +450,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
<h2>'.$this->l('Messages').'</h2>
|
||||
<form action="'.Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
|
||||
<p>
|
||||
<img src="../img/admin/msg-forward.png" alt="" style="vertical-align: middle;" /> '.$this->l('Forward this discussion to an employee:').'
|
||||
<img src="../img/admin/msg-forward.png" alt="" style="vertical-align: middle;" /> '.$this->l('Forward this discussion to an employee:').'
|
||||
<select name="id_employee_forward" style="vertical-align: middle;" onchange="
|
||||
if ($(this).val() >= 0)
|
||||
$(\'#message_forward\').show(400);
|
||||
@ -476,7 +476,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
</p>
|
||||
</form>
|
||||
<div class="clear"> </div>';
|
||||
|
||||
|
||||
$messages = Db::getInstance()->ExecuteS('
|
||||
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
|
||||
@ -486,7 +486,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
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)Tools::getValue('id_customer_thread').'
|
||||
ORDER BY cm.date_add DESC');
|
||||
|
||||
|
||||
echo '<div style="float:right">';
|
||||
|
||||
$nextThread = Db::getInstance()->getValue('
|
||||
@ -499,7 +499,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
'.($cookie->{'customer_threadFilter_cl!id_contact'} ? 'AND ct.id_contact = '.(int)$cookie->{'customer_threadFilter_cl!id_contact'} : '').'
|
||||
'.($cookie->{'customer_threadFilter_l!id_lang'} ? 'AND ct.id_lang = '.(int)$cookie->{'customer_threadFilter_l!id_lang'} : '').
|
||||
' ORDER BY ct.date_upd ASC');
|
||||
|
||||
|
||||
if ($nextThread)
|
||||
echo $this->displayButton('
|
||||
<a href="'.$currentIndex.'&id_customer_thread='.(int)$nextThread.'&viewcustomer_thread&token='.$this->token.'">
|
||||
@ -517,7 +517,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
<img src="../img/admin/msg-ok.png" style="margin-bottom:10px" />
|
||||
<br />'.$this->l('Set this message as handled').'
|
||||
</a>');
|
||||
|
||||
|
||||
if ($thread->status != "pending1")
|
||||
echo $this->displayButton('
|
||||
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=3&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
|
||||
@ -530,7 +530,7 @@ class AdminCustomerThreads extends AdminTab
|
||||
<img src="../img/admin/msg-is-pending.png" style="margin-bottom:10px" />
|
||||
<br />'.$this->l('Click here to disable pending status').'
|
||||
</a>');
|
||||
|
||||
|
||||
if ($thread->status != "pending2")
|
||||
echo $this->displayButton('
|
||||
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=4&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
|
||||
@ -543,15 +543,15 @@ class AdminCustomerThreads extends AdminTab
|
||||
<img src="../img/admin/msg-is-pending.png" style="margin-bottom:10px" />
|
||||
<br />'.$this->l('Click here to disable pending status').'
|
||||
</a>');
|
||||
|
||||
|
||||
echo '</div>';
|
||||
|
||||
|
||||
if ($thread->id_customer)
|
||||
{
|
||||
$customer = new Customer($thread->id_customer);
|
||||
$products = $customer->getBoughtProducts();
|
||||
$orders = Order::getCustomerOrders($customer->id);
|
||||
|
||||
|
||||
echo '<div style="float:left;width:600px">';
|
||||
if ($orders AND sizeof($orders))
|
||||
{
|
||||
@ -621,13 +621,23 @@ class AdminCustomerThreads extends AdminTab
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
foreach ($messages AS $message){
|
||||
if ($message['id_order']){
|
||||
$order_thread = new Order((int)($message['id_order']));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($order_thread) {
|
||||
echo '<div style="float:left;margin-top:10px">';
|
||||
Module::hookExec('rightColumnSav', array('order' => $order_thread));
|
||||
echo '</div>';
|
||||
}
|
||||
echo '<div style="float:left;margin-top:10px">';
|
||||
foreach ($messages AS $message)
|
||||
echo $this->displayMsg($message);
|
||||
echo '</div><div class="clear"> </div>';
|
||||
}
|
||||
|
||||
|
||||
private function displayButton($content)
|
||||
{
|
||||
return '
|
||||
|
@ -19,100 +19,48 @@ class BlockOrderSummary extends Module {
|
||||
$this->description = $this->l('Displays a summary of the current order');
|
||||
}
|
||||
|
||||
private $hooks = array(
|
||||
'rightColumnSav' => array('BO SAV right column', 'Allow to add information in right column of SAV message thread'),
|
||||
);
|
||||
|
||||
public function install() {
|
||||
return parent::install() && $this->registerHook('leftColumn');
|
||||
foreach($this->hooks as $k => $v) {
|
||||
if(count(Db::getInstance()->ExecuteS('
|
||||
SELECT `id_hook`
|
||||
FROM `'._DB_PREFIX_.'hook`
|
||||
WHERE `name` = "'.$k.'"
|
||||
LIMIT 1
|
||||
')) == 0) {
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'hook`
|
||||
VALUES (DEFAULT, "'.$k.'", "'.$v[0].'", "'.$v[1].'", 0, 0)
|
||||
');
|
||||
}
|
||||
}
|
||||
|
||||
$install_success = parent::install();
|
||||
if ($install_success) {
|
||||
foreach($this->hooks as $k => $v) {
|
||||
$install_success = $this->registerHook($k);
|
||||
if (!$install_success) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $install_success && $this->registerHook('leftColumn');
|
||||
}
|
||||
|
||||
public function hookLeftColumn($params) {
|
||||
global $cookie, $smarty, $cart;
|
||||
if(($step = (int) Tools::getValue('step')) && ($step == 3 || $step == 4)) {
|
||||
|
||||
if(Db::getInstance()->getValue('
|
||||
SELECT `id_carrier`
|
||||
FROM `'._DB_PREFIX_.'carrier`
|
||||
WHERE `id_carrier` = '.(int) $cart->id_carrier.'
|
||||
AND `name` LIKE "%so colissimo%"
|
||||
')) {
|
||||
$socol = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'socolissimo_delivery_info`
|
||||
WHERE `id_cart` = '.(int) $cart->id.'
|
||||
');
|
||||
|
||||
if($socol) {
|
||||
$order_address = nl2br(preg_replace("/(\r\n){2,}/", "\r\n", implode("\r\n", array(
|
||||
$socol['cefirstname'].' '.$socol['cename'],
|
||||
$socol['cecompanyname'],
|
||||
$socol['prfirstname'].' '.$socol['prname'],
|
||||
$socol['prcompladress'],
|
||||
$socol['pradress1'],
|
||||
$socol['pradress2'],
|
||||
$socol['pradress3'],
|
||||
$socol['pradress4'],
|
||||
$socol['przipcode'].' '.$socol['prtown'],
|
||||
'FRANCE',
|
||||
$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) $cart->id_address_delivery)));
|
||||
}
|
||||
} else {
|
||||
$order_address = nl2br(AddressFormat::generateAddress(new Address((int) $cart->id_address_delivery)));
|
||||
}
|
||||
|
||||
if ($cookie->id_lang == 3 && (int)$cart->id_carrier == 87) {
|
||||
$carrier_name = "SEUR a domicilio";
|
||||
} else {
|
||||
$carrier_name = Db::getInstance()->getValue('
|
||||
SELECT `name`
|
||||
FROM `'._DB_PREFIX_.'carrier`
|
||||
WHERE `id_carrier` = '.(int) $cart->id_carrier.'
|
||||
');
|
||||
}
|
||||
|
||||
$products_keys = array();
|
||||
$products_delays = array();
|
||||
|
||||
$products = $cart->getProducts();
|
||||
$i = 0;
|
||||
foreach($products as $product) {
|
||||
$products_keys[(int) $product['id_product']] = $i;
|
||||
$i++;
|
||||
}
|
||||
|
||||
// assign delay to Products
|
||||
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();
|
||||
$delivery_date = SaleDelay::getDeliveryDate($delays, null, $date, true);
|
||||
|
||||
foreach($delays as $delay) {
|
||||
$row = Db::getInstance()->getRow('
|
||||
SELECT l.`name`
|
||||
FROM `'._DB_PREFIX_.'privatesale_delay_lang` l
|
||||
WHERE l.`id_lang` = '.(int) $cookie->id_lang.'
|
||||
AND l.`id_delay`='.(int)$delay.'
|
||||
');
|
||||
$delay_name = $row['name'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->getOrderDetail($cart,$cookie->id_lang);
|
||||
$smarty->assign(array(
|
||||
'order_address' => $order_address,
|
||||
'carrier_name' => $carrier_name,
|
||||
'delay_name' => $delay_name,
|
||||
'delivery_date' => (isset($delivery_date)?$delivery_date:null)
|
||||
'order_address' => $data['order_address'],
|
||||
'carrier_name' => $data['carrier_name'],
|
||||
'delay_name' => $data['delay_name'],
|
||||
'delivery_date' => (isset($data['delivery_date'])?$data['delivery_date']:null)
|
||||
));
|
||||
|
||||
return $this->display(__FILE__, 'blockordersummary.tpl');
|
||||
}
|
||||
}
|
||||
@ -120,4 +68,144 @@ class BlockOrderSummary extends Module {
|
||||
public function hookRightColumn($params) {
|
||||
return $this->hookLeftColumn($params);
|
||||
}
|
||||
|
||||
public function hookRightColumnSav($params) {
|
||||
//global $cookie, $smarty;
|
||||
$cart = new Cart((int)$params['order']->id_cart);
|
||||
$data = $this->getOrderDetail($cart,(int)$cart->id_lang);
|
||||
//echo '<pre>';var_dump($data);echo '</pre>';die();
|
||||
|
||||
echo '<div id="blockordersummary">
|
||||
<div class="content">
|
||||
<h4>'.$this->l('Summary of my order' ).'</h4>
|
||||
<div class="my-cart">
|
||||
<h5>'.$this->l('My Cart' ).'</h5>
|
||||
<ul>';
|
||||
foreach ($cart->getProducts() as $key => $product) {
|
||||
echo '<li>'.$product['quantity'].' x '.$product['name'].' <span class="price">'.$product['total_wt'].'</span></li>';
|
||||
}
|
||||
echo '</ul>
|
||||
<p>'.$this->l('Products total').' <span class="price price_total">'.$cart->getOrderTotal(TRUE, 1).'</span></p>';
|
||||
if ($cart->getOrderTotal(TRUE, 2) != 0){
|
||||
echo '<p>'.$this->l('Discounts total').' <span class="price price_total">'.$cart->getOrderTotal(TRUE, 2).'</span></p>';
|
||||
}
|
||||
echo '</div>
|
||||
<div>
|
||||
<h5>'.$this->l('Shipping').'</h5>
|
||||
<p class="carrier-info"><span class="carrier-name">'.$data['carrier_name'].'</span> <span class="price price_total">'.$cart->getOrderTotal(TRUE, 5).'</span></p>
|
||||
</div>
|
||||
<div>
|
||||
<h5>'.$this->l('Delivery delays').'</h5>
|
||||
<p class="delivery-delay">'.$data['delay_name'].'</p>';
|
||||
if(isset($data['delivery_date'])){
|
||||
foreach($data['delivery_date'] as $k => $date) {
|
||||
if($k == 1) {
|
||||
echo '<p class="delivery-date">
|
||||
'.$this->l('Date de réception prévue entre le').' <strong>'.date('d/m/Y',strtotime($date['date_start'])).'</strong> '.$this->l('et le').' <strong>'.date('d/m/Y',strtotime($date['date_start'])).'</strong>
|
||||
</p>';
|
||||
} elseif ($k == 5){
|
||||
echo '<p class="delivery-date">'.$this->l('Livraison prévue avant le').' <strong>'.$this->l('24/12').'</strong></p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</div>
|
||||
<div>
|
||||
<h5>'.$this->l('My shipping address').'</h5>
|
||||
<p class="address">'.$data['order_address'].'</p>
|
||||
</div>
|
||||
<div>
|
||||
<h5>'.$this->l('My payment').'</h5>
|
||||
<p class="order_total">'.$this->l('Total to pay').' <span class="price price_total">'.$cart->getOrderTotal(TRUE).'</span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
public function getOrderDetail($cart,$id_lang){
|
||||
if(Db::getInstance()->getValue('
|
||||
SELECT `id_carrier`
|
||||
FROM `'._DB_PREFIX_.'carrier`
|
||||
WHERE `id_carrier` = '.(int) $cart->id_carrier.'
|
||||
AND `name` LIKE "%so colissimo%"
|
||||
')) {
|
||||
$socol = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'socolissimo_delivery_info`
|
||||
WHERE `id_cart` = '.(int) $cart->id.'
|
||||
');
|
||||
|
||||
if($socol) {
|
||||
$order_address = nl2br(preg_replace("/(\r\n){2,}/", "\r\n", implode("\r\n", array(
|
||||
$socol['cefirstname'].' '.$socol['cename'],
|
||||
$socol['cecompanyname'],
|
||||
$socol['prfirstname'].' '.$socol['prname'],
|
||||
$socol['prcompladress'],
|
||||
$socol['pradress1'],
|
||||
$socol['pradress2'],
|
||||
$socol['pradress3'],
|
||||
$socol['pradress4'],
|
||||
$socol['przipcode'].' '.$socol['prtown'],
|
||||
'FRANCE',
|
||||
$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) $cart->id_address_delivery)));
|
||||
}
|
||||
} else {
|
||||
$order_address = nl2br(AddressFormat::generateAddress(new Address((int) $cart->id_address_delivery)));
|
||||
}
|
||||
|
||||
if ($id_lang == 3 && (int)$cart->id_carrier == 87) {
|
||||
$carrier_name = "SEUR a domicilio";
|
||||
} else {
|
||||
$carrier_name = Db::getInstance()->getValue('
|
||||
SELECT `name`
|
||||
FROM `'._DB_PREFIX_.'carrier`
|
||||
WHERE `id_carrier` = '.(int) $cart->id_carrier.'
|
||||
');
|
||||
}
|
||||
|
||||
$products_keys = array();
|
||||
$products_delays = array();
|
||||
|
||||
$products = $cart->getProducts();
|
||||
$i = 0;
|
||||
foreach($products as $product) {
|
||||
$products_keys[(int) $product['id_product']] = $i;
|
||||
$i++;
|
||||
}
|
||||
|
||||
// assign delay to Products
|
||||
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();
|
||||
$delivery_date = SaleDelay::getDeliveryDate($delays, null, $date, true);
|
||||
|
||||
foreach($delays as $delay) {
|
||||
$row = Db::getInstance()->getRow('
|
||||
SELECT l.`name`
|
||||
FROM `'._DB_PREFIX_.'privatesale_delay_lang` l
|
||||
WHERE l.`id_lang` = '.(int) $id_lang.'
|
||||
AND l.`id_delay`='.(int)$delay.'
|
||||
');
|
||||
$delay_name = $row['name'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'order_address' => $order_address,
|
||||
'carrier_name' => $carrier_name,
|
||||
'delay_name' => $delay_name,
|
||||
'delivery_date' => (isset($delivery_date)?$delivery_date:null)
|
||||
);
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@
|
||||
</p>
|
||||
{elseif $k == 5}
|
||||
<p class="delivery-date">
|
||||
{l s='Livraison prévue avant le' mod='blockordersummary'} <strong>{l s='24/12' mod='blockordersummary'}</strong> </strong>
|
||||
{l s='Livraison prévue avant le' mod='blockordersummary'} <strong>{l s='24/12' mod='blockordersummary'}</strong>
|
||||
</p>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
Loading…
Reference in New Issue
Block a user