37 require
'../../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
45 $langs->loadLangs(array(
'expensereports',
'bills',
'banks',
'compta'));
47 $action =
GETPOST(
'action',
'alpha');
48 $massaction =
GETPOST(
'massaction',
'alpha');
49 $optioncss =
GETPOST(
'optioncss',
'alpha');
50 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'vendorpaymentlist';
52 $socid =
GETPOST(
'socid',
'int');
55 if ($user->socid) $socid = $user->socid;
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);
65 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
66 $search_user =
GETPOST(
'search_user',
'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');
72 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
73 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
74 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
77 if (empty($page) || $page == -1) {
80 $offset = $limit * $page;
81 $pageprev = $page - 1;
82 $pagenext = $page + 1;
88 $sortfield =
"pndf.datep";
94 $fieldstosearchall = array(
95 'pndf.rowid'=>
"RefPayment",
97 'pndf.num_payment'=>
"Numero",
98 'pndf.amount'=>
"Amount",
101 $arrayfields = array(
102 'pndf.rowid' =>array(
'label'=>
"RefPayment",
'checked'=>1,
'position'=>10),
103 'pndf.datep' =>array(
'label'=>
"Date",
'checked'=>1,
'position'=>20),
104 'u.login' =>array(
'label'=>
"User",
'checked'=>1,
'position'=>30),
105 'c.libelle' =>array(
'label'=>
"Type",
'checked'=>1,
'position'=>40),
106 'pndf.num_payment' =>array(
'label'=>
"Numero",
'checked'=>1,
'position'=>50,
'tooltip'=>
"ChequeOrTransferNumber"),
107 'ba.label' =>array(
'label'=>
"Account",
'checked'=>1,
'position'=>60,
'enable'=>(
isModEnabled(
"banque"))),
108 'pndf.amount' =>array(
'label'=>
"Amount",
'checked'=>1,
'position'=>70),
113 $hookmanager->initHooks(array(
'paymentexpensereportlist'));
118 $socid = $user->socid;
127 if (empty($user->rights->expensereport->lire)) {
136 $childids = $user->getAllChildIds(1);
138 $parameters = array(
'socid'=>$socid);
139 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
144 if (empty($reshook)) {
145 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
147 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
149 $search_date_startday =
'';
150 $search_date_startmonth =
'';
151 $search_date_startyear =
'';
152 $search_date_endday =
'';
153 $search_date_endmonth =
'';
154 $search_date_endyear =
'';
155 $search_date_start =
'';
156 $search_date_end =
'';
158 $search_payment_type =
'';
159 $search_cheque_num =
'';
160 $search_bank_account =
'';
169 llxHeader(
'', $langs->trans(
'ListPayment'));
173 $accountstatic =
new Account($db);
174 $userstatic =
new User($db);
177 $sql =
'SELECT pndf.rowid, pndf.rowid as ref, pndf.datep, pndf.amount as pamount, pndf.num_payment';
178 $sql .=
', u.rowid as userid, u.login, u.lastname, u.firstname';
179 $sql .=
', c.code as paiement_type, c.libelle as paiement_libelle';
180 $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';
181 $sql .=
', SUM(pndf.amount)';
182 $sql .=
' FROM '.MAIN_DB_PREFIX.
'payment_expensereport AS pndf';
183 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'expensereport AS ndf ON ndf.rowid=pndf.fk_expensereport';
184 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement AS c ON pndf.fk_typepayment = c.id';
185 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON u.rowid = ndf.fk_user_author';
186 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON pndf.fk_bank = b.rowid';
187 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
188 $sql .=
' WHERE ndf.entity IN ('.getEntity(
"expensereport").
')';
191 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
192 && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) {
193 $sql .=
" AND ndf.fk_user_author IN (".$db->sanitize(join(
',', $childids)).
")\n";
199 if ($search_date_start) {
200 $sql .=
" AND pndf.datep >= '" . $db->idate($search_date_start) .
"'";
202 if ($search_date_end) {
203 $sql .=
" AND pndf.datep <= '" . $db->idate($search_date_end) .
"'";
207 $sql .=
natural_search(array(
'u.login',
'u.lastname',
'u.firstname'), $search_user);
209 if ($search_payment_type !=
'') {
210 $sql .=
" AND c.code='".$db->escape($search_payment_type).
"'";
212 if ($search_cheque_num !=
'') {
215 if ($search_amount) {
218 if ($search_bank_account > 0) {
219 $sql .=
' AND b.fk_account = '.((int) $search_bank_account);
222 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
226 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
228 $sql .=
' GROUP BY pndf.rowid, pndf.datep, pndf.amount, pndf.num_payment, u.rowid, u.login, u.lastname, u.firstname, c.code, c.libelle,';
229 $sql .=
' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
231 $sql .= $db->order($sortfield, $sortorder);
234 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
235 $result = $db->query($sql);
243 $sql .= $db->plimit($limit + 1, $offset);
245 $resql = $db->query($sql);
253 $num = $db->num_rows(
$resql);
257 if (!empty($contextpage) && $contextpage != $_SERVER[
'PHP_SELF']) {
258 $param .=
'&contextpage='.urlencode($contextpage);
260 if ($limit > 0 && $limit != $conf->liste_limit) {
261 $param .=
'&limit='.urlencode($limit);
263 if ($optioncss !=
'') {
264 $param .=
'&optioncss='.urlencode($optioncss);
268 $param .=
'&search_ref='.urlencode($search_ref);
270 if ($search_date_startday) {
271 $param .=
'&search_date_startday='.urlencode($search_date_startday);
273 if ($search_date_startmonth) {
274 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
276 if ($search_date_startyear) {
277 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
279 if ($search_date_endday) {
280 $param .=
'&search_date_endday='.urlencode($search_date_endday);
282 if ($search_date_endmonth) {
283 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
285 if ($search_date_endyear) {
286 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
289 $param .=
'&search_user='.urlencode($search_user);
291 if ($search_payment_type) {
292 $param .=
'&search_payment_type='.urlencode($search_payment_type);
294 if ($search_cheque_num) {
295 $param .=
'&search_cheque_num='.urlencode($search_cheque_num);
297 if ($search_amount) {
298 $param .=
'&search_amount='.urlencode($search_amount);
301 if ($search_bank_account) {
302 $param .=
'&search_bank_account='.urlencode($search_bank_account);
306 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
308 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
309 if ($optioncss !=
'') {
310 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
312 print
'<input type="hidden" name="token" value="'.newToken().
'">';
313 print
'<input type="hidden" name="action" value="list">';
314 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
315 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
316 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
317 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
319 print_barre_liste($langs->trans(
'ExpenseReportPayments'), $page, $_SERVER[
'PHP_SELF'], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'expensereport', 0,
'',
'', $limit, 0, 0, 1);
322 foreach ($fieldstosearchall as $key => $val) {
323 $fieldstosearchall[$key] = $langs->trans($val);
325 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
330 $parameters = array();
331 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
332 if (empty($reshook)) {
333 $moreforfilter .= $hookmanager->resPrint;
335 $moreforfilter = $hookmanager->resPrint;
338 if ($moreforfilter) {
339 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
340 print $moreforfilter;
344 $varpage = empty($contextpage) ? $_SERVER[
'PHP_SELF'] : $contextpage;
345 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
346 if (!empty($massactionbutton)) {
347 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
350 print
'<div class="div-table-responsive">';
351 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
'').
'">';
353 print
'<tr class="liste_titre_filter">';
356 if (!empty($arrayfields[
'pndf.rowid'][
'checked'])) {
357 print
'<td class="liste_titre left">';
358 print
'<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
363 if (!empty($arrayfields[
'pndf.datep'][
'checked'])) {
364 print
'<td class="liste_titre center">';
365 print
'<div class="nowrap">';
366 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
368 print
'<div class="nowrap">';
369 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
375 if (!empty($arrayfields[
'u.login'][
'checked'])) {
376 print
'<td class="liste_titre">';
377 print
'<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
382 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
383 print
'<td class="liste_titre">';
384 $form->select_types_paiements($search_payment_type,
'search_payment_type',
'', 2, 1, 1);
389 if (!empty($arrayfields[
'pndf.num_payment'][
'checked'])) {
390 print
'<td class="liste_titre">';
391 print
'<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).
'">';
396 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
397 print
'<td class="liste_titre">';
398 $form->select_comptes($search_bank_account,
'search_bank_account', 0,
'', 1);
403 if (!empty($arrayfields[
'pndf.amount'][
'checked'])) {
404 print
'<td class="liste_titre right">';
405 print
'<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'">';
410 $parameters = array(
'arrayfields'=>$arrayfields);
411 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
412 print $hookmanager->resPrint;
415 print
'<td class="liste_titre maxwidthsearch">';
416 print
$form->showFilterAndCheckAddButtons(0);
421 $totalarray = array();
422 $totalarray[
'nbfield'] = 0;
424 print
'<tr class="liste_titre">';
425 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
428 if (!empty($arrayfields[
'pndf.rowid'][
'checked'])) {
429 print_liste_field_titre($arrayfields[
'pndf.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'pndf.rowid',
'', $param,
'', $sortfield, $sortorder);
431 if (!empty($arrayfields[
'pndf.datep'][
'checked'])) {
432 print_liste_field_titre($arrayfields[
'pndf.datep'][
'label'], $_SERVER[
"PHP_SELF"],
'pndf.datep',
'', $param,
'', $sortfield, $sortorder,
'center ');
434 if (!empty($arrayfields[
'u.login'][
'checked'])) {
435 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.lastname',
'', $param,
'', $sortfield, $sortorder);
437 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
438 print_liste_field_titre($arrayfields[
'c.libelle'][
'label'], $_SERVER[
"PHP_SELF"],
'c.libelle',
'', $param,
'', $sortfield, $sortorder);
440 if (!empty($arrayfields[
'pndf.num_payment'][
'checked'])) {
441 print_liste_field_titre($arrayfields[
'pndf.num_payment'][
'label'], $_SERVER[
"PHP_SELF"],
"pndf.num_payment",
'', $param,
'', $sortfield, $sortorder,
'', $arrayfields[
'pndf.num_payment'][
'tooltip']);
443 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
444 print_liste_field_titre($arrayfields[
'ba.label'][
'label'], $_SERVER[
"PHP_SELF"],
'ba.label',
'', $param,
'', $sortfield, $sortorder);
446 if (!empty($arrayfields[
'pndf.amount'][
'checked'])) {
447 print_liste_field_titre($arrayfields[
'pndf.amount'][
'label'], $_SERVER[
"PHP_SELF"],
'pndf.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
451 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
452 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
453 print $hookmanager->resPrint;
455 print_liste_field_titre($selectedfields, $_SERVER[
'PHP_SELF'],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
459 foreach ($arrayfields as $column) {
460 if ($column[
'checked']) {
468 $savnbfield = $totalarray[
'nbfield'];
469 $totalarray = array();
470 $totalarray[
'nbfield'] = 0;
471 while ($i < min($num, $limit)) {
472 $objp = $db->fetch_object(
$resql);
474 $paymentexpensereportstatic->id = $objp->rowid;
475 $paymentexpensereportstatic->ref = $objp->ref;
476 $paymentexpensereportstatic->datepaye = $objp->datep;
478 $userstatic->id = $objp->userid;
479 $userstatic->lastname = $objp->lastname;
480 $userstatic->firstname = $objp->firstname;
482 print
'<tr class="oddeven">';
485 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
486 print
'<td>'.(($offset * $limit) + $i).
'</td>';
488 $totalarray[
'nbfield']++;
493 if (!empty($arrayfields[
'pndf.rowid'][
'checked'])) {
494 print
'<td class="nowrap">'.$paymentexpensereportstatic->getNomUrl(1).
'</td>';
496 $totalarray[
'nbfield']++;
501 if (!empty($arrayfields[
'pndf.datep'][
'checked'])) {
502 $dateformatforpayment =
'dayhour';
503 print
'<td class="nowrap center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).
'</td>';
505 $totalarray[
'nbfield']++;
510 if (!empty($arrayfields[
'u.login'][
'checked'])) {
512 if ($userstatic->id > 0) {
513 print $userstatic->getNomUrl(1);
517 $totalarray[
'nbfield']++;
522 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
523 $payment_type = $langs->trans(
"PaymentType".$objp->paiement_type) != (
"PaymentType".$objp->paiement_type) ? $langs->trans(
"PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
524 print
'<td>'.$payment_type.
' '.
dol_trunc($objp->num_payment, 32).
'</td>';
526 $totalarray[
'nbfield']++;
531 if (!empty($arrayfields[
'pndf.num_payment'][
'checked'])) {
532 print
'<td>'.$objp->num_payment.
'</td>';
534 $totalarray[
'nbfield']++;
539 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
542 $accountstatic->id = $objp->bid;
543 $accountstatic->ref = $objp->bref;
544 $accountstatic->label = $objp->blabel;
545 $accountstatic->number = $objp->number;
546 $accountstatic->iban = $objp->iban_prefix;
547 $accountstatic->bic = $objp->bic;
548 $accountstatic->currency_code = $objp->currency_code;
549 $accountstatic->account_number = $objp->account_number;
552 $accountingjournal->fetch($objp->accountancy_journal);
553 $accountstatic->accountancy_journal = $accountingjournal->code;
555 print $accountstatic->getNomUrl(1);
561 $totalarray[
'nbfield']++;
566 if (!empty($arrayfields[
'pndf.amount'][
'checked'])) {
567 print
'<td class="right"><span class="amount">'.price($objp->pamount).
'</span></td>';
569 $totalarray[
'nbfield']++;
571 $totalarray[
'pos'][$checkedCount] =
'amount';
572 if (empty($totalarray[
'val'][
'amount'])) {
573 $totalarray[
'val'][
'amount'] = $objp->pamount;
575 $totalarray[
'val'][
'amount'] += $objp->pamount;
582 $totalarray[
'nbfield']++;
590 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage accounting accounts.
Class to manage payments of expense report.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.