[*] BO #PSFV-94 : Added AdminShopController
This commit is contained in:
@@ -1,251 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
|
||||
class AdminShop extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
$this->table = 'shop';
|
||||
$this->className = 'Shop';
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->deleted = false;
|
||||
|
||||
$this->_select = 'gs.name group_shop_name, cl.name category_name';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'group_shop` gs ON (a.id_group_shop = gs.id_group_shop)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (a.id_category = cl.id_category AND cl.id_lang='.(int)$this->context->language->id.')';
|
||||
$this->_group = 'GROUP BY a.id_shop';
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_shop' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Shop'), 'width' => 130, 'filter_key' => 'b!name'),
|
||||
'group_shop_name' => array('title' => $this->l('Group Shop'), 'width' => 70),
|
||||
'category_name' => array('title' => $this->l('Category Root'), 'width' => 70),
|
||||
'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'active'),
|
||||
);
|
||||
|
||||
$this->optionsList = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Shops options'),
|
||||
'fields' => array(
|
||||
'PS_SHOP_DEFAULT' => array('title' => $this->l('Default shop:'), 'desc' => $this->l('The default shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_shop', 'list' => Shop::getShops(), 'visibility' => Shop::CONTEXT_ALL)
|
||||
),
|
||||
),
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function afterAdd($newShop)
|
||||
{
|
||||
if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData))
|
||||
$newShop->copyShopData((int)Tools::getValue('importFromShop'), $importData);
|
||||
}
|
||||
|
||||
public function afterUpdate($newShop)
|
||||
{
|
||||
if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData))
|
||||
$newShop->copyShopData((int)Tools::getValue('importFromShop'), $importData);
|
||||
}
|
||||
|
||||
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = false)
|
||||
{
|
||||
parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, $id_lang_shop);
|
||||
$shop_delete_list = array();
|
||||
|
||||
// test store authorized to remove
|
||||
foreach($this->_list as $shop)
|
||||
{
|
||||
if(Shop::has_dependency($shop['id_shop']))
|
||||
$shop_delete_list[] = $shop['id_shop'];
|
||||
}
|
||||
$this->_listSkipDelete = $shop_delete_list;
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if ((Tools::isSubmit('status') || Tools::isSubmit('status'.$this->table) || (Tools::isSubmit('submitAdd'.$this->table) && Tools::getValue($this->identifier) && !Tools::getValue('active'))) && $this->loadObject() && $this->loadObject()->active)
|
||||
{
|
||||
if (Tools::getValue('id_shop') == Configuration::get('PS_SHOP_DEFAULT'))
|
||||
$this->_errors[] = Tools::displayError('You cannot disable the default shop.');
|
||||
else if (Shop::getTotalShops() == 1)
|
||||
$this->_errors[] = Tools::displayError('You cannot disable the last shop.');
|
||||
}
|
||||
|
||||
if ($this->_errors)
|
||||
return false;
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayConf()
|
||||
{
|
||||
if ($conf = Tools::getValue('conf'))
|
||||
{
|
||||
if ($conf == 3)
|
||||
echo '
|
||||
<div class="conf">
|
||||
<img src="../img/admin/ok2.png" alt="" /> <a href="index.php?tab=AdminShopUrl&addshop_url&token='.Tools::getAdminToken('AdminShopUrl'.Tab::getIdFromClassName('AdminShopUrl').(int)$this->context->employee->id).'">'.$this->l('Your store has been successfully created. To make your store accessible on front office, you must create a URL for your store by clicking on this text.').'</a>
|
||||
</div>';
|
||||
else
|
||||
parent::displayConf();
|
||||
}
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
parent::displayForm($isMainTab);
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
|
||||
$disabled = '';
|
||||
if (Shop::getTotalShops() > 1 && $obj->id)
|
||||
$disabled = 'disabled="disabled"';
|
||||
|
||||
echo '
|
||||
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend>'.$this->l('Shop').'</legend>
|
||||
<div class="hint" name="help_box" style="display:block;">'.$this->l('You can\'t change the GroupShop when you have more than one Shop').'</div><br />
|
||||
<label for="name">'.$this->l('Shop name').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="name" id="name" value="'.$this->getFieldValue($obj, 'name').'" />
|
||||
</div>
|
||||
<label for="id_group_shop">'.$this->l('Group Shop').'</label>
|
||||
<div class="margin-form">';
|
||||
if ($disabled)
|
||||
{
|
||||
$groupShop = new GroupShop($obj->id_group_shop);
|
||||
echo $groupShop->name;
|
||||
echo '<input type="hidden" name="id_group_shop" value="'.$obj->id_group_shop.'" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<select '.$disabled.' name="id_group_shop" id="id_group_shop">';
|
||||
foreach (GroupShop::getGroupShops() as $group)
|
||||
echo '<option value="'.(int)$group['id_group_shop'].'" '.($obj->id_group_shop == $group['id_group_shop'] ? 'selected="selected"' : '').'">'.$group['name'].'</option>';
|
||||
echo '</select>';
|
||||
}
|
||||
echo ' </div>';
|
||||
echo '<label for="id_category">'.$this->l('Category root').'</label>
|
||||
<div class="margin-form">
|
||||
<select id="id_category" name="id_category">';
|
||||
$categories = Category::getCategories($this->context->language->id, false);
|
||||
Category::recurseCategory($categories, $categories[0][1], 1, $obj->id_category);
|
||||
|
||||
echo '
|
||||
</select>
|
||||
</div>
|
||||
<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.(!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Enable or disable shop').'</p>
|
||||
</div>';
|
||||
|
||||
// Theme list
|
||||
echo '<label for="id_theme">'.$this->l('Theme').'</label>
|
||||
<div class="margin-form">';
|
||||
foreach (Theme::getThemes() as $i => $theme)
|
||||
{
|
||||
$checked = ((!$obj->id && $i == 0) || $obj->id_theme == $theme['id_theme']) ? true : false;
|
||||
echo '<div class="select_theme '.(($checked) ? 'select_theme_choice' : '').'" onclick="$(this).find(\'input\').attr(\'checked\', true); $(\'.select_theme\').removeClass(\'select_theme_choice\'); $(this).toggleClass(\'select_theme_choice\');">';
|
||||
echo ucfirst($theme['name']).'<br />';
|
||||
echo '<img src="../themes/'.$theme['name'].'/preview.jpg" alt="'.$theme['name'].'" /><br />';
|
||||
echo '<input type="radio" name="id_theme" value="'.$theme['id_theme'].'" '.(($checked) ? 'checked="checked"' : '').' />';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div><div class="clear"></div>';
|
||||
|
||||
echo '<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset><br /><br />';
|
||||
|
||||
$importData = array(
|
||||
'carrier' => $this->l('Carriers'),
|
||||
'carrier_lang' => $this->l('Carriers lang'),
|
||||
'category_lang' => $this->l('Category lang'),
|
||||
'cms' => $this->l('CMS page'),
|
||||
'contact' => $this->l('Contact'),
|
||||
'country' => $this->l('Countries'),
|
||||
'currency' => $this->l('Currencies'),
|
||||
'discount' => $this->l('Discounts'),
|
||||
'image' => $this->l('Images'),
|
||||
'lang' => $this->l('Langs'),
|
||||
'manufacturer' => $this->l('Manufacturers'),
|
||||
'module' => $this->l('Modules'),
|
||||
'hook_module' => $this->l('Modules hook'),
|
||||
'hook_module_exceptions' => $this->l('Modules hook exceptions'),
|
||||
'meta_lang' => $this->l('Meta'),
|
||||
'module_country' => $this->l('Payment module country restrictions'),
|
||||
'module_group' => $this->l('Payment module customer group restrictions'),
|
||||
'module_currency' => $this->l('Payment module currency restrictions'),
|
||||
'product' => $this->l('Products'),
|
||||
'product_lang' => $this->l('Products lang'),
|
||||
'scene' => $this->l('Scenes'),
|
||||
'stock' => $this->l('Stock'),
|
||||
'store' => $this->l('Stores'),
|
||||
);
|
||||
|
||||
$checked = (Tools::getValue('addshop') !== false) ? true : false;
|
||||
echo '<fieldset><legend>'.$this->l('Import data from another shop').'</legend>';
|
||||
echo '<label>'.$this->l('Import data from another shop').'</label>';
|
||||
echo '<div class="margin-form">';
|
||||
echo '<input type="checkbox" value="1" '.(($checked) ? 'checked="checked"' : '').' name="useImportData" onclick="$(\'#importList\').slideToggle(\'slow\')" /> ';
|
||||
echo $this->l('Duplicate data from shop');
|
||||
echo ' <select name="importFromShop">';
|
||||
foreach (Shop::getTree() as $gID => $gData)
|
||||
{
|
||||
echo '<optgroup label="'.$gData['name'].'">';
|
||||
foreach ($gData['shops'] as $sID => $sData)
|
||||
echo '<option value="'.(int)$sID.'" '.($sID == Configuration::get('PS_SHOP_DEFAULT') ? 'selected="selected"' : '').'">'.$sData['name'].'</option>';
|
||||
echo '</optgroup>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<div id="importList" style="'.((!$checked) ? 'display: none' : '').'"><ul>';
|
||||
foreach ($importData as $table => $lang)
|
||||
echo '<li><label><input type="checkbox" name="importData['.$table.']" checked="checked" /> '.$lang.'</label></li>';
|
||||
echo '</ul></div>';
|
||||
echo '<p>'.$this->l('Use this option to associate data (products, modules, etc.) the same way as the selected shop').'</p>';
|
||||
echo '</div><div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>';
|
||||
echo '</fieldset>';
|
||||
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
protected function displayAddButton()
|
||||
{
|
||||
echo '<br /><a href="'.self::$currentIndex.'&add'.$this->table.'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add new shop').'</a><br /><br />';
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,9 @@
|
||||
>
|
||||
<td class="center">
|
||||
{if {$has_bulk_actions}}
|
||||
<input type="checkbox" name="{$table}Box[]" value="{$tr.$identifier}" class="noborder" />
|
||||
{if isset($list_skip_actions.delete) && !in_array($tr.$identifier, $list_skip_actions.delete)}
|
||||
<input type="checkbox" name="{$table}Box[]" value="{$tr.$identifier}" class="noborder" />
|
||||
{/if}
|
||||
{/if}
|
||||
</td>
|
||||
{foreach $fields_display AS $key => $params}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
{*
|
||||
* 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
|
||||
*}
|
||||
{extends file="helper/form/form.tpl"}
|
||||
|
||||
{block name="label"}
|
||||
|
||||
{if $input.type == 'text' && $input.name == 'name'}
|
||||
<div class="hint" name="help_box" style="display:block;">{l s='You can\'t change the GroupShop when you have more than one Shop'}</div><br />
|
||||
{/if}
|
||||
|
||||
{if isset($input.label)}
|
||||
<label>{$input.label} </label>
|
||||
{/if}
|
||||
|
||||
{/block}
|
||||
|
||||
{block name="start_field_block"}
|
||||
<div class="margin-form">
|
||||
{if $input.type == 'theme'}
|
||||
{foreach $input.values as $theme}
|
||||
<div class="select_theme {if $theme.checked}select_theme_choice{/if}" onclick="$(this).find('input').attr('checked', true); $('.select_theme').removeClass('select_theme_choice'); $(this).toggleClass('select_theme_choice');">
|
||||
{$theme.name}<br />
|
||||
<img src="../themes/{$theme.name}/preview.jpg" alt="{$theme.name}" /><br />
|
||||
<input type="radio" name="id_theme" value="{$theme.id_theme}" {if $theme.checked}checked="checked"{/if} />
|
||||
</div>
|
||||
{/foreach}
|
||||
{/if}
|
||||
{if $input.type == 'textGroupShop'}
|
||||
{$input.value}
|
||||
{/if}
|
||||
{/block}
|
||||
|
||||
{block name="other_fieldsets"}
|
||||
{if isset($form_import)}
|
||||
<br /><br />
|
||||
<fieldset>
|
||||
{foreach $form_import 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}
|
||||
</fieldset>
|
||||
{/if}
|
||||
{/block}
|
||||
|
||||
{block name=script}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#useImportData').click(function() {
|
||||
$('#importList').slideToggle('slow');
|
||||
});
|
||||
});
|
||||
|
||||
{/block}
|
||||
Executable
+318
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
|
||||
class AdminShopControllerCore extends AdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
$this->table = 'shop';
|
||||
$this->className = 'Shop';
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_shop' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 25
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Shop'),
|
||||
'width' => 130,
|
||||
'filter_key' => 'b!name'
|
||||
),
|
||||
'group_shop_name' => array(
|
||||
'title' => $this->l('Group Shop'),
|
||||
'width' => 70
|
||||
),
|
||||
'category_name' => array(
|
||||
'title' => $this->l('Category Root'),
|
||||
'width' => 70
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Enabled'),
|
||||
'align' => 'center',
|
||||
'active' => 'status',
|
||||
'type' => 'bool',
|
||||
'orderby' => false,
|
||||
'filter_key' => 'active'
|
||||
)
|
||||
);
|
||||
|
||||
$this->options = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Shops options'),
|
||||
'fields' => array(
|
||||
'PS_SHOP_DEFAULT' => array(
|
||||
'title' => $this->l('Default shop:'),
|
||||
'desc' => $this->l('The default shop'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'identifier' => 'id_shop',
|
||||
'list' => Shop::getShops(),
|
||||
'visibility' => Shop::CONTEXT_ALL
|
||||
)
|
||||
),
|
||||
'submit' => array()
|
||||
)
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function initList()
|
||||
{
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'),'confirm' => $this->l('Delete selected items?')));
|
||||
|
||||
$this->_select = 'gs.name group_shop_name, cl.name category_name';
|
||||
$this->_join = '
|
||||
LEFT JOIN `'._DB_PREFIX_.'group_shop` gs
|
||||
ON (a.id_group_shop = gs.id_group_shop)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
ON (a.id_category = cl.id_category AND cl.id_lang='.(int)$this->context->language->id.')';
|
||||
$this->_group = 'GROUP BY a.id_shop';
|
||||
|
||||
return parent::initList();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if ((Tools::isSubmit('status') ||
|
||||
Tools::isSubmit('status'.$this->table) ||
|
||||
(Tools::isSubmit('submitAdd'.$this->table) && Tools::getValue($this->identifier) && !Tools::getValue('active'))) &&
|
||||
$this->loadObject() && $this->loadObject()->active)
|
||||
{
|
||||
if (Tools::getValue('id_shop') == Configuration::get('PS_SHOP_DEFAULT'))
|
||||
$this->_errors[] = Tools::displayError('You cannot disable the default shop.');
|
||||
else if (Shop::getTotalShops() == 1)
|
||||
$this->_errors[] = Tools::displayError('You cannot disable the last shop.');
|
||||
}
|
||||
|
||||
if ($this->_errors)
|
||||
return false;
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function afterAdd($new_shop)
|
||||
{
|
||||
if (Tools::getValue('useImportData') && ($import_data = Tools::getValue('importData')) && is_array($import_data))
|
||||
$new_shop->copyShopData((int)Tools::getValue('importFromShop'), $import_data);
|
||||
}
|
||||
|
||||
public function afterUpdate($new_shop)
|
||||
{
|
||||
if (Tools::getValue('useImportData') && ($import_data = Tools::getValue('importData')) && is_array($import_data))
|
||||
$new_shop->copyShopData((int)Tools::getValue('importFromShop'), $import_data);
|
||||
}
|
||||
|
||||
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
|
||||
{
|
||||
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
|
||||
$shop_delete_list = array();
|
||||
|
||||
// test store authorized to remove
|
||||
foreach ($this->_list as $shop)
|
||||
{
|
||||
if (Shop::has_dependency($shop['id_shop']))
|
||||
$shop_delete_list[] = $shop['id_shop'];
|
||||
}
|
||||
$this->addRowActionSkipList('delete', $shop_delete_list);
|
||||
}
|
||||
|
||||
public function initForm()
|
||||
{
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Shop')
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('GroupShop name:'),
|
||||
'name' => 'name',
|
||||
'required' => true,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (Shop::getTotalShops() > 1 && $obj->id)
|
||||
{
|
||||
$group_shop = new GroupShop($obj->id_group_shop);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'id_group_shop',
|
||||
'default' => $group_shop->name
|
||||
);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'textGroupShop',
|
||||
'label' => $this->l('Group Shop:'),
|
||||
'name' => 'id_group_shop',
|
||||
'value' => $group_shop->name
|
||||
);
|
||||
}
|
||||
else
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Group Shop:'),
|
||||
'name' => 'id_group_shop',
|
||||
'options' => array(
|
||||
'query' => GroupShop::getGroupShops(),
|
||||
'id' => 'id_group_shop',
|
||||
'name' => 'name'
|
||||
)
|
||||
);
|
||||
|
||||
$categories = Category::getCategories($this->context->language->id, false, false);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Category root:'),
|
||||
'name' => 'id_category',
|
||||
'options' => array(
|
||||
'query' => $categories,
|
||||
'id' => 'id_category',
|
||||
'name' => 'name'
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Status:'),
|
||||
'name' => 'active',
|
||||
'required' => true,
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
'p' => $this->l('Enable or disable shop')
|
||||
);
|
||||
|
||||
$themes = Theme::getThemes();
|
||||
foreach ($themes as $i => $theme)
|
||||
$themes[$i]['checked'] = ((!$obj->id && $i == 0) || $obj->id_theme == $theme['id_theme']) ? true : false;
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'theme',
|
||||
'label' => $this->l('Theme:'),
|
||||
'name' => 'theme',
|
||||
'values' => $themes
|
||||
);
|
||||
|
||||
$this->fields_form['submit'] = array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button'
|
||||
);
|
||||
|
||||
if (Shop::getTotalShops() > 1 && $obj->id)
|
||||
$disabled = array(
|
||||
'share_customer' => true,
|
||||
'share_order' => true,
|
||||
'active' => false
|
||||
);
|
||||
else
|
||||
$disabled = false;
|
||||
|
||||
$import_data = array(
|
||||
'carrier' => $this->l('Carriers'),
|
||||
'carrier_lang' => $this->l('Carriers lang'),
|
||||
'category_lang' => $this->l('Category lang'),
|
||||
'cms' => $this->l('CMS page'),
|
||||
'contact' => $this->l('Contact'),
|
||||
'country' => $this->l('Countries'),
|
||||
'currency' => $this->l('Currencies'),
|
||||
'discount' => $this->l('Discounts'),
|
||||
'image' => $this->l('Images'),
|
||||
'lang' => $this->l('Langs'),
|
||||
'manufacturer' => $this->l('Manufacturers'),
|
||||
'module' => $this->l('Modules'),
|
||||
'hook_module' => $this->l('Modules hook'),
|
||||
'hook_module_exceptions' => $this->l('Modules hook exceptions'),
|
||||
'meta_lang' => $this->l('Meta'),
|
||||
'module_country' => $this->l('Payment module country restrictions'),
|
||||
'module_group' => $this->l('Payment module customer group restrictions'),
|
||||
'module_currency' => $this->l('Payment module currency restrictions'),
|
||||
'product' => $this->l('Products'),
|
||||
'product_lang' => $this->l('Products lang'),
|
||||
'scene' => $this->l('Scenes'),
|
||||
'stock' => $this->l('Stock'),
|
||||
'store' => $this->l('Stores'),
|
||||
);
|
||||
|
||||
$this->fields_import_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Import data from another shop')
|
||||
),
|
||||
'label' => $this->l('Import data from another shop'),
|
||||
'checkbox' => array(
|
||||
'type' => 'checkbox',
|
||||
'label' => $this->l('Duplicate data from 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')
|
||||
);
|
||||
|
||||
$this->fields_value = array(
|
||||
'id_group_shop' => $obj->id_group_shop
|
||||
);
|
||||
|
||||
$this->tpl_form_vars = array(
|
||||
'disabled' => $disabled,
|
||||
'checked' => (Tools::getValue('addshop') !== false) ? true : false,
|
||||
'defaultGroup' => Shop::getInstance(Configuration::get('PS_SHOP_DEFAULT'))->getGroupID(),
|
||||
'form_import' => $this->fields_import_form
|
||||
);
|
||||
|
||||
return parent::initForm();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user