From 80ecb65475e2b3fdf044b80f36b1dd5bb540cbf3 Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Fri, 9 Dec 2011 14:22:46 +0000 Subject: [PATCH] // Commit new tabs in product edition git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11079 b9a71923-0436-4b27-9f14-aed3839534dd --- .../themes/template/products/associations.tpl | 47 ++++++ .../themes/template/products/informations.tpl | 82 +--------- admin-dev/themes/template/products/prices.tpl | 1 + .../themes/template/products/shipping.tpl | 69 +++++++++ classes/helper/Helper.php | 7 +- controllers/admin/AdminProductsController.php | 144 +++++++++++------- css/admin.css | 11 ++ js/admin-categories-tree.js | 5 +- js/admin-products.js | 3 +- 9 files changed, 229 insertions(+), 140 deletions(-) create mode 100644 admin-dev/themes/template/products/associations.tpl create mode 100644 admin-dev/themes/template/products/shipping.tpl diff --git a/admin-dev/themes/template/products/associations.tpl b/admin-dev/themes/template/products/associations.tpl new file mode 100644 index 000000000..1186a7200 --- /dev/null +++ b/admin-dev/themes/template/products/associations.tpl @@ -0,0 +1,47 @@ +{* +* 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='Product price'}

+
+ + + {**} + +
{$category_tree}
+
+ - - - - {$category_tree}
{************** DESCRIPTION *****************************} diff --git a/admin-dev/themes/template/products/prices.tpl b/admin-dev/themes/template/products/prices.tpl index 67dff1a38..a9b095af9 100644 --- a/admin-dev/themes/template/products/prices.tpl +++ b/admin-dev/themes/template/products/prices.tpl @@ -24,6 +24,7 @@ * International Registered Trademark & Property of PrestaShop SA *} +

{l s='Product price'}

diff --git a/admin-dev/themes/template/products/shipping.tpl b/admin-dev/themes/template/products/shipping.tpl new file mode 100644 index 000000000..6605d9f5e --- /dev/null +++ b/admin-dev/themes/template/products/shipping.tpl @@ -0,0 +1,69 @@ +{* +* 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 +*} + +

1. {l s='Info.'}

+

{l s='Shipping'}

