Updated the duplicate messages in the adminOrder, and made hidden fields readonly while replying to the message

This commit is contained in:
vishalsingh.qlo325
2025-02-27 15:55:07 +05:30
parent b4f03b3917
commit 42fa5390af
5 changed files with 38 additions and 39 deletions

View File

@@ -282,10 +282,6 @@
})
$('#order_message').live('change', function(e) {
e.preventDefault();
let visibility = 0;
if ($('#visibility').prop('checked')) {
visibility = 1;
}
$.ajax({
type:"POST",
url: "{$link->getAdminLink('AdminCarts')|addslashes}",
@@ -298,9 +294,7 @@
action: "updateOrderMessage",
id_cart: id_cart,
id_customer: id_customer,
message: $(this).val(),
visibility: visibility
},
message: $(this).val() },
success : function(res)
{
displaySummary(res);

View File

@@ -576,7 +576,7 @@ class AdminCartsControllerCore extends AdminController
public function ajaxProcessUpdateOrderMessage()
{
if ($this->tabAccess['edit'] === '1') {
if ($this->tabAccess['edit'] === '1' || $this->tabAccess['add'] === '1') {
$id_message = false;
if ($old_message = Message::getMessageByCartId((int)$this->context->cart->id)) {
$id_message = $old_message['id_message'];
@@ -587,7 +587,6 @@ class AdminCartsControllerCore extends AdminController
$message->message = $message_content;
$message->id_cart = (int)$this->context->cart->id;
$message->id_customer = (int)$this->context->cart->id_customer;
$message->private = !Tools::getValue('visibility');
$message->save();
}
} elseif (Validate::isLoadedObject($message)) {
@@ -599,7 +598,7 @@ class AdminCartsControllerCore extends AdminController
public function ajaxProcessUpdateCurrency()
{
if ($this->tabAccess['edit'] === '1' || $this->tabAccess['add'] === '1') {
if ($this->tabAccess['edit'] === '1') {
$currency = new Currency((int)Tools::getValue('id_currency'));
if (Validate::isLoadedObject($currency) && !$currency->deleted && $currency->active) {
$this->context->cart->id_currency = (int)$currency->id;

View File

@@ -3040,7 +3040,18 @@ class AdminOrdersControllerCore extends AdminController
$objCustomerThread = new CustomerThread();
$messages = Message::getMessagesByOrderId($order->id, true);
if ($customerMessages = CustomerMessage::getMessagesByOrderId($order->id, true)) {
$messages = array_merge($messages, $customerMessages);
foreach ($messages as $messageKey => $message) {
foreach ($customerMessages as $customerMessageKey => $customerMessage) {
if (strcmp($message['message'], $customerMessage['message']) == 0) {
unset($messages[$messageKey]);
}
}
}
$messages = array_merge($customerMessages, $messages);
usort($messages, function ($a, $b) {
return strtotime($a['date_add']) < strtotime($b['date_add']);
});
}
$this->tpl_view_vars = array(

View File

@@ -672,8 +672,7 @@ CREATE TABLE `PREFIX_customer_thread` (
KEY `id_lang` (`id_lang`),
KEY `id_contact` (`id_contact`),
KEY `id_customer` (`id_customer`),
KEY `id_order` (`id_order`),
KEY `id_product` (`id_product`)
KEY `id_order` (`id_order`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION;
CREATE TABLE `PREFIX_order_customer_guest_detail` (

View File

@@ -75,16 +75,14 @@
{else}
<form action="{$link->getPageLink('contact')}" method="post" class="contact-form-box" enctype="multipart/form-data">
{/if}
{if !isset($customerThread.id_contact)}
<div class="form-group row">
<div class="col-sm-12">
<label for="user_name" class="control-label">
{l s='Name'}{if isset($contactNameRequired) && $contactNameRequired}*{/if}
</label>
<input class="form-control contact_input" type="text" id="user_name" name="user_name" value="{if isset($customerThread.user_name)}{$customerThread.user_name|escape:'html':'UTF-8'}{/if}"/>
</div>
<div class="form-group row">
<div class="col-sm-12">
<label for="user_name" class="control-label">
{l s='Name'}{if isset($contactNameRequired) && $contactNameRequired}*{/if}
</label>
<input class="form-control contact_input" type="text" id="user_name" name="user_name" value="{if isset($smarty.post.user_name)}{$smarty.post.user_name}{elseif isset($customerThread.user_name)}{$customerThread.user_name|escape:'html':'UTF-8'}{/if}" {if isset($customerThread.user_name)} readonly{/if}/>
</div>
{/if}
</div>
<div class="form-group row">
<div class="col-sm-12">
<label for="Email" class="control-label">
@@ -93,28 +91,26 @@
{if isset($customerThread.email)}
<input class="form-control contact_input" type="email" id="email" name="from" value="{if isset($customerThread.email)}{$customerThread.email|escape:'html':'UTF-8'}" readonly="readonly"{/if} />
{else}
<input class="form-control contact_input validate" type="email" id="email" name="from" data-validate="isEmail" value="{$email|escape:'html':'UTF-8'}" />
<input class="form-control contact_input validate" type="email" id="email" name="from" data-validate="isEmail" value="{if isset($smarty.post.email)}{$smarty.post.email}{else}{$email|escape:'html':'UTF-8'}{/if}" />
{/if}
</div>
</div>
{if !isset($customerThread.id_contact)}
<div class="form-group row">
<div class="col-sm-12">
<label for="phone" class="control-label">
{l s='Phone'}{if isset($contactPhoneRequired) && $contactPhoneRequired}*{/if}
</label>
<input class="form-control contact_input" type="text" id="phone" name="phone" value="{if isset($customerThread.phone)}{$customerThread.phone|escape:'html':'UTF-8'}{/if}"/>
</div>
<div class="form-group row">
<div class="col-sm-12">
<label for="phone" class="control-label">
{l s='Phone'}{if isset($contactPhoneRequired) && $contactPhoneRequired}*{/if}
</label>
<input class="form-control contact_input" type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{else if isset($customerThread.phone)}{$customerThread.phone|escape:'html':'UTF-8'}{/if}" {if isset($customerThread.phone)}readonly="readonly"{/if}/>
</div>
<div class="form-group row">
<div class="col-sm-12">
<label for="subject" class="control-label">
{l s='Subject'}*
</label>
<input class="form-control contact_input" type="text" id="subject" name="subject" value="{if isset($customerThread.name)}{$customerThread.name|escape:'html':'UTF-8'}{/if}"/>
</div>
</div>
<div class="form-group row">
<div class="col-sm-12">
<label for="subject" class="control-label">
{l s='Subject'}*
</label>
<input class="form-control contact_input" type="text" id="subject" name="subject" value="{if isset($smarty.post.subject)}{$smarty.post.subject}{else if isset($customerThread.subject)}{$customerThread.subject|escape:'html':'UTF-8'}{/if}" {if isset($customerThread.subject)}readonly="readonly"{/if}/>
</div>
{/if}
</div>
{if !isset($customerThread.id_contact) && isset($allowContactSelection) && $allowContactSelection}
<div class="form-group row">
<div class="col-sm-12">