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