From 67d478fa3901ac37f939b4aa9ca6da9c6674ad5b Mon Sep 17 00:00:00 2001 From: rGaillard Date: Mon, 20 Feb 2012 13:25:55 +0000 Subject: [PATCH] // Improve and debug backoffice order --- .../addresses/helpers/list/list_header.tpl | 34 +++++++++++++++++++ .../customers/helpers/list/list_header.tpl | 10 +++++- .../template/controllers/orders/form.tpl | 9 +++-- .../default/template/form_submit_ajax.tpl | 4 ++- classes/controller/AdminController.php | 8 +++-- .../admin/AdminAddressesController.php | 7 ++++ .../admin/AdminCustomersController.php | 12 ++++++- 7 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 admin-dev/themes/default/template/controllers/addresses/helpers/list/list_header.tpl diff --git a/admin-dev/themes/default/template/controllers/addresses/helpers/list/list_header.tpl b/admin-dev/themes/default/template/controllers/addresses/helpers/list/list_header.tpl new file mode 100644 index 000000000..f6ea7ef1b --- /dev/null +++ b/admin-dev/themes/default/template/controllers/addresses/helpers/list/list_header.tpl @@ -0,0 +1,34 @@ +{* +* 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: 10891 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} +{extends file="helpers/list/list_header.tpl"} +{block name='override_header'} +{if $submit_form_ajax} + +{/if} +{/block} diff --git a/admin-dev/themes/default/template/controllers/customers/helpers/list/list_header.tpl b/admin-dev/themes/default/template/controllers/customers/helpers/list/list_header.tpl index 21262fe79..96470fc9b 100644 --- a/admin-dev/themes/default/template/controllers/customers/helpers/list/list_header.tpl +++ b/admin-dev/themes/default/template/controllers/customers/helpers/list/list_header.tpl @@ -25,7 +25,15 @@ *} {extends file="helpers/list/list_header.tpl"} - +{block name='override_header'} +{if $submit_form_ajax} + +{/if} +{/block} {block name=leadin} {if isset($delete_customer) && $delete_customer}
diff --git a/admin-dev/themes/default/template/controllers/orders/form.tpl b/admin-dev/themes/default/template/controllers/orders/form.tpl index e14cbbca4..25a88cb07 100755 --- a/admin-dev/themes/default/template/controllers/orders/form.tpl +++ b/admin-dev/themes/default/template/controllers/orders/form.tpl @@ -212,7 +212,7 @@ { $('.fancybox').fancybox({ 'type': 'iframe', - 'width': '50%', + 'width': '60%', 'height': '100%' }); /*$("#new_address").fancybox({ @@ -304,7 +304,12 @@ } }); } - + + function getSummary() + { + useCart(id_cart); + } + function deleteVoucher(id_cart_rule) { $.ajax({ diff --git a/admin-dev/themes/default/template/form_submit_ajax.tpl b/admin-dev/themes/default/template/form_submit_ajax.tpl index bd2e3813c..1c9ff73c9 100644 --- a/admin-dev/themes/default/template/form_submit_ajax.tpl +++ b/admin-dev/themes/default/template/form_submit_ajax.tpl @@ -30,6 +30,7 @@ e.preventDefault(); var form_datas = new Object; form_datas['liteDisplaying'] = 1; + form_datas['submitFormAjax'] = 1; var form_inputs = $('#{$table}_form input, #{$table}_form textarea, #{$table}_form button'); var form_selects = $('#{$table}_form select'); $.each(form_inputs, function() { @@ -39,7 +40,8 @@ form_datas[this.name] = this.value; }); $.each(form_selects, function() { - form_datas[this.name] = this[this.options.selectedIndex].value; + if (this.options != undefined && this.options.selectedIndex != undefined && this[this.options.selectedIndex] != undefined) + form_datas[this.name] = this[this.options.selectedIndex].value; }); $.ajax({ type: this.method, diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 980d5884a..bd3da62aa 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -624,13 +624,13 @@ class AdminControllerCore extends Controller $this->afterAdd($object); $this->updateAssoShop($object->id); // Save and stay on same form - if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) + if (empty($this->redirect_after) && $this->redirect_after !== false && Tools::isSubmit('submitAdd'.$this->table.'AndStay')) $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&update'.$this->table.'&token='.$token; // Save and back to parent - if (Tools::isSubmit('submitAdd'.$this->table.'AndBackToParent')) + if (empty($this->redirect_after) && $this->redirect_after !== false && Tools::isSubmit('submitAdd'.$this->table.'AndBackToParent')) $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$parent_id.'&conf=3&token='.$token; // Default behavior (save and back) - if (empty($this->redirect_after)) + if (empty($this->redirect_after) && $this->redirect_after !== false) $this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$token; } } @@ -1693,6 +1693,8 @@ class AdminControllerCore extends Controller 'current' => self::$currentIndex, 'token' => $this->token, )); + + $this->context->smarty->assign('submit_form_ajax', (int)Tools::getValue('submitFormAjax')); $this->initProcess(); } diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index ec0852520..28f9cc206 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -370,6 +370,13 @@ class AdminAddressesControllerCore extends AdminController Tools::redirectAdmin(Tools::getValue('back').'&conf=4'); } } + + public function processAdd($token) + { + if (Tools::getValue('submitFormAjax')) + $this->redirect_after = false; + return parent::processAdd($token); + } /** * Get Address formats used by the country where the address id retrieved from POST/GET is. diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index ea1d1d3dd..17823f6e5 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -719,6 +719,8 @@ class AdminCustomersControllerCore extends AdminController public function processAdd($token) { + if (Tools::getValue('submitFormAjax')) + $this->redirect_after = false; // Check that the new email is not already in use $customer_email = strval(Tools::getValue('email')); $customer = new Customer(); @@ -727,7 +729,15 @@ class AdminCustomersControllerCore extends AdminController if ($customer->id) $this->errors[] = Tools::displayError('An account already exists for this e-mail address:').' '.$customer_email; else - return parent::processAdd($token); + { + if ($customer = parent::processAdd($token)) + { + $this->context->smarty->assign('new_customer', $customer); + return true; + } + else + return false; + } }