card.php 47 KB

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