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