list.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. <?php
  2. /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  6. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  7. * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2017-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
  9. * Copyright (C) 2018-2021 Ferran Marcet <fmarcet@2byte.es>
  10. * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
  11. * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 3 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  25. */
  26. /**
  27. * \file htdocs/compta/paiement/list.php
  28. * \ingroup compta
  29. * \brief Payment page for customer invoices
  30. */
  31. require '../../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  36. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
  37. // Load translation files required by the page
  38. $langs->loadLangs(array('bills', 'banks', 'compta', 'companies'));
  39. $action = GETPOST('action', 'alpha');
  40. $massaction = GETPOST('massaction', 'alpha');
  41. $confirm = GETPOST('confirm', 'alpha');
  42. $optioncss = GETPOST('optioncss', 'alpha');
  43. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'paymentlist';
  44. $facid = GETPOST('facid', 'int');
  45. $socid = GETPOST('socid', 'int');
  46. $userid = GETPOST('userid', 'int');
  47. // Security check
  48. if ($user->socid) $socid = $user->socid;
  49. $result = restrictedArea($user, 'facture', $facid, '');
  50. $search_ref = GETPOST("search_ref", "alpha");
  51. $search_date_startday = GETPOST('search_date_startday', 'int');
  52. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  53. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  54. $search_date_endday = GETPOST('search_date_endday', 'int');
  55. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  56. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  57. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
  58. $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
  59. $search_company = GETPOST("search_company", 'alpha');
  60. $search_paymenttype = GETPOST("search_paymenttype");
  61. $search_account = GETPOST("search_account", "int");
  62. $search_payment_num = GETPOST('search_payment_num', 'alpha');
  63. $search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x"
  64. $search_status = GETPOST('search_status', 'intcomma');
  65. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  66. $sortfield = GETPOST('sortfield', 'aZ09comma');
  67. $sortorder = GETPOST('sortorder', 'aZ09comma');
  68. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  69. if (empty($page) || $page == -1) {
  70. $page = 0; // If $page is not defined, or '' or -1
  71. }
  72. $offset = $limit * $page;
  73. $pageprev = $page - 1;
  74. $pagenext = $page + 1;
  75. if (!$sortorder) {
  76. $sortorder = "DESC";
  77. }
  78. if (!$sortfield) {
  79. $sortfield = "p.ref";
  80. }
  81. $search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
  82. // List of fields to search into when doing a "search in all"
  83. $fieldstosearchall = array(
  84. 'p.ref'=>"RefPayment",
  85. 's.nom'=>"ThirdParty",
  86. 'p.num_paiement'=>"Numero",
  87. 'p.amount'=>"Amount",
  88. );
  89. $arrayfields = array(
  90. 'p.ref' => array('label'=>"RefPayment", 'checked'=>1, 'position'=>10),
  91. 'p.datep' => array('label'=>"Date", 'checked'=>1, 'position'=>20),
  92. 's.nom' => array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30),
  93. 'c.libelle' => array('label'=>"Type", 'checked'=>1, 'position'=>40),
  94. 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(!empty($conf->banque->enabled))),
  95. 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(!empty($conf->banque->enabled))),
  96. 'p.num_paiement' => array('label'=>"Numero", 'checked'=>1, 'position'=>70, 'tooltip'=>"ChequeOrTransferNumber"),
  97. 'p.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>80),
  98. 'p.statut' => array('label'=>"Status", 'checked'=>1, 'position'=>90, 'enabled'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))),
  99. );
  100. $arrayfields = dol_sort_array($arrayfields, 'position');
  101. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  102. $hookmanager->initHooks(array('paymentlist'));
  103. $object = new Paiement($db);
  104. /*
  105. * Actions
  106. */
  107. $parameters = array('socid'=>$socid);
  108. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  109. if ($reshook < 0) {
  110. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  111. }
  112. if (empty($reshook)) {
  113. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  114. // All tests are required to be compatible with all browsers
  115. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  116. $search_ref = '';
  117. $search_date_startday = '';
  118. $search_date_startmonth = '';
  119. $search_date_startyear = '';
  120. $search_date_endday = '';
  121. $search_date_endmonth = '';
  122. $search_date_endyear = '';
  123. $search_date_start = '';
  124. $search_date_end = '';
  125. $search_account = '';
  126. $search_amount = '';
  127. $search_paymenttype = '';
  128. $search_payment_num = '';
  129. $search_company = '';
  130. $search_status = '';
  131. $option = '';
  132. $toselect = array();
  133. $search_array_options = array();
  134. }
  135. }
  136. /*
  137. * View
  138. */
  139. $form = new Form($db);
  140. $formother = new FormOther($db);
  141. $accountstatic = new Account($db);
  142. $companystatic = new Societe($db);
  143. $bankline = new AccountLine($db);
  144. llxHeader('', $langs->trans('ListPayment'));
  145. if (GETPOST("orphelins", "alpha")) {
  146. // Payments not linked to an invoice. Should not happend. For debug only.
  147. $sql = "SELECT p.rowid, p.ref, p.datep, p.amount, p.statut, p.num_paiement";
  148. $sql .= ", c.code as paiement_code";
  149. // Add fields from hooks
  150. $parameters = array();
  151. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  152. $sql .= $hookmanager->resPrint;
  153. $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
  154. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
  155. $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
  156. $sql .= " AND pf.fk_facture IS NULL";
  157. // Add where from hooks
  158. $parameters = array();
  159. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  160. $sql .= $hookmanager->resPrint;
  161. } else {
  162. // DISTINCT is to avoid duplicate when there is a link to sales representatives
  163. $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep, p.fk_bank, p.amount, p.statut, p.num_paiement";
  164. $sql .= ", c.code as paiement_code";
  165. $sql .= ", ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.fk_accountancy_journal as accountancy_journal";
  166. $sql .= ", s.rowid as socid, s.nom as name, s.email";
  167. // Add fields from hooks
  168. $parameters = array();
  169. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  170. $sql .= $hookmanager->resPrint;
  171. $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
  172. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
  173. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
  174. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
  175. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
  176. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
  177. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
  178. if (empty($user->rights->societe->client->voir) && !$socid) {
  179. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
  180. }
  181. $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
  182. if (empty($user->rights->societe->client->voir) && !$socid) {
  183. $sql .= " AND sc.fk_user = ".((int) $user->id);
  184. }
  185. if ($socid > 0) {
  186. $sql .= " AND f.fk_soc = ".((int) $socid);
  187. }
  188. if ($userid) {
  189. if ($userid == -1) {
  190. $sql .= " AND f.fk_user_author IS NULL";
  191. } else {
  192. $sql .= " AND f.fk_user_author = ".((int) $userid);
  193. }
  194. }
  195. // Search criteria
  196. if ($search_ref) {
  197. $sql .= natural_search('p.ref', $search_ref);
  198. }
  199. if ($search_date_start) {
  200. $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
  201. }
  202. if ($search_date_end) {
  203. $sql .= " AND p.datep <= '" . $db->idate($search_date_end) . "'";
  204. }
  205. if ($search_account > 0) {
  206. $sql .= " AND b.fk_account=".((int) $search_account);
  207. }
  208. if ($search_paymenttype != '') {
  209. $sql .= " AND c.code='".$db->escape($search_paymenttype)."'";
  210. }
  211. if ($search_payment_num != '') {
  212. $sql .= natural_search('p.num_paiement', $search_payment_num);
  213. }
  214. if ($search_amount) {
  215. $sql .= natural_search('p.amount', $search_amount, 1);
  216. }
  217. if ($search_company) {
  218. $sql .= natural_search('s.nom', $search_company);
  219. }
  220. if ($search_all) {
  221. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  222. }
  223. // Add where from hooks
  224. $parameters = array();
  225. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  226. $sql .= $hookmanager->resPrint;
  227. }
  228. $sql .= $db->order($sortfield, $sortorder);
  229. $nbtotalofrecords = '';
  230. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  231. $result = $db->query($sql);
  232. $nbtotalofrecords = $db->num_rows($result);
  233. // if total resultset is smaller then paging size (filtering), goto and load page 0
  234. if (($page * $limit) > $nbtotalofrecords) {
  235. $page = 0;
  236. $offset = 0;
  237. }
  238. }
  239. $sql .= $db->plimit($limit + 1, $offset);
  240. $resql = $db->query($sql);
  241. if (!$resql) {
  242. dol_print_error($db);
  243. llxFooter();
  244. $db->close();
  245. exit;
  246. }
  247. $num = $db->num_rows($resql);
  248. $param = '';
  249. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  250. $param .= '&contextpage='.urlencode($contextpage);
  251. }
  252. if ($limit > 0 && $limit != $conf->liste_limit) {
  253. $param .= '&limit='.urlencode($limit);
  254. }
  255. if (GETPOST("orphelins")) {
  256. $param .= '&orphelins=1';
  257. }
  258. if ($search_ref) {
  259. $param .= '&search_ref='.urlencode($search_ref);
  260. }
  261. if ($search_date_startday) {
  262. $param .= '&search_date_startday='.urlencode($search_date_startday);
  263. }
  264. if ($search_date_startmonth) {
  265. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  266. }
  267. if ($search_date_startyear) {
  268. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  269. }
  270. if ($search_date_endday) {
  271. $param .= '&search_date_endday='.urlencode($search_date_endday);
  272. }
  273. if ($search_date_endmonth) {
  274. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  275. }
  276. if ($search_date_endyear) {
  277. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  278. }
  279. if ($search_company) {
  280. $param .= '&search_company='.urlencode($search_company);
  281. }
  282. if ($search_amount != '') {
  283. $param .= '&search_amount='.urlencode($search_amount);
  284. }
  285. if ($search_paymenttype) {
  286. $param .= '&search_paymenttype='.urlencode($search_paymenttype);
  287. }
  288. if ($search_account) {
  289. $param .= '&search_account='.urlencode($search_account);
  290. }
  291. if ($search_payment_num) {
  292. $param .= '&search_payment_num='.urlencode($search_payment_num);
  293. }
  294. if ($optioncss != '') {
  295. $param .= '&optioncss='.urlencode($optioncss);
  296. }
  297. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  298. if ($optioncss != '') {
  299. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  300. }
  301. print '<input type="hidden" name="token" value="'.newToken().'">';
  302. print '<input type="hidden" name="action" value="list">';
  303. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  304. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  305. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  306. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  307. print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
  308. if ($search_all) {
  309. foreach ($fieldstosearchall as $key => $val) {
  310. $fieldstosearchall[$key] = $langs->trans($val);
  311. }
  312. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  313. }
  314. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  315. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  316. $massactionbutton = '';
  317. if ($massactionbutton) {
  318. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  319. }
  320. $moreforfilter = '';
  321. print '<div class="div-table-responsive">';
  322. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
  323. print '<tr class="liste_titre_filter">';
  324. // Filters: Lines (placeholder)
  325. print '<tr class="liste_titre_filter">';
  326. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  327. print '<td class="liste_titre">';
  328. print '</td>';
  329. }
  330. // Filter: Ref
  331. if (!empty($arrayfields['p.ref']['checked'])) {
  332. print '<td class="liste_titre left">';
  333. print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  334. print '</td>';
  335. }
  336. // Filter: Date
  337. if (!empty($arrayfields['p.datep']['checked'])) {
  338. print '<td class="liste_titre center">';
  339. print '<div class="nowrap">';
  340. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  341. print '</div>';
  342. print '<div class="nowrap">';
  343. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  344. print '</div>';
  345. print '</td>';
  346. }
  347. // Filter: Thirdparty
  348. if (!empty($arrayfields['s.nom']['checked'])) {
  349. print '<td class="liste_titre">';
  350. print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
  351. print '</td>';
  352. }
  353. // Filter: Payment type
  354. if (!empty($arrayfields['c.libelle']['checked'])) {
  355. print '<td class="liste_titre">';
  356. $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1);
  357. print '</td>';
  358. }
  359. // Filter: Bank transaction number
  360. if (!empty($arrayfields['transaction']['checked'])) {
  361. print '<td class="liste_titre">';
  362. print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
  363. print '</td>';
  364. }
  365. // Filter: Cheque number (fund transfer)
  366. if (!empty($arrayfields['p.num_paiement']['checked'])) {
  367. print '<td class="liste_titre">';
  368. print '</td>';
  369. }
  370. // Filter: Bank account
  371. if (!empty($arrayfields['ba.label']['checked'])) {
  372. print '<td class="liste_titre">';
  373. $form->select_comptes($search_account, 'search_account', 0, '', 1);
  374. print '</td>';
  375. }
  376. // Filter: Amount
  377. if (!empty($arrayfields['p.amount']['checked'])) {
  378. print '<td class="liste_titre right">';
  379. print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
  380. print '</td>';
  381. }
  382. // Filter: Status (only placeholder)
  383. if (!empty($arrayfields['p.statut']['checked'])) {
  384. print '<td class="liste_titre right">';
  385. print '</td>';
  386. }
  387. // Fields from hook
  388. $parameters = array('arrayfields'=>$arrayfields);
  389. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  390. print $hookmanager->resPrint;
  391. print '<td class="liste_titre maxwidthsearch">';
  392. print $form->showFilterAndCheckAddButtons(0);
  393. print '</td>';
  394. print "</tr>";
  395. print '<tr class="liste_titre">';
  396. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  397. print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
  398. }
  399. if (!empty($arrayfields['p.ref']['checked'])) {
  400. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
  401. }
  402. if (!empty($arrayfields['p.datep']['checked'])) {
  403. print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], "p.datep", '', $param, '', $sortfield, $sortorder, 'center ');
  404. }
  405. if (!empty($arrayfields['s.nom']['checked'])) {
  406. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
  407. }
  408. if (!empty($arrayfields['c.libelle']['checked'])) {
  409. print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", '', $param, '', $sortfield, $sortorder);
  410. }
  411. if (!empty($arrayfields['p.num_paiement']['checked'])) {
  412. print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
  413. }
  414. if (!empty($arrayfields['transaction']['checked'])) {
  415. print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
  416. }
  417. if (!empty($arrayfields['ba.label']['checked'])) {
  418. print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", '', $param, '', $sortfield, $sortorder);
  419. }
  420. if (!empty($arrayfields['p.amount']['checked'])) {
  421. print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], "p.amount", '', $param, 'class="right"', $sortfield, $sortorder);
  422. }
  423. if (!empty($arrayfields['p.statut']['checked'])) {
  424. print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", '', $param, 'class="right"', $sortfield, $sortorder);
  425. }
  426. // Hook fields
  427. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  428. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  429. print $hookmanager->resPrint;
  430. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  431. print "</tr>";
  432. $checkedCount = 0;
  433. foreach ($arrayfields as $column) {
  434. if ($column['checked']) {
  435. $checkedCount++;
  436. }
  437. }
  438. $i = 0;
  439. $totalarray = array();
  440. while ($i < min($num, $limit)) {
  441. $objp = $db->fetch_object($resql);
  442. $object->id = $objp->rowid;
  443. $object->ref = ($objp->ref ? $objp->ref : $objp->rowid);
  444. $companystatic->id = $objp->socid;
  445. $companystatic->name = $objp->name;
  446. $companystatic->email = $objp->email;
  447. print '<tr class="oddeven">';
  448. // No
  449. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  450. print '<td>'.(($offset * $limit) + $i).'</td>';
  451. if (!$i) {
  452. $totalarray['nbfield']++;
  453. }
  454. }
  455. // Ref
  456. if (!empty($arrayfields['p.ref']['checked'])) {
  457. print '<td>'.$object->getNomUrl(1).'</td>';
  458. if (!$i) {
  459. $totalarray['nbfield']++;
  460. }
  461. }
  462. // Date
  463. if (!empty($arrayfields['p.datep']['checked'])) {
  464. $dateformatforpayment = 'dayhour';
  465. print '<td class="center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment, 'tzuser').'</td>';
  466. if (!$i) {
  467. $totalarray['nbfield']++;
  468. }
  469. }
  470. // Thirdparty
  471. if (!empty($arrayfields['s.nom']['checked'])) {
  472. print '<td>';
  473. if ($objp->socid > 0) {
  474. print $companystatic->getNomUrl(1, '', 24);
  475. }
  476. print '</td>';
  477. if (!$i) {
  478. $totalarray['nbfield']++;
  479. }
  480. }
  481. // Payment type
  482. if (!empty($arrayfields['c.libelle']['checked'])) {
  483. print '<td>'.$langs->trans("PaymentTypeShort".$objp->paiement_code).'</td>';
  484. if (!$i) {
  485. $totalarray['nbfield']++;
  486. }
  487. }
  488. // Filter: Cheque number (fund transfer)
  489. if (!empty($arrayfields['p.num_paiement']['checked'])) {
  490. print '<td>'.$objp->num_paiement.'</td>';
  491. if (!$i) {
  492. $totalarray['nbfield']++;
  493. }
  494. }
  495. // Bank transaction
  496. if (!empty($arrayfields['transaction']['checked'])) {
  497. $bankline->fetch($objp->fk_bank);
  498. print '<td>'.$bankline->getNomUrl(1, 0).'</td>';
  499. if (!$i) {
  500. $totalarray['nbfield']++;
  501. }
  502. }
  503. // Bank account
  504. if (!empty($arrayfields['ba.label']['checked'])) {
  505. print '<td>';
  506. if ($objp->bid > 0) {
  507. $accountstatic->id = $objp->bid;
  508. $accountstatic->ref = $objp->bref;
  509. $accountstatic->label = $objp->blabel;
  510. $accountstatic->number = $objp->number;
  511. $accountstatic->account_number = $objp->account_number;
  512. $accountingjournal = new AccountingJournal($db);
  513. $accountingjournal->fetch($objp->accountancy_journal);
  514. $accountstatic->accountancy_journal = $accountingjournal->code;
  515. print $accountstatic->getNomUrl(1);
  516. }
  517. print '</td>';
  518. if (!$i) {
  519. $totalarray['nbfield']++;
  520. }
  521. }
  522. // Amount
  523. if (!empty($arrayfields['p.amount']['checked'])) {
  524. print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
  525. if (!$i) {
  526. $totalarray['nbfield']++;
  527. }
  528. $totalarray['pos'][$checkedCount] = 'amount';
  529. $totalarray['val']['amount'] += $objp->amount;
  530. }
  531. // Status
  532. if (!empty($arrayfields['p.statut']['checked'])) {
  533. print '<td class="right">';
  534. if ($objp->statut == 0) {
  535. print '<a href="card.php?id='.$objp->rowid.'&amp;action=valide">';
  536. }
  537. print $object->LibStatut($objp->statut, 5);
  538. if ($objp->statut == 0) {
  539. print '</a>';
  540. }
  541. print '</td>';
  542. if (!$i) {
  543. $totalarray['nbfield']++;
  544. }
  545. }
  546. // Buttons
  547. print '<td></td>';
  548. if (!$i) {
  549. $totalarray['nbfield']++;
  550. }
  551. print '</tr>';
  552. $i++;
  553. }
  554. // Show total line
  555. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  556. // If no record found
  557. if ($num == 0) {
  558. $colspan = 1;
  559. foreach ($arrayfields as $key => $val) {
  560. if (!empty($val['checked'])) {
  561. $colspan++;
  562. }
  563. }
  564. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  565. }
  566. print "</table>";
  567. print "</div>";
  568. print "</form>";
  569. // End of page
  570. llxFooter();
  571. $db->close();