From 570ecde717ee2958fc714016b7eecca8ffff373d Mon Sep 17 00:00:00 2001 From: lLefevre Date: Sun, 4 Dec 2011 10:42:05 +0000 Subject: [PATCH] // update tab "attributes" in smarty template + update action in list in ajax --- .../helper/list/list_action_addstock.tpl | 5 +- .../helper/list/list_action_default.tpl | 28 + .../helper/list/list_action_delete.tpl | 5 +- .../helper/list/list_action_details.tpl | 4 +- .../helper/list/list_action_duplicate.tpl | 5 +- .../template/helper/list/list_action_edit.tpl | 4 +- .../helper/list/list_action_enable.tpl | 5 +- .../helper/list/list_action_removestock.tpl | 5 +- .../list_action_supplier_order_receipt.tpl | 5 +- .../list_action_supply_order_change_state.tpl | 5 +- ...tion_supply_order_create_from_template.tpl | 5 +- .../list/list_action_supply_order_receipt.tpl | 5 +- .../helper/list/list_action_transferstock.tpl | 5 +- .../template/helper/list/list_action_view.tpl | 5 +- .../template/helper/list/list_footer.tpl | 4 +- .../combinaison/list_action_default.tpl | 28 + .../combinaison/list_action_delete.tpl | 28 + .../products/combinaison/list_action_edit.tpl | 28 + .../products/combinaison/list_footer.tpl | 50 ++ .../themes/template/products/combinations.tpl | 472 +++++++------ admin-dev/themes/template/products/form.tpl | 11 +- .../themes/template/products/list_header.tpl | 67 +- classes/AdminController.php | 3 +- classes/HelperList.php | 20 +- classes/Product.php | 26 + controllers/admin/AdminProductsController.php | 665 ++++++++++++------ controllers/admin/AdminShippingController.php | 2 +- js/admin-products.js | 109 +++ 28 files changed, 1110 insertions(+), 494 deletions(-) create mode 100644 admin-dev/themes/template/helper/list/list_action_default.tpl create mode 100644 admin-dev/themes/template/products/combinaison/list_action_default.tpl create mode 100644 admin-dev/themes/template/products/combinaison/list_action_delete.tpl create mode 100644 admin-dev/themes/template/products/combinaison/list_action_edit.tpl create mode 100644 admin-dev/themes/template/products/combinaison/list_footer.tpl diff --git a/admin-dev/themes/template/helper/list/list_action_addstock.tpl b/admin-dev/themes/template/helper/list/list_action_addstock.tpl index a3dd29a3c..0e0b9c190 100644 --- a/admin-dev/themes/template/helper/list/list_action_addstock.tpl +++ b/admin-dev/themes/template/helper/list/list_action_addstock.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} + + {$action} + diff --git a/admin-dev/themes/template/helper/list/list_action_default.tpl b/admin-dev/themes/template/helper/list/list_action_default.tpl new file mode 100644 index 000000000..a4fa50937 --- /dev/null +++ b/admin-dev/themes/template/helper/list/list_action_default.tpl @@ -0,0 +1,28 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 9197 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + {$action} + \ No newline at end of file diff --git a/admin-dev/themes/template/helper/list/list_action_delete.tpl b/admin-dev/themes/template/helper/list/list_action_delete.tpl index 4514d72b0..7a41c74ab 100644 --- a/admin-dev/themes/template/helper/list/list_action_delete.tpl +++ b/admin-dev/themes/template/helper/list/list_action_delete.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} \ No newline at end of file + + {$action} + \ No newline at end of file diff --git a/admin-dev/themes/template/helper/list/list_action_details.tpl b/admin-dev/themes/template/helper/list/list_action_details.tpl index cbc266359..0160a654e 100644 --- a/admin-dev/themes/template/helper/list/list_action_details.tpl +++ b/admin-dev/themes/template/helper/list/list_action_details.tpl @@ -123,6 +123,6 @@ $(document).ready(function() { }); }); - - {$action} + + {$action} diff --git a/admin-dev/themes/template/helper/list/list_action_duplicate.tpl b/admin-dev/themes/template/helper/list/list_action_duplicate.tpl index ce5b9c8e7..885c23c59 100644 --- a/admin-dev/themes/template/helper/list/list_action_duplicate.tpl +++ b/admin-dev/themes/template/helper/list/list_action_duplicate.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} \ No newline at end of file + + {$action} + \ No newline at end of file diff --git a/admin-dev/themes/template/helper/list/list_action_edit.tpl b/admin-dev/themes/template/helper/list/list_action_edit.tpl index 906d7e398..469241ba2 100644 --- a/admin-dev/themes/template/helper/list/list_action_edit.tpl +++ b/admin-dev/themes/template/helper/list/list_action_edit.tpl @@ -23,6 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - - {$action} + + {$action} \ No newline at end of file diff --git a/admin-dev/themes/template/helper/list/list_action_enable.tpl b/admin-dev/themes/template/helper/list/list_action_enable.tpl index b25a60473..27abb61e5 100644 --- a/admin-dev/themes/template/helper/list/list_action_enable.tpl +++ b/admin-dev/themes/template/helper/list/list_action_enable.tpl @@ -24,7 +24,6 @@ * International Registered Trademark & Property of PrestaShop SA *} - - {if $enabled}{l s='Enabled'}{else}{l s='Disabled'}{/if} + + {if $enabled}{l s='Enabled'}{else}{l s='Disabled'}{/if} diff --git a/admin-dev/themes/template/helper/list/list_action_removestock.tpl b/admin-dev/themes/template/helper/list/list_action_removestock.tpl index 2a01ff537..c06384cc0 100644 --- a/admin-dev/themes/template/helper/list/list_action_removestock.tpl +++ b/admin-dev/themes/template/helper/list/list_action_removestock.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} + + {$action} + diff --git a/admin-dev/themes/template/helper/list/list_action_supplier_order_receipt.tpl b/admin-dev/themes/template/helper/list/list_action_supplier_order_receipt.tpl index 4727b3407..9e151db3d 100644 --- a/admin-dev/themes/template/helper/list/list_action_supplier_order_receipt.tpl +++ b/admin-dev/themes/template/helper/list/list_action_supplier_order_receipt.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} + + {$action} + diff --git a/admin-dev/themes/template/helper/list/list_action_supply_order_change_state.tpl b/admin-dev/themes/template/helper/list/list_action_supply_order_change_state.tpl index ba21670b4..716ffd720 100644 --- a/admin-dev/themes/template/helper/list/list_action_supply_order_change_state.tpl +++ b/admin-dev/themes/template/helper/list/list_action_supply_order_change_state.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} \ No newline at end of file + + {$action} + \ No newline at end of file diff --git a/admin-dev/themes/template/helper/list/list_action_supply_order_create_from_template.tpl b/admin-dev/themes/template/helper/list/list_action_supply_order_create_from_template.tpl index 3fd3bc783..7deb3740d 100644 --- a/admin-dev/themes/template/helper/list/list_action_supply_order_create_from_template.tpl +++ b/admin-dev/themes/template/helper/list/list_action_supply_order_create_from_template.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} + + {$action} + diff --git a/admin-dev/themes/template/helper/list/list_action_supply_order_receipt.tpl b/admin-dev/themes/template/helper/list/list_action_supply_order_receipt.tpl index 7475b155e..c6bc2d5b8 100644 --- a/admin-dev/themes/template/helper/list/list_action_supply_order_receipt.tpl +++ b/admin-dev/themes/template/helper/list/list_action_supply_order_receipt.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} + + {$action} + diff --git a/admin-dev/themes/template/helper/list/list_action_transferstock.tpl b/admin-dev/themes/template/helper/list/list_action_transferstock.tpl index dab100dc8..5c4008e66 100644 --- a/admin-dev/themes/template/helper/list/list_action_transferstock.tpl +++ b/admin-dev/themes/template/helper/list/list_action_transferstock.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} + + {$action} + diff --git a/admin-dev/themes/template/helper/list/list_action_view.tpl b/admin-dev/themes/template/helper/list/list_action_view.tpl index 2cf124a6a..1750894da 100644 --- a/admin-dev/themes/template/helper/list/list_action_view.tpl +++ b/admin-dev/themes/template/helper/list/list_action_view.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} \ No newline at end of file + + {$action} + \ No newline at end of file diff --git a/admin-dev/themes/template/helper/list/list_footer.tpl b/admin-dev/themes/template/helper/list/list_footer.tpl index cfd5faf93..36195e9f3 100644 --- a/admin-dev/themes/template/helper/list/list_footer.tpl +++ b/admin-dev/themes/template/helper/list/list_footer.tpl @@ -36,4 +36,6 @@ - \ No newline at end of file + + +{block name="after"}{/block} \ No newline at end of file diff --git a/admin-dev/themes/template/products/combinaison/list_action_default.tpl b/admin-dev/themes/template/products/combinaison/list_action_default.tpl new file mode 100644 index 000000000..6cf2b9fe3 --- /dev/null +++ b/admin-dev/themes/template/products/combinaison/list_action_default.tpl @@ -0,0 +1,28 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 9197 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + {$action} + \ No newline at end of file diff --git a/admin-dev/themes/template/products/combinaison/list_action_delete.tpl b/admin-dev/themes/template/products/combinaison/list_action_delete.tpl new file mode 100644 index 000000000..fa753b7b5 --- /dev/null +++ b/admin-dev/themes/template/products/combinaison/list_action_delete.tpl @@ -0,0 +1,28 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 9197 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + {$action} + \ No newline at end of file diff --git a/admin-dev/themes/template/products/combinaison/list_action_edit.tpl b/admin-dev/themes/template/products/combinaison/list_action_edit.tpl new file mode 100644 index 000000000..a055f68bd --- /dev/null +++ b/admin-dev/themes/template/products/combinaison/list_action_edit.tpl @@ -0,0 +1,28 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 9197 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + {l s='Modify this combination'} + \ No newline at end of file diff --git a/admin-dev/themes/template/products/combinaison/list_footer.tpl b/admin-dev/themes/template/products/combinaison/list_footer.tpl new file mode 100644 index 000000000..b6a245335 --- /dev/null +++ b/admin-dev/themes/template/products/combinaison/list_footer.tpl @@ -0,0 +1,50 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 10634 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +{extends file="helper/list/list_footer.tpl"} + +{block name="after"} + +
+
    +
  • {l s='The row in blue is the default combination.'}
  • +
  • {l s='A default combination must be designated for each product.'}
  • +
