From 550aa01faf28f453612c91dbf2b993651b89a8f0 Mon Sep 17 00:00:00 2001 From: jeromenadaud Date: Thu, 1 Aug 2013 15:14:14 +0200 Subject: [PATCH] [-] BO : FixBug #PSCFV-9859 Carriers free shipping inline edit --- controllers/admin/AdminCarriersController.php | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/controllers/admin/AdminCarriersController.php b/controllers/admin/AdminCarriersController.php index b2120da5f..126134938 100644 --- a/controllers/admin/AdminCarriersController.php +++ b/controllers/admin/AdminCarriersController.php @@ -87,11 +87,7 @@ class AdminCarriersControllerCore extends AdminController 'is_free' => array( 'title' => $this->l('Free Shipping'), 'align' => 'center', - 'icon' => array( - 0 => 'disabled.gif', - 1 => 'enabled.gif', - 'default' => 'disabled.gif' - ), + 'active' => 'isFree', 'type' => 'bool', 'orderby' => false, 'width' => 150 @@ -534,6 +530,10 @@ class AdminCarriersControllerCore extends AdminController else $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } + else if (isset($_GET['isFree'.$this->table])) + { + $this->processIsFree(); + } else { if ((Tools::isSubmit('submitDel'.$this->table) && in_array(Configuration::get('PS_CARRIER_DEFAULT'), Tools::getValue('carrierBox'))) @@ -566,6 +566,17 @@ class AdminCarriersControllerCore extends AdminController } } + public function processIsFree() + { + $carrier = new Carrier($this->id_object); + if (!Validate::isLoadedObject($carrier)) + $this->errors[] = Tools::displayError('An error occurred while updating carrier information.'); + $carrier->is_free = $carrier->is_free ? 0 : 1; + if (!$carrier->update()) + $this->errors[] = Tools::displayError('An error occurred while updating carrier information.'); + Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token); + } + /** * Overload the property $fields_value *