[-] BO : fix bug #PSFV-839 - Reset products features while editing products

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14640 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2012-04-13 16:03:05 +00:00
parent 235fb68255
commit 2db490b3c2
17 changed files with 84 additions and 36 deletions
@@ -25,7 +25,7 @@
*}
{if isset($product->id)}
<input type="hidden" name="submitted_tabs[]" value="Accounting" />
<h4>{l s='Accounting'}</h4>
<div class="separation"></div>
{if !empty($error)}
@@ -24,6 +24,7 @@
* International Registered Trademark & Property of PrestaShop SA
*}
<input type="hidden" name="submitted_tabs[]" value="Associations" />
<div class="Associations">
<h4>{l s='Associations'}</h4>
<div class="separation"></div>
@@ -25,7 +25,7 @@
*}
{if isset($obj->id)}
<input type="hidden" name="submitted_tabs[]" value="Attachments" />
<h4>{l s='Attachment'}</h4>
<div class="separation"></div>
<fieldset style="border:none;">
@@ -38,6 +38,7 @@
</script>
{if isset($product->id)}
<input type="hidden" name="submitted_tabs[]" value="Combinations" />
<script type="text/javascript">
var attrs = new Array();
var modifyattributegroup = "{l s='Modify this attribute combination' js=1}";
@@ -25,6 +25,7 @@
*}
{if isset($obj->id)}
<input type="hidden" name="submitted_tabs[]" value="Customization" />
<h4>{l s='Add or modify customizable properties'}</h4>
<div class="separation"></div><br />
@@ -25,7 +25,7 @@
*}
{if isset($product->id)}
<input type="hidden" name="submitted_tabs[]" value="Features" />
<h4>{l s='Assign features to this product:'}</h4>
<div class="separation"></div>
<ul>
@@ -25,6 +25,7 @@
*}
{if isset($id_product) && isset($product)}
<input type="hidden" name="submitted_tabs[]" value="Images" />
<h4 class="tab" >2. {l s='Images'} (<span id="countImage">{$countImages}</span>)</h4>
<h4>{if isset($id_image)}{l s='Edit this product image'}{else}{l s='Add a new image to this product'}{/if}</h4> <div class="separation"></div><br />
@@ -24,6 +24,7 @@
* International Registered Trademark & Property of PrestaShop SA
*}
<input type="hidden" name="submitted_tabs[]" value="Informations" />
<div id="step1">
<h4 class="tab">1. {l s='Info.'}</h4>
<h4>{l s='Product global information'}</h4>
@@ -28,7 +28,7 @@
var msg_select_one = '{l s='Please select at least one product.' js=1}';
var msg_set_quantity = '{l s='Please set a quantity to add a product.' js=1}';
</script>
<input type="hidden" name="submitted_tabs[]" value="Pack" />
<h4>{l s='Pack'}</h4>
<div class="separation"></div>
@@ -101,7 +101,7 @@ jQuery(document).ready(Customer.init);
</script>
{* END CUSTOMER AUTO-COMPLETE / TO REFACTO *}
<input type="hidden" name="submitted_tabs[]" value="Prices" />
<h4>{l s='Product price'}</h4>
<div class="hint" style="display:block;min-height:0;">
{l s='You must enter either the pre-tax retail price, or the retail price with tax. The input field will be automatically calculated.'}
@@ -25,7 +25,7 @@
*}
{if isset($product->id)}
<input type="hidden" name="submitted_tabs[]" value="Quantities" />
<h4>{l s='Available quantities for sale'}</h4>
<div class="separation"></div>
<div class="hint" style="display:block; position:'auto';">
@@ -24,6 +24,7 @@
* International Registered Trademark & Property of PrestaShop SA
*}
<input type="hidden" name="submitted_tabs[]" value="Seo" />
<h4>{l s='SEO'}</h4>
<div class="separation"></div>
@@ -24,6 +24,7 @@
* International Registered Trademark & Property of PrestaShop SA
*}
<input type="hidden" name="submitted_tabs[]" value="Shipping" />
<h4 class="tab">1. {l s='Info.'}</h4>
<h4>{l s='Shipping'}</h4>
@@ -26,7 +26,7 @@
<input type="hidden" name="supplier_loaded" value="1">
{if isset($product->id)}
<input type="hidden" name="submitted_tabs[]" value="Suppliers" />
<h4>{l s='Suppliers of the current product'}</h4>
<div class="separation"></div>
<div class="hint" style="display:block; position:'auto';">
@@ -101,6 +101,7 @@
</script>
<input type="hidden" name="submitted_tabs[]" value="VirtualProduct" />
<h4>{l s='Virtual Product (services, booking and downloadable products)'}</h4>
<div class="separation"></div>
<div>
@@ -26,7 +26,7 @@
<input type="hidden" name="warehouse_loaded" value="1">
{if isset($product->id)}
<input type="hidden" name="submitted_tabs[]" value="Warehouses" />
<h4>{l s='Product location in warehouses'}</h4>
<div class="separation"></div>
<div class="hint" style="display:block; position:'auto';">
+68 -28
View File
@@ -70,6 +70,8 @@ class AdminProductsControllerCore extends AdminController
protected $position_identifier = 'id_product';
protected $submitted_tabs;
public function __construct()
{
$this->table = 'product';
@@ -1459,7 +1461,7 @@ class AdminProductsControllerCore extends AdminController
$this->updateDownloadProduct($this->object);
$this->object->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group'), true);
if (!count($this->errors))
if (empty($this->errors))
{
$languages = Language::getLanguages(false);
if (!$this->object->updateCategories(Tools::getValue('categoryBox')))
@@ -1511,16 +1513,33 @@ class AdminProductsControllerCore extends AdminController
}
else
$this->object->delete();
// if errors : stay on edit page
$this->display = 'edit';
}
else
$this->errors[] = Tools::displayError('An error occurred while creating object.').' <b>'.$this->table.'</b>';
}
protected function isTabSubmitted($tab_name)
{
if (!is_array($this->submitted_tabs))
$this->submitted_tabs = Tools::getValue('submitted_tabs');
if (is_array($this->submitted_tabs) && in_array($tab_name, $this->submitted_tabs))
return true;
return false;
}
public function processUpdate()
{
$this->checkProduct();
if (!empty($this->errors))
{
//$this->display = 'edit';
return false;
}
$id = (int)Tools::getValue('id_'.$this->table);
/* Update an existing product */
@@ -1537,27 +1556,43 @@ class AdminProductsControllerCore extends AdminController
if ($object->update())
{
$this->addCarriers();
$this->updateAccessories($object);
if ($this->isTabSubmitted('Shipping'))
$this->addCarriers();
if ($this->isTabSubmitted('Associations'))
{
$this->updateAccessories($object);
$this->updateAssoShop((int)$object->id);
}
if ($this->isTabSubmitted('Accounting'))
$this->processAccounting();
if ($this->isTabSubmitted('Suppliers'))
$this->processSuppliers();
if ($this->isTabSubmitted('Warehouses'))
$this->processWarehouses();
if ($this->isTabSubmitted('Features'))
$this->processFeatures();
if ($this->isTabSubmitted('Combinations'))
$this->processProductAttribute();
if ($this->isTabSubmitted('Prices'))
{
$this->processPriceAddition();
$this->processSpecificPricePriorities();
$this->object->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group'));
}
if ($this->isTabSubmitted('Customization'))
$this->processCustomizationConfiguration();
if ($this->isTabSubmitted('Attachments'))
$this->processAttachments();
$this->updatePackItems($object);
$this->updateDownloadProduct($object, 1);
$this->updateAssoShop((int)$object->id);
$this->processAccounting();
$this->processSuppliers();
$this->processWarehouses();
$this->processFeatures();
$this->processProductAttribute();
$this->processPriceAddition();
$this->processSpecificPricePriorities();
$this->processCustomizationConfiguration();
$this->object->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group'));
$this->processAttachments();
if (!$this->updatePackItems($object))
$this->errors[] = Tools::displayError('An error occurred while adding products to the pack.');
elseif (!$object->updateCategories(Tools::getValue('categoryBox'), true))
$this->updateTags(Language::getLanguages(false), $object);
if (!$object->updateCategories(Tools::getValue('categoryBox'), true))
$this->errors[] = Tools::displayError('An error occurred while linking object.').' <b>'.$this->table.'</b> '.Tools::displayError('To categories');
elseif (!$this->updateTags(Language::getLanguages(false), $object))
$this->errors[] = Tools::displayError('An error occurred while adding tags.');
elseif (empty($this->errors))
if (empty($this->errors))
{
if (in_array($object->visibility, array('both', 'search')))
Search::indexation(false, $object->id);
@@ -1589,6 +1624,9 @@ class AdminProductsControllerCore extends AdminController
$this->redirect_after = self::$currentIndex.(Tools::getIsset('id_category') ? '&id_category='.(int)Tools::getValue('id_category') : '').'&conf=4&token='.$this->token;
}
}
// if errors : stay on edit page
else
$this->display = 'edit';
}
else
$this->errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b> ('.Db::getInstance()->getMsgError().')';
@@ -1742,7 +1780,8 @@ class AdminProductsControllerCore extends AdminController
}
if (Tools::getValue('virtual_product_expiration_date') && !Validate::isDate(Tools::getValue('virtual_product_expiration_date') && !empty($is_virtual_file))
&& Tools::getValue('virtual_product_expiration_date_attribute') && !Validate::isDate(Tools::getValue('virtual_product_expiration_date_attribute')))
&& Tools::getValue('virtual_product_expiration_date_attribute') && !Validate::isDate(Tools::getValue('virtual_product_expiration_date_attribute'))
)
{
if (!Tools::getValue('virtual_product_expiration_date'))
{
@@ -1881,15 +1920,17 @@ class AdminProductsControllerCore extends AdminController
*/
public function updateTags($languages, $product)
{
$tagError = true;
$tag_success = true;
/* Reset all tags for THIS product */
if (!Tag::deleteTagsForProduct((int)$product->id))
return false;
$this->errors[] = Tools::displayError('An error occurred while deleting previous tags.');
/* Assign tags to this product */
foreach ($languages as $language)
if ($value = Tools::getValue('tags_'.$language['id_lang']))
$tagError &= Tag::addTags($language['id_lang'], (int)$product->id, $value);
return $tagError;
$tag_success &= Tag::addTags($language['id_lang'], (int)$product->id, $value);
if (!$tag_success)
$this->errors[] = Tools::displayError('An error occurred while adding tags.');
}
public function initContent($token = null)
@@ -2132,7 +2173,7 @@ class AdminProductsControllerCore extends AdminController
{
parent::initToolbarTitle();
if ($product = $this->loadObject(true))
if ((bool)$product->id)
if ((bool)$product->id && $this->display != 'list')
$this->toolbar_title[2] = $this->toolbar_title[2].' ('.$product->name[$this->context->language->id].')';
}
@@ -3959,11 +4000,10 @@ class AdminProductsControllerCore extends AdminController
if ($qty > 0 && isset($item_id))
{
if (!Pack::addItem((int)$product->id, (int)$item_id, (int)$qty))
return false;
$this->errors[] = Tools::displayError('An error occurred while adding products to the pack.');
}
}
}
return true;
}
public function getL($key)