bebeboutik/modules/privatesales_logistique/privatesales_logistique.php
Srv Bebeboutik 6c0978166c add modules
2016-01-04 12:49:26 +01:00

103 lines
2.4 KiB
PHP
Executable File

<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Description of InventoryTracking
*
* @author Pierre
*/
class Privatesales_logistique extends Module {
public function __construct()
{
$this->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;
}
}
?>