[-] MO : mailalert : #PSCFV-3763 : Fix error when i delete an mail alert
This commit is contained in:
@@ -75,8 +75,7 @@ class MailAlert extends ObjectModel
|
||||
{
|
||||
$sql = '
|
||||
DELETE FROM `'._DB_PREFIX_.self::$definition['table'].'`
|
||||
WHERE '.(($id_customer > 0) ? '(`customer_email` = \''.pSQL($customer_email).'\'
|
||||
OR `id_customer` = '.(int)$id_customer.')' :
|
||||
WHERE '.(($id_customer > 0) ? '(`customer_email` = \''.pSQL($customer_email).'\' OR `id_customer` = '.(int)$id_customer.')' :
|
||||
'`customer_email` = \''.pSQL($customer_email).'\'').
|
||||
' AND `id_product` = '.(int)$id_product.'
|
||||
AND `id_product_attribute` = '.(int)$id_product_attribute;
|
||||
|
||||
@@ -34,6 +34,7 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
|
||||
* @var int
|
||||
*/
|
||||
public $id_product;
|
||||
public $id_product_attribute;
|
||||
|
||||
public function init()
|
||||
{
|
||||
@@ -41,6 +42,7 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
|
||||
|
||||
require_once($this->module->getLocalPath().'MailAlert.php');
|
||||
$this->id_product = (int)Tools::getValue('id_product');
|
||||
$this->id_product_attribute = (int)Tools::getValue('id_product_attribute');
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
@@ -63,8 +65,7 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
|
||||
if (!Validate::isLoadedObject($product))
|
||||
die('0');
|
||||
|
||||
$mailAlert = MailAlert::getMailAlert((int)Context::getContext()->customer->id, (int)$product->id);
|
||||
if ($mailAlert && $mailAlert->delete())
|
||||
if (MailAlert::deleteAlert((int)Context::getContext()->customer->id, (int)Context::getContext()->customer->email, (int)$product->id, (int)$this->id_product_attribute))
|
||||
die('0');
|
||||
die(1);
|
||||
}
|
||||
|
||||
@@ -29,14 +29,18 @@ $('document').ready(function()
|
||||
{
|
||||
$('img[rel^=ajax_id_mailalert_]').click(function()
|
||||
{
|
||||
var idMailAlert = $(this).attr('rel').replace('ajax_id_mailalert_', '');
|
||||
var ids = $(this).attr('rel').replace('ajax_id_mailalert_', '');
|
||||
ids = ids.split('_');
|
||||
var id_product_mail_alert = ids[0];
|
||||
var id_product_attribute_mail_alert = ids[1];
|
||||
var parent = $(this).parent().parent();
|
||||
|
||||
$.ajax({
|
||||
url: "{$link->getModuleLink('mailalerts', 'actions', ['process' => 'remove'])}",
|
||||
type: "POST",
|
||||
data: {
|
||||
'id_product': idMailAlert
|
||||
'id_product': id_product_mail_alert,
|
||||
'id_product_attribute': id_product_attribute_mail_alert
|
||||
},
|
||||
success: function(result)
|
||||
{
|
||||
@@ -67,7 +71,7 @@ $('document').ready(function()
|
||||
<div class="product_desc">{$mailAlert.attributes_small|escape:'htmlall':'UTF-8'}</div>
|
||||
|
||||
<div class="remove">
|
||||
<img rel="ajax_id_mailalert_{$mailAlert.id_product}" src="{$img_dir}icon/delete.gif" alt="" class="icon" />
|
||||
<img rel="ajax_id_mailalert_{$mailAlert.id_product}_{$mailAlert.id_product_attribute}" src="{$img_dir}icon/delete.gif" alt="" class="icon" />
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
|
||||
Reference in New Issue
Block a user