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