index.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/compta/bank/index.php
  22. * \ingroup banque
  23. * \brief Home page of bank module
  24. */
  25. require('../../main.inc.php');
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  30. if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
  31. if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
  32. $langs->load("banks");
  33. $langs->load("categories");
  34. $langs->load("accountancy");
  35. $langs->load("compta");
  36. $action=GETPOST('action','alpha');
  37. $massaction=GETPOST('massaction','alpha');
  38. $show_files=GETPOST('show_files','int');
  39. $confirm=GETPOST('confirm','alpha');
  40. $toselect = GETPOST('toselect', 'array');
  41. $search_ref=GETPOST('search_ref','alpha');
  42. $search_label=GETPOST('search_label','alpha');
  43. $search_number=GETPOST('search_number','alpha');
  44. $statut=GETPOST('statut')?GETPOST('statut', 'alpha'):'opened'; // 'all' or ''='opened'
  45. $optioncss = GETPOST('optioncss','alpha');
  46. // Security check
  47. if ($user->societe_id) $socid=$user->societe_id;
  48. $result=restrictedArea($user,'banque');
  49. $diroutputmassaction=$conf->bank->dir_output . '/temp/massgeneration/'.$user->id;
  50. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  51. $sortfield = GETPOST("sortfield",'alpha');
  52. $sortorder = GETPOST("sortorder",'alpha');
  53. $page = GETPOST("page",'int');
  54. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  55. $offset = $limit * $page;
  56. $pageprev = $page - 1;
  57. $pagenext = $page + 1;
  58. if (! $sortfield) $sortfield='b.label';
  59. if (! $sortorder) $sortorder='ASC';
  60. // Initialize technical object to manage context to save list fields
  61. $contextpage='bankaccountlist';
  62. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  63. $hookmanager->initHooks(array($contextpage));
  64. $extrafields = new ExtraFields($db);
  65. // fetch optionals attributes and labels
  66. $extralabels = $extrafields->fetch_name_optionals_label('bankaccount');
  67. $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
  68. // List of fields to search into when doing a "search in all"
  69. $fieldstosearchall = array(
  70. 'b.ref'=>'Ref',
  71. 'b.label'=>'Label',
  72. );
  73. $checkedtypetiers=0;
  74. $arrayfields=array(
  75. 'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1),
  76. 'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
  77. 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
  78. 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1),
  79. 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>$conf->accountancy->enabled),
  80. 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>$conf->accountancy->enabled),
  81. 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1),
  82. 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  83. 'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  84. 'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
  85. 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010),
  86. );
  87. // Extra fields
  88. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  89. {
  90. foreach($extrafields->attribute_label as $key => $val)
  91. {
  92. $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
  93. }
  94. }
  95. /*
  96. * Actions
  97. */
  98. if (GETPOST('cancel')) { $action='list'; $massaction=''; }
  99. if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
  100. $parameters=array('socid'=>$socid);
  101. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  102. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  103. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  104. // Purge search criteria
  105. if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
  106. {
  107. $statut = 'all';
  108. $search_ref='';
  109. $search_label='';
  110. $search_number='';
  111. $search_statut='';
  112. }
  113. /*
  114. * View
  115. */
  116. $form=new Form($db);
  117. $title=$langs->trans('BankAccounts');
  118. // Load array of financial accounts (opened by default)
  119. $accounts = array();
  120. $sql = "SELECT rowid, label, courant, rappro, account_number, fk_accountancy_journal, datec as date_creation, tms as date_update";
  121. // Add fields from extrafields
  122. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
  123. // Add fields from hooks
  124. $parameters=array();
  125. $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
  126. $sql.=$hookmanager->resPrint;
  127. $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b";
  128. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bankcacount_extrafields as ef on (c.rowid = ef.fk_object)";
  129. $sql.= " WHERE entity IN (".getEntity('bank_account').")";
  130. if ($statut == 'opened') $sql.= " AND clos = 0";
  131. if ($statut == 'closed') $sql.= " AND clos = 1";
  132. if ($search_ref != '') $sql.=natural_search('b.ref', $search_ref);
  133. if ($search_label != '') $sql.=natural_search('b.label', $search_label);
  134. if ($search_number != '') $sql.=natural_search('b.number', $search_number);
  135. // Add where from extra fields
  136. foreach ($search_array_options as $key => $val)
  137. {
  138. $crit=$val;
  139. $tmpkey=preg_replace('/search_options_/','',$key);
  140. $typ=$extrafields->attribute_type[$tmpkey];
  141. $mode=0;
  142. if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
  143. if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
  144. {
  145. $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
  146. }
  147. }
  148. // Add where from hooks
  149. $parameters=array();
  150. $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
  151. $sql.=$hookmanager->resPrint;
  152. $sql.= $db->order($sortfield,$sortorder);
  153. // Count total nb of records
  154. $nbtotalofrecords = '';
  155. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  156. {
  157. $result = $db->query($sql);
  158. $nbtotalofrecords = $db->num_rows($result);
  159. }
  160. $sql.= $db->plimit($limit + 1,$offset);
  161. $resql = $db->query($sql);
  162. if ($resql)
  163. {
  164. $num = $db->num_rows($resql);
  165. $i = 0;
  166. while ($i < $num)
  167. {
  168. $objp = $db->fetch_object($resql);
  169. $accounts[$objp->rowid] = $objp->courant;
  170. $i++;
  171. }
  172. $db->free($resql);
  173. }
  174. else dol_print_error($db);
  175. $help_url='EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
  176. llxHeader('',$title,$help_url);
  177. $link='';
  178. $num_rows = count($accounts);
  179. $arrayofselected=is_array($toselect)?$toselect:array();
  180. $param='';
  181. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  182. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  183. if ($search_ref != '') $param.='&search_ref='.$search_ref;
  184. if ($search_label != '') $param.='&search_label='.$search_label;
  185. if ($search_number != '') $param.='&search_number='.$search_number;
  186. if ($statut != '') $param.='&statut='.$statut;
  187. if ($show_files) $param.='&show_files=' .$show_files;
  188. if ($optioncss != '') $param.='&optioncss='.$optioncss;
  189. // Add $param from extra fields
  190. foreach ($search_array_options as $key => $val)
  191. {
  192. $crit=$val;
  193. $tmpkey=preg_replace('/search_options_/','',$key);
  194. if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
  195. }
  196. // List of mass actions available
  197. $arrayofmassactions = array(
  198. // 'presend'=>$langs->trans("SendByMail"),
  199. // 'builddoc'=>$langs->trans("PDFMerge"),
  200. );
  201. if ($user->rights->banque->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
  202. if ($massaction == 'presend') $arrayofmassactions=array();
  203. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  204. $newcardbutton='';
  205. if ($user->rights->banque->configurer)
  206. {
  207. $newcardbutton.='<a class="butAction" href="card.php?action=create">'.$langs->trans("NewFinancialAccount").'</a>';
  208. }
  209. // Lines of title fields
  210. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  211. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  212. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  213. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  214. print '<input type="hidden" name="action" value="list">';
  215. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  216. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  217. print '<input type="hidden" name="page" value="'.$page.'">';
  218. print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
  219. print_barre_liste($title,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_bank.png',0,$newcardbutton,'',$limit, 1);
  220. if ($sall)
  221. {
  222. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  223. print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
  224. }
  225. $moreforfilter='';
  226. // Bank accounts
  227. $parameters=array();
  228. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  229. if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
  230. else $moreforfilter = $hookmanager->resPrint;
  231. if (! empty($moreforfilter))
  232. {
  233. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  234. print $moreforfilter;
  235. print '</div>';
  236. }
  237. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  238. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  239. print '<div class="div-table-responsive">';
  240. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  241. print '<tr class="liste_titre_filter">';
  242. // Ref
  243. if (! empty($arrayfields['b.ref']['checked']))
  244. {
  245. print '<td class="liste_titre">';
  246. print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">';
  247. print '</td>';
  248. }
  249. // Label
  250. if (! empty($arrayfields['b.label']['checked']))
  251. {
  252. print '<td class="liste_titre">';
  253. print '<input class="flat" size="6" type="text" name="search_label" value="'.$search_label.'">';
  254. print '</td>';
  255. }
  256. // Account type
  257. if (! empty($arrayfields['accountype']['checked']))
  258. {
  259. print '<td class="liste_titre">';
  260. print '</td>';
  261. }
  262. // Bank number
  263. if (! empty($arrayfields['b.number']['checked']))
  264. {
  265. print '<td class="liste_titre">';
  266. print '<input class="flat" size="6" type="text" name="search_number" value="'.$search_number.'">';
  267. print '</td>';
  268. }
  269. // Account number
  270. if (! empty($arrayfields['b.account_number']['checked']))
  271. {
  272. print '<td class="liste_titre">';
  273. print '</td>';
  274. }
  275. // Accountancy journal
  276. if (! empty($arrayfields['b.fk_accountancy_journal']['checked']))
  277. {
  278. print '<td class="liste_titre">';
  279. print '</td>';
  280. }
  281. // Transactions to reconcile
  282. if (! empty($arrayfields['toreconcile']['checked']))
  283. {
  284. print '<td class="liste_titre">';
  285. print '</td>';
  286. }
  287. // Extra fields
  288. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  289. {
  290. foreach($extrafields->attribute_label as $key => $val)
  291. {
  292. if (! empty($arrayfields["ef.".$key]['checked']))
  293. {
  294. $align=$extrafields->getAlignFlag($key);
  295. $typeofextrafield=$extrafields->attribute_type[$key];
  296. print '<td class="liste_titre'.($align?' '.$align:'').'">';
  297. if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
  298. {
  299. $crit=$val;
  300. $tmpkey=preg_replace('/search_options_/','',$key);
  301. $searchclass='';
  302. if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
  303. if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
  304. print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
  305. }
  306. print '</td>';
  307. }
  308. }
  309. }
  310. // Fields from hook
  311. $parameters=array('arrayfields'=>$arrayfields);
  312. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  313. print $hookmanager->resPrint;
  314. // Date creation
  315. if (! empty($arrayfields['b.datec']['checked']))
  316. {
  317. print '<td class="liste_titre">';
  318. print '</td>';
  319. }
  320. // Date modification
  321. if (! empty($arrayfields['b.tms']['checked']))
  322. {
  323. print '<td class="liste_titre">';
  324. print '</td>';
  325. }
  326. // Statut
  327. if (! empty($arrayfields['b.clos']['checked']))
  328. {
  329. print '<td class="liste_titre center">';
  330. $array=array(
  331. 'opened'=>$langs->trans("Opened"),
  332. 'closed'=>$langs->trans("Closed")
  333. );
  334. print $form->selectarray("statut", $array, $statut, 1);
  335. print '</td>';
  336. }
  337. // Balance
  338. if (! empty($arrayfields['balance']['checked']))
  339. {
  340. print '<td class="liste_titre"></td>';
  341. }
  342. // Action column
  343. print '<td class="liste_titre" align="middle">';
  344. $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
  345. print $searchpicto;
  346. print '</td>';
  347. print '</tr>';
  348. // Fields title
  349. print '<tr class="liste_titre">';
  350. if (! empty($arrayfields['b.ref']['checked'])) print_liste_field_titre($arrayfields['b.ref']['label'],$_SERVER["PHP_SELF"],'b.ref','',$param,'',$sortfield,$sortorder);
  351. if (! empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'],$_SERVER["PHP_SELF"],'b.label','',$param,'',$sortfield,$sortorder);
  352. if (! empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'],$_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder);
  353. if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'],$_SERVER["PHP_SELF"],'b.number','',$param,'',$sortfield,$sortorder);
  354. if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'],$_SERVER["PHP_SELF"],'b.account_number','',$param,'',$sortfield,$sortorder);
  355. if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'],$_SERVER["PHP_SELF"],'b.fk_accountancy_journal','',$param,'',$sortfield,$sortorder);
  356. if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
  357. // Extra fields
  358. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  359. {
  360. foreach($extrafields->attribute_label as $key => $val)
  361. {
  362. if (! empty($arrayfields["ef.".$key]['checked']))
  363. {
  364. $align=$extrafields->getAlignFlag($key);
  365. print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
  366. }
  367. }
  368. }
  369. // Hook fields
  370. $parameters=array('arrayfields'=>$arrayfields);
  371. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  372. print $hookmanager->resPrint;
  373. if (! empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'],$_SERVER["PHP_SELF"],"b.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  374. if (! empty($arrayfields['b.tms']['checked'])) print_liste_field_titre($arrayfields['b.tms']['label'],$_SERVER["PHP_SELF"],"b.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  375. if (! empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'],$_SERVER["PHP_SELF"],'b.clos','',$param,'align="center"',$sortfield,$sortorder);
  376. if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder);
  377. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  378. print "</tr>\n";
  379. $total = array(); $found = 0; $i=0; $lastcurrencycode='';
  380. $var=true;
  381. foreach ($accounts as $key=>$type)
  382. {
  383. if ($i >= $limit) break;
  384. $found++;
  385. $acc = new Account($db);
  386. $acc->fetch($key);
  387. $var = !$var;
  388. $solde = $acc->solde(1);
  389. if (! empty($lastcurrencycode) && $lastcurrencycode != $acc->currency_code)
  390. {
  391. $lastcurrencycode='various'; // We found several different currencies
  392. }
  393. if ($lastcurrencycode != 'various')
  394. {
  395. $lastcurrencycode=$acc->currency_code;
  396. }
  397. print '<tr class="oddeven">';
  398. // Ref
  399. if (! empty($arrayfields['b.ref']['checked']))
  400. {
  401. print '<td>'.$acc->getNomUrl(1).'</td>';
  402. if (! $i) $totalarray['nbfield']++;
  403. }
  404. // Label
  405. if (! empty($arrayfields['b.label']['checked']))
  406. {
  407. print '<td>'.$acc->label.'</td>';
  408. if (! $i) $totalarray['nbfield']++;
  409. }
  410. // Account type
  411. if (! empty($arrayfields['accountype']['checked']))
  412. {
  413. print '<td>';
  414. print $acc->type_lib[$acc->type];
  415. print '</td>';
  416. if (! $i) $totalarray['nbfield']++;
  417. }
  418. // Number
  419. if (! empty($arrayfields['b.number']['checked']))
  420. {
  421. print '<td>'.$acc->number.'</td>';
  422. if (! $i) $totalarray['nbfield']++;
  423. }
  424. // Account number
  425. if (! empty($arrayfields['b.account_number']['checked']))
  426. {
  427. include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
  428. $accountingaccount = new AccountingAccount($db);
  429. $accountingaccount->fetch('',$acc->account_number);
  430. print '<td>'.length_accountg($accountingaccount->getNomUrl(0,1,1,'',1)).'</td>';
  431. if (! $i) $totalarray['nbfield']++;
  432. }
  433. // Accountancy journal
  434. if (! empty($arrayfields['b.fk_accountancy_journal']['checked']))
  435. {
  436. $accountingjournal = new AccountingJournal($db);
  437. $accountingjournal->fetch($acc->fk_accountancy_journal);
  438. print '<td>'.$accountingjournal->getNomUrl(0,1,1,'',1).'</td>';
  439. if (! $i) $totalarray['nbfield']++;
  440. }
  441. // Transactions to reconcile
  442. if (! empty($arrayfields['toreconcile']['checked']))
  443. {
  444. print '<td align="center">';
  445. if ($acc->rappro)
  446. {
  447. $result=$acc->load_board($user,$acc->id);
  448. if ($result<0) {
  449. setEventMessages($acc->error, $acc->errors, 'errors');
  450. } else {
  451. print $result->nbtodo;
  452. if ($result->nbtodolate) print ' &nbsp; ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
  453. }
  454. }
  455. else print $langs->trans("FeatureDisabled");
  456. print '</td>';
  457. if (! $i) $totalarray['nbfield']++;
  458. }
  459. // Extra fields
  460. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  461. {
  462. foreach($extrafields->attribute_label as $key => $val)
  463. {
  464. if (! empty($arrayfields["ef.".$key]['checked']))
  465. {
  466. print '<td';
  467. $align=$extrafields->getAlignFlag($key);
  468. if ($align) print ' align="'.$align.'"';
  469. print '>';
  470. $tmpkey='options_'.$key;
  471. print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
  472. print '</td>';
  473. if (! $i) $totalarray['nbfield']++;
  474. }
  475. }
  476. }
  477. // Fields from hook
  478. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  479. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  480. print $hookmanager->resPrint;
  481. // Date creation
  482. if (! empty($arrayfields['b.datec']['checked']))
  483. {
  484. print '<td align="center">';
  485. print dol_print_date($acc->date_creation, 'dayhour');
  486. print '</td>';
  487. if (! $i) $totalarray['nbfield']++;
  488. }
  489. // Date modification
  490. if (! empty($arrayfields['b.tms']['checked']))
  491. {
  492. print '<td align="center">';
  493. print dol_print_date($acc->date_update, 'dayhour');
  494. print '</td>';
  495. if (! $i) $totalarray['nbfield']++;
  496. }
  497. // Statut
  498. if (! empty($arrayfields['b.clos']['checked']))
  499. {
  500. print '<td align="center">'.$acc->getLibStatut(5).'</td>';
  501. if (! $i) $totalarray['nbfield']++;
  502. }
  503. // Balance
  504. if (! empty($arrayfields['balance']['checked']))
  505. {
  506. print '<td align="right">';
  507. print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?id='.$acc->id.'">'.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).'</a>';
  508. print '</td>';
  509. if (! $i) $totalarray['nbfield']++;
  510. if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield'];
  511. $totalarray['totalbalance'] += $solde;
  512. }
  513. // Action column
  514. print '<td class="nowrap" align="center">';
  515. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  516. {
  517. $selected=0;
  518. if (in_array($obj->rowid, $arrayofselected)) $selected=1;
  519. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
  520. }
  521. print '</td>';
  522. if (! $i) $totalarray['nbfield']++;
  523. print '</tr>';
  524. $total[$acc->currency_code] += $solde;
  525. $i++;
  526. }
  527. if (! $found) print '<tr class="oddeven"><td colspan="'.$totalarray['nbfield'].'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  528. // Show total line
  529. if (isset($totalarray['totalbalancefield']) && $lastcurrencycode != 'various') // If there is several currency, $lastcurrencycode is set to 'various' before
  530. {
  531. print '<tr class="liste_total">';
  532. $i=0;
  533. while ($i < $totalarray['nbfield'])
  534. {
  535. $i++;
  536. if ($i == 1)
  537. {
  538. if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
  539. else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
  540. }
  541. elseif ($totalarray['totalbalancefield'] == $i) print '<td align="right">'.price($totalarray['totalbalance'], 0, $langs, 0, 0, -1, $lastcurrencycode).'</td>';
  542. else print '<td></td>';
  543. }
  544. print '</tr>';
  545. }
  546. print '</table>';
  547. print "</div>";
  548. print "</form>";
  549. llxFooter();
  550. $db->close();