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