+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ {$ps_dimension_unit} +
+ {$ps_dimension_unit} +
+ {$ps_dimension_unit} +
+ {$ps_weight_unit} +
+ + + +
diff --git a/classes/helper/Helper.php b/classes/helper/Helper.php index 1be91a9ba..798ea935c 100755 --- a/classes/helper/Helper.php +++ b/classes/helper/Helper.php @@ -129,8 +129,7 @@ class HelperCore $context = Context::getContext(); $context->controller->addCSS(_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.css'); - - + $context->controller->addJs(array( _PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.js', _PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.async.js', @@ -158,6 +157,9 @@ class HelperCore var selectedLabel = \''.$trads['selected'].'\'; var home = \''.$trads['Home'].'\'; var use_radio = '.(int)$use_radio.'; + $(document).ready(function(){ + buildTreeView(); + }); '; $html .= ' @@ -172,6 +174,7 @@ class HelperCore '; $home_is_selected = false; + foreach($selected_cat AS $cat) { if (is_array($cat)) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 7ab3ea7f4..4ae87b4a6 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -40,6 +40,8 @@ class AdminProductsControllerCore extends AdminController 'Informations', 'Prices', 'Images', + 'Associations', + 'Shipping', 'Combinations', 'Features', 'Customization', @@ -52,6 +54,22 @@ class AdminProductsControllerCore extends AdminController protected $available_tabs_lang = array (); + protected $tabs_toolbar_save_buttons = array( + 'Informations' => true, + 'Images' => false, + 'Prices' => false, + 'Associations' => true, + 'Shipping' => true, + 'Combinations' => false, + 'Features' => true, + 'Customization' => false, + 'Attachments' => true, + 'Quantities' => false, + 'Suppliers' => true, + 'Warehouses' => true, + 'Accounting' => true + ); + public function __construct() { $this->table = 'product'; @@ -85,6 +103,8 @@ class AdminProductsControllerCore extends AdminController 'Informations' => $this->l('Informations'), 'Prices' => $this->l('Prices'), 'Images' => $this->l('Images'), + 'Associations' => $this->l('Associations'), + 'Shipping' => $this->l('Shipping'), 'Combinations' => $this->l('Combinations'), 'Features' => $this->l('Features'), 'Customization' => $this->l('Customization'), @@ -1484,13 +1504,6 @@ class AdminProductsControllerCore extends AdminController } } - // The oos behavior MUST be "Deny orders" for virtual products - if (Tools::getValue('out_of_stock') != 0) - { - $this->_errors[] = $this->l('The "when out of stock" behavior selection must be "deny order" for virtual products'); - return false; - } - // Trick's if ($edit == 1) { @@ -1647,6 +1660,7 @@ class AdminProductsControllerCore extends AdminController $this->tpl_form_vars['show_product_tab_content'] = Tools::getValue('action'); if (Tools::getValue('id_product') || ((Tools::isSubmit('submitAddproduct') OR Tools::isSubmit('submitAddproductAndPreview') OR Tools::isSubmit('submitAddproductAndStay') OR Tools::isSubmit('submitSpecificPricePriorities') OR Tools::isSubmit('submitPriceAddition') OR Tools::isSubmit('submitPricesModification')) AND count($this->_errors)) OR Tools::isSubmit('updateproduct') OR Tools::isSubmit('addproduct')) { + $this->addJS(_PS_JS_DIR_.'admin-products.js'); $this->fields_form = array(); if (empty($this->action)) $this->action = 'Informations'; @@ -1917,6 +1931,7 @@ class AdminProductsControllerCore extends AdminController { if(!method_exists($this, 'initForm'.$this->action)) return; + $this->addJqueryUI('ui.datepicker'); // getLanguages init this->_languages $this->getLanguages(); @@ -1951,6 +1966,7 @@ class AdminProductsControllerCore extends AdminController else return $this->tpl_form_vars['custom_form']; } + return parent::renderForm(); } @@ -2321,6 +2337,43 @@ class AdminProductsControllerCore extends AdminController $this->tpl_form_vars['custom_form'] = $this->context->smarty->createTemplate($this->tpl_form, $data)->fetch(); } + public function initFormAssociations($obj) + { + $product = $this->object; + $data = $this->context->smarty->createData(); + // Prepare Categories tree for display in Associations tab + $default_category = Tools::getValue('id_category', 1); + + if (!$product->id) + $selected_cat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language); + else + { + if (Tools::isSubmit('categoryBox')) + $selected_cat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language); + else + $selected_cat = Product::getProductCategoriesFull($product->id, $this->default_form_language); + } + + $translations = array( + 'Home' => $this->l('Home'), + 'selected' => $this->l('selected'), + 'Collapse All' => $this->l('Collapse All'), + 'Expand All' => $this->l('Expand All'), + 'Check All' => $this->l('Check All'), + 'Uncheck All' => $this->l('Uncheck All'), + 'search' => $this->l('Search a category') + ); + + $data->assign(array('default_category' => $default_category, + 'selected_cat_ids' => implode(',', array_keys($selected_cat)), + 'selected_cat' => $selected_cat, + 'category_tree' => Helper::renderAdminCategorieTree($translations, $selected_cat, 'categoryBox', false, true), + 'product' => $product + )); + + $this->tpl_form_vars['custom_form'] = $this->context->smarty->createTemplate($this->tpl_form, $data)->fetch(); + } + public function initFormPrices($obj, $languages, $default_language) { $data = $this->context->smarty->createData(); @@ -2331,7 +2384,6 @@ class AdminProductsControllerCore extends AdminController $countries = Country::getCountries($this->context->language->id); $groups = Group::getGroups($this->context->language->id); $currencies = Currency::getCurrencies(); - $currency = $attributes = $obj->getAttributesGroups((int)$this->context->language->id); $combinations = array(); foreach($attributes as $attribute) @@ -2672,6 +2724,7 @@ class AdminProductsControllerCore extends AdminController $currency = $this->context->currency; $data->assign('languages',$languages); + $data->assign('currency', $currency); $this->object = $product; $this->display = 'edit'; $has_attribute = $product->hasAttributes(); @@ -2679,7 +2732,7 @@ class AdminProductsControllerCore extends AdminController $this->_applyTaxToEcotax($product); /* - * Form for add a virtual product like software, mp3, etc... + * Form for adding a virtual product like software, mp3, etc... */ $product_download = new ProductDownload(); if ($id_product_download = $product_download->getIdFromIdProduct($this->getFieldValue($product, 'id'))) @@ -2691,8 +2744,6 @@ class AdminProductsControllerCore extends AdminController $data->assign('feature_shop_active', Shop::isFeatureActive()); // @todo : uses the helperform $data->assign('displayAssoShop', $this->displayAssoShop()); - $data->assign('carrier_list', $this->getCarrierList()); - $product_props = array(); // global informations @@ -2714,7 +2765,7 @@ class AdminProductsControllerCore extends AdminController array_push($product_props, 'price', 'wholesale_price', 'id_tax_rules_group', 'unit_price_ratio', 'on_sale', 'unity', 'minimum_quantity', 'additional_shipping_cost', - 'available_now', 'available_later', 'available_date', 'out_of_stock' + 'available_now', 'available_later', 'available_date' ); if(Configuration::get('PS_USE_ECOTAX')) @@ -2729,8 +2780,6 @@ class AdminProductsControllerCore extends AdminController $product->manufacturer_name = Manufacturer::getNameById($product->id_manufacturer); - $data->assign('ps_dimension_unit', Configuration::get('PS_DIMENSION_UNIT')); - $data->assign('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT')); // @todo : initPack should not be called like this $this->initPack($product); @@ -2799,35 +2848,6 @@ class AdminProductsControllerCore extends AdminController if (Combination::isFeatureActive()) $data->assign('countAttributes', (int)Db::getInstance()->getValue('SELECT COUNT(id_product) FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.(int)$product->id)); - $data->assign('ps_order_out_of_stock', Configuration::get('PS_ORDER_OUT_OF_STOCK')); - - $default_category = Tools::getValue('id_category', 1); - $data->assign('default_category', $default_category); - if (!$product->id) - { - $selectedCat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language); - } - else - { - if (Tools::isSubmit('categoryBox')) - $selectedCat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language); - else - $selectedCat = Product::getProductCategoriesFull($product->id, $this->default_form_language); - } - $data->assign('selected_cat_ids', implode(',', array_keys($selectedCat))); - $data->assign('selected_cat', $selectedCat); - - $trads = array( - 'Home' => $this->l('Home'), - 'selected' => $this->l('selected'), - 'Collapse All' => $this->l('Collapse All'), - 'Expand All' => $this->l('Expand All'), - 'Check All' => $this->l('Check All'), - 'Uncheck All' => $this->l('Uncheck All'), - 'search' => $this->l('Search a category') - ); - $data->assign('category_tree', Helper::renderAdminCategorieTree($trads, $selectedCat, 'categoryBox', false, true)); - $images = Image::getImages($this->context->language->id, $product->id); foreach($images as $k => $image) @@ -2836,17 +2856,17 @@ class AdminProductsControllerCore extends AdminController $data->assign('images', $images); $data->assign('imagesTypes', ImageType::getImagesTypes('products')); - $accessories = Product::getAccessoriesLight($this->context->language->id, $product->id); + $accessories = Product::getAccessoriesLight($this->context->language->id, $product->id); - if ($postAccessories = Tools::getValue('inputAccessories')) - { - $postAccessoriesTab = explode('-', Tools::getValue('inputAccessories')); - foreach ($postAccessoriesTab as $accessory_id) - if (!$this->haveThisAccessory($accessory_id, $accessories) && $accessory = Product::getAccessoryById($accessory_id)) - $accessories[] = $accessory; - } - $data->assign('accessories', $accessories); - $product->tags = Tag::getProductTags($product->id); + if ($postAccessories = Tools::getValue('inputAccessories')) + { + $postAccessoriesTab = explode('-', Tools::getValue('inputAccessories')); + foreach ($postAccessoriesTab as $accessory_id) + if (!$this->haveThisAccessory($accessory_id, $accessories) && $accessory = Product::getAccessoryById($accessory_id)) + $accessories[] = $accessory; + } + $data->assign('accessories', $accessories); + $product->tags = Tag::getProductTags($product->id); // TinyMCE $iso_tiny_mce = $this->context->language->iso_code; @@ -2863,6 +2883,18 @@ class AdminProductsControllerCore extends AdminController $this->tpl_form_vars['custom_form'] = $this->context->smarty->createTemplate($this->tpl_form, $data)->fetch(); } + public function initFormShipping($obj, $token = null) + { + $data = $this->context->smarty->createData(); + $data->assign(array( + 'product' => $obj, + 'ps_dimension_unit' => Configuration::get('PS_DIMENSION_UNIT'), + 'ps_weight_unit' => Configuration::get('PS_WEIGHT_UNIT'), + 'carrier_list' => $this->getCarrierList() + )); + $this->tpl_form_vars['custom_form'] = $this->context->smarty->createTemplate($this->tpl_form, $data)->fetch(); + } + protected function getCarrierList() { $carrier_list = Carrier::getCarriers($this->context->language->id); @@ -3567,7 +3599,11 @@ class AdminProductsControllerCore extends AdminController _PS_JS_DIR_.'tiny_mce/tiny_mce.js', _PS_JS_DIR_.'tinymce.inc.js', _PS_JS_DIR_.'fileuploader.js', - _PS_JS_DIR_.'admin-dnd.js' + _PS_JS_DIR_.'admin-dnd.js', + _PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.js', + _PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.async.js', + _PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.edit.js', + _PS_JS_DIR_.'admin-categories-tree.js' )); } } diff --git a/css/admin.css b/css/admin.css index 8badab8f4..2fc806768 100644 --- a/css/admin.css +++ b/css/admin.css @@ -1982,4 +1982,15 @@ div#scrollTop a:hover{ opacity:0.8; } +.loader{ + display:none; + margin: 450px 0 0 440px; + height:128px; + width:128px; + color:#fff; + background-image:url(../img/loader.gif); +} +#category_block{ + width: +} \ No newline at end of file diff --git a/js/admin-categories-tree.js b/js/admin-categories-tree.js index 6422c78fe..dbf01d807 100755 --- a/js/admin-categories-tree.js +++ b/js/admin-categories-tree.js @@ -32,7 +32,8 @@ var intervalCheck = null; var id = 0; var arrayCatToExpand = new Array(); -$(document).ready(function(){ +function buildTreeView() +{ $("#categories-treeview").treeview({ url : 'ajax.php', toggle: function () { callbackToggle($(this)); }, @@ -73,7 +74,7 @@ $(document).ready(function(){ uncheckAllCategories(); return false; }); -}); +} function callbackToggle(element) { diff --git a/js/admin-products.js b/js/admin-products.js index 6b4592f1b..fe872c453 100644 --- a/js/admin-products.js +++ b/js/admin-products.js @@ -345,10 +345,9 @@ $(document).ready(function() { $("#is_virtual_good").change(function(e) { - $(".toggleVirtualPhysicalProduct").toggle(); + $("#virtual_good").toggle(); }); - if ($("#is_virtual_good").attr("checked")) { $("#virtual_good").show();