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