card.php 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. <?php
  2. /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2014-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
  7. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  8. * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
  9. * Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
  10. * Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/compta/bank/card.php
  27. * \ingroup bank
  28. * \brief Page to create/view a bank account
  29. */
  30. // Load Dolibarr environment
  31. require '../../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  38. if (isModEnabled('categorie')) {
  39. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  40. }
  41. if (isModEnabled('accounting')) {
  42. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
  43. }
  44. if (isModEnabled('accounting')) {
  45. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
  46. }
  47. if (isModEnabled('accounting')) {
  48. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
  49. }
  50. // Load translation files required by the page
  51. $langs->loadLangs(array("banks", "bills", "categories", "companies", "compta"));
  52. $action = GETPOST('action', 'aZ09');
  53. $cancel = GETPOST('cancel', 'alpha');
  54. $object = new Account($db);
  55. $extrafields = new ExtraFields($db);
  56. // fetch optionals attributes and labels
  57. $extrafields->fetch_name_optionals_label($object->table_element);
  58. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  59. $hookmanager->initHooks(array('bankcard', 'globalcard'));
  60. // Security check
  61. $id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha');
  62. $fieldid = GETPOST("id", 'int') ? 'rowid' : 'ref';
  63. if (GETPOST("id", 'int') || GETPOST("ref")) {
  64. if (GETPOST("id", 'int')) {
  65. $object->fetch(GETPOST("id", 'int'));
  66. }
  67. if (GETPOST("ref")) {
  68. $object->fetch(0, GETPOST("ref"));
  69. }
  70. }
  71. $result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
  72. /*
  73. * Actions
  74. */
  75. $parameters = array();
  76. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  77. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  78. if (empty($reshook)) {
  79. $backurlforlist = DOL_URL_ROOT.'/compta/bank/list.php';
  80. if (empty($backtopage) || ($cancel && empty($id))) {
  81. if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
  82. if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
  83. $backtopage = $backurlforlist;
  84. } else {
  85. $backtopage = DOL_URL_ROOT.'/compta/bank/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
  86. }
  87. }
  88. }
  89. if ($cancel) {
  90. if (!empty($backtopageforcancel)) {
  91. header("Location: ".$backtopageforcancel);
  92. exit;
  93. } elseif (!empty($backtopage)) {
  94. header("Location: ".$backtopage);
  95. exit;
  96. }
  97. $action = '';
  98. }
  99. if ($action == 'add') {
  100. $error = 0;
  101. $db->begin();
  102. // Create account
  103. $object = new Account($db);
  104. $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha')));
  105. $object->label = trim(GETPOST("label", 'alphanohtml'));
  106. $object->courant = GETPOST("type");
  107. $object->clos = GETPOST("clos");
  108. $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1);
  109. $object->url = trim(GETPOST("url", 'alpha'));
  110. $object->bank = trim(GETPOST("bank"));
  111. $object->code_banque = trim(GETPOST("code_banque"));
  112. $object->code_guichet = trim(GETPOST("code_guichet"));
  113. $object->number = trim(GETPOST("number"));
  114. $object->cle_rib = trim(GETPOST("cle_rib"));
  115. $object->bic = trim(GETPOST("bic"));
  116. $object->iban = trim(GETPOST("iban"));
  117. $object->domiciliation = trim(GETPOST("domiciliation", "alphanohtml"));
  118. $object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1;
  119. $object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
  120. $object->owner_address = trim(GETPOST("owner_address", 'alphanohtml'));
  121. $object->ics = trim(GETPOST("ics", 'alpha'));
  122. $object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha'));
  123. $account_number = GETPOST('account_number', 'alphanohtml');
  124. if (empty($account_number) || $account_number == '-1') {
  125. $object->account_number = '';
  126. } else {
  127. $object->account_number = $account_number;
  128. }
  129. $fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int');
  130. if ($fk_accountancy_journal <= 0) {
  131. $object->fk_accountancy_journal = '';
  132. } else {
  133. $object->fk_accountancy_journal = $fk_accountancy_journal;
  134. }
  135. $object->solde = price2num(GETPOST("solde"));
  136. $object->date_solde = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST('reday', 'int'), GETPOST("reyear", 'int'));
  137. $object->currency_code = trim(GETPOST("account_currency_code"));
  138. $object->state_id = GETPOST("account_state_id", 'int');
  139. $object->country_id = GETPOST("account_country_id", 'int');
  140. $object->min_allowed = GETPOST("account_min_allowed", 'int');
  141. $object->min_desired = GETPOST("account_min_desired", 'int');
  142. $object->comment = trim(GETPOST("account_comment", 'restricthtml'));
  143. $object->fk_user_author = $user->id;
  144. if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) {
  145. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
  146. $action = 'create'; // Force chargement page en mode creation
  147. $error++;
  148. }
  149. if (empty($object->ref)) {
  150. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
  151. $action = 'create'; // Force chargement page en mode creation
  152. $error++;
  153. }
  154. if (empty($object->label)) {
  155. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
  156. $action = 'create'; // Force chargement page en mode creation
  157. $error++;
  158. }
  159. // Fill array 'array_options' with data from add form
  160. $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
  161. if (!$error) {
  162. $id = $object->create($user);
  163. if ($id > 0) {
  164. // Category association
  165. $categories = GETPOST('categories', 'array');
  166. $object->setCategories($categories);
  167. $_GET["id"] = $id; // Force chargement page en mode visu
  168. $action = '';
  169. } else {
  170. $error++;
  171. setEventMessages($object->error, $object->errors, 'errors');
  172. $action = 'create'; // Force chargement page en mode creation
  173. }
  174. }
  175. if (!$error) {
  176. $db->commit();
  177. } else {
  178. $db->rollback();
  179. }
  180. }
  181. if ($action == 'update') {
  182. $error = 0;
  183. // Update account
  184. $object = new Account($db);
  185. $object->fetch(GETPOST("id", 'int'));
  186. $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha')));
  187. $object->label = trim(GETPOST("label", 'alphanohtml'));
  188. $object->courant = GETPOST("type");
  189. $object->clos = GETPOST("clos");
  190. $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1);
  191. $object->url = trim(GETPOST("url", 'alpha'));
  192. $object->bank = trim(GETPOST("bank"));
  193. $object->code_banque = trim(GETPOST("code_banque"));
  194. $object->code_guichet = trim(GETPOST("code_guichet"));
  195. $object->number = trim(GETPOST("number"));
  196. $object->cle_rib = trim(GETPOST("cle_rib"));
  197. $object->bic = trim(GETPOST("bic"));
  198. $object->iban = trim(GETPOST("iban"));
  199. $object->domiciliation = trim(GETPOST("domiciliation", "alphanohtml"));
  200. $object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1;
  201. $object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
  202. $object->owner_address = trim(GETPOST("owner_address", 'alphanohtml'));
  203. $object->ics = trim(GETPOST("ics", 'alpha'));
  204. $object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha'));
  205. $account_number = GETPOST('account_number', 'alphanohtml');
  206. if (empty($account_number) || $account_number == '-1') {
  207. $object->account_number = '';
  208. } else {
  209. $object->account_number = $account_number;
  210. }
  211. $fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int');
  212. if ($fk_accountancy_journal <= 0) {
  213. $object->fk_accountancy_journal = '';
  214. } else {
  215. $object->fk_accountancy_journal = $fk_accountancy_journal;
  216. }
  217. $object->currency_code = trim(GETPOST("account_currency_code"));
  218. $object->state_id = GETPOST("account_state_id", 'int');
  219. $object->country_id = GETPOST("account_country_id", 'int');
  220. $object->min_allowed = GETPOST("account_min_allowed", 'int');
  221. $object->min_desired = GETPOST("account_min_desired", 'int');
  222. $object->comment = trim(GETPOST("account_comment", 'restricthtml'));
  223. if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) {
  224. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
  225. $action = 'edit'; // Force chargement page en mode creation
  226. $error++;
  227. }
  228. if (empty($object->ref)) {
  229. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
  230. $action = 'edit'; // Force chargement page en mode creation
  231. $error++;
  232. }
  233. if (empty($object->label)) {
  234. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
  235. $action = 'edit'; // Force chargement page en mode creation
  236. $error++;
  237. }
  238. $db->begin();
  239. if (!$error) {
  240. // Fill array 'array_options' with data from add form
  241. $ret = $extrafields->setOptionalsFromPost(null, $object);
  242. }
  243. if (!$error) {
  244. $result = $object->update($user);
  245. if ($result >= 0) {
  246. // Category association
  247. $categories = GETPOST('categories', 'array');
  248. $object->setCategories($categories);
  249. $_GET["id"] = GETPOST("id", 'int'); // Force chargement page en mode visu
  250. } else {
  251. $error++;
  252. setEventMessages($object->error, $object->errors, 'errors');
  253. $action = 'edit'; // Force chargement page edition
  254. }
  255. }
  256. if (!$error) {
  257. $db->commit();
  258. } else {
  259. $db->rollback();
  260. }
  261. }
  262. if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->banque->configurer) {
  263. // Delete
  264. $object = new Account($db);
  265. $object->fetch(GETPOST("id", "int"));
  266. $result = $object->delete($user);
  267. if ($result > 0) {
  268. setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
  269. header("Location: " . DOL_URL_ROOT . "/compta/bank/list.php");
  270. exit;
  271. } else {
  272. setEventMessages($object->error, $object->errors, 'errors');
  273. $action = '';
  274. }
  275. }
  276. }
  277. /*
  278. * View
  279. */
  280. $form = new Form($db);
  281. $formbank = new FormBank($db);
  282. $formcompany = new FormCompany($db);
  283. if (isModEnabled('accounting')) {
  284. $formaccounting = new FormAccounting($db);
  285. }
  286. $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
  287. $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas|DE:Modul_Banken_und_Barbestände';
  288. if ($action == 'create') {
  289. $title = $langs->trans("NewFinancialAccount");
  290. } elseif (!empty($object->ref)) {
  291. $title = $object->ref." - ".$langs->trans("Card");
  292. }
  293. llxHeader("", $title, $help_url);
  294. // Creation
  295. if ($action == 'create') {
  296. print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'bank_account');
  297. if ($conf->use_javascript_ajax) {
  298. print "\n".'<script type="text/javascript">';
  299. print 'jQuery(document).ready(function () {
  300. jQuery("#type").change(function() {
  301. document.formsoc.action.value="create";
  302. document.formsoc.submit();
  303. });
  304. jQuery("#selectaccount_country_id").change(function() {
  305. document.formsoc.action.value="create";
  306. document.formsoc.submit();
  307. });
  308. })';
  309. print '</script>'."\n";
  310. }
  311. print '<form action="'.$_SERVER["PHP_SELF"].'" name="formsoc" method="post">';
  312. print '<input type="hidden" name="token" value="'.newToken().'">';
  313. print '<input type="hidden" name="action" value="add">';
  314. print '<input type="hidden" name="clos" value="0">';
  315. print dol_get_fiche_head('');
  316. print '<table class="border centpercent tableforfieldcreate">';
  317. // Ref
  318. print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
  319. 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>';
  320. // Label
  321. print '<tr><td class="fieldrequired">'.$langs->trans("LabelBankCashAccount").'</td>';
  322. print '<td><input type="text" class="flat maxwidth150onsmartphone" name="label" value="'.dol_escape_htmltag(GETPOST('label', 'alpha')).'"></td></tr>';
  323. // Type
  324. print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
  325. print '<td>';
  326. $formbank->selectTypeOfBankAccount(GETPOSTISSET("type") ? GETPOST('type', 'int') : Account::TYPE_CURRENT, 'type');
  327. print '</td></tr>';
  328. // Currency
  329. print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
  330. print '<td>';
  331. $selectedcode = $object->currency_code;
  332. if (!$selectedcode) {
  333. $selectedcode = $conf->currency;
  334. }
  335. print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code');
  336. //print $langs->trans("Currency".$conf->currency);
  337. //print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
  338. print '</td></tr>';
  339. // Status
  340. print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
  341. print '<td>';
  342. print $form->selectarray("clos", $object->status, (GETPOST('clos', 'int') != '' ? GETPOST('clos', 'int') : $object->clos), 0, 0, 0, '', 0, 0, 0, '', 'maxwidth150onsmartphone');
  343. print '</td></tr>';
  344. // Country
  345. $selectedcode = '';
  346. if (GETPOSTISSET("account_country_id")) {
  347. $selectedcode = GETPOST("account_country_id") ? GETPOST("account_country_id") : $object->country_code;
  348. } elseif (empty($selectedcode)) {
  349. $selectedcode = $mysoc->country_code;
  350. }
  351. $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules
  352. print '<tr><td class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>';
  353. print '<td>';
  354. print img_picto('', 'country', 'class="pictofixedwidth"').$form->select_country($selectedcode, 'account_country_id');
  355. if ($user->admin) {
  356. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
  357. }
  358. print '</td></tr>';
  359. // State
  360. print '<tr><td>'.$langs->trans('State').'</td><td>';
  361. if ($selectedcode) {
  362. print img_picto('', 'state', 'class="pictofixedwidth"');
  363. print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : '', $selectedcode, 'account_state_id');
  364. } else {
  365. print $countrynotdefined;
  366. }
  367. print '</td></tr>';
  368. // Web
  369. print '<tr><td>'.$langs->trans("Web").'</td>';
  370. print '<td>';
  371. print img_picto('', 'globe', 'class="pictofixedwidth"');
  372. print '<input class="minwidth300 widthcentpercentminusx maxwidth500" type="text" class="flat" name="url" value="'.GETPOST("url").'">';
  373. print '</td></tr>';
  374. // Tags-Categories
  375. if (isModEnabled('categorie')) {
  376. print '<tr><td>'.$langs->trans("Categories").'</td><td>';
  377. $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
  378. $arrayselected = array();
  379. $c = new Categorie($db);
  380. $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT);
  381. if (is_array($cats)) {
  382. foreach ($cats as $cat) {
  383. $arrayselected[] = $cat->id;
  384. }
  385. }
  386. print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
  387. print "</td></tr>";
  388. }
  389. // Comment
  390. print '<tr><td>'.$langs->trans("Comment").'</td>';
  391. print '<td>';
  392. // Editor wysiwyg
  393. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  394. $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_4, '90%');
  395. $doleditor->Create();
  396. print '</td></tr>';
  397. // Other attributes
  398. $parameters = array();
  399. $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  400. print $hookmanager->resPrint;
  401. if (empty($reshook)) {
  402. print $object->showOptionals($extrafields, 'create', $parameters);
  403. }
  404. print '</table>';
  405. print '<br>';
  406. print '<table class="border centpercent">';
  407. // Sold
  408. print '<tr><td class="titlefieldcreate">'.$langs->trans("InitialBankBalance").'</td>';
  409. print '<td><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde") ?GETPOST("solde") : price2num($object->solde)).'"></td></tr>';
  410. print '<tr><td>'.$langs->trans("Date").'</td>';
  411. print '<td>';
  412. print $form->selectDate('', 're', 0, 0, 0, 'formsoc');
  413. print '</td></tr>';
  414. print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
  415. 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>';
  416. print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
  417. 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>';
  418. print '</table>';
  419. print '<br>';
  420. $type = (GETPOSTISSET("type") ? GETPOST('type', 'int') : Account::TYPE_CURRENT); // add default value
  421. if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
  422. print '<table class="border centpercent">';
  423. // If bank account
  424. print '<tr><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
  425. print '<td><input type="text" class="flat minwidth150" name="bank" value="'.(GETPOST('bank') ?GETPOST('bank', 'alpha') : $object->bank).'"></td>';
  426. print '</tr>';
  427. // Show fields of bank account
  428. $sizecss = '';
  429. foreach ($object->getFieldsToShow() as $val) {
  430. if ($val == 'BankCode') {
  431. $name = 'code_banque';
  432. $sizecss = 'minwidth100';
  433. $content = $object->code_banque;
  434. } elseif ($val == 'DeskCode') {
  435. $name = 'code_guichet';
  436. $sizecss = 'minwidth100';
  437. $content = $object->code_guichet;
  438. } elseif ($val == 'BankAccountNumber') {
  439. $name = 'number';
  440. $sizecss = 'minwidth200';
  441. $content = $object->number;
  442. } elseif ($val == 'BankAccountNumberKey') {
  443. $name = 'cle_rib';
  444. $sizecss = 'minwidth50';
  445. $content = $object->cle_rib;
  446. }
  447. print '<td>'.$langs->trans($val).'</td>';
  448. print '<td><input type="text" class="flat '.$sizecss.'" name="'.$name.'" value="'.(GETPOST($name) ?GETPOST($name, 'alpha') : $content).'"></td>';
  449. print '</tr>';
  450. }
  451. $ibankey = FormBank::getIBANLabel($object);
  452. $bickey = "BICNumber";
  453. if ($object->getCountryCode() == 'IN') {
  454. $bickey = "SWIFT";
  455. }
  456. // IBAN
  457. print '<tr><td>'.$langs->trans($ibankey).'</td>';
  458. print '<td><input maxlength="34" type="text" class="flat minwidth300" name="iban" value="'.(GETPOST('iban') ?GETPOST('iban', 'alpha') : $object->iban).'"></td></tr>';
  459. print '<tr><td>'.$langs->trans($bickey).'</td>';
  460. print '<td><input maxlength="11" type="text" class="flat minwidth150" name="bic" value="'.(GETPOST('bic') ?GETPOST('bic', 'alpha') : $object->bic).'"></td></tr>';
  461. if (isModEnabled('paymentbybanktransfer')) {
  462. print '<tr><td>'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").'</td>';
  463. print '<td><input type="checkbox" class="flat minwidth150" name="pti_in_ctti"'. (empty(GETPOST('pti_in_ctti')) ? '' : ' checked ') . '>&nbsp;';
  464. print img_picto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp"), 'info');
  465. print '</td></tr>';
  466. }
  467. print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
  468. print '<textarea class="flat quatrevingtpercent" name="domiciliation" rows="'.ROWS_2.'">';
  469. print (GETPOST('domiciliation') ?GETPOST('domiciliation') : $object->domiciliation);
  470. print "</textarea></td></tr>";
  471. print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
  472. print '<td><input type="text" class="flat minwidth300" name="proprio" value="'.(GETPOST('proprio') ?GETPOST('proprio', 'alpha') : $object->proprio).'">';
  473. print '</td></tr>';
  474. print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
  475. print '<textarea class="flat quatrevingtpercent" name="owner_address" rows="'.ROWS_2.'">';
  476. print (GETPOST('owner_address') ?GETPOST('owner_address', 'alpha') : $object->owner_address);
  477. print "</textarea></td></tr>";
  478. print '</table>';
  479. print '<br>';
  480. }
  481. print '<table class="border centpercent">';
  482. // Accountancy code
  483. $fieldrequired = '';
  484. if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
  485. $fieldrequired = 'fieldrequired ';
  486. }
  487. if (isModEnabled('accounting')) {
  488. print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
  489. print '<td>';
  490. print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
  491. print '</td></tr>';
  492. } else {
  493. print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
  494. print '<td><input type="text" name="account_number" value="'.(GETPOST("account_number") ?GETPOST('account_number', 'alpha') : $object->account_number).'"></td></tr>';
  495. }
  496. // Accountancy journal
  497. if (isModEnabled('accounting')) {
  498. print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
  499. print '<td>';
  500. print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
  501. print '</td></tr>';
  502. }
  503. print '</table>';
  504. print dol_get_fiche_end();
  505. print $form->buttonsSaveCancel("CreateAccount");
  506. print '</form>';
  507. } else {
  508. // View and edit mode
  509. if ((GETPOST("id", 'int') || GETPOST("ref")) && $action != 'edit') {
  510. // Show tabs
  511. $head = bank_prepare_head($object);
  512. print dol_get_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account');
  513. $formconfirm = '';
  514. // Confirmation to delete
  515. if ($action == 'delete') {
  516. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteAccount"), $langs->trans("ConfirmDeleteAccount"), "confirm_delete");
  517. }
  518. // Print form confirm
  519. print $formconfirm;
  520. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  521. $morehtmlref = '';
  522. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  523. print '<div class="fichecenter">';
  524. print '<div class="fichehalfleft">';
  525. print '<div class="underbanner clearboth"></div>';
  526. print '<table class="border tableforfield" width="100%">';
  527. // Type
  528. print '<tr><td class="titlefield">'.$langs->trans("AccountType").'</td>';
  529. print '<td>'.$object->type_lib[$object->type].'</td></tr>';
  530. // Currency
  531. print '<tr><td>'.$langs->trans("Currency").'</td>';
  532. print '<td>';
  533. $selectedcode = $object->currency_code;
  534. if (!$selectedcode) {
  535. $selectedcode = $conf->currency;
  536. }
  537. print $langs->trans("Currency".$selectedcode);
  538. print '</td></tr>';
  539. // Conciliate
  540. print '<tr><td>'.$langs->trans("Conciliable").'</td>';
  541. print '<td>';
  542. $conciliate = $object->canBeConciliated();
  543. if ($conciliate == -2) {
  544. print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("CashAccount").')</span>';
  545. } elseif ($conciliate == -3) {
  546. print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("Closed").')</span>';
  547. } else {
  548. print ($object->rappro == 1 ? $langs->trans("Yes") : ($langs->trans("No").' <span class="opacitymedium">('.$langs->trans("ConciliationDisabled").')</span>'));
  549. }
  550. print '</td></tr>';
  551. print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
  552. print '<td>'.$object->min_allowed.'</td></tr>';
  553. print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
  554. print '<td>'.$object->min_desired.'</td></tr>';
  555. // Accountancy code
  556. print '<tr class="liste_titre_add"><td class="titlefield">'.$langs->trans("AccountancyCode").'</td>';
  557. print '<td>';
  558. if (isModEnabled('accounting')) {
  559. $accountingaccount = new AccountingAccount($db);
  560. $accountingaccount->fetch('', $object->account_number, 1);
  561. print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
  562. } else {
  563. print $object->account_number;
  564. }
  565. print '</td></tr>';
  566. // Accountancy journal
  567. if (isModEnabled('accounting')) {
  568. print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
  569. print '<td>';
  570. if ($object->fk_accountancy_journal > 0) {
  571. $accountingjournal = new AccountingJournal($db);
  572. $accountingjournal->fetch($object->fk_accountancy_journal);
  573. print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
  574. }
  575. print '</td></tr>';
  576. }
  577. // Other attributes
  578. $cols = 2;
  579. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  580. print '</table>';
  581. print '</div>';
  582. print '<div class="fichehalfright">';
  583. print '<div class="underbanner clearboth"></div>';
  584. print '<table class="border tableforfield centpercent">';
  585. // Categories
  586. if (isModEnabled('categorie')) {
  587. print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
  588. print $form->showCategories($object->id, Categorie::TYPE_ACCOUNT, 1);
  589. print "</td></tr>";
  590. }
  591. print '<tr><td class="tdtop titlefield">'.$langs->trans("Comment").'</td>';
  592. print '<td>'.dol_htmlentitiesbr($object->comment).'</td></tr>';
  593. print '</table>';
  594. if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) {
  595. //print '<div class="underbanner clearboth"></div>';
  596. print '<table class="border tableforfield centpercent">';
  597. print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("BankName").'</td>';
  598. print '<td>'.$object->bank.'</td></tr>';
  599. // Show fields of bank account
  600. foreach ($object->getFieldsToShow() as $val) {
  601. if ($val == 'BankCode') {
  602. $content = $object->code_banque;
  603. } elseif ($val == 'DeskCode') {
  604. $content = $object->code_guichet;
  605. } elseif ($val == 'BankAccountNumber') {
  606. $content = $object->number;
  607. } elseif ($val == 'BankAccountNumberKey') {
  608. $content = $object->cle_rib;
  609. }
  610. print '<tr><td>'.$langs->trans($val).'</td>';
  611. print '<td>'.$content.'</td>';
  612. print '</tr>';
  613. }
  614. $ibankey = FormBank::getIBANLabel($object);
  615. $bickey = "BICNumber";
  616. if ($object->getCountryCode() == 'IN') {
  617. $bickey = "SWIFT";
  618. }
  619. print '<tr><td>'.$langs->trans($ibankey).'</td>';
  620. print '<td>'.getIbanHumanReadable($object).'&nbsp;';
  621. if (!empty($object->iban)) {
  622. if (!checkIbanForAccount($object)) {
  623. print img_picto($langs->trans("IbanNotValid"), 'warning');
  624. } else {
  625. print img_picto($langs->trans("IbanValid"), 'info');
  626. }
  627. }
  628. print '</td></tr>';
  629. print '<tr><td>'.$langs->trans($bickey).'</td>';
  630. print '<td>'.$object->bic.'&nbsp;';
  631. if (!empty($object->bic)) {
  632. if (!checkSwiftForAccount($object)) {
  633. print img_picto($langs->trans("SwiftNotValid"), 'warning');
  634. } else {
  635. print img_picto($langs->trans("SwiftValid"), 'info');
  636. }
  637. }
  638. print '</td></tr>';
  639. if (isModEnabled('prelevement')) {
  640. print '<tr><td>'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'</td>';
  641. print '<td>'.$object->ics.'</td>';
  642. print '</tr>';
  643. }
  644. // TODO ICS is not used with bank transfer !
  645. if (isModEnabled('paymentbybanktransfer')) {
  646. print '<tr><td>'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'</td>';
  647. print '<td>'.$object->ics_transfer.'</td>';
  648. print '</tr>';
  649. print '<tr><td>'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").'</td><td>';
  650. print (empty($object->pti_in_ctti) ? $langs->trans("No") : $langs->trans("Yes")) . '&nbsp;';
  651. print img_picto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp"), 'info');
  652. print "</td></tr>\n";
  653. }
  654. print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
  655. print nl2br($object->domiciliation);
  656. print "</td></tr>\n";
  657. print '<tr><td>'.$langs->trans("BankAccountOwner").'</td><td>';
  658. print $object->proprio;
  659. print "</td></tr>\n";
  660. print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
  661. print nl2br($object->owner_address);
  662. print "</td></tr>\n";
  663. print '</table>';
  664. }
  665. print '</div>';
  666. print '</div>';
  667. print '<div class="clearboth"></div>';
  668. print dol_get_fiche_end();
  669. /*
  670. * Action bar
  671. */
  672. print '<div class="tabsAction">';
  673. if ($user->rights->banque->configurer) {
  674. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Modify").'</a>';
  675. }
  676. $canbedeleted = $object->can_be_deleted(); // Renvoi vrai si compte sans mouvements
  677. if ($user->rights->banque->configurer && $canbedeleted) {
  678. print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Delete").'</a>';
  679. }
  680. print '</div>';
  681. }
  682. /* ************************************************************************** */
  683. /* */
  684. /* Edition */
  685. /* */
  686. /* ************************************************************************** */
  687. if (GETPOST('id', 'int') && $action == 'edit' && $user->rights->banque->configurer) {
  688. print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'bank_account');
  689. if ($conf->use_javascript_ajax) {
  690. print "\n".'<script type="text/javascript">';
  691. print 'jQuery(document).ready(function () {
  692. jQuery("#type").change(function() {
  693. document.formsoc.action.value="edit";
  694. document.formsoc.submit();
  695. });
  696. })'."\n";
  697. print 'jQuery(document).ready(function () {
  698. jQuery("#selectaccount_country_id").change(function() {
  699. document.formsoc.action.value="edit";
  700. document.formsoc.submit();
  701. });
  702. })';
  703. print '</script>'."\n";
  704. }
  705. print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formsoc">';
  706. print '<input type="hidden" name="token" value="'.newToken().'">';
  707. print '<input type="hidden" name="action" value="update">';
  708. print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">'."\n\n";
  709. print dol_get_fiche_head(array(), 0, '', 0);
  710. //print '<div class="underbanner clearboth"></div>';
  711. print '<table class="border centpercent tableforfieldcreate">';
  712. // Ref
  713. print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
  714. print '<td><input type="text" class="flat maxwidth200" name="ref" value="'.dol_escape_htmltag(GETPOSTISSET('ref') ? GETPOST('ref', 'alpha') : $object->ref).'"></td></tr>';
  715. // Label
  716. print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
  717. print '<td><input type="text" class="flat minwidth300" name="label" value="'.dol_escape_htmltag(GETPOSTISSET('label') ? GETPOST('label', 'alpha') : $object->label).'"></td></tr>';
  718. // Type
  719. print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
  720. print '<td class="maxwidth200onsmartphone">';
  721. $formbank->selectTypeOfBankAccount((GETPOSTISSET('type') ? GETPOST('type', 'int') : $object->type), 'type');
  722. print '</td></tr>';
  723. // Currency
  724. print '<tr><td class="fieldrequired">'.$langs->trans("Currency");
  725. print '<input type="hidden" value="'.$object->currency_code.'">';
  726. print '</td>';
  727. print '<td class="maxwidth200onsmartphone">';
  728. $selectedcode = $object->currency_code;
  729. if (!$selectedcode) {
  730. $selectedcode = $conf->currency;
  731. }
  732. print img_picto('', 'multicurrency', 'class="pictofixedwidth"');
  733. print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code');
  734. //print $langs->trans("Currency".$conf->currency);
  735. //print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
  736. print '</td></tr>';
  737. // Status
  738. print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
  739. print '<td class="maxwidth200onsmartphone">';
  740. print $form->selectarray("clos", $object->status, (GETPOSTISSET("clos") ? GETPOST("clos", "int") : $object->clos));
  741. print '</td></tr>';
  742. // Country
  743. $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id;
  744. $selectedcode = $object->country_code;
  745. if (GETPOSTISSET("account_country_id")) {
  746. $selectedcode = GETPOST("account_country_id");
  747. } elseif (empty($selectedcode)) {
  748. $selectedcode = $mysoc->country_code;
  749. }
  750. $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules
  751. print '<tr><td class="fieldrequired">'.$langs->trans("Country").'</td>';
  752. print '<td class="maxwidth200onsmartphone">';
  753. print img_picto('', 'country', 'class="pictofixedwidth"').$form->select_country($selectedcode, 'account_country_id');
  754. if ($user->admin) {
  755. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
  756. }
  757. print '</td></tr>';
  758. // State
  759. print '<tr><td>'.$langs->trans('State').'</td><td class="maxwidth200onsmartphone">';
  760. if ($selectedcode) {
  761. print img_picto('', 'state', 'class="pictofixedwidth"');
  762. print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : $object->state_id, $selectedcode, 'account_state_id');
  763. } else {
  764. print $countrynotdefined;
  765. }
  766. print '</td></tr>';
  767. // Conciliable
  768. print '<tr><td>'.$langs->trans("Conciliable").'</td>';
  769. print '<td>';
  770. $conciliate = $object->canBeConciliated();
  771. if ($conciliate == -2) {
  772. print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
  773. } elseif ($conciliate == -3) {
  774. print $langs->trans("No").' ('.$langs->trans("Closed").')';
  775. } else {
  776. print '<input type="checkbox" class="flat" id="norappro" name="norappro"'.(($conciliate > 0) ? '' : ' checked="checked"').'"> <label for="norappro">'.$langs->trans("DisableConciliation").'</label>';
  777. }
  778. print '</td></tr>';
  779. // Balance
  780. print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
  781. 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>';
  782. print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
  783. 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>';
  784. // Web
  785. print '<tr><td>'.$langs->trans("Web").'</td>';
  786. print '<td>';
  787. print img_picto('', 'globe', 'class="pictofixedwidth"');
  788. print '<input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(GETPOSTISSET("url") ? GETPOST("url") : $object->url).'">';
  789. print '</td></tr>';
  790. // Tags-Categories
  791. if (isModEnabled('categorie')) {
  792. print '<tr><td>'.$langs->trans("Categories").'</td><td>';
  793. $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
  794. $c = new Categorie($db);
  795. $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT);
  796. if (is_array($cats)) {
  797. foreach ($cats as $cat) {
  798. $arrayselected[] = $cat->id;
  799. }
  800. }
  801. print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
  802. print "</td></tr>";
  803. }
  804. // Comment
  805. print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
  806. print '<td>';
  807. // Editor wysiwyg
  808. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  809. $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_4, '95%');
  810. $doleditor->Create();
  811. print '</td></tr>';
  812. // Other attributes
  813. $parameters = array();
  814. $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  815. print $hookmanager->resPrint;
  816. if (empty($reshook)) {
  817. print $object->showOptionals($extrafields, 'edit', $parameters);
  818. }
  819. print '</table>';
  820. print '<br>';
  821. //print '<div class="underbanner clearboth"></div>';
  822. print '<table class="border centpercent">';
  823. // Accountancy code
  824. $tdextra = ' class="titlefieldcreate"';
  825. if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
  826. $tdextra = ' class="fieldrequired titlefieldcreate"';
  827. }
  828. print '<tr><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
  829. print '<td>';
  830. if (isModEnabled('accounting')) {
  831. print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
  832. } else {
  833. print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
  834. }
  835. print '</td></tr>';
  836. // Accountancy journal
  837. if (isModEnabled('accounting')) {
  838. print '<tr><td class="fieldrequired">'.$langs->trans("AccountancyJournal").'</td>';
  839. print '<td>';
  840. print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
  841. print '</td></tr>';
  842. }
  843. print '</table>';
  844. $type = (GETPOSTISSET('type') ? GETPOST('type', 'int') : $object->type); // add default current value
  845. if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
  846. print '<br>';
  847. //print '<div class="underbanner clearboth"></div>';
  848. print '<table class="border centpercent">';
  849. // If bank account
  850. print '<tr class="liste_titre_add"><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
  851. print '<td><input size="30" type="text" class="flat" name="bank" value="'.$object->bank.'"></td>';
  852. print '</tr>';
  853. // Show fields of bank account
  854. foreach ($object->getFieldsToShow() as $val) {
  855. if ($val == 'BankCode') {
  856. $name = 'code_banque';
  857. $size = 8;
  858. $content = $object->code_banque;
  859. } elseif ($val == 'DeskCode') {
  860. $name = 'code_guichet';
  861. $size = 8;
  862. $content = $object->code_guichet;
  863. } elseif ($val == 'BankAccountNumber') {
  864. $name = 'number';
  865. $size = 18;
  866. $content = $object->number;
  867. } elseif ($val == 'BankAccountNumberKey') {
  868. $name = 'cle_rib';
  869. $size = 3;
  870. $content = $object->cle_rib;
  871. }
  872. print '<tr><td>'.$langs->trans($val).'</td>';
  873. print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
  874. print '</tr>';
  875. }
  876. $ibankey = FormBank::getIBANLabel($object);
  877. $bickey = "BICNumber";
  878. if ($object->getCountryCode() == 'IN') {
  879. $bickey = "SWIFT";
  880. }
  881. // IBAN
  882. print '<tr><td>'.$langs->trans($ibankey).'</td>';
  883. print '<td><input class="minwidth300 maxwidth200onsmartphone" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOSTISSET('iban') ? GETPOST('iban', 'alphanohtml') : $object->iban).'"></td></tr>';
  884. print '<tr><td>'.$langs->trans($bickey).'</td>';
  885. print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOSTISSET('bic') ? GETPOST('bic', 'alphanohtml') : $object->bic).'"></td></tr>';
  886. if (isModEnabled('prelevement')) {
  887. print '<tr><td>'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'</td>';
  888. print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics" value="'.(GETPOSTISSET('ics') ? GETPOST('ics', 'alphanohtml') : $object->ics).'"></td></tr>';
  889. }
  890. if (isModEnabled('paymentbybanktransfer')) {
  891. print '<tr><td>'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'</td>';
  892. 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>';
  893. print '<tr><td>'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").'</td>';
  894. print '<td><input type="checkbox" class="flat minwidth150" name="pti_in_ctti"'. ($object->pti_in_ctti ? ' checked ' : '') . '>&nbsp;';
  895. print img_picto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp"), 'info');
  896. print '</td></tr>';
  897. }
  898. print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
  899. print '<textarea class="flat quatrevingtpercent" name="domiciliation" rows="'.ROWS_2.'">';
  900. print $object->domiciliation;
  901. print "</textarea></td></tr>";
  902. print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
  903. print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="proprio" value="'.$object->proprio.'"></td>';
  904. print '</tr>';
  905. print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
  906. print '<textarea class="flat quatrevingtpercent" name="owner_address" rows="'.ROWS_2.'">';
  907. print $object->owner_address;
  908. print "</textarea></td></tr>";
  909. print '</table>';
  910. }
  911. print dol_get_fiche_end();
  912. print $form->buttonsSaveCancel("Modify");
  913. print '</form>';
  914. }
  915. }
  916. // End of page
  917. llxFooter();
  918. $db->close();