dolibarr  18.0.0-alpha
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2014-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
7  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
8  * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
9  * Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
10  * Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  */
25 
32 // Load Dolibarr environment
33 require '../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
40 if (isModEnabled('categorie')) {
41  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
42 }
43 if (isModEnabled('accounting')) {
44  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
45 }
46 if (isModEnabled('accounting')) {
47  require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
48 }
49 if (isModEnabled('accounting')) {
50  require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
51 }
52 
53 // Load translation files required by the page
54 $langs->loadLangs(array("banks", "bills", "categories", "companies", "compta", "withdrawals"));
55 
56 $action = GETPOST('action', 'aZ09');
57 $cancel = GETPOST('cancel', 'alpha');
58 
59 $object = new Account($db);
60 $extrafields = new ExtraFields($db);
61 
62 // fetch optionals attributes and labels
63 $extrafields->fetch_name_optionals_label($object->table_element);
64 
65 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
66 $hookmanager->initHooks(array('bankcard', 'globalcard'));
67 
68 // Security check
69 $id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha');
70 $fieldid = GETPOST("id", 'int') ? 'rowid' : 'ref';
71 
72 if (GETPOST("id", 'int') || GETPOST("ref")) {
73  if (GETPOST("id", 'int')) {
74  $object->fetch(GETPOST("id", 'int'));
75  }
76  if (GETPOST("ref")) {
77  $object->fetch(0, GETPOST("ref"));
78  }
79 }
80 
81 $result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
82 
83 
84 /*
85  * Actions
86  */
87 
88 $parameters = array();
89 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
90 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
91 
92 if (empty($reshook)) {
93  $backurlforlist = DOL_URL_ROOT.'/compta/bank/list.php';
94 
95  if (empty($backtopage) || ($cancel && empty($id))) {
96  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
97  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
98  $backtopage = $backurlforlist;
99  } else {
100  $backtopage = DOL_URL_ROOT.'/compta/bank/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
101  }
102  }
103  }
104 
105  if ($cancel) {
106  if (!empty($backtopageforcancel)) {
107  header("Location: ".$backtopageforcancel);
108  exit;
109  } elseif (!empty($backtopage)) {
110  header("Location: ".$backtopage);
111  exit;
112  }
113  $action = '';
114  }
115 
116  if ($action == 'add') {
117  $error = 0;
118 
119  $db->begin();
120 
121  // Create account
122  $object = new Account($db);
123 
124  $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha')));
125  $object->label = trim(GETPOST("label", 'alphanohtml'));
126  $object->courant = GETPOST("type");
127  $object->clos = GETPOST("clos");
128  $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1);
129  $object->url = trim(GETPOST("url", 'alpha'));
130 
131  $object->bank = trim(GETPOST("bank"));
132  $object->code_banque = trim(GETPOST("code_banque"));
133  $object->code_guichet = trim(GETPOST("code_guichet"));
134  $object->number = trim(GETPOST("number"));
135  $object->cle_rib = trim(GETPOST("cle_rib"));
136  $object->bic = trim(GETPOST("bic"));
137  $object->iban = trim(GETPOST("iban"));
138  $object->domiciliation = trim(GETPOST("domiciliation", "alphanohtml"));
139  $object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1;
140 
141  $object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
142  $object->owner_address = trim(GETPOST("owner_address", 'alphanohtml'));
143  $object->owner_zip = trim(GETPOST("owner_zip", 'alphanohtml'));
144  $object->owner_town = trim(GETPOST("owner_town", 'alphanohtml'));
145  $object->owner_country_id = GETPOST("owner_country_id", 'int');
146 
147  $object->ics = trim(GETPOST("ics", 'alpha'));
148  $object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha'));
149 
150  $account_number = GETPOST('account_number', 'alphanohtml');
151  if (empty($account_number) || $account_number == '-1') {
152  $object->account_number = '';
153  } else {
154  $object->account_number = $account_number;
155  }
156  $fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int');
157  if ($fk_accountancy_journal <= 0) {
158  $object->fk_accountancy_journal = '';
159  } else {
160  $object->fk_accountancy_journal = $fk_accountancy_journal;
161  }
162 
163  $object->solde = price2num(GETPOST("solde"));
164  $object->date_solde = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST('reday', 'int'), GETPOST("reyear", 'int'));
165 
166  $object->currency_code = trim(GETPOST("account_currency_code"));
167 
168  $object->state_id = GETPOST("account_state_id", 'int');
169  $object->country_id = GETPOST("account_country_id", 'int');
170 
171  $object->min_allowed = GETPOST("account_min_allowed", 'int');
172  $object->min_desired = GETPOST("account_min_desired", 'int');
173  $object->comment = trim(GETPOST("account_comment", 'restricthtml'));
174 
175  $object->fk_user_author = $user->id;
176 
177  if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) {
178  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
179  $action = 'create'; // Force chargement page en mode creation
180  $error++;
181  }
182  if (empty($object->ref)) {
183  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
184  $action = 'create'; // Force chargement page en mode creation
185  $error++;
186  }
187  if (empty($object->label)) {
188  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
189  $action = 'create'; // Force chargement page en mode creation
190  $error++;
191  }
192 
193  // Fill array 'array_options' with data from add form
194  $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
195 
196  if (!$error) {
197  $id = $object->create($user);
198  if ($id > 0) {
199  // Category association
200  $categories = GETPOST('categories', 'array');
201  $object->setCategories($categories);
202 
203  $_GET["id"] = $id; // Force chargement page en mode visu
204 
205  $action = '';
206  } else {
207  $error++;
208  setEventMessages($object->error, $object->errors, 'errors');
209 
210  $action = 'create'; // Force chargement page en mode creation
211  }
212  }
213 
214  if (!$error) {
215  $db->commit();
216  } else {
217  $db->rollback();
218  }
219  }
220 
221  if ($action == 'update') {
222  $error = 0;
223 
224  // Update account
225  $object = new Account($db);
226  $object->fetch(GETPOST("id", 'int'));
227 
228  $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha')));
229  $object->label = trim(GETPOST("label", 'alphanohtml'));
230  $object->courant = GETPOST("type");
231  $object->clos = GETPOST("clos");
232  $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1);
233  $object->url = trim(GETPOST("url", 'alpha'));
234 
235  $object->bank = trim(GETPOST("bank"));
236  $object->code_banque = trim(GETPOST("code_banque"));
237  $object->code_guichet = trim(GETPOST("code_guichet"));
238  $object->number = trim(GETPOST("number"));
239  $object->cle_rib = trim(GETPOST("cle_rib"));
240  $object->bic = trim(GETPOST("bic"));
241  $object->iban = trim(GETPOST("iban"));
242  $object->domiciliation = trim(GETPOST("domiciliation", "alphanohtml"));
243  $object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1;
244 
245  $object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
246  $object->owner_address = trim(GETPOST("owner_address", 'alphanohtml'));
247  $object->owner_zip = trim(GETPOST("owner_zip", 'alphanohtml'));
248  $object->owner_town = trim(GETPOST("owner_town", 'alphanohtml'));
249  $object->owner_country_id = GETPOST("owner_country_id", 'int');
250 
251  $object->ics = trim(GETPOST("ics", 'alpha'));
252  $object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha'));
253 
254  $account_number = GETPOST('account_number', 'alphanohtml');
255  if (empty($account_number) || $account_number == '-1') {
256  $object->account_number = '';
257  } else {
258  $object->account_number = $account_number;
259  }
260  $fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int');
261  if ($fk_accountancy_journal <= 0) {
262  $object->fk_accountancy_journal = '';
263  } else {
264  $object->fk_accountancy_journal = $fk_accountancy_journal;
265  }
266 
267  $object->currency_code = trim(GETPOST("account_currency_code"));
268 
269  $object->state_id = GETPOST("account_state_id", 'int');
270  $object->country_id = GETPOST("account_country_id", 'int');
271 
272  $object->min_allowed = GETPOST("account_min_allowed", 'int');
273  $object->min_desired = GETPOST("account_min_desired", 'int');
274  $object->comment = trim(GETPOST("account_comment", 'restricthtml'));
275 
276  if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) {
277  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
278  $action = 'edit'; // Force chargement page en mode creation
279  $error++;
280  }
281  if (empty($object->ref)) {
282  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
283  $action = 'edit'; // Force chargement page en mode creation
284  $error++;
285  }
286  if (empty($object->label)) {
287  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
288  $action = 'edit'; // Force chargement page en mode creation
289  $error++;
290  }
291 
292  $db->begin();
293 
294  if (!$error) {
295  // Fill array 'array_options' with data from add form
296  $ret = $extrafields->setOptionalsFromPost(null, $object);
297  }
298 
299  if (!$error) {
300  $result = $object->update($user);
301  if ($result >= 0) {
302  // Category association
303  $categories = GETPOST('categories', 'array');
304  $object->setCategories($categories);
305 
306  $_GET["id"] = GETPOST("id", 'int'); // Force chargement page en mode visu
307  } else {
308  $error++;
309  setEventMessages($object->error, $object->errors, 'errors');
310  $action = 'edit'; // Force chargement page edition
311  }
312  }
313 
314  if (!$error) {
315  $db->commit();
316  } else {
317  $db->rollback();
318  }
319  }
320 
321  if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->banque->configurer) {
322  // Delete
323  $object = new Account($db);
324  $object->fetch(GETPOST("id", "int"));
325  $result = $object->delete($user);
326 
327  if ($result > 0) {
328  setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
329  header("Location: " . DOL_URL_ROOT . "/compta/bank/list.php");
330  exit;
331  } else {
332  setEventMessages($object->error, $object->errors, 'errors');
333  $action = '';
334  }
335  }
336 }
337 
338 
339 /*
340  * View
341  */
342 
343 $form = new Form($db);
344 $formbank = new FormBank($db);
345 $formcompany = new FormCompany($db);
346 if (isModEnabled('accounting')) {
347  $formaccounting = new FormAccounting($db);
348 }
349 
350 $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
351 
352 $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas|DE:Modul_Banken_und_Barbestände';
353 if ($action == 'create') {
354  $title = $langs->trans("NewFinancialAccount");
355 } elseif (!empty($object->ref)) {
356  $title = $object->ref." - ".$langs->trans("Card");
357 }
358 llxHeader("", $title, $help_url);
359 
360 // Creation
361 if ($action == 'create') {
362  print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'bank_account');
363 
364  if ($conf->use_javascript_ajax) {
365  print "\n".'<script type="text/javascript">';
366  print 'jQuery(document).ready(function () {
367  jQuery("#type").change(function() {
368  document.formsoc.action.value="create";
369  document.formsoc.submit();
370  });
371  jQuery("#selectaccount_country_id").change(function() {
372  document.formsoc.action.value="create";
373  document.formsoc.submit();
374  });
375  })';
376  print '</script>'."\n";
377  }
378 
379  print '<form action="'.$_SERVER["PHP_SELF"].'" name="formsoc" method="post">';
380  print '<input type="hidden" name="token" value="'.newToken().'">';
381  print '<input type="hidden" name="action" value="add">';
382  print '<input type="hidden" name="clos" value="0">';
383 
384  print dol_get_fiche_head('');
385 
386  print '<table class="border centpercent tableforfieldcreate">';
387 
388  // Ref
389  print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
390  print '<td><input size="8" type="text" class="flat" name="ref" value="'.dol_escape_htmltag(GETPOSTISSET('ref') ? GETPOST("ref", 'alpha') : $object->ref).'" maxlength="12" autofocus></td></tr>';
391 
392  // Label
393  print '<tr><td class="fieldrequired">'.$langs->trans("LabelBankCashAccount").'</td>';
394  print '<td><input type="text" class="flat maxwidth150onsmartphone" name="label" value="'.dol_escape_htmltag(GETPOST('label', 'alpha')).'"></td></tr>';
395 
396  // Type
397  print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
398  print '<td>';
399  $formbank->selectTypeOfBankAccount(GETPOSTISSET("type") ? GETPOST('type', 'int') : Account::TYPE_CURRENT, 'type');
400  print '</td></tr>';
401 
402  // Currency
403  print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
404  print '<td>';
405  $selectedcode = $object->currency_code;
406  if (!$selectedcode) {
407  $selectedcode = $conf->currency;
408  }
409  print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code');
410  //print $langs->trans("Currency".$conf->currency);
411  //print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
412  print '</td></tr>';
413 
414  // Status
415  print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
416  print '<td>';
417  print $form->selectarray("clos", $object->status, (GETPOST('clos', 'int') != '' ? GETPOST('clos', 'int') : $object->clos), 0, 0, 0, '', 0, 0, 0, '', 'maxwidth150onsmartphone');
418  print '</td></tr>';
419 
420  // Country
421  $selectedcode = '';
422  if (GETPOSTISSET("account_country_id")) {
423  $selectedcode = GETPOST("account_country_id") ? GETPOST("account_country_id") : $object->country_code;
424  } elseif (empty($selectedcode)) {
425  $selectedcode = $mysoc->country_code;
426  }
427  $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules
428 
429  print '<tr><td class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>';
430  print '<td>';
431  print img_picto('', 'country', 'class="pictofixedwidth"');
432  print $form->select_country($selectedcode, 'account_country_id');
433  if ($user->admin) {
434  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
435  }
436  print '</td></tr>';
437 
438  // State
439  print '<tr><td>'.$langs->trans('State').'</td><td>';
440  if ($selectedcode) {
441  print img_picto('', 'state', 'class="pictofixedwidth"');
442  print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : '', $selectedcode, 'account_state_id');
443  } else {
444  print $countrynotdefined;
445  }
446  print '</td></tr>';
447 
448  $type = (GETPOSTISSET("type") ? GETPOST('type', 'int') : Account::TYPE_CURRENT); // add default value
449  if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
450  print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
451  print '<textarea class="flat quatrevingtpercent" name="domiciliation" rows="'.ROWS_2.'">';
452  print (GETPOSTISSET('domiciliation') ?GETPOST('domiciliation') : $object->domiciliation);
453  print "</textarea></td></tr>";
454  }
455 
456  // Web
457  print '<tr><td>'.$langs->trans("Web").'</td>';
458  print '<td>';
459  print img_picto('', 'globe', 'class="pictofixedwidth"');
460  print '<input class="minwidth300 widthcentpercentminusx maxwidth500" type="text" class="flat" name="url" value="'.GETPOST("url").'">';
461  print '</td></tr>';
462 
463  // Tags-Categories
464  if (isModEnabled('categorie')) {
465  print '<tr><td>'.$langs->trans("Categories").'</td><td>';
466  $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
467 
468  $arrayselected = array();
469  $c = new Categorie($db);
470  $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT);
471  if (is_array($cats)) {
472  foreach ($cats as $cat) {
473  $arrayselected[] = $cat->id;
474  }
475  }
476  print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
477  print "</td></tr>";
478  }
479 
480  // Comment
481  print '<tr><td>'.$langs->trans("Comment").'</td>';
482  print '<td>';
483  // Editor wysiwyg
484  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
485  $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_4, '90%');
486  $doleditor->Create();
487  print '</td></tr>';
488 
489  // Other attributes
490  $parameters = array();
491  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
492  print $hookmanager->resPrint;
493  if (empty($reshook)) {
494  print $object->showOptionals($extrafields, 'create', $parameters);
495  }
496 
497  print '</table>';
498 
499  print '<br>';
500 
501  print '<table class="border centpercent">';
502 
503  // Sold
504  print '<tr><td class="titlefieldcreate">'.$langs->trans("InitialBankBalance").'</td>';
505  print '<td><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde") ?GETPOST("solde") : price2num($object->solde)).'"></td></tr>';
506 
507  print '<tr><td>'.$langs->trans("Date").'</td>';
508  print '<td>';
509  print $form->selectDate('', 're', 0, 0, 0, 'formsoc');
510  print '</td></tr>';
511 
512  print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
513  print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(GETPOST("account_min_allowed") ?GETPOST("account_min_allowed") : $object->min_allowed).'"></td></tr>';
514 
515  print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
516  print '<td><input size="12" type="text" class="flat" name="account_min_desired" value="'.(GETPOST("account_min_desired") ?GETPOST("account_min_desired") : $object->min_desired).'"></td></tr>';
517 
518  print '</table>';
519  print '<br>';
520 
521  $type = (GETPOSTISSET("type") ? GETPOST('type', 'int') : Account::TYPE_CURRENT); // add default value
522  if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
523  print '<table class="border centpercent">';
524 
525  // If bank account
526  print '<tr><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
527  print '<td><input type="text" class="flat minwidth150" name="bank" value="'.(GETPOST('bank') ?GETPOST('bank', 'alpha') : $object->bank).'"></td>';
528  print '</tr>';
529 
530  // Show fields of bank account
531  $sizecss = '';
532  foreach ($object->getFieldsToShow() as $val) {
533  $content = '';
534  if ($val == 'BankCode') {
535  $name = 'code_banque';
536  $sizecss = 'minwidth100';
537  $content = $object->code_banque;
538  } elseif ($val == 'DeskCode') {
539  $name = 'code_guichet';
540  $sizecss = 'minwidth100';
541  $content = $object->code_guichet;
542  } elseif ($val == 'BankAccountNumber') {
543  $name = 'number';
544  $sizecss = 'minwidth200';
545  $content = $object->number;
546  } elseif ($val == 'BankAccountNumberKey') {
547  $name = 'cle_rib';
548  $sizecss = 'minwidth50';
549  $content = $object->cle_rib;
550  }
551 
552  print '<td>'.$langs->trans($val).'</td>';
553  print '<td><input type="text" class="flat '.$sizecss.'" name="'.$name.'" value="'.(GETPOSTISSET($name) ? GETPOST($name, 'alpha') : $content).'"></td>';
554  print '</tr>';
555  }
556  $ibankey = FormBank::getIBANLabel($object);
557  $bickey = "BICNumber";
558  if ($object->getCountryCode() == 'IN') {
559  $bickey = "SWIFT";
560  }
561 
562  // IBAN
563  print '<tr><td>'.$langs->trans($ibankey).'</td>';
564  print '<td><input maxlength="34" type="text" class="flat minwidth300" name="iban" value="'.(GETPOSTISSET('iban') ?GETPOST('iban', 'alpha') : $object->iban).'"></td></tr>';
565 
566  print '<tr><td>'.$langs->trans($bickey).'</td>';
567  print '<td><input maxlength="11" type="text" class="flat minwidth150" name="bic" value="'.(GETPOSTISSET('bic') ?GETPOST('bic', 'alpha') : $object->bic).'"></td></tr>';
568 
569  if (isModEnabled('paymentbybanktransfer')) {
570  print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>';
571  print '<td><input type="checkbox" class="flat" name="pti_in_ctti"'. (empty(GETPOST('pti_in_ctti')) ? '' : ' checked ') . '>';
572  print '</td></tr>';
573  }
574  print '</table>';
575  print '<hr>';
576 
577  print '<table class="border centpercent">';
578  print '<tr><td class="titlefieldcreate">'.$langs->trans("BankAccountOwner").'</td>';
579  print '<td><input type="text" class="flat minwidth300" name="proprio" value="'.(GETPOST('proprio') ?GETPOST('proprio', 'alpha') : $object->proprio).'">';
580  print '</td></tr>';
581 
582  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
583  print '<textarea class="flat quatrevingtpercent" name="owner_address" rows="'.ROWS_2.'">';
584  print (GETPOST('owner_address') ?GETPOST('owner_address', 'alpha') : $object->owner_address);
585  print "</textarea></td></tr>";
586 
587  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerZip").'</td>';
588  print '<td><input type="text" class="flat maxwidth100" name="owner_zip" value="'.(GETPOST('owner_zip') ?GETPOST('owner_zip', 'alpha') : $object->owner_zip).'">';
589  print '</td></tr>';
590 
591  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerTown").'</td>';
592  print '<td><input type="text" class="flat maxwidth200" name="owner_town" value="'.(GETPOST('owner_town') ?GETPOST('owner_town', 'alpha') : $object->owner_town).'">';
593  print '</td></tr>';
594 
595  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerCountry").'</td>';
596  print '<td>';
597  print img_picto('', 'country', 'class="pictofixedwidth"');
598  print $form->select_country(GETPOST('owner_country_id') ?GETPOST('owner_country_id', 'alpha') : $object->owner_country_id, 'owner_country_id');
599  print '</td></tr>';
600 
601  print '</table>';
602  print '<hr>';
603  }
604 
605  print '<table class="border centpercent">';
606  // Accountancy code
607  $fieldrequired = '';
608  if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
609  $fieldrequired = 'fieldrequired ';
610  }
611 
612  if (isModEnabled('accounting')) {
613  print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
614  print '<td>';
615  print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
616  print '</td></tr>';
617  } else {
618  print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
619  print '<td><input type="text" name="account_number" value="'.(GETPOST("account_number") ?GETPOST('account_number', 'alpha') : $object->account_number).'"></td></tr>';
620  }
621 
622  // Accountancy journal
623  if (isModEnabled('accounting')) {
624  print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
625  print '<td>';
626  print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
627  print '</td></tr>';
628  }
629 
630  print '</table>';
631 
632  print dol_get_fiche_end();
633 
634  print $form->buttonsSaveCancel("CreateAccount");
635 
636  print '</form>';
637 } else {
638  // View and edit mode
639  if ((GETPOST("id", 'int') || GETPOST("ref")) && $action != 'edit') {
640  // Show tabs
641  $head = bank_prepare_head($object);
642  print dol_get_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account');
643 
644  $formconfirm = '';
645 
646  // Confirmation to delete
647  if ($action == 'delete') {
648  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteAccount"), $langs->trans("ConfirmDeleteAccount"), "confirm_delete");
649  }
650 
651  // Print form confirm
652  print $formconfirm;
653 
654  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
655 
656  $morehtmlref = '';
657  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
658 
659 
660  print '<div class="fichecenter">';
661  print '<div class="fichehalfleft">';
662  print '<div class="underbanner clearboth"></div>';
663 
664  print '<table class="border tableforfield" width="100%">';
665 
666  // Type
667  print '<tr><td class="titlefield">'.$langs->trans("AccountType").'</td>';
668  print '<td>'.$object->type_lib[$object->type].'</td></tr>';
669 
670  // Currency
671  print '<tr><td>'.$langs->trans("Currency").'</td>';
672  print '<td>';
673  $selectedcode = $object->currency_code;
674  if (!$selectedcode) {
675  $selectedcode = $conf->currency;
676  }
677  print $langs->trans("Currency".$selectedcode);
678  print '</td></tr>';
679 
680  // Conciliate
681  print '<tr><td>'.$langs->trans("Conciliable").'</td>';
682  print '<td>';
683  $conciliate = $object->canBeConciliated();
684  if ($conciliate == -2) {
685  print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("CashAccount").')</span>';
686  } elseif ($conciliate == -3) {
687  print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("Closed").')</span>';
688  } else {
689  print ($object->rappro == 1 ? $langs->trans("Yes") : ($langs->trans("No").' <span class="opacitymedium">('.$langs->trans("ConciliationDisabled").')</span>'));
690  }
691  print '</td></tr>';
692 
693  print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
694  print '<td>'.$object->min_allowed.'</td></tr>';
695 
696  print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
697  print '<td>'.$object->min_desired.'</td></tr>';
698 
699  // Accountancy code
700  print '<tr class="liste_titre_add"><td class="titlefield">'.$langs->trans("AccountancyCode").'</td>';
701  print '<td>';
702  if (isModEnabled('accounting')) {
703  $accountingaccount = new AccountingAccount($db);
704  $accountingaccount->fetch('', $object->account_number, 1);
705 
706  print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
707  } else {
708  print $object->account_number;
709  }
710  print '</td></tr>';
711 
712  // Accountancy journal
713  if (isModEnabled('accounting')) {
714  print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
715  print '<td>';
716 
717  if ($object->fk_accountancy_journal > 0) {
718  $accountingjournal = new AccountingJournal($db);
719  $accountingjournal->fetch($object->fk_accountancy_journal);
720 
721  print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
722  }
723  print '</td></tr>';
724  }
725 
726  // Other attributes
727  $cols = 2;
728  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
729 
730  print '</table>';
731 
732  print '</div>';
733  print '<div class="fichehalfright">';
734  print '<div class="underbanner clearboth"></div>';
735 
736  print '<table class="border tableforfield centpercent">';
737 
738  // Categories
739  if (isModEnabled('categorie')) {
740  print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
741  print $form->showCategories($object->id, Categorie::TYPE_ACCOUNT, 1);
742  print "</td></tr>";
743  }
744 
745  print '<tr><td class="tdtop titlefield">'.$langs->trans("Comment").'</td>';
746  print '<td>'.dol_htmlentitiesbr($object->comment).'</td></tr>';
747 
748  print '</table>';
749 
750  if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) {
751  print '<table class="border tableforfield centpercent">';
752 
753  print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("BankName").'</td>';
754  print '<td>'.$object->bank.'</td></tr>';
755 
756  // Show fields of bank account
757  foreach ($object->getFieldsToShow() as $val) {
758  $content = '';
759  if ($val == 'BankCode') {
760  $content = $object->code_banque;
761  } elseif ($val == 'DeskCode') {
762  $content = $object->code_guichet;
763  } elseif ($val == 'BankAccountNumber') {
764  $content = $object->number;
765  } elseif ($val == 'BankAccountNumberKey') {
766  $content = $object->cle_rib;
767  }
768 
769  print '<tr><td>'.$langs->trans($val).'</td>';
770  print '<td>'.$content.'</td>';
771  print '</tr>';
772  }
773 
774  $ibankey = FormBank::getIBANLabel($object);
775  $bickey = "BICNumber";
776  if ($object->getCountryCode() == 'IN') {
777  $bickey = "SWIFT";
778  }
779 
780  print '<tr><td>'.$langs->trans($ibankey).'</td>';
781  print '<td>'.getIbanHumanReadable($object).'&nbsp;';
782  if (!empty($object->iban)) {
783  if (!checkIbanForAccount($object)) {
784  print img_picto($langs->trans("IbanNotValid"), 'warning');
785  } else {
786  print img_picto($langs->trans("IbanValid"), 'info');
787  }
788  }
789  print '</td></tr>';
790 
791  print '<tr><td>'.$langs->trans($bickey).'</td>';
792  print '<td>'.$object->bic.'&nbsp;';
793  if (!empty($object->bic)) {
794  if (!checkSwiftForAccount($object)) {
795  print img_picto($langs->trans("SwiftNotValid"), 'warning');
796  } else {
797  print img_picto($langs->trans("SwiftValid"), 'info');
798  }
799  }
800  print '</td></tr>';
801 
802  if (isModEnabled('prelevement')) {
803  print '<tr><td>'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'</td>';
804  print '<td>'.$object->ics.'</td>';
805  print '</tr>';
806  }
807 
808  // TODO ICS is not used with bank transfer !
809  if (isModEnabled('paymentbybanktransfer')) {
810  print '<tr><td>'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'</td>';
811  print '<td>'.$object->ics_transfer.'</td>';
812  print '</tr>';
813 
814  print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td><td>';
815  print (empty($object->pti_in_ctti) ? $langs->trans("No") : $langs->trans("Yes"));
816  print "</td></tr>\n";
817  }
818 
819  print '<tr><td>'.$langs->trans("BankAccountOwner").'</td><td>';
820  print $object->proprio;
821  print "</td></tr>\n";
822 
823  print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
824  print nl2br($object->owner_address);
825  print "</td></tr>\n";
826 
827  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerZip").'</td>';
828  print '<td>'.$object->owner_zip;
829  print '</td></tr>';
830 
831  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerTown").'</td>';
832  print '<td>'.$object->owner_town;
833  print '</td></tr>';
834 
835  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerCountry").'</td>';
836  print '<td>';
837  $object->owner_country_code = dol_getIdFromCode($db, $object->owner_country_id, 'c_country', 'rowid', 'code');
838  $langs->load("dict");
839  print (empty($object->owner_country_code) ? '' : $langs->convToOutputCharset($langs->transnoentitiesnoconv("Country".$object->owner_country_code)));
840 
841  print '</td></tr>';
842 
843  print '</table>';
844  }
845 
846  print '</div>';
847  print '</div>';
848 
849  print '<div class="clearboth"></div>';
850 
851  print dol_get_fiche_end();
852 
853  /*
854  * Action bar
855  */
856  print '<div class="tabsAction">';
857 
858  if ($user->rights->banque->configurer) {
859  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Modify").'</a>';
860  }
861 
862  $canbedeleted = $object->can_be_deleted(); // Renvoi vrai si compte sans mouvements
863  if ($user->rights->banque->configurer && $canbedeleted) {
864  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Delete").'</a>';
865  }
866 
867  print '</div>';
868  }
869 
870  /* ************************************************************************** */
871  /* */
872  /* Edition */
873  /* */
874  /* ************************************************************************** */
875 
876  if (GETPOST('id', 'int') && $action == 'edit' && $user->rights->banque->configurer) {
877  print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'bank_account');
878 
879  if ($conf->use_javascript_ajax) {
880  print "\n".'<script type="text/javascript">';
881  print 'jQuery(document).ready(function () {
882  jQuery("#type").change(function() {
883  document.formsoc.action.value="edit";
884  document.formsoc.submit();
885  });
886  })'."\n";
887 
888  print 'jQuery(document).ready(function () {
889  jQuery("#selectaccount_country_id").change(function() {
890  document.formsoc.action.value="edit";
891  document.formsoc.submit();
892  });
893  })';
894  print '</script>'."\n";
895  }
896 
897  print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formsoc">';
898  print '<input type="hidden" name="token" value="'.newToken().'">';
899  print '<input type="hidden" name="action" value="update">';
900  print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">'."\n\n";
901 
902  print dol_get_fiche_head(array(), 0, '', 0);
903 
904  //print '<div class="underbanner clearboth"></div>';
905 
906  print '<table class="border centpercent tableforfieldcreate">';
907 
908  // Ref
909  print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
910  print '<td><input type="text" class="flat maxwidth200" name="ref" value="'.dol_escape_htmltag(GETPOSTISSET('ref') ? GETPOST('ref', 'alpha') : $object->ref).'"></td></tr>';
911 
912  // Label
913  print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
914  print '<td><input type="text" class="flat minwidth300" name="label" value="'.dol_escape_htmltag(GETPOSTISSET('label') ? GETPOST('label', 'alpha') : $object->label).'"></td></tr>';
915 
916  // Type
917  print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
918  print '<td class="maxwidth200onsmartphone">';
919  $formbank->selectTypeOfBankAccount((GETPOSTISSET('type') ? GETPOST('type', 'int') : $object->type), 'type');
920  print '</td></tr>';
921 
922  // Currency
923  print '<tr><td class="fieldrequired">'.$langs->trans("Currency");
924  print '<input type="hidden" value="'.$object->currency_code.'">';
925  print '</td>';
926  print '<td class="maxwidth200onsmartphone">';
927  $selectedcode = $object->currency_code;
928  if (!$selectedcode) {
929  $selectedcode = $conf->currency;
930  }
931  print img_picto('', 'multicurrency', 'class="pictofixedwidth"');
932  print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code');
933  //print $langs->trans("Currency".$conf->currency);
934  //print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
935  print '</td></tr>';
936 
937  // Status
938  print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
939  print '<td class="maxwidth200onsmartphone">';
940  print $form->selectarray("clos", $object->status, (GETPOSTISSET("clos") ? GETPOST("clos", "int") : $object->clos));
941  print '</td></tr>';
942 
943  // Country
944  $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id;
945  $selectedcode = $object->country_code;
946  if (GETPOSTISSET("account_country_id")) {
947  $selectedcode = GETPOST("account_country_id");
948  } elseif (empty($selectedcode)) {
949  $selectedcode = $mysoc->country_code;
950  }
951  $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules
952 
953  print '<tr><td class="fieldrequired">'.$langs->trans("Country").'</td>';
954  print '<td class="maxwidth200onsmartphone">';
955  print img_picto('', 'country', 'class="pictofixedwidth"').$form->select_country($selectedcode, 'account_country_id');
956  if ($user->admin) {
957  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
958  }
959  print '</td></tr>';
960 
961  // State
962  print '<tr><td>'.$langs->trans('State').'</td><td class="maxwidth200onsmartphone">';
963  if ($selectedcode) {
964  print img_picto('', 'state', 'class="pictofixedwidth"');
965  print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : $object->state_id, $selectedcode, 'account_state_id');
966  } else {
967  print $countrynotdefined;
968  }
969  print '</td></tr>';
970 
971  $type = (GETPOSTISSET('type') ? GETPOST('type', 'int') : $object->type); // add default current value
972  if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
973  print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
974  print '<textarea class="flat quatrevingtpercent" name="domiciliation" rows="'.ROWS_2.'">';
975  print $object->domiciliation;
976  print "</textarea></td></tr>";
977  }
978 
979  // Conciliable
980  print '<tr><td>'.$langs->trans("Conciliable").'</td>';
981  print '<td>';
982  $conciliate = $object->canBeConciliated();
983  if ($conciliate == -2) {
984  print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
985  } elseif ($conciliate == -3) {
986  print $langs->trans("No").' ('.$langs->trans("Closed").')';
987  } else {
988  print '<input type="checkbox" class="flat" id="norappro" name="norappro"'.(($conciliate > 0) ? '' : ' checked="checked"').'"> <label for="norappro" class="opacitymedium">'.$langs->trans("DisableConciliation").'</label>';
989  }
990  print '</td></tr>';
991 
992  // Balance
993  print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
994  print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(GETPOSTISSET("account_min_allowed") ? GETPOST("account_min_allowed") : $object->min_allowed).'"></td></tr>';
995 
996  print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
997  print '<td><input size="12" type="text" class="flat" name="account_min_desired" value="'.(GETPOSTISSET("account_min_desired") ? GETPOST("account_min_desired") : $object->min_desired).'"></td></tr>';
998 
999  // Web
1000  print '<tr><td>'.$langs->trans("Web").'</td>';
1001  print '<td>';
1002  print img_picto('', 'globe', 'class="pictofixedwidth"');
1003  print '<input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(GETPOSTISSET("url") ? GETPOST("url") : $object->url).'">';
1004  print '</td></tr>';
1005 
1006  // Tags-Categories
1007  if (isModEnabled('categorie')) {
1008  print '<tr><td>'.$langs->trans("Categories").'</td><td>';
1009  $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
1010  $c = new Categorie($db);
1011  $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT);
1012  if (is_array($cats)) {
1013  foreach ($cats as $cat) {
1014  $arrayselected[] = $cat->id;
1015  }
1016  }
1017  print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1018  print "</td></tr>";
1019  }
1020 
1021  // Comment
1022  print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
1023  print '<td>';
1024  // Editor wysiwyg
1025  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1026  $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_4, '95%');
1027  $doleditor->Create();
1028  print '</td></tr>';
1029 
1030  // Other attributes
1031  $parameters = array();
1032  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1033  print $hookmanager->resPrint;
1034  if (empty($reshook)) {
1035  print $object->showOptionals($extrafields, 'edit', $parameters);
1036  }
1037 
1038  print '</table>';
1039  print '<hr>';
1040 
1041 
1042  //print '<div class="underbanner clearboth"></div>';
1043 
1044  print '<table class="border centpercent">';
1045 
1046  // Accountancy code
1047  $tdextra = ' class="titlefieldcreate"';
1048 
1049  if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
1050  $tdextra = ' class="fieldrequired titlefieldcreate"';
1051  }
1052 
1053  print '<tr><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
1054  print '<td>';
1055  if (isModEnabled('accounting')) {
1056  print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
1057  } else {
1058  print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
1059  }
1060  print '</td></tr>';
1061 
1062  // Accountancy journal
1063  if (isModEnabled('accounting')) {
1064  print '<tr><td class="fieldrequired">'.$langs->trans("AccountancyJournal").'</td>';
1065  print '<td>';
1066  print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
1067  print '</td></tr>';
1068  }
1069 
1070  print '</table>';
1071 
1072  $type = (GETPOSTISSET('type') ? GETPOST('type', 'int') : $object->type); // add default current value
1073  if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
1074  print '<br>';
1075 
1076  print '<table class="border centpercent">';
1077 
1078  // If bank account
1079  print '<tr class="liste_titre_add"><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
1080  print '<td><input type="text" class="flat width300" name="bank" value="'.$object->bank.'"></td>';
1081  print '</tr>';
1082 
1083  // Show fields of bank account
1084  foreach ($object->getFieldsToShow() as $val) {
1085  $content = '';
1086  if ($val == 'BankCode') {
1087  $name = 'code_banque';
1088  $css = 'with100';
1089  $content = $object->code_banque;
1090  } elseif ($val == 'DeskCode') {
1091  $name = 'code_guichet';
1092  $css = 'with100';
1093  $content = $object->code_guichet;
1094  } elseif ($val == 'BankAccountNumber') {
1095  $name = 'number';
1096  $css = 'with200';
1097  $content = $object->number;
1098  } elseif ($val == 'BankAccountNumberKey') {
1099  $name = 'cle_rib';
1100  $css = 'with50';
1101  $content = $object->cle_rib;
1102  }
1103 
1104  print '<tr><td>'.$langs->trans($val).'</td>';
1105  print '<td><input type="text" class="flat '.$css.'" name="'.$name.'" value="'.dol_escape_htmltag($content).'"></td>';
1106  print '</tr>';
1107  }
1108 
1109  $ibankey = FormBank::getIBANLabel($object);
1110  $bickey = "BICNumber";
1111  if ($object->getCountryCode() == 'IN') {
1112  $bickey = "SWIFT";
1113  }
1114 
1115  // IBAN
1116  print '<tr><td>'.$langs->trans($ibankey).'</td>';
1117  print '<td><input class="minwidth300 maxwidth200onsmartphone" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOSTISSET('iban') ? GETPOST('iban', 'alphanohtml') : $object->iban).'"></td></tr>';
1118 
1119  print '<tr><td>'.$langs->trans($bickey).'</td>';
1120  print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOSTISSET('bic') ? GETPOST('bic', 'alphanohtml') : $object->bic).'"></td></tr>';
1121 
1122  if (isModEnabled('prelevement')) {
1123  print '<tr><td>'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'</td>';
1124  print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics" value="'.(GETPOSTISSET('ics') ? GETPOST('ics', 'alphanohtml') : $object->ics).'"></td></tr>';
1125  }
1126 
1127  if (isModEnabled('paymentbybanktransfer')) {
1128  print '<tr><td>'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'</td>';
1129  print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics_transfer" value="'.(GETPOSTISSET('ics_transfer') ? GETPOST('ics_transfer', 'alphanohtml') : $object->ics_transfer).'"></td></tr>';
1130 
1131  print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>';
1132  print '<td><input type="checkbox" class="flat" name="pti_in_ctti"'. ($object->pti_in_ctti ? ' checked ' : '') . '>';
1133  print '</td></tr>';
1134  }
1135 
1136  print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
1137  print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="proprio" value="'.$object->proprio.'"></td>';
1138  print '</tr>';
1139 
1140  print '</table>';
1141  print '<hr>';
1142 
1143  print '<table class="border centpercent">';
1144 
1145  print '<tr><td class="titlefieldcreate">'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
1146  print '<textarea class="flat quatrevingtpercent" name="owner_address" rows="'.ROWS_2.'">';
1147  print $object->owner_address;
1148  print "</textarea></td></tr>";
1149 
1150  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerZip").'</td>';
1151  print '<td><input type="text" class="flat maxwidth100" name="owner_zip" value="'.(GETPOST('owner_zip') ?GETPOST('owner_zip', 'alpha') : $object->owner_zip).'">';
1152  print '</td></tr>';
1153 
1154  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerTown").'</td>';
1155  print '<td><input type="text" class="flat maxwidth200" name="owner_town" value="'.(GETPOST('owner_town') ?GETPOST('owner_town', 'alpha') : $object->owner_town).'">';
1156  print '</td></tr>';
1157 
1158  print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerCountry").'</td>';
1159  print '<td>';
1160  print img_picto('', 'country', 'class="pictofixedwidth"');
1161  print $form->select_country(GETPOST('owner_country_id') ?GETPOST('owner_country_id', 'alpha') : $object->owner_country_id, 'owner_country_id');
1162  print '</td></tr>';
1163 
1164  print '</table>';
1165  }
1166 
1167  print dol_get_fiche_end();
1168 
1169  print $form->buttonsSaveCancel("Modify");
1170 
1171  print '</form>';
1172  }
1173 }
1174 
1175 // End of page
1176 llxFooter();
1177 $db->close();
Account\TYPE_CURRENT
const TYPE_CURRENT
Current account.
Definition: account.class.php:350
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:1504
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5363
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:530
checkIbanForAccount
checkIbanForAccount(Account $account)
Check IBAN number informations for a bank account.
Definition: bank.lib.php:295
checkSwiftForAccount
checkSwiftForAccount($account)
Check SWIFT informations for a bank account.
Definition: bank.lib.php:279
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
Categorie
Class to manage categories.
Definition: categorie.class.php:47
FormAccounting
Class to manage generation of HTML components for accounting management.
Definition: html.formaccounting.class.php:33
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:2097
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5834
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
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:4025
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
$formconfirm
$formconfirm
if ($action == 'delbookkeepingyear') {
Definition: listbyaccount.php:634
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:8911
AccountingJournal
Class to manage accounting accounts.
Definition: accountingjournal.class.php:27
dol_string_nospecial
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='')
Clean a string from all punctuation characters to use it as a ref or login.
Definition: functions.lib.php:1408
Account\TYPE_SAVINGS
const TYPE_SAVINGS
Savings account.
Definition: account.class.php:358
bank_prepare_head
bank_prepare_head(Account $object)
Prepare array with list of tabs.
Definition: bank.lib.php:37
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:1873
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:4950
restrictedArea
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:341
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11317
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2069
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:147
AccountingAccount
Class to manage accounting accounts.
Definition: accountingaccount.class.php:36
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:431
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
FormBank
Class to manage generation of HTML components for bank module.
Definition: html.formbank.class.php:32
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
$parameters
$parameters
Actions.
Definition: card.php:79
getCountry
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Definition: company.lib.php:515
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8509
FormBank\getIBANLabel
static getIBANLabel(Account $account)
Returns the name of the Iban label.
Definition: html.formbank.class.php:75
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:2859
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:96
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30
Account
Class to manage bank accounts.
Definition: account.class.php:39