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