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