* Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2014 Ari Elbaz (elarifr) * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file accountingex/core/modules/modAccountingExpert.class.php * \ingroup Accounting Expert * \brief Module to activate Accounting Expert module */ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; /** * \class modAccountingExpert * \brief Description and activation class for module accounting expert */ class modAccounting extends DolibarrModules { /** * Constructor. * Define names, constants, directories, boxes, permissions * * @param DoliDB $db */ function __construct($db) { global $conf; $this->db = $db; $this->numero = 50400; $this->family = "financial"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Advanced manage of accounting"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'development'; $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); $this->special = 0; $this->picto = 'accountingex@accountingex'; // Defined if the directory /mymodule/inc/triggers/ contains triggers or not // $this->triggers = 1; // Data directories to create when module is enabled $this->dirs = array ( '/accountingex/temp' ); // Config pages $this->config_page_url = array('index.php@accounting'); // Dependencies $this->depends = array ("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled $this->requiredby = array (); // List of modules id to disable if this one is disabled $this->conflictwith = array ("modComptabilite"); // List of modules are in conflict with this module $this->phpmin = array ( 5, 2 ); // Minimum version of PHP required by module $this->need_dolibarr_version = array ( 3, 4 ); // Minimum version of Dolibarr required by module $this->langfiles = array ( "accountingex@accountingex" ); // Constants $this->const = array (); $this->const[1] = array ( "MAIN_COMPANY_CODE_ALWAYS_REQUIRED", "chaine", "1", "With this constants on, third party code is always required whatever is numbering module behaviour" ); $this->const[2] = array ( "MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED", "chaine", "1", "With this constants on, bank account number is always required" ); $this->const[1] = array ( "ACCOUNTING_SEPARATORCSV", "string", "," ); $this->const[2] = array ( "ACCOUNTING_ACCOUNT_SUSPENSE", "chaine", "471" ); $this->const[3] = array ( "ACCOUNTING_SELL_JOURNAL", "chaine", "VTE" ); $this->const[4] = array ( "ACCOUNTING_PURCHASE_JOURNAL", "chaine", "ACH" ); $this->const[5] = array ( "ACCOUNTING_SOCIAL_JOURNAL", "chaine", "SOC" ); $this->const[6] = array ( "ACCOUNTING_CASH_JOURNAL", "chaine", "CAI" ); $this->const[7] = array ( "ACCOUNTING_MISCELLANEOUS_JOURNAL", "chaine", "OD" ); $this->const[8] = array ( "ACCOUNTING_BANK_JOURNAL", "chaine", "BQ" ); // Deprecated Move into llx_bank_account $this->const[9] = array ( "ACCOUNTING_ACCOUNT_TRANSFER_CASH", "chaine", "58" ); $this->const[10] = array ( "CHARTOFACCOUNTS", "chaine", "2" ); $this->const[11] = array ( "ACCOUNTING_MODELCSV", "chaine", "0" ); $this->const[12] = array ( "ACCOUNTING_LENGTH_GACCOUNT", "chaine", "" ); $this->const[13] = array ( "ACCOUNTING_LENGTH_AACCOUNT", "chaine", "" ); $this->const[14] = array ( "ACCOUNTING_LIMIT_LIST_VENTILATION", "chaine", "50" ); $this->const[15] = array ( "ACCOUNTING_LIST_SORT_VENTILATION_TODO", "yesno", "1" ); $this->const[16] = array ( "ACCOUNTING_LIST_SORT_VENTILATION_DONE", "yesno", "1" ); // Tabs $this->tabs = array(); // Css $this->module_parts = array ( 'css' => array ( '/accountingex/css/accountingex.css.php' ) ); // Boxes $this->boxes = array (); // Permissions $this->rights_class = 'accounting'; $this->rights = array (); // Permission array used by this module $r = 0; $this->rights[$r][0] = 150001; // Permission id (must not be already used) $this->rights[$r][1] = 'Acces_module'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'access'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r ++; $this->rights[$r][0] = 150002; // Permission id (must not be already used) $this->rights[$r][1] = 'Administration_module'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'admin'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r ++; $this->rights[$r][0] = 150010; // Permission id (must not be already used) $this->rights[$r][1] = 'Développement'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'dev'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r ++; // Main menu entries $this->menus = array (); $r = 0; $this->menu[$r] = array ( 'fk_menu' => 0, 'type' => 'top', 'titre' => 'Accounting', 'mainmenu' => 'accounting', 'leftmenu' => '0', 'url' => '/accountingex/customer/index.php', 'langs' => 'accountingex@accountingex', 'position' => 100, 'perms' => '$user->rights->accountingex->access', 'enabled' => '$conf->accountingexpert->enabled', 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting', 'type' => 'left', 'titre' => 'CustomersVentilation', 'leftmenu' => 'CustomersVentilation', 'mainmenu' => 'accounting', 'url' => '/accountingex/customer/index.php', 'langs' => 'accountingex@accountingex', 'position' => 101, 'enabled' => 1, 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=CustomersVentilation', 'type' => 'left', 'titre' => 'ToDispatch', 'leftmenu' => 'ToDispatchCustomer', 'mainmenu' => 'accounting', 'url' => '/accountingex/customer/liste.php', 'langs' => 'accountingex@accountingex', 'position' => 102, 'enabled' => 1, 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=CustomersVentilation', 'type' => 'left', 'titre' => 'Dispatched', 'leftmenu' => 'DispatchedCustomer', 'mainmenu' => 'accounting', 'url' => '/accountingex/customer/lignes.php', 'langs' => 'accountingex@accountingex', 'position' => 103, 'enabled' => 1, 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting', 'type' => 'left', 'titre' => 'SuppliersVentilation', 'leftmenu' => 'SuppliersVentilation', 'mainmenu' => 'accounting', 'url' => '/accountingex/supplier/index.php', 'langs' => 'accountingex@accountingex', 'position' => 110, 'enabled' => '$conf->fournisseur->enabled', 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=SuppliersVentilation', 'type' => 'left', 'titre' => 'ToDispatch', 'leftmenu' => 'ToDispatchSupplier', 'mainmenu' => 'accounting', 'url' => '/accountingex/supplier/liste.php', 'langs' => 'accountingex@accountingex', 'position' => 111, 'enabled' => '$conf->fournisseur->enabled', 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=SuppliersVentilation', 'type' => 'left', 'titre' => 'Dispatched', 'leftmenu' => 'DispatchedSupplier', 'mainmenu' => 'accounting', 'url' => '/accountingex/supplier/lignes.php', 'langs' => 'accountingex@accountingex', 'position' => 112, 'enabled' => '$conf->fournisseur->enabled', 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting', 'type' => 'left', 'titre' => 'Journaux', 'leftmenu' => 'Journaux', 'mainmenu' => 'accounting', // 'url'=>'', 'langs' => 'accountingex@accountingex', 'position' => 120, 'enabled' => 1, 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', 'type' => 'left', 'titre' => 'SellsJournal', 'leftmenu' => 'SellsJournal', 'mainmenu' => 'accounting', 'url' => '/accountingex/journal/sellsjournal.php', 'langs' => 'accountingex@accountingex', 'position' => 121, 'enabled' => 1, 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', 'type' => 'left', 'titre' => 'PurchasesJournal', 'leftmenu' => 'PurchasesJournal', 'mainmenu' => 'accounting', 'url' => '/accountingex/journal/purchasesjournal.php', 'langs' => 'accountingex@accountingex', 'position' => 122, 'enabled' => '$conf->fournisseur->enabled', 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', 'type' => 'left', 'titre' => 'CashJournal', 'leftmenu' => 'CashJournal', 'mainmenu' => 'accounting', 'url' => '/accountingex/journal/cashjournal.php', 'langs' => 'accountingex@accountingex', 'position' => 123, 'enabled' => 1, 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', 'type' => 'left', 'titre' => 'BankJournal', 'leftmenu' => 'BankJournal', 'mainmenu' => 'accounting', 'url' => '/accountingex/journal/bankjournal.php', 'langs' => 'accountingex@accountingex', 'position' => 200, 'enabled' => '$conf->banque->enabled', 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting', 'type' => 'left', 'titre' => 'Bookkeeping', 'leftmenu' => 'Bookkeeping', 'mainmenu' => 'accounting', 'url' => '/accountingex/bookkeeping/liste.php', 'langs' => 'accountingex@accountingex', 'position' => 300, 'enabled' => 1, 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Bookkeeping', 'type' => 'left', 'titre' => 'ByYear', 'leftmenu' => 'ByYear', 'mainmenu' => 'accounting', 'url' => '/accountingex/bookkeeping/listebyyear.php', 'langs' => 'accountingex@accountingex', 'position' => 301, 'enabled' => 1, 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Bookkeeping', 'type' => 'left', 'titre' => 'AccountBalanceByMonth', 'leftmenu' => 'AccountBalanceByMonth', 'mainmenu' => 'accounting', 'url' => '/accountingex/bookkeeping/balancebymonth.php', 'langs' => 'accountingex@accountingex', 'position' => 302, 'enabled' => 1, 'perms' => 1, 'target' => '', 'user' => 0 ); $r ++; // Parameters Menu $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting', 'type' => 'left', 'titre' => 'Parameters', 'leftmenu' => 'Parameters', 'mainmenu' => 'accounting', 'url' => '/accountingex/admin/index.php', 'langs' => 'accountingex@accountingex', 'position' => 400, 'enabled' => 1, 'perms' => '$user->rights->accountingex->admin', 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters', 'type' => 'left', 'titre' => 'Globalparameters', 'leftmenu' => 'Globalparameters', 'mainmenu' => 'accounting', 'url' => '/accountingex/admin/index.php', 'langs' => 'accountingex@accountingex', 'position' => 401, 'enabled' => 1, 'perms' => '$user->rights->accountingex->admin', 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Globalparameters', 'type' => 'left', 'titre' => 'Chartofaccounts', 'leftmenu' => 'Chartofaccounts', 'mainmenu' => 'accounting', 'url' => '/accountingex/admin/account.php', 'langs' => 'accountingex@accountingex', 'position' => 402, 'enabled' => 1, 'perms' => '$user->rights->accountingex->admin', 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Globalparameters', 'type' => 'left', 'titre' => 'Menuaccount', 'leftmenu' => 'Menuaccount', 'mainmenu' => 'accounting', 'url' => '/accountingex/admin/account.php', 'langs' => 'accountingex@accountingex', 'position' => 403, 'enabled' => 1, 'perms' => '$user->rights->accountingex->admin', 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters', 'type' => 'left', 'titre' => 'Menuthirdpartyaccount', 'mainmenu' => 'accounting', 'url' => '/accountingex/admin/thirdpartyaccount.php', 'langs' => 'accountingex@accountingex', 'position' => 404, 'enabled' => 1, 'perms' => '$user->rights->accountingex->admin', 'target' => '', 'user' => 0 ); $r ++; $this->menu[$r] = array ( 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters', 'type' => 'left', 'titre' => 'MenuTools', 'mainmenu' => 'accounting', 'url' => '/accountingex/admin/productaccount.php', 'langs' => 'accountingex@accountingex', 'position' => 405, 'enabled' => 1, 'perms' => '$user->rights->accountingex->admin', 'target' => '', 'user' => 0 ); $r ++; } /** * Function called when module is enabled. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ function init($options='') { $sql = array(); return $this->_init($sql,$options); } /** * Function called when module is disabled. * Remove from database constants, boxes and permissions from Dolibarr database. * Data directories are not deleted * * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ function remove($options='') { $sql = array(); return $this->_remove($sql,$options); } }