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