name = 'expeditor';
$this->tab = 'Import/export';
$this->version = '0.4';
parent::__construct ();
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Expeditor Inet') . ' ©';
$this->description = $this->l('Manage yours orders between Prestashop and your Expeditor Inet software');
}
public function install()
{
global $cookie;
if (!parent::install())
return false;
$this->installDB();
if (!$id_tab = $this->installAdmin())
return false;
if (!Configuration::get('EXPEDITOR_STATE_EXP'))
Configuration::updateValue('EXPEDITOR_STATE_EXP', _PS_OS_PREPARATION_);
if (!Configuration::get('EXPEDITOR_STATE_IMP'))
Configuration::updateValue('EXPEDITOR_STATE_IMP', _PS_OS_PREPARATION_);
if (!Configuration::get('EXPEDITOR_CARRIER'))
Configuration::updateValue('EXPEDITOR_CARRIER', 0);
if (!Configuration::get('EXPEDITOR_MULTIPLY'))
Configuration::updateValue('EXPEDITOR_MULTIPLY', 1000);
if (!Configuration::get('EXPEDITOR_CARRIER_CODES'))
Configuration::updateValue('EXPEDITOR_CARRIER_CODES', NULL);
if (!sizeof($this->_errors))
Tools::redirectAdmin('index.php?tab=AdminModules&configure='.$this->name.'&token='.Tools::getAdminToken('AdminModules'.intval(Tab::getIdFromClassName('AdminModules')).intval($cookie->id_employee)));
foreach ($this->_errors as $errors)
echo $errors.'
';
return false;
}
function installDB()
{
Db::getInstance()->Execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'expeditor` (
`id_expeditor` INT NOT NULL AUTO_INCREMENT,
`id_order` INT NOT NULL,
`weight` FLOAT NOT NULL DEFAULT 0,
`standard_size` BOOLEAN NOT NULL DEFAULT 1,
`is_send` BOOLEAN NOT NULL DEFAULT 0,
`date_add` DATETIME NOT NULL,
`date_upd` DATETIME NOT NULL,
PRIMARY KEY (`id_expeditor`),
INDEX index_order_expeditor (`id_order`)
);');
}
function installAdmin()
{
$tab = new Tab();
$tab->class_name = 'AdminExpeditor';
$tab->id_parent = 3;
$tab->name[Configuration::get('PS_LANG_DEFAULT')] = $this->l('Expeditor Inet');
if ($tab->add())
{
if (!@copy(dirname(__FILE__).'/AdminExpeditor.php', dirname('index.php').'/tabs/AdminExpeditor.php'))
$this->_errors[] = $this->l('Please manually copy ') .dirname(__FILE__).'/AdminExpeditor.php'.' in the \'tabs\' folder located in your admin directory.';
if (!@copy(dirname(__FILE__).'/ExpeditorModule.php', dirname(__FILE__).'/../../classes/ExpeditorModule.php'))
$this->_errors[] = $this->l('Please manually copy ') .dirname(__FILE__).'/ExpeditorModule.php'.' in the \'classes\' folder located in your shop directory.';
if (!@copy(dirname(__FILE__).'/logo.gif', dirname(__FILE__).'/../../img/t/adminExpeditor.gif'))
$this->_errors[] = $this->l('Please manually copy ') .dirname(__FILE__).'/logo.gif'.' as '.dirname(__FILE__).'/../../img/t/adminExpeditor.gif.';
return $tab->id;
}
return false;
}
function uninstall()
{
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'tab` WHERE `class_name` = \'AdminExpeditor\'');
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'tab_lang` WHERE `id_tab` NOT IN (SELECT `id_tab` FROM `'._DB_PREFIX_.'tab`)');
@unlink(dirname('index.php').'/tabs/AdminExpeditor.php');
@unlink(dirname(__FILE__).'/../../classes/ExpeditorModule.php');
@unlink(dirname(__FILE__).'/../../img/t/'.Tab::getIdFromClassName('AdminExpeditor').'.gif');
return (parent::uninstall(false));
}
public function getContent()
{
$this->_html .= '
'.$this->l('Direct access to Expeditor tab.').'
'; return $this->_html; } private function _displayForm() { global $cookie; $this->orderStateExp = Configuration::get('EXPEDITOR_STATE_EXP'); $this->orderStateImp = Configuration::get('EXPEDITOR_STATE_IMP'); $this->_html .= ''; $this->_html .= ' ' . $this->l('Download format file for import data') . ''; $this->_html .= '
'; } } ?>