dolibarr  13.0.2
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  *
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  */
23 
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';
35 if (!empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
36 if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
37 if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
38 
39 // Load translation files required by page
40 $langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries'));
41 
42 $id = GETPOST('id', 'int');
43 $ref = GETPOST('ref', 'alphanohtml');
44 $bankid = GETPOST('bankid', 'int');
45 $action = GETPOST("action", 'alpha');
46 $cancel = GETPOST('cancel', 'alpha');
47 
48 // Security check
49 $socid = 0;
50 if ($user->socid > 0) $socid = $user->socid;
51 $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
52 // Ok if user->rights->salaries->read or user->rights->hrm->read
53 //$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2);
54 $ok = false;
55 if ($user->id == $id) $ok = true; // A user can always read its own card
56 if (!empty($user->rights->salaries->read)) $ok = true;
57 if (!empty($user->rights->hrm->read)) $ok = true;
58 if (!empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) $ok = true;
59 if (!$ok)
60 {
62 }
63 
64 $object = new User($db);
65 if ($id > 0 || !empty($ref))
66 {
67  $result = $object->fetch($id, $ref, '', 1);
68  $object->getrights();
69 }
70 
71 $account = new UserBankAccount($db);
72 if (!$bankid)
73 {
74  $account->fetch(0, '', $id);
75 } else {
76  $account->fetch($bankid);
77 }
78 if (empty($account->userid)) $account->userid = $object->id;
79 
80 $permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || !empty($user->rights->user->creer));
81 
82 
83 /*
84  * Actions
85  */
86 
87 if ($action == 'add' && !$cancel)
88 {
89  $account->userid = $object->id;
90 
91  $account->bank = GETPOST('bank', 'alpha');
92  $account->label = GETPOST('label', 'alpha');
93  $account->courant = GETPOST('courant', 'alpha');
94  $account->code_banque = GETPOST('code_banque', 'alpha');
95  $account->code_guichet = GETPOST('code_guichet', 'alpha');
96  $account->number = GETPOST('number', 'alpha');
97  $account->cle_rib = GETPOST('cle_rib', 'alpha');
98  $account->bic = GETPOST('bic', 'alpha');
99  $account->iban = GETPOST('iban', 'alpha');
100  $account->domiciliation = GETPOST('domiciliation', 'alpha');
101  $account->proprio = GETPOST('proprio', 'alpha');
102  $account->owner_address = GETPOST('owner_address', 'alpha');
103 
104  $result = $account->create($user);
105 
106  if (!$result)
107  {
108  setEventMessages($account->error, $account->errors, 'errors');
109  $action = 'edit'; // Force chargement page edition
110  } else {
111  setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
112  $action = '';
113  }
114 }
115 
116 if ($action == 'update' && !$cancel)
117 {
118  $account->userid = $object->id;
119 
120  /*
121  if ($action == 'update' && !$cancel)
122  {
123  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
124 
125  if ($canedituser) // Case we can edit all field
126  {
127  $error = 0;
128 
129  if (!$error)
130  {
131  $objectuser->fetch($id);
132 
133  $objectuser->oldcopy = clone $objectuser;
134 
135  $db->begin();
136 
137  $objectuser->default_range = GETPOST('default_range');
138  $objectuser->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat');
139 
140  if (!$error) {
141  $ret = $objectuser->update($user);
142  if ($ret < 0) {
143  $error++;
144  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
145  $langs->load("errors");
146  setEventMessages($langs->trans("ErrorLoginAlreadyExists", $objectuser->login), null, 'errors');
147  } else {
148  setEventMessages($objectuser->error, $objectuser->errors, 'errors');
149  }
150  }
151  }
152 
153  if (!$error && !count($objectuser->errors)) {
154  setEventMessages($langs->trans("UserModified"), null, 'mesgs');
155  $db->commit();
156  } else {
157  $db->rollback();
158  }
159  }
160  }
161  }*/
162 
163  $account->bank = GETPOST('bank', 'alpha');
164  $account->label = GETPOST('label', 'alpha');
165  $account->courant = GETPOST('courant', 'alpha');
166  $account->code_banque = GETPOST('code_banque', 'alpha');
167  $account->code_guichet = GETPOST('code_guichet', 'alpha');
168  $account->number = GETPOST('number', 'alpha');
169  $account->cle_rib = GETPOST('cle_rib', 'alpha');
170  $account->bic = GETPOST('bic', 'alpha');
171  $account->iban = GETPOST('iban', 'alpha');
172  $account->domiciliation = GETPOST('domiciliation', 'alpha');
173  $account->proprio = GETPOST('proprio', 'alpha');
174  $account->owner_address = GETPOST('owner_address', 'alpha');
175 
176  $result = $account->update($user);
177 
178  if (!$result) {
179  setEventMessages($account->error, $account->errors, 'errors');
180  $action = 'edit'; // Force chargement page edition
181  } else {
182  setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
183  $action = '';
184  }
185 }
186 
187 // update personal email
188 if ($action == 'setpersonal_email') {
189  $object->personal_email = (string) GETPOST('personal_email', 'alphanohtml');
190  $result = $object->update($user);
191  if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
192 }
193 
194 // update personal mobile
195 if ($action == 'setpersonal_mobile') {
196  $object->personal_mobile = (string) GETPOST('personal_mobile', 'alphanohtml');
197  $result = $object->update($user);
198  if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
199 }
200 
201 // update default_c_exp_tax_cat
202 if ($action == 'setdefault_c_exp_tax_cat') {
203  $object->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat', 'int');
204  $result = $object->update($user);
205  if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
206 }
207 
208 // update default range
209 if ($action == 'setdefault_range') {
210  $object->default_range = GETPOST('default_range', 'int');
211  $result = $object->update($user);
212  if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
213 }
214 
215 
216 
217 /*
218  * View
219  */
220 
221 $form = new Form($db);
222 
223 $childids = $user->getAllChildIds(1);
224 
225 llxHeader(null, $langs->trans("BankAccounts"));
226 
227 $head = user_prepare_head($object);
228 
229 if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer)
230 {
231  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
232  print '<input type="hidden" name="token" value="'.newToken().'">';
233  print '<input type="hidden" name="action" value="update">';
234  print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">';
235  print '<input type="hidden" name="bankid" value="'.$bankid.'">';
236 }
237 if ($id && $action == 'create' && $user->rights->user->user->creer)
238 {
239  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
240  print '<input type="hidden" name="token" value="'.newToken().'">';
241  print '<input type="hidden" name="action" value="add">';
242  print '<input type="hidden" name="bankid" value="'.$bankid.'">';
243 }
244 
245 
246 // View
247 if ($action != 'edit' && $action != 'create') // If not bank account yet, $account may be empty
248 {
249  $title = $langs->trans("User");
250  print dol_get_fiche_head($head, 'bank', $title, -1, 'user');
251 
252  $linkback = '';
253 
254  if ($user->rights->user->user->lire || $user->admin) {
255  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
256  }
257 
258  dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
259 
260  print '<div class="fichecenter"><div class="fichehalfleft">';
261 
262  print '<div class="underbanner clearboth"></div>';
263 
264  print '<table class="border centpercent tableforfield">';
265 
266  print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
267  print '<td>'.$object->login.'</td>';
268  print '</tr>';
269 
270  print '<tr class="nowrap">';
271  print '<td>';
272  print $form->editfieldkey("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer);
273  print '</td><td>';
274  print $form->editfieldval("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer, 'email', ($object->personal_email != '' ? dol_print_email($object->personal_email) : ''));
275  print '</td>';
276  print '</tr>';
277 
278  print '<tr class="nowrap">';
279  print '<td>';
280  print $form->editfieldkey("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer);
281  print '</td><td>';
282  print $form->editfieldval("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer, 'string', ($object->personal_mobile != '' ? dol_print_phone($object->personal_mobile) : ''));
283  print '</td>';
284  print '</tr>';
285 
286  if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
287  {
288  print '<tr class="nowrap">';
289  print '<td>';
290  print $form->editfieldkey("DefaultCategoryCar", 'default_c_exp_tax_cat', $object->default_c_exp_tax_cat, $object, $user->rights->user->user->creer);
291  print '</td><td>';
292  if ($action == 'editdefault_c_exp_tax_cat') {
293  $ret = '<form method="post" action="'.$_SERVER["PHP_SELF"].($moreparam ? '?'.$moreparam : '').'">';
294  $ret .= '<input type="hidden" name="action" value="setdefault_c_exp_tax_cat">';
295  $ret .= '<input type="hidden" name="token" value="'.newToken().'">';
296  $ret .= '<input type="hidden" name="id" value="'.$object->id.'">';
297  $ret .= $form->selectExpenseCategories($object->default_c_exp_tax_cat, 'default_c_exp_tax_cat', 1);
298  $ret .= '<input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'"> ';
299  $ret .= '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
300  $ret .= '</form>';
301  print $ret;
302  } else {
303  print dol_getIdFromCode($db, $object->default_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label');
304  //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 : ''));
305  }
306  print '</td>';
307  print '</tr>';
308 
309  print '<tr class="nowrap">';
310  print '<td>';
311  print $form->editfieldkey("DefaultRangeNumber", 'default_range', $object->default_range, $object, $user->rights->user->user->creer);
312  print '</td><td>';
313  if ($action == 'editdefault_range') {
314  $ret = '<form method="post" action="'.$_SERVER["PHP_SELF"].($moreparam ? '?'.$moreparam : '').'">';
315  $ret .= '<input type="hidden" name="action" value="setdefault_range">';
316  $ret .= '<input type="hidden" name="token" value="'.newToken().'">';
317  $ret .= '<input type="hidden" name="id" value="'.$object->id.'">';
318  $maxRangeNum = ExpenseReportIk::getMaxRangeNumber($object->default_c_exp_tax_cat);
319  $ret .= $form->selectarray('default_range', range(0, $maxRangeNum), $object->default_range);
320  $ret .= '<input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'"> ';
321  $ret .= '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
322  $ret .= '</form>';
323  print $ret;
324  } else {
325  print $object->default_range;
326  }
327  print '</td>';
328  print '</tr>';
329  }
330 
331  print '</table>';
332 
333  print '</div><div class="fichehalfright"><div class="ficheaddleft">';
334 
335  // Nbre max d'elements des petites listes
336  $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
337 
338  // Latest payments of salaries
339  if (!empty($conf->salaries->enabled) &&
340  $user->rights->salaries->read && (in_array($object->id, $childids) || $object->id == $user->id)
341  )
342  {
343  $salary = new PaymentSalary($db);
344 
345  $sql = "SELECT ps.rowid, ps.datesp, ps.dateep, ps.amount";
346  $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps";
347  $sql .= " WHERE ps.fk_user = ".$object->id;
348  $sql .= " AND ps.entity = ".$conf->entity;
349  $sql .= " ORDER BY ps.datesp DESC";
350 
351  $resql = $db->query($sql);
352  if ($resql)
353  {
354  $num = $db->num_rows($resql);
355 
356  print '<table class="noborder centpercent">';
357 
358  print '<tr class="liste_titre">';
359  print '<td colspan="4"><table width="100%" class="nobordernopadding"><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>';
360  print '</tr></table></td>';
361  print '</tr>';
362 
363  $i = 0;
364  while ($i < $num && $i < $MAXLIST)
365  {
366  $objp = $db->fetch_object($resql);
367 
368  print '<tr class="oddeven">';
369  print '<td class="nowraponall">';
370  $salary->id = $objp->rowid;
371  $salary->ref = $objp->rowid;
372  print $salary->getNomUrl(1);
373  print '</td>';
374 
375  print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->datesp), 'day')."</td>\n";
376  print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dateep), 'day')."</td>\n";
377  print '<td class="right" style="min-width: 60px">'.price($objp->amount).'</td>';
378 
379  print '</tr>';
380  $i++;
381  }
382  $db->free($resql);
383 
384  if ($num <= 0) print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>';
385  print "</table>";
386  } else {
387  dol_print_error($db);
388  }
389  }
390 
391  /*
392  * Last holidays
393  */
394  if (!empty($conf->holiday->enabled) &&
395  ($user->rights->holiday->readall || ($user->rights->holiday->read && $object->id == $user->id))
396  )
397  {
398  $holiday = new Holiday($db);
399 
400  $sql = "SELECT h.rowid, h.statut as status, h.fk_type, h.date_debut, h.date_fin, h.halfday";
401  $sql .= " FROM ".MAIN_DB_PREFIX."holiday as h";
402  $sql .= " WHERE h.fk_user = ".$object->id;
403  $sql .= " AND h.entity IN (".getEntity('holiday').")";
404  $sql .= " ORDER BY h.date_debut DESC";
405 
406  $resql = $db->query($sql);
407  if ($resql)
408  {
409  $num = $db->num_rows($resql);
410 
411  print '<table class="noborder centpercent">';
412 
413  print '<tr class="liste_titre">';
414  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>';
415  print '</tr></table></td>';
416  print '</tr>';
417 
418  $i = 0;
419  while ($i < $num && $i < $MAXLIST)
420  {
421  $objp = $db->fetch_object($resql);
422 
423  $holiday->id = $objp->rowid;
424  $holiday->ref = $objp->rowid;
425  $holiday->fk_type = $objp->fk_type;
426  $holiday->statut = $objp->status;
427  $nbopenedday = num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday);
428 
429  print '<tr class="oddeven">';
430  print '<td class="nowrap">';
431  print $holiday->getNomUrl(1);
432  print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_debut), 'day')."</td>\n";
433  print '<td class="right" style="min-width: 60px">'.$nbopenedday.' '.$langs->trans('DurationDays').'</td>';
434  print '<td class="right" style="min-width: 60px" class="nowrap">'.$holiday->LibStatut($objp->status, 5).'</td></tr>';
435  $i++;
436  }
437  $db->free($resql);
438 
439  if ($num <= 0) print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>';
440  print "</table>";
441  } else {
442  dol_print_error($db);
443  }
444  }
445 
446  /*
447  * Last expense report
448  */
449  if (!empty($conf->expensereport->enabled) &&
450  ($user->rights->expensereport->readall || ($user->rights->expensereport->lire && $object->id == $user->id))
451  )
452  {
453  $exp = new ExpenseReport($db);
454 
455  $sql = "SELECT e.rowid, e.ref, e.fk_statut as status, e.date_debut, e.total_ttc";
456  $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e";
457  $sql .= " WHERE e.fk_user_author = ".$object->id;
458  $sql .= " AND e.entity = ".$conf->entity;
459  $sql .= " ORDER BY e.date_debut DESC";
460 
461  $resql = $db->query($sql);
462  if ($resql)
463  {
464  $num = $db->num_rows($resql);
465 
466  print '<table class="noborder centpercent">';
467 
468  print '<tr class="liste_titre">';
469  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>';
470  print '</tr></table></td>';
471  print '</tr>';
472 
473  $i = 0;
474  while ($i < $num && $i < $MAXLIST)
475  {
476  $objp = $db->fetch_object($resql);
477 
478  $exp->id = $objp->rowid;
479  $exp->ref = $objp->ref;
480  $exp->fk_type = $objp->fk_type;
481  $exp->status = $objp->status;
482 
483  print '<tr class="oddeven">';
484  print '<td class="nowrap">';
485  print $exp->getNomUrl(1);
486  print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_debut), 'day')."</td>\n";
487  print '<td class="right" style="min-width: 60px">'.price($objp->total_ttc).'</td>';
488  print '<td class="right nowrap" style="min-width: 60px">'.$exp->LibStatut($objp->status, 5).'</td></tr>';
489  $i++;
490  }
491  $db->free($resql);
492 
493  if ($num <= 0) print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>';
494  print "</table>";
495  } else {
496  dol_print_error($db);
497  }
498  }
499 
500  print '</div></div></div>';
501  print '<div style="clear:both"></div>';
502 
503  print dol_get_fiche_end();
504 
505  // List of bank accounts (Currently only one bank account possible for each employee)
506 
507  $morehtmlright = '';
508  if ($account->id == 0) {
509  if ($permissiontoaddbankaccount) {
510  $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=create');
511  } else {
512  $morehtmlright = dolGetButtonTitle($langs->trans('Add'), 'NotEnoughPermission', 'fa fa-plus-circle', '', '', -2);
513  }
514  } else {
515  $morehtmlright = dolGetButtonTitle($langs->trans('Add'), 'AlreadyOneBankAccount', 'fa fa-plus-circle', '', '', -2);
516  }
517 
518  print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank_account');
519 
520  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
521  print '<table class="liste centpercent">';
522 
523  print '<tr class="liste_titre">';
524  print_liste_field_titre("LabelRIB");
525  print_liste_field_titre("Bank");
527  print_liste_field_titre("IBAN");
529  print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
530  print "</tr>\n";
531 
532  if ($account->id > 0) {
533  print '<tr class="oddeven">';
534  // Label
535  print '<td>'.$account->label.'</td>';
536  // Bank name
537  print '<td>'.$account->bank.'</td>';
538  // Account number
539  print '<td>';
540  $string = '';
541  foreach ($account->getFieldsToShow() as $val) {
542  if ($val == 'BankCode') {
543  $string .= $account->code_banque.' ';
544  } elseif ($val == 'BankAccountNumber') {
545  $string .= $account->number.' ';
546  } elseif ($val == 'DeskCode') {
547  $string .= $account->code_guichet.' ';
548  } elseif ($val == 'BankAccountNumberKey') {
549  $string .= $account->cle_rib.' ';
550  }
551  }
552  if (!empty($account->label) && $account->number) {
553  if (!checkBanForAccount($account)) {
554  $string .= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning');
555  } else {
556  $string .= ' '.img_picto($langs->trans("ValueIsValid"), 'info');
557  }
558  }
559 
560  print $string;
561  print '</td>';
562  // IBAN
563  print '<td>'.$account->iban;
564  if (!empty($account->iban)) {
565  if (!checkIbanForAccount($account)) {
566  print ' '.img_picto($langs->trans("IbanNotValid"), 'warning');
567  }
568  }
569  print '</td>';
570  // BIC
571  print '<td>'.$account->bic;
572  if (!empty($account->bic)) {
573  if (!checkSwiftForAccount($account)) {
574  print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning');
575  }
576  }
577  print '</td>';
578 
579  // Edit/Delete
580  print '<td class="right nowraponall">';
581  if ($permissiontoaddbankaccount) {
582  print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&bankid='.$account->id.'&action=edit">';
583  print img_picto($langs->trans("Modify"), 'edit');
584  print '</a>';
585  }
586  print '</td>';
587 
588  print '</tr>';
589  }
590 
591 
592  if ($account->id == 0)
593  {
594  $colspan = 6;
595  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>';
596  }
597 
598  print '</table>';
599  print '</div>';
600 }
601 
602 // Edit
603 if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->user->creer)
604 {
605  $title = $langs->trans("User");
606  print dol_get_fiche_head($head, 'bank', $title, 0, 'user');
607 
608  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
609 
610  dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
611 
612  //print '<div class="fichecenter">';
613 
614  print '<div class="underbanner clearboth"></div>';
615  print '<table class="border centpercent">';
616 
617  print '<tr><td class="titlefield fieldrequired">'.$langs->trans("LabelRIB").'</td>';
618  print '<td colspan="4"><input size="30" type="text" name="label" value="'.$account->label.'"></td></tr>';
619 
620  print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>';
621  print '<td><input size="30" type="text" name="bank" value="'.$account->bank.'"></td></tr>';
622 
623  // Show fields of bank account
624  foreach ($account->getFieldsToShow() as $val) {
625  if ($val == 'BankCode') {
626  $name = 'code_banque';
627  $size = 8;
628  $content = $account->code_banque;
629  } elseif ($val == 'DeskCode') {
630  $name = 'code_guichet';
631  $size = 8;
632  $content = $account->code_guichet;
633  } elseif ($val == 'BankAccountNumber') {
634  $name = 'number';
635  $size = 18;
636  $content = $account->number;
637  } elseif ($val == 'BankAccountNumberKey') {
638  $name = 'cle_rib';
639  $size = 3;
640  $content = $account->cle_rib;
641  }
642 
643  print '<td>'.$langs->trans($val).'</td>';
644  print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
645  print '</tr>';
646  }
647 
648  // IBAN
649  print '<tr><td class="fieldrequired">'.$langs->trans("IBAN").'</td>';
650  print '<td colspan="4"><input size="30" type="text" name="iban" value="'.$account->iban.'"></td></tr>';
651 
652  print '<tr><td class="fieldrequired">'.$langs->trans("BIC").'</td>';
653  print '<td colspan="4"><input size="12" type="text" name="bic" value="'.$account->bic.'"></td></tr>';
654 
655  print '<tr><td class="tdtop">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
656  print '<textarea name="domiciliation" rows="4" class="quatrevingtpercent">';
657  print $account->domiciliation;
658  print "</textarea></td></tr>";
659 
660  print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
661  print '<td colspan="4"><input size="30" type="text" name="proprio" value="'.$account->proprio.'"></td></tr>';
662  print "</td></tr>\n";
663 
664  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="4">';
665  print '<textarea name="owner_address" rows="4" class="quatrevingtpercent">';
666  print $account->owner_address;
667  print "</textarea></td></tr>";
668 
669  print '</table>';
670 
671  //print '</div>';
672 
673  print dol_get_fiche_end();
674 
675  print '<div class="center">';
676  print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">';
677  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
678  print '<input class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
679  print '</div>';
680 }
681 
682 if ($id && $action == 'edit' && $user->rights->user->user->creer) print '</form>';
683 
684 if ($id && $action == 'create' && $user->rights->user->user->creer) print '</form>';
685 
686 // End of page
687 llxFooter();
688 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class of the module paid holiday.
static getMaxRangeNumber($default_c_exp_tax_cat=0)
Return the max number of range by a category.
user_prepare_head($object)
Prepare array with list of tabs.
Class to manage salary payments.
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.
Class to manage bank accounts description of users.
Class to manage Dolibarr users.
Definition: user.class.php:44
dol_print_phone($phone, $countrycode= '', $cid=0, $socid=0, $addlink= '', $separ="&nbsp;", $withpicto= '', $titlealt= '', $adddivfloat=0)
Format phone numbers according to country.
checkSwiftForAccount($account)
Check SWIFT informations for a bank account.
Definition: bank.lib.php:251
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
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:863
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 ...
Class to manage Trips and Expenses.
print $_SERVER["PHP_SELF"]
Edit parameters.
checkBanForAccount($account)
Check account number informations for a bank account.
Definition: bank.lib.php:284
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
checkIbanForAccount($account)
Check IBAN number informations for a bank account.
Definition: bank.lib.php:267
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59