From a0e4124e3a63be6b11e44c7dce344cb8a841740b Mon Sep 17 00:00:00 2001 From: lLefevre Date: Thu, 3 Nov 2011 18:24:00 +0000 Subject: [PATCH] // fix add var current and back in helperList git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9868 b9a71923-0436-4b27-9f14-aed3839534dd --- .../template/helper/list/list_action_edit.tpl | 5 +- admin-dev/themes/template/statuses/form.tpl | 10 +- .../themes/template/tax_rules_group/form.tpl | 158 ++++++++++++++++++ classes/HelperList.php | 2 + .../admin/AdminTaxRulesGroupController.php | 6 +- 5 files changed, 169 insertions(+), 12 deletions(-) create mode 100644 admin-dev/themes/template/tax_rules_group/form.tpl diff --git a/admin-dev/themes/template/helper/list/list_action_edit.tpl b/admin-dev/themes/template/helper/list/list_action_edit.tpl index ca6ee9ac6..906d7e398 100644 --- a/admin-dev/themes/template/helper/list/list_action_edit.tpl +++ b/admin-dev/themes/template/helper/list/list_action_edit.tpl @@ -23,5 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$action} \ No newline at end of file + + {$action} + \ No newline at end of file diff --git a/admin-dev/themes/template/statuses/form.tpl b/admin-dev/themes/template/statuses/form.tpl index 3b2a321b1..9deebb0b7 100644 --- a/admin-dev/themes/template/statuses/form.tpl +++ b/admin-dev/themes/template/statuses/form.tpl @@ -74,11 +74,9 @@ {/block} {block name="script"} - + }); {/block} \ No newline at end of file diff --git a/admin-dev/themes/template/tax_rules_group/form.tpl b/admin-dev/themes/template/tax_rules_group/form.tpl new file mode 100644 index 000000000..681a98dd7 --- /dev/null +++ b/admin-dev/themes/template/tax_rules_group/form.tpl @@ -0,0 +1,158 @@ +{* +* 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 +*} +{extends file="../helper/form/form.tpl"} +{block name="label"} + {if $input.type == 'select' && $input.name == 'country[]'} + + {else} + + {/if} +{/block} + +{block name="script"} + + $(document).ready(function() { + + $('#country').click(function() { + populateStates($(this).val(), ''); + }); + + $('span.process-icon-new').parent().click(function() { + initForm(); + $('#add_new_tax_rule').slideToggle(); + }); + + $('table.tax_rule').find('a.edit').attr('href', '#'); + + }); + + function populateStates(id_country, id_state) + { + if ($("#country option:selected").size() > 1) + { + $("#zipcode-label").hide(); + $("#zipcode").hide(); + + $("#state-select").hide(); + $("#state-label").hide(); + } else { + $.ajax({ + url: "ajax.php", + cache: false, + data: "ajaxStates=1&id_country="+id_country+"&id_state="+id_state+"&empty_value={l s='All'}", + success: function(html){ + if (html == "false") + { + $("#state-label").hide(); + $("#state-select").hide(); + $("#states").html(''); + } + else + { + $("#state-label").show(); + $("#state-select").show(); + $("#states").html(html); + } + } + }); + + $("#zipcode-label").show(); + $("#zipcode").show(); + } + } + + function loadTaxRule(id_tax_rule) + { + $.ajax({ + type: 'POST', + url: 'ajax.php', + async: true, + dataType: 'json', + data: 'ajaxStates=1&ajaxUpdateTaxRule=1&id_tax_rule='+id_tax_rule, + success: function(data){ + $('#add_new_tax_rule').show(); + $('#id_tax_rule').val(data.id); + $('#country').val(data.id_country); + $('#state').val(data.id_state); + + zipcode = 0; + if (data.zipcode_from != 0) + { + zipcode = data.zipcode_from; + + if (data.zipcode_to != 0) + zipcode = zipcode +"-"+data.zipcode_to + } + + $('#zipcode').val(zipcode); + $('#behavior').val(data.behavior); + $('#id_tax').val(data.id_tax); + $('#description').val(data.description); + + populateStates(data.id_country, data.id_state); + } + }); + } + + function initForm() + { + $('#id_tax_rule').val(''); + $('#country').val(0); + $('#state').val(0); + $('#zipcode').val(0); + $('#behavior').val(0); + $('#tax').val(0); + $('#description').val(''); + + populateStates(0,0); + } +{/block} diff --git a/classes/HelperList.php b/classes/HelperList.php index 8400e7f92..a5f715f34 100644 --- a/classes/HelperList.php +++ b/classes/HelperList.php @@ -614,8 +614,10 @@ class HelperListCore extends Helper $this->footer_tpl->assign(array( 'token' => $this->token, 'table' => $this->table, + 'current' => $this->currentIndex, 'simple_header' => $this->simple_header, 'bulk_actions' => $this->bulk_actions, + 'back' => Tools::getValue('back'), 'no_back' => $this->no_back )); return $this->footer_tpl->fetch(); diff --git a/controllers/admin/AdminTaxRulesGroupController.php b/controllers/admin/AdminTaxRulesGroupController.php index a74662c5c..a0fc0a9b2 100644 --- a/controllers/admin/AdminTaxRulesGroupController.php +++ b/controllers/admin/AdminTaxRulesGroupController.php @@ -332,11 +332,9 @@ class AdminTaxRulesGroupControllerCore extends AdminController $this->getlanguages(); $helper = new HelperForm(); - // Check if form template has been overriden - if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'form_new.tpl')) - $helper->tpl = $this->tpl_folder.'form_new.tpl'; - + if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'form.tpl')) + $helper->setTpl($this->tpl_folder.'form.tpl'); $helper->currentIndex = self::$currentIndex; $helper->token = $this->token; $helper->table = 'tax_rule';