dolibarr 23.0.3
modLoan.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
26include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27
28
33{
39 public function __construct($db)
40 {
41 $this->db = $db;
42 $this->numero = 520;
43
44 $this->family = "financial";
45 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
46 $this->name = preg_replace('/^mod/i', '', get_class($this));
47 // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
48 $this->description = "Loans management";
49
50 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
51 $this->version = 'dolibarr';
52
53 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54 $this->picto = 'loan';
55
56 // Data directories to create when module is enabled
57 $this->dirs = array("/loan/temp");
58
59 // Config pages
60 $this->config_page_url = array('loan.php');
61
62 // Dependencies
63 $this->hidden = false; // A condition to hide module
64 $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
65 $this->requiredby = array(); // List of module ids to disable if this one is disabled
66 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
67 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
68 $this->langfiles = array("loan");
69
70 // Constants
71 $this->const = array();
72 $this->const[0] = array(
73 "LOAN_ACCOUNTING_ACCOUNT_CAPITAL",
74 "chaine",
75 "164"
76 );
77 $this->const[1] = array(
78 "LOAN_ACCOUNTING_ACCOUNT_INTEREST",
79 "chaine",
80 "6611"
81 );
82 $this->const[2] = array(
83 "LOAN_ACCOUNTING_ACCOUNT_INSURANCE",
84 "chaine",
85 "6162"
86 );
87
88 // Boxes
89 $this->boxes = array();
90
91 // Permissions
92 $this->rights = array();
93 $this->rights_class = 'loan';
94 $r = 0;
95
96 $r++;
97 $this->rights[$r][0] = 521;
98 $this->rights[$r][1] = 'Read loans';
99 $this->rights[$r][2] = 'r';
100 $this->rights[$r][3] = 0;
101 $this->rights[$r][4] = 'read';
102 $this->rights[$r][5] = '';
103
104 $r++;
105 $this->rights[$r][0] = 522;
106 $this->rights[$r][1] = 'Create/modify loans';
107 $this->rights[$r][2] = 'w';
108 $this->rights[$r][3] = 0;
109 $this->rights[$r][4] = 'write';
110 $this->rights[$r][5] = '';
111
112 $r++;
113 $this->rights[$r][0] = 524;
114 $this->rights[$r][1] = 'Delete loans';
115 $this->rights[$r][2] = 'd';
116 $this->rights[$r][3] = 0;
117 $this->rights[$r][4] = 'delete';
118 $this->rights[$r][5] = '';
119
120 $r++;
121 $this->rights[$r][0] = 525;
122 $this->rights[$r][1] = 'Access loan calculator';
123 $this->rights[$r][2] = 'r';
124 $this->rights[$r][3] = 0;
125 $this->rights[$r][4] = 'calc';
126 $this->rights[$r][5] = '';
127
128 $r++;
129 $this->rights[$r][0] = 527;
130 $this->rights[$r][1] = 'Export loans';
131 $this->rights[$r][2] = 'r';
132 $this->rights[$r][3] = 0;
133 $this->rights[$r][4] = 'export';
134 $this->rights[$r][5] = '';
135
136
137 // Menus
138 //-------
139 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
140
141
142 // Exports
143 //--------
144 $r = 0;
145 }
146
147
156 public function init($options = '')
157 {
158 $result = $this->_load_tables('/install/mysql/', 'loan');
159 if ($result < 0) {
160 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')
161 }
162
163 // Clean before activation
164 $this->remove($options);
165
166 $sql = array();
167
168 return $this->_init($sql, $options);
169 }
170}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Class to manage loan module.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:128