list.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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 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. $day = GETPOST('day', 'int');
  48. $month = GETPOST('month', 'int');
  49. $year = GETPOST('year', 'int');
  50. // Security check
  51. if ($user->socid) $socid = $user->socid;
  52. $result = restrictedArea($user, 'facture', $facid, '');
  53. $search_ref = GETPOST("search_ref", "alpha");
  54. $search_company = GETPOST("search_company", 'alpha');
  55. $search_paymenttype = GETPOST("search_paymenttype");
  56. $search_account = GETPOST("search_account", "int");
  57. $search_payment_num = GETPOST('search_payment_num', 'alpha');
  58. $search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x"
  59. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  60. $sortfield = GETPOST("sortfield", 'alpha');
  61. $sortorder = GETPOST("sortorder", 'alpha');
  62. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  63. if (empty($page) || $page == -1) {
  64. $page = 0; // If $page is not defined, or '' or -1
  65. }
  66. $offset = $limit * $page;
  67. $pageprev = $page - 1;
  68. $pagenext = $page + 1;
  69. if (!$sortorder) {
  70. $sortorder = "DESC";
  71. }
  72. if (!$sortfield) {
  73. $sortfield = "p.ref";
  74. }
  75. $search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
  76. // List of fields to search into when doing a "search in all"
  77. $fieldstosearchall = array(
  78. 'p.ref'=>"RefPayment",
  79. 's.nom'=>"ThirdParty",
  80. 'p.num_paiement'=>"Numero",
  81. 'p.amount'=>"Amount",
  82. );
  83. $arrayfields = array(
  84. 'p.ref' => array('label'=>"RefPayment", 'checked'=>1, 'position'=>10),
  85. 'p.datep' => array('label'=>"Date", 'checked'=>1, 'position'=>20),
  86. 's.nom' => array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30),
  87. 'c.libelle' => array('label'=>"Type", 'checked'=>1, 'position'=>40),
  88. 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(!empty($conf->banque->enabled))),
  89. 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(!empty($conf->banque->enabled))),
  90. 'p.num_paiement' => array('label'=>"Numero", 'checked'=>1, 'position'=>70, 'tooltip'=>"ChequeOrTransferNumber"),
  91. 'p.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>80),
  92. 'p.statut' => array('label'=>"Status", 'checked'=>1, 'position'=>90, 'enabled'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))),
  93. );
  94. $arrayfields = dol_sort_array($arrayfields, 'position');
  95. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  96. $hookmanager->initHooks(array('paymentlist'));
  97. $object = new Paiement($db);
  98. /*
  99. * Actions
  100. */
  101. $parameters = array('socid'=>$socid);
  102. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  103. if ($reshook < 0) {
  104. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  105. }
  106. if (empty($reshook)) {
  107. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  108. // All tests are required to be compatible with all browsers
  109. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  110. $search_ref = '';
  111. $search_account = '';
  112. $search_amount = '';
  113. $search_paymenttype = '';
  114. $search_payment_num = '';
  115. $search_company = '';
  116. $day = '';
  117. $year = '';
  118. $month = '';
  119. $option = '';
  120. $toselect = '';
  121. $search_array_options = array();
  122. }
  123. }
  124. /*
  125. * View
  126. */
  127. $form = new Form($db);
  128. $formother = new FormOther($db);
  129. $accountstatic = new Account($db);
  130. $companystatic = new Societe($db);
  131. $bankline = new AccountLine($db);
  132. llxHeader('', $langs->trans('ListPayment'));
  133. if (GETPOST("orphelins", "alpha")) {
  134. // Payments not linked to an invoice. Should not happend. For debug only.
  135. $sql = "SELECT p.rowid, p.ref, p.datep, p.amount, p.statut, p.num_paiement";
  136. $sql .= ", c.code as paiement_code";
  137. // Add fields from hooks
  138. $parameters = array();
  139. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  140. $sql .= $hookmanager->resPrint;
  141. $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
  142. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
  143. $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
  144. $sql .= " AND pf.fk_facture IS NULL";
  145. // Add where from hooks
  146. $parameters = array();
  147. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  148. $sql .= $hookmanager->resPrint;
  149. } else {
  150. // DISTINCT is to avoid duplicate when there is a link to sales representatives
  151. $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep, p.fk_bank, p.amount, p.statut, p.num_paiement";
  152. $sql .= ", c.code as paiement_code";
  153. $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";
  154. $sql .= ", s.rowid as socid, s.nom as name, s.email";
  155. // Add fields from hooks
  156. $parameters = array();
  157. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  158. $sql .= $hookmanager->resPrint;
  159. $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
  160. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
  161. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
  162. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
  163. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
  164. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
  165. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
  166. if (!$user->rights->societe->client->voir && !$socid) {
  167. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
  168. }
  169. $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
  170. if (!$user->rights->societe->client->voir && !$socid) {
  171. $sql .= " AND sc.fk_user = ".((int) $user->id);
  172. }
  173. if ($socid > 0) {
  174. $sql .= " AND f.fk_soc = ".((int) $socid);
  175. }
  176. if ($userid) {
  177. if ($userid == -1) {
  178. $sql .= " AND f.fk_user_author IS NULL";
  179. } else {
  180. $sql .= " AND f.fk_user_author = ".((int) $userid);
  181. }
  182. }
  183. // Search criteria
  184. $sql .= dolSqlDateFilter("p.datep", $day, $month, $year);
  185. if ($search_ref) {
  186. $sql .= natural_search('p.ref', $search_ref);
  187. }
  188. if ($search_account > 0) {
  189. $sql .= " AND b.fk_account=".((int) $search_account);
  190. }
  191. if ($search_paymenttype != '') {
  192. $sql .= " AND c.code='".$db->escape($search_paymenttype)."'";
  193. }
  194. if ($search_payment_num != '') {
  195. $sql .= natural_search('p.num_paiement', $search_payment_num);
  196. }
  197. if ($search_amount) {
  198. $sql .= natural_search('p.amount', $search_amount, 1);
  199. }
  200. if ($search_company) {
  201. $sql .= natural_search('s.nom', $search_company);
  202. }
  203. if ($search_all) {
  204. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  205. }
  206. // Add where from hooks
  207. $parameters = array();
  208. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  209. $sql .= $hookmanager->resPrint;
  210. }
  211. $sql .= $db->order($sortfield, $sortorder);
  212. $nbtotalofrecords = '';
  213. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  214. $result = $db->query($sql);
  215. $nbtotalofrecords = $db->num_rows($result);
  216. // if total resultset is smaller then paging size (filtering), goto and load page 0
  217. if (($page * $limit) > $nbtotalofrecords) {
  218. $page = 0;
  219. $offset = 0;
  220. }
  221. }
  222. $sql .= $db->plimit($limit + 1, $offset);
  223. $resql = $db->query($sql);
  224. if (!$resql) {
  225. dol_print_error($db);
  226. llxFooter();
  227. $db->close();
  228. exit;
  229. }
  230. $num = $db->num_rows($resql);
  231. $param = '';
  232. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  233. $param .= '&contextpage='.urlencode($contextpage);
  234. }
  235. if ($limit > 0 && $limit != $conf->liste_limit) {
  236. $param .= '&limit='.urlencode($limit);
  237. }
  238. $param .= (GETPOST("orphelins") ? "&orphelins=1" : '');
  239. $param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : '');
  240. $param .= ($search_company ? "&search_company=".urlencode($search_company) : '');
  241. $param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : '');
  242. $param .= ($search_paymenttype ? "&search_paymenttype=".urlencode($search_paymenttype) : '');
  243. $param .= ($search_account ? "&search_account=".urlencode($search_account) : '');
  244. $param .= ($day ? "&day=".urlencode($day) : '');
  245. $param .= ($month ? "&month=".urlencode($month) : '');
  246. $param .= ($year ? "&year=".urlencode($year) : '');
  247. $param .= ($search_payment_num ? "&search_payment_num=".urlencode($search_payment_num) : '');
  248. if ($optioncss != '') {
  249. $param .= '&optioncss='.urlencode($optioncss);
  250. }
  251. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  252. if ($optioncss != '') {
  253. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  254. }
  255. print '<input type="hidden" name="token" value="'.newToken().'">';
  256. print '<input type="hidden" name="action" value="list">';
  257. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  258. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  259. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  260. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  261. print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
  262. if ($search_all) {
  263. foreach ($fieldstosearchall as $key => $val) {
  264. $fieldstosearchall[$key] = $langs->trans($val);
  265. }
  266. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  267. }
  268. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  269. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  270. if ($massactionbutton) {
  271. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  272. }
  273. print '<div class="div-table-responsive">';
  274. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
  275. print '<tr class="liste_titre_filter">';
  276. // Filters: Lines (placeholder)
  277. print '<tr class="liste_titre_filter">';
  278. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  279. print '<td class="liste_titre">';
  280. print '</td>';
  281. }
  282. // Filter: Ref
  283. if (!empty($arrayfields['p.ref']['checked'])) {
  284. print '<td class="liste_titre left">';
  285. print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  286. print '</td>';
  287. }
  288. // Filter: Date
  289. if (!empty($arrayfields['p.datep']['checked'])) {
  290. print '<td class="liste_titre center">';
  291. if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
  292. print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">';
  293. }
  294. print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month" value="'.dol_escape_htmltag($month).'">';
  295. $formother->select_year($year ? $year : -1, 'year', 1, 20, 5);
  296. print '</td>';
  297. }
  298. // Filter: Thirdparty
  299. if (!empty($arrayfields['s.nom']['checked'])) {
  300. print '<td class="liste_titre">';
  301. print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
  302. print '</td>';
  303. }
  304. // Filter: Payment type
  305. if (!empty($arrayfields['c.libelle']['checked'])) {
  306. print '<td class="liste_titre">';
  307. $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1);
  308. print '</td>';
  309. }
  310. // Filter: Bank transaction number
  311. if (!empty($arrayfields['transaction']['checked'])) {
  312. print '<td class="liste_titre">';
  313. print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
  314. print '</td>';
  315. }
  316. // Filter: Cheque number (fund transfer)
  317. if (!empty($arrayfields['p.num_paiement']['checked'])) {
  318. print '<td class="liste_titre">';
  319. print '</td>';
  320. }
  321. // Filter: Bank account
  322. if (!empty($arrayfields['ba.label']['checked'])) {
  323. print '<td class="liste_titre">';
  324. $form->select_comptes($search_account, 'search_account', 0, '', 1);
  325. print '</td>';
  326. }
  327. // Filter: Amount
  328. if (!empty($arrayfields['p.amount']['checked'])) {
  329. print '<td class="liste_titre right">';
  330. print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
  331. print '</td>';
  332. }
  333. // Filter: Status (only placeholder)
  334. if (!empty($arrayfields['p.statut']['checked'])) {
  335. print '<td class="liste_titre right">';
  336. print '</td>';
  337. }
  338. // Fields from hook
  339. $parameters = array('arrayfields'=>$arrayfields);
  340. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  341. print $hookmanager->resPrint;
  342. print '<td class="liste_titre maxwidthsearch">';
  343. print $form->showFilterAndCheckAddButtons(0);
  344. print '</td>';
  345. print "</tr>";
  346. print '<tr class="liste_titre">';
  347. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  348. print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
  349. }
  350. if (!empty($arrayfields['p.ref']['checked'])) {
  351. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
  352. }
  353. if (!empty($arrayfields['p.datep']['checked'])) {
  354. print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], "p.datep", '', $param, '', $sortfield, $sortorder, 'center ');
  355. }
  356. if (!empty($arrayfields['s.nom']['checked'])) {
  357. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
  358. }
  359. if (!empty($arrayfields['c.libelle']['checked'])) {
  360. print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", '', $param, '', $sortfield, $sortorder);
  361. }
  362. if (!empty($arrayfields['p.num_paiement']['checked'])) {
  363. print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
  364. }
  365. if (!empty($arrayfields['transaction']['checked'])) {
  366. print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
  367. }
  368. if (!empty($arrayfields['ba.label']['checked'])) {
  369. print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", '', $param, '', $sortfield, $sortorder);
  370. }
  371. if (!empty($arrayfields['p.amount']['checked'])) {
  372. print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], "p.amount", '', $param, 'class="right"', $sortfield, $sortorder);
  373. }
  374. if (!empty($arrayfields['p.statut']['checked'])) {
  375. print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", '', $param, 'class="right"', $sortfield, $sortorder);
  376. }
  377. // Hook fields
  378. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  379. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  380. print $hookmanager->resPrint;
  381. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  382. print "</tr>";
  383. $checkedCount = 0;
  384. foreach ($arrayfields as $column) {
  385. if ($column['checked']) {
  386. $checkedCount++;
  387. }
  388. }
  389. $i = 0;
  390. $totalarray = array();
  391. while ($i < min($num, $limit)) {
  392. $objp = $db->fetch_object($resql);
  393. $object->id = $objp->rowid;
  394. $object->ref = ($objp->ref ? $objp->ref : $objp->rowid);
  395. $companystatic->id = $objp->socid;
  396. $companystatic->name = $objp->name;
  397. $companystatic->email = $objp->email;
  398. print '<tr class="oddeven">';
  399. // No
  400. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  401. print '<td>'.(($offset * $limit) + $i).'</td>';
  402. if (!$i) {
  403. $totalarray['nbfield']++;
  404. }
  405. }
  406. // Ref
  407. if (!empty($arrayfields['p.ref']['checked'])) {
  408. print '<td>'.$object->getNomUrl(1).'</td>';
  409. if (!$i) {
  410. $totalarray['nbfield']++;
  411. }
  412. }
  413. // Date
  414. if (!empty($arrayfields['p.datep']['checked'])) {
  415. $dateformatforpayment = 'day';
  416. if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) {
  417. $dateformatforpayment = 'dayhour';
  418. }
  419. print '<td class="center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
  420. if (!$i) {
  421. $totalarray['nbfield']++;
  422. }
  423. }
  424. // Thirdparty
  425. if (!empty($arrayfields['s.nom']['checked'])) {
  426. print '<td>';
  427. if ($objp->socid > 0) {
  428. print $companystatic->getNomUrl(1, '', 24);
  429. }
  430. print '</td>';
  431. if (!$i) {
  432. $totalarray['nbfield']++;
  433. }
  434. }
  435. // Payment type
  436. if (!empty($arrayfields['c.libelle']['checked'])) {
  437. print '<td>'.$langs->trans("PaymentTypeShort".$objp->paiement_code).'</td>';
  438. if (!$i) {
  439. $totalarray['nbfield']++;
  440. }
  441. }
  442. // Filter: Cheque number (fund transfer)
  443. if (!empty($arrayfields['p.num_paiement']['checked'])) {
  444. print '<td>'.$objp->num_paiement.'</td>';
  445. if (!$i) {
  446. $totalarray['nbfield']++;
  447. }
  448. }
  449. // Bank transaction
  450. if (!empty($arrayfields['transaction']['checked'])) {
  451. $bankline->fetch($objp->fk_bank);
  452. print '<td>'.$bankline->getNomUrl(1, 0).'</td>';
  453. if (!$i) {
  454. $totalarray['nbfield']++;
  455. }
  456. }
  457. // Bank account
  458. if (!empty($arrayfields['ba.label']['checked'])) {
  459. print '<td>';
  460. if ($objp->bid > 0) {
  461. $accountstatic->id = $objp->bid;
  462. $accountstatic->ref = $objp->bref;
  463. $accountstatic->label = $objp->blabel;
  464. $accountstatic->number = $objp->number;
  465. $accountstatic->account_number = $objp->account_number;
  466. $accountingjournal = new AccountingJournal($db);
  467. $accountingjournal->fetch($objp->accountancy_journal);
  468. $accountstatic->accountancy_journal = $accountingjournal->code;
  469. print $accountstatic->getNomUrl(1);
  470. }
  471. print '</td>';
  472. if (!$i) {
  473. $totalarray['nbfield']++;
  474. }
  475. }
  476. // Amount
  477. if (!empty($arrayfields['p.amount']['checked'])) {
  478. print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
  479. if (!$i) {
  480. $totalarray['nbfield']++;
  481. }
  482. $totalarray['pos'][$checkedCount] = 'amount';
  483. $totalarray['val']['amount'] += $objp->amount;
  484. }
  485. // Status
  486. if (!empty($arrayfields['p.statut']['checked'])) {
  487. print '<td class="right">';
  488. if ($objp->statut == 0) {
  489. print '<a href="card.php?id='.$objp->rowid.'&amp;action=valide">';
  490. }
  491. print $object->LibStatut($objp->statut, 5);
  492. if ($objp->statut == 0) {
  493. print '</a>';
  494. }
  495. print '</td>';
  496. if (!$i) {
  497. $totalarray['nbfield']++;
  498. }
  499. }
  500. // Buttons
  501. print '<td></td>';
  502. if (!$i) {
  503. $totalarray['nbfield']++;
  504. }
  505. print '</tr>';
  506. $i++;
  507. }
  508. // Show total line
  509. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  510. // If no record found
  511. if ($num == 0) {
  512. $colspan = 1;
  513. foreach ($arrayfields as $key => $val) {
  514. if (!empty($val['checked'])) {
  515. $colspan++;
  516. }
  517. }
  518. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  519. }
  520. print "</table>";
  521. print "</div>";
  522. print "</form>";
  523. // End of page
  524. llxFooter();
  525. $db->close();