From da02f290b7b3b93ffaf1ae91c9405d6585d90f69 Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Tue, 8 Nov 2011 10:09:57 +0000 Subject: [PATCH] [*] BO : #PSFV-94 - added AdminAttributeGeneratorController --- admin-dev/tabs/AdminAttributeGenerator.php | 319 ------------------ admin-dev/themes/default/admin.css | 1 + .../themes/default/process-icon-back.png | Bin 0 -> 2342 bytes .../template/attribute_generator/content.tpl | 146 ++++++++ .../themes/template/products/combinations.tpl | 2 +- classes/Product.php | 2 +- .../AdminAttributeGeneratorController.php | 224 ++++++++++++ controllers/admin/AdminProductsController.php | 23 +- install-dev/sql/db_settings_lite.sql | 24 +- install-dev/sql/upgrade/1.5.0.1.sql | 2 + 10 files changed, 401 insertions(+), 342 deletions(-) delete mode 100644 admin-dev/tabs/AdminAttributeGenerator.php create mode 100644 admin-dev/themes/default/process-icon-back.png create mode 100644 admin-dev/themes/template/attribute_generator/content.tpl create mode 100644 controllers/admin/AdminAttributeGeneratorController.php diff --git a/admin-dev/tabs/AdminAttributeGenerator.php b/admin-dev/tabs/AdminAttributeGenerator.php deleted file mode 100644 index c89c38f9c..000000000 --- a/admin-dev/tabs/AdminAttributeGenerator.php +++ /dev/null @@ -1,319 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -@ini_set('max_execution_time', 3600); -include_once(_PS_ADMIN_DIR_.'/../classes/AdminTab.php'); - -class AdminAttributeGenerator extends AdminTab -{ - private $combinations = array(); - private $product; - - private function addAttribute($arr, $price = 0, $weight = 0) - { - foreach ($arr AS $attr) - { - $price += (float)($_POST['price_impact_'.(int)($attr)]); - $weight += (float)($_POST['weight_impact'][(int)($attr)]); - } - if ($this->product->id) - { - return (array( - 'id_product' => (int)($this->product->id), - 'price' => (float)($price), - 'weight' => (float)($weight), - 'ecotax' => 0, - 'quantity' => (int)($_POST['quantity']), - 'reference' => pSQL($_POST['reference']), - 'default_on' => 0)); - } - return array(); - } - - static private function createCombinations($list) - { - if (sizeof($list) <= 1) - return sizeof($list) ? array_map(create_function('$v', 'return (array($v));'), $list[0]) : $list; - $res = array(); - $first = array_pop($list); - foreach ($first AS $attribute) - { - $tab = self::createCombinations($list); - foreach ($tab AS $toAdd) - $res[] = is_array($toAdd) ? array_merge($toAdd, array($attribute)) : array($toAdd, $attribute); - } - return $res; - } - - public function postProcess() - { - $this->product = new Product((int)(Tools::getValue('id_product'))); - - if (isset($_POST['generate'])) - { - if (!is_array(Tools::getValue('options'))) - $this->_errors[] = Tools::displayError('Please choose at least 1 attribute.'); - else - { - $tab = array_values($_POST['options']); - if (sizeof($tab) AND Validate::isLoadedObject($this->product)) - { - self::setAttributesImpacts($this->product->id, $tab); - $this->combinations = array_values(self::createCombinations($tab)); - $values = array_values(array_map(array($this, 'addAttribute'), $this->combinations)); - $this->product->deleteProductAttributes(); - $res = $this->product->addProductAttributeMultiple($values); - $this->product->addAttributeCombinationMultiple($res, $this->combinations); - $this->product->updateQuantityProductWithAttributeQuantity(); - } - else - $this->_errors[] = Tools::displayError('Unable to initialize parameters, combination is missing or object cannot be loaded.'); - } - } - elseif (isset($_POST['back'])) - Tools::redirectAdmin(self::$currentIndex.'&id_product='.(int)(Tools::getValue('id_product')).'&id_category='.(int)(Tools::getValue('id_category')).'&addproduct'.'&tabs=3&token='.Tools::getValue('token')); - parent::postProcess(); - } - - private static function displayAndReturnAttributeJs() - { - $attributes = Attribute::getAttributes(Context::getContext()->language->id, true); - $attributeJs = array(); - foreach ($attributes AS $k => $attribute) - $attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; - echo ' - '; - return $attributeJs; - } - - private function displayGroupSelect($attributeJs, $attributesGroups) - { - echo '
- -
'; - } - - private static function setAttributesImpacts($id_product, $tab) - { - $attributes = array(); - foreach ($tab AS $group) - foreach ($group AS $attribute) - $attributes[] = '('.(int)($id_product).', '.(int)($attribute).', '.(float)($_POST['price_impact_'.(int)($attribute)]).', '.(float)($_POST['weight_impact'][(int)($attribute)]).')'; - return Db::getInstance()->execute( - 'INSERT INTO `'._DB_PREFIX_.'attribute_impact` (`id_product`, `id_attribute`, `price`, `weight`) - VALUES '.implode(',', $attributes).' - ON DUPLICATE KEY UPDATE `price`=VALUES(price), `weight`=VALUES(weight)' - ); - } - - private static function getAttributesImpacts($id_product) - { - $tab = array(); - $result = Db::getInstance()->executeS( - 'SELECT ai.`id_attribute`, ai.`price`, ai.`weight` - FROM `'._DB_PREFIX_.'attribute_impact` ai - WHERE ai.`id_product` = '.(int)($id_product)); - if (!$result) - return array(); - foreach ($result AS $impact) - { - $tab[$impact['id_attribute']]['price'] = (float)($impact['price']); - $tab[$impact['id_attribute']]['weight'] = (float)($impact['weight']); - } - return $tab; - } - - private function displayGroupeTable($attributeJs, $attributesGroups) - { - - $combinationsGroups = $this->product->getAttributesGroups($this->context->language->id); - $attributes = array(); - $impacts = self::getAttributesImpacts($this->product->id); - foreach ($combinationsGroups AS &$combination) - { - $target = &$attributes[$combination['id_attribute_group']][$combination['id_attribute']]; - $target = $combination; - if (isset($impacts[$combination['id_attribute']])) - { - $target['price'] = $impacts[$combination['id_attribute']]['price']; - $target['weight'] = $impacts[$combination['id_attribute']]['weight']; - } - } - - foreach ($attributesGroups AS $k => $attributeGroup) - { - $idGroup = $attributeGroup['id_attribute_group']; - if (isset($attributeJs[$idGroup])) - { - echo ' -
- - - - - - - - - - - '; - if (isset($attributes[$idGroup])) - foreach ($attributes[$idGroup] AS $k => $attribute) - echo ''; - } - } - } - - public function displayForm($isMainTab = true) - { - if (!Combination::isFeatureActive()) - { - $this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' '.$this->l('Performances').''); - return; - } - - parent::displayForm(); - - $jsAttributes = self::displayAndReturnAttributeJs(); - $attributesGroups = AttributeGroup::getAttributesGroups($this->context->language->id); - $this->product = new Product((int)(Tools::getValue('id_product'))); - - // JS Init - echo - ''; - - - - if (isset($_POST['generate']) AND !sizeof($this->_errors)) - echo ' -
- - '.sizeof($this->combinations).' '.$this->l('product(s) successfully created.').' -
'; - echo ' - -
-
'.$this->l('Attributes generator').''. - $this->l('Add or modify attributes for product:').' '.$this->product->name[$this->context->language->id].' -

