From a9cbb3fdcdd81164209c7cef589d4dbc8a296874 Mon Sep 17 00:00:00 2001 From: lLefevre Date: Wed, 19 Oct 2011 14:34:37 +0000 Subject: [PATCH] [*] BO #PSFV-94 : Added AdminCarrierController --- admin-dev/tabs/AdminCarriers.php | 417 ------------------ admin-dev/themes/template/carriers/form.tpl | 295 +++++++++++++ admin-dev/themes/template/form.tpl | 5 + admin-dev/themes/template/form_group.tpl | 49 ++ admin-dev/themes/template/form_shop.tpl | 131 ++++++ admin-dev/themes/template/group_shop/form.tpl | 3 +- admin-dev/themes/template/shop_url/form.tpl | 3 +- admin-dev/themes/template/stores/form.tpl | 10 +- admin-dev/themes/template/stores/options.tpl | 3 - classes/AdminController.php | 30 +- classes/Carrier.php | 15 +- classes/HelperList.php | 5 +- classes/HelperOptions.php | 4 +- 13 files changed, 530 insertions(+), 440 deletions(-) delete mode 100644 admin-dev/tabs/AdminCarriers.php create mode 100644 admin-dev/themes/template/carriers/form.tpl create mode 100644 admin-dev/themes/template/form_group.tpl create mode 100644 admin-dev/themes/template/form_shop.tpl diff --git a/admin-dev/tabs/AdminCarriers.php b/admin-dev/tabs/AdminCarriers.php deleted file mode 100644 index 881862ca4..000000000 --- a/admin-dev/tabs/AdminCarriers.php +++ /dev/null @@ -1,417 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 7321 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -include_once(_PS_ADMIN_DIR_.'/../classes/AdminTab.php'); - -class AdminCarriers extends AdminTab -{ - public function __construct() - { - $this->table = 'carrier'; - $this->className = 'Carrier'; - $this->lang = true; - $this->edit = true; - $this->delete = true; - $this->deleted = true; - $this->fieldImageSettings = array('name' => 'logo', 'dir' => 's'); - - $this->fieldsDisplay = array( - 'id_carrier' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'name' => array('title' => $this->l('Name'), 'width' => 100), - 'logo' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 's', 'orderby' => false, 'search' => false), - 'delay' => array('title' => $this->l('Delay'), 'width' => 300, 'orderby' => false), - 'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), - 'is_free' => array('title' => $this->l('Is Free'), 'align' => 'center', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif', 'default' => 'disabled.gif'), 'type' => 'bool', 'orderby' => false), - 'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'cp!position', 'align' => 'center', 'position' => 'position') - ); - - $carrier_default_sort = array( - array('value' => Carrier::SORT_BY_PRICE, 'name' => $this->l('Price')), - array('value' => Carrier::SORT_BY_POSITION, 'name' => $this->l('Position')) - ); - - $this->optionsList = array( - 'general' => array( - 'title' => $this->l('Carrier options'), - 'fields' => array( - 'PS_CARRIER_DEFAULT' => array('title' => $this->l('Default carrier:'), 'desc' => $this->l('The default carrier used in shop'), 'cast' => 'intval', 'type' => 'select', - 'identifier' => 'id_carrier', 'list' => Carrier::getCarriers((int)Configuration::get('PS_LANG_DEFAULT'), true, false, false, null, Carrier::ALL_CARRIERS)), - 'PS_CARRIER_DEFAULT_SORT' => array('title' => $this->l('Carrier default sort:'), 'desc' => $this->l('This default sort will be available only on front-office'), 'cast' => 'intval', 'type' => 'select', - 'identifier' => 'value', 'list' => $carrier_default_sort), - ), - ), - ); - - parent::__construct(); - } - - public function displayTop() - { - echo ' -
'. - ' '.$this->l('How to create a new carrier?').''. - '
'. - ' -

