dolibarr  16.0.5
bank.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
7  * Copyright (C) 2015-2016 Marcos GarcĂ­a <marcosgdf@gmail.com>
8  * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
9  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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  */
24 
31 require '../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';
36 if (!empty($conf->holiday->enabled)) {
37  require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
38 }
39 if (!empty($conf->expensereport->enabled)) {
40  require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
41 }
42 if (!empty($conf->salaries->enabled)) {
43  require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
44  require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
45 }
46 
47 // Load translation files required by page
48 $langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries'));
49 
50 $id = GETPOST('id', 'int');
51 $ref = GETPOST('ref', 'alphanohtml');
52 $bankid = GETPOST('bankid', 'int');
53 $action = GETPOST("action", 'alpha');
54 $cancel = GETPOST('cancel', 'alpha');
55 
56 // Security check
57 $socid = 0;
58 if ($user->socid > 0) {
59  $socid = $user->socid;
60 }
61 $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
62 
63 $object = new User($db);
64 if ($id > 0 || !empty($ref)) {
65  $result = $object->fetch($id, $ref, '', 1);
66  $object->getrights();
67 }
68 
69 $account = new UserBankAccount($db);
70 if (!$bankid) {
71  $account->fetch(0, '', $id);
72 } else {
73  $account->fetch($bankid);
74 }
75 if (empty($account->userid)) {
76  $account->userid = $object->id;
77 }
78 
79 
80 // Define value to know what current user can do on users
81 $canadduser = (!empty($user->admin) || $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
82 $canreaduser = (!empty($user->admin) || $user->rights->user->user->lire || $user->rights->hrm->read_personal_information->read);
83 $permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || !empty($user->rights->user->creer));
84 
85 // Ok if user->rights->salaries->read or user->rights->hrm->read
86 //$result = restrictedArea($user, 'salaries|hrm', $object->id, 'user&user', $feature2);
87 $ok = false;
88 if ($user->id == $id) {
89  $ok = true; // A user can always read its own card
90 }
91 if (!empty($user->rights->salaries->read)) {
92  $ok = true;
93 }
94 if (!empty($user->rights->hrm->read)) {
95  $ok = true;
96 }
97 if (!empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) {
98  $ok = true;
99 }
100 if (!$ok) {
101  accessforbidden();
102 }
103 
104 
105 /*
106  * Actions
107  */
108 
109 if ($action == 'add' && !$cancel && $permissiontoaddbankaccount) {
110  $account->userid = $object->id;
111 
112  $account->bank = GETPOST('bank', 'alpha');
113  $account->label = GETPOST('label', 'alpha');
114  $account->courant = GETPOST('courant', 'alpha');
115  $account->code_banque = GETPOST('code_banque', 'alpha');
116  $account->code_guichet = GETPOST('code_guichet', 'alpha');
117  $account->number = GETPOST('number', 'alpha');
118  $account->cle_rib = GETPOST('cle_rib', 'alpha');
119  $account->bic = GETPOST('bic', 'alpha');
120  $account->iban = GETPOST('iban', 'alpha');
121  $account->domiciliation = GETPOST('domiciliation', 'alpha');
122  $account->proprio = GETPOST('proprio', 'alpha');
123  $account->owner_address = GETPOST('owner_address', 'alpha');
124 
125  $result = $account->create($user);
126 
127  if (!$result) {
128  setEventMessages($account->error, $account->errors, 'errors');
129  $action = 'edit'; // Force chargement page edition
130  } else {
131  setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
132  $action = '';
133  }
134 }
135 
136 if ($action == 'update' && !$cancel && $permissiontoaddbankaccount) {
137  $account->userid = $object->id;
138 
139  /*
140  if ($action == 'update' && !$cancel)
141  {
142  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
143 
144  if ($canedituser) // Case we can edit all field
145  {
146  $error = 0;
147 
148  if (!$error)
149  {
150  $objectuser->fetch($id);
151 
152  $objectuser->oldcopy = clone $objectuser;
153 
154  $db->begin();
155 
156  $objectuser->default_range = GETPOST('default_range');
157  $objectuser->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat');
158 
159  if (!$error) {
160  $ret = $objectuser->update($user);
161  if ($ret < 0) {
162  $error++;
163  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
164  $langs->load("errors");
165  setEventMessages($langs->trans("ErrorLoginAlreadyExists", $objectuser->login), null, 'errors');
166  } else {
167  setEventMessages($objectuser->error, $objectuser->errors, 'errors');
168  }
169  }
170  }
171 
172  if (!$error && !count($objectuser->errors)) {
173  setEventMessages($langs->trans("UserModified"), null, 'mesgs');
174  $db->commit();
175  } else {
176  $db->rollback();
177  }
178  }
179  }
180  }*/
181 
182  $account->bank = GETPOST('bank', 'alpha');
183  $account->label = GETPOST('label', 'alpha');
184  $account->courant = GETPOST('courant', 'alpha');
185  $account->code_banque = GETPOST('code_banque', 'alpha');
186  $account->code_guichet = GETPOST('code_guichet', 'alpha');
187  $account->number = GETPOST('number', 'alpha');
188  $account->cle_rib = GETPOST('cle_rib', 'alpha');
189  $account->bic = GETPOST('bic', 'alpha');
190  $account->iban = GETPOST('iban', 'alpha');
191  $account->domiciliation = GETPOST('domiciliation', 'alpha');
192  $account->proprio = GETPOST('proprio', 'alpha');
193  $account->owner_address = GETPOST('owner_address', 'alpha');
194 
195  $result = $account->update($user);
196 
197  if (!$result) {
198  setEventMessages($account->error, $account->errors, 'errors');
199  $action = 'edit'; // Force chargement page edition
200  } else {
201  setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
202  $action = '';
203  }
204 }
205 
206 // update birth
207 if ($action == 'setbirth' && $canadduser && !$cancel) {
208  $object->birth = dol_mktime(0, 0, 0, GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int'));
209  $result = $object->update($user);
210  if ($result < 0) {
211  setEventMessages($object->error, $object->errors, 'errors');
212  }
213 }
214 
215 // update personal email
216 if ($action == 'setpersonal_email' && $canadduser && !$cancel) {
217  $object->personal_email = (string) GETPOST('personal_email', 'alphanohtml');
218  $result = $object->update($user);
219  if ($result < 0) {
220  setEventMessages($object->error, $object->errors, 'errors');
221  }
222 }
223 
224 // update personal mobile
225 if ($action == 'setpersonal_mobile' && $canadduser && !$cancel) {
226  $object->personal_mobile = (string) GETPOST('personal_mobile', 'alphanohtml');
227  $result = $object->update($user);
228  if ($result < 0) {
229  setEventMessages($object->error, $object->errors, 'errors');
230  }
231 }
232 
233 // update ref_employee
234 if ($action == 'setref_employee' && $canadduser && !$cancel) {
235  $object->ref_employee = (string) GETPOST('ref_employee', 'alphanohtml');
236  $result = $object->update($user);
237  if ($result < 0) {
238  setEventMessages($object->error, $object->errors, 'errors');
239  }
240 }
241 
242 // update national_registration_number
243 if ($action == 'setnational_registration_number' && $canadduser && !$cancel) {
244  $object->national_registration_number = (string) GETPOST('national_registration_number', 'alphanohtml');
245  $result = $object->update($user);
246  if ($result < 0) {
247  setEventMessages($object->error, $object->errors, 'errors');
248  }
249 }
250 
251 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
252  // update default_c_exp_tax_cat
253  if ($action == 'setdefault_c_exp_tax_cat' && $canadduser) {
254  $object->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat', 'int');
255  $result = $object->update($user);
256  if ($result < 0) {
257  setEventMessages($object->error, $object->errors, 'errors');
258  }
259  }
260 
261  // update default range
262  if ($action == 'setdefault_range' && $canadduser) {
263  $object->default_range = GETPOST('default_range', 'int');
264  $result = $object->update($user);
265  if ($result < 0) {
266  setEventMessages($object->error, $object->errors, 'errors');
267  }
268  }
269 }
270 
271 
272 /*
273  * View
274  */
275 
276 $form = new Form($db);
277 
278 $childids = $user->getAllChildIds(1);
279 
280 llxHeader(null, $langs->trans("BankAccounts"));
281 
282 $head = user_prepare_head($object);
283 
284 if ($id && $bankid && $action == 'edit' && ($user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write)) {
285  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
286  print '<input type="hidden" name="token" value="'.newToken().'">';
287  print '<input type="hidden" name="action" value="update">';
288  print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">';
289  print '<input type="hidden" name="bankid" value="'.$bankid.'">';
290 }
291 if ($id && $action == 'create' && $user->rights->user->user->creer) {
292  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
293  print '<input type="hidden" name="token" value="'.newToken().'">';
294  print '<input type="hidden" name="action" value="add">';
295  print '<input type="hidden" name="bankid" value="'.$bankid.'">';
296 }
297 
298 
299 // View
300 if ($action != 'edit' && $action != 'create') { // If not bank account yet, $account may be empty
301  $title = $langs->trans("User");
302  print dol_get_fiche_head($head, 'bank', $title, -1, 'user');
303 
304  $linkback = '';
305 
306  if ($user->rights->user->user->lire || $user->admin) {
307  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
308  }
309 
310  $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'" class="refid">';
311  $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
312  $morehtmlref .= '</a>';
313 
314  dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref);
315 
316  print '<div class="fichecenter"><div class="fichehalfleft">';
317 
318  print '<div class="underbanner clearboth"></div>';
319 
320  print '<table class="border centpercent tableforfield">';
321 
322  print '<tr><td class="titlefieldmiddle">'.$langs->trans("Login").'</td>';
323  if (!empty($object->ldap_sid) && $object->statut == 0) {
324  print '<td class="error">';
325  print $langs->trans("LoginAccountDisableInDolibarr");
326  print '</td>';
327  } else {
328  print '<td>';
329  $addadmin = '';
330  if (property_exists($object, 'admin')) {
331  if (!empty($conf->multicompany->enabled) && !empty($object->admin) && empty($object->entity)) {
332  $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
333  } elseif (!empty($object->admin)) {
334  $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
335  }
336  }
337  print showValueWithClipboardCPButton($object->login).$addadmin;
338  print '</td>';
339  }
340  print '</tr>';
341 
342 
343  // Hierarchy
344  print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>';
345  print '<td>';
346  if (empty($object->fk_user)) {
347  print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
348  } else {
349  $huser = new User($db);
350  if ($object->fk_user > 0) {
351  $huser->fetch($object->fk_user);
352  print $huser->getNomUrl(1);
353  } else {
354  print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
355  }
356  }
357  print '</td>';
358  print "</tr>\n";
359 
360  // Expense report validator
361  if (!empty($conf->expensereport->enabled)) {
362  print '<tr><td>';
363  $text = $langs->trans("ForceUserExpenseValidator");
364  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
365  print '</td>';
366  print '<td>';
367  if (!empty($object->fk_user_expense_validator)) {
368  $evuser = new User($db);
369  $evuser->fetch($object->fk_user_expense_validator);
370  print $evuser->getNomUrl(1);
371  }
372  print '</td>';
373  print "</tr>\n";
374  }
375 
376  // Holiday request validator
377  if (!empty($conf->holiday->enabled)) {
378  print '<tr><td>';
379  $text = $langs->trans("ForceUserHolidayValidator");
380  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
381  print '</td>';
382  print '<td>';
383  if (!empty($object->fk_user_holiday_validator)) {
384  $hvuser = new User($db);
385  $hvuser->fetch($object->fk_user_holiday_validator);
386  print $hvuser->getNomUrl(1);
387  }
388  print '</td>';
389  print "</tr>\n";
390  }
391 
392  // Position/Job
393  print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
394  print '<td>'.dol_escape_htmltag($object->job).'</td>';
395  print '</tr>'."\n";
396 
397  // Weeklyhours
398  print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
399  print '<td>';
400  print price2num($object->weeklyhours);
401  print '</td>';
402  print "</tr>\n";
403 
404  // Sensitive salary/value information
405  if ((empty($user->socid) && in_array($id, $childids)) // A user can always see salary/value information for its subordinates
406  || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->readall))
407  || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) {
408  $langs->load("salaries");
409 
410  // Salary
411  print '<tr><td>'.$langs->trans("Salary").'</td>';
412  print '<td>';
413  print ($object->salary != '' ? img_picto('', 'salary', 'class="pictofixedwidth paddingright"').'<span class="amount">'.price($object->salary, '', $langs, 1, -1, -1, $conf->currency) : '').'</span>';
414  print '</td>';
415  print "</tr>\n";
416 
417  // THM
418  print '<tr><td>';
419  $text = $langs->trans("THM");
420  print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
421  print '</td>';
422  print '<td>';
423  print ($object->thm != '' ?price($object->thm, '', $langs, 1, -1, -1, $conf->currency) : '');
424  print '</td>';
425  print "</tr>\n";
426 
427  // TJM
428  print '<tr><td>';
429  $text = $langs->trans("TJM");
430  print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm');
431  print '</td>';
432  print '<td>';
433  print ($object->tjm != '' ?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency) : '');
434  print '</td>';
435  print "</tr>\n";
436  }
437 
438  // Date employment
439  print '<tr><td>'.$langs->trans("DateOfEmployment").'</td>';
440  print '<td>';
441  if ($object->dateemployment) {
442  print '<span class="opacitymedium">'.$langs->trans("FromDate").'</span> ';
443  print dol_print_date($object->dateemployment, 'day');
444  }
445  if ($object->dateemploymentend) {
446  print '<span class="opacitymedium"> - '.$langs->trans("To").'</span> ';
447  print dol_print_date($object->dateemploymentend, 'day');
448  }
449  print '</td>';
450  print "</tr>\n";
451 
452  // Date of birth
453  if ($user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write')) {
454  print '<tr>';
455  print '<td>';
456  print $form->editfieldkey("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer);
457  print '</td><td>';
458  print $form->editfieldval("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer, 'day', $object->birth);
459  print '</td>';
460  print "</tr>\n";
461  }
462 
463  // Personal email
464  if ($user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write')) {
465  print '<tr class="nowrap">';
466  print '<td>';
467  print $form->editfieldkey("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
468  print '</td><td>';
469  print $form->editfieldval("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'email', '', null, null, '', 0, 'dol_print_email');
470  print '</td>';
471  print '</tr>';
472  }
473 
474  // Personal phone
475  if ($user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write')) {
476  print '<tr class="nowrap">';
477  print '<td>';
478  print $form->editfieldkey("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
479  print '</td><td>';
480  print $form->editfieldval("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'string', '', null, null, '', 0, 'dol_print_phone');
481  print '</td>';
482  print '</tr>';
483  }
484 
485  if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
486  print '<tr class="nowrap">';
487  print '<td>';
488  print $form->editfieldkey("DefaultCategoryCar", 'default_c_exp_tax_cat', $object->default_c_exp_tax_cat, $object, $user->rights->user->user->creer);
489  print '</td><td>';
490  if ($action == 'editdefault_c_exp_tax_cat') {
491  $ret = '<form method="post" action="'.$_SERVER["PHP_SELF"].($moreparam ? '?'.$moreparam : '').'">';
492  $ret .= '<input type="hidden" name="action" value="setdefault_c_exp_tax_cat">';
493  $ret .= '<input type="hidden" name="token" value="'.newToken().'">';
494  $ret .= '<input type="hidden" name="id" value="'.$object->id.'">';
495  $ret .= $form->selectExpenseCategories($object->default_c_exp_tax_cat, 'default_c_exp_tax_cat', 1);
496  $ret .= '<input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'"> ';
497  $ret .= '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
498  $ret .= '</form>';
499  print $ret;
500  } else {
501  $label_exp_tax_cat = dol_getIdFromCode($db, $object->default_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label');
502  print $langs->trans($label_exp_tax_cat);
503  //print $form->editfieldval("DefaultCategoryCar", 'default_c_exp_tax_cat', $object->default_c_exp_tax_cat, $object, $user->rights->user->user->creer, 'string', ($object->default_c_exp_tax_cat != '' ? $object->default_c_exp_tax_cat : ''));
504  }
505  print '</td>';
506  print '</tr>';
507 
508  print '<tr class="nowrap">';
509  print '<td>';
510  print $form->editfieldkey("DefaultRangeNumber", 'default_range', $object->default_range, $object, $user->rights->user->user->creer);
511  print '</td><td>';
512  if ($action == 'editdefault_range') {
513  $ret = '<form method="post" action="'.$_SERVER["PHP_SELF"].($moreparam ? '?'.$moreparam : '').'">';
514  $ret .= '<input type="hidden" name="action" value="setdefault_range">';
515  $ret .= '<input type="hidden" name="token" value="'.newToken().'">';
516  $ret .= '<input type="hidden" name="id" value="'.$object->id.'">';
517 
518  $expensereportik = new ExpenseReportIk($db);
519  $maxRangeNum = $expensereportik->getMaxRangeNumber($object->default_c_exp_tax_cat);
520 
521  $ret .= $form->selectarray('default_range', range(0, $maxRangeNum), $object->default_range);
522  $ret .= '<input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'"> ';
523  $ret .= '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
524  $ret .= '</form>';
525  print $ret;
526  } else {
527  print $object->default_range;
528  }
529  print '</td>';
530  print '</tr>';
531  }
532 
533  // Accountancy code
534  if (!empty($conf->accounting->enabled)) {
535  print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
536  print '<td>'.$object->accountancy_code.'</td></tr>';
537  }
538 
539  // Employee Number
540  if ($user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write')) {
541  print '<tr class="nowrap">';
542  print '<td>';
543  print $form->editfieldkey("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
544  print '</td><td>';
545  print $form->editfieldval("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'string', $object->ref_employee);
546  print '</td>';
547  print '</tr>';
548  }
549 
550  // National registration number
551  if ($user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write')) {
552  print '<tr class="nowrap">';
553  print '<td>';
554  print $form->editfieldkey("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
555  print '</td><td>';
556  print $form->editfieldval("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'string', $object->national_registration_number);
557  print '</td>';
558  print '</tr>';
559  }
560 
561  print '</table>';
562 
563  print '</div><div class="fichehalfright">';
564 
565  // Max number of elements in small lists
566  $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
567 
568  // Latest payments of salaries
569  if (!empty($conf->salaries->enabled) &&
570  (($user->rights->salaries->read && (in_array($object->id, $childids) || $object->id == $user->id)) || (!empty($user->rights->salaries->readall)))
571  ) {
572  $payment_salary = new PaymentSalary($db);
573  $salary = new Salary($db);
574 
575  $sql = "SELECT s.rowid as sid, s.ref as sref, s.label, s.datesp, s.dateep, s.paye, s.amount, SUM(ps.amount) as alreadypaid";
576  $sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
577  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as ps ON (s.rowid = ps.fk_salary)";
578  $sql .= " WHERE s.fk_user = ".((int) $object->id);
579  $sql .= " AND s.entity IN (".getEntity('salary').")";
580  $sql .= " GROUP BY s.rowid, s.ref, s.label, s.datesp, s.dateep, s.paye, s.amount";
581  $sql .= " ORDER BY s.dateep DESC";
582 
583  $resql = $db->query($sql);
584  if ($resql) {
585  $num = $db->num_rows($resql);
586 
587  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
588  print '<table class="noborder centpercent">';
589 
590  print '<tr class="liste_titre">';
591  print '<td colspan="5"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastSalaries", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/salaries/list.php?search_user='.$object->login.'">'.$langs->trans("AllSalaries").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
592  print '</tr></table></td>';
593  print '</tr>';
594 
595  $i = 0;
596  while ($i < $num && $i < $MAXLIST) {
597  $objp = $db->fetch_object($resql);
598 
599  $salary->id = $objp->sid;
600  $salary->ref = $objp->sref ? $objp->sref : $objp->sid;
601  $salary->label = $objp->label;
602  $salary->datesp = $db->jdate($objp->datesp);
603  $salary->dateep = $db->jdate($objp->dateep);
604  $salary->paye = $objp->paye;
605  $salary->amount = $objp->amount;
606 
607  $payment_salary->id = $objp->rowid;
608  $payment_salary->ref = $objp->ref;
609  $payment_salary->datep = $db->jdate($objp->datep);
610 
611  print '<tr class="oddeven">';
612  print '<td class="nowraponall">';
613  print $salary->getNomUrl(1);
614  print '</td>';
615  print '<td class="right nowraponall">'.dol_print_date($db->jdate($objp->datesp), 'day')."</td>\n";
616  print '<td class="right nowraponall">'.dol_print_date($db->jdate($objp->dateep), 'day')."</td>\n";
617  print '<td class="right nowraponall"><span class="amount">'.price($objp->amount).'</span></td>';
618  print '<td class="right nowraponall">'.$salary->getLibStatut(5, $objp->alreadypaid).'</td>';
619  print '</tr>';
620  $i++;
621  }
622  $db->free($resql);
623 
624  if ($num <= 0) {
625  print '<td colspan="5"><span class="opacitymedium">'.$langs->trans("None").'</span></a>';
626  }
627  print "</table>";
628  print "</div>";
629  } else {
630  dol_print_error($db);
631  }
632  }
633 
634  // Latest leave requests
635  if (!empty($conf->holiday->enabled) && ($user->rights->holiday->readall || ($user->rights->holiday->read && $object->id == $user->id))) {
636  $holiday = new Holiday($db);
637 
638  $sql = "SELECT h.rowid, h.statut as status, h.fk_type, h.date_debut, h.date_fin, h.halfday";
639  $sql .= " FROM ".MAIN_DB_PREFIX."holiday as h";
640  $sql .= " WHERE h.fk_user = ".((int) $object->id);
641  $sql .= " AND h.entity IN (".getEntity('holiday').")";
642  $sql .= " ORDER BY h.date_debut DESC";
643 
644  $resql = $db->query($sql);
645  if ($resql) {
646  $num = $db->num_rows($resql);
647 
648  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
649  print '<table class="noborder centpercent">';
650 
651  print '<tr class="liste_titre">';
652  print '<td colspan="4"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastHolidays", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/holiday/list.php?id='.$object->id.'">'.$langs->trans("AllHolidays").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
653  print '</tr></table></td>';
654  print '</tr>';
655 
656  $i = 0;
657  while ($i < $num && $i < $MAXLIST) {
658  $objp = $db->fetch_object($resql);
659 
660  $holiday->id = $objp->rowid;
661  $holiday->ref = $objp->rowid;
662 
663  $holiday->fk_type = $objp->fk_type;
664  $holiday->statut = $objp->status;
665  $holiday->status = $objp->status;
666 
667  $nbopenedday = num_open_day($db->jdate($objp->date_debut, 'gmt'), $db->jdate($objp->date_fin, 'gmt'), 0, 1, $objp->halfday);
668 
669  print '<tr class="oddeven">';
670  print '<td class="nowraponall">';
671  print $holiday->getNomUrl(1);
672  print '</td><td class="right nowraponall">'.dol_print_date($db->jdate($objp->date_debut), 'day')."</td>\n";
673  print '<td class="right nowraponall">'.$nbopenedday.' '.$langs->trans('DurationDays').'</td>';
674  print '<td class="right nowraponall">'.$holiday->LibStatut($objp->status, 5).'</td>';
675  print '</tr>';
676  $i++;
677  }
678  $db->free($resql);
679 
680  if ($num <= 0) {
681  print '<td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></a>';
682  }
683  print "</table>";
684  print "</div>";
685  } else {
686  dol_print_error($db);
687  }
688  }
689 
690  // Latest expense report
691  if (!empty($conf->expensereport->enabled) &&
692  ($user->rights->expensereport->readall || ($user->rights->expensereport->lire && $object->id == $user->id))
693  ) {
694  $exp = new ExpenseReport($db);
695 
696  $sql = "SELECT e.rowid, e.ref, e.fk_statut as status, e.date_debut, e.total_ttc";
697  $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e";
698  $sql .= " WHERE e.fk_user_author = ".((int) $object->id);
699  $sql .= " AND e.entity = ".((int) $conf->entity);
700  $sql .= " ORDER BY e.date_debut DESC";
701 
702  $resql = $db->query($sql);
703  if ($resql) {
704  $num = $db->num_rows($resql);
705 
706  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
707  print '<table class="noborder centpercent">';
708 
709  print '<tr class="liste_titre">';
710  print '<td colspan="4"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastExpenseReports", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expensereport/list.php?id='.$object->id.'">'.$langs->trans("AllExpenseReports").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
711  print '</tr></table></td>';
712  print '</tr>';
713 
714  $i = 0;
715  while ($i < $num && $i < $MAXLIST) {
716  $objp = $db->fetch_object($resql);
717 
718  $exp->id = $objp->rowid;
719  $exp->ref = $objp->ref;
720  $exp->status = $objp->status;
721 
722  print '<tr class="oddeven">';
723  print '<td class="nowraponall">';
724  print $exp->getNomUrl(1);
725  print '</td><td class="right nowraponall">'.dol_print_date($db->jdate($objp->date_debut), 'day')."</td>\n";
726  print '<td class="right nowraponall"><span class="amount">'.price($objp->total_ttc).'</span></td>';
727  print '<td class="right nowraponall">'.$exp->LibStatut($objp->status, 5).'</td>';
728  print '</tr>';
729  $i++;
730  }
731  $db->free($resql);
732 
733  if ($num <= 0) {
734  print '<td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></a>';
735  }
736  print "</table>";
737  print "</div>";
738  } else {
739  dol_print_error($db);
740  }
741  }
742 
743  print '</div></div>';
744  print '<div style="clear:both"></div>';
745 
746  print dol_get_fiche_end();
747 
748  // List of bank accounts (Currently only one bank account possible for each employee)
749 
750  $morehtmlright = '';
751  if ($account->id == 0) {
752  if ($permissiontoaddbankaccount) {
753  $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=create');
754  } else {
755  $morehtmlright = dolGetButtonTitle($langs->trans('Add'), $langs->trans('NotEnoughPermissions'), 'fa fa-plus-circle', '', '', -2);
756  }
757  } else {
758  $morehtmlright = dolGetButtonTitle($langs->trans('Add'), $langs->trans('AlreadyOneBankAccount'), 'fa fa-plus-circle', '', '', -2);
759  }
760 
761  print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank_account');
762 
763  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
764  print '<table class="liste centpercent">';
765 
766  print '<tr class="liste_titre">';
767  print_liste_field_titre("LabelRIB");
768  print_liste_field_titre("Bank");
770  print_liste_field_titre("IBAN");
772  print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch ');
773  print "</tr>\n";
774 
775  if ($account->id > 0) {
776  print '<tr class="oddeven">';
777  // Label
778  print '<td>'.$account->label.'</td>';
779  // Bank name
780  print '<td>'.$account->bank.'</td>';
781  // Account number
782  print '<td>';
783  $string = '';
784  foreach ($account->getFieldsToShow() as $val) {
785  if ($val == 'BankCode') {
786  $string .= $account->code_banque.' ';
787  } elseif ($val == 'BankAccountNumber') {
788  $string .= $account->number.' ';
789  } elseif ($val == 'DeskCode') {
790  $string .= $account->code_guichet.' ';
791  } elseif ($val == 'BankAccountNumberKey') {
792  $string .= $account->cle_rib.' ';
793  }
794  }
795  if (!empty($account->label) && $account->number) {
796  if (!checkBanForAccount($account)) {
797  $string .= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning');
798  } else {
799  $string .= ' '.img_picto($langs->trans("ValueIsValid"), 'info');
800  }
801  }
802 
803  print $string;
804  print '</td>';
805  // IBAN
806  print '<td>'.$account->iban;
807  if (!empty($account->iban)) {
808  if (!checkIbanForAccount($account)) {
809  print ' '.img_picto($langs->trans("IbanNotValid"), 'warning');
810  }
811  }
812  print '</td>';
813  // BIC
814  print '<td>'.$account->bic;
815  if (!empty($account->bic)) {
816  if (!checkSwiftForAccount($account)) {
817  print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning');
818  }
819  }
820  print '</td>';
821 
822  // Edit/Delete
823  print '<td class="right nowraponall">';
824  if ($permissiontoaddbankaccount) {
825  print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&bankid='.$account->id.'&action=edit&token='.newToken().'">';
826  print img_picto($langs->trans("Modify"), 'edit');
827  print '</a>';
828  }
829  print '</td>';
830 
831  print '</tr>';
832  }
833 
834 
835  if ($account->id == 0) {
836  $colspan = 6;
837  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoBANRecord").'</span></td></tr>';
838  }
839 
840  print '</table>';
841  print '</div>';
842 }
843 
844 // Edit
845 if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->user->creer) {
846  $title = $langs->trans("User");
847  print dol_get_fiche_head($head, 'bank', $title, 0, 'user');
848 
849  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
850 
851  dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
852 
853  //print '<div class="fichecenter">';
854 
855  print '<div class="underbanner clearboth"></div>';
856  print '<table class="border centpercent">';
857 
858  print '<tr><td class="titlefield fieldrequired">'.$langs->trans("LabelRIB").'</td>';
859  print '<td colspan="4"><input size="30" type="text" name="label" value="'.$account->label.'"></td></tr>';
860 
861  print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>';
862  print '<td><input size="30" type="text" name="bank" value="'.$account->bank.'"></td></tr>';
863 
864  // Show fields of bank account
865  foreach ($account->getFieldsToShow() as $val) {
866  if ($val == 'BankCode') {
867  $name = 'code_banque';
868  $size = 8;
869  $content = $account->code_banque;
870  } elseif ($val == 'DeskCode') {
871  $name = 'code_guichet';
872  $size = 8;
873  $content = $account->code_guichet;
874  } elseif ($val == 'BankAccountNumber') {
875  $name = 'number';
876  $size = 18;
877  $content = $account->number;
878  } elseif ($val == 'BankAccountNumberKey') {
879  $name = 'cle_rib';
880  $size = 3;
881  $content = $account->cle_rib;
882  }
883 
884  print '<td>'.$langs->trans($val).'</td>';
885  print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
886  print '</tr>';
887  }
888 
889  // IBAN
890  print '<tr><td class="fieldrequired">'.$langs->trans("IBAN").'</td>';
891  print '<td colspan="4"><input size="30" type="text" name="iban" value="'.$account->iban.'"></td></tr>';
892 
893  print '<tr><td class="fieldrequired">'.$langs->trans("BIC").'</td>';
894  print '<td colspan="4"><input size="12" type="text" name="bic" value="'.$account->bic.'"></td></tr>';
895 
896  print '<tr><td class="tdtop">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
897  print '<textarea name="domiciliation" rows="4" class="quatrevingtpercent">';
898  print dol_escape_htmltag($account->domiciliation);
899  print "</textarea></td></tr>";
900 
901  print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
902  print '<td colspan="4"><input size="30" type="text" name="proprio" value="'.$account->proprio.'"></td></tr>';
903  print "</td></tr>\n";
904 
905  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="4">';
906  print '<textarea name="owner_address" rows="4" class="quatrevingtpercent">';
907  print dol_escape_htmltag($account->owner_address);
908  print "</textarea></td></tr>";
909 
910  print '</table>';
911 
912  //print '</div>';
913 
914  print dol_get_fiche_end();
915 
916  print $form->buttonsSaveCancel("Modify");
917 }
918 
919 if ($id && $action == 'edit' && $user->rights->user->user->creer) {
920  print '</form>';
921 }
922 
923 if ($id && $action == 'create' && $user->rights->user->user->creer) {
924  print '</form>';
925 }
926 
927 // End of page
928 llxFooter();
929 $db->close();
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
num_open_day
num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='')
Function to return number of working days (and text of units) between two dates (working days)
Definition: date.lib.php:982
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
user_prepare_head
user_prepare_head(User $object)
Prepare array with list of tabs.
Definition: usergroups.lib.php:35
PaymentSalary
Class to manage payments of salaries.
Definition: paymentsalary.class.php:34
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
checkIbanForAccount
checkIbanForAccount(Account $account)
Check IBAN number informations for a bank account.
Definition: bank.lib.php:277
checkSwiftForAccount
checkSwiftForAccount($account)
Check SWIFT informations for a bank account.
Definition: bank.lib.php:261
ExpenseReportIk
Class to manage inventories.
Definition: expensereport_ik.class.php:30
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
UserBankAccount
Class to manage bank accounts description of users.
Definition: userbankaccount.class.php:35
checkBanForAccount
checkBanForAccount($account)
Check account number informations for a bank account.
Definition: bank.lib.php:299
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
dol_getIdFromCode
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
Definition: functions.lib.php:8535
showValueWithClipboardCPButton
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
Definition: functions.lib.php:11087
Holiday
Class of the module paid holiday.
Definition: holiday.class.php:34
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
User
Class to manage Dolibarr users.
Definition: user.class.php:44
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
ExpenseReport
Class to manage Trips and Expenses.
Definition: expensereport.class.php:36
Salary
Class to manage salary payments.
Definition: salary.class.php:33
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
price
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
Definition: functions.lib.php:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59