2017-07-13 16:46:11 +02:00
|
|
|
<?php
|
|
|
|
if (!defined('_PS_VERSION_'))
|
|
|
|
exit;
|
|
|
|
|
|
|
|
class Ant_Supplierdemand extends Module
|
|
|
|
{
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->name = 'ant_supplierdemand';
|
|
|
|
$this->tab = 'administration';
|
|
|
|
$this->author = 'Antadis';
|
|
|
|
$this->version = '1.0';
|
|
|
|
$this->need_instance = 0;
|
|
|
|
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->displayName = $this->l('Administration of supplier demands');
|
|
|
|
$this->description = $this->l('Track every request made to suppliers.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function install()
|
|
|
|
{
|
|
|
|
if (!$this->installDB()){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(parent::install())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function uninstall() {
|
|
|
|
|
|
|
|
if(parent::uninstall() == false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function installDB()
|
|
|
|
{
|
|
|
|
$result = true;
|
|
|
|
# Add tables
|
|
|
|
$query = '
|
|
|
|
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'supplier_demand` (
|
|
|
|
`id_supplier_demand` INTEGER NOT NULL AUTO_INCREMENT,
|
|
|
|
`id_order` INTEGER NOT NULL,
|
|
|
|
`id_order_detail` INTEGER NOT NULL,
|
|
|
|
`qty` INTEGER NOT NULL,
|
|
|
|
`id_state` INTEGER NOT NULL DEFAULT 1,
|
|
|
|
`comment` TEXT,
|
2017-07-28 12:16:24 +02:00
|
|
|
`solution` INTEGER NOT NULL DEFAULT 0,
|
2017-07-13 16:46:11 +02:00
|
|
|
`date_add` DATETIME NOT NULL,
|
|
|
|
`date_upd` DATETIME NOT NULL,
|
|
|
|
PRIMARY KEY(`id_supplier_demand`)
|
|
|
|
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8
|
|
|
|
';
|
|
|
|
|
|
|
|
$result = Db::getInstance()->Execute($query);
|
|
|
|
|
|
|
|
$query = '
|
|
|
|
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'supplier_demand_history` (
|
|
|
|
`id_supplier_demand_history` INTEGER NOT NULL AUTO_INCREMENT,
|
|
|
|
`id_supplier_demand` INTEGER NOT NULL,
|
|
|
|
`id_employee` INTEGER NOT NULL,
|
|
|
|
`id_state` INTEGER NOT NULL,
|
|
|
|
`date_add` DATETIME NOT NULL,
|
|
|
|
PRIMARY KEY(`id_supplier_demand_history`)
|
|
|
|
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8
|
|
|
|
';
|
|
|
|
|
|
|
|
$result = (Db::getInstance()->Execute($query) and $result);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|