// Changes and fixes to specific prices creation

This commit is contained in:
tDidierjean
2012-02-15 16:16:10 +00:00
parent 10364a2759
commit 7895a7f533
3 changed files with 43 additions and 22 deletions
@@ -226,7 +226,8 @@ jQuery(document).ready(Customer.init);
{l s='You can set specific prices for clients belonging to different groups, different countries...'}
</div>
<br />
<a class="button bt-icon" href="#" onclick="$('#add_specific_price').slideToggle();return false;"><img src="../img/admin/add.gif" alt="" /><span>{l s='Add a new specific price'}</span></a>
<a class="button bt-icon" href="#" id="show_specific_price"><img src="../img/admin/add.gif" alt="" /><span>{l s='Add a new specific price'}</span></a>
<a class="button bt-icon" href="#" id="hide_specific_price" style="display:none"><img src="../img/admin/cross.png" alt=""/><span>{l s='Cancel new specific price'}</span></a>
<br/>
<script type="text/javascript">
var product_prices = new Array();
@@ -348,10 +349,6 @@ jQuery(document).ready(Customer.init);
</select>
{l s='(if set to "amount", the tax is included)'}
</div>
<div class="margin-form">
<input type="submit" name="submitPriceAddition" value="{l s='Add'}" class="button" />
</div>
</div>
<table style="text-align: center;width:100%" class="table" cellpadding="0" cellspacing="0">
+15 -17
View File
@@ -694,6 +694,11 @@ class AdminProductsControllerCore extends AdminController
$this->errors[] = Tools::displayError('Product must be created before adding features.');
}
/**
* This function is never called at the moment (specific prices cannot be edited)
*
* @param $token
*/
public function processPricesModification($token)
{
$id_specific_prices = Tools::getValue('spm_id_specific_price');
@@ -734,6 +739,10 @@ class AdminProductsControllerCore extends AdminController
public function processPriceAddition($token)
{
// Check if a specific price has been submitted
if (!Tools::getIsset('submitPriceAddition'))
return;
$id_product = Tools::getValue('id_product');
$id_product_attribute = Tools::getValue('sp_id_product_attribute');
$id_shop = Tools::getValue('sp_id_shop');
@@ -765,8 +774,6 @@ class AdminProductsControllerCore extends AdminController
$specificPrice->to = !$to ? '0000-00-00 00:00:00' : $to;
if (!$specificPrice->add())
$this->errors = Tools::displayError('An error occurred while updating the specific price.');
else
$this->redirect_after = self::$currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&id_product='.$id_product.'&add'.$this->table.'&action=Prices&conf=3&token='.($token ? $token : $this->token);
}
}
@@ -800,8 +807,6 @@ class AdminProductsControllerCore extends AdminController
}
elseif (!SpecificPrice::setSpecificPriority((int)$obj->id, $priorities))
$this->errors[] = Tools::displayError('An error occurred while setting priorities.');
else
$this->confirmations[] = $this->l('Price priorities successfully updated');
}
public function processCustomizationConfiguration($token)
@@ -927,7 +932,7 @@ class AdminProductsControllerCore extends AdminController
else
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
// Product specific prices management
// Product specific prices management NEVER USED
elseif (Tools::isSubmit('submitPricesModification'))
{
if ($this->tabAccess['add'] === '1')
@@ -935,13 +940,6 @@ class AdminProductsControllerCore extends AdminController
else
$this->errors[] = Tools::displayError('You do not have permission to add here.');
}
elseif (Tools::isSubmit('submitPriceAddition'))
{
if ($this->tabAccess['add'] === '1')
$this->action = 'priceAddition';
else
$this->errors[] = Tools::displayError('You do not have permission to add here.');
}
elseif (Tools::isSubmit('deleteSpecificPrice'))
{
if ($this->tabAccess['delete'] === '1')
@@ -1480,6 +1478,8 @@ class AdminProductsControllerCore extends AdminController
$this->processWarehouses($token);
$this->processFeatures($token);
$this->processProductAttribute($token);
$this->processPriceAddition($token);
$this->processSpecificPricePriorities($token);
if (!$this->updatePackItems($object))
$this->errors[] = Tools::displayError('An error occurred while adding products to the pack.');
@@ -2847,7 +2847,9 @@ class AdminProductsControllerCore extends AdminController
// Not use id_customer
if ($specific_price_priorities[0] == 'id_customer')
unset($specific_price_priorities[0]);
sort($specific_price_priorities);
// Reindex array starting from 0
$specific_price_priorities = array_values($specific_price_priorities);
$content .= '
<div class="separation"></div>
<h4>'.$this->l('Priorities management').'</h4>
@@ -2889,10 +2891,6 @@ class AdminProductsControllerCore extends AdminController
<div class="margin-form">
<input type="checkbox" name="specificPricePriorityToAll" id="specificPricePriorityToAll" /> <label class="t" for="specificPricePriorityToAll">'.$this->l('Apply to all products').'</label>
</div>
<div class="margin-form">
<input class="button" type="submit" name="submitSpecificPricePriorities" value="'.$this->l('Apply').'" />
</div>
';
return $content;
}
+26
View File
@@ -344,6 +344,30 @@ function enableProductName()
$('.copy2friendlyUrl').removeAttr('disabled');
}
function toggleSpecificPrice()
{
$('#show_specific_price').click(function()
{
$('#add_specific_price').slideToggle();
$('#add_specific_price').append('<input type="hidden" name="submitPriceAddition"/>');
$('#hide_specific_price').show();
$('#show_specific_price').hide();
return false;
});
$('#hide_specific_price').click(function()
{
$('#add_specific_price').slideToggle();
$('#add_specific_price').find('input[name=submitPriceAddition]').remove();
$('#hide_specific_price').hide();
$('#show_specific_price').show();
return false;
});
}
/**
* Execute a callback function when a specific tab has finished loading or right now if the tab is already loaded
*
@@ -377,4 +401,6 @@ $(document).ready(function() {
// Enable writing of the product name when the friendly url field in tab SEO is loaded
onTabLoad('Seo', enableProductName);
onTabLoad('Prices', toggleSpecificPrice);
});