dolibarr 24.0.0-beta
modSalaries.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
5 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2014-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
9 * Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 * or see https://www.gnu.org/
24 */
25
33include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
34
35
40{
46 public function __construct($db)
47 {
48 $this->db = $db;
49 $this->numero = 510; // Perms from 501..519
50
51 // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
52 // It is used to group modules by family in module setup page
53 $this->family = "financial";
54 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
55 $this->name = preg_replace('/^mod/i', '', get_class($this));
56 // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
57 $this->description = "Payment of salaries";
58
59 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
60 $this->version = 'dolibarr';
61
62 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
63 $this->picto = 'salary';
64
65 // Data directories to create when module is enabled
66 $this->dirs = array("/salaries/temp");
67
68 // Parts of module
69 $this->module_parts = array(
70 'models' => 1,
71 'triggers' => 0,
72 'substitutions' => 0,
73 );
74
75 // Config pages
76 $this->config_page_url = array('salaries.php@salaries');
77
78 // Dependencies
79 $this->hidden = false; // A condition to hide module
80 $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
81 $this->requiredby = array(); // List of module ids to disable if this one is disabled
82 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
83 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
84 $this->langfiles = array("salaries", "bills");
85
86 // Constants
87 $this->const = [
88 [
89 "SALARIES_ACCOUNTING_ACCOUNT_PAYMENT",
90 "chaine",
91 "421",
92 "",
93 0,
94 ],
95 [
96 "SALARIES_ACCOUNTING_ACCOUNT_CHARGE",
97 "chaine",
98 "641",
99 "",
100 0,
101 ]
102 ];
103
104 // Boxes
105 $this->boxes = array();
106
107 // Permissions
108 $this->rights = array();
109 $this->rights_class = 'salaries';
110 $r = 0;
111
112 $r++;
113 $this->rights[$r][0] = 511;
114 $this->rights[$r][1] = 'Read employee salaries and payments (yours only)';
115 $this->rights[$r][2] = 'r';
116 $this->rights[$r][3] = 0;
117 $this->rights[$r][4] = 'read';
118 $this->rights[$r][5] = '';
119
120 $r++;
121 $this->rights[$r][0] = 512;
122 $this->rights[$r][1] = 'Read employee salaries and payments (yours and of your subordinates)';
123 $this->rights[$r][2] = 'r';
124 $this->rights[$r][3] = 0;
125 $this->rights[$r][4] = 'readchild';
126 $this->rights[$r][5] = '';
127
128 $r++;
129 $this->rights[$r][0] = 513;
130 $this->rights[$r][1] = 'Create/modify payments of empoyee salaries';
131 $this->rights[$r][2] = 'w';
132 $this->rights[$r][3] = 0;
133 $this->rights[$r][4] = 'write';
134 $this->rights[$r][5] = '';
135
136 $r++;
137 $this->rights[$r][0] = 514;
138 $this->rights[$r][1] = 'Delete payments of employee salary';
139 $this->rights[$r][2] = 'd';
140 $this->rights[$r][3] = 0;
141 $this->rights[$r][4] = 'delete';
142 $this->rights[$r][5] = '';
143
144 $r++;
145 $this->rights[$r][0] = 517;
146 $this->rights[$r][1] = 'Read salaries and payments (of all employees)';
147 $this->rights[$r][2] = 'r';
148 $this->rights[$r][3] = 0;
149 $this->rights[$r][4] = 'readall';
150
151 $r++;
152 $this->rights[$r][0] = 519;
153 $this->rights[$r][1] = 'Export payments of employee salaries';
154 $this->rights[$r][2] = 'r';
155 $this->rights[$r][3] = 0;
156 $this->rights[$r][4] = 'export';
157 $this->rights[$r][5] = '';
158
159
160
161 // Menus
162 //-------
163 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
164
165
166 // Exports
167 //--------
168 $r = 0;
169
170 $r++;
171 $this->export_code[$r] = $this->rights_class.'_'.$r;
172 $this->export_label[$r] = 'SalariesAndPayments';
173 $this->export_icon[$r] = 'salary';
174 $this->export_permission[$r] = array(array("salaries", "export"));
175 $this->export_fields_array[$r] = array('s.rowid' => 'SalaryID', 's.label'=>'Label', 's.datesp'=>'DateStartPeriod', 's.dateep'=>'DateEndPeriod', 's.amount' => 'SalaryAmount', 's.paye' => 'Status', 'u.firstname'=>"Firstname", 'u.lastname'=>"Lastname", 'u.login'=>"Login", 'u.salary'=>'CurrentSalary', 'p.datep'=>'DatePayment', 'p.amount'=>'AmountPayment', 'p.num_payment'=>'Numero', 'p.note'=>'Note');
176 $this->export_TypeFields_array[$r] = array('s.rowid' => 'Numeric', 's.label'=>'Text', 's.amount' => 'Numeric', 's.paye' => 'Numeric', 'u.firstname'=>"Text", 'u.lastname'=>"Text", 'u.login'=>'Text', 'u.salary'=>"Numeric", 'p.datep'=>'Date', 's.datesp'=>'Date', 's.dateep'=>'Date', 'p.amount'=>'Numeric', 'p.num_payment'=>'Numeric');
177 $this->export_entities_array[$r] = array('u.firstname'=>'user', 'u.lastname'=>'user', 'u.login'=>'user', 'u.salary'=>'user', 'p.datep'=>'payment', 'p.datesp'=>'payment', 'p.dateep'=>'payment', 'p.amount'=>'payment', 'p.label'=>'payment', 'p.note'=>'payment', 'p.num_payment'=>'payment');
178
179 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
180 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'salary as s';
181 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON s.fk_user = u.rowid';
182 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_salary = s.rowid';
183 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id';
184 $this->export_sql_end[$r] .= ' AND s.entity IN ('.getEntity('salary').')';
185 }
186
195 public function init($options = '')
196 {
197 global $conf;
198
199 // Clean before activation
200 $this->remove($options);
201
202 // Ensure data directory exists
203 $dirSalary = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/salaries/temp';
204 if (!is_dir($dirSalary)) {
205 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
206 dol_mkdir($dirSalary);
207 }
208
209 // Register the PDF model
210 $sql = array();
211 $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model
212 WHERE nom = 'standard_salary'
213 AND type = 'salary'
214 AND entity = ".((int) $conf->entity);
215
216 $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity)
217 VALUES ('standard_salary', 'salary', ".((int) $conf->entity).")";
218
219 return $this->_init($sql, $options);
220 }
221}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
Class to manage salaries module.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133