This commit is contained in:
Marion Muszynski 2016-10-17 17:29:37 +02:00
parent 27a62959a6
commit 6e0cfd7635
3 changed files with 2271 additions and 106 deletions

View File

@ -116,7 +116,7 @@ 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;
@ -305,6 +305,142 @@ class AdminCustomerThreads extends AdminTab
readfile(_PS_UPLOAD_DIR_.$filename);
die;
}
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']))
$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 .= '
<div class="panel-head">
<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>'
: ''
).'
<a onclick="$(\'#info_'.(int)$message['id_customer_message'].'\').toggle();"><span class="anticon anticon-info"></span></a>
</div>
</div>
<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']).' <img src="../img/admin/search.gif" alt="'.$this->l('view').'" /></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']).' <img src="../img/admin/search.gif" alt="'.$this->l('view').'" /></a></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 = '<div style="font-size:11px">
'.($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 />' : '')
.'</div><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">
<b>'.$this->l('Thread ID:').'</b> '.(int)$message['id_customer_thread'].'<br />
<b>'.$this->l('Message ID:').'</b> '.(int)$message['id_customer_message'].'<br />
<b>'.$this->l('Message:').'</b><br />
'.$message['message'].'
</div>';
if (!$email)
{
if (empty($message['employee_name']))
$output .= '
<p style="text-align:right">
<button style="font-family: Verdana; font-size: 11px; font-weight:bold; height: 65px; width: 120px;" onclick="$(\'#reply_to_'.(int)($message['id_customer_message']).'\').show(500); $(this).hide();">
<img src="'.__PS_BASE_URI__.'img/admin/contact.gif" alt="" style="margin-bottom: 5px;" /><br />'.$this->l('Reply to this message').'
</button>
</p>
<div id="reply_to_'.(int)($message['id_customer_message']).'" style="display: none; margin-top: 20px;"">
<form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
<p>'.$this->l('Please type your reply below:').'</p>
<textarea style="width: 450px; height: 175px;" name="reply_message">'.str_replace('\r\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', $message['id_lang'])).'</textarea>
<div style="width: 450px; 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="width: 450px; margin-top: 0px;">
<input type="file" name="joinFile"/>
<div>
<div style="width: 450px; text-align: center;">
<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;
@ -474,8 +610,46 @@ 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
@ -500,50 +674,38 @@ class AdminCustomerThreads extends AdminTab
'.($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'));
$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,
);
}
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>');
echo '<div style="margin-top:10px">';
Module::hookExec('rightColumnSav', array(
'customer' => $customer,
'customer_info' => $customer_info,
'order' => $order_thread)
);
echo '</div>';
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>');
echo '</div>';
echo '<div style="float:left;margin-top:10px">';
foreach ($messages AS $message)
echo $this->displayMsgCustom($message);
echo '</div>';
if ($thread->id_customer)
@ -621,28 +783,15 @@ 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">&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

View File

@ -70,55 +70,146 @@ class BlockOrderSummary extends Module {
}
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();
if(isset($params['order'])) {
$cart = new Cart((int)$params['order']->id_cart);
$data = $this->getOrderDetail($cart,(int)$cart->id_lang);
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 "<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>
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>
<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>';
</div>';
}
}
public function getOrderDetail($cart,$id_lang){