dolibarr/htdocs/core/modules/modAccounting.class.php

240 lines
7.7 KiB
PHP
Raw Normal View History

2011-08-31 13:05:58 +02:00
<?php
2014-08-27 07:03:42 +02:00
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
2014-09-09 09:46:57 +02:00
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
2014-08-27 07:03:42 +02:00
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
2011-08-31 13:05:58 +02:00
*
* 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
2011-08-31 13:05:58 +02:00
* (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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/modules/modAccounting.class.php
2016-04-22 06:58:18 +02:00
* \ingroup Advanced accountancy
2014-08-27 07:03:42 +02:00
* \brief Module to activate Accounting Expert module
2011-08-31 13:05:58 +02:00
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
2011-08-31 13:05:58 +02:00
/**
2017-02-24 16:23:43 +01:00
* Description and activation class for module accounting expert
2011-08-31 13:05:58 +02:00
*/
class modAccounting extends DolibarrModules
{
/**
2014-08-29 06:43:05 +02:00
* Constructor. Define names, constants, directories, boxes, permissions
2011-08-31 13:05:58 +02:00
*
2014-08-29 06:43:05 +02:00
* @param DoliDB $db Database handler
*/
function __construct($db)
2011-08-31 13:05:58 +02:00
{
global $conf;
$this->db = $db;
2014-08-27 07:03:42 +02:00
$this->numero = 50400;
2014-09-09 09:46:57 +02:00
2011-08-31 13:05:58 +02:00
$this->family = "financial";
$this->module_position = 610;
2011-08-31 13:05:58 +02:00
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2014-08-27 07:03:42 +02:00
$this->name = preg_replace('/^mod/i', '', get_class($this));
2014-09-09 09:46:57 +02:00
$this->description = "Advanced accounting management";
2016-12-31 16:35:56 +01:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this->version = 'dolibarr';
2014-09-09 09:46:57 +02:00
2014-08-27 07:03:42 +02:00
$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
2011-08-31 13:05:58 +02:00
$this->special = 0;
2014-08-28 06:48:22 +02:00
$this->picto = 'accounting';
2014-09-09 09:46:57 +02:00
2014-08-27 07:03:42 +02:00
// Data directories to create when module is enabled
2014-09-09 09:46:57 +02:00
$this->dirs = array('/accounting/temp');
2011-08-31 13:05:58 +02:00
// Config pages
$this->config_page_url = array();
2014-09-09 09:46:57 +02:00
2014-08-27 07:03:42 +02:00
// Dependencies
2014-09-09 09:46:57 +02:00
$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, 3); // Minimum version of PHP required by module
2016-06-29 16:54:37 +02:00
$this->need_dolibarr_version = array(3, 9); // Minimum version of Dolibarr required by module
$this->langfiles = array("accountancy","compta");
2014-09-09 09:46:57 +02:00
2011-08-31 13:05:58 +02:00
// Constants
2014-09-09 09:46:57 +02:00
$this->const = array();
$this->const[1] = array(
2014-08-27 07:03:42 +02:00
"MAIN_COMPANY_CODE_ALWAYS_REQUIRED",
"chaine",
"1",
"With this constants on, third party code is always required whatever is numbering module behaviour"
);
2014-09-09 09:46:57 +02:00
$this->const[2] = array(
2014-08-27 07:03:42 +02:00
"MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED",
"chaine",
"1",
"With this constants on, bank account number is always required"
);
$this->const[3] = array(
2014-08-27 07:03:42 +02:00
"ACCOUNTING_ACCOUNT_SUSPENSE",
"chaine",
2014-09-09 09:46:57 +02:00
"471"
2014-08-27 07:03:42 +02:00
);
2014-09-09 09:46:57 +02:00
$this->const[4] = array(
2014-08-27 07:03:42 +02:00
"ACCOUNTING_ACCOUNT_TRANSFER_CASH",
"chaine",
2014-09-09 09:46:57 +02:00
"58"
2014-08-27 07:03:42 +02:00
);
$this->const[5] = array(
2014-08-27 07:03:42 +02:00
"CHARTOFACCOUNTS",
"chaine",
2014-09-09 09:46:57 +02:00
"2"
2014-08-27 07:03:42 +02:00
);
$this->const[6] = array(
"ACCOUNTING_EXPORT_MODELCSV",
2014-08-27 07:03:42 +02:00
"chaine",
2015-02-03 06:39:44 +01:00
"1"
2014-08-27 07:03:42 +02:00
);
$this->const[7] = array(
2014-08-27 07:03:42 +02:00
"ACCOUNTING_LENGTH_GACCOUNT",
"chaine",
2014-09-09 09:46:57 +02:00
""
2014-08-27 07:03:42 +02:00
);
$this->const[8] = array(
2014-08-27 07:03:42 +02:00
"ACCOUNTING_LENGTH_AACCOUNT",
"chaine",
2014-09-09 09:46:57 +02:00
""
2014-08-27 07:03:42 +02:00
);
$this->const[9] = array(
2014-08-27 07:03:42 +02:00
"ACCOUNTING_LIST_SORT_VENTILATION_TODO",
"yesno",
2014-09-09 09:46:57 +02:00
"1"
2014-08-27 07:03:42 +02:00
);
$this->const[10] = array(
2014-08-27 07:03:42 +02:00
"ACCOUNTING_LIST_SORT_VENTILATION_DONE",
"yesno",
2014-09-09 09:46:57 +02:00
"1"
2014-08-27 07:03:42 +02:00
);
$this->const[11] = array (
"ACCOUNTING_EXPORT_DATE",
"chaine",
"%d%m%Y"
);
$this->const[12] = array(
"ACCOUNTING_EXPORT_SEPARATORCSV",
"string",
","
);
$this->const[13] = array(
"ACCOUNTING_EXPORT_FORMAT",
"chaine",
"csv"
);
2014-09-09 09:46:57 +02:00
2014-08-27 07:03:42 +02:00
// Tabs
$this->tabs = array();
2014-09-09 09:46:57 +02:00
2014-08-27 07:03:42 +02:00
// Css
2014-09-09 09:46:57 +02:00
$this->module_parts = array();
2011-08-31 13:05:58 +02:00
// Boxes
2014-09-09 09:46:57 +02:00
$this->boxes = array();
2011-08-31 13:05:58 +02:00
// Permissions
$this->rights_class = 'accounting';
2014-09-09 09:46:57 +02:00
$this->rights = array(); // Permission array used by this module
2014-08-27 07:03:42 +02:00
$r = 0;
2014-09-09 09:46:57 +02:00
2016-10-13 21:48:07 +02:00
$this->rights[$r][0] = 50440;
$this->rights[$r][1] = 'Manage chart of accounts, setup of accountancy';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'chartofaccount';
$this->rights[$r][5] = '';
$r++;
2017-06-15 19:29:00 +02:00
$this->rights[$r][0] = 50401;
2016-10-13 21:48:07 +02:00
$this->rights[$r][1] = 'Bind products and invoices with accounting accounts';
2014-08-28 07:13:33 +02:00
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
2016-10-13 21:48:07 +02:00
$this->rights[$r][4] = 'bind';
$this->rights[$r][5] = 'write';
2014-08-28 07:13:33 +02:00
$r++;
2014-09-09 09:46:57 +02:00
2016-10-13 21:48:07 +02:00
/*
$this->rights[$r][0] = 50402;
2016-10-13 21:48:07 +02:00
$this->rights[$r][1] = 'Make binding with products and invoices';
2014-08-28 07:13:33 +02:00
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'ventilation';
2016-10-13 21:48:07 +02:00
$this->rights[$r][5] = 'dispatch_advanced';
2014-08-28 07:13:33 +02:00
$r++;
2016-10-13 21:48:07 +02:00
*/
2017-06-15 19:29:00 +02:00
2014-08-28 06:48:22 +02:00
$this->rights[$r][0] = 50411;
2017-06-15 19:29:00 +02:00
$this->rights[$r][1] = 'Read operations in Ledger';
2014-08-28 06:48:22 +02:00
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mouvements';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 50412;
2017-06-15 19:29:00 +02:00
$this->rights[$r][1] = 'Write/Edit operations in Ledger';
2014-08-28 06:48:22 +02:00
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mouvements';
$this->rights[$r][5] = 'creer';
$r++;
$this->rights[$r][0] = 50420;
2017-06-15 19:29:00 +02:00
$this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, ledger)';
2014-08-28 06:48:22 +02:00
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'comptarapport';
$this->rights[$r][5] = 'lire';
$r++;
2014-09-09 09:46:57 +02:00
$this->rights[$r][0] = 50430;
$this->rights[$r][1] = 'Define and close a fiscal year';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'fiscalyear';
$this->rights[$r][5] = '';
$r++;
2016-06-29 16:54:37 +02:00
// Menus
//-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
2017-06-15 19:29:00 +02:00
// Exports
//--------
$r=0;
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='Chartofaccounts';
$this->export_icon[$r]='accounting';
$this->export_permission[$r]=array(array("accounting","chartofaccount"));
$this->export_fields_array[$r]=array('ac.rowid'=>'ChartofaccountsId','ac.pcg_version'=>'Chartofaccounts','aa.rowid'=>'Id','aa.account_number'=>"AccountAccounting",'aa.label'=>"Label",'aa.account_parent'=>"Accountparent",'aa.pcg_type'=>"Pcgtype",'aa.pcg_subtype'=>'Pcgsubtype','aa.active'=>'Status');
$this->export_TypeFields_array[$r]=array('ac.rowid'=>'List:accounting_system:pcg_version','aa.account_number'=>"Text",'aa.label'=>"Text",'aa.pcg_type'=>'Text','aa.pcg_subtype'=>'Text','aa.active'=>'Status');
$this->export_entities_array[$r]=array('ac.rowid'=>"accounting",'ac.pcg_version'=>"accounting",'aa.rowid'=>'accounting','aa.account_number'=>"accounting",'aa.label'=>"accounting",'aa.accountparent'=>"accounting",'aa.pcg_type'=>"accounting",'aa.pcgsubtype'=>"accounting",'aa_active'=>"accounting");
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'accounting_account as aa, '.MAIN_DB_PREFIX.'accounting_system as ac';
$this->export_sql_end[$r] .=' WHERE ac.pcg_version = aa.fk_pcg_version AND aa.entity IN ('.getEntity('accounting').') ';
2011-08-31 13:05:58 +02:00
}
}