list.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <?php
  2. /* Copyright (C) 2017-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
  3. * Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  5. * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
  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 <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/compta/bank/various_payment/list.php
  22. * \ingroup bank
  23. * \brief List of various payments
  24. */
  25. require '../../../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  32. // Load translation files required by the page
  33. $langs->loadLangs(array("compta", "banks", "bills", "accountancy"));
  34. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlist'; // To manage different context of search
  35. // Security check
  36. $socid = GETPOST("socid", "int");
  37. if ($user->socid) {
  38. $socid = $user->socid;
  39. }
  40. $optioncss = GETPOST('optioncss', 'alpha');
  41. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  42. $search_ref = GETPOST('search_ref', 'int');
  43. $search_user = GETPOST('search_user', 'alpha');
  44. $search_label = GETPOST('search_label', 'alpha');
  45. $search_datep_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
  46. $search_datep_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
  47. $search_datev_start = dol_mktime(0, 0, 0, GETPOST('search_date_value_startmonth', 'int'), GETPOST('search_date_value_startday', 'int'), GETPOST('search_date_value_startyear', 'int'));
  48. $search_datev_end = dol_mktime(23, 59, 59, GETPOST('search_date_value_endmonth', 'int'), GETPOST('search_date_value_endday', 'int'), GETPOST('search_date_value_endyear', 'int'));
  49. $search_amount_deb = GETPOST('search_amount_deb', 'alpha');
  50. $search_amount_cred = GETPOST('search_amount_cred', 'alpha');
  51. $search_bank_account = GETPOST('search_account', 'int');
  52. $search_bank_entry = GETPOST('search_bank_entry', 'int');
  53. $search_accountancy_account = GETPOST("search_accountancy_account");
  54. if ($search_accountancy_account == - 1) {
  55. $search_accountancy_account = '';
  56. }
  57. $search_accountancy_subledger = GETPOST("search_accountancy_subledger");
  58. if ($search_accountancy_subledger == - 1) {
  59. $search_accountancy_subledger = '';
  60. }
  61. if (empty($search_datep_start)) {
  62. $search_datep_start = GETPOST("search_datep_start", 'int');
  63. }
  64. if (empty($search_datep_end)) {
  65. $search_datep_end = GETPOST("search_datep_end", 'int');
  66. }
  67. if (empty($search_datev_start)) {
  68. $search_datev_start = GETPOST("search_datev_start", 'int');
  69. }
  70. if (empty($search_datev_end)) {
  71. $search_datev_end = GETPOST("search_datev_end", 'int');
  72. }
  73. $search_type_id = GETPOST('search_type_id', 'int');
  74. $sortfield = GETPOST('sortfield', 'aZ09comma');
  75. $sortorder = GETPOST('sortorder', 'aZ09comma');
  76. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  77. if (empty($page) || $page == -1) {
  78. $page = 0;
  79. } // If $page is not defined, or '' or -1
  80. $offset = $limit * $page;
  81. $pageprev = $page - 1;
  82. $pagenext = $page + 1;
  83. if (!$sortfield) {
  84. $sortfield = "v.datep,v.rowid";
  85. }
  86. if (!$sortorder) {
  87. $sortorder = "DESC,DESC";
  88. }
  89. $filtre = GETPOST("filtre", 'alpha');
  90. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
  91. $search_ref = '';
  92. $search_label = '';
  93. $search_datep_start = '';
  94. $search_datep_end = '';
  95. $search_datev_start = '';
  96. $search_datev_end = '';
  97. $search_amount_deb = '';
  98. $search_amount_cred = '';
  99. $search_bank_account = '';
  100. $search_bank_entry = '';
  101. $search_accountancy_account = '';
  102. $search_accountancy_subledger = '';
  103. $search_type_id = '';
  104. }
  105. $search_all = GETPOSTISSET("search_all") ? trim(GETPOST("search_all", 'alpha')) : trim(GETPOST('sall'));
  106. /*
  107. * TODO: fill array "$fields" in "/compta/bank/class/paymentvarious.class.php" and use
  108. *
  109. *
  110. * $object = new PaymentVarious($db);
  111. *
  112. * $search = array();
  113. * foreach ($object->fields as $key => $val)
  114. * {
  115. * if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
  116. * }
  117. * $fieldstosearchall = array();
  118. * foreach ($object->fields as $key => $val)
  119. * {
  120. * if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
  121. * }
  122. *
  123. */
  124. // List of fields to search into when doing a "search in all"
  125. $fieldstosearchall = array(
  126. 'v.rowid'=>"Ref",
  127. 'v.label'=>"Label",
  128. 'v.datep'=>"DatePayment",
  129. 'v.datev'=>"DateValue",
  130. 'v.amount'=>$langs->trans("Debit").", ".$langs->trans("Credit"),
  131. );
  132. // Definition of fields for lists
  133. $arrayfields = array(
  134. 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100),
  135. 'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110),
  136. 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120),
  137. 'datev' =>array('label'=>"DateValue", 'checked'=>-1, 'position'=>130),
  138. 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140),
  139. 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>isModEnabled('project')),
  140. 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>isModEnabled("banque")),
  141. 'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>isModEnabled("banque")),
  142. 'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>isModEnabled('accounting')),
  143. 'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>isModEnabled('accounting')),
  144. 'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500),
  145. 'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510),
  146. );
  147. $arrayfields = dol_sort_array($arrayfields, 'position');
  148. $object = new PaymentVarious($db);
  149. $result = restrictedArea($user, 'banque', '', '', '');
  150. /*
  151. * Actions
  152. */
  153. $parameters = array();
  154. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  155. if ($reshook < 0) {
  156. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  157. }
  158. if (empty($reshook)) {
  159. // Selection of new fields
  160. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  161. }
  162. /*
  163. * View
  164. */
  165. $form = new Form($db);
  166. if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) {
  167. $formaccounting = new FormAccounting($db);
  168. }
  169. if ($arrayfields['bank']['checked'] && isModEnabled('accounting')) {
  170. $accountingjournal = new AccountingJournal($db);
  171. }
  172. if ($arrayfields['ref']['checked']) {
  173. $variousstatic = new PaymentVarious($db);
  174. }
  175. if ($arrayfields['bank']['checked']) {
  176. $accountstatic = new Account($db);
  177. }
  178. if ($arrayfields['project']['checked']) {
  179. $proj = new Project($db);
  180. }
  181. if ($arrayfields['entry']['checked']) {
  182. $bankline = new AccountLine($db);
  183. }
  184. if ($arrayfields['account']['checked']) {
  185. $accountingaccount = new AccountingAccount($db);
  186. }
  187. $sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account, v.fk_projet as fk_project,";
  188. $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,";
  189. $sql .= " pst.code as payment_code";
  190. $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as v";
  191. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id";
  192. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid";
  193. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
  194. $sql .= " WHERE v.entity IN (".getEntity('payment_various').")";
  195. // Search criteria
  196. if ($search_ref) {
  197. $sql .= " AND v.rowid = ".((int) $search_ref);
  198. }
  199. if ($search_label) {
  200. $sql .= natural_search(array('v.label'), $search_label);
  201. }
  202. if ($search_datep_start) {
  203. $sql .= " AND v.datep >= '".$db->idate($search_datep_start)."'";
  204. }
  205. if ($search_datep_end) {
  206. $sql .= " AND v.datep <= '".$db->idate($search_datep_end)."'";
  207. }
  208. if ($search_datev_start) {
  209. $sql .= " AND v.datev >= '".$db->idate($search_datev_start)."'";
  210. }
  211. if ($search_datev_end) {
  212. $sql .= " AND v.datev <= '".$db->idate($search_datev_end)."'";
  213. }
  214. if ($search_amount_deb) {
  215. $sql .= natural_search("v.amount", $search_amount_deb, 1);
  216. }
  217. if ($search_amount_cred) {
  218. $sql .= natural_search("v.amount", $search_amount_cred, 1);
  219. }
  220. if ($search_bank_account > 0) {
  221. $sql .= " AND b.fk_account = ".((int) $search_bank_account);
  222. }
  223. if ($search_bank_entry > 0) {
  224. $sql .= " AND b.fk_account = ".((int) $search_bank_account);
  225. }
  226. if ($search_accountancy_account > 0) {
  227. $sql .= " AND v.accountancy_code = ".((int) $search_accountancy_account);
  228. }
  229. if ($search_accountancy_subledger > 0) {
  230. $sql .= " AND v.subledger_account = ".((int) $search_accountancy_subledger);
  231. }
  232. if ($search_type_id > 0) {
  233. $sql .= " AND v.fk_typepayment=".((int) $search_type_id);
  234. }
  235. if ($search_all) {
  236. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  237. }
  238. $sql .= $db->order($sortfield, $sortorder);
  239. $totalnboflines = 0;
  240. $resql = $db->query($sql);
  241. if ($resql) {
  242. $totalnboflines = $db->num_rows($resql);
  243. }
  244. $sql .= $db->plimit($limit + 1, $offset);
  245. $resql = $db->query($sql);
  246. if ($resql) {
  247. $num = $db->num_rows($resql);
  248. // Direct jump if only one record found
  249. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
  250. $obj = $db->fetch_object($resql);
  251. $id = $obj->rowid;
  252. header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id);
  253. exit;
  254. }
  255. // must be place behind the last "header(...)" call
  256. llxHeader('', $langs->trans("VariousPayments"));
  257. $i = 0;
  258. $total = 0;
  259. $param = '';
  260. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  261. $param .= '&contextpage='.urlencode($contextpage);
  262. }
  263. if ($limit > 0 && $limit != $conf->liste_limit) {
  264. $param .= '&limit='.urlencode($limit);
  265. }
  266. if ($search_ref) {
  267. $param .= '&search_ref='.urlencode($search_ref);
  268. }
  269. if ($search_label) {
  270. $param .= '&search_label='.urlencode($search_label);
  271. }
  272. if ($search_datep_start) {
  273. $param .= '&search_datep_start='.urlencode($search_datep_start);
  274. }
  275. if ($search_datep_end) {
  276. $param .= '&search_datep_end='.urlencode($search_datep_end);
  277. }
  278. if ($search_datev_start) {
  279. $param .= '&search_datev_start='.urlencode($search_datev_start);
  280. }
  281. if ($search_datev_end) {
  282. $param .= '&search_datev_end='.urlencode($search_datev_end);
  283. }
  284. if ($search_type_id > 0) {
  285. $param .= '&search_type_id='.urlencode($search_type_id);
  286. }
  287. if ($search_amount_deb) {
  288. $param .= '&search_amount_deb='.urlencode($search_amount_deb);
  289. }
  290. if ($search_amount_cred) {
  291. $param .= '&search_amount_cred='.urlencode($search_amount_cred);
  292. }
  293. if ($search_bank_account > 0) {
  294. $param .= '&search_account='.urlencode($search_bank_account);
  295. }
  296. if ($search_accountancy_account > 0) {
  297. $param .= '&search_accountancy_account='.urlencode($search_accountancy_account);
  298. }
  299. if ($search_accountancy_subledger > 0) {
  300. $param .= '&search_accountancy_subledger='.urlencode($search_accountancy_subledger);
  301. }
  302. if ($optioncss != '') {
  303. $param .= '&optioncss='.urlencode($optioncss);
  304. }
  305. $url = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create';
  306. if (!empty($socid)) {
  307. $url .= '&socid='.urlencode($socid);
  308. }
  309. $newcardbutton = dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->modifier);
  310. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  311. if ($optioncss != '') {
  312. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  313. }
  314. print '<input type="hidden" name="token" value="'.newToken().'">';
  315. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  316. print '<input type="hidden" name="action" value="list">';
  317. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  318. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  319. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  320. print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
  321. if ($search_all) {
  322. foreach ($fieldstosearchall as $key => $val) {
  323. $fieldstosearchall[$key] = $langs->trans($val);
  324. }
  325. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  326. }
  327. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  328. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  329. $moreforfilter= '';
  330. print '<div class="div-table-responsive">';
  331. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
  332. print '<tr class="liste_titre">';
  333. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  334. print '<td class="liste_titre">';
  335. print '</td>';
  336. }
  337. // Ref
  338. if ($arrayfields['ref']['checked']) {
  339. print '<td class="liste_titre left">';
  340. print '<input class="flat" type="text" size="3" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  341. print '</td>';
  342. }
  343. // Label
  344. if ($arrayfields['label']['checked']) {
  345. print '<td class="liste_titre">';
  346. print '<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
  347. print '</td>';
  348. }
  349. // Payment date
  350. if ($arrayfields['datep']['checked']) {
  351. print '<td class="liste_titre center">';
  352. print '<div class="nowrap">';
  353. print $form->selectDate($search_datep_start ? $search_datep_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  354. print '</div>';
  355. print '<div class="nowrap">';
  356. print $form->selectDate($search_datep_end ? $search_datep_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  357. print '</div>';
  358. print '</td>';
  359. }
  360. // Value date
  361. if ($arrayfields['datev']['checked']) {
  362. print '<td class="liste_titre center">';
  363. print '<div class="nowrap">';
  364. print $form->selectDate($search_datev_start ? $search_datev_start : -1, 'search_date_value_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  365. print '</div>';
  366. print '<div class="nowrap">';
  367. print $form->selectDate($search_datev_end ? $search_datev_end : -1, 'search_date_value_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  368. print '</div>';
  369. print '</td>';
  370. }
  371. // Payment type
  372. if ($arrayfields['type']['checked']) {
  373. print '<td class="liste_titre center">';
  374. print $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, 'maxwidth100', 1);
  375. print '</td>';
  376. }
  377. // Project
  378. if ($arrayfields['project']['checked']) {
  379. print '<td class="liste_titre">';
  380. // TODO
  381. print '</td>';
  382. }
  383. // Bank account
  384. if ($arrayfields['bank']['checked']) {
  385. print '<td class="liste_titre">';
  386. $form->select_comptes($search_bank_account, 'search_account', 0, '', 1, '', 0, 'maxwidth100');
  387. print '</td>';
  388. }
  389. // Bank entry
  390. if ($arrayfields['entry']['checked']) {
  391. print '<td class="liste_titre left">';
  392. print '<input name="search_bank_entry" class="flat maxwidth50" type="text" value="'.dol_escape_htmltag($search_bank_entry).'">';
  393. print '</td>';
  394. }
  395. // Accounting account
  396. if ($arrayfields['account']['checked']) {
  397. print '<td class="liste_titre">';
  398. print '<div class="nowrap">';
  399. print $formaccounting->select_account($search_accountancy_account, 'search_accountancy_account', 1, array(), 1, 1, 'maxwidth200');
  400. print '</div>';
  401. print '</td>';
  402. }
  403. // Subledger account
  404. if ($arrayfields['subledger']['checked']) {
  405. print '<td class="liste_titre">';
  406. print '<div class="nowrap">';
  407. print $formaccounting->select_auxaccount($search_accountancy_subledger, 'search_accountancy_subledger', 1, 'maxwidth200');
  408. print '</div>';
  409. print '</td>';
  410. }
  411. // Debit
  412. if ($arrayfields['debit']['checked']) {
  413. print '<td class="liste_titre right">';
  414. print '<input name="search_amount_deb" class="flat maxwidth50" type="text" value="'.dol_escape_htmltag($search_amount_deb).'">';
  415. print '</td>';
  416. }
  417. // Credit
  418. if ($arrayfields['credit']['checked']) {
  419. print '<td class="liste_titre right">';
  420. print '<input name="search_amount_cred" class="flat maxwidth50" type="text" size="8" value="'.dol_escape_htmltag($search_amount_cred).'">';
  421. print '</td>';
  422. }
  423. print '<td class="liste_titre maxwidthsearch">';
  424. $searchpicto = $form->showFilterAndCheckAddButtons(0);
  425. print $searchpicto;
  426. print '</td>';
  427. print '</tr>';
  428. print '<tr class="liste_titre">';
  429. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  430. print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
  431. }
  432. if ($arrayfields['ref']['checked']) {
  433. print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], 'v.rowid', '', $param, '', $sortfield, $sortorder);
  434. }
  435. if ($arrayfields['label']['checked']) {
  436. print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], 'v.label', '', $param, '', $sortfield, $sortorder);
  437. }
  438. if ($arrayfields['datep']['checked']) {
  439. print_liste_field_titre($arrayfields['datep']['label'], $_SERVER["PHP_SELF"], 'v.datep,v.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
  440. }
  441. if ($arrayfields['datev']['checked']) {
  442. print_liste_field_titre($arrayfields['datev']['label'], $_SERVER["PHP_SELF"], 'v.datev,v.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
  443. }
  444. if ($arrayfields['type']['checked']) {
  445. print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], 'type', '', $param, '', $sortfield, $sortorder, 'center ');
  446. }
  447. if ($arrayfields['project']['checked']) {
  448. print_liste_field_titre($arrayfields['project']['label'], $_SERVER["PHP_SELF"], 'fk_project', '', $param, '', $sortfield, $sortorder);
  449. }
  450. if ($arrayfields['bank']['checked']) {
  451. print_liste_field_titre($arrayfields['bank']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
  452. }
  453. if ($arrayfields['entry']['checked']) {
  454. print_liste_field_titre($arrayfields['entry']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
  455. }
  456. if ($arrayfields['account']['checked']) {
  457. print_liste_field_titre($arrayfields['account']['label'], $_SERVER["PHP_SELF"], 'v.accountancy_code', '', $param, '', $sortfield, $sortorder, 'left ');
  458. }
  459. if ($arrayfields['subledger']['checked']) {
  460. print_liste_field_titre($arrayfields['subledger']['label'], $_SERVER["PHP_SELF"], 'v.subledger_account', '', $param, '', $sortfield, $sortorder, 'left ');
  461. }
  462. if ($arrayfields['debit']['checked']) {
  463. print_liste_field_titre($arrayfields['debit']['label'], $_SERVER["PHP_SELF"], 'v.amount', '', $param, '', $sortfield, $sortorder, 'right ');
  464. }
  465. if ($arrayfields['credit']['checked']) {
  466. print_liste_field_titre($arrayfields['credit']['label'], $_SERVER["PHP_SELF"], 'v.amount', '', $param, '', $sortfield, $sortorder, 'right ');
  467. }
  468. // Fields from hook
  469. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  470. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  471. print $hookmanager->resPrint;
  472. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
  473. print '</tr>';
  474. $totalarray = array();
  475. $totalarray['nbfield'] = 0;
  476. $totalarray['val']['total_cred'] = 0;
  477. $totalarray['val']['total_deb'] = 0;
  478. while ($i < min($num, $limit)) {
  479. $obj = $db->fetch_object($resql);
  480. $variousstatic->id = $obj->rowid;
  481. $variousstatic->ref = $obj->rowid;
  482. $variousstatic->label = $obj->label;
  483. print '<tr class="oddeven">';
  484. // No
  485. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  486. print '<td>'.(($offset * $limit) + $i).'</td>';
  487. }
  488. // Ref
  489. if ($arrayfields['ref']['checked']) {
  490. print '<td>'.$variousstatic->getNomUrl(1)."</td>";
  491. if (!$i) {
  492. $totalarray['nbfield']++;
  493. }
  494. }
  495. // Label payment
  496. if ($arrayfields['label']['checked']) {
  497. print '<td class="tdoverflowmax150" title="'.$variousstatic->label.'">'.$variousstatic->label."</td>";
  498. if (!$i) {
  499. $totalarray['nbfield']++;
  500. }
  501. }
  502. // Date payment
  503. if ($arrayfields['datep']['checked']) {
  504. print '<td class="center">'.dol_print_date($obj->datep, 'day')."</td>";
  505. if (!$i) {
  506. $totalarray['nbfield']++;
  507. }
  508. }
  509. // Date value
  510. if ($arrayfields['datev']['checked']) {
  511. print '<td class="center">'.dol_print_date($obj->datev, 'day')."</td>";
  512. if (!$i) {
  513. $totalarray['nbfield']++;
  514. }
  515. }
  516. // Type
  517. if ($arrayfields['type']['checked']) {
  518. print '<td class="center">';
  519. if ($obj->payment_code) {
  520. print $langs->trans("PaymentTypeShort".$obj->payment_code);
  521. print ' ';
  522. }
  523. print $obj->num_payment;
  524. print '</td>';
  525. if (!$i) {
  526. $totalarray['nbfield']++;
  527. }
  528. }
  529. // Project
  530. if ($arrayfields['project']['checked']) {
  531. print '<td class="nowraponall">';
  532. if ($obj->fk_project > 0) {
  533. $proj->fetch($obj->fk_project);
  534. print $proj->getNomUrl(1);
  535. }
  536. print '</td>';
  537. if (!$i) {
  538. $totalarray['nbfield']++;
  539. }
  540. }
  541. // Bank account
  542. if ($arrayfields['bank']['checked']) {
  543. print '<td class="nowraponall">';
  544. if ($obj->bid > 0) {
  545. $accountstatic->id = $obj->bid;
  546. $accountstatic->ref = $obj->bref;
  547. $accountstatic->number = $obj->bnumber;
  548. if (isModEnabled('accounting')) {
  549. $accountstatic->account_number = $obj->bank_account_number;
  550. $accountingjournal->fetch($obj->accountancy_journal);
  551. $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
  552. }
  553. $accountstatic->label = $obj->blabel;
  554. print $accountstatic->getNomUrl(1);
  555. } else {
  556. print '&nbsp;';
  557. }
  558. print '</td>';
  559. if (!$i) {
  560. $totalarray['nbfield']++;
  561. }
  562. }
  563. // Bank entry
  564. if ($arrayfields['entry']['checked']) {
  565. $bankline->fetch($obj->fk_bank);
  566. print '<td>'.$bankline->getNomUrl(1).'</td>';
  567. if (!$i) {
  568. $totalarray['nbfield']++;
  569. }
  570. }
  571. // Accounting account
  572. if ($arrayfields['account']['checked']) {
  573. $accountingaccount->fetch('', $obj->accountancy_code, 1);
  574. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->accountancy_code.' '.$accountingaccount->label).'">'.$accountingaccount->getNomUrl(0, 1, 1, '', 1).'</td>';
  575. if (!$i) {
  576. $totalarray['nbfield']++;
  577. }
  578. }
  579. // Accounting subledger account
  580. if ($arrayfields['subledger']['checked']) {
  581. print '<td class="tdoverflowmax150">'.length_accounta($obj->subledger_account).'</td>';
  582. if (!$i) {
  583. $totalarray['nbfield']++;
  584. }
  585. }
  586. // Debit
  587. if ($arrayfields['debit']['checked']) {
  588. print '<td class="nowrap right">';
  589. if ($obj->sens == 0) {
  590. print '<span class="amount">'.price($obj->amount).'</span>';
  591. $totalarray['val']['total_deb'] += $obj->amount;
  592. }
  593. if (!$i) {
  594. $totalarray['nbfield']++;
  595. }
  596. if (!$i) {
  597. $totalarray['pos'][$totalarray['nbfield']] = 'total_deb';
  598. }
  599. print '</td>';
  600. }
  601. // Credit
  602. if ($arrayfields['credit']['checked']) {
  603. print '<td class="nowrap right">';
  604. if ($obj->sens == 1) {
  605. print '<span class="amount">'.price($obj->amount).'</span>';
  606. $totalarray['val']['total_cred'] += $obj->amount;
  607. }
  608. if (!$i) {
  609. $totalarray['nbfield']++;
  610. }
  611. if (!$i) {
  612. $totalarray['pos'][$totalarray['nbfield']] = 'total_cred';
  613. }
  614. print '</td>';
  615. }
  616. print '<td></td>';
  617. if (!$i) {
  618. $totalarray['nbfield']++;
  619. }
  620. print '</tr>'."\n";
  621. $i++;
  622. }
  623. // Show total line
  624. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  625. // If no record found
  626. if ($num == 0) {
  627. $colspan = 1;
  628. foreach ($arrayfields as $key => $val) {
  629. if (!empty($val['checked'])) {
  630. $colspan++;
  631. }
  632. }
  633. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  634. }
  635. $db->free($resql);
  636. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  637. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
  638. print $hookmanager->resPrint;
  639. print '</table>'."\n";
  640. print '</div>'."\n";
  641. print '</form>'."\n";
  642. } else {
  643. dol_print_error($db);
  644. }
  645. // End of page
  646. llxFooter();
  647. $db->close();