dolibarr  7.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@capnetworks.com>
7  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
8  * Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
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 <http://www.gnu.org/licenses/>.
22  * or see http://www.gnu.org/
23  */
24 
32 include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
33 
34 
39 {
40 
46  function __construct($db)
47  {
48  global $conf;
49 
50  $this->db = $db;
51  $this->numero = 510; // Perms from 501..519
52 
53  $this->family = "hr";
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->special = 0;
64  $this->picto='bill';
65 
66  // Data directories to create when module is enabled
67  $this->dirs = array("/salaries/temp");
68 
69  // Config pages
70  $this->config_page_url = array('salaries.php');
71 
72  // Dependencies
73  $this->depends = array();
74  $this->requiredby = array();
75  $this->conflictwith = array();
76  $this->langfiles = array("salaries","bills");
77 
78  // Constants
79  $this->const = array();
80  $this->const[0] = array(
81  "SALARIES_ACCOUNTING_ACCOUNT_PAYMENT",
82  "chaine",
83  "421"
84  );
85  $this->const[1] = array(
86  "SALARIES_ACCOUNTING_ACCOUNT_CHARGE",
87  "chaine",
88  "641"
89  );
90 
91  // Boxes
92  $this->boxes = array();
93 
94  // Permissions
95  $this->rights = array();
96  $this->rights_class = 'salaries';
97  $r=0;
98 
99  $r++;
100  $this->rights[$r][0] = 501;
101  $this->rights[$r][1] = 'Read employee contracts/salaries';
102  $this->rights[$r][2] = 'r';
103  $this->rights[$r][3] = 0;
104  $this->rights[$r][4] = 'read';
105  $this->rights[$r][5] = '';
106 
107  $r++;
108  $this->rights[$r][0] = 502;
109  $this->rights[$r][1] = 'Create/modify employee contracts/salaries';
110  $this->rights[$r][2] = 'w';
111  $this->rights[$r][3] = 0;
112  $this->rights[$r][4] = 'write';
113  $this->rights[$r][5] = '';
114 
115  $r++;
116  $this->rights[$r][0] = 511;
117  $this->rights[$r][1] = 'Read payment of salaries';
118  $this->rights[$r][2] = 'w';
119  $this->rights[$r][3] = 0;
120  $this->rights[$r][4] = 'payment';
121  $this->rights[$r][5] = 'read';
122 
123  $r++;
124  $this->rights[$r][0] = 512;
125  $this->rights[$r][1] = 'Create/modify payment of salaries';
126  $this->rights[$r][2] = 'w';
127  $this->rights[$r][3] = 0;
128  $this->rights[$r][4] = 'payment';
129  $this->rights[$r][5] = 'write';
130 
131  $r++;
132  $this->rights[$r][0] = 514;
133  $this->rights[$r][1] = 'Delete contracts/salaries';
134  $this->rights[$r][2] = 'd';
135  $this->rights[$r][3] = 0;
136  $this->rights[$r][4] = 'delete';
137  $this->rights[$r][5] = '';
138 
139  $r++;
140  $this->rights[$r][0] = 517;
141  $this->rights[$r][1] = 'Export employee contracts and salaries payments';
142  $this->rights[$r][2] = 'r';
143  $this->rights[$r][3] = 0;
144  $this->rights[$r][4] = 'export';
145  $this->rights[$r][5] = '';
146 
147 
148  // Menus
149  //-------
150  $this->menu = 1; // This module add menu entries. They are coded into menu manager.
151 
152 
153  // Exports
154  //--------
155  $r=0;
156 
157  $r++;
158  $this->export_code[$r]=$this->rights_class.'_'.$r;
159  $this->export_label[$r]='Salaries and payments';
160  $this->export_permission[$r]=array(array("salaries","export"));
161  $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');
162  $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');
163  $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');
164 
165  $this->export_sql_start[$r]='SELECT DISTINCT ';
166  $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
167  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid';
168  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id AND cp.entity IN ('.getEntity('c_paiement').')';
169  $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user').')';
170  }
171 
172 
181  function init($options='')
182  {
183  global $conf;
184 
185  // Clean before activation
186  $this->remove($options);
187 
188  $sql = array();
189 
190  return $this->_init($sql,$options);
191  }
192 }
Class DolibarrModules.
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:554
__construct($db)
Constructor.
getEntity($element, $shared=1, $forceentity=null)
Get list of entity id to use.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
_init($array_sql, $options='')
Enables a module.
init($options='')
Function called when module is enabled.
Class to manage salaries module.