list.php 21 KB

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