diff --git a/classes/Customer.php b/classes/Customer.php index 2983aa607..6923209a3 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -149,8 +149,7 @@ class CustomerCore extends ObjectModel 'last_passwd_gen' => array('setter' => null), 'secure_key' => array('setter' => null), 'deleted' => array(), - 'passwd' => array('setter' => 'setWsPasswd'), - 'phone' => array() + 'passwd' => array('setter' => 'setWsPasswd') ), 'associations' => array( 'groups' => array('resource' => 'group'), @@ -180,6 +179,7 @@ class CustomerCore extends ObjectModel 'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret'), 'ape' => array('type' => self::TYPE_STRING, 'validate' => 'isApe'), + 'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32), 'outstanding_allow_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'copy_post' => false), 'show_public_prices' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), 'id_risk' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false), @@ -206,12 +206,8 @@ public function __construct($id = null) $this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP'); parent::__construct($id); - if ($this->email) { - $this->phone = CartCustomerGuestDetail::getCustomerPhone($this->email); - } - if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) { - $this->webserviceParameters['fields']['phone']['required'] = true; + self::$definition['fields']['phone']['required'] = true; } } @@ -264,7 +260,7 @@ public function add($autodate = true, $null_values = true) } $success = parent::add($autodate, $null_values); $this->updateGroup($this->groupBox); - $this->updateCustomerAdditionalDetails(CartCustomerGuestDetail::getIdCustomerGuest($this->email)); + return $success; } @@ -289,22 +285,9 @@ public function update($nullValues = false) $objOldCustomer = new Customer($this->id); $success = parent::update(true); - $this->updateCustomerAdditionalDetails(CartCustomerGuestDetail::getIdCustomerGuest($objOldCustomer->email)); return $success; } - public function updateCustomerAdditionalDetails($idCustomerGuest) - { - $objCartCustomerGuestDetail = new CartCustomerGuestDetail($idCustomerGuest); - $objCartCustomerGuestDetail->id_cart = 0; - $objCartCustomerGuestDetail->id_gender = $this->id_gender; - $objCartCustomerGuestDetail->firstname = $this->firstname; - $objCartCustomerGuestDetail->lastname = $this->lastname; - $objCartCustomerGuestDetail->email = $this->email; - $objCartCustomerGuestDetail->phone = $this->phone; - return $objCartCustomerGuestDetail->save(); - } - public function delete() { if (!count(Order::getCustomerOrders((int)$this->id))) { @@ -343,8 +326,6 @@ public function delete() CartRule::deleteByIdCustomer((int)$this->id); // delete customer data from customerGuest table - $objCartCustomerGuestDetail = new CartCustomerGuestDetail(CartCustomerGuestDetail::getIdCustomerGuest($this->email)); - $objCartCustomerGuestDetail->delete(); return parent::delete(); } diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index c8e20a62e..997cb0508 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -141,6 +141,11 @@ public function __construct() 'align' => 'text-right', 'badge_success' => true ), + 'phone' => array( + 'title' => $this->l('Phone'), + 'optional' => true, + 'visible_default' => false, + ), 'active' => array( 'title' => $this->l('Enabled'), 'align' => 'text-center', diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index de57c4024..c4dc5ff7e 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -606,6 +606,7 @@ CREATE TABLE `PREFIX_customer` ( `max_payment_days` int(10) unsigned NOT NULL DEFAULT '60', `secure_key` varchar(32) NOT NULL DEFAULT '-1', `note` text, + `phone` varchar(32) DEFAULT NULL, `active` tinyint(1) unsigned NOT NULL DEFAULT '0', `is_guest` tinyint(1) NOT NULL DEFAULT '0', `deleted` tinyint(1) NOT NULL DEFAULT '0',