dolibarr/htdocs/compta/bank/card.php

1128 lines
43 KiB
PHP
Raw Normal View History

<?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
2019-01-28 21:39:22 +01:00
* Copyright (C) 2014-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
2018-09-09 09:56:33 +02:00
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
2002-12-24 01:08:44 +01:00
*
* 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
2002-12-24 01:08:44 +01:00
* (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
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2002-12-24 01:08:44 +01:00
*/
/**
* \file htdocs/compta/bank/card.php
* \ingroup bank
2010-02-21 13:12:14 +01:00
* \brief Page to create/view a bank account
*/
2018-07-26 11:57:25 +02:00
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';
2021-02-23 21:09:01 +01:00
if (!empty($conf->categorie->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
}
if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
}
if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
}
if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
}
2013-06-05 16:24:32 +02:00
2018-05-27 09:40:17 +02:00
// Load translation files required by the page
$langs->loadLangs(array("banks", "bills", "categories", "companies", "compta"));
$action = GETPOST('action', 'aZ09');
2016-10-05 21:49:04 +02:00
$cancel = GETPOST('cancel', 'alpha');
2011-02-07 17:04:26 +01:00
2016-10-05 21:49:04 +02:00
$object = new Account($db);
2014-11-10 13:18:27 +01:00
$extrafields = new ExtraFields($db);
2014-11-10 13:18:27 +01:00
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
2016-10-05 21:49:04 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('bankcard', 'globalcard'));
2021-03-18 20:57:50 +01:00
// Security check
$id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha');
2022-04-05 18:19:06 +02:00
$fieldid = GETPOST("id", 'int') ? 'rowid' : 'ref';
2022-04-05 18:17:45 +02:00
2021-03-18 20:57:50 +01:00
$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
/*
* Actions
*/
2016-10-05 21:49:04 +02:00
2021-06-10 16:18:20 +02:00
$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');
2016-10-05 21:49:04 +02:00
2021-06-10 16:18:20 +02:00
if (empty($reshook)) {
2021-09-02 21:35:36 +02:00
$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__');
}
}
}
2021-06-10 16:18:20 +02:00
if ($cancel) {
2021-09-02 21:35:36 +02:00
if (!empty($backtopageforcancel)) {
header("Location: ".$backtopageforcancel);
exit;
} elseif (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
2021-06-10 16:18:20 +02:00
$action = '';
}
2017-06-07 16:44:04 +02:00
2021-06-10 16:18:20 +02:00
if ($action == 'add') {
$error = 0;
2016-10-05 21:49:04 +02:00
2021-06-10 16:18:20 +02:00
$db->begin();
2021-06-10 16:18:20 +02:00
// Create account
$object = new Account($db);
2021-06-10 16:18:20 +02:00
$object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha')));
$object->label = trim(GETPOST("label", 'alphanohtml'));
$object->courant = GETPOST("type");
$object->clos = GETPOST("clos");
$object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1);
$object->url = trim(GETPOST("url", 'alpha'));
2021-06-10 16:18:20 +02:00
$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->domiciliation = trim(GETPOST("domiciliation", "nohtml"));
$object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1;
2021-06-10 16:18:20 +02:00
$object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
$object->owner_address = trim(GETPOST("owner_address", 'nohtml'));
2021-06-10 16:18:20 +02:00
$object->ics = trim(GETPOST("ics", 'alpha'));
$object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha'));
2021-06-10 16:18:20 +02:00
$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 = GETPOST('fk_accountancy_journal', 'int');
if ($fk_accountancy_journal <= 0) {
$object->fk_accountancy_journal = '';
} else {
$object->fk_accountancy_journal = $fk_accountancy_journal;
}
2021-06-10 16:18:20 +02:00
$object->solde = price2num(GETPOST("solde"));
$object->date_solde = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST('reday', 'int'), GETPOST("reyear", 'int'));
2021-06-10 16:18:20 +02:00
$object->currency_code = trim(GETPOST("account_currency_code"));
2021-06-10 16:18:20 +02:00
$object->state_id = GETPOST("account_state_id", 'int');
$object->country_id = GETPOST("account_country_id", 'int');
2021-06-10 16:18:20 +02:00
$object->min_allowed = GETPOST("account_min_allowed", 'int');
$object->min_desired = GETPOST("account_min_desired", 'int');
$object->comment = trim(GETPOST("account_comment", 'restricthtml'));
2021-06-10 16:18:20 +02:00
$object->fk_user_author = $user->id;
if ($conf->global->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
2021-06-10 16:18:20 +02:00
$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++;
}
2021-06-10 16:18:20 +02:00
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
2002-12-24 01:08:44 +01:00
2021-06-10 16:18:20 +02:00
if (!$error) {
$id = $object->create($user);
if ($id > 0) {
// Category association
$categories = GETPOST('categories', 'array');
$object->setCategories($categories);
2021-06-10 16:18:20 +02:00
$_GET["id"] = $id; // Force chargement page en mode visu
$action = '';
} else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
$action = 'create'; // Force chargement page en mode creation
}
}
if (!$error) {
$db->commit();
} else {
$db->rollback();
}
2021-02-23 21:09:01 +01:00
}
2021-06-10 16:18:20 +02:00
if ($action == 'update') {
$error = 0;
// Update account
$object = new Account($db);
$object->fetch(GETPOST("id", 'int'));
$object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha')));
$object->label = trim(GETPOST("label", 'alphanohtml'));
$object->courant = GETPOST("type");
$object->clos = GETPOST("clos");
$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->domiciliation = trim(GETPOST("domiciliation", "nohtml"));
$object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1;
2021-06-10 16:18:20 +02:00
$object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
$object->owner_address = trim(GETPOST("owner_address", 'nohtml'));
$object->ics = trim(GETPOST("ics", 'alpha'));
$object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha'));
2021-08-04 13:12:07 +02:00
$account_number = GETPOST('account_number', 'alphanohtml');
2021-06-10 16:18:20 +02:00
if (empty($account_number) || $account_number == '-1') {
$object->account_number = '';
} else {
$object->account_number = $account_number;
}
$fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int');
if ($fk_accountancy_journal <= 0) {
$object->fk_accountancy_journal = '';
} else {
$object->fk_accountancy_journal = $fk_accountancy_journal;
}
2021-06-10 16:18:20 +02:00
$object->currency_code = trim(GETPOST("account_currency_code"));
2021-06-10 16:18:20 +02:00
$object->state_id = GETPOST("account_state_id", 'int');
$object->country_id = GETPOST("account_country_id", 'int');
2021-06-10 16:18:20 +02:00
$object->min_allowed = GETPOST("account_min_allowed", 'int');
$object->min_desired = GETPOST("account_min_desired", 'int');
$object->comment = trim(GETPOST("account_comment", 'restricthtml'));
if ($conf->global->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++;
}
2021-06-10 16:18:20 +02:00
$db->begin();
2019-08-18 18:56:21 +02:00
2021-06-10 16:18:20 +02:00
if (!$error) {
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
}
2021-06-10 16:18:20 +02:00
if (!$error) {
$result = $object->update($user);
if ($result >= 0) {
// Category association
$categories = GETPOST('categories', 'array');
$object->setCategories($categories);
2022-02-22 23:44:56 +01:00
$_GET["id"] = GETPOST("id", 'int'); // Force chargement page en mode visu
2021-06-10 16:18:20 +02:00
} else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
$action = 'edit'; // Force chargement page edition
}
}
2021-06-10 16:18:20 +02:00
if (!$error) {
$db->commit();
2020-05-21 15:05:19 +02:00
} else {
2021-06-10 16:18:20 +02:00
$db->rollback();
}
}
2019-08-18 18:56:21 +02:00
2021-06-10 16:18:20 +02:00
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->banque->configurer) {
// Delete
$object = new Account($db);
$object->fetch(GETPOST("id", "int"));
$result = $object->delete($user);
2002-12-24 01:08:44 +01:00
2021-06-10 16:18:20 +02:00
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
*/
2012-02-20 12:31:01 +01:00
$form = new Form($db);
$formbank = new FormBank($db);
$formcompany = new FormCompany($db);
2021-02-23 21:09:01 +01:00
if (!empty($conf->accounting->enabled)) {
$formaccounting = new FormAccounting($db);
}
2012-02-20 12:31:01 +01:00
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
$title = $langs->trans("FinancialAccount")." - ".$langs->trans("Card");
$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas|DE:Modul_Banken_und_Barbestände';
llxHeader("", $title, $help_url);
2002-12-24 01:08:44 +01:00
2012-02-20 12:31:01 +01:00
// Creation
2002-12-24 01:08:44 +01:00
2021-02-23 21:09:01 +01:00
if ($action == 'create') {
$object = new Account($db);
2020-04-09 16:36:39 +02:00
print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'bank_account');
2002-12-24 01:08:44 +01:00
2021-02-23 21:09:01 +01:00
if ($conf->use_javascript_ajax) {
print "\n".'<script type="text/javascript">';
print 'jQuery(document).ready(function () {
2022-02-10 09:54:09 +01:00
jQuery("#type").change(function() {
document.formsoc.action.value="create";
document.formsoc.submit();
});
2010-08-29 18:47:17 +02:00
jQuery("#selectaccount_country_id").change(function() {
document.formsoc.action.value="create";
document.formsoc.submit();
});
})';
print '</script>'."\n";
}
2010-08-29 18:47:17 +02:00
print '<form action="'.$_SERVER["PHP_SELF"].'" name="formsoc" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="clos" value="0">';
2002-12-24 01:08:44 +01:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head('');
2021-05-20 21:25:36 +02:00
print '<table class="border centpercent tableforfieldcreate">';
// Ref
2016-04-08 03:40:23 +02:00
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
print '<td><input size="8" type="text" class="flat" name="ref" value="'.dol_escape_htmltag(GETPOSTISSET('ref') ? GETPOST("ref", 'alpha') : $object->ref).'" maxlength="12" autofocus></td></tr>';
// Label
print '<tr><td class="fieldrequired">'.$langs->trans("LabelBankCashAccount").'</td>';
print '<td><input type="text" class="flat maxwidth150onsmartphone" name="label" value="'.dol_escape_htmltag(GETPOST('label', 'alpha')).'"></td></tr>';
// Type
print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
2017-06-07 16:44:04 +02:00
print '<td>';
2022-02-14 09:08:58 +01:00
$formbank->selectTypeOfBankAccount(GETPOSTISSET("type") ? GETPOST('type', 'int') : Account::TYPE_CURRENT, 'type');
print '</td></tr>';
2002-12-24 01:08:44 +01:00
// Currency
print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
2017-06-07 16:44:04 +02:00
print '<td>';
$selectedcode = $object->currency_code;
2021-02-23 21:09:01 +01:00
if (!$selectedcode) {
$selectedcode = $conf->currency;
}
2020-11-30 14:47:07 +01:00
print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code');
//print $langs->trans("Currency".$conf->currency);
//print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
print '</td></tr>';
// Status
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
print '<td>';
print $form->selectarray("clos", $object->status, (GETPOST('clos', 'int') != '' ? GETPOST('clos', 'int') : $object->clos), 0, 0, 0, '', 0, 0, 0, '', 'maxwidth150onsmartphone');
print '</td></tr>';
// Country
$selectedcode = '';
2020-11-30 14:47:07 +01:00
if (GETPOSTISSET("account_country_id")) {
$selectedcode = GETPOST("account_country_id") ? GETPOST("account_country_id") : $object->country_code;
2021-02-23 21:09:01 +01:00
} 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 '<tr><td class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>';
2017-06-07 16:44:04 +02:00
print '<td>';
2021-04-15 15:30:02 +02:00
print img_picto('', 'country', 'class="pictofixedwidth"').$form->select_country($selectedcode, 'account_country_id');
2021-02-23 21:09:01 +01:00
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>';
// State
2017-06-07 16:44:04 +02:00
print '<tr><td>'.$langs->trans('State').'</td><td>';
2021-02-23 21:09:01 +01:00
if ($selectedcode) {
2021-07-04 19:23:04 +02:00
print img_picto('', 'state', 'class="pictofixedwidth"');
print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : '', $selectedcode, 'account_state_id');
2020-05-21 15:05:19 +02:00
} else {
print $countrynotdefined;
}
print '</td></tr>';
// Web
print '<tr><td>'.$langs->trans("Web").'</td>';
2021-07-04 19:23:04 +02:00
print '<td>';
print img_picto('', 'globe', 'class="pictofixedwidth"');
2021-11-28 23:51:20 +01:00
print '<input class="minwidth300 widthcentpercentminusx maxwidth500" type="text" class="flat" name="url" value="'.GETPOST("url").'">';
2021-07-04 19:23:04 +02:00
print '</td></tr>';
// Tags-Categories
2021-02-23 21:09:01 +01:00
if ($conf->categorie->enabled) {
2019-12-04 16:43:56 +01:00
print '<tr><td>'.$langs->trans("Categories").'</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
2019-10-23 14:59:02 +02:00
$arrayselected = array();
$c = new Categorie($db);
$cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT);
2021-02-23 21:09:01 +01:00
if (is_array($cats)) {
foreach ($cats as $cat) {
2019-10-23 14:59:02 +02:00
$arrayselected[] = $cat->id;
}
}
2020-12-03 14:34:15 +01:00
print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
print "</td></tr>";
}
// Comment
2019-12-04 16:43:56 +01:00
print '<tr><td>'.$langs->trans("Comment").'</td>';
2017-06-07 16:44:04 +02:00
print '<td>';
// 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, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%');
$doleditor->Create();
print '</td></tr>';
2019-08-18 18:56:21 +02:00
// 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;
2021-02-23 21:09:01 +01:00
if (empty($reshook)) {
2021-10-08 15:58:08 +02:00
print $object->showOptionals($extrafields, 'create', $parameters);
2014-11-10 13:18:27 +01:00
}
2014-09-04 04:22:43 +02:00
print '</table>';
2014-09-04 04:22:43 +02:00
print '<br>';
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">';
2014-09-04 04:22:43 +02:00
// Sold
2016-04-08 03:40:23 +02:00
print '<tr><td class="titlefieldcreate">'.$langs->trans("InitialBankBalance").'</td>';
print '<td><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde") ?GETPOST("solde") : price2num($object->solde)).'"></td></tr>';
2002-12-24 01:08:44 +01:00
print '<tr><td>'.$langs->trans("Date").'</td>';
2017-06-07 16:44:04 +02:00
print '<td>';
2018-09-09 09:56:33 +02:00
print $form->selectDate('', 're', 0, 0, 0, 'formsoc');
print '</td></tr>';
print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(GETPOST("account_min_allowed") ?GETPOST("account_min_allowed") : $object->min_allowed).'"></td></tr>';
print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
print '<td><input size="12" type="text" class="flat" name="account_min_desired" value="'.(GETPOST("account_min_desired") ?GETPOST("account_min_desired") : $object->min_desired).'"></td></tr>';
print '</table>';
print '<br>';
2014-08-01 14:26:13 +02:00
2022-02-14 09:08:58 +01:00
$type = (GETPOSTISSET("type") ? GETPOST('type', 'int') : Account::TYPE_CURRENT); // add default value
2021-03-25 16:59:47 +01:00
if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">';
// If bank account
2016-04-08 03:40:23 +02:00
print '<tr><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
2019-12-04 16:43:56 +01:00
print '<td><input type="text" class="flat minwidth150" name="bank" value="'.(GETPOST('bank') ?GETPOST('bank', 'alpha') : $object->bank).'"></td>';
print '</tr>';
// Show fields of bank account
2019-12-04 16:43:56 +01:00
$sizecss = '';
2016-10-05 21:49:04 +02:00
foreach ($object->getFieldsToShow() as $val) {
if ($val == 'BankCode') {
$name = 'code_banque';
2019-12-04 16:43:56 +01:00
$sizecss = 'minwidth100';
2016-10-05 21:49:04 +02:00
$content = $object->code_banque;
} elseif ($val == 'DeskCode') {
$name = 'code_guichet';
2019-12-04 16:43:56 +01:00
$sizecss = 'minwidth100';
2016-10-05 21:49:04 +02:00
$content = $object->code_guichet;
} elseif ($val == 'BankAccountNumber') {
$name = 'number';
$sizecss = 'minwidth200';
2016-10-05 21:49:04 +02:00
$content = $object->number;
} elseif ($val == 'BankAccountNumberKey') {
$name = 'cle_rib';
$sizecss = 'minwidth50';
2016-10-05 21:49:04 +02:00
$content = $object->cle_rib;
}
print '<td>'.$langs->trans($val).'</td>';
2019-12-04 16:43:56 +01:00
print '<td><input type="text" class="flat '.$sizecss.'" name="'.$name.'" value="'.(GETPOST($name) ?GETPOST($name, 'alpha') : $content).'"></td>';
print '</tr>';
}
2016-10-05 21:49:04 +02:00
$ibankey = FormBank::getIBANLabel($object);
$bickey = "BICNumber";
2021-02-23 21:09:01 +01:00
if ($object->getCountryCode() == 'IN') {
$bickey = "SWIFT";
}
// IBAN
print '<tr><td>'.$langs->trans($ibankey).'</td>';
2019-12-04 16:43:56 +01:00
print '<td><input maxlength="34" type="text" class="flat minwidth300" name="iban" value="'.(GETPOST('iban') ?GETPOST('iban', 'alpha') : $object->iban).'"></td></tr>';
print '<tr><td>'.$langs->trans($bickey).'</td>';
2019-12-04 16:43:56 +01:00
print '<td><input maxlength="11" type="text" class="flat minwidth150" name="bic" value="'.(GETPOST('bic') ?GETPOST('bic', 'alpha') : $object->bic).'"></td></tr>';
if ($conf->paymentbybanktransfer->enabled) {
print '<tr><td>'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").'</td>';
print '<td><input type="checkbox" class="flat minwidth150" name="pti_in_ctti"'. (empty(GETPOST('pti_in_ctti')) ? '' : ' checked ') . '>&nbsp;';
print img_picto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp"), 'info');
print '</td></tr>';
}
2017-06-07 16:44:04 +02:00
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
2019-12-04 16:43:56 +01:00
print '<textarea class="flat quatrevingtpercent" name="domiciliation" rows="'.ROWS_2.'">';
print (GETPOST('domiciliation') ?GETPOST('domiciliation') : $object->domiciliation);
print "</textarea></td></tr>";
print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
2019-12-04 16:43:56 +01:00
print '<td><input type="text" class="flat minwidth300" name="proprio" value="'.(GETPOST('proprio') ?GETPOST('proprio', 'alpha') : $object->proprio).'">';
print '</td></tr>';
2017-06-07 16:44:04 +02:00
print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
2019-12-04 16:43:56 +01:00
print '<textarea class="flat quatrevingtpercent" name="owner_address" rows="'.ROWS_2.'">';
print (GETPOST('owner_address') ?GETPOST('owner_address', 'alpha') : $object->owner_address);
print "</textarea></td></tr>";
print '</table>';
print '<br>';
}
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">';
// Accountancy code
$fieldrequired = '';
2021-02-23 21:09:01 +01:00
if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
$fieldrequired = 'fieldrequired ';
}
2017-06-07 16:44:04 +02:00
2021-02-23 21:09:01 +01:00
if (!empty($conf->accounting->enabled)) {
print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
print '<td>';
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
print '</td></tr>';
2020-05-21 15:05:19 +02:00
} else {
print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
print '<td><input type="text" name="account_number" value="'.(GETPOST("account_number") ?GETPOST('account_number', 'alpha') : $object->account_number).'"></td></tr>';
}
2014-08-01 14:26:13 +02:00
// Accountancy journal
2021-02-23 21:09:01 +01:00
if (!empty($conf->accounting->enabled)) {
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<td>';
2017-06-15 20:27:40 +02:00
print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
2017-05-06 08:06:01 +02:00
print '</td></tr>';
}
2014-08-01 14:26:13 +02:00
print '</table>';
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
print $form->buttonsSaveCancel("CreateAccount");
2011-09-15 00:51:11 +02:00
print '</form>';
2020-05-23 21:14:44 +02:00
} else {
/* ************************************************************************** */
/* */
/* Visu et edition */
/* */
/* ************************************************************************** */
2021-03-30 03:55:17 +02:00
if ((GETPOST("id", 'int') || GETPOST("ref")) && $action != 'edit') {
2016-10-05 21:49:04 +02:00
$object = new Account($db);
2021-03-30 03:55:17 +02:00
if (GETPOST("id", 'int')) {
$object->fetch(GETPOST("id", 'int'));
2007-11-05 23:37:41 +01:00
}
2021-03-30 03:55:17 +02:00
if (GETPOST("ref")) {
$object->fetch(0, GETPOST("ref"));
$_GET["id"] = $object->id;
2007-11-05 23:37:41 +01:00
}
2017-08-27 12:06:46 +02:00
// Show tabs
$head = bank_prepare_head($object);
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account');
2016-10-05 21:49:04 +02:00
$formconfirm = '';
2017-06-07 16:44:04 +02:00
2016-10-05 21:49:04 +02:00
// Confirmation to delete
2021-02-23 21:09:01 +01:00
if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteAccount"), $langs->trans("ConfirmDeleteAccount"), "confirm_delete");
}
2016-10-05 21:49:04 +02:00
// Print form confirm
print $formconfirm;
2017-06-07 16:44:04 +02:00
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
2017-06-07 16:44:04 +02:00
$morehtmlref = '';
2016-10-05 21:49:04 +02:00
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
2017-06-07 16:44:04 +02:00
2016-10-05 21:49:04 +02:00
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
2017-06-07 16:44:04 +02:00
2019-01-17 19:31:01 +01:00
print '<table class="border tableforfield" width="100%">';
// Type
2016-11-27 20:02:57 +01:00
print '<tr><td class="titlefield">'.$langs->trans("AccountType").'</td>';
2016-10-05 21:49:04 +02:00
print '<td>'.$object->type_lib[$object->type].'</td></tr>';
// Currency
print '<tr><td>'.$langs->trans("Currency").'</td>';
2016-10-05 21:49:04 +02:00
print '<td>';
$selectedcode = $object->currency_code;
2021-02-23 21:09:01 +01:00
if (!$selectedcode) {
$selectedcode = $conf->currency;
}
print $langs->trans("Currency".$selectedcode);
print '</td></tr>';
// Conciliate
print '<tr><td>'.$langs->trans("Conciliable").'</td>';
2016-10-05 21:49:04 +02:00
print '<td>';
$conciliate = $object->canBeConciliated();
2021-02-23 21:09:01 +01:00
if ($conciliate == -2) {
print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("CashAccount").')</span>';
} elseif ($conciliate == -3) {
print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("Closed").')</span>';
} else {
print ($object->rappro == 1 ? $langs->trans("Yes") : ($langs->trans("No").' <span class="opacitymedium">('.$langs->trans("ConciliationDisabled").')</span>'));
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
2016-10-05 21:49:04 +02:00
print '<td>'.$object->min_allowed.'</td></tr>';
print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
2016-10-05 21:49:04 +02:00
print '<td>'.$object->min_desired.'</td></tr>';
2016-10-05 21:49:04 +02:00
// Accountancy code
print '<tr class="liste_titre_add"><td class="titlefield">'.$langs->trans("AccountancyCode").'</td>';
print '<td>';
if (!empty($conf->accounting->enabled)) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('', $object->account_number, 1);
print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
2016-10-05 21:49:04 +02:00
} else {
print $object->account_number;
2016-10-05 21:49:04 +02:00
}
print '</td></tr>';
2017-06-07 16:44:04 +02:00
2016-10-05 21:49:04 +02:00
// Accountancy journal
2021-02-23 21:09:01 +01:00
if (!empty($conf->accounting->enabled)) {
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<td>';
2017-06-07 16:44:04 +02:00
2019-08-18 18:56:21 +02:00
if ($object->fk_accountancy_journal > 0) {
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($object->fk_accountancy_journal);
2017-06-07 16:44:04 +02:00
2019-08-18 18:56:21 +02:00
print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
}
2017-05-06 08:33:12 +02:00
print '</td></tr>';
2016-10-05 21:49:04 +02:00
}
2017-06-07 16:44:04 +02:00
// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
2017-06-07 16:44:04 +02:00
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="underbanner clearboth"></div>';
2019-01-17 19:31:01 +01:00
print '<table class="border tableforfield centpercent">';
2017-06-07 16:44:04 +02:00
// Categories
if ($conf->categorie->enabled) {
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
2019-11-14 08:15:39 +01:00
print $form->showCategories($object->id, Categorie::TYPE_ACCOUNT, 1);
print "</td></tr>";
}
2016-11-27 20:02:57 +01:00
print '<tr><td class="tdtop titlefield">'.$langs->trans("Comment").'</td>';
print '<td>'.dol_htmlentitiesbr($object->comment).'</td></tr>';
2016-10-05 21:49:04 +02:00
print '</table>';
2021-02-23 21:09:01 +01:00
if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) {
2022-04-05 18:20:45 +02:00
//print '<div class="underbanner clearboth"></div>';
2017-06-07 16:44:04 +02:00
2019-01-17 19:31:01 +01:00
print '<table class="border tableforfield centpercent">';
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("BankName").'</td>';
2016-10-05 21:49:04 +02:00
print '<td>'.$object->bank.'</td></tr>';
// Show fields of bank account
2016-10-05 21:49:04 +02:00
foreach ($object->getFieldsToShow() as $val) {
if ($val == 'BankCode') {
2016-10-05 21:49:04 +02:00
$content = $object->code_banque;
} elseif ($val == 'DeskCode') {
2016-10-05 21:49:04 +02:00
$content = $object->code_guichet;
} elseif ($val == 'BankAccountNumber') {
2016-10-05 21:49:04 +02:00
$content = $object->number;
} elseif ($val == 'BankAccountNumberKey') {
2016-10-05 21:49:04 +02:00
$content = $object->cle_rib;
}
print '<tr><td>'.$langs->trans($val).'</td>';
2017-06-07 16:44:04 +02:00
print '<td>'.$content.'</td>';
print '</tr>';
}
2016-10-05 21:49:04 +02:00
$ibankey = FormBank::getIBANLabel($object);
$bickey = "BICNumber";
2021-02-23 21:09:01 +01:00
if ($object->getCountryCode() == 'IN') {
$bickey = "SWIFT";
}
print '<tr><td>'.$langs->trans($ibankey).'</td>';
2016-10-05 21:49:04 +02:00
print '<td>'.$object->iban.'&nbsp;';
if (!empty($object->iban)) {
if (!checkIbanForAccount($object)) {
print img_picto($langs->trans("IbanNotValid"), 'warning');
} else {
print img_picto($langs->trans("IbanValid"), 'info');
}
}
print '</td></tr>';
print '<tr><td>'.$langs->trans($bickey).'</td>';
2016-10-05 21:49:04 +02:00
print '<td>'.$object->bic.'&nbsp;';
if (!empty($object->bic)) {
if (!checkSwiftForAccount($object)) {
print img_picto($langs->trans("SwiftNotValid"), 'warning');
} else {
print img_picto($langs->trans("SwiftValid"), 'info');
}
}
print '</td></tr>';
2020-12-31 10:49:27 +01:00
2021-02-23 21:09:01 +01:00
if ($conf->prelevement->enabled) {
print '<tr><td>'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'</td>';
print '<td>'.$object->ics.'</td>';
print '</tr>';
}
2020-12-31 10:49:27 +01:00
// TODO ICS is not used with bank transfer !
2021-02-23 21:09:01 +01:00
if ($conf->paymentbybanktransfer->enabled) {
print '<tr><td>'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'</td>';
print '<td>'.$object->ics_transfer.'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").'</td><td>';
print (empty($object->pti_in_ctti) ? $langs->trans("No") : $langs->trans("Yes")) . '&nbsp;';
print img_picto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp"), 'info');
print "</td></tr>\n";
}
2016-10-05 21:49:04 +02:00
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
print nl2br($object->domiciliation);
print "</td></tr>\n";
2016-10-05 21:49:04 +02:00
print '<tr><td>'.$langs->trans("BankAccountOwner").'</td><td>';
print $object->proprio;
print "</td></tr>\n";
2016-10-05 21:49:04 +02:00
print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
print nl2br($object->owner_address);
print "</td></tr>\n";
print '</table>';
2016-04-23 08:09:38 +02:00
}
2014-08-01 14:26:13 +02:00
2016-10-05 21:49:04 +02:00
print '</div>';
print '</div>';
2016-10-05 21:49:04 +02:00
print '<div class="clearboth"></div>';
2017-06-07 16:44:04 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
/*
2021-03-16 04:22:55 +01:00
* Action bar
2011-02-07 17:04:26 +01:00
*/
print '<div class="tabsAction">';
2021-02-23 21:09:01 +01:00
if ($user->rights->banque->configurer) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Modify").'</a>';
}
$canbedeleted = $object->can_be_deleted(); // Renvoi vrai si compte sans mouvements
2021-02-23 21:09:01 +01:00
if ($user->rights->banque->configurer && $canbedeleted) {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Delete").'</a>';
}
print '</div>';
}
/* ************************************************************************** */
/* */
/* Edition */
/* */
/* ************************************************************************** */
2021-02-23 21:09:01 +01:00
if (GETPOST('id', 'int') && $action == 'edit' && $user->rights->banque->configurer) {
$object = new Account($db);
$object->fetch(GETPOST('id', 'int'));
2020-04-09 16:36:39 +02:00
print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'bank_account');
2021-02-23 21:09:01 +01:00
if ($conf->use_javascript_ajax) {
print "\n".'<script type="text/javascript">';
print 'jQuery(document).ready(function () {
jQuery("#type").change(function() {
2015-03-03 06:20:09 +01:00
document.formsoc.action.value="edit";
document.formsoc.submit();
});
})'."\n";
2015-03-03 06:20:09 +01:00
print 'jQuery(document).ready(function () {
2010-08-29 18:47:17 +02:00
jQuery("#selectaccount_country_id").change(function() {
document.formsoc.action.value="edit";
document.formsoc.submit();
});
})';
print '</script>'."\n";
}
2010-08-29 18:47:17 +02:00
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formsoc">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
2021-05-17 07:27:02 +02:00
print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">'."\n\n";
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head(array(), 0, '', 0);
2018-04-09 11:42:43 +02:00
//print '<div class="underbanner clearboth"></div>';
2017-06-07 16:44:04 +02:00
2021-05-20 21:25:36 +02:00
print '<table class="border centpercent tableforfieldcreate">';
// Ref
2016-04-08 03:40:23 +02:00
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
print '<td><input type="text" class="flat maxwidth200" name="ref" value="'.dol_escape_htmltag(GETPOSTISSET('ref') ? GETPOST('ref', 'alpha') : $object->ref).'"></td></tr>';
// Label
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
print '<td><input type="text" class="flat minwidth300" name="label" value="'.dol_escape_htmltag(GETPOSTISSET('label') ? GETPOST('label', 'alpha') : $object->label).'"></td></tr>';
// Type
print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
print '<td class="maxwidth200onsmartphone">';
2022-02-14 09:08:58 +01:00
$formbank->selectTypeOfBankAccount((GETPOSTISSET('type') ? GETPOST('type', 'int') : $object->type), 'type');
print '</td></tr>';
// Currency
print '<tr><td class="fieldrequired">'.$langs->trans("Currency");
2016-10-05 21:49:04 +02:00
print '<input type="hidden" value="'.$object->currency_code.'">';
print '</td>';
2016-11-11 23:47:56 +01:00
print '<td class="maxwidth200onsmartphone">';
$selectedcode = $object->currency_code;
2021-02-23 21:09:01 +01:00
if (!$selectedcode) {
$selectedcode = $conf->currency;
}
2021-07-04 19:23:04 +02:00
print img_picto('', 'multicurrency', 'class="pictofixedwidth"');
2020-11-30 14:47:07 +01:00
print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code');
//print $langs->trans("Currency".$conf->currency);
//print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
print '</td></tr>';
// Status
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
print '<td class="maxwidth200onsmartphone">';
print $form->selectarray("clos", $object->status, (GETPOSTISSET("clos") ? GETPOST("clos", "int") : $object->clos));
print '</td></tr>';
// Country
$object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id;
$selectedcode = $object->country_code;
2021-02-23 21:09:01 +01:00
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 '<tr><td class="fieldrequired">'.$langs->trans("Country").'</td>';
2016-11-11 23:47:56 +01:00
print '<td class="maxwidth200onsmartphone">';
2021-04-15 15:30:02 +02:00
print img_picto('', 'country', 'class="pictofixedwidth"').$form->select_country($selectedcode, 'account_country_id');
2021-02-23 21:09:01 +01:00
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>';
// State
2016-11-11 23:47:56 +01:00
print '<tr><td>'.$langs->trans('State').'</td><td class="maxwidth200onsmartphone">';
2021-02-23 21:09:01 +01:00
if ($selectedcode) {
2021-07-04 19:23:04 +02:00
print img_picto('', 'state', 'class="pictofixedwidth"');
2020-11-30 14:47:07 +01:00
print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : $object->state_id, $selectedcode, 'account_state_id');
2020-05-21 15:05:19 +02:00
} else {
print $countrynotdefined;
}
print '</td></tr>';
2011-02-07 17:04:26 +01:00
// Conciliable
print '<tr><td>'.$langs->trans("Conciliable").'</td>';
print '<td>';
$conciliate = $object->canBeConciliated();
2021-02-23 21:09:01 +01:00
if ($conciliate == -2) {
print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
} elseif ($conciliate == -3) {
print $langs->trans("No").' ('.$langs->trans("Closed").')';
} else {
2021-03-16 19:09:56 +01:00
print '<input type="checkbox" class="flat" id="norappro" name="norappro"'.(($conciliate > 0) ? '' : ' checked="checked"').'"> <label for="norappro">'.$langs->trans("DisableConciliation").'</label>';
2021-02-23 21:09:01 +01:00
}
print '</td></tr>';
// Balance
print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
2020-11-30 14:47:07 +01:00
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>';
print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
2020-11-30 14:47:07 +01:00
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>';
// Web
print '<tr><td>'.$langs->trans("Web").'</td>';
2021-07-04 19:23:04 +02:00
print '<td>';
print img_picto('', 'globe', 'class="pictofixedwidth"');
print '<input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(GETPOSTISSET("url") ? GETPOST("url") : $object->url).'">';
print '</td></tr>';
// Tags-Categories
2021-02-23 21:09:01 +01:00
if ($conf->categorie->enabled) {
2021-05-20 21:25:36 +02:00
print '<tr><td>'.$langs->trans("Categories").'</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
$c = new Categorie($db);
$cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT);
2021-02-23 21:09:01 +01:00
if (is_array($cats)) {
foreach ($cats as $cat) {
2019-11-08 15:52:57 +01:00
$arrayselected[] = $cat->id;
}
}
2020-12-03 14:34:15 +01:00
print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
print "</td></tr>";
}
// Comment
print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
2016-10-17 00:21:39 +02:00
print '<td>';
// 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, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%');
$doleditor->Create();
print '</td></tr>';
2014-11-10 13:18:27 +01:00
// 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;
2021-02-23 21:09:01 +01:00
if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit', $parameters);
2014-11-10 13:18:27 +01:00
}
2017-06-07 16:44:04 +02:00
2014-09-04 04:22:43 +02:00
print '</table>';
print '<br>';
2016-10-17 00:21:39 +02:00
2017-03-28 18:42:23 +02:00
//print '<div class="underbanner clearboth"></div>';
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">';
2016-10-17 00:21:39 +02:00
// Accountancy code
$tdextra = ' class="titlefieldcreate"';
2016-10-17 00:21:39 +02:00
if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
$tdextra = ' class="fieldrequired titlefieldcreate"';
2016-10-17 00:21:39 +02:00
}
2016-10-17 00:21:39 +02:00
print '<tr class="liste_titre_add"><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
print '<td>';
if (!empty($conf->accounting->enabled)) {
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
2016-10-17 00:21:39 +02:00
} else {
print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
2016-10-17 00:21:39 +02:00
}
print '</td></tr>';
2016-10-17 00:21:39 +02:00
// Accountancy journal
2021-02-23 21:09:01 +01:00
if (!empty($conf->accounting->enabled)) {
2017-12-03 12:21:38 +01:00
print '<tr><td class="fieldrequired">'.$langs->trans("AccountancyJournal").'</td>';
2017-05-06 08:06:01 +02:00
print '<td>';
2017-06-15 20:27:40 +02:00
print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
2017-05-06 08:06:01 +02:00
print '</td></tr>';
2016-10-17 00:21:39 +02:00
}
2016-10-17 00:21:39 +02:00
print '</table>';
2022-02-14 09:08:58 +01:00
$type = (GETPOSTISSET('type') ? GETPOST('type', 'int') : $object->type); // add default current value
if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
print '<br>';
//print '<div class="underbanner clearboth"></div>';
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">';
// If bank account
2016-09-18 21:13:23 +02:00
print '<tr class="liste_titre_add"><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
2016-10-17 00:21:39 +02:00
print '<td><input size="30" type="text" class="flat" name="bank" value="'.$object->bank.'"></td>';
print '</tr>';
// Show fields of bank account
2016-10-05 21:49:04 +02:00
foreach ($object->getFieldsToShow() as $val) {
if ($val == 'BankCode') {
$name = 'code_banque';
$size = 8;
2016-10-05 21:49:04 +02:00
$content = $object->code_banque;
} elseif ($val == 'DeskCode') {
$name = 'code_guichet';
$size = 8;
2016-10-05 21:49:04 +02:00
$content = $object->code_guichet;
} elseif ($val == 'BankAccountNumber') {
$name = 'number';
$size = 18;
2016-10-05 21:49:04 +02:00
$content = $object->number;
} elseif ($val == 'BankAccountNumberKey') {
$name = 'cle_rib';
$size = 3;
2016-10-05 21:49:04 +02:00
$content = $object->cle_rib;
}
print '<tr><td>'.$langs->trans($val).'</td>';
print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
print '</tr>';
}
2016-10-05 21:49:04 +02:00
$ibankey = FormBank::getIBANLabel($object);
$bickey = "BICNumber";
2021-02-23 21:09:01 +01:00
if ($object->getCountryCode() == 'IN') {
$bickey = "SWIFT";
}
// IBAN
print '<tr><td>'.$langs->trans($ibankey).'</td>';
2022-01-07 14:28:58 +01:00
print '<td><input class="minwidth300 maxwidth200onsmartphone" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOSTISSET('iban') ? GETPOST('iban', 'alphanohtml') : $object->iban).'"></td></tr>';
print '<tr><td>'.$langs->trans($bickey).'</td>';
2022-01-07 14:28:58 +01:00
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOSTISSET('bic') ? GETPOST('bic', 'alphanohtml') : $object->bic).'"></td></tr>';
2020-12-31 10:49:27 +01:00
2021-02-23 21:09:01 +01:00
if ($conf->prelevement->enabled) {
print '<tr><td>'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'</td>';
2022-01-07 14:28:58 +01:00
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics" value="'.(GETPOSTISSET('ics') ? GETPOST('ics', 'alphanohtml') : $object->ics).'"></td></tr>';
}
2020-12-31 10:49:27 +01:00
2021-02-23 21:09:01 +01:00
if ($conf->paymentbybanktransfer->enabled) {
print '<tr><td>'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'</td>';
2022-01-07 14:28:58 +01:00
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>';
2020-12-31 10:49:27 +01:00
print '<tr><td>'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").'</td>';
print '<td><input type="checkbox" class="flat minwidth150" name="pti_in_ctti"'. ($object->pti_in_ctti ? ' checked ' : '') . '>&nbsp;';
print img_picto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp"), 'info');
print '</td></tr>';
}
2016-10-17 00:21:39 +02:00
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
2016-11-11 23:47:56 +01:00
print '<textarea class="flat quatrevingtpercent" name="domiciliation" rows="'.ROWS_2.'">';
2016-10-05 21:49:04 +02:00
print $object->domiciliation;
print "</textarea></td></tr>";
print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
2016-11-11 23:47:56 +01:00
print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="proprio" value="'.$object->proprio.'"></td>';
2016-10-17 00:21:39 +02:00
print '</tr>';
2016-10-17 00:21:39 +02:00
print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
2016-11-11 23:47:56 +01:00
print '<textarea class="flat quatrevingtpercent" name="owner_address" rows="'.ROWS_2.'">';
2016-10-05 21:49:04 +02:00
print $object->owner_address;
print "</textarea></td></tr>";
print '</table>';
}
2016-03-19 20:40:46 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
print $form->buttonsSaveCancel("Modify");
2005-10-25 21:32:04 +02:00
2014-09-04 04:22:43 +02:00
print '</form>';
2002-12-24 01:08:44 +01:00
}
}
2018-07-29 19:16:28 +02:00
// End of page
llxFooter();
$db->close();