'; - } - - public function displayForm($isMainTab = true) - { - parent::displayForm(); - - if (!($obj = $this->loadObject(true))) - return; - - echo ' -
- '.($obj->id ? '' : '').' -
'.$this->l('Carriers').' - -
- * - '.$this->l('Allowed characters: letters, spaces and').' ().-  -

'.$this->l('Carrier name displayed during checkout').'
'.$this->l('With a value of 0, the carrier name will be replaced by the shop name').'

-
- -
- -

'.$this->l('Upload logo from your computer').' (.gif, .jpg, .jpeg '.$this->l('or').' .png)

-
- -
'; - foreach ($this->_languages as $language) - echo ' -
- * -
'; - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'delay', 'delay'); - echo ' -

'.$this->l('Time taken for product delivery; displayed during checkout').'

-
- -
- -

'.$this->l('URL for the tracking number; type \'@\' where the tracking number will appear').'

-
- -
'; - $carrier_zones = $obj->getZones(); - $carrier_zones_ids = array(); - if (is_array($carrier_zones)) - foreach ($carrier_zones as $carrier_zone) - $carrier_zones_ids[] = $carrier_zone['id_zone']; - - $zones = Zone::getZones(false); - foreach ($zones as $zone) - echo ' -
'; - - echo '

'.$this->l('The zone in which this carrier is to be used').'

-
- -
'; - $groups = Group::getGroups(Context::getContext()->language->id); - if (count($groups)) - { - echo ' - - - - - - '; - $irow = 0; - foreach ($groups as $group) - echo ' - - - - - '; - echo ' -
id) ? 'checked="checked" ' : '').' />'.$this->l('ID').''.$this->l('Group name').'
getValue('SELECT id_group FROM '._DB_PREFIX_.'carrier_group - WHERE id_carrier='.(int)$obj->id.' AND id_group='.(int)$group['id_group']) || (!isset($obj->id))) ? 'checked="checked" ' : '').'/>'.$group['id_group'].'
-

'.$this->l('Mark all groups you want to give access to this carrier').'

- '; - } - else - echo '

'.$this->l('No group created').'

'; - echo '
- -
- getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> - - getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> - -

'.$this->l('Include or exclude carrier from list of carriers on Front Office').'

-
- -
- getFieldValue($obj, 'is_free') ? 'checked="checked" ' : '').'/> - - getFieldValue($obj, 'is_free') ? 'checked="checked" ' : '').'/> - -

'.$this->l('Apply shipping costs and additional shipping costs by products in carrier price').'

-
-
- -
- -
- -
- getFieldValue($obj, 'shipping_handling') ? 'checked="checked" ' : '').'/> - - getFieldValue($obj, 'shipping_handling') ? 'checked="checked" ' : '').'/> - -

'.$this->l('Include the shipping & handling costs in carrier price').'

-
- -
- getFieldValue($obj, 'shipping_method') == Carrier::SHIPPING_METHOD_DEFAULT ? 'checked="checked" ' : '').'/> -
- getFieldValue($obj, 'shipping_method') == Carrier::SHIPPING_METHOD_PRICE ? 'checked="checked" ' : '').'/> -
- getFieldValue($obj, 'shipping_method') == Carrier::SHIPPING_METHOD_WEIGHT ? 'checked="checked" ' : '').'/> -
-
- -
- -

'.$this->l('Out-of-range behavior when none is defined (e.g., when a customer\'s cart weight is greater than the highest range limit)').'

-
'; - if ($this->getFieldValue($obj, 'is_module')) - { - echo ' -

- '. - $this->l('This carrier is bound to this module ').' => '.$this->getFieldValue($obj, 'external_module_name').'

- - '; - - if ($this->getFieldValue($obj, 'shipping_external')) - { - echo '

- '.$this->l('The shipping costs are calculated outside of your shop').'

- '; - } - if ($this->getFieldValue($obj, 'need_range')) - { - echo '

