jepot Posted September 10, 2013 Share Posted September 10, 2013 Bonjour à tous, actuellement sur PS 1.4.9 je rencontre un leger problème, le module expeditor la poste rencontre des problèmes lorsqu'il y a des accents dans le nom et l'adresse exemple : étienne devient e'tienne. Ma solution serait de remplacer automatiquement les accents dans le formulaire d'adresse (classes/Address.php ) mais la je bloque : public function getFields() { parent::validateFields(); $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); $fields['firstname'] = pSQL($this->firstname); $fields['address1'] = pSQL($this->address1); $fields['address2'] = pSQL($this->address2); $fields['postcode'] = pSQL($this->postcode); $fields['city'] = pSQL($this->city); $fields['other'] = pSQL($this->other); $fields['phone'] = pSQL($this->phone); $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['date_add'] = pSQL($this->date_add); $fields['date_upd'] = pSQL($this->date_upd); return $fields; }J'arrive pas exemple à tout mettre en majuscule en mettant (Tools::strtolower(($this->address1)); mais l'accent reste sur la majuscule :-( et en mettant (Tools::mb_strtolower(($this->address1)); là j'obtient un page blanche... Auriez vous une idée ? Merci d'avance ;-) Link to comment Share on other sites More sharing options...
domi77185 Posted September 10, 2013 Share Posted September 10, 2013 Peut-être créer une fonction qui fera cela. function sansaccent($chaineTest) { $accent = array("é", "è", "ê", "ë"); $chaineModifiee = str_replace($accent , "", $chaineTest); // Possiblité d'ajouter d'autre tests pour "ç", "à",.... return $chaineModifiee ; } Puis modifier : $fields['lastname'] = $this->sansaccent(pSQL($this->lastname)); $fields['firstname'] = $this->sansaccent(pSQL($this->firstname)); $fields['address1'] = $this->sansaccent(pSQL($this->address1)); $fields['address2'] = $this->sansaccent(pSQL($this->address2)); Voila rapidement un début de piste Link to comment Share on other sites More sharing options...
jepot Posted September 10, 2013 Author Share Posted September 10, 2013 Merci ça m'a largement aidé, ça marche à présent grace au code suivant pour ceux que cela intéresse : public static function getFieldsValidate() { $tmp_addr = new Address(); $out = ($tmp_addr->fieldsValidate); unset($tmp_addr); return $out; }function stripAccents($string){$string = mb_strtolower($string, 'UTF-8');$string = str_replace(array('à', 'â', 'ä', 'á', 'ã', 'å','î', 'ï', 'ì', 'í','ô', 'ö', 'ò', 'ó', 'õ', 'ø','ù', 'û', 'ü', 'ú','é', 'è', 'ê', 'ë','ç', 'ÿ', 'ñ',),array('a', 'a', 'a', 'a', 'a', 'a','i', 'i', 'i', 'i','o', 'o', 'o', 'o', 'o', 'o','u', 'u', 'u', 'u','e', 'e', 'e', 'e','c', 'y', 'n',),$string);return $string;} public function getFields() { parent::validateFields(); $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'] = $this->stripAccents(pSQL($this->alias)); $fields['company'] = $this->stripAccents(pSQL($this->company)); $fields['lastname'] = $this->stripAccents(pSQL($this->lastname)); $fields['firstname'] = $this->stripAccents(pSQL($this->firstname)); $fields['address1'] = $this->stripAccents(pSQL($this->address1)); $fields['address2'] = $this->stripAccents(pSQL($this->address2)); $fields['postcode'] = pSQL($this->postcode); $fields['city'] = $this->stripAccents(pSQL($this->city)); $fields['other'] = $this->stripAccents(pSQL($this->other)); $fields['phone'] = pSQL($this->phone); $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['date_add'] = pSQL($this->date_add); $fields['date_upd'] = pSQL($this->date_upd); return $fields; } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now