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