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