name = 'privatesales_logistique'; $this->tab = 'administration'; $this->author = 'Antadis'; $this->version = '1.0'; $this->displayName = $this->l('Private sales logistics'); $this->description = $this->l('Private sales logistics tools'); parent::__construct(); } public function install() { if(!file_exists(_PS_MODULE_DIR_.'privatesales/Sale.php')) throw new Exception("Sale Class doesn't exists", 1); if( !parent::install() || !$this->installTab() || !$this->installDb() ) return false; return true; } public function installDb() { Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'privatesale_order_form` ( `id_order_form` int(11) NOT NULL AUTO_INCREMENT, `id_category` int(11) NOT NULL, `from` date NOT NULL, `to` date NOT NULL, `date_add` datetime NOT NULL, PRIMARY KEY (`id_order_form`) ) ENGINE=InnoDB '); return true; } public function installTab() { $parent_tab = Db::getInstance()->getValue('SELECT id_tab FROM '._DB_PREFIX_.'tab WHERE id_parent = 0 AND class_name = "AdminPrivateSales"'); if(!$parent_tab) $parent_tab = 1; //CATALOG TAB if(!self::createTab($parent_tab, $this->name, 'Logistique', 'AdminPrivateSalesLogistique')) return false; return true; } static function createTab($id_parent, $module, $name, $class_name) { $Tab = new Tab(); $Tab->module = $module; foreach(Language::getLanguages(true) as $languages) { $Tab->name[$languages["id_lang"]] = $name; } $Tab->id_parent = $id_parent; $Tab->class_name = $class_name; $r = $Tab->save(); if($r === false) return false; return $Tab->id; } public function uninstall() { if(!parent::uninstall()) return false; Db::getInstance()->Execute('DROP TABLE `'._DB_PREFIX_.'privatesale_order_form`'); return true; } } ?>