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