// 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
This commit is contained in:
tDidierjean
2011-12-09 14:22:46 +00:00
parent 43ff904c57
commit 80ecb65475
9 changed files with 229 additions and 140 deletions

View File

@@ -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 <contact@prestashop.com>
* @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
*}
<div class="Associations">
<h4>{l s='Product price'}</h4>
<div class="separation"></div>
<label for="id_category_default" class="t">
{l s='Default category:'}
</label>
<div id="no_default_category" style="color: red;font-weight: bold;display: none;">
{l s='Please check a category in order to select the default category.'}
</div>
{*<script type="text/javascript">
var post_selected_cat;
post_selected_cat = '{$selected_cat_ids}';
</script>*}
<select id="id_category_default" name="id_category_default">
{foreach from=$selected_cat item=cat}
<option value="{$cat.id_category}" {if $product->id_category_default == $cat.id_category}selected="selected"{/if} >{$cat.name}</option>
{/foreach}
</select>
<div id="category_block">{$category_tree}</div>
</div>
<script type="text/javascript">

View File

@@ -158,7 +158,7 @@
{/if}
<option disabled="disabled">----------</option>
</select>&nbsp;&nbsp;&nbsp;
<a href="{$link->getAdminLink('AdminManufacturer')}&addmanufacturer" onclick="return confirm('{l s='Are you sure you want to delete product information entered?' js=1} ')">
<a href="{$link->getAdminLink('AdminManufacturers')}&addmanufacturer" onclick="return confirm('{l s='Are you sure you want to delete product information entered?' js=1} ')">
<img src="../img/admin/add.gif" alt="{l s='Create'}" title="{l s='Create'}" /> <b>{l s='Create'}</b>
</a>
</td>
@@ -215,51 +215,6 @@ var textFieldLabel = 0;
<p><input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" {*onclick="toggleVirtualProduct(this);"*} {if $product->is_virtual && $product->productDownload->active}checked="checked"{/if} />
<label for="is_virtual_good" class="t bold" style="color: black;">{l s='Is this a virtual product?'}</label>
</p>
{* [begin] physical product infos *}
<div id="physical_good" class="toggleVirtualPhysicalProduct" {if $product->productDownload->id && $product->productDownload->active}style="display:none"{/if} >
<div class="separation"></div>
<table cellpadding="5" style="width: 50%; float: left; margin-right: 20px; border-right: 1px solid #CCCCCC;">
<tr>
<td class="col-left"><label>{l s='Width ( package ) :' }</label></td>
<td style="padding-bottom:5px;">
<input size="6" maxlength="6" name="width" type="text" value="{$product->width}" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.');" /> {$ps_dimension_unit}
</td>
</tr>
<tr>
<td class="col-left"><label>{l s='Height ( package ) :' }</label></td>
<td style="padding-bottom:5px;">
<input size="6" maxlength="6" name="height" type="text" value="{$product->height}" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.');" /> {$ps_dimension_unit}
</td>
</tr>
<tr>
<td class="col-left">
<label>Carriers:</label>
</td>
<td class="padding-bottom:5px;">
<select name="carriers[]" multiple="multiple" size="4">
{foreach $carrier_list as $carrier}
<option value="{$carrier.id_reference}" {if isset($carrier.selected) && $carrier.selected}selected="selected"{/if}>{$carrier.name}</option>
{/foreach}
</select>
</td>
</tr>
</table>
<table cellpadding="5" style="width: 40%; float: left; margin-left: 10px;">
<tr>
<td class="col-left"><label>{l s='Deep ( package ) :' }</label></td>
<td style="padding-bottom:5px;">
<input size="6" maxlength="6" name="depth" type="text" value="{$product->depth}" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.');" /> {$ps_dimension_unit}
</td>
</tr>
<tr>
<td class="col-left"><label>{l s='Weight ( package ) :' }</label></td>
<td style="padding-bottom:5px;">
<input size="6" maxlength="6" name="weight" type="text" value="{$product->weight}" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.');" /> {$ps_weight_unit}
</td>
</tr>
</table>
</div>
{* [end] of physical product *}
{* [begin] virtual product *}
<div id="virtual_good" class="toggleVirtualPhysicalProduct" {if !$product->productDownload->id || $product->productDownload->active}style="display:none"{/if} >
<input type="hidden" id="is_virtual" name="is_virtual" value="{$product->is_virtual}" />
@@ -410,45 +365,12 @@ var textFieldLabel = 0;
</td>
</tr>
{/if}
<tr>
<td class="col-left"><label>{l s='When out of stock:'}</label></td>
<td style="padding-bottom:5px;">
<input type="radio" name="out_of_stock" id="out_of_stock_1" value="0" {if $product->out_of_stock == 0}checked="checked"{/if} />
<label for="out_of_stock_1" class="t" id="label_out_of_stock_1">{l s='Deny orders'}</label>
<br /><input type="radio" name="out_of_stock" id="out_of_stock_2" value="1" {if $product->out_of_stock == 1}checked="checked"{/if} />
<label for="out_of_stock_2" class="t" id="label_out_of_stock_2">{l s='Allow orders'}</label>
<br /><input type="radio" name="out_of_stock" id="out_of_stock_3" value="2" {if $product->out_of_stock == 2}checked="checked"{/if} />
<label for="out_of_stock_3" class="t" id="label_out_of_stock_3">{l s='Default:'}
<i>{if $ps_order_out_of_stock}{l s='Allow orders'}{else}{l s='Deny orders'}{/if}</i> ({l s='as set in'} <a href="{$link->getAdminLink('AdminPPreferences')}"
onclick="return confirm('{l s='Are you sure you want to delete entered product information?'}')">{l s='Preferences'}</a>)</label>
</td>
</tr>
<tr>
<td colspan="2" style="padding-bottom:5px;">
<div class="separation"></div>
</td>
</tr>
<tr>
<td class="col-left"><label for="id_category_default" class="t">
{l s='Default category:'}
</label></td>
<td>
<div id="no_default_category" style="color: red;font-weight: bold;display: none;">
{l s='Please check a category in order to select the default category.'}
</div>
<script type="text/javascript">
var post_selected_cat;
post_selected_cat = '{$selected_cat_ids}';
</script>
<select id="id_category_default" name="id_category_default">
{foreach from=$selected_cat item=cat}
<option value="{$cat.id_category}" {if $product->id_category_default == $cat.id_category}selected="selected"{/if} >{$cat.name}</option>
{/foreach}
</select>
</td>
</tr>
<tr><td colspan="2">{$category_tree}</td></tr>
<tr><td colspan="2" style="padding-bottom:5px;"><div class="separation"></div></td></tr>
{************** DESCRIPTION *****************************}
<tr><td colspan="2">