+
+ + + +{/block} diff --git a/admin-dev/themes/template/products/combinations.tpl b/admin-dev/themes/template/products/combinations.tpl index 88012e412..cde362f4e 100644 --- a/admin-dev/themes/template/products/combinations.tpl +++ b/admin-dev/themes/template/products/combinations.tpl @@ -1,6 +1,32 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @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 +*} + - - - - -
- - - - - - -
- - {l s='Reference:'} - - - {l s='EAN13:'} - {l s='UPC:'} - {l s='Special characters allowed:'} .-_#  - - - -
- - - - - - - - - - + +
{l s='Wholesale price:'} + + + + + + + + + + + + + + + + + + + + + + + +
+ {l s='Group:'} + + +
+ {l s='Attribute:'} + + + +
+
+
+ +
+
+
{l s='Reference:'} + + {l s='EAN13:'} + {l s='UPC:'} + {l s='Special characters allowed:'} .-_#  +
+
+
+ + + + + + + + + + + + - - - - + + + + - - - - - - - - - + + + + + + + + + {if $ps_use_ecotax} - - - - -{/if} - + + + {/if} + + - - - - - - - - - + + + + + + + + + + + - - - - - - - - + + + + + + + + - -
+ {l s='Wholesale price:'} + {if $currency->format % 2 != 0}{$currency->sign}{/if} - {if $currency->format % 2 == 0} {$currency->sign} {/if}({l s='overrides Wholesale price on Information tab'})
{l s='Impact on price:'} + {if $currency->format % 2 == 0} {$currency->sign} {/if}({l s='overrides Wholesale price on Information tab'}) +
{l s='Impact on price:'}   {l s='of'}  {if $currency->format % 2 != 0}{$currency->sign} {/if} {if $currency->format % 2 == 0} {$currency->sign}{/if} - {if $country_display_tax_label} - {l s='(tax excl.)'} - {l s='or'} {if $currency->format % 2 != 0}{$currency->sign} {/if} - - {if $currency->format % 2 == 0} {$currency->sign}{/if} {l s='(tax incl.)'} - {l s='final product price will be set to'} - {if $currency->format % 2 != 0}{$currency->sign} {/if} - 0.00 - {if $currency->format % 2 == 0}{$currency->sign} {/if} - {/if} + {if $country_display_tax_label} + {l s='(tax excl.)'} + {l s='or'} + {if $currency->format % 2 != 0}{$currency->sign} {/if} + + {if $currency->format % 2 == 0} {$currency->sign}{/if} {l s='(tax incl.)'} + {l s='final product price will be set to'} + {if $currency->format % 2 != 0}{$currency->sign} {/if} + 0.00 + {if $currency->format % 2 == 0}{$currency->sign} {/if} + {/if}
{l s='Impact on weight:'} -   {l s='of'}   - {$ps_weight_unit}
{l s='Impact on unit price :'} -   {l s='of'}   -   {if $currency->format % 2 != 0} {$currency->sign} {/if} - {if $currency->format % 2 == 0} {$currency->sign}{/if} / {$field_value_unity} -
{l s='Impact on weight:'} + +   {l s='of'}   + + {$ps_weight_unit} + +
{l s='Impact on unit price :'} + +   {l s='of'}     + {if $currency->format % 2 != 0} {$currency->sign} {/if} + {if $currency->format % 2 == 0} {$currency->sign}{/if} / {$field_value_unity} + +
- {l s='Eco-tax:'} - {if $currency->format % 2 != 0}{$currency->sign}{/if} - - {if $currency->format % 2 == 0} {$currency->sign}{/if} - ({l s='overrides Eco-tax on Information tab'}) -
+ + {l s='Eco-tax:'} + {if $currency->format % 2 != 0}{$currency->sign}{/if} + + {if $currency->format % 2 == 0} {$currency->sign}{/if} + ({l s='overrides Eco-tax on Information tab'}) +
+

