[*] BO #PSFV-94 : update of the displayform method by helperForm in AdminGroupShopController

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9308 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2011-10-13 09:07:36 +00:00
parent 278dc40a5e
commit 502369ee4f
4 changed files with 413 additions and 165 deletions
@@ -1,113 +0,0 @@
{*
* 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: 8897 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{if isset($tab_form)}
<script type="text/javascript">
$().ready(function()
{
$('input[name=share_order]').attr('disabled', true);
$('input[name=share_customer], input[name=share_stock]').click(function()
{
var disabled = ($('input[name=share_customer]').attr('checked') && $('input[name=share_stock]').attr('checked')) ? false : true;
$('input[name=share_order]').attr('disabled', disabled);
if (disabled)
$('#share_order_off').attr('checked', true);
});
});
</script>
<form action="{$tab_form['current']}&submitAdd{$tab_form['table']}=1&token={$tab_form['token']}" method="post">
{if $tab_form['id']}<input type="hidden" name="id_{$tab_form['table']}" value="{$tab_form['id']}" />{/if}
<fieldset>
<legend>{l s ='GroupShop'}</legend>
<div class="hint" name="help_box" style="display:block;">{l s ='You can\'t edit GroupShop when you have more than one Shop'}</div><br />
<label for="name">{l s ='GroupShop name'}</label>
<div class="margin-form">
<input type="text" name="name" id="name" value="{$tab_form['name']}" />
</div>
<label for="share_customer">{l s ='Share customers'}</label>
<div class="margin-form">
<input type="radio" name="share_customer" {$tab_form['disabled']} id="share_customer_on" value="1" {if $tab_form['share_customer']} checked="checked"{/if}/>
<label class="t" for="share_customer_on"> <img src="../img/admin/enabled.gif" alt="{l s ='Enabled'}" title="{l s ='Enabled'}" /></label>
<input type="radio" name="share_customer" {$tab_form['disabled']} id="share_customer_off" value="0" {if !$tab_form['share_customer']} checked="checked"{/if}/>
<label class="t" for="ashare_customer_off"> <img src="../img/admin/disabled.gif" alt="{l s ='Disabled'}" title="{l s ='Disabled'}" /></label>
<p>{l s ='Share customers between shops of this group'}</p>
</div>
<label for="share_stock">{l s ='Share stock'}</label>
<div class="margin-form">
<input type="radio" name="share_stock" {$tab_form['disabled']} id="share_stock_on" value="1" {if $tab_form['share_stock']} checked="checked"{/if}/>
<label class="t" for="share_stock_on"> <img src="../img/admin/enabled.gif" alt="{l s ='Enabled'}" title="{l s ='Enabled'}" /></label>
<input type="radio" name="share_stock" {$tab_form['disabled']} id="share_stock_off" value="0" {if !$tab_form['share_stock']} checked="checked"{/if} />
<label class="t" for="share_stock_off"> <img src="../img/admin/disabled.gif" alt="{l s ='Disabled'}" title="{l s ='Disabled'}" /></label>
<p>{l s ='Sare stock between shops of this group'}</p>
</div>
<label for="share_order">{l s ='Share orders'}</label>
<div class="margin-form">
<input type="radio" name="share_order" {$tab_form['disabled']} id="share_order_on" value="1" {if $tab_form['share_order']} checked="checked"{/if}/>
<label class="t" for="share_order_on"> <img src="../img/admin/enabled.gif" alt="{l s ='Enabled'}" title="{l s ='Enabled'}" /></label>
<input type="radio" name="share_order" {$tab_form['disabled']} id="share_order_off" value="0" {if !$tab_form['share_order']} checked="checked"{/if}/>
<label class="t" for="share_order_off"> <img src="../img/admin/disabled.gif" alt="{l s ='Disabled'}" title="{l s ='Disabled'}" /></label>
<p>{l s ='Share orders and carts between shops of this group (you can share orders only if you share customers and stock)'}</p>
</div>
<label>{l s ='Status:'} </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" value="1" {if $tab_form['active']} checked="checked"{/if}/>
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="{l s ='Enabled'}" title="{l s ='Enabled'}" /></label>
<input type="radio" name="active" id="active_off" value="0" {if !$tab_form['active']} checked="checked"{/if}/>
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="{l s ='Disabled'}" title="{l s ='Disabled'}" /></label>
<p>{l s ='Enable or disable shop'}</p>
</div>
<div class="margin-form">
<input type="submit" value="{l s =' Save '}" name="submitAdd{$tab_form['table']}" class="button" />
</div>
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
</fieldset><br />
<fieldset><legend>{l s ='Import data from another group shop'}</legend>
<label>{l s ='Import data from another group shop'}</label>
<div class="margin-form">
<input type="checkbox" value="1" {if $tab_form['checked']} checked="checked"{/if} name="useImportData" onclick="$('#importList').slideToggle('slow')" />
{l s ='Duplicate data from group shop'}
<select name="importFromShop">
{foreach $tab_form['getTree'] as $gID => $gData}
<option value="{$gID}" {if $gID == $tab_form['defaultGroup']} selected="selected"{/if}">{$gData['name']}</option>
{/foreach}
</select>
<div id="importList" style="{if !$tab_form['checked']}display: none{/if}"><ul>
{foreach $tab_form['importData'] as $table => $lang}
<li><label><input type="checkbox" name="importData[{$table}]" checked="checked" /> {$lang}</label></li>
{/foreach}
</ul></div>
<p>{l s ='Use this option to associate data (products, modules, etc.) the same way as the selected shop'}</p>
</div><div class="margin-form">
<input type="submit" value="{l s =' Save '}" name="submitAdd{$tab_form['table']}" class="button" />
</div>
</fieldset>
</form>
{/if}
{$content}
@@ -0,0 +1,151 @@
{*
* 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: 8971 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{if $firstCall}
<script type="text/javascript">
var vat_number = {$vat_number};
var module_dir = '{$module_dir}';
$(document).ready(function() {ldelim}
var id_language = {$defaultFormLanguage};
var languages = new Array();
{foreach $languages as $k => $language}
languages[{$k}] = {ldelim}
id_lang: {$language.id_lang},
iso_code: '{$language.iso_code}',
name: '{$language.name}'
{rdelim};
{/foreach}
displayFlags(languages, id_language, {$allowEmployeeFormLang});
$('input[name=share_order]').attr('disabled', true);
$('input[name=share_customer], input[name=share_stock]').click(function()
{
var disabled = ($('input[name=share_customer]').attr('checked') && $('input[name=share_stock]').attr('checked')) ? false : true;
$('input[name=share_order]').attr('disabled', disabled);
if (disabled)
$('#share_order_off').attr('checked', true);
});
$('#useImportData').click(function() {
$('#importList').slideToggle('slow');
});
{rdelim});
</script>
<script type="text/javascript" src="../js/form.js"></script>
{/if}
<form action="{$current}&submitAdd{$table}=1&token={$token}" method="post">
{if $form_id}
<input type="hidden" name="id_{$table}" value="{$form_id}" />
{/if}
<fieldset>
{foreach $fields as $key => $field}
{if $key == 'legend'}
<legend>
{if isset($field.image)}<img src="{$field.image}" alt="{$field.title}" />{/if}
{$field.title}
</legend>
<div class="hint" name="help_box" style="display:block;">{l s ='You can\'t edit GroupShop when you have more than one Shop'}</div><br />
{elseif $key == 'input'}
{foreach $field as $input}
{if $input.name == 'id_state'}
<div id="contains_states" {if $contains_states}style="display:none;"{/if}>
{/if}
<label>{$input.label} </label>
<div class="margin-form">
{if $input.type == 'text'}
<input type="text"
name="{$input.name}"
id="{$input.name}"
value="{$fields_value[$input.name]}"
{if isset($input.size)}size="{$input.size}"{/if}
{if isset($input.class)}class="{$input.class}"{/if}
{if isset($input.readonly) && $input.readonly}readonly="readonly"{/if} />
{elseif $input.type == 'select'}
<select name="{$input.name}" id="{$input.name}" {if isset($input.onchange)}onchange="{$input.onchange}"{/if}>
{if isset($input.options.optiongroup)}
{foreach $input.options.optiongroup.query AS $optiongroup}
<optgroup label="{$optiongroup[$input.options.optiongroup.label]}">
{foreach $optiongroup[$input.options.options.query] as $option}
<option value="{$option[$input.options.options.id]}"
{if $fields_value[$input.name] == $option[$input.options.options.id]}selected="selected"{/if}>{$option[$input.options.options.name]}</option>
{/foreach}
</optgroup>
{/foreach}
{else}
{foreach $input.options.query AS $option}
<option value="{$option[$input.options.id]}"
{if $fields_value[$input.name] == $option[$input.options.id]}selected="selected"{/if}>{$option[$input.options.name]}</option>
{/foreach}
{/if}
</select>
{elseif $input.type == 'radio'}
{foreach $input.values as $value}
<input type="radio"
name="{$input.name}"
id="{$value.id}"
value="{$value.value}"
{if $disabled[$input.name]}disabled="disabled"{/if}
{if $fields_value[$input.name] == $value.value}checked="checked"{/if} />
<label {if isset($input.class)}class="{$input.class}"{/if} for="{$value.id}"> {$value.label}</label>
{/foreach}
{elseif $input.type == 'textarea'}
<textarea name="{$input.name}" id="{$input.name}" cols="{$input.cols}" rows="{$input.rows}">{$fields_value[$input.name]}</textarea>
{elseif $input.type == 'checkbox'}
{/if}
{if isset($input.required) && $input.required} <sup>*</sup>{/if}
{if isset($input.p)}
<p class="clear">
{if is_array($input.p)}
{foreach $input.p as $p}
{if is_array($p)}
<span id="{$p.id}">{$p.text}</span><br />
{else}
{$p}<br />
{/if}
{/foreach}
{else}
{$input.p}
{/if}
</p>
{/if}
</div>
{if $input.name == 'id_state'}
</div>
{/if}
{/foreach}
{elseif $key == 'submit'}
<div class="margin-form">
<input type="submit" value="{$field.title}" name="submitAdd{$table}" {if isset($field.class)}class="{$field.class}"{/if} />
</div>
{/if}
{/foreach}
{if $requiredFields}
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
{/if}
</fieldset>
@@ -0,0 +1,80 @@
{*
* 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: 8971 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<br />
<fieldset>
{foreach $fields as $key => $field}
{if $key == 'legend'}
<legend>
{if isset($field.image)}<img src="{$field.image}" alt="{$field.title}" />{/if}
{$field.title}
</legend>
{elseif $key == 'label'}
<label>{$field}</label>
{/if}
{if $key == 'checkbox'}
<div class="margin-form">
<label><input type="{$field.type}" value="{$field.value}" name="{$field.name}" id="{$field.name}" {if $checked} checked="checked"{/if}/> {$field.label}</label>
{elseif $key == 'select'}
<select name="{$field.name}" id="{$field.name}">
{foreach $field.options.query AS $key => $option}
<option value="{$key}" {if $key == $defaultGroup}selected="selected"{/if}>
{$option.name}
</option>
{/foreach}
</select>
{elseif $key == 'allcheckbox'}
<div id="importList" {if !$checked}style="display:none"{/if}>
<ul>
{foreach $field.values as $key => $label}
<li><label><input type="checkbox" name="importData[{$key}]" checked="checked" /> {$label}</label></li>
{/foreach}
</ul>
</div>
{elseif $key == 'p'}
<p>{$field}</p>
</div>
{elseif $key == 'submit'}
<div class="margin-form">
<input type="submit" value="{$field.title}" name="submitAdd{$table}" {if isset($field.class)}class="{$field.class}"{/if} />
</div>
{/if}
{/foreach}
{if $requiredFields}
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
{/if}
</fieldset>
</form>
<br /><br />
{if $firstCall}
{if $back}
<a href="{$back}"><img src="../img/admin/arrow2.gif" />{l s='Back'}</a>
{else}
<a href="{$current}&token={$token}"><img src="../img/admin/arrow2.gif" />{l s='Back to list'}</a>
{/if}
<br />
{/if}
+182 -52
View File
@@ -47,7 +47,147 @@ class AdminGroupShopControllerCore extends AdminController
'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'active'),
);
$this->template = 'adminGroupShop.tpl';
$enabled = '<img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" />';
$disabled = '<img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" />';
$this->fields_form = array(
'legend' => array(
'title' => $this->l('GroupShop')
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('GroupShop name:'),
'name' => 'name'
),
array(
'type' => 'radio',
'label' => $this->l('Share customers:'),
'name' => 'share_customer',
'required' => true,
'class' => 't',
'values' => array(
array(
'id' => 'share_customer_on',
'value' => 1,
'label' => $enabled
),
array(
'id' => 'share_customer_off',
'value' => 0,
'label' => $disabled
)
),
'p' => $this->l('Share customers between shops of this group')
),
array(
'type' => 'radio',
'label' => $this->l('Share stock:'),
'name' => 'share_stock',
'required' => true,
'class' => 't',
'values' => array(
array(
'id' => 'share_stock_on',
'value' => 1,
'label' => $enabled
),
array(
'id' => 'share_stock_off',
'value' => 0,
'label' => $disabled
)
),
'p' => $this->l('Share stock between shops of this group')
),
array(
'type' => 'radio',
'label' => $this->l('Share orders:'),
'name' => 'share_order',
'required' => true,
'class' => 't',
'values' => array(
array(
'id' => 'share_order_on',
'value' => 1,
'label' => $enabled
),
array(
'id' => 'share_order_off',
'value' => 0,
'label' => $disabled
)
),
'p' => $this->l('Share orders and carts between shops of this group (you can share orders only if you share customers and stock)')
),
array(
'type' => 'radio',
'label' => $this->l('Status:'),
'name' => 'active',
'required' => true,
'class' => 't',
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $enabled
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $disabled
)
),
'p' => $this->l('Enable or disable shop')
)
),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button'
)
);
$import_data = array(
'attribute_group' => $this->l('Attribute groups'),
'attribute' => $this->l('Attributes'),
//'customer_group' => $this->l('Customer groups'),
'feature' => $this->l('Features'),
'group' => $this->l('Groups'),
'manufacturer' => $this->l('Manufacturers'),
'supplier' => $this->l('Suppliers'),
'tax_rules_group' => $this->l('Tax rules groups'),
'zone' => $this->l('Zones'),
);
$this->fields_import_form = array(
'legend' => array(
'title' => $this->l('Import data from another group shop')
),
'label' => $this->l('Duplicate data from group shop'),
'checkbox' => array(
'type' => 'checkbox',
'label' => $this->l('Duplicate data from group shop'),
'name' => 'useImportData',
'value' => 1
),
'select' => array(
'type' => 'select',
'name' => 'importFromShop',
'options' => array(
'query' => Shop::getTree(),
'name' => 'name'
)
),
'allcheckbox' => array(
'type' => 'checkbox',
'values' => $import_data
),
'p' => $this->l('Use this option to associate data (products, modules, etc.) the same way as the selected shop'),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button'
)
);
parent::__construct();
}
@@ -68,6 +208,47 @@ class AdminGroupShopControllerCore extends AdminController
return parent::postProcess();
}
public function initContent()
{
if (!($obj = $this->loadObject(true)))
return;
if (Shop::getTotalShops() > 1 && $obj->id)
$disabled = array(
'share_customer' => true,
'share_stock' => true,
'share_order' => true,
'active' => false
);
else
$disabled = false;
$this->context->smarty->assign(array(
'disabled' => $disabled,
'checked' => (Tools::getValue('addgroup_shop') !== false) ? true : false,
'defaultGroup' => Shop::getInstance(Configuration::get('PS_SHOP_DEFAULT'))->getGroupID()
));
if ($this->display != 'edit' && $this->display != 'add')
$this->display = 'list';
parent::initContent();
if ($this->display == 'edit' || $this->display == 'add')
{
$helper = new HelperForm();
// Check if form template has been overriden
if (file_exists($this->context->smarty->template_dir.'/'.$this->tpl_folder.'form_import.tpl'))
$helper->tpl = $this->tpl_folder.'form_import.tpl';
$helper::$currentIndex = self::$currentIndex;
$helper->token = $this->token;
$helper->table = $this->table;
$helper->id = $obj->id;
$helper->fields_value = $this->getFieldsValue($obj);
$this->content .= $helper->generateForm($this->fields_import_form);
}
}
public function afterAdd($new_group_shop)
{
if (Tools::getValue('useImportData') && ($import_data = Tools::getValue('importData')) && is_array($import_data))
@@ -79,57 +260,6 @@ class AdminGroupShopControllerCore extends AdminController
if (Tools::getValue('useImportData') && ($import_data = Tools::getValue('importData')) && is_array($import_data))
$new_group_shop->copyGroupShopData(Tools::getValue('importFromShop'), $import_data);
}
public function displayForm($is_main_tab = true)
{
parent::displayForm($is_main_tab);
if (!($obj = $this->loadObject(true)))
return;
if (Shop::getTotalShops() > 1 && $obj->id)
$disabled = 'disabled="disabled"';
else
$disabled = '';
$import_data = array(
'attribute_group' => $this->l('Attribute groups'),
'attribute' => $this->l('Attributes'),
//'customer_group' => $this->l('Customer groups'),
'feature' => $this->l('Features'),
'group' => $this->l('Groups'),
'manufacturer' => $this->l('Manufacturers'),
'supplier' => $this->l('Suppliers'),
'tax_rules_group' => $this->l('Tax rules groups'),
'zone' => $this->l('Zones'),
);
$this->context->smarty->assign('tab_form', array(
'current' => self::$currentIndex,
'table' => $this->table,
'token' => $this->token,
'id' => $obj->id,
'name' => $this->getFieldValue($obj, 'name'),
'disabled' => $disabled,
'share_customer' => $this->getFieldValue($obj, 'share_customer') ? true : false,
'share_stock' => $this->getFieldValue($obj, 'share_stock') ? true : false,
'share_order' => $this->getFieldValue($obj, 'share_order') ? true : false,
'active' => $this->getFieldValue($obj, 'active') ? true : false,
'importData' => $import_data,
'getTree' => Shop::getTree(),
'checked' => (Tools::getValue('addgroup_shop') !== false) ? true : false,
'defaultGroup' => Shop::getInstance(Configuration::get('PS_SHOP_DEFAULT'))->getGroupID()
));
}
public function initContent()
{
if ($this->display != 'edit' && $this->display != 'add')
$this->display = 'list';
parent::initContent();
}
}