- '.$this->l('This carrier uses PrestaShop range to calculate shipping costs').'

- '; - } - - echo '
'; - } - echo '
'; - if (Shop::isFeatureActive()) - { - echo '
'; - $this->displayAssoShop(); - echo '
'; - } - echo ' -
- -
-
* '.$this->l('Required field').'
-
-
'; - } - - public function beforeDelete($object) - { - return $object->isUsed(); - } - - public function afterDelete($object, $oldId) - { - $object->copyCarrierData((int)($oldId)); - } - - private function changeGroups($id_carrier, $delete = true) - { - if ($delete) - Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier = '.(int)$id_carrier); - $groups = Db::getInstance()->executeS('SELECT id_group FROM `'._DB_PREFIX_.'group`'); - foreach ($groups as $group) - if (Tools::getIsset('groupBox') && in_array($group['id_group'], Tools::getValue('groupBox'))) - Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'carrier_group (id_group, id_carrier) VALUES('.(int)$group['id_group'].','.(int)$id_carrier.')'); - } - - public function postProcess() - { - if (Tools::getValue('submitAdd'.$this->table)) - { - /* Checking fields validity */ - $this->validateRules(); - if (!count($this->_errors)) - { - $id = (int)Tools::getValue('id_'.$this->table); - - /* Object update */ - if (isset($id) && !empty($id)) - { - if ($this->tabAccess['edit'] === '1') - { - $object = new $this->className($id); - if (Validate::isLoadedObject($object)) - { - Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier = '.(int)$id); - $object->deleted = 1; - $object->update(); - $object_new = new $this->className(); - $this->copyFromPost($object_new, $this->table); - $object_new->position = $object->position; - $result = $object_new->add(); - if (Validate::isLoadedObject($object_new)) - { - $this->afterDelete($object_new, $object->id); - Hook::updateCarrier((int)$object->id, $object_new); - } - $this->changeGroups($object_new->id); - if (!$result) - $this->_errors[] = Tools::displayError('An error occurred while updating object.').' '.$this->table.''; - else if ($this->postImage($object_new->id)) - { - $this->changeZones($object_new->id); - Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=4&token='.$this->token); - } - } - else - $this->_errors[] = Tools::displayError('An error occurred while updating object.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - - /* Object creation */ - else - { - if ($this->tabAccess['add'] === '1') - { - $object = new $this->className(); - $this->copyFromPost($object, $this->table); - $object->position = Carrier::getHigherPosition() + 1; - if (!$object->add()) - $this->_errors[] = Tools::displayError('An error occurred while creating object.').' '.$this->table.''; - else if (($_POST['id_'.$this->table] = $object->id /* voluntary */) && $this->postImage($object->id) && $this->_redirect) - { - $this->changeZones($object->id); - $this->changeGroups($object->id); - Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=3'.'&token='.$this->token); - } - } - else - $this->_errors[] = Tools::displayError('You do not have permission to add here.'); - } - } - } - else if ((isset($_GET['status'.$this->table]) || isset($_GET['status'])) && Tools::getValue($this->identifier)) - { - if ($this->tabAccess['edit'] === '1') - { - if (Tools::getValue('id_carrier') == Configuration::get('PS_CARRIER_DEFAULT')) - $this->_errors[] = Tools::displayError('You can\'t disable the default carrier, please change your default carrier first.'); - else - parent::postProcess(); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - else - { - if ((Tools::isSubmit('submitDel'.$this->table) && in_array(Configuration::get('PS_CARRIER_DEFAULT'), Tools::getValue('carrierBox'))) - || (isset($_GET['delete'.$this->table]) && Tools::getValue('id_carrier') == Configuration::get('PS_CARRIER_DEFAULT'))) - $this->_errors[] = $this->l('Please set another carrier as default before deleting'); - else - parent::postProcess(); - } - } - - - public function changeZones($id) - { - $carrier = new $this->className($id); - if (!Validate::isLoadedObject($carrier)) - die (Tools::displayError('Object cannot be loaded')); - $zones = Zone::getZones(true); - foreach ($zones as $zone) - if (count($carrier->getZone($zone['id_zone']))) - { - if (!isset($_POST['zone_'.$zone['id_zone']]) || !$_POST['zone_'.$zone['id_zone']]) - $carrier->deleteZone($zone['id_zone']); - } - else - if (isset($_POST['zone_'.$zone['id_zone']]) && $_POST['zone_'.$zone['id_zone']]) - $carrier->addZone($zone['id_zone']); - } - - public function displayListContent($token = null) - { - foreach ($this->_list as $key => $list) - if ($list['name'] == '0') - $this->_list[$key]['name'] = Configuration::get('PS_SHOP_NAME'); - parent::displayListContent($token); - } - - /** - * Modifying initial getList method to display position feature (drag and drop) - */ - public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) - { - $order_by = ($order_by && $this->context->cookie->__get($this->table.'Orderby')) ? $this->context->cookie->__get($this->table.'Orderby'): 'position'; - parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); - } -} \ No newline at end of file diff --git a/admin-dev/themes/template/carriers/form.tpl b/admin-dev/themes/template/carriers/form.tpl new file mode 100644 index 000000000..41b93ee61 --- /dev/null +++ b/admin-dev/themes/template/carriers/form.tpl @@ -0,0 +1,295 @@ +{* +* 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: 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} + + +{/if} + +
+ {if $form_id} + + {/if} +
+ {foreach $fields as $key => $field} + {if $key == 'legend'} + + {if isset($field.image)}{$field.title}{/if} + {$field.title} + + {elseif $key == 'input'} + {foreach $field as $input} + {if $input.name == 'id_state'} +
+ {/if} + {if $input.name == 'id_tax_rules_group'}
{/if} + {if isset($input.label)} + {if $input.name == 'is_module' && $fields_value['is_module'] == 0} + {else} + + {/if} + {/if} +
+ {if $input.type == 'text'} + {if isset($input.lang) && isset($input.attributeLang)} + {foreach $languages as $language} +
+ + {if isset($input.hint)}{$input.hint} {/if} +
+ {/foreach} + {if count($languages) > 1} +
+ +
+
+ {l s='Choose language:'}

