Creating new plugin
This commit is contained in:
80
modules/eksporthistorii/eksporthistorii.php
Normal file
80
modules/eksporthistorii/eksporthistorii.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class EksportHistorii extends Module
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'eksporthistorii';
|
||||
$this->tab = 'administration';
|
||||
$this->version = '1.0.0';
|
||||
$this->author = 'Custom';
|
||||
$this->need_instance = 0;
|
||||
$this->bootstrap = true;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->l('Eksport historii zamówień');
|
||||
$this->description = $this->l('Eksport historii zamówień do pliku Excel (CSV).');
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
return parent::install()
|
||||
&& $this->installTab();
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
return $this->uninstallTab()
|
||||
&& parent::uninstall();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodanie zakładki jako podmenu w "Zamówienia"
|
||||
*/
|
||||
protected function installTab()
|
||||
{
|
||||
// rodzic: Orders / Zamówienia
|
||||
$id_parent = (int) Tab::getIdFromClassName('AdminParentOrders');
|
||||
|
||||
$tab = new Tab();
|
||||
$tab->active = 1;
|
||||
$tab->class_name = 'AdminEksportHistorii';
|
||||
$tab->name = [];
|
||||
|
||||
foreach (Language::getLanguages(false) as $lang) {
|
||||
$tab->name[$lang['id_lang']] = 'Eksport historii';
|
||||
}
|
||||
|
||||
$tab->id_parent = $id_parent;
|
||||
$tab->module = $this->name;
|
||||
|
||||
return (bool) $tab->add();
|
||||
}
|
||||
|
||||
/**
|
||||
* Usunięcie zakładki przy deinstalacji
|
||||
*/
|
||||
protected function uninstallTab()
|
||||
{
|
||||
// Usuwamy naszą aktualną zakładkę
|
||||
$id_tab = (int) Tab::getIdFromClassName('AdminEksportHistorii');
|
||||
if ($id_tab) {
|
||||
$tab = new Tab($id_tab);
|
||||
$tab->delete();
|
||||
}
|
||||
|
||||
// Sprzątamy ewentualną starą zakładkę (ze starego modułu)
|
||||
$old_id_tab = (int) Tab::getIdFromClassName('AdminEksportowanieIstorii');
|
||||
if ($old_id_tab) {
|
||||
$old_tab = new Tab($old_id_tab);
|
||||
$old_tab->delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user