- '; - echo ' -
-
- -
- -
- -
- -
-
-
-
- -
-
-
'; - self::displayGroupeTable($jsAttributes, $attributesGroups); - echo ' -
-
-
- '; - self::displayGroupSelect($jsAttributes, $attributesGroups); - echo ' -
-

- -
- -

-
-
-
-
-
'; - } -} \ No newline at end of file diff --git a/admin-dev/themes/default/admin.css b/admin-dev/themes/default/admin.css index fafb844fe..b5dcf6099 100644 --- a/admin-dev/themes/default/admin.css +++ b/admin-dev/themes/default/admin.css @@ -156,6 +156,7 @@ a.module_toggle_all{color: #268CCD;} .toolbarBox .process-icon-save { background-image: url(process-icon-save.png);} .toolbarBox .process-icon-save-and-stay { background-image: url(process-icon-save-and-stay.png);} .toolbarBox .process-icon-edit { background-image: url(process-icon-edit.png);} +.toolbarBox .process-icon-back { background-image: url(process-icon-back.png);} /*leadin*/ .leadin { padding:10px;} diff --git a/admin-dev/themes/default/process-icon-back.png b/admin-dev/themes/default/process-icon-back.png new file mode 100644 index 0000000000000000000000000000000000000000..3cfadb3e2b64c0d26a9ab178241d0fde5f77bea8 GIT binary patch literal 2342 zcmaJ@dpuO@8Xh~@$hCArZLLPp4s*pY8JX)bg5}+yQ_At(Ur7kDxLF3o%Q>z^?mR6d!FZgzW06qSSjlR{%&e) zYYchFhV3;76^4ug>MMOrot=CwvHVzGH31Z)K(xdH-wwC)NV;BpA?5I296 zzlaP*aed>&U|?JTlO4xndvf4wya6vcUMs){Ar>I#M++o)IRXAj7q8vxj*)QS69nQB z;Ga!}`mYDbLNN%qAy6)ClsgJ=MQ~ z=4`_=D6}uRv=IRw1wkS_5-F3(5Hc)6D2_y;Jv}{j8W@a=7U3d^6+kSxi$G#Ot3UxI zY%x~^afJdvr^wnWltKi!*6HUf@I_x`1(Gji(iRLUXNiz#1WI?MS)jlF|A+GVU(phX z0shzTH-#n4SP_V1fD)lp%+@w;o4qcT2u~J+EJ!G33Wd?LRa_q>goKhPp$H%cx&i(y zHdmmFKjHoT@pOR%VhPwFokDfM@m8X4k&=SNJZD>~;;B0a(3r$pEOr+;jBuR>{#l+95np8GZUH6L8nv0qG3^1=*4 zSVdW{>y8$<8g<$E`5?_lIMq$CpC%2()cXuxx zuDP3O?D#rs+VVeh`9+c*In~4Ahe;v%M&85Rm-%SOc(vQ=Z+?3CPUl0}*#N^vw>q;JzBR zwKO+B_H7Bz6ELx}JYC_u=V1PJ#TCkA_RaFCy|+Am-C~=G+IhHNMqXC7YS$mD)jql;xI5I2eI3c$;W!vl^ueT_DBI5%i9gh8)%BzG(~vHOZQ4k%(~XNFiAe@) zz+7UGX&>WIgQhvrEZ=uZ9Uop(RfGdeL}ls0@|KoA>8uSznAMtaR`Wbc@d(|7W@Ke^@o##!S~p)kO?J$PeLI(uoagIVX0uF1PP!!MP%8FD$t%*& z?`u&VOHQ*@-eH<7JfPW>0#2oeZ<(KDlqcuUId>wRRJGgAY0X>x)Nqm_&2DqG1tvDX z*D8qy*+7B6SyOOfOUg?-DS%2E?UL* z`#hUxzl?U*?Wqc0?(0pDE33#i*c38}Jzrp$SChPA?erKgz)%8pGXM2LHtKO8^@i=x z*yHV4QJt}4)K~Ni&FMi`Q9_QTixJ22tS;)2E$wrgUY;}3qp^m^D z1u^dHEfUidfw?)0Xz$x%H%|_ghn{`Gt^w-?@ZP;CC*35XcTIYWDGi5SovEX8# z#$29jFg!2Ys9%-PQ=id4xAb;?!UOffGZ;Mf{&nNWe($|Xipo?|4Xz0oJ7m?xN2P^| zoVEL}ALKT2&3-H5bR9RZB?r}7ZoHPNF%o3Q^KFo?3Vay=rRYUzc|yot*T=)%4dy8$ zBKrxyB->B~H` z%R0BzzC4-le!;uuSf!7Zn(Cv(5gLJIYhp>3{qxth zbTx!9qHFI{kohEjyK256tS~60yg6#g_}e$m$~S1U;hEmbV;iZ`ex{l@s%$Gt4I{d# zU>MUyL_^zL%U^eNlU;fCs^6DC*f5AQi +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + + +
+ {include file="toolbar.tpl" toolbar_btn=$toolbar_btn} +
+