+ {foreach $languages as $language} + {$language.name} + {/foreach} +
+ {/if} + {else} + + {if isset($input.hint)}{$input.hint} {/if} + {/if} + {elseif $input.type == 'hidden'} + {if $input.name == 'is_module'} + {if $fields_value['is_module'] != 0} +

- {l s='This carrier is bound to this module '} : {$fields_value['external_module_name']}

+ + + {if $fields_value['shipping_external'] != 0} +

- {l s='The shipping costs are calculated outside of your shop'}

+ + {/if} + {if $fields_value['need_range'] != 0} +

- {l s='This carrier uses PrestaShop range to calculate shipping costs'}

+ + {/if} + {/if} + {else} + + {/if} + {elseif $input.type == 'select'} + + {if isset($input.hint)}{$input.hint} {/if} + {elseif $input.type == 'radio'} + {foreach $input.values as $value} + + + {if isset($input.br) && $input.br}
{/if} + {/foreach} + {elseif $input.type == 'textarea'} + {if isset($input.lang) && isset($input.attributeLang)} + {foreach $languages as $language} +
+ +
+ {/foreach} + {if count($languages) > 1} +
+ +
+
+ {l s='Choose language:'}

+ {foreach $languages as $language} + {$language.name} + {/foreach} +
+ {/if} + {else} + + {/if} + {elseif $input.type == 'checkbox'} + {foreach $input.values.query as $value} + {assign var=id_checkbox value=$input.name|cat:'_'|cat:$value[$input.values.id]} + +
+ {/foreach} + {elseif $input.type == 'file'} + + + {elseif $input.type == 'group'} + {assign var=groups value=$input.values} + {include file='form_group.tpl'} + {elseif $input.type == 'shop' OR $input.type == 'group_shop'} + {include file='form_shop.tpl'} + {elseif $input.type == 'asso_shop' && isset($asso_shop) && $asso_shop} + +
+ {$asso_shop} +
+ {/if} + {if isset($input.required) && $input.required} *{/if} + {if isset($input.p)} +