View File

@@ -24,6 +24,7 @@
* International Registered Trademark & Property of PrestaShop SA
*}
<script type="text/javascript" src="{$smarty.const._PS_JS_DIR_}price.js"></script>
<div class="block_specific_prices_modifications">
<h4>{l s='Product price'}</h4>
<div class="separation"></div>

View File

@@ -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 <contact@prestashop.com>
* @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
*}
<h4 class="tab">1. {l s='Info.'}</h4>
<h4>{l s='Shipping'}</h4>
<div class="separation"></div>
<table>
<tr>
<td class="col-left"><label>{l s='Width ( package ) :' }</label></td>
<td style="padding-bottom:5px;">
<input size="6" maxlength="6" name="width" type="text" value="{$product->width}" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.');" /> {$ps_dimension_unit}
</td>
</tr>
<tr>
<td class="col-left"><label>{l s='Height ( package ) :' }</label></td>
<td style="padding-bottom:5px;">
<input size="6" maxlength="6" name="height" type="text" value="{$product->height}" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.');" /> {$ps_dimension_unit}
</td>
</tr>
<tr>
<td class="col-left"><label>{l s='Depth ( package ) :' }</label></td>
<td style="padding-bottom:5px;">
<input size="6" maxlength="6" name="depth" type="text" value="{$product->depth}" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.');" /> {$ps_dimension_unit}
</td>
</tr>
<tr>
<td class="col-left"><label>{l s='Weight ( package ) :' }</label></td>
<td style="padding-bottom:5px;">
<input size="6" maxlength="6" name="weight" type="text" value="{$product->weight}" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.');" /> {$ps_weight_unit}
</td>
</tr>
<tr>
<td class="col-left">
<label>Carriers:</label>
</td>
<td class="padding-bottom:5px;">
<select name="carriers[]" multiple="multiple" size="4">
{foreach $carrier_list as $carrier}
<option value="{$carrier.id_reference}" {if isset($carrier.selected) && $carrier.selected}selected="selected"{/if}>{$carrier.name}</option>
{/foreach}
</select>
</td>
</tr>
</table>

View File

@@ -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();
});
</script>';
$html .= '
@@ -172,6 +174,7 @@ class HelperCore
';
$home_is_selected = false;
foreach($selected_cat AS $cat)
{
if (is_array($cat))

View File

@@ -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'
));
}
}

View File

@@ -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:
}

View File

@@ -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)
{

View File

@@ -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();