Merge branch 'ticket-AideContact-SAV' into develop

This commit is contained in:
Marion Muszynski 2016-10-24 18:34:13 +02:00
commit 4ad4ae47bc
4 changed files with 98 additions and 29 deletions

View File

@ -518,16 +518,20 @@ class AdminCustomerThreads extends AdminTab
SELECT * FROM `'._DB_PREFIX_.'support_product_customerthread`
WHERE `id_customer_thread` = '.(int)$tr['id_customer_thread']
);
$supTo10 = false;
$supTo100 = false;
$supTo10 = 0;
$supTo100 = 0;
if(!empty($products)) {
foreach ($products as $product) {
$price = Product::getPriceStatic((int)$product['id_product'], false, (int)$product['id_product_attribute'], 6, NULL, false, true, 1, false, ((int)($tr['id_customer']) ? (int)($tr['id_customer']) : NULL), (int)($order->id_cart), ((int)($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) ? (int)($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) : NULL), $specificPriceOutput);
$supTo10 = ($price>10)?true:false;
$supTo100 = ($price>100)?true:false;
if($price>10){
$supTo10++;
}
if($price>100){
$supTo100++;
}
}
}
echo ($supTo10?'<p class="bg-green-light text-green-light"><span class="anticon anticon-coin-euro"></span>'.($supTo100?'<span class="anticon anticon-coin-euro"></span>':'').'</p>':'<p>--</p>');
echo ($supTo10>0?'<p class="bg-green-light text-green-light"><span class="anticon anticon-coin-euro"></span>'.($supTo100>0?'<span class="anticon anticon-coin-euro"></span>':'').'</p>':'<p>--</p>');
} elseif ($key == 'id_order' AND isset($tr[$key])) {
$order = new Order((int)$tr[$key]);
$cart = new Cart((int)$order->id_cart);

View File

@ -26,22 +26,13 @@ if ($cookie->isLogged()) {
$order = new Order($row['id_order']);
$date = explode(' ', $order->date_add);
$orders[$row['id_order']] = Tools::displayDate($date[0], $cookie->id_lang);
$tmp = $order->getProducts();
foreach ($tmp as $key => $val)
$products[$val['product_id']] = $val['product_name'];
}
$orderList = '';
foreach ($orders as $key => $val) {
$orderList .= '<option value="'.$key.'" '.((int)(Tools::getValue('id_order')) == $key ? 'selected' : '').' >'.$key.' -- '.$val.'</option>';
}
$orderedProductList = '';
foreach ($products as $key => $val) {
$orderedProductList .= '<option value="'.$key.'" '.((int)(Tools::getValue('id_product')) == $key ? 'selected' : '').' >'.$val.'</option>';
$orderList .= '<option value="'.$key.'" '.((int)(Tools::getValue('id_order')) == $key ? 'selected' : '').' >#'.$key.' - '.$val.'</option>';
}
$smarty->assign('orderList', $orderList);
$smarty->assign('orderedProductList', $orderedProductList);
}
if (Tools::isSubmit('submitMessage')) {
@ -67,7 +58,7 @@ if (Tools::isSubmit('submitMessage')) {
$errors[] = Tools::displayError('Please select a reason on the list.');
elseif (($id_contact = (int)(Tools::getValue('id_contact'))) && ($id_contact == 9 || $id_contact == 1) && !Tools::getValue('id_order'))
$errors[] = Tools::displayError('Please enter/choose an order ID');
elseif (($id_contact = (int)(Tools::getValue('id_contact'))) && $id_contact == 1 && !Tools::getValue('id_product'))
elseif (($id_contact = (int)(Tools::getValue('id_contact'))) && $id_contact == 1 && !Tools::getValue('id_products'))
$errors[] = Tools::displayError('Please choose a product');
elseif (!empty($_FILES['fileUpload']['name']) AND $_FILES['fileUpload']['error'] != 0)
$errors[] = Tools::displayError('An error occurred during the file upload');
@ -152,10 +143,13 @@ if (Tools::isSubmit('submitMessage')) {
$ct->status = 'open';
$ct->id_lang = (int)$cookie->id_lang;
$ct->id_contact = (int)($id_contact);
if ($id_order = (int)Tools::getValue('id_order'))
if ($id_order = (int)Tools::getValue('id_order')) {
$ct->id_order = $id_order;
if ($id_product = (int)Tools::getValue('id_product'))
$ct->id_product = $id_product;
}
if ($id_products = Tools::getValue('id_products')) {
$first_product = explode("_", $id_products[0]);
$ct->id_product = (int)$first_product[0];
}
$ct->update();
}
else
@ -163,10 +157,13 @@ if (Tools::isSubmit('submitMessage')) {
$ct = new CustomerThread();
if (isset($customer->id))
$ct->id_customer = (int)($customer->id);
if ($id_order = (int)Tools::getValue('id_order'))
if ($id_order = (int)Tools::getValue('id_order')){
$ct->id_order = $id_order;
if ($id_product = (int)Tools::getValue('id_product'))
$ct->id_product = $id_product;
}
if ($id_products = Tools::getValue('id_products')) {
$first_product = explode("_", $id_products[0]);
$ct->id_product = (int)$first_product[0];
}
$ct->id_contact = (int)($id_contact);
$ct->id_lang = (int)$cookie->id_lang;
$ct->email = $from;
@ -185,6 +182,20 @@ if (Tools::isSubmit('submitMessage')) {
$reason->insertReasonCustomerThread((int) $ct->id);
}
}
// adding (antadis) - linking productS and customer_thread
if ($id_products = Tools::getValue('id_products')) {
foreach ($id_products as $key => $val) {
$p = explode("_", $val);
DB::getInstance()->execute('
INSERT IGNORE INTO `'._DB_PREFIX_.'support_product_customerthread` (`id_product`,`id_product_attribute`, `id_customer_thread`)
VALUE(
'.(int)$p[0].',
'.(int)$p[1].',
'.(int)$ct->id.'
)
');
}
}
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;

View File

@ -34,7 +34,7 @@
{if !isset($customerThread.id_order) && isset($isLogged) && $isLogged == 1 && !empty($orderList)}
<p class="text">
<label for="id_order">{l s='Order ID' mod='ant_support_form'}</label>
<select name="id_order" ><option value="0">{l s='-- Choose --' mod='ant_support_form'}</option>{$orderList}</select>
<select name="id_order" id="id_order"><option value="0">{l s='-- Choose --' mod='ant_support_form'}</option>{$orderList}</select>
{elseif !isset($customerThread.id_order) && !isset($isLogged)}
<p class="text">
<label for="id_order">{l s='Order ID' mod='ant_support_form'}</label>
@ -50,15 +50,64 @@
</p>
{/if}
{if isset($isLogged) && $isLogged && isset($allow_product) && $allow_product}
{if !isset($customerThread.id_product) && !empty($orderedProductList)}
<p class="text">
<label for="id_product">{l s='Product' mod='ant_support_form'}</label>
<select name="id_product" style="width:300px;"><option value="0">{l s='-- Choose --'}</option>{$orderedProductList}</select>
</p>
{if !isset($customerThread.id_product)}
<div id="products_part" class="text" style="display:none;">
<label for="id_products">{l s='Product' mod='ant_support_form'}</label>
<div id="products">
</div>
</div>
{literal}<script>
$(function() {
if ($('#id_order').val()!= 0) {
var id_order = $('#id_order').val();
$.ajax({
type: 'GET',
url: '{/literal}{$base_dir_ssl}{literal}modules/ant_support_form/ajax_support.php',
dataType: 'json',
data: {
id_order : id_order,
token : static_token
},
success: function(jsonData) {
$("#products_part").hide();
$("#products").empty();
if(jsonData.error == "false") {
$("#products").append(jsonData.result);
$("#products_part").show();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to get order products \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
}
$('#id_order').change(function() {
var id_order = $(this).val();
$.ajax({
type: 'GET',
url: '{/literal}{$base_dir_ssl}{literal}modules/ant_support_form/ajax_support.php',
dataType: 'json',
data: {
id_order : id_order,
token : static_token
},
success: function(jsonData) {
$("#products_part").hide();
$("#products").empty();
if(jsonData.error == "false") {
$("#products").append(jsonData.result);
$("#products_part").show();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to get order products \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
});
});
</script>{/literal}
{elseif $customerThread.id_product > 0}
<p class="text">
<label for="id_product">{l s='Product' mod='ant_support_form'}</label>
<input type="text" name="id_product" id="id_product" value="{$customerThread.id_product|intval}" readonly="readonly" />
<input type="text" name="id_products[]" id="id_product" value="{$customerThread.id_product|intval}" readonly="readonly" />
</p>
{else}
<p class="text error cant-submit">

View File

@ -5836,6 +5836,11 @@ div#giftvoucher_ask_infos_block .gv_customization > .gv_param input {
}
/** Module ant_support_form **/
#module-ant_support_form-support #center_column div#products_part label,
#module-ant_support_form-support #center_column div#products_part label img{
display: inline-block;
vertical-align: middle;
}
#module-ant_support_form-support #center_column p.submit {
text-align: right;
}