+ {if is_array($input.p)} + {foreach $input.p as $p} + {if is_array($p)} + {$p.text}
+ {else} + {$p}
+ {/if} + {/foreach} + {else} + {$input.p} + {/if} +

+ {/if} +
+ {if $input.name == 'range_behavior'}
{/if} + {if $input.name == 'id_state'}
{/if} + {/foreach} + {elseif $key == 'submit'} +
+ +
+ {/if} + {/foreach} + {if $required_fields} +
* {l s ='Required field'}
+ {/if} +
+
+ +

+{if $firstCall} + {if $back} + {l s='Back'} + {else} + {l s='Back to list'} + {/if} +
+{/if} diff --git a/admin-dev/themes/template/form.tpl b/admin-dev/themes/template/form.tpl index 2afc1880c..e5e780984 100644 --- a/admin-dev/themes/template/form.tpl +++ b/admin-dev/themes/template/form.tpl @@ -214,6 +214,11 @@ {elseif $input.type == 'file'} + {elseif $input.type == 'group'} + {assign var=groups value=$input.values} + {include file='form_group.tpl'} + {elseif $input.type == 'shop' OR $input.type == 'group_shop'} + {include file='form_shop.tpl'} {elseif $input.type == 'asso_shop' && isset($asso_shop) && $asso_shop}
diff --git a/admin-dev/themes/template/form_group.tpl b/admin-dev/themes/template/form_group.tpl new file mode 100644 index 000000000..d7565517b --- /dev/null +++ b/admin-dev/themes/template/form_group.tpl @@ -0,0 +1,49 @@ +{* +* 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: 8971 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +{if count($groups) && isset($groups)} + + + + + + + {foreach $groups as $key => $group} + + + + + + {/foreach} +
+ + {l s='ID'}{l s='Group name'}
+ {assign var=id_checkbox value=groupBox|cat:'_'|cat:$group['id_group']} + + {$group['id_group']}
+{else} +

{l s='No group created'}

+{/if} \ No newline at end of file diff --git a/admin-dev/themes/template/form_shop.tpl b/admin-dev/themes/template/form_shop.tpl new file mode 100644 index 000000000..199ac05ae --- /dev/null +++ b/admin-dev/themes/template/form_shop.tpl @@ -0,0 +1,131 @@ +{* +* 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: 8971 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + + +
+ + + + + + + + {foreach $input.values as $groupID => $groupData} + {if ($input.type == 'group_shop' && ((isset($fields_value.shop[$groupID]) && in_array($form_id, $fields_value.shop[$groupID])) || !$form_id))} + {assign var=groupChecked value=true} + {else} + {assign var=groupChecked value=false} + {/if} + + + + + {if $input.type = 'shop'} + {assign var=j value=0} + {foreach $groupData['shops'] as $shopID => $shopData} + {if ((isset($fields_value.shop[$shopID]) && in_array($form_id, $fields_value.shop[$shopID])) || !$form_id)} + {assign var=checked value=true} + {else} + {assign var=checked value=false} + {/if} + + + + {assign var=j value=$j+1} + {/foreach} + {/if} + {/foreach} +
{l s='Shop'}
+ +
+ + +
+ + +
+
\ No newline at end of file diff --git a/admin-dev/themes/template/group_shop/form.tpl b/admin-dev/themes/template/group_shop/form.tpl index 65fc6bda4..ed8b4c63a 100644 --- a/admin-dev/themes/template/group_shop/form.tpl +++ b/admin-dev/themes/template/group_shop/form.tpl @@ -82,7 +82,8 @@ name="{$input.name}" id="{$input.name}" value="{$fields_value[$input.name]}" - {if isset($input.size)}size="{$input.size}"{/if} + {if isset($input.size)}size="{$input.size}"{/if} + {if isset($input.maxlength)}maxlength="{$input.maxlength}"{/if} {if isset($input.class)}class="{$input.class}"{/if} {if isset($input.readonly) && $input.readonly}readonly="readonly"{/if} /> {elseif $input.type == 'select'} diff --git a/admin-dev/themes/template/shop_url/form.tpl b/admin-dev/themes/template/shop_url/form.tpl index 6089543a8..a0c8639af 100644 --- a/admin-dev/themes/template/shop_url/form.tpl +++ b/admin-dev/themes/template/shop_url/form.tpl @@ -144,7 +144,8 @@ name="{$input.name}" id="{$input.name}" value="{$fields_value[$input.name]}" - {if isset($input.size)}size="{$input.size}"{/if} + {if isset($input.size)}size="{$input.size}"{/if} + {if isset($input.maxlength)}maxlength="{$input.maxlength}"{/if} {if isset($input.class)}class="{$input.class}"{/if} {if isset($input.readonly) && $input.readonly}readonly="readonly"{/if} /> {elseif $input.type == 'select'} diff --git a/admin-dev/themes/template/stores/form.tpl b/admin-dev/themes/template/stores/form.tpl index 5c487a3ca..8437762fd 100644 --- a/admin-dev/themes/template/stores/form.tpl +++ b/admin-dev/themes/template/stores/form.tpl @@ -83,13 +83,13 @@ {if $input.name == 'latitude'} / @@ -100,7 +100,8 @@ {if isset($input.hint)}{$input.hint} {/if} @@ -129,7 +130,8 @@ name="{$input.name}" id="{$input.name}" value="{$fields_value[$input.name]}" - {if isset($input.size)}size="{$input.size}"{/if} + {if isset($input.size)}size="{$input.size}"{/if} + {if isset($input.maxlength)}maxlength="{$input.maxlength}"{/if} {if isset($input.class)}class="{$input.class}"{/if} {if isset($input.readonly) && $input.readonly}readonly="readonly"{/if} /> {if isset($input.hint)}{$input.hint} {/if} diff --git a/admin-dev/themes/template/stores/options.tpl b/admin-dev/themes/template/stores/options.tpl index bac3959d7..52c921a21 100644 --- a/admin-dev/themes/template/stores/options.tpl +++ b/admin-dev/themes/template/stores/options.tpl @@ -24,9 +24,6 @@ * International Registered Trademark & Property of PrestaShop SA *}
-
{foreach $optionsList AS $category => $categoryData} diff --git a/classes/AdminController.php b/classes/AdminController.php index 28d32e620..44c22fb9c 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -1077,6 +1077,7 @@ class AdminControllerCore extends Controller $helper->table = $this->table; $helper->_orderBy = $this->_orderBy; $helper->_orderWay = $this->_orderWay; + $helper->_listTotal = $this->_listTotal; $helper->shopLink = $this->shopLink; $helper->shopLinkType = $this->shopLinkType; $helper->identifier = $this->identifier; @@ -1088,15 +1089,19 @@ class AdminControllerCore extends Controller // For each action, try to add the corresponding skip elements list $helper->list_skip_actions = $this->list_skip_actions; $this->content .= $helper->generateList($this->_list, $this->fieldsDisplay); - } - else if ($this->display == 'options') - { + // init options declaration $this->initOptions(); - - $helper = new HelperOptions(); - $this->content .= $helper->generateOptions(); + + if ($this->options) + { + $helper = new HelperOptions(); + $helper->id = $this->id; + $helper->currentIndex = self::$currentIndex; + $this->content .= $helper->generateOptions($this->options); + } } + } /** @@ -1758,7 +1763,13 @@ class AdminControllerCore extends Controller } } - protected function updateAssoShop($id_object = false) + /** + * Update the associations of shops + * + * @param int $id_object + * @param int $new_id_object + */ + protected function updateAssoShop($id_object = false, $new_id_object = false) { if (!Shop::isFeatureActive()) return; @@ -1782,9 +1793,10 @@ class AdminControllerCore extends Controller } Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.$this->table.'_'.$type.($id_object ? ' WHERE `'.$this->identifier.'`='.(int)$id_object : '')); + foreach ($assos as $asso) Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.$this->table.'_'.$type.' (`'.pSQL($this->identifier).'`, id_'.$type.') - VALUES('.(int)$asso['id_object'].', '.(int)$asso['id_'.$type].')'); + VALUES('.($new_id_object ? $new_id_object : (int)$asso['id_object']).', '.(int)$asso['id_'.$type].')'); } protected function validateField($value, $field) @@ -1825,6 +1837,8 @@ class AdminControllerCore extends Controller $languages = Language::getLanguages(false); + // init options declaration + $this->initOptions(); foreach ($this->options as $category => $category_data) { $fields = $category_data['fields']; diff --git a/classes/Carrier.php b/classes/Carrier.php index 3576e19de..879bc28c1 100644 --- a/classes/Carrier.php +++ b/classes/Carrier.php @@ -546,9 +546,7 @@ class CarrierCore extends ObjectModel if (Configuration::get('PS_CARRIER_DEFAULT_SORT') == Carrier::SORT_BY_PRICE) { foreach ($results_array as $r) - { $prices[] = $r['price']; - } array_multisort($prices, SORT_NUMERIC, $results_array); } @@ -619,6 +617,19 @@ class CarrierCore extends ObjectModel AND `id_zone` = '.(int)$id_zone.' LIMIT 1'); } + /** + * Get a specific group + * + * @return array Group + */ + public function getGroups() + { + return Db::getInstance()->executeS(' + SELECT id_group + FROM '._DB_PREFIX_.'carrier_group + WHERE id_carrier='.(int)$this->id); + } + /** * Clean delivery prices (weight/price) * diff --git a/classes/HelperList.php b/classes/HelperList.php index be5b8c1c7..74bf38edd 100644 --- a/classes/HelperList.php +++ b/classes/HelperList.php @@ -31,7 +31,7 @@ class HelperListCore extends Helper protected $_list = array(); /** @var integer Number of results in list */ - protected $_listTotal = 0; + public $_listTotal = 0; /** @var array WHERE clause determined by filter fields */ protected $_filter; @@ -95,7 +95,8 @@ class HelperListCore extends Helper 'id_category' => 'id_category_to_move', 'id_cms_category' => 'id_cms_category_to_move', 'id_cms' => 'id_cms', - 'id_attribute' => 'id_attribute' + 'id_attribute' => 'id_attribute', + 'id_carrier' => 'id_carrier' ); // @var boolean ask for simple header : no filters, no paginations and no sorting diff --git a/classes/HelperOptions.php b/classes/HelperOptions.php index 98b19316f..065945fc0 100644 --- a/classes/HelperOptions.php +++ b/classes/HelperOptions.php @@ -112,7 +112,7 @@ class HelperOptionsCore extends Helper // Is at least one required field present? if (isset($field['required']) && $field['required']) - $required_fields = true; + $this->required = true; } // Assign the modifications back to parent array $option_list[$category] = $category_data; @@ -122,7 +122,7 @@ class HelperOptionsCore extends Helper 'current' => $this->currentIndex, 'option_list' => $option_list, 'current_id_lang' => $this->context->language->id, - 'required_fields' => $required_fields, + 'required_fields' => $this->required, )); return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl); }