* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2014-2017 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Marcos García * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022 Charlene Benke * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/compta/bank/card.php * \ingroup bank * \brief Page to create/view a bank account */ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; if (isModEnabled('category')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; } if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; } if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; } // Load translation files required by the page $langs->loadLangs(array("banks", "bills", "categories", "companies", "compta", "withdrawals")); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $object = new Account($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('bankcard', 'globalcard')); // Security check $id = GETPOSTINT("id") ? GETPOSTINT("id") : GETPOST('ref'); $fieldid = GETPOSTINT("id") ? 'rowid' : 'ref'; if (GETPOSTINT("id") || GETPOST("ref")) { if (GETPOSTINT("id")) { $object->fetch(GETPOSTINT("id")); } if (GETPOST("ref")) { $object->fetch(0, GETPOST("ref")); } } $result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); /* * Actions */ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } if (empty($reshook)) { $backurlforlist = DOL_URL_ROOT.'/compta/bank/list.php'; if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { $backtopage = DOL_URL_ROOT.'/compta/bank/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); } } } if ($cancel) { if (!empty($backtopageforcancel)) { header("Location: ".$backtopageforcancel); exit; } elseif (!empty($backtopage)) { header("Location: ".$backtopage); exit; } $action = ''; } if ($action == 'add' && $user->hasRight('banque', 'configurer')) { $error = 0; $db->begin(); // Create account $object = new Account($db); $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha'))); $object->label = trim(GETPOST("label", 'alphanohtml')); $object->type = GETPOSTINT("type"); $object->courant = $object->type; // deprecated $object->status = GETPOSTINT("clos"); $object->clos = $object->status; // deprecated $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1); $object->url = trim(GETPOST("url", 'alpha')); $object->bank = trim(GETPOST("bank")); $object->code_banque = trim(GETPOST("code_banque")); $object->code_guichet = trim(GETPOST("code_guichet")); $object->number = trim(GETPOST("number")); $object->cle_rib = trim(GETPOST("cle_rib")); $object->bic = trim(GETPOST("bic")); $object->iban = trim(GETPOST("iban")); $object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1; $object->address = trim(GETPOST("account_address", "alphanohtml")); $object->domiciliation = $object->address; // deprecated $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_name = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_address = trim(GETPOST("owner_address", 'alphanohtml')); $object->owner_zip = trim(GETPOST("owner_zip", 'alphanohtml')); $object->owner_town = trim(GETPOST("owner_town", 'alphanohtml')); $object->owner_country_id = GETPOSTINT("owner_country_id"); $object->ics = trim(GETPOST("ics", 'alpha')); $object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha')); $account_number = GETPOST('account_number', 'alphanohtml'); if (empty($account_number) || $account_number == '-1') { $object->account_number = ''; } else { $object->account_number = $account_number; } $fk_accountancy_journal = GETPOSTINT('fk_accountancy_journal'); if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = 0; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; } $object->balance = GETPOSTFLOAT("solde"); $object->solde = $object->balance; // deprecated $object->date_solde = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT('reday'), GETPOSTINT("reyear")); $object->currency_code = trim(GETPOST("account_currency_code")); $object->state_id = GETPOSTINT("account_state_id"); $object->country_id = GETPOSTINT("account_country_id"); $object->min_allowed = GETPOSTFLOAT("account_min_allowed"); $object->min_desired = GETPOSTFLOAT("account_min_desired"); $object->comment = trim(GETPOST("account_comment", 'restricthtml')); $object->fk_user_author = $user->id; if (getDolGlobalInt('MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED') && empty($object->account_number)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); $action = 'create'; // Force chargement page en mode creation $error++; } if (empty($object->ref)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); $action = 'create'; // Force chargement page en mode creation $error++; } if (empty($object->label)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors'); $action = 'create'; // Force chargement page en mode creation $error++; } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if (!$error) { $id = $object->create($user); if ($id > 0) { // Category association $categories = GETPOST('categories', 'array'); $object->setCategories($categories); $action = ''; } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; // Force chargement page en mode creation } } if (!$error) { $noback = 0; $db->commit(); $urltogo = $backtopage ? str_replace('__ID__', (string) $object->id, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', (string) $object->id, $urltogo); // New method to autoselect project after a New on another form object creation if (empty($noback)) { header("Location: " . $urltogo); exit; } } else { $db->rollback(); } } if ($action == 'update' && $user->hasRight('banque', 'configurer')) { $error = 0; // Update account $object = new Account($db); $object->fetch(GETPOSTINT("id")); $object->oldref = $object->ref; $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha'))); $object->label = trim(GETPOST("label", 'alphanohtml')); $object->type = GETPOSTINT("type"); $object->courant = $object->type; // deprecated $object->status = GETPOSTINT("clos"); $object->clos = $object->status; // deprecated $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1); $object->url = trim(GETPOST("url", 'alpha')); $object->bank = trim(GETPOST("bank")); $object->code_banque = trim(GETPOST("code_banque")); $object->code_guichet = trim(GETPOST("code_guichet")); $object->number = trim(GETPOST("number")); $object->cle_rib = trim(GETPOST("cle_rib")); $object->bic = trim(GETPOST("bic")); $object->iban = trim(GETPOST("iban")); $object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1; $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_name = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_address = trim(GETPOST("owner_address", 'alphanohtml')); $object->owner_zip = trim(GETPOST("owner_zip", 'alphanohtml')); $object->owner_town = trim(GETPOST("owner_town", 'alphanohtml')); $object->owner_country_id = GETPOSTINT("owner_country_id"); $object->ics = trim(GETPOST("ics", 'alpha')); $object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha')); $account_number = GETPOST('account_number', 'alphanohtml'); if (empty($account_number) || $account_number == '-1') { $object->account_number = ''; } else { $object->account_number = $account_number; } $fk_accountancy_journal = GETPOSTINT('fk_accountancy_journal'); if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = 0; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; } $object->currency_code = trim(GETPOST("account_currency_code")); $object->address = trim(GETPOST("account_address", "alphanohtml")); $object->state_id = GETPOSTINT("account_state_id"); $object->country_id = GETPOSTINT("account_country_id"); $object->min_allowed = GETPOSTFLOAT("account_min_allowed"); $object->min_desired = GETPOSTFLOAT("account_min_desired"); $object->comment = trim(GETPOST("account_comment", 'restricthtml')); if (getDolGlobalInt('MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED') && empty($object->account_number)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); $action = 'edit'; // Force chargement page en mode creation $error++; } if (empty($object->ref)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); $action = 'edit'; // Force chargement page en mode creation $error++; } if (empty($object->label)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors'); $action = 'edit'; // Force chargement page en mode creation $error++; } $db->begin(); if (!$error) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); } if (!$error) { $result = $object->update($user); if ($result >= 0) { // Category association $categories = GETPOST('categories', 'array'); $object->setCategories($categories); $id = GETPOSTINT("id"); // Force load of this page } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; // Force load of page in edit mode } } if (!$error) { $db->commit(); } else { $db->rollback(); } } if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->hasRight('banque', 'configurer')) { // Delete $object = new Account($db); $object->fetch(GETPOSTINT("id")); $result = $object->delete($user); if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: " . DOL_URL_ROOT . "/compta/bank/list.php"); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } } /* * View */ $form = new Form($db); $formbank = new FormBank($db); $formcompany = new FormCompany($db); if (isModEnabled('accounting')) { $formaccounting = new FormAccounting($db); } $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas|DE:Modul_Banken_und_Barbestände'; if ($action == 'create') { $title = $langs->trans("NewFinancialAccount"); } elseif (!empty($object->ref)) { $title = $object->ref." - ".$langs->trans("Card"); } llxHeader("", $title, $help_url); // Creation if ($action == 'create') { print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'bank_account'); if ($conf->use_javascript_ajax) { print "\n".''."\n"; } print '
'; print ''; print ''; print ''; print ''; print dol_get_fiche_head(''); print ''; // Ref print ''; print ''; // Label print ''; print ''; // Type print ''; print ''; // Currency print ''; print ''; // Status print ''; print ''; // Bank country $selectedcode = ''; if (GETPOSTISSET("account_country_id")) { $selectedcode = GETPOST("account_country_id") ? GETPOST("account_country_id") : $object->country_code; } elseif (empty($selectedcode)) { $selectedcode = $mysoc->country_code; } $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules print ''; print ''; // Bank state print ''; // Bank address $type = (GETPOSTISSET("type") ? GETPOSTINT('type') : Account::TYPE_CURRENT); // add default value if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) { print '"; } // Web print ''; print ''; // Tags-Categories if (isModEnabled('category')) { print '"; } // Comment print ''; print ''; // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'create', $parameters); } print '
'.$langs->trans("Ref").'ref).'" maxlength="12" autofocus>
'.$langs->trans("LabelBankCashAccount").'
'.$langs->trans("AccountType").''; $formbank->selectTypeOfBankAccount(GETPOSTISSET("type") ? GETPOSTINT('type') : Account::TYPE_CURRENT, 'type'); print '
'.$langs->trans("Currency").''; $selectedcode = $object->currency_code; if (!$selectedcode) { $selectedcode = $conf->currency; } print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
'.$langs->trans("Status").''; print $form->selectarray("clos", $object->labelStatus, (GETPOSTINT('clos') != '' ? GETPOSTINT('clos') : $object->status), 0, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth150onsmartphone'); print '
'.$langs->trans("BankAccountCountry").''; print img_picto('', 'country', 'class="pictofixedwidth"'); print $form->select_country($selectedcode, 'account_country_id'); if ($user->admin) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } print '
'.$langs->trans('State').''; if ($selectedcode) { print img_picto('', 'state', 'class="pictofixedwidth"'); print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : '', $selectedcode, 'account_state_id'); } else { print $countrynotdefined; } print '
'.$langs->trans("BankAccountDomiciliation").''; print '
'.$langs->trans("Web").''; print img_picto('', 'globe', 'class="pictofixedwidth"'); print ''; print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 3); $arrayselected = array(); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT); if (is_array($cats)) { foreach ($cats as $cat) { $arrayselected[] = $cat->id; } } print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'.$langs->trans("Comment").''; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $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%'); $doleditor->Create(); print '
'; print '
'; print ''; // Sold print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("InitialBankBalance").'solde)).'">
'.$langs->trans("Date").''; print $form->selectDate('', 're', 0, 0, 0, 'formsoc'); print '
'.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
'.$langs->trans("BalanceMinimalDesired").'min_desired).'">
'; print '
'; $type = (GETPOSTISSET("type") ? GETPOSTINT('type') : Account::TYPE_CURRENT); // add default value if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) { print ''; // If bank account print ''; print ''; print ''; $ibankey = FormBank::getIBANLabel($object); $bickey = "BICNumber"; if ($object->getCountryCode() == 'IN') { $bickey = "SWIFT"; } // IBAN print ''; print ''; // BIC print ''; print ''; // Show fields of bank account $sizecss = ''; foreach ($object->getFieldsToShow() as $val) { $content = ''; if ($val == 'BankCode') { $name = 'code_banque'; $sizecss = 'minwidth100'; $content = $object->code_banque; } elseif ($val == 'DeskCode') { $name = 'code_guichet'; $sizecss = 'minwidth100'; $content = $object->code_guichet; } elseif ($val == 'BankAccountNumber') { $name = 'number'; $sizecss = 'minwidth200'; $content = $object->number; } elseif ($val == 'BankAccountNumberKey') { $name = 'cle_rib'; $sizecss = 'minwidth50'; $content = $object->cle_rib; } print ''; print ''; print ''; } if (isModEnabled('paymentbybanktransfer')) { if ($mysoc->isInEEC()) { print ''; print ''; } } print '
'.$langs->trans("BankName").'
'.$langs->trans($ibankey).'
'.$langs->trans($bickey).'
'.$langs->trans($val).'
'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).''; print '
'; print '
'; print ''; print ''; print ''; print '"; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("BankAccountOwner").''; print '
'.$langs->trans("BankAccountOwnerAddress").''; print '
'.$langs->trans("BankAccountOwnerZip").''; print '
'.$langs->trans("BankAccountOwnerTown").''; print '
'.$langs->trans("BankAccountOwnerCountry").''; print img_picto('', 'country', 'class="pictofixedwidth"'); print $form->select_country(GETPOSTISSET('owner_country_id') ? GETPOST('owner_country_id', 'alpha') : $object->owner_country_id, 'owner_country_id'); print '
'; print '
'; } print ''; // Accountancy code $fieldrequired = ''; if (getDolGlobalString('MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED')) { $fieldrequired = 'fieldrequired '; } if (isModEnabled('accounting')) { print ''; print ''; } else { print ''; print ''; } // Accountancy journal if (isModEnabled('accounting')) { print ''; print ''; } print '
'.$langs->trans("AccountancyCode").''; print img_picto('', 'accounting_account', 'class="pictofixedwidth"'); print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1); if ($formaccounting->nbaccounts == 0) { $langs->load("errors"); $htmltext = $langs->transnoentitiesnoconv("WarningGoOnAccountancySetupToAddAccounts", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Chartofaccounts")); print $form->textwithpicto('', $htmltext); } print '
'.$langs->trans("AccountancyCode").'account_number).'">
'.$langs->trans("AccountancyJournal").''; print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0); print '
'; print dol_get_fiche_end(); print $form->buttonsSaveCancel("CreateAccount"); print '
'; } else { // View and edit mode if ((GETPOSTINT("id") || GETPOST("ref")) && $action != 'edit') { // Show tabs $head = bank_prepare_head($object); print dol_get_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account', 0, '', '', 0, '', 1); $formconfirm = ''; // Confirmation to delete if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteAccount"), $langs->trans("ConfirmDeleteAccount"), "confirm_delete"); } // Print form confirm print $formconfirm; $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = ''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); print '
'; print '
'; print '
'; print ''; // Type print ''; print ''; // Currency print ''; print ''; // Conciliable print ''; print ''; print ''; print ''; print ''; print ''; // Accountancy code print ''; print ''; // Accountancy journal if (isModEnabled('accounting')) { print ''; print ''; } // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans("AccountType").''.$object->type_lib[$object->type].'
'.$langs->trans("Currency").''; $selectedcode = $object->currency_code; if (!$selectedcode) { $selectedcode = $conf->currency; } print $langs->trans("Currency".$selectedcode); print '
'.$langs->trans("Conciliable").''; $conciliate = $object->canBeConciliated(); if ($conciliate == -2) { print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; } elseif ($conciliate == -3) { print $langs->trans("No").' ('.$langs->trans("Closed").')'; } else { print($object->rappro == 1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); } print '
'.$langs->trans("BalanceMinimalAllowed").''.$object->min_allowed.'
'.$langs->trans("BalanceMinimalDesired").''.$object->min_desired.'
'.$langs->trans("AccountancyCode").''; if (isModEnabled('accounting')) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(0, $object->account_number, 1); print $accountingaccount->getNomUrl(0, 1, 1, '', 1); } else { print $object->account_number; } print '
'.$langs->trans("AccountancyJournal").''; if ($object->fk_accountancy_journal > 0) { $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($object->fk_accountancy_journal); print $accountingjournal->getNomUrl(0, 1, 1, '', 1); } print '
'; print '
'; print '
'; print '
'; print ''; // Categories if (isModEnabled('category')) { print '"; } print ''; print ''; print '
'.$langs->trans("Categories").''; print $form->showCategories($object->id, Categorie::TYPE_ACCOUNT, 1); print "
'.$langs->trans("Comment").''.dol_htmlentitiesbr($object->comment).'
'; if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) { print ''; print ''; print ''; $ibankey = FormBank::getIBANLabel($object); $bickey = "BICNumber"; if ($object->getCountryCode() == 'IN') { $bickey = "SWIFT"; } // IBAN print ''; print ''; // BIC print ''; print ''; // TODO Add a link "Show more..." for all other information. // Show fields of bank account foreach ($object->getFieldsToShow() as $val) { $content = ''; if ($val == 'BankCode') { $content = $object->code_banque; } elseif ($val == 'DeskCode') { $content = $object->code_guichet; } elseif ($val == 'BankAccountNumber') { $content = $object->number; } elseif ($val == 'BankAccountNumberKey') { $content = $object->cle_rib; } print ''; print ''; print ''; } if (isModEnabled('prelevement')) { print ''; print ''; print ''; } if (isModEnabled('paymentbybanktransfer')) { if (getDolGlobalString("SEPA_USE_IDS")) { // Use another ICS for bank transfer print ''; print ''; print ''; } if ($mysoc->isInEEC()) { print '\n"; } } print '\n"; print '\n"; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("BankName").''.$object->bank.'
'.$langs->trans($ibankey).''.getIbanHumanReadable($object).' '; if (!empty($object->iban)) { if (!checkIbanForAccount($object)) { print img_picto($langs->trans("IbanNotValid"), 'warning'); } else { print img_picto($langs->trans("IbanValid"), 'tick'); } } print '
'.$langs->trans($bickey).''.$object->bic.' '; if (!empty($object->bic)) { if (!checkSwiftForAccount($object)) { print img_picto($langs->trans("SwiftNotValid"), 'warning'); } else { print img_picto($langs->trans("SwiftValid"), 'tick'); } } print '
'.$langs->trans($val).''.$content.'
'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').''.$object->ics.'
'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').''.$object->ics_transfer.'
'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).''; print(empty($object->pti_in_ctti) ? $langs->trans("No") : $langs->trans("Yes")); print "
'.$langs->trans("BankAccountOwner").''; print dol_escape_htmltag($object->owner_name); print "
'.$langs->trans("BankAccountOwnerAddress").''; print nl2br($object->owner_address); print "
'.$langs->trans("BankAccountOwnerZip").''.dol_escape_htmltag($object->owner_zip); print '
'.$langs->trans("BankAccountOwnerTown").''.dol_escape_htmltag($object->owner_town); print '
'.$langs->trans("BankAccountOwnerCountry").''; $object->owner_country_code = dol_getIdFromCode($db, $object->owner_country_id, 'c_country', 'rowid', 'code'); $langs->load("dict"); print(empty($object->owner_country_code) ? '' : $langs->convToOutputCharset($langs->transnoentitiesnoconv("Country".$object->owner_country_code))); print '
'; } print '
'; print '
'; print '
'; print dol_get_fiche_end(); /* * Action bar */ print '
'; if ($user->hasRight('banque', 'configurer')) { print 'id.'">'.$langs->trans("Modify").''; } $canbedeleted = $object->can_be_deleted(); // Return true if account without movements if ($user->hasRight('banque', 'configurer') && $canbedeleted) { print 'id.'">'.$langs->trans("Delete").''; } print '
'; } /* ************************************************************************** */ /* */ /* Edition */ /* */ /* ************************************************************************** */ if (GETPOSTINT('id') && $action == 'edit' && $user->hasRight('banque', 'configurer')) { print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'bank_account'); if ($conf->use_javascript_ajax) { print "\n".''."\n"; } print '
'; print ''; print ''; print ''."\n\n"; print ''; print dol_get_fiche_head(array(), '', '', 0); //print '
'; print ''; // Ref print ''; print ''; // Label print ''; print ''; // Type print ''; print ''; // Currency print ''; print ''; // Status print ''; print ''; // Bank country $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id; $selectedcode = $object->country_code; if (GETPOSTISSET("account_country_id")) { $selectedcode = GETPOST("account_country_id"); } elseif (empty($selectedcode)) { $selectedcode = $mysoc->country_code; } $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules print ''; print ''; // Bank state print ''; // Bank address $type = (GETPOSTISSET('type') ? GETPOSTINT('type') : $object->type); // add default current value if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) { print '"; } // Conciliable print ''; print ''; // Balance print ''; print ''; print ''; print ''; // Web print ''; print ''; // Tags-Categories if (isModEnabled('category')) { print '"; } // Comment print ''; print ''; // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("AccountType").''; $formbank->selectTypeOfBankAccount((GETPOSTISSET('type') ? GETPOSTINT('type') : $object->type), 'type'); print '
'.$langs->trans("Currency"); print ''; print ''; $selectedcode = $object->currency_code; if (!$selectedcode) { $selectedcode = $conf->currency; } print img_picto('', 'multicurrency', 'class="pictofixedwidth"'); print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
'.$langs->trans("Status").''; print $form->selectarray("clos", $object->labelStatus, (GETPOSTISSET("clos") ? GETPOSTINT("clos") : $object->status)); print '
'.$langs->trans("Country").''; print img_picto('', 'country', 'class="pictofixedwidth"').$form->select_country($selectedcode, 'account_country_id'); if ($user->admin) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } print '
'.$langs->trans('State').''; if ($selectedcode) { print img_picto('', 'state', 'class="pictofixedwidth"'); print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : $object->state_id, $selectedcode, 'account_state_id'); } else { print $countrynotdefined; } print '
'.$langs->trans("BankAccountDomiciliation").''; print '
'.$langs->trans("Conciliable").''; $conciliate = $object->canBeConciliated(); if ($conciliate == -2) { print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; } elseif ($conciliate == -3) { print $langs->trans("No").' ('.$langs->trans("Closed").')'; } else { print ' 0) ? '' : ' checked="checked"').'"> '; } print '
'.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
'.$langs->trans("BalanceMinimalDesired").'min_desired).'">
'.$langs->trans("Web").''; print img_picto('', 'globe', 'class="pictofixedwidth"'); print 'url).'">'; print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 3); $arrayselected = array(); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT); if (is_array($cats)) { foreach ($cats as $cat) { $arrayselected[] = $cat->id; } } print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'.$langs->trans("Comment").''; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $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%'); $doleditor->Create(); print '
'; print '
'; //print '
'; print ''; // Accountancy code $tdextra = ' class="titlefieldcreate"'; if (getDolGlobalString('MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED')) { $tdextra = ' class="fieldrequired titlefieldcreate"'; } print ''.$langs->trans("AccountancyCode").''; print ''; // Accountancy journal if (isModEnabled('accounting')) { print ''; print ''; } print '
'; if (isModEnabled('accounting')) { print img_picto('', 'accounting_account', 'class="pictofixedwidth"'); print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1); if ($formaccounting->nbaccounts == 0) { $langs->load("errors"); $htmltext = $langs->transnoentitiesnoconv("WarningGoOnAccountancySetupToAddAccounts", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Chartofaccounts")); print $form->textwithpicto('', $htmltext); } } else { print 'account_number).'">'; } print '
'.$langs->trans("AccountancyJournal").''; print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0); print '
'; $type = (GETPOSTISSET('type') ? GETPOSTINT('type') : $object->type); // add default current value if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) { print '
'; print ''; // If bank account print ''; print ''; print ''; $ibankey = FormBank::getIBANLabel($object); $bickey = "BICNumber"; if ($object->getCountryCode() == 'IN') { $bickey = "SWIFT"; } // IBAN print ''; print ''; // BIC print ''; print ''; // Show fields of bank account foreach ($object->getFieldsToShow() as $val) { $content = ''; if ($val == 'BankCode') { $name = 'code_banque'; $css = 'width100'; $content = $object->code_banque; } elseif ($val == 'DeskCode') { $name = 'code_guichet'; $css = 'width100'; $content = $object->code_guichet; } elseif ($val == 'BankAccountNumber') { $name = 'number'; $css = 'width200'; $content = $object->number; } elseif ($val == 'BankAccountNumberKey') { $name = 'cle_rib'; $css = 'width50'; $content = $object->cle_rib; } print ''; print ''; print ''; } if (isModEnabled('prelevement')) { print ''; print ''; } if (isModEnabled('paymentbybanktransfer')) { if (getDolGlobalString("SEPA_USE_IDS")) { // ICS is not used with bank transfer ! print ''; print ''; } if ($mysoc->isInEEC()) { print ''; print ''; } } print '
'.$langs->trans("BankName").'
'; $tooltip = $langs->trans("Example").':
CH93 0076 2011 6238 5295 7
LT12 1000 0111 0100 1000
FR14 2004 1010 0505 0001 3M02 606
LU28 0019 4006 4475 0000
DE89 3704 0044 0532 0130 00'; print $form->textwithpicto($langs->trans($ibankey), $tooltip, 1, 'help', '', 0, 3, 'iban'); print '
'; $tooltip = $langs->trans("Example").': LIABLT2XXXX'; print $form->textwithpicto($langs->trans($bickey), $tooltip, 1, 'help', '', 0, 3, 'bic'); print '
'.$langs->trans($val).'
'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'
'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'
'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'pti_in_ctti ? ' checked ' : '') . '>'; print '
'; print '
'; print ''; print ''; print ''; print ''; print '"; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BankAccountOwnerAddress").''; print '
'.$langs->trans("BankAccountOwnerZip").''; print '
'.$langs->trans("BankAccountOwnerTown").''; print '
'.$langs->trans("BankAccountOwnerCountry").''; print img_picto('', 'country', 'class="pictofixedwidth"'); print $form->select_country(GETPOSTISSET('owner_country_id') ? GETPOST('owner_country_id', 'alpha') : $object->owner_country_id, 'owner_country_id'); print '
'; } print dol_get_fiche_end(); print $form->buttonsSaveCancel("Modify"); print '
'; } } // End of page llxFooter(); $db->close();