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