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