'', 'id_tax' => 1, 'id_tax_rules_group' => 1, 'url' => 'http://www.colissimo.fr/portail_colissimo/suivreResultat.do?parcelnumber=@', 'active' => true, 'deleted' => 0, 'shipping_handling' => false, 'range_behavior' => 0, 'is_module' => false, 'id_zone' => 1, 'shipping_external' => true, 'external_module_name' => 'soflexibilite', 'need_range' => true ); public function __construct($id = null, $id_lang = null) { parent::__construct($id, $id_lang); } public function add($autodate = true, $null_values = false) { if (parent::add($autodate, $null_values)) { if (version_compare(_PS_VERSION_, '1.5', '>=') && Feature::isFeatureActive()) { Configuration::updateGlobalValue('SOFLEXIBILITE_'.$this->mode.'_ID', (int)$this->id, false); } else { Configuration::updateValue('SOFLEXIBILITE_'.$this->mode.'_ID', (int)$this->id); } return true; } return false; } public function setColissimoConfiguration($active) { foreach (self::$carrier_config as $k => $v) { $this->{$k} = $v; } $this->name .= $this->getNameExtension(); $this->active = (int)$active; $this->setColissimoDelay(); } private function setColissimoDelay() { foreach (Language::getLanguages(false) as $language) { if ($language['iso_code'] == 'fr') { switch ($this->mode) { case 'DOM': case 'DOS': $this->delay[$language['id_lang']] = 'Faites vous livrer à une adresse de votre choix, '. ($this->mode === 'DOM' ? 'sans' : 'avec').' signature'; break; case 'BPR': $this->delay[$language['id_lang']] = 'Faites vous livrer dans un des bureaux de poste parmi '. '10 000 points de retrait partout en France'; break; case 'A2P': $this->delay[$language['id_lang']] = 'Faites vous livrer dans un des relais pickup ou '. 'consignes Pickup Station parmi 8 000 points de retrait partout en France'; break; default: $this->delay[$language['id_lang']] = 'Faites vous livrer en France selon votre choix'; break; } } else { switch ($this->mode) { case 'DOM': case 'DOS': $this->delay[$language['id_lang']] = 'Get delivered at home, in France '. ($this->mode === 'DOM' ? 'with' : 'without').' signature'; break; case 'BPR': $this->delay[$language['id_lang']] = 'Get delivered among one of our 10 000 post-offices '. 'everywhere in France'; break; case 'A2P': $this->delay[$language['id_lang']] = 'Get delivered in one of our relay pickup or '. 'Pickup Station among 8 000 relay everywhere in France'; break; default: $this->delay[$language['id_lang']] = 'Get delivered in France according to your choice'; break; } } } } private function getNameExtension() { $name_extension = null; switch ($this->mode) { case 'DOM': $name_extension = self::TEXT_DOM; break; case 'DOS': $name_extension = self::TEXT_DOS; break; case 'BPR': $name_extension = self::TEXT_BPR; break; case 'A2P': $name_extension = self::TEXT_A2P; break; } return html_entity_decode($name_extension, ENT_COMPAT, 'UTF-8'); } public static function getSoColissimoCarriers(Context $context) { $ps15x = version_compare(_PS_VERSION_, '1.5', '>='); $sql = 'SELECT c.*, cl.delay FROM `'._DB_PREFIX_.'carrier` c LEFT JOIN `'._DB_PREFIX_.'carrier_lang` cl ON ( c.`id_carrier` = cl.`id_carrier` AND cl.`id_lang` = '.(int)$context->language->id.' ) WHERE c.`deleted` = 0 AND c.`external_module_name` = "soflexibilite" GROUP BY c.`id_carrier`'; if ($ps15x) { $sql .= ' ORDER BY c.`position` ASC'; } $carriers = Db::getInstance()->executeS($sql); if (!is_array($carriers)) { $carriers = array(); ConfigureMessage::error( 'Beware : you do not have any So Colissimo carrier linked to this module. '. 'A new install or reset is necessary.' ); } else { foreach (array_keys($carriers) as $key) { $carriers[$key]['logo'] = __PS_BASE_URI__.'img/s/'.(int)$carriers[$key]['id_carrier'].'.jpg'; if (version_compare(_PS_VERSION_, '1.5.4.1', '>')) { $carriers[$key]['conf_url'] = '?controller=AdminCarrierWizard&token='. Tools::getAdminToken( 'AdminCarrierWizard'.(int)Tab::getIdFromClassName('AdminCarrierWizard'). (int)$context->employee->id ).'&id_carrier='.(int)$carriers[$key]['id_carrier']; } elseif ($ps15x) { $carriers[$key]['conf_url'] = '?controller=AdminCarriers&id_carrier='. (int)$carriers[$key]['id_carrier'].'&updatecarrier&token='. Tools::getAdminToken( 'AdminCarriers'.(int)Tab::getIdFromClassName('AdminCarriers'). (int)$context->employee->id ); } else { $carriers[$key]['conf_url'] = '?tab=AdminCarriers&id_carrier='.(int)$carriers[$key]['id_carrier']. '&updatecarrier&token='.Tools::getAdminToken( 'AdminCarriers'.(int)Tab::getIdFromClassName('AdminCarriers'). (int)$context->employee->id ); } } } return ($carriers); } }