Merge branch 'ticket-AideContact-SAV' into develop

This commit is contained in:
Marion Muszynski 2016-10-18 12:12:27 +02:00
commit b5916c5a74
6 changed files with 2654 additions and 183 deletions

View File

@ -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
@ -116,8 +116,8 @@ class AdminCustomerThreads extends AdminTab
ORDER BY cm.date_add DESC');
$output = '';
foreach ($messages AS $message)
$output .= $this->displayMsg($message, true, (int)Tools::getValue('id_employee_forward'));
$output .= $this->displayMsgCustom($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;">&nbsp;'.$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">&nbsp;</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');
@ -305,13 +305,14 @@ class AdminCustomerThreads extends AdminTab
readfile(_PS_UPLOAD_DIR_.$filename);
die;
}
private function displayMsg($message, $email = false, $id_employee = null)
private function displayMsgCustom($message, $email = false, $id_employee = null)
{
global $cookie, $currentIndex;
$customersToken = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee));
$contacts = Contact::getContacts($cookie->id_lang);
$output = '<div class="panel-message">';
if (!$email)
{
if (!empty($message['id_product']) AND empty($message['employee_name']))
@ -322,7 +323,146 @@ 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 .= '
<div class="panel-head '.(!empty($message['employee_name'])?'bg-rose':'').'">
<div class="panel-head-left">
<div class="user-info">
'.(!empty($message['employee_name'])
?'<span class="anticon anticon-user-tie"></span> '.Configuration::get('PS_SHOP_NAME').' - '.$message['employee_name']
:'<span class="anticon anticon-user"></span>
'.(!empty($message['id_customer'])
?'<a href="index.php?tab=AdminCustomers&id_customer='.(int)($message['id_customer']).'&viewcustomer&token='.$customersToken.'" title="'.$this->l('View customer').'">'.strtoupper($message['customer_name']).'</a>'
: $message['email'])
).
'</div>
<div class="grey div-date"><span class="anticon anticon-clock"></span> '.Tools::displayDate($message['date_add'], (int)($cookie->id_lang), true).'</div>
</div>
<div class="panel-head-right">
'.(
(!empty($message['file_name']) AND file_exists(_PS_UPLOAD_DIR_.$message['file_name']))
? '<a href="index.php?tab=AdminCustomerThreads&id_customer_thread='.$message['id_customer_thread'].'&viewcustomer_thread&token='.Tools::getAdminToken('AdminCustomerThreads'.(int)(Tab::getIdFromClassName('AdminCustomerThreads')).(int)($cookie->id_employee)).'&filename='.$message['file_name'].'" title="'.$this->l('View file').'"><span class="anticon anticon-attachment"></span></a>'
: ''
)
.(empty($message['employee_name'])
?'<a onclick="$(\'#info_'.(int)$message['id_customer_message'].'\').toggle();"><span class="anticon anticon-info"></span></a>'
:'').'
</div>
</div>
'.(empty($message['employee_name'])?'
<div class="more-info" id="info_'.(int)$message['id_customer_message'].'"" style="font-size:11px">
<h4><span class="anticon anticon-info"></span> '.$this->l('Informations').'</h4>
<ul>'.(empty($message['employee_name'])
? '<li><span class="anticon anticon-sphere"></span> '.strip_tags($message['user_agent']).'</li>'
: ''
).(
(!empty($message['id_order']) AND empty($message['employee_name']))
? '<li><b>'.$this->l('Order #').'</b> <a href="index.php?tab=AdminOrders&id_order='.(int)($message['id_order']).'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)).'" title="'.$this->l('View order').'">'.(int)($message['id_order']).' <span class="anticon anticon-eye"></span></a></li>'
: ''
).(
(!empty($message['id_product']) AND empty($message['employee_name']))
? '<li><b>'.$this->l('Product #').'</b> <a href="index.php?tab=AdminOrders&id_order='.(int)($id_order_product).'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)).'" title="'.$this->l('View order').'">'.(int)($message['id_product']).' <span class="anticon anticon-eye"></span></a></li>'
: ''
).'
<li><b>'.$this->l('Thread ID:').'</b> '.(int)$message['id_customer_thread'].'</li>
<li><b>'.$this->l('Message ID:').'</b> '.(int)$message['id_customer_message'].'</li>
</ul>
</div>'
:'').'
<form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post">
<b>'.$this->l('Subject:').'</b>
<input type="hidden" name="id_customer_message" value="'.$message['id_customer_message'].'" />
<select name="id_contact" onchange="this.form.submit();">';
foreach ($contacts as $contact)
$output .= '<option value="'.(int)$contact['id_contact'].'" '.($contact['id_contact'] == $message['id_contact'] ? 'selected="selected"' : '').'>'.Tools::htmlentitiesutf8($contact['name']).'</option>';
$output .= '</select>
</form>';
}
else
{
$output .= '
'.($id_employee ? '<a href="'.Tools::getHttpHost(true).$currentIndex.'&token='.Tools::getAdminToken('AdminCustomerThreads'.(int)(Tab::getIdFromClassName('AdminCustomerThreads')).(int)($id_employee)).'&id_customer_thread='.(int)$message['id_customer_thread'].'&viewcustomer_thread">'.$this->l('View this thread').'</a><br />' : '').'
<b>'.$this->l('Sent by:').'</b> '.(!empty($message['customer_name']) ? $message['customer_name'].' ('.$message['email'].')' : $message['email'])
.((!empty($message['id_customer']) AND empty($message['employee_name'])) ? '<br /><b>'.$this->l('Customer ID:').'</b> '.(int)($message['id_customer']).'<br />' : '')
.((!empty($message['id_order']) AND empty($message['employee_name'])) ? '<br /><b>'.$this->l('Order #').':</b> '.(int)($message['id_order']).'<br />' : '')
.((!empty($message['id_product']) AND empty($message['employee_name'])) ? '<br /><b>'.$this->l('Product #').':</b> '.(int)($message['id_product']).'<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('
SELECT sr.*, srl.title
FROM `'._DB_PREFIX_.'support_reason` sr
LEFT JOIN `'._DB_PREFIX_.'support_reason_lang` srl ON (srl.id_reason = sr.id_reason)
LEFT JOIN `'._DB_PREFIX_.'support_reason_customerthread` src ON (src.id_reason = sr.id_reason)
WHERE `id_customer_thread` = '.(int) $message['id_customer_thread'].'
AND srl.id_lang = '.$cookie->id_lang
);
if ($result) {
$output .='<br />
<b>'.$this->l('Reason:').'</b> '.$result['title'].'<br />';
}
}
// end adding
$message['message'] = preg_replace('/(https?:\/\/[a-z0-9#%&_=\(\)\.\? \+\-@\/]{6,1000})([\s\n<])/Uui', '<a href="\1">\1</a>\2', html_entity_decode($message['message'], ENT_NOQUOTES, 'UTF-8'));
$output .= '<div class="panel-content-message '.(!empty($message['employee_name'])?'bg-rose':'bg-purple').'">
<b>'.$this->l('Message:').'</b><br />
'.$message['message'].'
</div>';
if (!$email)
{
if (empty($message['employee_name']))
$output .= '
<p class="btn-answer" style="text-align:right">
<button class="button" onclick="$(\'#reply_to_'.(int)($message['id_customer_message']).'\').show(500); $(this).hide();">
<span class="anticon anticon-bubbles3"></span> '.$this->l('Reply to this message').'
</button>
</p>
<p class="clear">&nbsp;</p>
<div id="reply_to_'.(int)($message['id_customer_message']).'" style="display: none; margin-top: 10px;" class="panel-answer">
<form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
<p>'.$this->l('Please type your reply below:').'</p>
<div style="width: 450px; margin-top: 0px;margin-bottom:5px;">
<input type="file" name="joinFile"/>
</div>
<textarea name="reply_message">'.str_replace('\r\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', $message['id_lang'])).'</textarea>
<div style="text-align: right; font-style: italic; font-size: 9px; margin-top: 2px;">
'.$this->l('Your reply will be sent to:').' '.$message['email'].'
</div>
<div style="text-align: right;">
<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>
</form>
</div>';
}
$output .= '</div>';
return $output;
}
private function displayMsg($message, $email = false, $id_employee = null)
{
global $cookie, $currentIndex;
$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']))
$id_order_product = Db::getInstance()->getValue('
SELECT o.id_order
FROM '._DB_PREFIX_.'orders o
LEFT JOIN '._DB_PREFIX_.'order_detail od ON o.id_order = od.id_order
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 +515,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 +540,7 @@ class AdminCustomerThreads extends AdminTab
<b>'.$this->l('Message:').'</b><br />
'.$message['message'].'
</div>';
if (!$email)
{
if (empty($message['employee_name']))
@ -424,24 +564,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 +590,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);
@ -474,9 +614,47 @@ class AdminCustomerThreads extends AdminTab
<input type="Submit" name="submitForward" class="button" value="'.$this->l('Forward this discussion').'" style="margin-top: 10px;" />
</div>
</p>
</form>
<div class="clear">&nbsp;</div>';
</form>';
if ($nextThread)
echo $this->displayButton('
<a href="'.$currentIndex.'&id_customer_thread='.(int)$nextThread.'&viewcustomer_thread&token='.$this->token.'">
'.$this->l('Answer to the next unanswered message in this category').' &gt;
</a>');
else
echo $this->displayButton('
<span class="non-action"><span class="anticon anticon-tick">&#xea10;</span> '.$this->l('The other messages in this category have been answered').'</span>');
if ($thread->status != "closed")
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=2&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
<span class="anticon anticon-tick">&#xea10;</span> '.$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.'">
<span class="anticon anticon-tick">&#xea07;</span> '.$this->l('pending 1').'
</a>');
else
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=1&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
'.$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.'">
<span class="anticon anticon-tick">&#xea07;</span> '.$this->l('pending 2').'
</a>');
else
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=1&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
'.$this->l('Click here to disable pending status').'
</a>');
echo '<div class="clear">&nbsp;</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 +664,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,59 +677,49 @@ 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.'">
<img src="../img/admin/next-msg.png" title="'.$this->l('Go to the oldest next unanswered message').'" style="margin-bottom: 10px;" />
<br />'.$this->l('Answer to the next unanswered message in this category').' &gt;
</a>');
else
echo $this->displayButton('
<img src="../img/admin/msg-ok.png" title="'.$this->l('Go to the oldest next unanswered message').'" style="margin-bottom: 10px;" />
<br />'.$this->l('The other messages in this category have been answered'));
if ($thread->status != "closed")
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=2&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
<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.'">
<img src="../img/admin/msg-pending.png" style="margin-bottom:10px" />
<br />'.$this->l('Declare this message').'<br />'.$this->l('as "pending 1"').'<br />'.$this->l('(will be answered later)').'
</a>');
else
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=1&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
<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.'">
<img src="../img/admin/msg-pending.png" style="margin-bottom:10px" />
<br />'.$this->l('Declare this message').'<br />'.$this->l('as "pending 2"').'<br />'.$this->l('(will be answered later)').'
</a>');
else
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=1&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
<img src="../img/admin/msg-is-pending.png" style="margin-bottom:10px" />
<br />'.$this->l('Click here to disable pending status').'
</a>');
$order_thread = null;
foreach ($messages AS $message){
if ($message['id_order']){
$order_thread = new Order((int)($message['id_order']));
break;
}
}
if ($thread->id_customer) {
$customer = new Customer($thread->id_customer);
$products = $customer->getBoughtProducts();
$nb_orders = Db::getInstance()->getValue('
SELECT COUNT(id_order) FROM '._DB_PREFIX_.'orders
WHERE id_customer = '.(int)$customer->id.' AND valid=1
');
$customer_info = array(
'nb_orders' => $nb_orders,
);
}
echo '<div style="margin-top:10px">';
Module::hookExec('rightColumnSav', array(
'customer' => $customer,
'customer_info' => $customer_info,
'order' => $order_thread)
);
echo '</div>';
echo '</div>';
echo '<div style="float:left;margin-top:10px">';
foreach ($messages AS $message) {
echo $this->displayMsgCustom($message);
}
echo '</div>';
echo '<div class="clear">&nbsp;</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))
{
@ -617,22 +785,20 @@ class AdminCustomerThreads extends AdminTab
<td align="right">'.$product['product_quantity'].'</td>
<td align="center"><a href="?tab=AdminOrders&id_order='.$product['id_order'].'&vieworder&token='.$tokenOrders.'"><img src="../img/admin/details.gif" /></a></td>
</tr>';
echo '</table></div>';
echo '</table>
</div>';
}
echo '</div>';
}
echo '<div style="float:left;margin-top:10px">';
foreach ($messages AS $message)
echo $this->displayMsg($message);
echo '</div><div class="clear">&nbsp;</div>';
echo '<div class="clear">&nbsp;</div>';
}
private function displayButton($content)
{
return '
<div style="margin-bottom:10px;border:1px solid #005500;width:200px;height:130px;padding:10px;background:#EFE">
<p style="text-align:center;font-size:15px;font-weight:bold">
<div class="btn-action-message">
<p style="text-align:center;font-size:13px;">
'.$content.'
</p>
</div>';

File diff suppressed because it is too large Load Diff

BIN
css/fonts/IcoMoon-Free.ttf Executable file

Binary file not shown.

View File

@ -0,0 +1,139 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
class Ant_Infocustomer extends Module
{
public function __construct()
{
$this->name = 'ant_infocustomer';
$this->tab = 'administration';
$this->author = 'Antadis';
$this->version = '1.0';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Information about customer');
$this->description = $this->l('Block of information about customer in BO');
}
private $hooks = array(
'rightColumnSav' => array('BO SAV right column', 'Allow to add information in right column of SAV message thread'),
);
public function install() {
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;
}
public function hookRightColumnSav($params) {
if(isset($params['customer'])) {
global $cookie;
echo "<style type='text/css'>
#blockinfocustomer {
width: 300px;
background: #fff;
padding-bottom: 5px;
margin-bottom: 20px;
-moz-box-shadow: 1px 1px 2px 2px #cccccc;
-webkit-box-shadow: 1px 1px 2px 2px #ccc;
-ms-box-shadow: 1px 1px 2px 2px #cccccc;
-o-box-shadow: 1px 1px 2px 2px #cccccc;
box-shadow: 1px 1px 2px 2px #ccc;
clear: both;
}
#blockinfocustomer .content {
padding: 5px;
position: relative;
}
#blockinfocustomer .content div{
color: #1e1633;
margin: 0px 5px;
font-size: 12px;
padding: 8px 0px 5px;
border-top: 1px dashed #ccc;
line-height: 1.4em;
}
#blockinfocustomer .content div.first-div{
border-top: 1px solid #ccc;
}
#blockinfocustomer h4{
display: block;
font-size: 18px;
color: #796dc7;
font-weight: normal;
margin: 0px 5px 2px;
padding: 12px 0px 10px;
border-bottom: 1px solid #ccc;
}
#blockinfocustomer h5 {
color: #444d52;
font-family: georgia, times new roman, serif;
margin-bottom: 10px;
font-weight: 600;
font-size: 13px;
}
#blockinfocustomer .content span.anticon-user{
position: absolute;
font-size: 80px;
right: 10px;
opacity: 0.3;
}
#blockinfocustomer ul {
margin: 0px 0px 7px;
padding: 0px;
list-style: none;
border-bottom: 1px solid #999;
}
#blockinfocustomer li {
padding-bottom: 5px;
}
#blockinfocustomer p {
margin-bottom: 5px;
}
#blockinfocustomer p span.anticon{
font-size:14px;
}
</style>";
$customersToken = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee));
echo '<div id="blockinfocustomer">
<div class="content">
<h4>'.$this->l('Customer Information' ).'</h4>
<div class="first-div">
<span class="anticon anticon-user"></span>
<h5>'.ucfirst($params['customer']->firstname).' '.ucfirst($params['customer']->lastname).' <a target="_blank" href="index.php?tab=AdminCustomers&id_customer='.(int)$params['customer']->id.'&viewcustomer&token='.$customersToken.'">('.$params['customer']->id.')</a></h5>
<p><span class="anticon anticon-envelop"></span> '.$params['customer']->email.'</p>
<p><span class="anticon anticon-cart"></span> '.$params['customer_info']['nb_orders'].' '.$this->l('valid orders').'</p>
</div>
</div>
</div>';
}
}
}

