dolibarr  18.0.0
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  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  * or see https://www.gnu.org/
23  */
24 
32 include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
33 
34 
39 {
40 
46  public function __construct($db)
47  {
48  global $conf;
49 
50  $this->db = $db;
51  $this->numero = 510; // Perms from 501..519
52 
53  // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
54  // It is used to group modules by family in module setup page
55  $this->family = "financial";
56  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
57  $this->name = preg_replace('/^mod/i', '', get_class($this));
58  // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
59  $this->description = "Payment of salaries";
60 
61  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
62  $this->version = 'dolibarr';
63 
64  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
65  $this->picto = 'payment';
66 
67  // Data directories to create when module is enabled
68  $this->dirs = array("/salaries/temp");
69 
70  // Config pages
71  $this->config_page_url = array('salaries.php@salaries');
72 
73  // Dependencies
74  $this->hidden = false; // A condition to hide module
75  $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
76  $this->requiredby = array(); // List of module ids to disable if this one is disabled
77  $this->conflictwith = array(); // List of module class names as string this module is in conflict with
78  $this->phpmin = array(7, 0); // Minimum version of PHP required by module
79  $this->langfiles = array("salaries", "bills");
80 
81  // Constants
82  $this->const = array();
83  $this->const[0] = array(
84  "SALARIES_ACCOUNTING_ACCOUNT_PAYMENT",
85  "chaine",
86  "421"
87  );
88  $this->const[1] = array(
89  "SALARIES_ACCOUNTING_ACCOUNT_CHARGE",
90  "chaine",
91  "641"
92  );
93 
94  // Boxes
95  $this->boxes = array();
96 
97  // Permissions
98  $this->rights = array();
99  $this->rights_class = 'salaries';
100  $r = 0;
101 
102  $r++;
103  $this->rights[$r][0] = 511;
104  $this->rights[$r][1] = 'Read employee salaries and payments (yours and your subordinates)';
105  $this->rights[$r][2] = 'r';
106  $this->rights[$r][3] = 0;
107  $this->rights[$r][4] = 'read';
108  $this->rights[$r][5] = '';
109 
110  $r++;
111  $this->rights[$r][0] = 512;
112  $this->rights[$r][1] = 'Create/modify payments of empoyee salaries';
113  $this->rights[$r][2] = 'w';
114  $this->rights[$r][3] = 0;
115  $this->rights[$r][4] = 'write';
116  $this->rights[$r][5] = '';
117 
118  $r++;
119  $this->rights[$r][0] = 514;
120  $this->rights[$r][1] = 'Delete payments of employee salary';
121  $this->rights[$r][2] = 'd';
122  $this->rights[$r][3] = 0;
123  $this->rights[$r][4] = 'delete';
124  $this->rights[$r][5] = '';
125 
126  $r++;
127  $this->rights[$r][0] = 517;
128  $this->rights[$r][1] = 'Read salaries and payments of all employees';
129  $this->rights[$r][2] = 'r';
130  $this->rights[$r][3] = 0;
131  $this->rights[$r][4] = 'readall';
132 
133  $r++;
134  $this->rights[$r][0] = 519;
135  $this->rights[$r][1] = 'Export payments of employee salaries';
136  $this->rights[$r][2] = 'r';
137  $this->rights[$r][3] = 0;
138  $this->rights[$r][4] = 'export';
139  $this->rights[$r][5] = '';
140 
141 
142 
143  // Menus
144  //-------
145  $this->menu = 1; // This module add menu entries. They are coded into menu manager.
146 
147 
148  // Exports
149  //--------
150  $r = 0;
151 
152  $r++;
153  $this->export_code[$r] = $this->rights_class.'_'.$r;
154  $this->export_label[$r] = 'SalariesAndPayments';
155  $this->export_permission[$r] = array(array("salaries", "export"));
156  $this->export_fields_array[$r] = array('u.firstname'=>"Firstname", 'u.lastname'=>"Lastname", 'u.login'=>"Login", 'u.salary'=>'CurrentSalary', 'p.datep'=>'DatePayment', 'p.datesp'=>'DateStartPeriod', 'p.dateep'=>'DateEndPeriod', 'p.amount'=>'AmountPayment', 'p.num_payment'=>'Numero', 'p.label'=>'Label', 'p.note'=>'Note');
157  $this->export_TypeFields_array[$r] = array('u.firstname'=>"Text", 'u.lastname'=>"Text", 'u.login'=>'Text', 'u.salary'=>"Numeric", 'p.datep'=>'Date', 'p.datesp'=>'Date', 'p.dateep'=>'Date', 'p.amount'=>'Numeric', 'p.num_payment'=>'Numeric', 'p.label'=>'Text');
158  $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');
159 
160  $this->export_sql_start[$r] = 'SELECT DISTINCT ';
161  $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'user as u';
162  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid';
163  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id';
164  $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('user').')';
165  }
166 
167 
176  public function init($options = '')
177  {
178  global $conf;
179 
180  // Clean before activation
181  $this->remove($options);
182 
183  $sql = array();
184 
185  return $this->_init($sql, $options);
186  }
187 }
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.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
print *****$script_file(".$version.") pid 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:123