list.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <?php
  2. /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  4. * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
  6. * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
  7. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  8. * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
  9. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  10. * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
  11. * Copyright (C) 2017-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
  12. * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
  13. * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
  14. * Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License as published by
  18. * the Free Software Foundation; either version 3 of the License, or
  19. * (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  28. */
  29. /**
  30. * \file htdocs/fourn/paiement/list.php
  31. * \ingroup fournisseur,facture
  32. * \brief Payment list for supplier invoices
  33. */
  34. // Load Dolibarr environment
  35. require '../../main.inc.php';
  36. require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  39. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  40. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
  41. // Load translation files required by the page
  42. $langs->loadLangs(array('companies', 'bills', 'banks', 'compta'));
  43. $action = GETPOST('action', 'alpha');
  44. $massaction = GETPOST('massaction', 'alpha');
  45. $optioncss = GETPOST('optioncss', 'alpha');
  46. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist';
  47. $socid = GETPOST('socid', 'int');
  48. // Security check
  49. if ($user->socid) $socid = $user->socid;
  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_payment_type = GETPOST('search_payment_type');
  61. $search_cheque_num = GETPOST('search_cheque_num', 'alpha');
  62. $search_bank_account = GETPOST('search_bank_account', 'int');
  63. $search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
  64. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  65. $sortfield = GETPOST('sortfield', 'aZ09comma');
  66. $sortorder = GETPOST('sortorder', 'aZ09comma');
  67. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
  68. if (empty($page) || $page == -1) {
  69. $page = 0; // If $page is not defined, or '' or -1
  70. }
  71. $offset = $limit * $page;
  72. $pageprev = $page - 1;
  73. $pagenext = $page + 1;
  74. if (!$sortorder) {
  75. $sortorder = "DESC";
  76. }
  77. if (!$sortfield) {
  78. $sortfield = "p.datep";
  79. }
  80. $search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
  81. // List of fields to search into when doing a "search in all"
  82. $fieldstosearchall = array(
  83. 'p.ref'=>"RefPayment",
  84. 's.nom'=>"ThirdParty",
  85. 'p.num_paiement'=>"Numero",
  86. 'p.amount'=>"Amount",
  87. );
  88. $arrayfields = array(
  89. 'p.ref' =>array('label'=>"RefPayment", 'checked'=>1, 'position'=>10),
  90. 'p.datep' =>array('label'=>"Date", 'checked'=>1, 'position'=>20),
  91. 's.nom' =>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30),
  92. 'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40),
  93. 'p.num_paiement' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"),
  94. 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))),
  95. 'p.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70),
  96. );
  97. $arrayfields = dol_sort_array($arrayfields, 'position');
  98. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  99. $hookmanager->initHooks(array('paymentsupplierlist'));
  100. $object = new PaiementFourn($db);
  101. // Security check
  102. if ($user->socid) {
  103. $socid = $user->socid;
  104. }
  105. // doesn't work :-(
  106. // restrictedArea($user, 'fournisseur');
  107. // doesn't work :-(
  108. // require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
  109. // $object = new PaiementFourn($db);
  110. // restrictedArea($user, $object->element);
  111. if ((!isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
  112. || (!isModEnabled('supplier_invoice') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
  113. accessforbidden();
  114. }
  115. if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
  116. || (empty($user->rights->supplier_invoice->lire) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
  117. accessforbidden();
  118. }
  119. /*
  120. * Actions
  121. */
  122. $parameters = array('socid'=>$socid);
  123. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  124. if ($reshook < 0) {
  125. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  126. }
  127. if (empty($reshook)) {
  128. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  129. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  130. $search_ref = '';
  131. $search_date_startday = '';
  132. $search_date_startmonth = '';
  133. $search_date_startyear = '';
  134. $search_date_endday = '';
  135. $search_date_endmonth = '';
  136. $search_date_endyear = '';
  137. $search_date_start = '';
  138. $search_date_end = '';
  139. $search_company = '';
  140. $search_payment_type = '';
  141. $search_cheque_num = '';
  142. $search_bank_account = '';
  143. $search_amount = '';
  144. }
  145. }
  146. /*
  147. * View
  148. */
  149. llxHeader('', $langs->trans('ListPayment'));
  150. $form = new Form($db);
  151. $formother = new FormOther($db);
  152. $accountstatic = new Account($db);
  153. $companystatic = new Societe($db);
  154. $paymentfournstatic = new PaiementFourn($db);
  155. $sql = 'SELECT p.rowid, p.ref, p.datep, p.amount as pamount, p.num_paiement';
  156. $sql .= ', s.rowid as socid, s.nom as name, s.email';
  157. $sql .= ', c.code as paiement_type, c.libelle as paiement_libelle';
  158. $sql .= ', ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal as accountancy_journal';
  159. if (empty($user->rights->societe->client->voir)) {
  160. $sql .= ', sc.fk_soc, sc.fk_user';
  161. }
  162. $sql .= ', SUM(pf.amount)';
  163. $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
  164. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
  165. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
  166. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
  167. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
  168. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
  169. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
  170. if (empty($user->rights->societe->client->voir)) {
  171. $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc';
  172. }
  173. $sql .= ' WHERE f.entity = '.$conf->entity;
  174. if (empty($user->rights->societe->client->voir)) {
  175. $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.((int) $user->id);
  176. }
  177. if ($socid > 0) {
  178. $sql .= ' AND f.fk_soc = '.((int) $socid);
  179. }
  180. if ($search_ref) {
  181. $sql .= natural_search('p.ref', $search_ref);
  182. }
  183. if ($search_date_start) {
  184. $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
  185. }
  186. if ($search_date_end) {
  187. $sql .=" AND p.datep <= '" . $db->idate($search_date_end) . "'";
  188. }
  189. if ($search_company) {
  190. $sql .= natural_search('s.nom', $search_company);
  191. }
  192. if ($search_payment_type != '') {
  193. $sql .= " AND c.code='".$db->escape($search_payment_type)."'";
  194. }
  195. if ($search_cheque_num != '') {
  196. $sql .= natural_search('p.num_paiement', $search_cheque_num);
  197. }
  198. if ($search_amount) {
  199. $sql .= natural_search('p.amount', $search_amount, 1);
  200. }
  201. if ($search_bank_account > 0) {
  202. $sql .= ' AND b.fk_account = '.((int) $search_bank_account);
  203. }
  204. if ($search_all) {
  205. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  206. }
  207. // Add where from extra fields
  208. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  209. $sql .= ' GROUP BY p.rowid, p.ref, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, s.email, c.code, c.libelle,';
  210. $sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
  211. if (empty($user->rights->societe->client->voir)) {
  212. $sql .= ', sc.fk_soc, sc.fk_user';
  213. }
  214. $sql .= $db->order($sortfield, $sortorder);
  215. $nbtotalofrecords = '';
  216. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  217. $result = $db->query($sql);
  218. $nbtotalofrecords = $db->num_rows($result);
  219. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  220. $page = 0;
  221. $offset = 0;
  222. }
  223. }
  224. $sql .= $db->plimit($limit + 1, $offset);
  225. $resql = $db->query($sql);
  226. if (!$resql) {
  227. dol_print_error($db);
  228. llxFooter();
  229. $db->close();
  230. exit;
  231. }
  232. $num = $db->num_rows($resql);
  233. $i = 0;
  234. $param = '';
  235. if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) {
  236. $param .= '&contextpage='.urlencode($contextpage);
  237. }
  238. if ($limit > 0 && $limit != $conf->liste_limit) {
  239. $param .= '&limit='.urlencode($limit);
  240. }
  241. if ($optioncss != '') {
  242. $param .= '&optioncss='.urlencode($optioncss);
  243. }
  244. if ($search_ref) {
  245. $param .= '&search_ref='.urlencode($search_ref);
  246. }
  247. if ($search_date_startday) {
  248. $param .= '&search_date_startday='.urlencode($search_date_startday);
  249. }
  250. if ($search_date_startmonth) {
  251. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  252. }
  253. if ($search_date_startyear) {
  254. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  255. }
  256. if ($search_date_endday) {
  257. $param .= '&search_date_endday='.urlencode($search_date_endday);
  258. }
  259. if ($search_date_endmonth) {
  260. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  261. }
  262. if ($search_date_endyear) {
  263. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  264. }
  265. if ($search_company) {
  266. $param .= '&search_company='.urlencode($search_company);
  267. }
  268. if ($search_payment_type) {
  269. $param .= '&search_company='.urlencode($search_payment_type);
  270. }
  271. if ($search_cheque_num) {
  272. $param .= '&search_cheque_num='.urlencode($search_cheque_num);
  273. }
  274. if ($search_amount) {
  275. $param .= '&search_amount='.urlencode($search_amount);
  276. }
  277. // Add $param from extra fields
  278. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  279. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  280. if ($optioncss != '') {
  281. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  282. }
  283. print '<input type="hidden" name="token" value="'.newToken().'">';
  284. print '<input type="hidden" name="action" value="list">';
  285. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  286. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  287. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  288. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  289. print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1);
  290. if ($search_all) {
  291. foreach ($fieldstosearchall as $key => $val) {
  292. $fieldstosearchall[$key] = $langs->trans($val);
  293. }
  294. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  295. }
  296. $moreforfilter = '';
  297. $parameters = array();
  298. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  299. if (empty($reshook)) {
  300. $moreforfilter .= $hookmanager->resPrint;
  301. } else {
  302. $moreforfilter = $hookmanager->resPrint;
  303. }
  304. if ($moreforfilter) {
  305. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  306. print $moreforfilter;
  307. print '</div>';
  308. }
  309. $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage;
  310. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  311. if (!empty($massactionbutton)) {
  312. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  313. }
  314. print '<div class="div-table-responsive">';
  315. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
  316. print '<tr class="liste_titre_filter">';
  317. // Filter: Ref
  318. if (!empty($arrayfields['p.ref']['checked'])) {
  319. print '<td class="liste_titre left">';
  320. print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  321. print '</td>';
  322. }
  323. // Filter: Date
  324. if (!empty($arrayfields['p.datep']['checked'])) {
  325. print '<td class="liste_titre center">';
  326. print '<div class="nowrap">';
  327. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  328. print '</div>';
  329. print '<div class="nowrap">';
  330. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  331. print '</div>';
  332. print '</td>';
  333. }
  334. // Filter: Thirdparty
  335. if (!empty($arrayfields['s.nom']['checked'])) {
  336. print '<td class="liste_titre">';
  337. print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
  338. print '</td>';
  339. }
  340. // Filter: Payment type
  341. if (!empty($arrayfields['c.libelle']['checked'])) {
  342. print '<td class="liste_titre">';
  343. $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1);
  344. print '</td>';
  345. }
  346. // Filter: Cheque number (fund transfer)
  347. if (!empty($arrayfields['p.num_paiement']['checked'])) {
  348. print '<td class="liste_titre">';
  349. print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
  350. print '</td>';
  351. }
  352. // Filter: Bank account
  353. if (!empty($arrayfields['ba.label']['checked'])) {
  354. print '<td class="liste_titre">';
  355. $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
  356. print '</td>';
  357. }
  358. // Filter: Amount
  359. if (!empty($arrayfields['p.amount']['checked'])) {
  360. print '<td class="liste_titre right">';
  361. print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
  362. print '</td>';
  363. }
  364. // Fields from hook
  365. $parameters = array('arrayfields'=>$arrayfields);
  366. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  367. print $hookmanager->resPrint;
  368. // Buttons
  369. print '<td class="liste_titre maxwidthsearch">';
  370. print $form->showFilterAndCheckAddButtons(0);
  371. print '</td>';
  372. print '</tr>';
  373. print '<tr class="liste_titre">';
  374. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  375. print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
  376. }
  377. if (!empty($arrayfields['p.ref']['checked'])) {
  378. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder);
  379. }
  380. if (!empty($arrayfields['p.datep']['checked'])) {
  381. print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center ');
  382. }
  383. if (!empty($arrayfields['s.nom']['checked'])) {
  384. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
  385. }
  386. if (!empty($arrayfields['c.libelle']['checked'])) {
  387. print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
  388. }
  389. if (!empty($arrayfields['p.num_paiement']['checked'])) {
  390. print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
  391. }
  392. if (!empty($arrayfields['ba.label']['checked'])) {
  393. print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
  394. }
  395. if (!empty($arrayfields['p.amount']['checked'])) {
  396. print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
  397. }
  398. // Hook fields
  399. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  400. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  401. print $hookmanager->resPrint;
  402. print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  403. print '</tr>';
  404. $checkedCount = 0;
  405. foreach ($arrayfields as $column) {
  406. if ($column['checked']) {
  407. $checkedCount++;
  408. }
  409. }
  410. $i = 0;
  411. $totalarray = array();
  412. while ($i < min($num, $limit)) {
  413. $objp = $db->fetch_object($resql);
  414. $paymentfournstatic->id = $objp->rowid;
  415. $paymentfournstatic->ref = $objp->ref;
  416. $paymentfournstatic->datepaye = $objp->datep;
  417. $companystatic->id = $objp->socid;
  418. $companystatic->name = $objp->name;
  419. $companystatic->email = $objp->email;
  420. print '<tr class="oddeven">';
  421. // No
  422. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  423. print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
  424. if (!$i) {
  425. $totalarray['nbfield']++;
  426. }
  427. }
  428. // Ref
  429. if (!empty($arrayfields['p.ref']['checked'])) {
  430. print '<td class="nowraponall">'.$paymentfournstatic->getNomUrl(1).'</td>';
  431. if (!$i) {
  432. $totalarray['nbfield']++;
  433. }
  434. }
  435. // Date
  436. if (!empty($arrayfields['p.datep']['checked'])) {
  437. $dateformatforpayment = 'dayhour';
  438. print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
  439. if (!$i) {
  440. $totalarray['nbfield']++;
  441. }
  442. }
  443. // Thirdparty
  444. if (!empty($arrayfields['s.nom']['checked'])) {
  445. print '<td class="tdoverflowmax125">';
  446. if ($objp->socid > 0) {
  447. print $companystatic->getNomUrl(1, '', 24);
  448. }
  449. print '</td>';
  450. if (!$i) {
  451. $totalarray['nbfield']++;
  452. }
  453. }
  454. // Pyament type
  455. if (!empty($arrayfields['c.libelle']['checked'])) {
  456. $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
  457. print '<td>'.$payment_type.' '.dol_trunc($objp->num_paiement, 32).'</td>';
  458. if (!$i) {
  459. $totalarray['nbfield']++;
  460. }
  461. }
  462. // Cheque number (fund transfer)
  463. if (!empty($arrayfields['p.num_paiement']['checked'])) {
  464. print '<td>'.$objp->num_paiement.'</td>';
  465. if (!$i) {
  466. $totalarray['nbfield']++;
  467. }
  468. }
  469. // Bank account
  470. if (!empty($arrayfields['ba.label']['checked'])) {
  471. print '<td class="tdoverflowmax125">';
  472. if ($objp->bid) {
  473. $accountstatic->id = $objp->bid;
  474. $accountstatic->ref = $objp->bref;
  475. $accountstatic->label = $objp->blabel;
  476. $accountstatic->number = $objp->number;
  477. $accountstatic->iban = $objp->iban_prefix;
  478. $accountstatic->bic = $objp->bic;
  479. $accountstatic->currency_code = $objp->currency_code;
  480. $accountstatic->account_number = $objp->account_number;
  481. $accountingjournal = new AccountingJournal($db);
  482. $accountingjournal->fetch($objp->accountancy_journal);
  483. $accountstatic->accountancy_journal = $accountingjournal->code;
  484. print $accountstatic->getNomUrl(1);
  485. } else {
  486. print '&nbsp;';
  487. }
  488. print '</td>';
  489. if (!$i) {
  490. $totalarray['nbfield']++;
  491. }
  492. }
  493. // Amount
  494. if (!empty($arrayfields['p.amount']['checked'])) {
  495. print '<td class="right"><span class="amount">'.price($objp->pamount).'</span></td>';
  496. if (!$i) {
  497. $totalarray['nbfield']++;
  498. }
  499. $totalarray['pos'][$checkedCount] = 'amount';
  500. $totalarray['val']['amount'] += $objp->pamount;
  501. }
  502. // Buttons
  503. print '<td></td>';
  504. if (!$i) {
  505. $totalarray['nbfield']++;
  506. }
  507. print '</tr>';
  508. $i++;
  509. }
  510. // Show total line
  511. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  512. print '</table>';
  513. print '</div>';
  514. print '</form>';
  515. // End of page
  516. llxFooter();
  517. $db->close();