View File

@ -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,235 @@ class BlockOrderSummary extends Module {
public function hookRightColumn($params) {
return $this->hookLeftColumn($params);
}
public function hookRightColumnSav($params) {
if(isset($params['order'])) {
$cart = new Cart((int)$params['order']->id_cart);
$data = $this->getOrderDetail($cart,(int)$cart->id_lang);
echo "<style type='text/css'>
#blockordersummary {
width: 300px;
background: #fff;
padding-bottom: 5px;
margin-bottom: 20px;
-moz-box-shadow: 1px 1px 2px 2px #cccccc;
-webkit-box-shadow: 1px 1px 2px 2px #ccc;
-ms-box-shadow: 1px 1px 2px 2px #cccccc;
-o-box-shadow: 1px 1px 2px 2px #cccccc;
box-shadow: 1px 1px 2px 2px #ccc;
clear: both;
}
#blockordersummary .content {
padding: 5px;
}
#blockordersummary .content div{
color: #1e1633;
margin: 0px 5px;
font-size: 12px;
padding: 8px 0px 5px;
border-top: 1px dashed #ccc;
line-height: 1.4em;
}
#blockordersummary .content div.my-cart {
border-top: 1px solid #ccc;
}
#blockordersummary h4{
display: block;
font-size: 18px;
color: #796dc7;
font-weight: normal;
margin: 0px 5px 2px;
padding: 12px 0px 10px;
border-bottom: 1px solid #ccc;
}
#blockordersummary h5 {
color: #444d52;
font-family: georgia, times new roman, serif;
margin-bottom: 10px;
font-weight: 600;
font-size: 13px;
}
#blockordersummary ul {
margin: 0px 0px 7px;
padding: 0px;
list-style: none;
border-bottom: 1px solid #999;
}
#blockordersummary li {
padding-bottom: 5px;
}
#blockordersummary p {
margin-bottom: 5px;
}
#blockordersummary p.carrier-info:after{
content: '';
display: block;
clear: both;
}
#blockordersummary span.carrier-name {
float: left;
max-width: 130px;
}
#blockordersummary p.delivery-delay {
color: #e36ea2;
font-weight: 600;
}
#blockordersummary p.delivery-date strong{
font-size: 11px;
}
#blockordersummary .price {
float: right;
}
#blockordersummary .price.price_total {
color: #e36ea2;
font-weight: bold;
}
#blockordersummary .address {
color: #1e1633;
}
#blockordersummary .order_total {
color: #e36ea2;
padding: 15px;
font-size: 14px;
font-weight: bold;
background: rgba(226,110,162,0.2) ;
}
</style>";
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)
);
}
}

View File

@ -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}