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("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="clos" value="0">';
432 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
433
434 print dol_get_fiche_head([]);
435
436 print '<table class="border centpercent tableforfieldcreate">';
437
438 // Ref
439 print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
440 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>';
441
442 // Label
443 print '<tr><td class="fieldrequired">'.$langs->trans("LabelBankCashAccount").'</td>';
444 print '<td><input type="text" class="flat maxwidth150onsmartphone" name="label" value="'.dol_escape_htmltag(GETPOST('label', 'alpha')).'"></td></tr>';
445
446 // Type
447 print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
448 print '<td>';
449 $formbank->selectTypeOfBankAccount(GETPOSTISSET("type") ? GETPOSTINT('type') : Account::TYPE_CURRENT, 'type');
450 print '</td></tr>';
451
452 // Currency
453 print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
454 print '<td>';
455 $selectedcode = $object->currency_code;
456 if (!$selectedcode) {
457 $selectedcode = $conf->currency;
458 }
459 print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code');
460 //print $langs->trans("Currency".$conf->currency);
461 //print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
462 print '</td></tr>';
463
464 // Status
465 print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
466 print '<td>';
467 print $form->selectarray("clos", $object->labelStatus, (GETPOSTINT('clos') != '' ? GETPOSTINT('clos') : $object->status), 0, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth150onsmartphone');
468 print '</td></tr>';
469
470 // Bank country
471 $selectedcode = '';
472 if (GETPOSTISSET("account_country_id")) {
473 $selectedcode = GETPOST("account_country_id") ? GETPOST("account_country_id") : $object->country_code;
474 } elseif (empty($selectedcode)) {
475 $selectedcode = $mysoc->country_code;
476 }
477 $object->country_code = getCountry($selectedcode, '2'); // Force country code on account to have following field on bank fields matching country rules
478
479 print '<tr><td class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>';
480 print '<td>';
481 print img_picto('', 'country', 'class="pictofixedwidth"');
482 print $form->select_country($selectedcode, 'account_country_id');
483 if ($user->admin) {
484 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
485 }
486 print '</td></tr>';
487
488 // Bank state
489 print '<tr><td>'.$langs->trans('State').'</td><td>';
490 if ($selectedcode) {
491 print img_picto('', 'state', 'class="pictofixedwidth"');
492 print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOSTINT("account_state_id") : 0, $selectedcode, 'account_state_id');
493 } else {
494 print $countrynotdefined;
495 }
496 print '</td></tr>';
497
498 // Bank address
499 $type = (GETPOSTISSET("type") ? GETPOSTINT('type') : Account::TYPE_CURRENT); // add default value
500 if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
501 print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
502 print '<textarea class="flat quatrevingtpercent" name="account_address" rows="'.ROWS_2.'">';
503 print(GETPOSTISSET('account_address') ? GETPOST('account_address') : $object->address);
504 print "</textarea></td></tr>";
505 }
506
507 // Web
508 print '<tr><td>'.$langs->trans("Web").'</td>';
509 print '<td>';
510 print img_picto('', 'globe', 'class="pictofixedwidth"');
511 print '<input class="minwidth300 widthcentpercentminusx maxwidth500" type="text" class="flat" name="url" value="'.GETPOST("url").'">';
512 print '</td></tr>';
513
514 // Tags-Categories
515 if (isModEnabled('category')) {
516 print '<tr><td>'.$langs->trans("Categories").'</td><td>';
517 print $form->selectCategories(Categorie::TYPE_ACCOUNT, 'categories', $object);
518 print "</td></tr>";
519 }
520
521 // Comment
522 print '<tr><td>'.$langs->trans("Comment").'</td>';
523 print '<td>';
524 // Editor wysiwyg
525 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
526 $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%');
527 $doleditor->Create();
528 print '</td></tr>';
529
530 // Other attributes
531 $parameters = array();
532 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
533 print $hookmanager->resPrint;
534 if (empty($reshook)) {
535 print $object->showOptionals($extrafields, 'create', $parameters);
536 }
537
538 print '</table>';
539
540 print '<br>';
541
542 print '<table class="border centpercent">';
543
544 // Sold
545 print '<tr><td class="titlefieldcreate">'.$langs->trans("InitialBankBalance").'</td>';
546 print '<td><input size="12" type="text" class="flat" name="solde" value="'.(GETPOSTISSET("solde") ? GETPOST("solde") : price2num($object->solde)).'"></td></tr>';
547
548 print '<tr><td>'.$langs->trans("Date").'</td>';
549 print '<td>';
550 $startdate = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT('reday'), GETPOSTINT("reyear"));
551 print $form->selectDate($startdate, 're', 0, 0, 0, 'formsoc');
552 print '</td></tr>';
553
554 print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
555 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>';
556
557 print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
558 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>';
559
560 print '</table>';
561 print '<br>';
562
563 $type = (GETPOSTISSET("type") ? GETPOSTINT('type') : Account::TYPE_CURRENT); // add default value
564 if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
565 print '<table class="border centpercent">';
566
567 // If bank account
568 print '<tr><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
569 print '<td><input type="text" class="flat minwidth150" name="bank" value="'.(GETPOSTISSET('bank') ? GETPOST('bank', 'alpha') : $object->bank).'"></td>';
570 print '</tr>';
571
572 $ibankey = FormBank::getIBANLabel($object);
573 $bickey = "BICNumber";
574 if ($object->getCountryCode() == 'IN') {
575 $bickey = "SWIFT";
576 }
577
578 // IBAN
579 print '<tr><td>'.$langs->trans($ibankey).'</td>';
580 print '<td><input maxlength="34" type="text" class="flat minwidth300" name="iban" value="'.(GETPOSTISSET('iban') ? GETPOST('iban', 'alpha') : $object->iban).'"></td></tr>';
581
582 // BIC
583 print '<tr><td>'.$langs->trans($bickey).'</td>';
584 print '<td><input maxlength="11" type="text" class="flat minwidth150" name="bic" value="'.(GETPOSTISSET('bic') ? GETPOST('bic', 'alpha') : $object->bic).'"></td></tr>';
585
586 // Show fields of bank account
587 $sizecss = '';
588 foreach ($object->getFieldsToShow() as $val) {
589 $content = '';
590 if ($val == 'BankCode') {
591 $name = 'code_banque';
592 $sizecss = 'minwidth100';
593 $content = $object->code_banque;
594 } elseif ($val == 'DeskCode') {
595 $name = 'code_guichet';
596 $sizecss = 'minwidth100';
597 $content = $object->code_guichet;
598 } elseif ($val == 'BankAccountNumber') {
599 $name = 'number';
600 $sizecss = 'minwidth200';
601 $content = $object->number;
602 } elseif ($val == 'BankAccountNumberKey') {
603 $name = 'cle_rib';
604 $sizecss = 'minwidth50';
605 $content = $object->cle_rib;
606 } else {
607 $name = 'undefined';
608 $sizecss = 'undefined';
609 $content = 'undefined';
610 }
611
612 print '<td>'.$langs->trans($val).'</td>';
613 print '<td><input type="text" class="flat '.$sizecss.'" name="'.$name.'" value="'.(GETPOSTISSET($name) ? GETPOST($name, 'alpha') : $content).'"></td>';
614 print '</tr>';
615 }
616
617 if (isModEnabled('paymentbybanktransfer')) {
618 if ($mysoc->isInSEPA()) {
619 print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>';
620 print '<td><input type="checkbox" class="flat" name="pti_in_ctti"'. (empty(GETPOST('pti_in_ctti')) ? '' : ' checked ') . '>';
621 print '</td></tr>';
622 }
623 }
624 print '</table>';
625 print '<hr>';
626
627 print '<table class="border centpercent">';
628 print '<tr><td class="titlefieldcreate">'.$langs->trans("BankAccountOwner").'</td>';
629 print '<td><input type="text" class="flat minwidth300" name="proprio" value="'.(GETPOSTISSET('proprio') ? GETPOST('proprio', 'alpha') : $object->owner_name).'">';
630 print '</td></tr>';
631
632 print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
633 print '<textarea class="flat quatrevingtpercent" name="owner_address" rows="'.ROWS_2.'">';
634 print(GETPOSTISSET('owner_address') ? GETPOST('owner_address', 'alpha') : $object->owner_address);
635 print "</textarea></td></tr>";
636
637 print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerZip").'</td>';
638 print '<td><input type="text" class="flat maxwidth100" name="owner_zip" value="'.(GETPOSTISSET('owner_zip') ? GETPOST('owner_zip', 'alpha') : $object->owner_zip).'">';
639 print '</td></tr>';
640
641 print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerTown").'</td>';
642 print '<td><input type="text" class="flat maxwidth200" name="owner_town" value="'.(GETPOSTISSET('owner_town') ? GETPOST('owner_town', 'alpha') : $object->owner_town).'">';
643 print '</td></tr>';
644
645 print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerCountry").'</td>';
646 print '<td>';
647 print img_picto('', 'country', 'class="pictofixedwidth"');
648 print $form->select_country(GETPOSTISSET('owner_country_id') ? GETPOST('owner_country_id', 'alpha') : $object->owner_country_id, 'owner_country_id');
649 print '</td></tr>';
650
651 print '</table>';
652 print '<hr>';
653 }
654
655 print '<table class="border centpercent">';
656 // Accountancy code
657 $fieldrequired = '';
658 if (getDolGlobalString('MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED')) {
659 $fieldrequired = 'fieldrequired ';
660 }
661
662 if (isModEnabled('accounting')) {
664 print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
665 print '<td>';
666 print img_picto('', 'accounting_account', 'class="pictofixedwidth"');
667 print $formaccounting->select_account($object->account_number, 'account_number', 1, array(), 1, 1);
668 if ($formaccounting->nbaccounts == 0) {
669 $langs->load("errors");
670 $htmltext = $langs->transnoentitiesnoconv("WarningGoOnAccountancySetupToAddAccounts", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Chartofaccounts"));
671 print $form->textwithpicto('', $htmltext);
672 }
673 print '</td></tr>';
674 } else {
675 print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
676 print '<td><input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST('account_number', 'alpha') : $object->account_number).'"></td></tr>';
677 }
678
679 // Accountancy journal
680 if (isModEnabled('accounting')) {
682 print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyJournal").'</td>';
683 print '<td>';
684 print $formaccounting->select_journal((string) $object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
685 print '</td></tr>';
686 }
687
688 print '</table>';
689
690 print dol_get_fiche_end();
691
692 print $form->buttonsSaveCancel("CreateAccount");
693
694 print '</form>';
695} else {
696 // View and edit mode
697 if ((GETPOSTINT("id") || GETPOST("ref")) && $action != 'edit') {
698 // Show tabs
699 $head = bank_prepare_head($object);
700
701 print dol_get_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account', 0, '', '', 0, '', 1);
702
703 $formconfirm = '';
704
705 // Confirmation to delete
706 if ($action == 'delete') {
707 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteAccount"), $langs->trans("ConfirmDeleteAccount"), "confirm_delete");
708 }
709
710 // Print form confirm
711 print $formconfirm;
712
713 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
714
715 $morehtmlref = '';
716 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
717
718 print '<div class="fichecenter">';
719 print '<div class="fichehalfleft">';
720 print '<div class="underbanner clearboth"></div>';
721
722 print '<table class="border centpercent tableforfield">';
723
724 // Type
725 print '<tr><td class="titlefieldmiddle">'.$langs->trans("AccountType").'</td>';
726 print '<td>'.$object->type_lib[$object->type].'</td></tr>';
727
728 // Currency
729 print '<tr><td>'.$langs->trans("Currency").'</td>';
730 print '<td>';
731 $selectedcode = $object->currency_code;
732 if (!$selectedcode) {
733 $selectedcode = $conf->currency;
734 }
735 print $langs->trans("Currency".$selectedcode);
736 print '</td></tr>';
737
738 // Conciliable
739 print '<tr><td>'.$langs->trans("Conciliable").'</td>';
740 print '<td>';
741 $conciliate = $object->canBeConciliated();
742 if ($conciliate == -2) {
743 print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("CashAccount").')</span>';
744 } elseif ($conciliate == -3) {
745 print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("Closed").')</span>';
746 } else {
747 print($object->rappro == 1 ? $langs->trans("Yes") : ($langs->trans("No").' <span class="opacitymedium">('.$langs->trans("ConciliationDisabled").')</span>'));
748 }
749 print '</td></tr>';
750
751 print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
752 print '<td>'.$object->min_allowed.'</td></tr>';
753
754 print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
755 print '<td>'.$object->min_desired.'</td></tr>';
756
757 // Accountancy code
758 print '<tr class="liste_titre_add"><td class="titlefield">'.$langs->trans("AccountancyCode").'</td>';
759 print '<td>';
760 if (isModEnabled('accounting')) {
761 if (empty($object->account_number)) {
762 print img_warning($langs->trans("Mandatory"));
763 } else {
764 $accountingaccount = new AccountingAccount($db);
765 $accountingaccount->fetch(0, $object->account_number, 1);
766 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
767 }
768 } else {
769 print $object->account_number;
770 }
771 print '</td></tr>';
772
773 // Accountancy journal
774 if (isModEnabled('accounting')) {
775 print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
776 print '<td>';
777 if (empty($object->fk_accountancy_journal)) {
778 print img_warning($langs->trans("Mandatory"));
779 } elseif ($object->fk_accountancy_journal > 0) {
780 $accountingjournal = new AccountingJournal($db);
781 $accountingjournal->fetch($object->fk_accountancy_journal);
782 print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
783 }
784 print '</td></tr>';
785 }
786
787 // Other attributes
788 $cols = 2;
789 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
790
791 print '</table>';
792
793 print '</div>';
794 print '<div class="fichehalfright">';
795 print '<div class="underbanner clearboth"></div>';
796
797 print '<table class="border tableforfield centpercent">';
798
799 // Categories
800 if (isModEnabled('category')) {
801 print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
802 print $form->showCategories($object->id, Categorie::TYPE_ACCOUNT, 1);
803 print "</td></tr>";
804 }
805
806 print '<tr><td class="tdtop titlefield">'.$langs->trans("Comment").'</td>';
807 print '<td>'.dol_htmlentitiesbr($object->comment).'</td></tr>';
808
809 print '</table>';
810
812 print '<table class="border tableforfield centpercent">';
813
814 print '<tr><td class="titlefieldmiddle">'.$langs->trans("BankName").'</td>';
815 print '<td>'.$object->bank.'</td></tr>';
816
817 $ibankey = FormBank::getIBANLabel($object);
818 $bickey = "BICNumber";
819 if ($object->getCountryCode() == 'IN') {
820 $bickey = "SWIFT";
821 }
822
823 // IBAN
824 print '<tr><td>'.$langs->trans($ibankey).'</td>';
825 print '<td>'.getIbanHumanReadable($object).'&nbsp;';
826 if (!empty($object->iban)) {
827 if (!checkIbanForAccount($object)) {
828 print img_picto($langs->trans("IbanNotValid"), 'warning');
829 } else {
830 print img_picto($langs->trans("IbanValid"), 'tick');
831 }
832 }
833 print '</td></tr>';
834
835 // BIC
836 print '<tr><td>'.$langs->trans($bickey).'</td>';
837 print '<td>'.$object->bic.'&nbsp;';
838 if (!empty($object->bic)) {
839 if (!checkSwiftForAccount($object)) {
840 print img_picto($langs->trans("SwiftNotValid"), 'warning');
841 } else {
842 print img_picto($langs->trans("SwiftValid"), 'tick');
843 }
844 }
845 print '</td></tr>';
846
847 // TODO Add a link "Show more..." for all other information.
848
849 // Show fields of bank account
850 foreach ($object->getFieldsToShow() as $val) {
851 $content = '';
852 if ($val == 'BankCode') {
853 $content = $object->code_banque;
854 } elseif ($val == 'DeskCode') {
855 $content = $object->code_guichet;
856 } elseif ($val == 'BankAccountNumber') {
857 $content = $object->number;
858 } elseif ($val == 'BankAccountNumberKey') {
859 $content = $object->cle_rib;
860 }
861
862 print '<tr><td>'.$langs->trans($val).'</td>';
863 print '<td>'.$content.'</td>';
864 print '</tr>';
865 }
866
867 if (isModEnabled('prelevement')) {
868 print '<tr><td>'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'</td>';
869 print '<td>'.$object->ics.'</td>';
870 print '</tr>';
871 }
872
873 if (isModEnabled('paymentbybanktransfer')) {
874 if (getDolGlobalString("SEPA_USE_IDS")) { // Use another ICS for bank transfer
875 print '<tr><td>'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'</td>';
876 print '<td>'.$object->ics_transfer.'</td>';
877 print '</tr>';
878 }
879 if ($mysoc->isInSEPA()) {
880 print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td><td>';
881 print(empty($object->pti_in_ctti) ? $langs->trans("No") : $langs->trans("Yes"));
882 print "</td></tr>\n";
883 }
884 }
885
886 print '<tr><td>'.$langs->trans("BankAccountOwner").'</td><td>';
887 print dol_escape_htmltag($object->owner_name);
888 print "</td></tr>\n";
889
890 print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
891 print nl2br($object->owner_address);
892 print "</td></tr>\n";
893
894 print '<tr><td>'.$langs->trans("BankAccountOwnerZip").'</td>';
895 print '<td>'.dol_escape_htmltag($object->owner_zip);
896 print '</td></tr>';
897
898 print '<tr><td>'.$langs->trans("BankAccountOwnerTown").'</td>';
899 print '<td>'.dol_escape_htmltag($object->owner_town);
900 print '</td></tr>';
901
902 print '<tr><td>'.$langs->trans("BankAccountOwnerCountry").'</td>';
903 print '<td>';
904 $object->owner_country_code = dol_getIdFromCode($db, $object->owner_country_id, 'c_country', 'rowid', 'code');
905 $langs->load("dict");
906 print(empty($object->owner_country_code) ? '' : $langs->convToOutputCharset($langs->transnoentitiesnoconv("Country".$object->owner_country_code)));
907
908 print '</td></tr>';
909
910 print '</table>';
911 }
912
913 print '</div>';
914 print '</div>';
915
916 print '<div class="clearboth"></div>';
917
918 print dol_get_fiche_end();
919
920 /*
921 * Action bar
922 */
923 print '<div class="tabsAction">';
924 $parameters = array();
925 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
926 if ($reshook < 0) {
927 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
928 }
929
930 if (empty($reshook)) {
931 if ($user->hasRight('banque', 'configurer') && $object->status == $object::STATUS_CLOSED) {
932 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id.'">'.$langs->trans("ReOpen").'</a>';
933 }
934
935 if ($user->hasRight('banque', 'configurer') && $object->status == $object::STATUS_OPEN) {
936 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Modify").'</a>';
937 }
938
939 if ($user->hasRight('banque', 'configurer') && $object->status == $object::STATUS_OPEN) {
940 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=close&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Close").'</a>';
941 }
942
943 $canbedeleted = $object->can_be_deleted(); // Return true if account without movements
944 if ($user->hasRight('banque', 'configurer') && $canbedeleted) {
945 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";
946 }
947 }
948
949 print '</div>';
950 }
951
952 /* ************************************************************************** */
953 /* */
954 /* Edition */
955 /* */
956 /* ************************************************************************** */
957
958 if (GETPOSTINT('id') && $action == 'edit' && $user->hasRight('banque', 'configurer')) {
959 print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'bank_account');
960
961 if ($conf->use_javascript_ajax) {
962 print "\n".'<script type="text/javascript">';
963 print 'jQuery(document).ready(function () {
964 jQuery("#type").change(function() {
965 document.formsoc.action.value="edit";
966 document.formsoc.submit();
967 });
968 })'."\n";
969
970 print 'jQuery(document).ready(function () {
971 jQuery("#selectaccount_country_id").change(function() {
972 document.formsoc.action.value="edit";
973 document.formsoc.submit();
974 });
975 })';
976 print '</script>'."\n";
977 }
978
979 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formsoc">';
980 print '<input type="hidden" name="token" value="'.newToken().'">';
981 print '<input type="hidden" name="action" value="update">';
982 print '<input type="hidden" name="id" value="'.GETPOSTINT("id").'">'."\n\n";
983 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
984
985 print dol_get_fiche_head(array(), '', '', 0);
986
987 //print '<div class="underbanner clearboth"></div>';
988
989 print '<table class="border centpercent tableforfieldcreate">';
990
991 // Ref
992 print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
993 print '<td><input type="text" class="flat maxwidth200" name="ref" value="'.dol_escape_htmltag(GETPOSTISSET('ref') ? GETPOST('ref', 'alpha') : $object->ref).'" maxlength="12" autofocus></td></tr>';
994
995 // Label
996 print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
997 print '<td><input type="text" class="flat minwidth300" name="label" value="'.dol_escape_htmltag(GETPOSTISSET('label') ? GETPOST('label', 'alpha') : $object->label).'"></td></tr>';
998
999 // Type
1000 print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
1001 print '<td class="maxwidth200onsmartphone">';
1002 $formbank->selectTypeOfBankAccount((GETPOSTISSET('type') ? GETPOSTINT('type') : $object->type), 'type');
1003 print '</td></tr>';
1004
1005 // Currency
1006 print '<tr><td class="fieldrequired">'.$langs->trans("Currency");
1007 print '<input type="hidden" value="'.$object->currency_code.'">';
1008 print '</td>';
1009 print '<td class="maxwidth200onsmartphone">';
1010 $selectedcode = $object->currency_code;
1011 if (!$selectedcode) {
1012 $selectedcode = $conf->currency;
1013 }
1014 print img_picto('', 'multicurrency', 'class="pictofixedwidth"');
1015 print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code');
1016 //print $langs->trans("Currency".$conf->currency);
1017 //print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
1018 print '</td></tr>';
1019
1020 // Status
1021 print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
1022 print '<td class="maxwidth200onsmartphone">';
1023 print $form->selectarray("clos", $object->labelStatus, (GETPOSTISSET("clos") ? GETPOSTINT("clos") : $object->status));
1024 print '</td></tr>';
1025
1026 // Bank country
1027 $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id;
1028 $selectedcode = $object->country_code;
1029 if (GETPOSTISSET("account_country_id")) {
1030 $selectedcode = GETPOST("account_country_id");
1031 } elseif (empty($selectedcode)) {
1032 $selectedcode = $mysoc->country_code;
1033 }
1034 $object->country_code = getCountry($selectedcode, '2'); // Force country code on account to have following field on bank fields matching country rules
1035
1036 print '<tr><td class="fieldrequired">'.$langs->trans("Country").'</td>';
1037 print '<td class="maxwidth200onsmartphone">';
1038 print img_picto('', 'country', 'class="pictofixedwidth"').$form->select_country($selectedcode, 'account_country_id');
1039 if ($user->admin) {
1040 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1041 }
1042 print '</td></tr>';
1043
1044 // Bank state
1045 print '<tr><td>'.$langs->trans('State').'</td><td class="maxwidth200onsmartphone">';
1046 if ($selectedcode) {
1047 print img_picto('', 'state', 'class="pictofixedwidth"');
1048 print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : $object->state_id, $selectedcode, 'account_state_id');
1049 } else {
1050 print $countrynotdefined;
1051 }
1052 print '</td></tr>';
1053
1054 // Bank address
1055 $type = (GETPOSTISSET('type') ? GETPOSTINT('type') : $object->type); // add default current value
1056 if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
1057 print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
1058 print '<textarea class="flat quatrevingtpercent" name="account_address" rows="'.ROWS_2.'">';
1059 print $object->address;
1060 print "</textarea></td></tr>";
1061 }
1062
1063 // Conciliable
1064 print '<tr><td>'.$langs->trans("Conciliable").'</td>';
1065 print '<td>';
1066 $conciliate = $object->canBeConciliated();
1067 if ($conciliate == -2) {
1068 print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("CashAccount").')</span>';
1069 } elseif ($conciliate == -3) {
1070 print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("Closed").')</span>';
1071 } else {
1072 print '<input type="checkbox" class="flat" id="norappro" name="norappro"'.(($conciliate > 0) ? '' : ' checked="checked"').'"> <label for="norappro" class="opacitymedium">'.$langs->trans("DisableConciliation").'</label>';
1073 }
1074 print '</td></tr>';
1075
1076 // Balance
1077 print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
1078 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>';
1079
1080 print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
1081 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>';
1082
1083 // Web
1084 print '<tr><td>'.$langs->trans("Web").'</td>';
1085 print '<td>';
1086 print img_picto('', 'globe', 'class="pictofixedwidth"');
1087 print '<input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(GETPOSTISSET("url") ? GETPOST("url") : $object->url).'">';
1088 print '</td></tr>';
1089
1090 // Tags-Categories
1091 if (isModEnabled('category')) {
1092 print '<tr><td>'.$langs->trans("Categories").'</td><td>';
1093 print $form->selectCategories(Categorie::TYPE_ACCOUNT, 'categories', $object);
1094 print "</td></tr>";
1095 }
1096
1097 // Comment
1098 print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
1099 print '<td>';
1100 // Editor wysiwyg
1101 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1102 $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%');
1103 $doleditor->Create();
1104 print '</td></tr>';
1105
1106 // Other attributes
1107 $parameters = array();
1108 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1109 print $hookmanager->resPrint;
1110 if (empty($reshook)) {
1111 print $object->showOptionals($extrafields, 'edit', $parameters);
1112 }
1113
1114 print '</table>';
1115 print '<hr>';
1116
1117
1118 //print '<div class="underbanner clearboth"></div>';
1119
1120 print '<table class="border centpercent">';
1121
1122 // Accountancy code
1123 $tdextra = ' class="titlefieldcreate"';
1124
1125 if (getDolGlobalString('MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED')) {
1126 $tdextra = ' class="fieldrequired titlefieldcreate"';
1127 }
1128
1129 print '<tr><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
1130 print '<td>';
1131 if (isModEnabled('accounting')) {
1133 print img_picto('', 'accounting_account', 'class="pictofixedwidth"');
1134 print $formaccounting->select_account($object->account_number, 'account_number', 1, array(), 1, 1);
1135 if ($formaccounting->nbaccounts == 0) {
1136 $langs->load("errors");
1137 $htmltext = $langs->transnoentitiesnoconv("WarningGoOnAccountancySetupToAddAccounts", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Chartofaccounts"));
1138 print $form->textwithpicto('', $htmltext);
1139 }
1140 } else {
1141 print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
1142 }
1143 print '</td></tr>';
1144
1145 // Accountancy journal
1146 if (isModEnabled('accounting')) {
1148 print '<tr><td class="fieldrequired">'.$langs->trans("AccountancyJournal").'</td>';
1149 print '<td>';
1150 print $formaccounting->select_journal((string) $object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
1151 print '</td></tr>';
1152 }
1153
1154 print '</table>';
1155
1156 $type = (GETPOSTISSET('type') ? GETPOSTINT('type') : $object->type); // add default current value
1157 if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
1158 print '<br>';
1159
1160 print '<table class="border centpercent">';
1161
1162 // If bank account
1163 print '<tr class="liste_titre_add"><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
1164 print '<td><input type="text" class="flat width300" name="bank" value="'.$object->bank.'"></td>';
1165 print '</tr>';
1166
1167 $ibankey = FormBank::getIBANLabel($object);
1168 $bickey = "BICNumber";
1169 if ($object->getCountryCode() == 'IN') {
1170 $bickey = "SWIFT";
1171 }
1172
1173 // IBAN
1174 print '<tr><td>';
1175 $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';
1176 print $form->textwithpicto($langs->trans($ibankey), $tooltip, 1, 'help', '', 0, 3, 'iban');
1177 print '</td>';
1178 print '<td><input class="minwidth300 maxwidth200onsmartphone" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOSTISSET('iban') ? GETPOST('iban', 'alphanohtml') : $object->iban).'"></td></tr>';
1179
1180 // BIC
1181 print '<tr><td>';
1182 $tooltip = $langs->trans("Example").': LIABLT2XXXX';
1183 print $form->textwithpicto($langs->trans($bickey), $tooltip, 1, 'help', '', 0, 3, 'bic');
1184 print '</td>';
1185 print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOSTISSET('bic') ? GETPOST('bic', 'alphanohtml') : $object->bic).'"></td></tr>';
1186
1187 // Show fields of bank account
1188 foreach ($object->getFieldsToShow() as $val) {
1189 $content = '';
1190 if ($val == 'BankCode') {
1191 $name = 'code_banque';
1192 $css = 'width100';
1193 $content = $object->code_banque;
1194 } elseif ($val == 'DeskCode') {
1195 $name = 'code_guichet';
1196 $css = 'width100';
1197 $content = $object->code_guichet;
1198 } elseif ($val == 'BankAccountNumber') {
1199 $name = 'number';
1200 $css = 'width200';
1201 $content = $object->number;
1202 } elseif ($val == 'BankAccountNumberKey') {
1203 $name = 'cle_rib';
1204 $css = 'width50';
1205 $content = $object->cle_rib;
1206 } else {
1207 $name = 'undefined';
1208 $css = 'undefined';
1209 $content = 'undefined';
1210 }
1211
1212 print '<tr><td>'.$langs->trans($val).'</td>';
1213 print '<td><input type="text" class="flat '.$css.'" name="'.$name.'" value="'.dol_escape_htmltag($content).'"></td>';
1214 print '</tr>';
1215 }
1216
1217 if (isModEnabled('prelevement')) {
1218 print '<tr><td>'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'</td>';
1219 print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics" value="'.(GETPOSTISSET('ics') ? GETPOST('ics', 'alphanohtml') : $object->ics).'"></td></tr>';
1220 }
1221
1222 if (isModEnabled('paymentbybanktransfer')) {
1223 if (getDolGlobalString("SEPA_USE_IDS")) { // ICS is not used with bank transfer !
1224 print '<tr><td>'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'</td>';
1225 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>';
1226 }
1227 if ($mysoc->isInSEPA()) {
1228 print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>';
1229 print '<td><input type="checkbox" class="flat" name="pti_in_ctti"'. ($object->pti_in_ctti ? ' checked ' : '') . '>';
1230 print '</td></tr>';
1231 }
1232 }
1233
1234 print '</table>';
1235
1236 print '<hr>';
1237
1238 print '<table class="border centpercent">';
1239
1240 print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
1241 print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="proprio" value="'.(GETPOSTISSET('proprio') ? GETPOST('proprio', 'alpha') : $object->owner_name).'"></td>';
1242 print '</tr>';
1243
1244 print '<tr><td class="titlefieldcreate tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
1245 print '<textarea class="flat quatrevingtpercent" name="owner_address" rows="'.ROWS_2.'">';
1246 print GETPOSTISSET('owner_address') ? GETPOST('owner_address', 'alpha') : $object->owner_address;
1247 print "</textarea></td></tr>";
1248
1249 print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerZip").'</td>';
1250 print '<td><input type="text" class="flat maxwidth100" name="owner_zip" value="'.(GETPOSTISSET('owner_zip') ? GETPOST('owner_zip', 'alpha') : $object->owner_zip).'">';
1251 print '</td></tr>';
1252
1253 print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerTown").'</td>';
1254 print '<td><input type="text" class="flat maxwidth200" name="owner_town" value="'.(GETPOSTISSET('owner_town') ? GETPOST('owner_town', 'alpha') : $object->owner_town).'">';
1255 print '</td></tr>';
1256
1257 print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerCountry").'</td>';
1258 print '<td>';
1259 print img_picto('', 'country', 'class="pictofixedwidth"');
1260 print $form->select_country(GETPOSTISSET('owner_country_id') ? GETPOST('owner_country_id', 'alpha') : $object->owner_country_id, 'owner_country_id');
1261 print '</td></tr>';
1262
1263 print '</table>';
1264 }
1265
1266 print dol_get_fiche_end();
1267
1268 print $form->buttonsSaveCancel("Modify");
1269
1270 print '</form>';
1271 }
1272}
1273
1274// End of page
1275llxFooter();
1276$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:280
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:390
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:369
$object ref
Definition info.php:90
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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)
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.
div refaddress div address
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:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
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:181
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.