33 require
'../../main.inc.php';
36 if ($user->socid) $socid = $user->socid;
39 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
46 $langs->loadLangs(array(
'bills',
'banks',
'compta',
'companies'));
48 $action =
GETPOST(
'action',
'alpha');
49 $massaction =
GETPOST(
'massaction',
'alpha');
50 $confirm =
GETPOST(
'confirm',
'alpha');
51 $optioncss =
GETPOST(
'optioncss',
'alpha');
52 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'paymentlist';
54 $facid =
GETPOST(
'facid',
'int');
55 $socid =
GETPOST(
'socid',
'int');
56 $userid =
GETPOST(
'userid',
'int');
58 $month =
GETPOST(
'month',
'int');
61 $search_ref =
GETPOST(
"search_ref",
"alpha");
62 $search_company =
GETPOST(
"search_company",
'alpha');
63 $search_paymenttype =
GETPOST(
"search_paymenttype");
64 $search_account =
GETPOST(
"search_account",
"int");
65 $search_payment_num =
GETPOST(
'search_payment_num',
'alpha');
66 $search_amount =
GETPOST(
"search_amount",
'alpha');
68 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
69 $sortfield =
GETPOST(
"sortfield",
'alpha');
70 $sortorder =
GETPOST(
"sortorder",
'alpha');
73 if (empty($page) || $page == -1) $page = 0;
74 $offset = $limit * $page;
75 $pageprev = $page - 1;
76 $pagenext = $page + 1;
78 if (!$sortorder) $sortorder =
"DESC";
79 if (!$sortfield) $sortfield =
"p.ref";
84 $fieldstosearchall = array(
85 'p.ref'=>
"RefPayment",
86 's.nom'=>
"ThirdParty",
87 'p.num_paiement'=>
"Numero",
92 'p.ref' => array(
'label'=>
"RefPayment",
'checked'=>1,
'position'=>10),
93 'p.datep' => array(
'label'=>
"Date",
'checked'=>1,
'position'=>20),
94 's.nom' => array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>30),
95 'c.libelle' => array(
'label'=>
"Type",
'checked'=>1,
'position'=>40),
96 'transaction' => array(
'label'=>
"BankTransactionLine",
'checked'=>1,
'position'=>50,
'enabled'=>(!empty($conf->banque->enabled))),
97 'ba.label' => array(
'label'=>
"Account",
'checked'=>1,
'position'=>60,
'enabled'=>(!empty($conf->banque->enabled))),
98 'p.num_paiement' => array(
'label'=>
"Numero",
'checked'=>1,
'position'=>70,
'tooltip'=>
"ChequeOrTransferNumber"),
99 'p.amount' => array(
'label'=>
"Amount",
'checked'=>1,
'position'=>80),
100 'p.statut' => array(
'label'=>
"Status",
'checked'=>1,
'position'=>90,
'enabled'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))),
105 $hookmanager->initHooks(array(
'paymentlist'));
112 $parameters = array(
'socid'=>$socid);
113 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
114 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
117 if (empty($reshook)) {
118 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
121 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
123 $search_account =
'';
125 $search_paymenttype =
'';
126 $search_payment_num =
'';
127 $search_company =
'';
133 $search_array_options = array();
141 $form =
new Form($db);
143 $accountstatic =
new Account($db);
144 $companystatic =
new Societe($db);
147 llxHeader(
'', $langs->trans(
'ListPayment'));
149 if (
GETPOST(
"orphelins",
"alpha")) {
151 $sql =
"SELECT p.rowid, p.ref, p.datep, p.amount, p.statut, p.num_paiement";
152 $sql .=
", c.code as paiement_code";
155 $parameters = array();
156 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
157 $sql .= $hookmanager->resPrint;
158 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement as p LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_paiement = c.id";
159 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf ON p.rowid = pf.fk_paiement";
160 $sql .=
" WHERE p.entity IN (".getEntity(
'invoice').
")";
161 $sql .=
" AND pf.fk_facture IS NULL";
164 $parameters = array();
165 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
166 $sql .= $hookmanager->resPrint;
169 $sql =
"SELECT DISTINCT p.rowid, p.ref, p.datep, p.fk_bank, p.amount, p.statut, p.num_paiement";
170 $sql .=
", c.code as paiement_code";
171 $sql .=
", ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.fk_accountancy_journal as accountancy_journal";
172 $sql .=
", s.rowid as socid, s.nom as name, s.email";
175 $parameters = array();
176 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
177 $sql .= $hookmanager->resPrint;
178 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement as p";
179 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_paiement = c.id";
180 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON p.fk_bank = b.rowid";
181 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
182 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf ON p.rowid = pf.fk_paiement";
183 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as f ON pf.fk_facture = f.rowid";
184 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON f.fk_soc = s.rowid";
185 if (!$user->rights->societe->client->voir && !$socid) {
186 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
188 $sql .=
" WHERE p.entity IN (".getEntity(
'invoice').
")";
189 if (!$user->rights->societe->client->voir && !$socid) {
190 $sql .=
" AND sc.fk_user = ".$user->id;
193 $sql .=
" AND f.fk_soc = ".$socid;
196 if ($userid == -1) $sql .=
" AND f.fk_user_author IS NULL";
197 else $sql .=
" AND f.fk_user_author = ".$userid;
203 if ($search_account > 0) $sql .=
" AND b.fk_account=".$search_account;
204 if ($search_paymenttype !=
'') $sql .=
" AND c.code='".$db->escape($search_paymenttype).
"'";
205 if ($search_payment_num !=
'') $sql .=
natural_search(
'p.num_paiement', $search_payment_num);
206 if ($search_amount) $sql .=
natural_search(
'p.amount', $search_amount, 1);
207 if ($search_company) $sql .=
natural_search(
's.nom', $search_company);
209 if ($search_all) $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
212 $parameters = array();
213 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
214 $sql .= $hookmanager->resPrint;
216 $sql .= $db->order($sortfield, $sortorder);
218 $nbtotalofrecords =
'';
219 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
220 $result = $db->query($sql);
221 $nbtotalofrecords = $db->num_rows($result);
224 if (($page * $limit) > $nbtotalofrecords) {
230 $sql .= $db->plimit($limit + 1, $offset);
232 $resql = $db->query($sql);
240 $num = $db->num_rows(
$resql);
243 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
244 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
245 $param .= (
GETPOST(
"orphelins") ?
"&orphelins=1" :
'');
246 $param .= ($search_ref ?
"&search_ref=".urlencode($search_ref) :
'');
247 $param .= ($search_company ?
"&search_company=".urlencode($search_company) :
'');
248 $param .= ($search_amount ?
"&search_amount=".urlencode($search_amount) :
'');
249 $param .= ($search_payment_num ?
"&search_payment_num=".urlencode($search_payment_num) :
'');
250 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
252 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
253 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
254 print '<input type="hidden" name="token" value="'.newToken().
'">';
255 print '<input type="hidden" name="action" value="list">';
256 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
257 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
258 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
259 print '<input type="hidden" name="search_status" value="'.$search_status.
'">';
260 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
262 print_barre_liste($langs->trans(
"ReceivedCustomersPayments"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'bill', 0,
'',
'', $limit, 0, 0, 1);
266 foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
267 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
270 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
271 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
272 if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
274 print '<div class="div-table-responsive">';
275 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
'').
'">';
277 print '<tr class="liste_titre_filter">';
280 print
'<tr class="liste_titre_filter">';
281 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
282 print
'<td class="liste_titre">';
287 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
288 print
'<td class="liste_titre left">';
289 print
'<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
294 if (!empty($arrayfields[
'p.datep'][
'checked'])) {
295 print
'<td class="liste_titre center">';
296 if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print
'<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).
'">';
297 print
'<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month" value="'.dol_escape_htmltag($month).
'">';
298 $formother->select_year($year ? $year : -1,
'year', 1, 20, 5);
303 if (!empty($arrayfields[
's.nom'][
'checked'])) {
304 print
'<td class="liste_titre">';
305 print
'<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).
'">';
310 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
311 print
'<td class="liste_titre">';
312 $form->select_types_paiements($search_paymenttype,
'search_paymenttype',
'', 2, 1, 1);
317 if (!empty($arrayfields[
'transaction'][
'checked'])) {
318 print
'<td class="liste_titre">';
319 print
'<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).
'">';
324 if (!empty($arrayfields[
'p.num_paiement'][
'checked'])) {
325 print
'<td class="liste_titre">';
330 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
331 print
'<td class="liste_titre">';
332 $form->select_comptes($search_account,
'search_account', 0,
'', 1);
337 if (!empty($arrayfields[
'p.amount'][
'checked'])) {
338 print
'<td class="liste_titre right">';
339 print
'<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'">';
344 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
345 print
'<td class="liste_titre right">';
350 $parameters = array(
'arrayfields'=>$arrayfields);
351 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
352 print $hookmanager->resPrint;
354 print
'<td class="liste_titre maxwidthsearch">';
355 print $form->showFilterAndCheckAddButtons(0);
360 print
'<tr class="liste_titre">';
361 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST))
print_liste_field_titre(
'#', $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
362 if (!empty($arrayfields[
'p.ref'][
'checked']))
print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
363 if (!empty($arrayfields[
'p.datep'][
'checked']))
print_liste_field_titre($arrayfields[
'p.datep'][
'label'], $_SERVER[
"PHP_SELF"],
"p.datep",
'', $param,
'', $sortfield, $sortorder,
'center ');
364 if (!empty($arrayfields[
's.nom'][
'checked']))
print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
'', $param,
'', $sortfield, $sortorder);
365 if (!empty($arrayfields[
'c.libelle'][
'checked']))
print_liste_field_titre($arrayfields[
'c.libelle'][
'label'], $_SERVER[
"PHP_SELF"],
"c.libelle",
'', $param,
'', $sortfield, $sortorder);
366 if (!empty($arrayfields[
'p.num_paiement'][
'checked']))
print_liste_field_titre($arrayfields[
'p.num_paiement'][
'label'], $_SERVER[
"PHP_SELF"],
"p.num_paiement",
'', $param,
'', $sortfield, $sortorder,
'', $arrayfields[
'p.num_paiement'][
'tooltip']);
367 if (!empty($arrayfields[
'transaction'][
'checked']))
print_liste_field_titre($arrayfields[
'transaction'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
368 if (!empty($arrayfields[
'ba.label'][
'checked']))
print_liste_field_titre($arrayfields[
'ba.label'][
'label'], $_SERVER[
"PHP_SELF"],
"ba.label",
'', $param,
'', $sortfield, $sortorder);
369 if (!empty($arrayfields[
'p.amount'][
'checked']))
print_liste_field_titre($arrayfields[
'p.amount'][
'label'], $_SERVER[
"PHP_SELF"],
"p.amount",
'', $param,
'class="right"', $sortfield, $sortorder);
370 if (!empty($arrayfields[
'p.statut'][
'checked']))
print_liste_field_titre($arrayfields[
'p.statut'][
'label'], $_SERVER[
"PHP_SELF"],
"p.statut",
'', $param,
'class="right"', $sortfield, $sortorder);
373 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
374 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
375 print $hookmanager->resPrint;
377 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
381 foreach ($arrayfields as $column) {
382 if ($column[
'checked']) {
388 $totalarray = array();
389 while ($i < min($num, $limit)) {
390 $objp = $db->fetch_object(
$resql);
392 $object->id = $objp->rowid;
393 $object->ref = ($objp->ref ? $objp->ref : $objp->rowid);
395 $companystatic->id = $objp->socid;
396 $companystatic->name = $objp->name;
397 $companystatic->email = $objp->email;
399 print
'<tr class="oddeven">';
402 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
403 print
'<td>'.(($offset * $limit) + $i).
'</td>';
404 if (!$i) $totalarray[
'nbfield']++;
408 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
409 print
'<td>'.$object->getNomUrl(1).
'</td>';
410 if (!$i) $totalarray[
'nbfield']++;
414 if (!empty($arrayfields[
'p.datep'][
'checked'])) {
415 $dateformatforpayment =
'day';
416 if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment =
'dayhour';
417 print
'<td class="center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).
'</td>';
418 if (!$i) $totalarray[
'nbfield']++;
422 if (!empty($arrayfields[
's.nom'][
'checked'])) {
424 if ($objp->socid > 0) {
425 print $companystatic->getNomUrl(1,
'', 24);
428 if (!$i) $totalarray[
'nbfield']++;
432 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
433 print
'<td>'.$langs->trans(
"PaymentTypeShort".$objp->paiement_code).
'</td>';
434 if (!$i) $totalarray[
'nbfield']++;
438 if (!empty($arrayfields[
'p.num_paiement'][
'checked'])) {
439 print
'<td>'.$objp->num_paiement.
'</td>';
440 if (!$i) $totalarray[
'nbfield']++;
444 if (!empty($arrayfields[
'transaction'][
'checked'])) {
445 $bankline->fetch($objp->fk_bank);
446 print
'<td>'.$bankline->getNomUrl(1, 0).
'</td>';
447 if (!$i) $totalarray[
'nbfield']++;
451 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
453 if ($objp->bid > 0) {
454 $accountstatic->id = $objp->bid;
455 $accountstatic->ref = $objp->bref;
456 $accountstatic->label = $objp->blabel;
457 $accountstatic->number = $objp->number;
458 $accountstatic->account_number = $objp->account_number;
461 $accountingjournal->fetch($objp->accountancy_journal);
462 $accountstatic->accountancy_journal = $accountingjournal->code;
464 print $accountstatic->getNomUrl(1);
467 if (!$i) $totalarray[
'nbfield']++;
471 if (!empty($arrayfields[
'p.amount'][
'checked'])) {
472 print
'<td class="right">'.price($objp->amount).
'</td>';
473 if (!$i) $totalarray[
'nbfield']++;
474 $totalarray[
'pos'][$checkedCount] =
'amount';
475 $totalarray[
'val'][
'amount'] += $objp->amount;
479 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
480 print
'<td class="right">';
481 if ($objp->statut == 0) print
'<a href="card.php?id='.$objp->rowid.
'&action=valide">';
482 print $object->LibStatut($objp->statut, 5);
483 if ($objp->statut == 0) print
'</a>';
485 if (!$i) $totalarray[
'nbfield']++;
490 if (!$i) $totalarray[
'nbfield']++;
498 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
504 foreach ($arrayfields as $key => $val) {
if (!empty($val[
'checked'])) $colspan++; }
505 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage bank transaction lines.
Class to manage bank accounts.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage payments of customer invoices.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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...
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
print $_SERVER["PHP_SELF"]
Edit parameters.
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
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage accounting accounts.