list.php 24 KB

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