// Changes and fixes to specific prices creation
This commit is contained in:
@@ -226,7 +226,8 @@ jQuery(document).ready(Customer.init);
|
|||||||
{l s='You can set specific prices for clients belonging to different groups, different countries...'}
|
{l s='You can set specific prices for clients belonging to different groups, different countries...'}
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<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/>
|
<br/>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var product_prices = new Array();
|
var product_prices = new Array();
|
||||||
@@ -348,10 +349,6 @@ jQuery(document).ready(Customer.init);
|
|||||||
</select>
|
</select>
|
||||||
{l s='(if set to "amount", the tax is included)'}
|
{l s='(if set to "amount", the tax is included)'}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="margin-form">
|
|
||||||
<input type="submit" name="submitPriceAddition" value="{l s='Add'}" class="button" />
|
|
||||||
</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">
|
||||||
|
|||||||
@@ -694,6 +694,11 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
$this->errors[] = Tools::displayError('Product must be created before adding features.');
|
$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)
|
public function processPricesModification($token)
|
||||||
{
|
{
|
||||||
$id_specific_prices = Tools::getValue('spm_id_specific_price');
|
$id_specific_prices = Tools::getValue('spm_id_specific_price');
|
||||||
@@ -734,6 +739,10 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
|
|
||||||
public function processPriceAddition($token)
|
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 = Tools::getValue('id_product');
|
||||||
$id_product_attribute = Tools::getValue('sp_id_product_attribute');
|
$id_product_attribute = Tools::getValue('sp_id_product_attribute');
|
||||||
$id_shop = Tools::getValue('sp_id_shop');
|
$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;
|
$specificPrice->to = !$to ? '0000-00-00 00:00:00' : $to;
|
||||||
if (!$specificPrice->add())
|
if (!$specificPrice->add())
|
||||||
$this->errors = Tools::displayError('An error occurred while updating the specific price.');
|
$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))
|
elseif (!SpecificPrice::setSpecificPriority((int)$obj->id, $priorities))
|
||||||
$this->errors[] = Tools::displayError('An error occurred while setting priorities.');
|
$this->errors[] = Tools::displayError('An error occurred while setting priorities.');
|
||||||
else
|
|
||||||
$this->confirmations[] = $this->l('Price priorities successfully updated');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processCustomizationConfiguration($token)
|
public function processCustomizationConfiguration($token)
|
||||||
@@ -927,7 +932,7 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
|
$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'))
|
elseif (Tools::isSubmit('submitPricesModification'))
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['add'] === '1')
|
if ($this->tabAccess['add'] === '1')
|
||||||
@@ -935,13 +940,6 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
$this->errors[] = Tools::displayError('You do not have permission to add here.');
|
$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'))
|
elseif (Tools::isSubmit('deleteSpecificPrice'))
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['delete'] === '1')
|
if ($this->tabAccess['delete'] === '1')
|
||||||
@@ -1480,6 +1478,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
$this->processWarehouses($token);
|
$this->processWarehouses($token);
|
||||||
$this->processFeatures($token);
|
$this->processFeatures($token);
|
||||||
$this->processProductAttribute($token);
|
$this->processProductAttribute($token);
|
||||||
|
$this->processPriceAddition($token);
|
||||||
|
$this->processSpecificPricePriorities($token);
|
||||||
|
|
||||||
if (!$this->updatePackItems($object))
|
if (!$this->updatePackItems($object))
|
||||||
$this->errors[] = Tools::displayError('An error occurred while adding products to the pack.');
|
$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
|
// Not use id_customer
|
||||||
if ($specific_price_priorities[0] == 'id_customer')
|
if ($specific_price_priorities[0] == 'id_customer')
|
||||||
unset($specific_price_priorities[0]);
|
unset($specific_price_priorities[0]);
|
||||||
sort($specific_price_priorities);
|
// Reindex array starting from 0
|
||||||
|
$specific_price_priorities = array_values($specific_price_priorities);
|
||||||
|
|
||||||
$content .= '
|
$content .= '
|
||||||
<div class="separation"></div>
|
<div class="separation"></div>
|
||||||
<h4>'.$this->l('Priorities management').'</h4>
|
<h4>'.$this->l('Priorities management').'</h4>
|
||||||
@@ -2889,10 +2891,6 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
<input type="checkbox" name="specificPricePriorityToAll" id="specificPricePriorityToAll" /> <label class="t" for="specificPricePriorityToAll">'.$this->l('Apply to all products').'</label>
|
<input type="checkbox" name="specificPricePriorityToAll" id="specificPricePriorityToAll" /> <label class="t" for="specificPricePriorityToAll">'.$this->l('Apply to all products').'</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="margin-form">
|
|
||||||
<input class="button" type="submit" name="submitSpecificPricePriorities" value="'.$this->l('Apply').'" />
|
|
||||||
</div>
|
|
||||||
';
|
';
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,6 +344,30 @@ function enableProductName()
|
|||||||
$('.copy2friendlyUrl').removeAttr('disabled');
|
$('.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
|
* 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
|
// Enable writing of the product name when the friendly url field in tab SEO is loaded
|
||||||
onTabLoad('Seo', enableProductName);
|
onTabLoad('Seo', enableProductName);
|
||||||
|
|
||||||
|
onTabLoad('Prices', toggleSpecificPrice);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user