dolibarr 18.0.6
list.php
Go to the documentation of this file.
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
36// Load Dolibarr environment
37require '../../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
39require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
43
44// Load translation files required by the page
45$langs->loadLangs(array('companies', 'bills', 'banks', 'compta'));
46
47$action = GETPOST('action', 'alpha');
48$massaction = GETPOST('massaction', 'alpha');
49$optioncss = GETPOST('optioncss', 'alpha');
50$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist';
51
52$socid = GETPOST('socid', 'int');
53
54// Security check
55if ($user->socid) $socid = $user->socid;
56
57$search_ref = GETPOST('search_ref', 'alpha');
58$search_date_startday = GETPOST('search_date_startday', 'int');
59$search_date_startmonth = GETPOST('search_date_startmonth', 'int');
60$search_date_startyear = GETPOST('search_date_startyear', 'int');
61$search_date_endday = GETPOST('search_date_endday', 'int');
62$search_date_endmonth = GETPOST('search_date_endmonth', 'int');
63$search_date_endyear = GETPOST('search_date_endyear', 'int');
64$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
65$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
66$search_company = GETPOST('search_company', 'alpha');
67$search_payment_type = GETPOST('search_payment_type');
68$search_cheque_num = GETPOST('search_cheque_num', 'alpha');
69$search_bank_account = GETPOST('search_bank_account', 'int');
70$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
71$search_sale = GETPOST('search_sale', 'int');
72
73$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
74$sortfield = GETPOST('sortfield', 'aZ09comma');
75$sortorder = GETPOST('sortorder', 'aZ09comma');
76$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
77
78if (empty($page) || $page == -1) {
79 $page = 0; // If $page is not defined, or '' or -1
80}
81$offset = $limit * $page;
82$pageprev = $page - 1;
83$pagenext = $page + 1;
84
85if (!$sortorder) {
86 $sortorder = "DESC";
87}
88if (!$sortfield) {
89 $sortfield = "p.datep";
90}
91
92$search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
93
94// List of fields to search into when doing a "search in all"
95$fieldstosearchall = array(
96 'p.ref'=>"RefPayment",
97 's.nom'=>"ThirdParty",
98 'p.num_paiement'=>"Numero",
99 'p.amount'=>"Amount",
100);
101
102$arrayfields = array(
103 'p.ref' =>array('label'=>"RefPayment", 'checked'=>1, 'position'=>10),
104 'p.datep' =>array('label'=>"Date", 'checked'=>1, 'position'=>20),
105 's.nom' =>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30),
106 'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40),
107 'p.num_paiement' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"),
108 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))),
109 'p.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70),
110);
111$arrayfields = dol_sort_array($arrayfields, 'position');
112
113// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
114$hookmanager->initHooks(array('paymentsupplierlist'));
115$object = new PaiementFourn($db);
116
117if (!$user->hasRight('societe', 'client', 'voir')) {
118 $search_sale = $user->id;
119}
120
121// Security check
122if ($user->socid) {
123 $socid = $user->socid;
124}
125
126// doesn't work :-(
127// restrictedArea($user, 'fournisseur');
128// doesn't work :-(
129// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
130// $object = new PaiementFourn($db);
131// restrictedArea($user, $object->element);
132if (!isModEnabled('supplier_invoice')) {
134}
135if ((!$user->hasRight("fournisseur", "facture", "lire") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
136 || (!$user->hasRight("supplier_invoice", "lire") && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
138}
139
140
141/*
142 * Actions
143 */
144
145$parameters = array('socid'=>$socid);
146$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
147if ($reshook < 0) {
148 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
149}
150
151if (empty($reshook)) {
152 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
153
154 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
155 $search_ref = '';
156 $search_date_startday = '';
157 $search_date_startmonth = '';
158 $search_date_startyear = '';
159 $search_date_endday = '';
160 $search_date_endmonth = '';
161 $search_date_endyear = '';
162 $search_date_start = '';
163 $search_date_end = '';
164 $search_company = '';
165 $search_payment_type = '';
166 $search_cheque_num = '';
167 $search_bank_account = '';
168 $search_amount = '';
169 }
170}
171
172/*
173 * View
174 */
175
176llxHeader('', $langs->trans('ListPayment'));
177
178$form = new Form($db);
179$formother = new FormOther($db);
180$accountstatic = new Account($db);
181$companystatic = new Societe($db);
182$paymentfournstatic = new PaiementFourn($db);
183
184$sql = 'SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement, p.amount';
185$sql .= ', c.code as paiement_type, c.libelle as paiement_libelle';
186$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';
187$sql .= ', s.rowid as socid, s.nom as name, s.email';
188// We need an aggregate because we added a left join to get the thirdparty. In real world, it should be the same thirdparty if payment is same (but not in database structure)
189// so SUM(pf.amount) should be equal to p.amount but if we filter on $socid, it may differ
190$sql .= ", SUM(pf.amount) as totalamount, COUNT(f.rowid) as nbinvoices";
191
192$sqlfields = $sql; // $sql fields to remove for count total
193
194$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
195$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
196$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
197$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
198
199$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
200$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
201$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
202
203$sql .= ' WHERE f.entity IN ('.getEntity('supplier_invoice').')'; // TODO We should use p.entity that does not exists yet in this table
204if ($socid > 0) {
205 $sql .= " AND EXISTS (SELECT f.fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
206 $sql .= " WHERE p.rowid = pf.fk_paiementfourn AND pf.fk_facturefourn = f.rowid AND f.fk_soc = ".((int) $socid).")";
207}
208
209// Search criteria
210if ($search_ref) {
211 $sql .= natural_search('p.ref', $search_ref);
212}
213if ($search_date_start) {
214 $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
215}
216if ($search_date_end) {
217 $sql .=" AND p.datep <= '" . $db->idate($search_date_end) . "'";
218}
219
220if ($search_company) {
221 $sql .= natural_search('s.nom', $search_company);
222}
223if ($search_payment_type != '') {
224 $sql .= " AND c.code = '".$db->escape($search_payment_type)."'";
225}
226if ($search_cheque_num != '') {
227 $sql .= natural_search('p.num_paiement', $search_cheque_num);
228}
229if ($search_amount) {
230 $sql .= " AND (".natural_search('p.amount', $search_amount, 1, 1);
231 $sql .= " OR ";
232 $sql .= natural_search('pf.amount', $search_amount, 1, 1);
233 $sql .= ")";
234}
235if ($search_bank_account > 0) {
236 $sql .= ' AND b.fk_account = '.((int) $search_bank_account);
237}
238if ($search_all) {
239 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
240}
241// Search on sale representative
242if ($search_sale && $search_sale != '-1') {
243 if ($search_sale == -2) {
244 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
245 } elseif ($search_sale > 0) {
246 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
247 }
248}
249
250// Add where from extra fields
251include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
252
253$sql .= ' GROUP BY p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement, p.amount, s.rowid, s.nom, s.email, c.code, c.libelle,';
254$sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
255
256// Count total nb of records
257$nbtotalofrecords = '';
258if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
259 /* The fast and low memory method to get and count full list converts the sql into a sql count */
260 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT p.rowid) as nbtotalofrecords', $sql);
261 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
262 $resql = $db->query($sqlforcount);
263 if ($resql) {
264 $objforcount = $db->fetch_object($resql);
265 $nbtotalofrecords = $objforcount->nbtotalofrecords;
266 } else {
267 dol_print_error($db);
268 }
269
270 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
271 $page = 0;
272 $offset = 0;
273 }
274 $db->free($resql);
275}
276
277// Complete request and execute it with limit
278$sql .= $db->order($sortfield, $sortorder);
279if ($limit) {
280 $sql .= $db->plimit($limit + 1, $offset);
281}
282//print $sql;
283
284$resql = $db->query($sql);
285if (!$resql) {
286 dol_print_error($db);
287 llxFooter();
288 $db->close();
289 exit;
290}
291
292$num = $db->num_rows($resql);
293$i = 0;
294
295$param = '';
296if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) {
297 $param .= '&contextpage='.urlencode($contextpage);
298}
299if ($limit > 0 && $limit != $conf->liste_limit) {
300 $param .= '&limit='.((int) $limit);
301}
302if ($optioncss != '') {
303 $param .= '&optioncss='.urlencode($optioncss);
304}
305
306if ($search_ref) {
307 $param .= '&search_ref='.urlencode($search_ref);
308}
309if ($search_date_startday) {
310 $param .= '&search_date_startday='.urlencode($search_date_startday);
311}
312if ($search_date_startmonth) {
313 $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
314}
315if ($search_date_startyear) {
316 $param .= '&search_date_startyear='.urlencode($search_date_startyear);
317}
318if ($search_date_endday) {
319 $param .= '&search_date_endday='.urlencode($search_date_endday);
320}
321if ($search_date_endmonth) {
322 $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
323}
324if ($search_date_endyear) {
325 $param .= '&search_date_endyear='.urlencode($search_date_endyear);
326}
327if ($search_company) {
328 $param .= '&search_company='.urlencode($search_company);
329}
330if ($search_payment_type) {
331 $param .= '&search_company='.urlencode($search_payment_type);
332}
333if ($search_cheque_num) {
334 $param .= '&search_cheque_num='.urlencode($search_cheque_num);
335}
336if ($search_amount) {
337 $param .= '&search_amount='.urlencode($search_amount);
338}
339
340// Add $param from extra fields
341include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
342
343print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
344if ($optioncss != '') {
345 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
346}
347print '<input type="hidden" name="token" value="'.newToken().'">';
348print '<input type="hidden" name="action" value="list">';
349print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
350print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
351print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
352print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
353
354print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1);
355
356if ($search_all) {
357 foreach ($fieldstosearchall as $key => $val) {
358 $fieldstosearchall[$key] = $langs->trans($val);
359 }
360 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
361}
362
363$moreforfilter = '';
364
365$parameters = array();
366$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
367if (empty($reshook)) {
368 $moreforfilter .= $hookmanager->resPrint;
369} else {
370 $moreforfilter = $hookmanager->resPrint;
371}
372
373if ($moreforfilter) {
374 print '<div class="liste_titre liste_titre_bydiv centpercent">';
375 print $moreforfilter;
376 print '</div>';
377}
378
379$varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage;
380$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
381if (!empty($massactionbutton)) {
382 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
383}
384
385print '<div class="div-table-responsive">';
386print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
387
388print '<tr class="liste_titre_filter">';
389
390// Filter: Ref
391if (!empty($arrayfields['p.ref']['checked'])) {
392 print '<td class="liste_titre left">';
393 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
394 print '</td>';
395}
396
397// Filter: Date
398if (!empty($arrayfields['p.datep']['checked'])) {
399 print '<td class="liste_titre center">';
400 print '<div class="nowrap">';
401 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
402 print '</div>';
403 print '<div class="nowrap">';
404 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
405 print '</div>';
406 print '</td>';
407}
408
409// Filter: Thirdparty
410if (!empty($arrayfields['s.nom']['checked'])) {
411 print '<td class="liste_titre">';
412 print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
413 print '</td>';
414}
415
416// Filter: Payment type
417if (!empty($arrayfields['c.libelle']['checked'])) {
418 print '<td class="liste_titre">';
419 $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1);
420 print '</td>';
421}
422
423// Filter: Cheque number (fund transfer)
424if (!empty($arrayfields['p.num_paiement']['checked'])) {
425 print '<td class="liste_titre">';
426 print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
427 print '</td>';
428}
429
430// Filter: Bank account
431if (!empty($arrayfields['ba.label']['checked'])) {
432 print '<td class="liste_titre">';
433 $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
434 print '</td>';
435}
436
437// Filter: Amount
438if (!empty($arrayfields['p.amount']['checked'])) {
439 print '<td class="liste_titre right">';
440 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
441 print '</td>';
442}
443
444// Fields from hook
445$parameters = array('arrayfields'=>$arrayfields);
446$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
447print $hookmanager->resPrint;
448
449// Buttons
450print '<td class="liste_titre maxwidthsearch">';
451print $form->showFilterAndCheckAddButtons(0);
452print '</td>';
453
454print '</tr>';
455
456print '<tr class="liste_titre">';
457if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
458 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
459}
460if (!empty($arrayfields['p.ref']['checked'])) {
461 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder);
462}
463if (!empty($arrayfields['p.datep']['checked'])) {
464 print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center ');
465}
466if (!empty($arrayfields['s.nom']['checked'])) {
467 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
468}
469if (!empty($arrayfields['c.libelle']['checked'])) {
470 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
471}
472if (!empty($arrayfields['p.num_paiement']['checked'])) {
473 print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
474}
475if (!empty($arrayfields['ba.label']['checked'])) {
476 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
477}
478if (!empty($arrayfields['p.amount']['checked'])) {
479 print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
480}
481
482// Hook fields
483$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
484$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
485print $hookmanager->resPrint;
486
487print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
488print '</tr>';
489
490$checkedCount = 0;
491foreach ($arrayfields as $column) {
492 if ($column['checked']) {
493 $checkedCount++;
494 }
495}
496
497$i = 0;
498$totalarray = array();
499while ($i < min($num, $limit)) {
500 $objp = $db->fetch_object($resql);
501
502 $paymentfournstatic->id = $objp->rowid;
503 $paymentfournstatic->ref = $objp->ref;
504 $paymentfournstatic->datepaye = $db->jdate($objp->datep);
505 $paymentfournstatic->amount = $objp->amount;
506
507 $companystatic->id = $objp->socid;
508 $companystatic->name = $objp->name;
509 $companystatic->email = $objp->email;
510
511 print '<tr class="oddeven">';
512
513 // No
514 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
515 print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
516 if (!$i) {
517 $totalarray['nbfield']++;
518 }
519 }
520
521 // Ref
522 if (!empty($arrayfields['p.ref']['checked'])) {
523 print '<td class="nowraponall">';
524 print $paymentfournstatic->getNomUrl(1);
525 print '</td>';
526 if (!$i) {
527 $totalarray['nbfield']++;
528 }
529 }
530
531 // Date
532 if (!empty($arrayfields['p.datep']['checked'])) {
533 $dateformatforpayment = 'dayhour';
534 print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
535 if (!$i) {
536 $totalarray['nbfield']++;
537 }
538 }
539
540 // Thirdparty
541 if (!empty($arrayfields['s.nom']['checked'])) {
542 print '<td class="tdoverflowmax125">';
543 if ($objp->socid > 0) {
544 print $companystatic->getNomUrl(1, '', 24);
545 }
546 print '</td>';
547 if (!$i) {
548 $totalarray['nbfield']++;
549 }
550 }
551
552 // Pyament type
553 if (!empty($arrayfields['c.libelle']['checked'])) {
554 $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
555 print '<td>'.$payment_type.' '.dol_trunc($objp->num_paiement, 32).'</td>';
556 if (!$i) {
557 $totalarray['nbfield']++;
558 }
559 }
560
561 // Cheque number (fund transfer)
562 if (!empty($arrayfields['p.num_paiement']['checked'])) {
563 print '<td>'.$objp->num_paiement.'</td>';
564 if (!$i) {
565 $totalarray['nbfield']++;
566 }
567 }
568
569 // Bank account
570 if (!empty($arrayfields['ba.label']['checked'])) {
571 print '<td class="tdoverflowmax125">';
572 if ($objp->bid) {
573 $accountstatic->id = $objp->bid;
574 $accountstatic->ref = $objp->bref;
575 $accountstatic->label = $objp->blabel;
576 $accountstatic->number = $objp->number;
577 $accountstatic->iban = $objp->iban_prefix;
578 $accountstatic->bic = $objp->bic;
579 $accountstatic->currency_code = $objp->currency_code;
580 $accountstatic->account_number = $objp->account_number;
581
582 $accountingjournal = new AccountingJournal($db);
583 $accountingjournal->fetch($objp->accountancy_journal);
584 $accountstatic->accountancy_journal = $accountingjournal->code;
585
586 print $accountstatic->getNomUrl(1);
587 } else {
588 print '&nbsp;';
589 }
590 print '</td>';
591 if (!$i) {
592 $totalarray['nbfield']++;
593 }
594 }
595
596 // Amount
597 if (!empty($arrayfields['p.amount']['checked'])) {
598 print '<td class="right">';
599 if ($objp->nbinvoices > 1 || ($objp->totalamount && $objp->amount != $objp->totalamount)) {
600 print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
601 }
602 print '<span class="amount">'.price($objp->amount).'</span>';
603 print '</td>';
604 if (!$i) {
605 $totalarray['nbfield']++;
606 }
607 $totalarray['pos'][$checkedCount] = 'amount';
608 $totalarray['val']['amount'] += $objp->amount;
609 }
610
611 // Buttons
612 print '<td></td>';
613 if (!$i) {
614 $totalarray['nbfield']++;
615 }
616
617 print '</tr>';
618 $i++;
619}
620
621// Show total line
622include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
623
624print '</table>';
625print '</div>';
626print '</form>';
627
628// End of page
629llxFooter();
630$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage bank accounts.
Class to manage accounting accounts.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation de composants html autre Only common components are here.
Class to manage payments for supplier invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.