module = 'nkmgls'; parent::__construct(); } /** * Méthode ajax de création d'un transporteur */ public function displayAjaxCreateCarrier() { $return = array( 'hasError' => false, 'errors' => '', 'data' => '' ); $errors = array(); $gls_carrier_code = Tools::getValue('code'); if (! empty($gls_carrier_code) && array_key_exists($gls_carrier_code, NkmGls::$carrier_definition)) { if ($this->module->createCarrier($gls_carrier_code)) { die(json_encode($return)); } else { $return['hasError'] = true; $errors[] = sprintf($this->l('Error creating the new carrier %s'), $gls_carrier_code); } } else { $return['hasError'] = true; $errors[] = $this->l('Invalid parameters'); } if (count($errors) > 0) { $return['errors'] = implode("\r\n", $errors); $return['hasError'] = true; } die(json_encode($return)); } /** * Add an entry in the tab menu */ public static function installInBO() { $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminGlsAjax"; $tab->name = array(); foreach (Language::getLanguages(true) as $lang) { $tab->name[(int) $lang['id_lang']] = 'GLSAjax'; } $tab->id_parent = - 1; $tab->module = 'nkmgls'; return $tab->add(); } /** * Remove an entry in the tab menu */ public static function removeFromBO() { $id_tab = (int) Tab::getIdFromClassName('AdminGlsAjax'); if ($id_tab) { $tab = new Tab($id_tab); if (validate::isLoadedObject($tab)) { return $tab->delete(); } } return false; } }