diff --git a/classes/Address.php b/classes/Address.php index eb25f2ea3..7cf3c116c 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -1,6 +1,6 @@ 32, 'company' => 32, 'lastname' => 32, 'firstname' => 32, + protected $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'city'); + protected $fieldsSize = array('alias' => 32, 'company' => 32, 'lastname' => 32, 'firstname' => 32, 'address1' => 128, 'address2' => 128, 'postcode' => 12, 'city' => 64, 'other' => 300, 'phone' => 16, 'phone_mobile' => 16, 'dni' => 16); - protected $fieldsValidate = array('id_customer' => 'isNullOrUnsignedId', 'id_manufacturer' => 'isNullOrUnsignedId', + protected $fieldsValidate = array('id_customer' => 'isNullOrUnsignedId', 'id_manufacturer' => 'isNullOrUnsignedId', 'id_supplier' => 'isNullOrUnsignedId', 'id_country' => 'isUnsignedId', 'id_state' => 'isNullOrUnsignedId', 'alias' => 'isGenericName', 'company' => 'isGenericName', 'lastname' => 'isName','vat_number' => 'isGenericName', 'firstname' => 'isName', 'address1' => 'isAddress', 'address2' => 'isAddress', 'postcode'=>'isPostCode', 'city' => 'isCityName', 'other' => 'isMessage', 'phone' => 'isPhoneNumber', 'phone_mobile' => 'isPhoneNumber', 'deleted' => 'isBool', 'dni' => 'isDniLite'); - protected $table = 'address'; - protected $identifier = 'id_address'; - protected $_includeVars = array('addressType' => 'table'); - protected $_includeContainer = false; + protected $table = 'address'; + protected $identifier = 'id_address'; + protected $_includeVars = array('addressType' => 'table'); + protected $_includeContainer = false; - protected $webserviceParameters = array( + protected $webserviceParameters = array( 'objectsNodeName' => 'addresses', 'fields' => array( 'id_customer' => array('xlink_resource'=> 'customers'), @@ -128,7 +128,7 @@ class AddressCore extends ObjectModel * * @param integer $id_address Existing address id in order to load object (optional) */ - public function __construct($id_address = NULL, $id_lang = NULL) + public function __construct($id_address = null, $id_lang = null) { parent::__construct($id_address); @@ -136,15 +136,15 @@ class AddressCore extends ObjectModel if ($this->id) { $result = Db::getInstance()->getRow('SELECT `name` FROM `'._DB_PREFIX_.'country_lang` - WHERE `id_country` = '.(int)($this->id_country).' - AND `id_lang` = '.($id_lang ? (int)($id_lang) : Configuration::get('PS_LANG_DEFAULT'))); + WHERE `id_country` = '.(int)$this->id_country.' + AND `id_lang` = '.($id_lang ? (int)$id_lang : Configuration::get('PS_LANG_DEFAULT'))); $this->country = $result['name']; } } - public function add($autodate = true, $nullValues = false) + public function add($autodate = true, $null_values = false) { - if (!parent::add($autodate, $nullValues)) + if (!parent::add($autodate, $null_values)) return false; if (Validate::isUnsignedId($this->id_customer)) @@ -167,13 +167,13 @@ class AddressCore extends ObjectModel } /** - * Returns fields required for an address in an array hash - * @return array hash values + * Returns fields required for an address in an array hash + * @return array hash values */ public static function getFieldsValidate() { $tmp_addr = new Address(); - $out = ($tmp_addr->fieldsValidate); + $out = $tmp_addr->fieldsValidate; unset($tmp_addr); return $out; @@ -186,12 +186,12 @@ class AddressCore extends ObjectModel { $this->validateFields(); if (isset($this->id)) - $fields['id_address'] = (int)($this->id); - $fields['id_customer'] = is_null($this->id_customer) ? 0 : (int)($this->id_customer); - $fields['id_manufacturer'] = is_null($this->id_manufacturer) ? 0 : (int)($this->id_manufacturer); - $fields['id_supplier'] = is_null($this->id_supplier) ? 0 : (int)($this->id_supplier); - $fields['id_country'] = (int)($this->id_country); - $fields['id_state'] = (int)($this->id_state); + $fields['id_address'] = (int)$this->id; + $fields['id_customer'] = is_null($this->id_customer) ? 0 : (int)$this->id_customer; + $fields['id_manufacturer'] = is_null($this->id_manufacturer) ? 0 : (int)$this->id_manufacturer; + $fields['id_supplier'] = is_null($this->id_supplier) ? 0 : (int)$this->id_supplier; + $fields['id_country'] = (int)$this->id_country; + $fields['id_state'] = (int)$this->id_state; $fields['alias'] = pSQL($this->alias); $fields['company'] = pSQL($this->company); $fields['lastname'] = pSQL($this->lastname); @@ -205,7 +205,7 @@ class AddressCore extends ObjectModel $fields['phone_mobile'] = pSQL($this->phone_mobile); $fields['vat_number'] = pSQL($this->vat_number); $fields['dni'] = pSQL($this->dni); - $fields['deleted'] = (int)($this->deleted); + $fields['deleted'] = (int)$this->deleted; $fields['date_add'] = pSQL($this->date_add); $fields['date_upd'] = pSQL($this->date_upd); return $fields; @@ -237,9 +237,9 @@ class AddressCore extends ObjectModel FROM `'._DB_PREFIX_.'address` a LEFT JOIN `'._DB_PREFIX_.'country` c ON c.`id_country` = a.`id_country` LEFT JOIN `'._DB_PREFIX_.'state` s ON s.`id_state` = a.`id_state` - WHERE a.`id_address` = '.(int)($id_address)); + WHERE a.`id_address` = '.(int)$id_address); - self::$_idZones[$id_address] = (int)((int)($result['id_zone_state']) ? $result['id_zone_state'] : $result['id_zone']); + self::$_idZones[$id_address] = (int)((int)$result['id_zone_state'] ? $result['id_zone_state'] : $result['id_zone']); return self::$_idZones[$id_address]; } @@ -255,7 +255,7 @@ class AddressCore extends ObjectModel SELECT c.`active` FROM `'._DB_PREFIX_.'address` a LEFT JOIN `'._DB_PREFIX_.'country` c ON c.`id_country` = a.`id_country` - WHERE a.`id_address` = '.(int)($id_address))) + WHERE a.`id_address` = '.(int)$id_address)) return false; return ($result['active']); } @@ -270,8 +270,8 @@ class AddressCore extends ObjectModel $result = Db::getInstance()->getRow(' SELECT COUNT(`id_order`) AS used FROM `'._DB_PREFIX_.'orders` - WHERE `id_address_delivery` = '.(int)($this->id).' - OR `id_address_invoice` = '.(int)($this->id)); + WHERE `id_address_delivery` = '.(int)$this->id.' + OR `id_address_invoice` = '.(int)$this->id); return isset($result['used']) ? $result['used'] : false; } @@ -282,7 +282,7 @@ class AddressCore extends ObjectModel return self::$_idCountries[$id_address]; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT `id_country`, `id_state`, `vat_number`, `postcode` FROM `'._DB_PREFIX_.'address` - WHERE `id_address` = '.(int)($id_address)); + WHERE `id_address` = '.(int)$id_address); self::$_idCountries[$id_address] = $result; return $result; } @@ -298,7 +298,7 @@ class AddressCore extends ObjectModel $row = Db::getInstance()->getRow(' SELECT `id_address` FROM '._DB_PREFIX_.'address a - WHERE a.`id_address` = '.(int)($id_address)); + WHERE a.`id_address` = '.(int)$id_address); return isset($row['id_address']); } @@ -308,7 +308,7 @@ class AddressCore extends ObjectModel return Db::getInstance()->getValue(' SELECT `id_address` FROM `'._DB_PREFIX_.'address` - WHERE `id_customer` = '.(int)($id_customer).' AND `deleted` = 0'.($active ? ' AND `active` = 1' : '') + WHERE `id_customer` = '.(int)$id_customer.' AND `deleted` = 0'.($active ? ' AND `active` = 1' : '') ); } }