+ {$title|default:' '} +

+
+
+ +{if $generate} +
+ + {$combinations_size} {l s='product(s) successfully created.'} +
+{/if} + +
+
+ {l s='Attributes generator'} + {l s='Add or modify attributes for product:'} {$product_name} +

+
+
+ +
+ +
+ +
+ +
+
+
+
+
+
+
+ {foreach $attribute_groups as $k => $attribute_group} + {if isset($attribute_js[$attribute_group['id_attribute_group']])} +
+ + + + + + + + + + + + {if isset($attributes[$attribute_group['id_attribute_group']])} + {foreach $attributes[$attribute_group['id_attribute_group']] AS $k => $attribute} + + {/foreach} + {/if} + {/if} + {/foreach} +
+
+
+
+ +
+
+

+ +
+

+
+
+
+
+
\ No newline at end of file diff --git a/admin-dev/themes/template/products/combinations.tpl b/admin-dev/themes/template/products/combinations.tpl index 672f05597..351a84d83 100644 --- a/admin-dev/themes/template/products/combinations.tpl +++ b/admin-dev/themes/template/products/combinations.tpl @@ -49,7 +49,7 @@
{l s='Add or modify combinations for this product'} {l s='or go to'} -  combinations_generator {l s='Product combinations generator'} +  combinations_generator {l s='Product combinations generator'}
diff --git a/classes/Product.php b/classes/Product.php index ab8744e44..c7e4f7ff1 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -893,7 +893,7 @@ class ProductCore extends ObjectModel /** * addProductAttribute is deprecated - * @deprecated + * @deprecated */ public function addProductAttribute($price, $weight, $unit_impact, $ecotax, $quantity, $id_images, $reference, $supplier_reference, $ean13, $default, $location = NULL, $upc = NULL) { diff --git a/controllers/admin/AdminAttributeGeneratorController.php b/controllers/admin/AdminAttributeGeneratorController.php new file mode 100644 index 000000000..cde9cf003 --- /dev/null +++ b/controllers/admin/AdminAttributeGeneratorController.php @@ -0,0 +1,224 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 6844 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +@ini_set('max_execution_time', 3600); + +class AdminAttributeGeneratorControllerCore extends AdminController +{ + private $combinations = array(); + private $product; + + public function __construct() + { + $this->table = 'product_attribute'; + $this->className = 'Product'; + parent::__construct(); + } + + private function addAttribute($arr, $price = 0, $weight = 0) + { + foreach ($arr AS $attr) + { + $price += (float)($_POST['price_impact_'.(int)($attr)]); + $weight += (float)($_POST['weight_impact'][(int)($attr)]); + } + if ($this->product->id) + { + return (array( + 'id_product' => (int)($this->product->id), + 'price' => (float)($price), + 'weight' => (float)($weight), + 'ecotax' => 0, + 'quantity' => (int)($_POST['quantity']), + 'reference' => pSQL($_POST['reference']), + 'default_on' => 0, + 'available_date' => '0000-00-00')); + } + return array(); + } + + static private function createCombinations($list) + { + if (sizeof($list) <= 1) + return sizeof($list) ? array_map(create_function('$v', 'return (array($v));'), $list[0]) : $list; + $res = array(); + $first = array_pop($list); + foreach ($first AS $attribute) + { + $tab = self::createCombinations($list); + foreach ($tab AS $toAdd) + $res[] = is_array($toAdd) ? array_merge($toAdd, array($attribute)) : array($toAdd, $attribute); + } + return $res; + } + + public function postProcess() + { + $this->product = new Product((int)(Tools::getValue('id_product'))); + + if (isset($_POST['generate'])) + { + if (!is_array(Tools::getValue('options'))) + $this->_errors[] = Tools::displayError('Please choose at least 1 attribute.'); + else + { + $tab = array_values($_POST['options']); + if (sizeof($tab) AND Validate::isLoadedObject($this->product)) + { + self::setAttributesImpacts($this->product->id, $tab); + $this->combinations = array_values(self::createCombinations($tab)); + $values = array_values(array_map(array($this, 'addAttribute'), $this->combinations)); + $this->product->deleteProductAttributes(); + $res = $this->product->addProductAttributeMultiple($values); + $this->product->addAttributeCombinationMultiple($res, $this->combinations); + $this->product->updateQuantityProductWithAttributeQuantity(); + } + else + $this->_errors[] = Tools::displayError('Unable to initialize parameters, combination is missing or object cannot be loaded.'); + } + } + elseif (isset($_POST['back'])) + Tools::redirectAdmin(self::$currentIndex.'&id_product='.(int)(Tools::getValue('id_product')).'&addproduct'.'&tabs=3&token='.Tools::getValue('token')); + parent::postProcess(); + } + + private static function displayAndReturnAttributeJs() + { + $attributes = Attribute::getAttributes(Context::getContext()->language->id, true); + $attributeJs = array(); + foreach ($attributes AS $k => $attribute) + $attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; + echo ' + '; + return $attributeJs; + } + + private static function setAttributesImpacts($id_product, $tab) + { + $attributes = array(); + foreach ($tab AS $group) + foreach ($group AS $attribute) + $attributes[] = '('.(int)($id_product).', '.(int)($attribute).', '.(float)($_POST['price_impact_'.(int)($attribute)]).', '.(float)($_POST['weight_impact'][(int)($attribute)]).')'; + + return Db::getInstance()->execute( + 'INSERT INTO `'._DB_PREFIX_.'attribute_impact` (`id_product`, `id_attribute`, `price`, `weight`) + VALUES '.implode(',', $attributes).' + ON DUPLICATE KEY UPDATE `price`=VALUES(price), `weight`=VALUES(weight)' + ); + } + + private static function getAttributesImpacts($id_product) + { + $tab = array(); + $result = Db::getInstance()->executeS( + 'SELECT ai.`id_attribute`, ai.`price`, ai.`weight` + FROM `'._DB_PREFIX_.'attribute_impact` ai + WHERE ai.`id_product` = '.(int)($id_product)); + if (!$result) + return array(); + foreach ($result AS $impact) + { + $tab[$impact['id_attribute']]['price'] = (float)($impact['price']); + $tab[$impact['id_attribute']]['weight'] = (float)($impact['weight']); + } + return $tab; + } + + public function initGroupTable() + { + $combinationsGroups = $this->product->getAttributesGroups($this->context->language->id); + $attributes = array(); + $impacts = self::getAttributesImpacts($this->product->id); + foreach ($combinationsGroups as &$combination) + { + $target = &$attributes[$combination['id_attribute_group']][$combination['id_attribute']]; + $target = $combination; + if (isset($impacts[$combination['id_attribute']])) + { + $target['price'] = $impacts[$combination['id_attribute']]['price']; + $target['weight'] = $impacts[$combination['id_attribute']]['weight']; + } + } + $this->context->smarty->assign(array( + 'currency_sign' => $this->context->currency->sign, + 'weight_unit' => Configuration::get('PS_WEIGHT_UNIT'), + 'attributes' => $attributes, + )); + } + + public function initToolbar() + { + $this->toolbar_btn['back'] = array( + 'href' => $this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)Tools::getValue('id_product'), + 'desc' => $this->l('Back to product') + ); + } + + public function initContent() + { + if (!Combination::isFeatureActive()) + { + $this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' '.$this->l('Performances').''); + return; + } + + // Init toolbar + $this->initToolbarTitle(); + $this->initToolbar(); + + $this->initGroupTable(); + + $js_attributes = self::displayAndReturnAttributeJs(); + $attribute_groups = AttributeGroup::getAttributesGroups($this->context->language->id); + $this->product = new Product((int)(Tools::getValue('id_product'))); + + $this->context->smarty->assign(array( + 'tax_rates' => $this->product->getTaxesRate(), + 'generate' => isset($_POST['generate']) AND !sizeof($this->_errors), + 'combinations_size' => count($this->combinations), + 'product_name' => $this->product->name[$this->context->language->id], + 'product_reference' => $this->product->reference, + 'url_generator' => self::$currentIndex.'&id_product='.(int)(Tools::getValue('id_product')).'&attributegenerator&token='.Tools::getValue('token'), + 'attribute_groups' => $attribute_groups, + 'attribute_js' => $js_attributes, + 'toolbar_btn' => $this->toolbar_btn, + 'title' => $this->toolbar_title, + )); + } +} \ No newline at end of file diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 3d489fb21..6c824b0a1 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -1913,7 +1913,7 @@ switch ($this->action) $countries = Country::getCountries($this->context->language->id); $groups = Group::getGroups($this->context->language->id); $currencies = Currency::getCurrencies(); - $currency = + $currency = $attributes = $obj->getAttributesGroups((int)$this->context->language->id); $combinations = array(); foreach($attributes as $attribute) @@ -1922,7 +1922,7 @@ switch ($this->action) if (!isset($combinations[$attribute['id_product_attribute']]['attributes'])) $combinations[$attribute['id_product_attribute']]['attributes'] = ''; $combinations[$attribute['id_product_attribute']]['attributes'] .= $attribute['attribute_name'].' - '; - + $combinations[$attribute['id_product_attribute']]['price'] = Tools::displayPrice(Tools::convertPrice(Product::getPriceStatic((int)$obj->id, false, $attribute['id_product_attribute']), $this->context->currency), $this->context->currency); } foreach ($combinations as &$combination) @@ -3481,9 +3481,7 @@ $product->supplier_name = Supplier::getNameById($product->id_supplier); '.$this->l('Weight').' '.$this->l('Reference').' '.$this->l('EAN13').' - '.$this->l('UPC').' - '.$this->l('Quantity').''; - + '.$this->l('UPC').''; if ($id_product_download && !empty($productDownload->display_filename)) { @@ -3517,7 +3515,6 @@ $product->supplier_name = Supplier::getNameById($product->id_supplier); $combArray[$combinaison['id_product_attribute']]['minimal_quantity'] = $combinaison['minimal_quantity']; $combArray[$combinaison['id_product_attribute']]['available_date'] = strftime($combinaison['available_date']); $combArray[$combinaison['id_product_attribute']]['location'] = $combinaison['location']; - $combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity']; $combArray[$combinaison['id_product_attribute']]['id_image'] = isset($combinationImages[$combinaison['id_product_attribute']][0]['id_image']) ? $combinationImages[$combinaison['id_product_attribute']][0]['id_image'] : 0; $combArray[$combinaison['id_product_attribute']]['default_on'] = $combinaison['default_on']; $combArray[$combinaison['id_product_attribute']]['ecotax'] = $combinaison['ecotax']; @@ -3568,8 +3565,7 @@ $product->supplier_name = Supplier::getNameById($product->id_supplier); '.$product_attribute['weight'].Configuration::get('PS_WEIGHT_UNIT').' '.$product_attribute['reference'].' '.$product_attribute['ean13'].' - '.$product_attribute['upc'].' - '.$product_attribute['quantity'].''; + '.$product_attribute['upc'].''; if ($id_product_download && !empty($product->productDownload->display_filename)) { @@ -3590,7 +3586,7 @@ $product->supplier_name = Supplier::getNameById($product->id_supplier); '.$this->l('Modify this combination').'  '.(!$product_attribute['default_on'] ? ' '.$this->l('Make this the default combination').'' : '').' @@ -3628,9 +3624,12 @@ $product->supplier_name = Supplier::getNameById($product->id_supplier); $this->content .= $content; // @todo $smarty->assign('up_filename', strval(Tools::getValue('virtual_product_filename_attribute'))); - $this->context->smarty->assign('content', $content); - $this->context->smarty->assign('product', $product); - $this->context->smarty->assign('id_category', $product->id_category_default); + $this->context->smarty->assign(array( + 'content' => $content, + 'product' => $product, + 'id_category' => $product->id_category_default, + 'token_generator' => Tools::getAdminTokenLite('AdminAttributeGenerator') + )); $this->content = $this->context->smarty->fetch('products/combinations.tpl'); } diff --git a/install-dev/sql/db_settings_lite.sql b/install-dev/sql/db_settings_lite.sql index 0e19c4fa3..fd4ab7a30 100644 --- a/install-dev/sql/db_settings_lite.sql +++ b/install-dev/sql/db_settings_lite.sql @@ -360,8 +360,8 @@ INSERT INTO `PREFIX_category_lang` (`id_category`, `id_lang`, `name`, `descripti (1, 1, 'Home', '', 'home', NULL, NULL, NULL),(1, 2, 'Accueil', '', 'home', NULL, NULL, NULL),(1, 3, 'Inicio', '', 'home', NULL, NULL, NULL),(1, 4, 'Start', '', 'home', NULL, NULL, NULL),(1, 5, 'Home page', '', 'home', NULL, NULL, NULL); INSERT INTO `PREFIX_order_state` (`id_order_state`, `invoice`, `send_email`, `color`, `unremovable`, `logable`, `delivery`, `shipped`) VALUES -(1, 0, 1, 'lightblue', 1, 0, 0, 0),(2, 1, 1, '#DDEEFF', 1, 1, 0, 0),(3, 1, 1, '#FFDD99', 1, 1, 1, 0),(4, 1, 1, '#EEDDFF', 1, 1, 1, 1),(5, 1, 0, '#DDFFAA', 1, 1, 1, 1), -(6, 0, 1, '#DADADA', 1, 0, 0, 0),(7, 1, 1, '#FFFFBB', 1, 0, 0, 0),(8, 0, 1, '#FFDFDF', 1, 0, 0, 0),(9, 1, 1, '#FFD3D3', 1, 0, 0, 0),(10, 0, 1, 'lightblue', 1, 0, 0, 0),(11, 0, 0, 'lightblue', 1, 0, 0, 0),(12, 1, 0, '#DDEEFF', 1, 1, 0, 0); +(1, 0, 1, 'RoyalBlue', 1, 0, 0, 0),(2, 1, 1, 'LimeGreen', 1, 1, 0, 0),(3, 1, 1, 'DarkOrange', 1, 1, 1, 0),(4, 1, 1, 'BlueViolet', 1, 1, 1, 1),(5, 1, 0, 'Crimson', 1, 1, 1, 1), +(6, 0, 1, '#999999', 1, 0, 0, 0),(7, 1, 1, 'Orange', 1, 0, 0, 0),(8, 0, 1, 'DarkOrange', 1, 0, 0, 0),(9, 1, 1, 'HotPink', 1, 0, 0, 0),(10, 0, 1, 'RoyalBlue', 1, 0, 0, 0),(11, 0, 0, 'RoyalBlue', 1, 0, 0, 0),(12, 1, 0, 'LimeGreen', 1, 1, 0, 0); INSERT INTO `PREFIX_order_state_lang` (`id_order_state`, `id_lang`, `name`, `template`) VALUES (1, 1, 'Awaiting cheque payment', 'cheque'), @@ -949,7 +949,8 @@ INSERT INTO `PREFIX_tab` (`id_tab`, `class_name`, `id_parent`, `position`) VALUE (97, 'AdminStockManagement', 95, 2), (98, 'AdminStockInstantState', 95, 4), (99, 'AdminStockCover', 95, 5), -(100, 'AdminSupplierOrders', 95, 6); +(100, 'AdminSupplierOrders', 95, 6), +(101, 'AdminAttributeGenerator', -1, 0); INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) (SELECT 1, id_tab, 1, 1, 1, 1 FROM `PREFIX_tab`); @@ -974,7 +975,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (1, 97, 'Stock Management'), (1, 98, 'Stock instant state'), (1, 99, 'Stock cover'), -(1, 100, 'Supplier orders'); +(1, 100, 'Supplier orders'), +(1, 101, 'Combinations generator'); INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (2, 1, 'Catalogue'),(2, 2, 'Clients'),(2, 3, 'Commandes'),(2, 4, 'Paiement'),(2, 5, 'Transport'), @@ -997,7 +999,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (2, 97, 'Gestion du stock'), (2, 98, 'Etat instantané du stock'), (2, 99, 'Couverture de stock'), -(2, 100, 'Commandes fournisseurs'); +(2, 100, 'Commandes fournisseurs'), +(2, 101, 'Générateur de combinaisons'); INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (3, 1, 'Catálogo'),(3, 2, 'Clientes'),(3, 3, 'Pedidos'),(3, 4, 'Pago'),(3, 5, 'Transporte'), @@ -1019,7 +1022,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (3, 97, 'Stock Management'), (3, 98, 'Stock instant state'), (3, 99, 'Stock cover'), -(3, 100, 'Supplier orders'); +(3, 100, 'Supplier orders'), +(3, 101, 'Combinations generator'); INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (4, 1, 'Katalog'),(4, 2, 'Kunden'),(4, 3, 'Bestellungen'),(4, 4, 'Zahlung'), @@ -1042,7 +1046,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (4, 97, 'Stock Management'), (4, 98, 'Stock instant state'), (4, 99, 'Stock cover'), -(4, 100, 'Supplier orders'); +(4, 100, 'Supplier orders'), +(4, 101, 'Combinations generator'); INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (5, 1, 'Catalogo'),(5, 2, 'Clienti'),(5, 3, 'Ordini'),(5, 4, 'Pagamento'), @@ -1065,7 +1070,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (5, 97, 'Stock Management'), (5, 98, 'Stock instant state'), (5, 99, 'Stock cover'), -(5, 100, 'Supplier orders'); +(5, 100, 'Supplier orders'), +(5, 101, 'Combinations generator'); INSERT IGNORE INTO `PREFIX_tab_lang` (`id_tab`, `id_lang`, `name`) (SELECT `id_tab`, id_lang, (SELECT tl.`name` @@ -1085,7 +1091,7 @@ INSERT INTO `PREFIX_quick_access_lang` (`id_quick_access`, `id_lang`, `name`) VA (4, 1, 'New product'),(4, 2, 'Nouveau produit'),(4, 3, 'Nuevo producto'),(4, 4, 'Neues Produkt'),(4, 5, 'Nuovo prodotto'), (5, 1, 'New voucher'),(5, 2, 'Nouveau bon de réduction'),(5, 3, 'Nuevo cupón'),(5, 4, 'Neuer Ermäßigungsgutschein'),(5, 5, 'Nuovo buono sconto'); -INSERT INTO `PREFIX_order_return_state` (`id_order_return_state`, `color`) VALUES (1, '#ADD8E6'),(2, '#EEDDFF'),(3, '#DDFFAA'),(4, '#FFD3D3'),(5, '#FFFFBB'); +INSERT INTO `PREFIX_order_return_state` (`id_order_return_state`, `color`) VALUES (1, '#ADD8E6'),(2, 'BlueViolet'),(3, 'Crimson'),(4, 'HotPink'),(5, 'Orange'); INSERT INTO `PREFIX_order_return_state_lang` (`id_order_return_state`, `id_lang`, `name`) VALUES (1, 1, 'Waiting for confirmation'),(2, 1, 'Waiting for package'),(3, 1, 'Package received'),(4, 1, 'Return denied'),(5, 1, 'Return completed'), diff --git a/install-dev/sql/upgrade/1.5.0.1.sql b/install-dev/sql/upgrade/1.5.0.1.sql index 3bbe924fb..4f5b018ed 100644 --- a/install-dev/sql/upgrade/1.5.0.1.sql +++ b/install-dev/sql/upgrade/1.5.0.1.sql @@ -471,3 +471,5 @@ UPDATE `PREFIX_hook` SET `name` = 'actionTaxManager' WHERE `name` = 'taxManager' ALTER TABLE `PREFIX_specific_price` ADD `id_product_attribute` INT UNSIGNED NOT NULL AFTER `id_product`; ALTER TABLE `PREFIX_specific_price` DROP INDEX `id_product`; ALTER TABLE `PREFIX_specific_price` ADD INDEX `id_product` (`id_product`, `id_product_attribute`, `id_shop`, `id_currency`, `id_country`, `id_group`, `from_quantity`, `from`, `to`); + +/* PHP:add_new_tab(AdminAttributeGenerator, fr:Générateur de combinaisons|es:Combinations generator|en:Combinations generator|de:Combinations generator|it:Combinations generator, 1); */; \ No newline at end of file