// Upgrade specific price deletion
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13378 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -351,7 +351,7 @@ jQuery(document).ready(Customer.init);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table style="text-align: center;width:100%" class="table" cellpadding="0" cellspacing="0">
|
<table style="text-align: center;width:100%" class="table" cellpadding="0" cellspacing="0" id="specific_prices_list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="cell border" style="width: 12%;">{l s='Rule'}</th>
|
<th class="cell border" style="width: 12%;">{l s='Rule'}</th>
|
||||||
|
|||||||
@@ -777,19 +777,35 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processDeleteSpecificPrice($token)
|
public function ajaxProcessDeleteSpecificPrice()
|
||||||
{
|
{
|
||||||
if (!($obj = $this->loadObject()))
|
if ($this->tabAccess['delete'] === '1')
|
||||||
return;
|
|
||||||
$id_specific_price = (int)Tools::getValue('id_specific_price');
|
|
||||||
if (!$id_specific_price || !Validate::isUnsignedId($id_specific_price))
|
|
||||||
$this->errors[] = Tools::displayError('Invalid specific price ID');
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
$specificPrice = new SpecificPrice((int)$id_specific_price);
|
$id_specific_price = (int)Tools::getValue('id_specific_price');
|
||||||
if (!$specificPrice->delete())
|
if (!$id_specific_price || !Validate::isUnsignedId($id_specific_price))
|
||||||
$this->errors[] = Tools::displayError('An error occurred while deleting the specific price');
|
$error = Tools::displayError('Invalid specific price ID');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$specificPrice = new SpecificPrice((int)$id_specific_price);
|
||||||
|
if (!$specificPrice->delete())
|
||||||
|
$error = Tools::displayError('An error occurred while deleting the specific price');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
$error = Tools::displayError('You do not have permission to delete here.');
|
||||||
|
|
||||||
|
if (isset($error))
|
||||||
|
$json = array(
|
||||||
|
'status' => 'error',
|
||||||
|
'message'=> $error
|
||||||
|
);
|
||||||
|
else
|
||||||
|
$json = array(
|
||||||
|
'status' => 'ok',
|
||||||
|
'message'=> $this->_conf[1]
|
||||||
|
);
|
||||||
|
|
||||||
|
die(Tools::jsonEncode($json));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processSpecificPricePriorities($token)
|
public function processSpecificPricePriorities($token)
|
||||||
@@ -2815,7 +2831,7 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
<td class="cell border">'.$period.'</td>
|
<td class="cell border">'.$period.'</td>
|
||||||
<td class="cell border">'.$specific_price['from_quantity'].'</th>
|
<td class="cell border">'.$specific_price['from_quantity'].'</th>
|
||||||
<td class="cell border"><b>'.Tools::displayPrice(Tools::ps_round((float)($this->_getFinalPrice($specific_price, (float)($obj->price), $taxRate)), 2), $current_specific_currency).'</b></td>
|
<td class="cell border"><b>'.Tools::displayPrice(Tools::ps_round((float)($this->_getFinalPrice($specific_price, (float)($obj->price), $taxRate)), 2), $current_specific_currency).'</b></td>
|
||||||
<td class="cell border">'.(!$rule->id ? '<a href="'.self::$currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&id_product='.(int)(Tools::getValue('id_product')).'&updateproduct&deleteSpecificPrice&action=Prices&id_specific_price='.(int)($specific_price['id_specific_price']).'&token='.Tools::getValue('token').'"><img src="../img/admin/delete.gif" alt="'.$this->l('Delete').'" /></a>': '').'</td>
|
<td class="cell border">'.(!$rule->id ? '<a name="delete_link" href="'.self::$currentIndex.'&id_product='.(int)(Tools::getValue('id_product')).'&action=deleteSpecificPrice&id_specific_price='.(int)($specific_price['id_specific_price']).'&token='.Tools::getValue('token').'"><img src="../img/admin/delete.gif" alt="'.$this->l('Delete').'" /></a>': '').'</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
$i++;
|
$i++;
|
||||||
unset($customer_full_name);
|
unset($customer_full_name);
|
||||||
|
|||||||
@@ -368,6 +368,36 @@ function toggleSpecificPrice()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajax call to delete a specific price
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @param token
|
||||||
|
* @param parent
|
||||||
|
*/
|
||||||
|
function deleteSpecificPrice(url, parent)
|
||||||
|
{
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
data: {
|
||||||
|
ajax: true
|
||||||
|
},
|
||||||
|
context: document.body,
|
||||||
|
dataType: 'json',
|
||||||
|
context: this,
|
||||||
|
async: false,
|
||||||
|
success: function(data) {
|
||||||
|
if (data.status == 'ok')
|
||||||
|
{
|
||||||
|
showSuccessMessage(data.message);
|
||||||
|
parent.remove();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
showErrorMessage(data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a callback function when a specific tab has finished loading or right now if the tab is already loaded
|
* Execute a callback function when a specific tab has finished loading or right now if the tab is already loaded
|
||||||
*
|
*
|
||||||
@@ -402,5 +432,14 @@ $(document).ready(function() {
|
|||||||
// Enable writing of the product name when the friendly url field in tab SEO is loaded
|
// Enable writing of the product name when the friendly url field in tab SEO is loaded
|
||||||
onTabLoad('Seo', enableProductName);
|
onTabLoad('Seo', enableProductName);
|
||||||
|
|
||||||
|
// Bind to show/hide new specific price form
|
||||||
onTabLoad('Prices', toggleSpecificPrice);
|
onTabLoad('Prices', toggleSpecificPrice);
|
||||||
|
|
||||||
|
// Bind to delete specific price link
|
||||||
|
onTabLoad('Prices', function(){
|
||||||
|
$('#specific_prices_list').delegate('a[name="delete_link"]', 'click', function(){
|
||||||
|
deleteSpecificPrice(this.href, $(this).parents('tr'));
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user