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