start refund sav page

This commit is contained in:
Marion Muszynski 2016-10-14 18:30:05 +02:00
parent bcffb2088f
commit 27a62959a6
3 changed files with 230 additions and 132 deletions

View File

@ -621,7 +621,17 @@ class AdminCustomerThreads extends AdminTab
} }
echo '</div>'; 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">'; echo '<div style="float:left;margin-top:10px">';
foreach ($messages AS $message) foreach ($messages AS $message)
echo $this->displayMsg($message); echo $this->displayMsg($message);

View File

@ -19,14 +19,109 @@ class BlockOrderSummary extends Module {
$this->description = $this->l('Displays a summary of the current order'); $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() { 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) { public function hookLeftColumn($params) {
global $cookie, $smarty, $cart; global $cookie, $smarty, $cart;
if(($step = (int) Tools::getValue('step')) && ($step == 3 || $step == 4)) { if(($step = (int) Tools::getValue('step')) && ($step == 3 || $step == 4)) {
$data = $this->getOrderDetail($cart,$cookie->id_lang);
$smarty->assign(array(
'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');
}
}
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(' if(Db::getInstance()->getValue('
SELECT `id_carrier` SELECT `id_carrier`
FROM `'._DB_PREFIX_.'carrier` FROM `'._DB_PREFIX_.'carrier`
@ -63,7 +158,7 @@ class BlockOrderSummary extends Module {
$order_address = nl2br(AddressFormat::generateAddress(new Address((int) $cart->id_address_delivery))); $order_address = nl2br(AddressFormat::generateAddress(new Address((int) $cart->id_address_delivery)));
} }
if ($cookie->id_lang == 3 && (int)$cart->id_carrier == 87) { if ($id_lang == 3 && (int)$cart->id_carrier == 87) {
$carrier_name = "SEUR a domicilio"; $carrier_name = "SEUR a domicilio";
} else { } else {
$carrier_name = Db::getInstance()->getValue(' $carrier_name = Db::getInstance()->getValue('
@ -98,7 +193,7 @@ class BlockOrderSummary extends Module {
$row = Db::getInstance()->getRow(' $row = Db::getInstance()->getRow('
SELECT l.`name` SELECT l.`name`
FROM `'._DB_PREFIX_.'privatesale_delay_lang` l FROM `'._DB_PREFIX_.'privatesale_delay_lang` l
WHERE l.`id_lang` = '.(int) $cookie->id_lang.' WHERE l.`id_lang` = '.(int) $id_lang.'
AND l.`id_delay`='.(int)$delay.' AND l.`id_delay`='.(int)$delay.'
'); ');
$delay_name = $row['name']; $delay_name = $row['name'];
@ -106,18 +201,11 @@ class BlockOrderSummary extends Module {
} }
} }
$smarty->assign(array( return array(
'order_address' => $order_address, 'order_address' => $order_address,
'carrier_name' => $carrier_name, 'carrier_name' => $carrier_name,
'delay_name' => $delay_name, 'delay_name' => $delay_name,
'delivery_date' => (isset($delivery_date)?$delivery_date:null) 'delivery_date' => (isset($delivery_date)?$delivery_date:null)
)); );
return $this->display(__FILE__, 'blockordersummary.tpl');
}
}
public function hookRightColumn($params) {
return $this->hookLeftColumn($params);
} }
} }

View File

@ -27,7 +27,7 @@
</p> </p>
{elseif $k == 5} {elseif $k == 5}
<p class="delivery-date"> <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> </p>
{/if} {/if}
{/foreach} {/foreach}