2014-09-21 17:42:38 +02:00
< ? php
2019-01-28 21:39:22 +01:00
/* Copyright ( C ) 2014 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2014-09-21 17:42:38 +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
* ( 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
* or see https :// www . gnu . org /
2014-09-21 17:42:38 +02:00
*/
/**
* \defgroup tax Module Loans
* \brief Module to include loans management
* \file htdocs / core / modules / modLoan . class . php
* \ingroup loan
2021-03-20 13:55:43 +01:00
* \brief Description and activation file for the module loan
2014-09-21 17:42:38 +02:00
*/
2020-04-10 10:59:32 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2014-09-21 17:42:38 +02:00
/**
* Class to manage loan module
*/
class modLoan extends DolibarrModules
{
/**
* Constructor . Define names , constants , directories , boxes , permissions
*
* @ param DoliDB $db Database handler
*/
2019-02-25 20:35:59 +01:00
public function __construct ( $db )
2014-09-21 17:42:38 +02:00
{
global $conf ;
$this -> db = $db ;
$this -> numero = 520 ;
$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)
2019-01-27 11:55:16 +01:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2014-09-21 17:42:38 +02:00
// Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this -> description = " Loans management " ;
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
2016-04-06 11:21:55 +02:00
$this -> version = 'dolibarr' ;
2014-09-21 17:42:38 +02:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2020-04-20 18:38:25 +02:00
$this -> picto = 'money-bill-alt' ;
2014-09-21 17:42:38 +02:00
// Data directories to create when module is enabled
$this -> dirs = array ( " /loan/temp " );
// Config pages
$this -> config_page_url = array ( 'loan.php' );
2015-09-07 15:29:51 +02:00
// Dependencies
2020-04-10 10:59:32 +02:00
$this -> hidden = false ; // A condition to hide module
$this -> depends = array (); // List of module class names as string that must be enabled if this module is enabled
$this -> requiredby = array (); // List of module ids to disable if this one is disabled
$this -> conflictwith = array (); // List of module class names as string this module is in conflict with
2022-09-27 20:48:47 +02:00
$this -> phpmin = array ( 7 , 0 ); // Minimum version of PHP required by module
2014-09-21 17:42:38 +02:00
$this -> langfiles = array ( " loan " );
// Constants
$this -> const = array ();
$this -> const [ 0 ] = array (
" LOAN_ACCOUNTING_ACCOUNT_CAPITAL " ,
" chaine " ,
" 164 "
);
$this -> const [ 1 ] = array (
" LOAN_ACCOUNTING_ACCOUNT_INTEREST " ,
" chaine " ,
" 6611 "
);
2023-01-01 23:50:37 +01:00
$this -> const [ 2 ] = array (
2014-09-21 17:42:38 +02:00
" LOAN_ACCOUNTING_ACCOUNT_INSURANCE " ,
" chaine " ,
" 6162 "
);
// Boxes
$this -> boxes = array ();
// Permissions
$this -> rights = array ();
$this -> rights_class = 'loan' ;
2020-04-10 10:59:32 +02:00
$r = 0 ;
2014-09-21 17:42:38 +02:00
$r ++ ;
2021-04-05 13:52:19 +02:00
$this -> rights [ $r ][ 0 ] = 521 ;
2014-09-21 17:42:38 +02:00
$this -> rights [ $r ][ 1 ] = 'Read loans' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
2016-06-04 12:16:30 +02:00
$this -> rights [ $r ][ 3 ] = 0 ;
2014-09-21 17:42:38 +02:00
$this -> rights [ $r ][ 4 ] = 'read' ;
$this -> rights [ $r ][ 5 ] = '' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 522 ;
$this -> rights [ $r ][ 1 ] = 'Create/modify loans' ;
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'write' ;
$this -> rights [ $r ][ 5 ] = '' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 524 ;
$this -> rights [ $r ][ 1 ] = 'Delete loans' ;
$this -> rights [ $r ][ 2 ] = 'd' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'delete' ;
$this -> rights [ $r ][ 5 ] = '' ;
2018-02-25 10:55:02 +01:00
2014-11-17 06:38:06 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 525 ;
$this -> rights [ $r ][ 1 ] = 'Access loan calculator' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'calc' ;
$this -> rights [ $r ][ 5 ] = '' ;
2014-09-21 17:42:38 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 527 ;
$this -> rights [ $r ][ 1 ] = 'Export loans' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'export' ;
$this -> rights [ $r ][ 5 ] = '' ;
2018-02-25 10:55:02 +01:00
2016-09-30 13:02:13 +02:00
// Menus
//-------
2020-04-10 10:59:32 +02:00
$this -> menu = 1 ; // This module add menu entries. They are coded into menu manager.
2018-02-25 10:55:02 +01:00
2014-09-21 17:42:38 +02:00
// Exports
//--------
2020-04-10 10:59:32 +02:00
$r = 0 ;
2014-09-21 17:42:38 +02:00
}
/**
2019-02-26 21:13:07 +01:00
* 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
2014-09-21 17:42:38 +02:00
*
2020-10-31 14:32:18 +01:00
* @ param string $options Options when enabling module ( '' , 'noboxes' )
2019-02-26 21:13:07 +01:00
* @ return int 1 if OK , 0 if KO
2014-09-21 17:42:38 +02:00
*/
2019-02-26 21:13:07 +01:00
public function init ( $options = '' )
2014-09-21 17:42:38 +02:00
{
2022-05-08 15:18:34 +02:00
$result = $this -> _load_tables ( '/install/mysql/' , 'loan' );
2022-02-06 13:31:44 +01:00
if ( $result < 0 ) {
return - 1 ; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}
2014-09-21 17:42:38 +02:00
// Clean before activation
$this -> remove ( $options );
$sql = array ();
2019-01-27 11:55:16 +01:00
return $this -> _init ( $sql , $options );
2014-09-21 17:42:38 +02:00
}
}