From 0ac8d632f067e85f1c21b4f6c71064f3ad194ef8 Mon Sep 17 00:00:00 2001 From: vChabot Date: Thu, 26 Jan 2012 17:31:55 +0000 Subject: [PATCH] [-] BO : BugFix #PSTEST-561 customer creation in fancybox is improved : you cannot select the visitor and guest group as the default group and theses groups are unchecked for the group access --- .../admin/AdminCustomersController.php | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 3af916269..bb5c1e77b 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -358,22 +358,34 @@ class AdminCustomersControllerCore extends AdminController 'values' => $groups, 'required' => true, 'desc' => $this->l('Check all the box(es) of groups of which the customer is to be a member') - ), - array( - 'type' => 'select', - 'label' => $this->l('Default group:'), - 'name' => 'id_default_group', - 'options' => array( - 'query' => $groups, - 'id' => 'id_group', - 'name' => 'name' - ), - 'hint' => $this->l('The group will be as applied by default.'), - 'desc' => $this->l('Apply the discount\'s price of this group.') ) ) ); + // if we add a customer via fancybox (ajax), it's a customer and he doesn't need to be added to the visitor and guest groups + if (Tools::isSubmit('addcustomer') && Tools::isSubmit('submitFormAjax')) + { + $visitor_group = Configuration::get('PS_UNIDENTIFIED_GROUP'); + $guest_group = Configuration::get('PS_GUEST_GROUP'); + foreach ($groups as $key => $g) + if (in_array($g['id_group'], array($visitor_group, $guest_group))) + unset($groups[$key]); + } + + $this->fields_form['input'][] = + array( + 'type' => 'select', + 'label' => $this->l('Default group:'), + 'name' => 'id_default_group', + 'options' => array( + 'query' => $groups, + 'id' => 'id_group', + 'name' => 'name' + ), + 'hint' => $this->l('The group will be as applied by default.'), + 'desc' => $this->l('Apply the discount\'s price of this group.') + ); + // if customer is a guest customer, password hasn't to be there if ($obj->id && ($obj->is_guest && $obj->id_default_group == Configuration::get('PS_GUEST_GROUP'))) {