{l s='The minimum quantity to buy this product (set to 1 to disable this feature)'}

-
-

{l s='The available date when this product is out of stock'}

- -
{l s='Image:'} +
+ + + +

{l s='The available date when this product is out of stock'}

+ +
+
+
{l s='Image:'}
    {foreach from=$images key=k item=image} -
  • - - -
  • +
  • + + +
  • {/foreach}
-
{l s='Default:'}

-  {l s='Make this the default combination for this product'}

-
  - +
{l s='Default:'}

+ +  {l s='Make this the default combination for this product'}

+
  + + + -
- - -{$content} + + + +
+ + +{$list} diff --git a/admin-dev/themes/template/products/form.tpl b/admin-dev/themes/template/products/form.tpl index 4401524ef..6d17f4c92 100644 --- a/admin-dev/themes/template/products/form.tpl +++ b/admin-dev/themes/template/products/form.tpl @@ -23,17 +23,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} -{extends file="helper/form/form.tpl"} -{block name="script"} - - - - - - - - {l s='Go to category:'} - -{/if} + + {l s='Go to category:'} + + {/if} {/block} diff --git a/classes/AdminController.php b/classes/AdminController.php index 4c4837199..753496391 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -1503,8 +1503,7 @@ class AdminControllerCore extends Controller $this->addCSS(_THEME_CSS_DIR_.'rtl.css'); $this->addJquery(); - $this->addjQueryPlugin(array('cluetip', 'hoverIntent')); - $this->addJqueryPlugin('scrollTo'); + $this->addjQueryPlugin(array('cluetip', 'hoverIntent', 'scrollTo')); $this->addJS(array( _PS_JS_DIR_.'admin.js', diff --git a/classes/HelperList.php b/classes/HelperList.php index df4757202..c9eefee7e 100644 --- a/classes/HelperList.php +++ b/classes/HelperList.php @@ -432,7 +432,7 @@ class HelperListCore extends Helper $tpl->assign(array( 'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.'&token='.($token != null ? $token : $this->token), 'action' => self::$cache_lang['Edit'], - 'id' => (int)$id + 'id' => $id )); return $tpl->fetch(); @@ -461,6 +461,24 @@ class HelperListCore extends Helper return $tpl->fetch(); } + /** + * Display delete action link + */ + protected function displayDefaultLink($token = null, $id) + { + $tpl = $this->createTemplate('list_action_default.tpl'); + if (!array_key_exists('Default', self::$cache_lang)) + self::$cache_lang['Default'] = $this->l('Default'); + + $tpl->assign(array_merge($this->tpl_delete_link_vars, array( + 'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&token='.($token != null ? $token : $this->token), + 'action' => self::$cache_lang['Default'], + 'id' => $id, + ))); + + return $tpl->fetch(); + } + /** * Display list header (filtering, pagination and column names) */ diff --git a/classes/Product.php b/classes/Product.php index e13a6bb5f..e21e886db 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -1669,6 +1669,32 @@ class ProductCore extends ObjectModel return Db::getInstance()->executeS($sql); } + /** + * Get product attribute combinaison by id_product_attribute + * + * @param integer $id_product_attribute + * @param integer $id_lang Language id + * @return array Product attribute combinaison by id_product_attribute + */ + public function getAttributeCombinaisonsById($id_product_attribute, $id_lang) + { + if (!Combination::isFeatureActive()) + return array(); + $sql = 'SELECT pa.*, ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, al.`name` AS attribute_name, + a.`id_attribute`, pa.`unit_price_impact`, IFNULL(stock.quantity, 0) as quantity + FROM `'._DB_PREFIX_.'product_attribute` pa + LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` + LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` + LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group` + LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.') + LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.') + '.Product::sqlStock('pa', 'pa').' + WHERE pa.`id_product` = '.(int)$this->id.' + AND pa.`id_product_attribute` = '.(int)$id_product_attribute.' + ORDER BY pa.`id_product_attribute`'; + return Db::getInstance()->executeS($sql); + } + public function getCombinationImages($id_lang) { if (!Combination::isFeatureActive()) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 57a9f538c..eef1648f6 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -70,9 +70,6 @@ class AdminProductsControllerCore extends AdminController $this->table = 'product'; $this->className = 'Product'; $this->lang = true; - $this->addRowAction('edit'); - $this->addRowAction('duplicate'); - $this->addRowAction('delete'); $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); $this->imageType = 'jpg'; @@ -172,24 +169,24 @@ class AdminProductsControllerCore extends AdminController $_POST['weight'] = empty($_POST['weight']) ? '0' : str_replace(',', '.', $_POST['weight']); if ($_POST['unit_price'] != null) $object->unit_price = str_replace(',', '.', $_POST['unit_price']); - if (array_key_exists('ecotax', $_POST) && $_POST['ecotax'] != null) - $object->ecotax = str_replace(',', '.', $_POST['ecotax']); - $object->available_for_order = (int)Tools::isSubmit('available_for_order'); - $object->show_price = $object->available_for_order ? 1 : (int)Tools::isSubmit('show_price'); - $object->on_sale = Tools::isSubmit('on_sale'); - $object->online_only = Tools::isSubmit('online_only'); -} - -public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = null) -{ - $orderByPriceFinal = (empty($orderBy) ? ($this->context->cookie->__get($this->table.'Orderby') ? $this->context->cookie->__get($this->table.'Orderby') : 'id_'.$this->table) : $orderBy); - $orderWayPriceFinal = (empty($orderWay) ? ($this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderby') : 'ASC') : $orderWay); - if ($orderByPriceFinal == 'price_final') - { - $orderBy = 'id_'.$this->table; - $orderWay = 'ASC'; + if (array_key_exists('ecotax', $_POST) && $_POST['ecotax'] != null) + $object->ecotax = str_replace(',', '.', $_POST['ecotax']); + $object->available_for_order = (int)Tools::isSubmit('available_for_order'); + $object->show_price = $object->available_for_order ? 1 : (int)Tools::isSubmit('show_price'); + $object->on_sale = Tools::isSubmit('on_sale'); + $object->online_only = Tools::isSubmit('online_only'); } - parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, $id_lang_shop); + + public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = null) + { + $orderByPriceFinal = (empty($orderBy) ? ($this->context->cookie->__get($this->table.'Orderby') ? $this->context->cookie->__get($this->table.'Orderby') : 'id_'.$this->table) : $orderBy); + $orderWayPriceFinal = (empty($orderWay) ? ($this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderby') : 'ASC') : $orderWay); + if ($orderByPriceFinal == 'price_final') + { + $orderBy = 'id_'.$this->table; + $orderWay = 'ASC'; + } + parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, $id_lang_shop); /* update product quantity with attributes ...*/ $nb = count($this->_list); @@ -650,41 +647,6 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, } } } - else if (Tools::isSubmit('deleteProductAttribute')) - { - if (!Combination::isFeatureActive()) - return; - if ($this->tabAccess['delete'] === '1') - { - if (($id_product = (int)(Tools::getValue('id_product'))) && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product))) - { - $product->deleteAttributeCombinaison(Tools::getValue('id_product_attribute')); - - $id_product_download = ProductDownload::getIdFromIdAttribute((int) $id_product, (int) Tools::getValue('id_product_attribute')); - if ($id_product_download) - { - $productDownload = new ProductDownload((int) $id_product_download); - $this->deleteDownloadProduct((int) $id_product_download); - $productDownload->deleteFile(); - } - $product->checkDefaultAttributes(); - $product->updateQuantityProductWithAttributeQuantity(); - if (!$product->hasAttributes()) - { - $product->cache_default_attribute = 0; - $product->update(); - } - else - Product::updateDefaultAttribute($id_product); - - $this->redirect_after = self::$currentIndex.'&add'.$this->table.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&tabs=3&id_product='.$product->id.'&token='.($token ? $token : $this->token); - } - else - $this->_errors[] = Tools::displayError('Cannot delete attribute'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); - } else if (Tools::isSubmit('deleteAllProductAttributes')) { if (!Combination::isFeatureActive()) @@ -708,19 +670,6 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, else $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); } - else if (Tools::isSubmit('defaultProductAttribute')) - { - if (!Combination::isFeatureActive()) - return; - if (Validate::isLoadedObject($product = new Product((int)(Tools::getValue('id_product'))))) - { - $product->deleteDefaultAttributes(); - $product->setDefaultAttribute((int)(Tools::getValue('id_product_attribute'))); - $this->redirect_after = self::$currentIndex.'&add'.$this->table.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&tabs=3&id_product='.$product->id.'&token='.($token ? $token : $this->token); - } - else - $this->_errors[] = Tools::displayError('Cannot make default attribute'); - } /* Product features management */ else if (Tools::isSubmit('submitFeatures') || Tools::isSubmit('submitFeaturesAndStay')) @@ -980,6 +929,96 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, die(Tools::jsonEncode($result)); } + public function ajaxProcessDeleteProductAttribute() + { + if (!Combination::isFeatureActive()) + return; + + if ($this->tabAccess['delete'] === '1') + { + $id_product = (int)Tools::getValue('id_product'); + $id_product_attribute = (int)Tools::getValue('id_product_attribute'); + if ($id_product && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product))) + { + $product->deleteAttributeCombinaison($id_product_attribute); + + $id_product_download = (int)ProductDownload::getIdFromIdAttribute($id_product, $id_product_attribute); + if ($id_product_download) + { + $productDownload = new ProductDownload($id_product_download); + $this->deleteDownloadProduct($id_product_download); + $productDownload->deleteFile(); + } + $product->checkDefaultAttributes(); + $product->updateQuantityProductWithAttributeQuantity(); + if (!$product->hasAttributes()) + { + $product->cache_default_attribute = 0; + $product->update(); + } + else + Product::updateDefaultAttribute($id_product); + + $json = array( + 'status' => 'ok', + 'message'=> $this->_conf[1] + ); + } + else + $json = array( + 'status' => 'error', + 'message'=> $this->l('Cannot delete attribute') + ); + } + else + $json = array( + 'status' => 'error', + 'message'=> $this->l('You do not have permission to delete here.') + ); + + die(Tools::jsonEncode($json)); + } + + public function ajaxProcessDefaultProductAttribute() + { + if ($this->tabAccess['edit'] === '1') + { + if (!Combination::isFeatureActive()) + return; + + if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product')))) + { + $product->deleteDefaultAttributes(); + $product->setDefaultAttribute((int)Tools::getValue('id_product_attribute')); + $json = array( + 'status' => 'ok', + 'message'=> $this->_conf[4] + ); + } + else + $json = array( + 'status' => 'error', + 'message'=> $this->l('Cannot make default attribute') + ); + + die(Tools::jsonEncode($json)); + } + } + + public function ajaxProcessEditProductAttribute() + { + if ($this->tabAccess['edit'] === '1') + { + $id_product = (int)Tools::getValue('id_product'); + $id_product_attribute = (int)Tools::getValue('id_product_attribute'); + if ($id_product && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product))) + { + $combinaisons = $product->getAttributeCombinaisonsById($id_product_attribute, $this->context->language->id); + die(Tools::jsonEncode($combinaisons)); + } + } + } + public function ajaxPreProcess() { $this->action = Tools::getValue('action'); @@ -1710,6 +1749,10 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, public function renderList() { + $this->addRowAction('edit'); + $this->addRowAction('duplicate'); + $this->addRowAction('delete'); + if (!Tools::getValue('id_category')) unset($this->fieldsDisplay['position']); return parent::renderList(); @@ -1793,14 +1836,14 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, if ($this->display == 'edit' || $this->display == 'add') if ($product = $this->loadObject(true)) { - if ($this->tabAccess['delete']) + if ($this->tabAccess['delete'] && $this->display != 'add') $this->toolbar_btn['delete'] = array( 'short' => 'Delete', 'href' => $this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id.'&deleteproduct', 'desc' => $this->l('Delete this product'), 'confirm' => 1); - if ($this->tabAccess['add']) + if ($this->tabAccess['add'] && $this->display != 'add') $this->toolbar_btn['duplicate'] = array( 'short' => 'Duplicate', 'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id, @@ -1818,7 +1861,7 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, 'class' => 'previewUrl' ); - if (file_exists(_PS_MODULE_DIR_.'statsproduct/statsproduct.php')) + if (file_exists(_PS_MODULE_DIR_.'statsproduct/statsproduct.php') && $this->display != 'add') $this->toolbar_btn['stats'] = array( 'short' => 'Statistics', 'href' => $this->context->link->getAdminLink('AdminStats').'&module=statsproduct&id_product='.$product->id, @@ -2662,9 +2705,6 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $this->tpl_form_vars['iso'] = file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en'; $this->tpl_form_vars['ad'] = dirname($_SERVER['PHP_SELF']); $this->tpl_form_vars['tinymce'] = true; - $this->addJS(_PS_JS_DIR_.'admin-products.js'); - $this->addJS(_PS_JS_DIR_.'tiny_mce/tiny_mce.js'); - $this->addJS(_PS_JS_DIR_.'tinymce.inc.js'); $currency = $this->context->currency; $data->assign('languages',$languages); @@ -2950,16 +2990,15 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, return; } - $smarty = $this->context->smarty; - $content = ''; + $data = $this->context->smarty->createData(); $attributeJs = array(); $attributes = Attribute::getAttributes($this->context->language->id, true); foreach ($attributes as $k => $attribute) $attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; $currency = $this->context->currency; - $smarty->assign('attributeJs', $attributeJs); - $smarty->assign('attributes_groups', AttributeGroup::getAttributesGroups($this->context->language->id)); + $data->assign('attributeJs', $attributeJs); + $data->assign('attributes_groups', AttributeGroup::getAttributesGroups($this->context->language->id)); $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); $product->productDownload = new ProductDownload(); @@ -2967,40 +3006,206 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, if (!empty($id_product_download)) $product->productDownload = new ProductDownload($id_product_download); - // $smarty->assign('productDownload', $productDownload); - $smarty->assign('currency', $currency); + // $data->assign('productDownload', $productDownload); + $data->assign('currency', $currency); $images = Image::getImages($this->context->language->id, $product->id); if ($product->id) { - $smarty->assign('tax_exclude_option', Tax::excludeTaxeOption()); - $smarty->assign('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT')); + $data->assign('tax_exclude_option', Tax::excludeTaxeOption()); + $data->assign('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT')); - $smarty->assign('ps_use_ecotax', Configuration::get('PS_USE_ECOTAX')); - $smarty->assign('field_value_unity', $this->getFieldValue($product, 'unity')); + $data->assign('ps_use_ecotax', Configuration::get('PS_USE_ECOTAX')); + $data->assign('field_value_unity', $this->getFieldValue($product, 'unity')); - $smarty->assign('reasons', $reasons = StockMvtReason::getStockMvtReasons($this->context->language->id)); - $smarty->assign('ps_stock_mvt_reason_default', $ps_stock_mvt_reason_default = Configuration::get('PS_STOCK_MVT_REASON_DEFAULT')); - $smarty->assign('minimal_quantity', $this->getFieldValue($product, 'minimal_quantity') ? $this->getFieldValue($product, 'minimal_quantity') : 1); - $smarty->assign('available_date', ($this->getFieldValue($product, 'available_date') != 0) ? stripslashes(htmlentities(Tools::displayDate($this->getFieldValue($product, 'available_date'), $language['id_lang']))) : '0000-00-00'); + $data->assign('reasons', $reasons = StockMvtReason::getStockMvtReasons($this->context->language->id)); + $data->assign('ps_stock_mvt_reason_default', $ps_stock_mvt_reason_default = Configuration::get('PS_STOCK_MVT_REASON_DEFAULT')); + $data->assign('minimal_quantity', $this->getFieldValue($product, 'minimal_quantity') ? $this->getFieldValue($product, 'minimal_quantity') : 1); + $data->assign('available_date', ($this->getFieldValue($product, 'available_date') != 0) ? stripslashes(htmlentities(Tools::displayDate($this->getFieldValue($product, 'available_date'), $language['id_lang']))) : '0000-00-00'); // date picker include $i = 0; - $smarty->assign('imageType', ImageType::getByNameNType('small', 'products')); - $smarty->assign('imageWidth', (isset($imageType['width']) ? (int)($imageType['width']) : 64) + 25); + $data->assign('imageType', ImageType::getByNameNType('small', 'products')); + $data->assign('imageWidth', (isset($imageType['width']) ? (int)($imageType['width']) : 64) + 25); foreach ($images as $k => $image) { $images[$k]['obj'] = new Image($image['id_image']); ++$i; } - $smarty->assign('images', $images); - $content .= ' -
+ $data->assign('images', $images); + } + else + $content .= ''.$this->l('You must save this product before adding combinations').'.'; + + // @todo + $data->assign('up_filename', strval(Tools::getValue('virtual_product_filename_attribute'))); + $data->assign($this->tpl_form_vars); + $data->assign(array( + 'list' => $this->renderListAttributes($id_product_download, $product, $currency), + 'product' => $product, + 'id_category' => $product->id_category_default, + 'token_generator' => Tools::getAdminTokenLite('AdminAttributeGenerator') + )); + $this->tpl_form_vars['custom_form'] = $this->context->smarty->createTemplate($this->tpl_form, $data)->fetch(); + } + + public function renderListAttributes($id_product_download, $product, $currency) + { + $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + $this->addRowAction('edit'); + $this->addRowAction('default'); + $this->addRowAction('delete'); + + $color_by_default = '#BDE5F8'; + + $this->fieldsDisplay = array( + 'attributes' => array('title' => $this->l('Attributes'), 'align' => 'center', 'width' => 70), + 'price' => array('title' => $this->l('Impact'), 'type' => 'price', 'align' => 'center', 'width' => 70), + 'weight' => array('title' => $this->l('Weight'), 'align' => 'center', 'width' => 70), + 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 70), + 'ean13' => array('title' => $this->l('EAN13'), 'align' => 'center', 'width' => 70), + 'upc' => array('title' => $this->l('UPC'), 'align' => 'center', 'width' => 70) + ); + + if ($id_product_download && !empty($productDownload->display_filename)) + { + $this->fieldsDisplay['Filename'] = array('title' => $this->l('Filename'), 'align' => 'center', 'width' => 70); + $this->fieldsDisplay['nb_downloadable'] = array('title' => $this->l('Number of downloads'), 'align' => 'center', 'width' => 70); + $this->fieldsDisplay['date_expiration'] = array('title' => $this->l('Number of days'), 'align' => 'center', 'width' => 70); + $this->fieldsDisplay['is_shareable'] = array('title' => $this->l('Share'), 'align' => 'center', 'width' => 70); + } + + if ($product->id) + { + /* Build attributes combinaisons */ + $combinaisons = $product->getAttributeCombinaisons($this->context->language->id); + $groups = array(); + $combArray = array(); + if (is_array($combinaisons)) + { + $combinationImages = $product->getCombinationImages($this->context->language->id); + foreach ($combinaisons as $k => $combinaison) + { + if ($currency->format % 2 != 0) + $price = $currency->sign.' '.$combinaison['price']; + else + $price = $combinaison['price'].' '.$currency->sign; + + $combArray[$combinaison['id_product_attribute']]['id_combinaison_attribute'] = $product->id.'||'.$combinaison['id_product_attribute']; + $combArray[$combinaison['id_product_attribute']]['id_product_attribute'] = $combinaison['id_product_attribute']; + $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']); + $combArray[$combinaison['id_product_attribute']]['wholesale_price'] = $combinaison['wholesale_price']; + $combArray[$combinaison['id_product_attribute']]['price'] = $price; + $combArray[$combinaison['id_product_attribute']]['weight'] = $combinaison['weight'].Configuration::get('PS_WEIGHT_UNIT'); + $combArray[$combinaison['id_product_attribute']]['unit_impact'] = $combinaison['unit_price_impact']; + $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference']; + $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13']; + $combArray[$combinaison['id_product_attribute']]['upc'] = $combinaison['upc']; + $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']]['available_date'] = strftime($combinaison['available_date']); + $combArray[$combinaison['id_product_attribute']]['default_on'] = $combinaison['default_on']; + /*$combArray[$combinaison['id_product_attribute']]['minimal_quantity'] = $combinaison['minimal_quantity']; + $combArray[$combinaison['id_product_attribute']]['ecotax'] = $combinaison['ecotax'];*/ + if ($combinaison['is_color_group']) + $groups[$combinaison['id_attribute_group']] = $combinaison['group_name']; + } + } + + $irow = 0; + if (isset($combArray)) + { + foreach ($combArray as $id_product_attribute => $product_attribute) + { + $list = ''; + $jsList = ''; + + /* In order to keep the same attributes order */ + asort($product_attribute['attributes']); + + foreach ($product_attribute['attributes'] as $attribute) + { + $list .= addslashes(htmlspecialchars($attribute[0])).' - '.addslashes(htmlspecialchars($attribute[1])).', '; + $jsList .= '\''.addslashes(htmlspecialchars($attribute[0])).' : '.addslashes(htmlspecialchars($attribute[1])).'\', \''.$attribute[2].'\', '; + } + $list = rtrim($list, ', '); + $jsList = rtrim($jsList, ', '); + $combArray[$id_product_attribute]['image'] = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false; + $combArray[$id_product_attribute]['available_date'] = $product_attribute['available_date'] != 0 ? date('Y-m-d', strtotime($product_attribute['available_date'])) : '0000-00-00'; + $combArray[$id_product_attribute]['attributes'] = $list; + if ($product_attribute['default_on']) + { + $this->list_skip_actions['default'][] = $product_attribute['id_combinaison_attribute']; + $combArray[$id_product_attribute]['color']= $color_by_default; + } + + $id_product_download = $product->productDownload->getIdFromIdAttribute((int) $product->id, (int) $id_product_attribute); + if ($id_product_download) + $product->productDownload = new ProductDownload($id_product_download); + + $available_date_attribute = substr($product->productDownload->date_expiration, 0, -9); + + if ($available_date_attribute == '0000-00-00') + $available_date_attribute = ''; + + if ($id_product_download && !empty($product->productDownload->display_filename)) + { + if ($product->productDownload->is_shareable == 1) + $is_shareable = $this->l('Yes'); + else + $is_shareable = $this->l('No'); + + $combArray[$id_product_attribute]['link'] = $product->productDownload->getHtmlLink(false, true); + $combArray[$id_product_attribute]['nb_downloadable'] = $product->productDownload->nb_downloadable; + $combArray[$id_product_attribute]['is_shareable'] = $is_shareable; + } + + $exists_file = realpath(_PS_DOWNLOAD_DIR_).'/'.$product->productDownload->filename; + + if ($product->productDownload->id && file_exists($exists_file)) + $filename = $product->productDownload->filename; + else + $filename = ''; + + //$combArray[$id_product_attribute]['productDownload'] = $product->productDownload; + $combArray[$id_product_attribute]['id_product_download'] = $id_product_download; + $combArray[$id_product_attribute]['date_expiration'] = $available_date_attribute; + $combArray[$id_product_attribute]['filename'] = $filename; + } + } + } + + foreach ($this->actions_available as $action) + { + if (!in_array($action, $this->actions) && isset($this->$action) && $this->$action) + $this->actions[] = $action; + } + + $helper = new HelperList(); + $helper->identifier = 'id_combinaison_attribute'; + $helper->token = $this->token; + $helper->currentIndex = self::$currentIndex; + $helper->no_link = true; + $helper->simple_header = true; + $helper->show_toolbar = false; + $helper->shopLinkType = $this->shopLinkType; + $helper->actions = $this->actions; + $helper->list_skip_actions = $this->list_skip_actions; + $helper->colorOnBackground = true; + $helper->override_folder = $this->tpl_folder.'combinaison/'; + + return $helper->generateList($combArray, $this->fieldsDisplay); + + $content = ''; + $content .= ' - - - + + + + - -
+
+
+

@@ -3022,141 +3227,131 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $content .= ''; - if ($product->id) - { - /* Build attributes combinaisons */ - $combinaisons = $product->getAttributeCombinaisons($this->context->language->id); - $groups = array(); - if (is_array($combinaisons)) - { - $combinationImages = $product->getCombinationImages($this->context->language->id); - foreach ($combinaisons as $k => $combinaison) - { - $combArray[$combinaison['id_product_attribute']]['wholesale_price'] = $combinaison['wholesale_price']; - $combArray[$combinaison['id_product_attribute']]['price'] = $combinaison['price']; - $combArray[$combinaison['id_product_attribute']]['weight'] = $combinaison['weight']; - $combArray[$combinaison['id_product_attribute']]['unit_impact'] = $combinaison['unit_price_impact']; - $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference']; - $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13']; - $combArray[$combinaison['id_product_attribute']]['upc'] = $combinaison['upc']; - $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']]['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']; - $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']); - if ($combinaison['is_color_group']) - $groups[$combinaison['id_attribute_group']] = $combinaison['group_name']; - } - } - $irow = 0; - if (isset($combArray)) - { - foreach ($combArray as $id_product_attribute => $product_attribute) - { - $list = ''; - $jsList = ''; - /* In order to keep the same attributes order */ - asort($product_attribute['attributes']); - - foreach ($product_attribute['attributes'] as $attribute) + if ($product->id) { - $list .= addslashes(htmlspecialchars($attribute[0])).' - '.addslashes(htmlspecialchars($attribute[1])).', '; - $jsList .= '\''.addslashes(htmlspecialchars($attribute[0])).' : '.addslashes(htmlspecialchars($attribute[1])).'\', \''.$attribute[2].'\', '; - } - $list = rtrim($list, ', '); - $jsList = rtrim($jsList, ', '); - $attrImage = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false; - $available_date = ($product_attribute['available_date'] != 0) ? date('Y-m-d', strtotime($product_attribute['available_date'])) : '0000-00-00'; - - $id_product_download = $product->productDownload->getIdFromIdAttribute((int) $product->id, (int) $id_product_attribute); - if ($id_product_download) - $product->productDownload = new ProductDownload($id_product_download); - - $available_date_attribute = substr($product->productDownload->date_expiration, 0, -9); - - if ($available_date_attribute == '0000-00-00') - $available_date_attribute = ''; - - if ($product->productDownload->is_shareable == 1) - $is_shareable = $this->l('Yes'); - else - $is_shareable = $this->l('No'); - - $content .= ' - - - - - - - '; - - if ($id_product_download && !empty($product->productDownload->display_filename)) + /* Build attributes combinaisons */ + $combinaisons = $product->getAttributeCombinaisons($this->context->language->id); + $groups = array(); + if (is_array($combinaisons)) { - $content .= ' - - - '; + $combinationImages = $product->getCombinationImages($this->context->language->id); + foreach ($combinaisons as $k => $combinaison) + { + $combArray[$combinaison['id_product_attribute']]['wholesale_price'] = $combinaison['wholesale_price']; + $combArray[$combinaison['id_product_attribute']]['price'] = $combinaison['price']; + $combArray[$combinaison['id_product_attribute']]['weight'] = $combinaison['weight']; + $combArray[$combinaison['id_product_attribute']]['unit_impact'] = $combinaison['unit_price_impact']; + $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference']; + $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13']; + $combArray[$combinaison['id_product_attribute']]['upc'] = $combinaison['upc']; + $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']]['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']; + $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']); + if ($combinaison['is_color_group']) + $groups[$combinaison['id_attribute_group']] = $combinaison['group_name']; + } } - $exists_file = realpath(_PS_DOWNLOAD_DIR_).'/'.$product->productDownload->filename; - - if ($product->productDownload->id && file_exists($exists_file)) - $filename = $product->productDownload->filename; + $irow = 0; + if (isset($combArray)) + { + foreach ($combArray as $id_product_attribute => $product_attribute) + { + $list = ''; + $jsList = ''; + + /* In order to keep the same attributes order */ + asort($product_attribute['attributes']); + + foreach ($product_attribute['attributes'] as $attribute) + { + $list .= addslashes(htmlspecialchars($attribute[0])).' - '.addslashes(htmlspecialchars($attribute[1])).', '; + $jsList .= '\''.addslashes(htmlspecialchars($attribute[0])).' : '.addslashes(htmlspecialchars($attribute[1])).'\', \''.$attribute[2].'\', '; + } + $list = rtrim($list, ', '); + $jsList = rtrim($jsList, ', '); + $attrImage = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false; + $available_date = ($product_attribute['available_date'] != 0) ? date('Y-m-d', strtotime($product_attribute['available_date'])) : '0000-00-00'; + + $id_product_download = $product->productDownload->getIdFromIdAttribute((int) $product->id, (int) $id_product_attribute); + if ($id_product_download) + $product->productDownload = new ProductDownload($id_product_download); + + $available_date_attribute = substr($product->productDownload->date_expiration, 0, -9); + + if ($available_date_attribute == '0000-00-00') + $available_date_attribute = ''; + + if ($product->productDownload->is_shareable == 1) + $is_shareable = $this->l('Yes'); + else + $is_shareable = $this->l('No'); + + $content .= ' + + + + + + + '; + + if ($id_product_download && !empty($product->productDownload->display_filename)) + { + $content .= ' + + + '; + } + + $exists_file = realpath(_PS_DOWNLOAD_DIR_).'/'.$product->productDownload->filename; + + if ($product->productDownload->id && file_exists($exists_file)) + $filename = $product->productDownload->filename; + else + $filename = ''; + // @todo : a better way to "fillCombinaison" maybe ? + $content .= ' + '; + } + $content .= ''; + } else - $filename = ''; - // @todo : a better way to "fillCombinaison" maybe ? - $content .= ' - '; - } - $content .= ''; - } - else - $content .= ''; - } - $content .= ' -
'.$this->l('Actions').'
'.stripslashes($list).''.($currency->format % 2 != 0 ? $currency->sign.' ' : '').$product_attribute['price'].($currency->format % 2 == 0 ? ' '.$currency->sign : '').''.$product_attribute['weight'].Configuration::get('PS_WEIGHT_UNIT').''.$product_attribute['reference'].''.$product_attribute['ean13'].''.$product_attribute['upc'].''.$product->productDownload->getHtmlLink(false, true).''.$product->productDownload->nb_downloadable.''.$product->productDownload->nb_downloadable.''.$is_shareable.''.stripslashes($list).''.($currency->format % 2 != 0 ? $currency->sign.' ' : '').$product_attribute['price'].($currency->format % 2 == 0 ? ' '.$currency->sign : '').''.$product_attribute['weight'].Configuration::get('PS_WEIGHT_UNIT').''.$product_attribute['reference'].''.$product_attribute['ean13'].''.$product_attribute['upc'].''.$product->productDownload->getHtmlLink(false, true).''.$product->productDownload->nb_downloadable.''.$product->productDownload->nb_downloadable.''.$is_shareable.' + + '.$this->l('Modify this combination').'  + '.(!$product_attribute['default_on'] ? ' + '.$this->l('Make this the default combination').'' : '').' + + '.$this->l('Delete this combination').'
'.$this->l('Delete this combination').' '.$this->l('Delete all combinations').'
- - '.$this->l('Modify this combination').'  - '.(!$product_attribute['default_on'] ? ' - '.$this->l('Make this the default combination').'' : '').' - - '.$this->l('Delete this combination').'
'.$this->l('Delete this combination').' '.$this->l('Delete all combinations').'
'.$this->l('No combination yet').'.
-
'.$this->l('The row in blue is the default combination.').' -
- '.$this->l('A default combination must be designated for each product.').' -
- '; - } - else - $content .= ''.$this->l('You must save this product before adding combinations').'.'; - // @todo - $smarty->assign('up_filename', strval(Tools::getValue('virtual_product_filename_attribute'))); - $this->context->smarty->assign($this->tpl_form_vars); - $this->context->smarty->assign(array( - 'content' => $content, - 'product' => $product, - 'id_category' => $product->id_category_default, - 'token_generator' => Tools::getAdminTokenLite('AdminAttributeGenerator') - )); - $this->tpl_form_vars['custom_form'] = $this->context->smarty->fetch('products/combinations.tpl'); + $content .= ''.$this->l('No combination yet').'.'; + } + $content .= ' + +
'.$this->l('The row in blue is the default combination.').' +
+ '.$this->l('A default combination must be designated for each product.').' + + + + '; + return $content; } public function initFormQuantities($obj) @@ -3589,4 +3784,24 @@ public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $this->addJqueryPlugin('ajaxfileupload'); $this->addJqueryPlugin('date'); } + + public function setMedia() + { + parent::setMedia(); + + $this->addjQueryPlugin('fileuploader'); + + $this->addJqueryUI(array( + 'ui.core', + 'ui.widget', + 'ui.progressbar' + )); + + $this->addJS(array( + _PS_JS_DIR_.'admin-products.js', + _PS_JS_DIR_.'price.js', + _PS_JS_DIR_.'tiny_mce/tiny_mce.js', + _PS_JS_DIR_.'tinymce.inc.js' + )); + } } diff --git a/controllers/admin/AdminShippingController.php b/controllers/admin/AdminShippingController.php index 2007bd525..892af710b 100644 --- a/controllers/admin/AdminShippingController.php +++ b/controllers/admin/AdminShippingController.php @@ -64,7 +64,7 @@ class AdminShippingControllerCore extends AdminController 'validation' => 'isUnsignedFloat'), ), 'description' => - '
    + '
    • '.$this->l('If you set these parameters to 0, they will be disabled').'
    • '.$this->l('Coupons are not taken into account when calculating free shipping').'
    ', diff --git a/js/admin-products.js b/js/admin-products.js index 6308a2967..ec440d1a4 100644 --- a/js/admin-products.js +++ b/js/admin-products.js @@ -23,6 +23,115 @@ * International Registered Trademark & Property of PrestaShop SA */ +function deleteProductAttribute(ids, token, parent) +{ + var id = ids.split('||'); + $.ajax({ + url: 'index.php', + data: { + id_product: id[0], + id_product_attribute: id[1], + controller: 'AdminProducts', + token: token, + action: 'deleteProductAttribute', + ajax: true + }, + context: document.body, + dataType: 'json', + context: this, + async: false, + success: function(data) { + if (data.status == 'ok') + { + showSuccessMessage(data.message); + parent.hide(); + } + else + showErrorMessage(data.message); + } + }); +} + +function defaultProductAttribute(ids, token, parent) +{ + var id = ids.split('||'); + $.ajax({ + url: 'index.php', + data: { + id_product: id[0], + id_product_attribute: id[1], + controller: 'AdminProducts', + token: token, + action: 'defaultProductAttribute', + ajax: true + }, + context: document.body, + dataType: 'json', + context: this, + async: false, + success: function(data) { + if (data.status == 'ok') + { + showSuccessMessage(data.message); + $('table.table').find('tr').each(function(){ + $(this).attr('style', ''); + }); + parent.find('a.default').hide(); + parent.css('background','#BDE5F8'); + } + else + showErrorMessage(data.message); + } + }); +} + +function editProductAttribute(ids, token) +{ + var id = ids.split('||'); + $.ajax({ + url: 'index.php', + data: { + id_product: id[0], + id_product_attribute: id[1], + controller: 'AdminProducts', + token: token, + action: 'editProductAttribute', + ajax: true + }, + context: document.body, + dataType: 'json', + context: this, + async: false, + success: function(data) { + $('#add_new_combination').show(); + console.log(data[0]); + console.log(data[1]); + for(i=0;i'+data[i]['group_name']+' : '+data[i]['attribute_name']+''); + $('#attribute_reference').val(data[i]['reference']); + $('#attribute_ean13').val(data[i]['ean13']); + $('#attribute_upc').val(data[i]['upc']); + $('#attribute_wholesale_price').val(Math.abs(data[i]['wholesale_price'])); + $('#attribute_price').val(Math.abs(data[i]['price'])); + $('#attribute_priceTI').val(data[i]['attribute_reference']); + $('#attribute_weight').val(Math.abs(data[i]['weight'])); + $('#attribute_unity').val(Math.abs(data[i]['unit_price_impact'])); + if ($('#attribute_ecotax').length != 0) + $('#attribute_ecotax').val(data[i]['ecotax']); + $('#minimal_quantity').val(data[i]['minimal_quantity']); + $('#attribute_minimal_quantity').val(data[i]['minimal_quantity']); + $('#available_date').val(data[i]['available_date']); + + if (data[i]['default_on'] == 1) + $('#attribute_default').checked = true; + else + $('#attribute_default').checked = false; + } + } + }); +} + function addPackItem() { if ($('#curPackItemId').val() == '' || $('#curPackItemName').val() == '')