From 29ee420f3e2565e5cb815f0452d0122658a2312a Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Wed, 7 Oct 2020 11:18:31 +0200 Subject: [PATCH 1/3] Selectable columns on sup. invoice payment list --- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/fourn/paiement/card.php | 4 +- htdocs/fourn/paiement/list.php | 429 ++++++++++++++++++++++++ 3 files changed, 432 insertions(+), 3 deletions(-) create mode 100644 htdocs/fourn/paiement/list.php diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 2c3549cdea9..047cfe2d6b3 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1043,7 +1043,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_paid&search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_paid'); } - $newmenu->add("/fourn/facture/paiement.php?leftmenu=suppliers_bills_payment", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_payment'); + $newmenu->add("/fourn/paiement/list.php?leftmenu=suppliers_bills_payment", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_payment'); $newmenu->add("/fourn/facture/rapport.php?leftmenu=suppliers_bills_report", $langs->trans("Reportings"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_report'); diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 9a7af329f50..da2d04574ee 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -74,7 +74,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisse if ($result > 0) { $db->commit(); - header('Location: '.DOL_URL_ROOT.'/fourn/facture/paiement.php'); + header('Location: '.DOL_URL_ROOT.'/fourn/paiement/list.php'); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -166,7 +166,7 @@ if ($result > 0) print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide'); } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref'); diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php new file mode 100644 index 00000000000..874a15bb8ac --- /dev/null +++ b/htdocs/fourn/paiement/list.php @@ -0,0 +1,429 @@ + + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2004 Christophe Combelles + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> + * Copyright (C) 2015 Marcos García + * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2018 Frédéric France + * Copyright (C) 2020 Tobias Sekan + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/fourn/paiment/list.php +* \ingroup fournisseur,facture + * \brief Payment list for supplier invoices + */ + +require '../../main.inc.php'; + +// Security check +if ($user->socid) $socid = $user->socid; + +// doesn't work :-( +// restrictedArea($user, 'fournisseur'); + +// doesn't work :-( +// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +// $object = new PaiementFourn($db); +// restrictedArea($user, $object->element); + +if(!$user->rights->fournisseur->facture->lire) { + accessforbidden(); +} + +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'bills', 'banks', 'compta')); + +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist'; + +$socid = GETPOST('socid', 'int'); + +$search_ref = GETPOST('search_ref', 'alpha'); +$search_day = GETPOST('search_day', 'int'); +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); +$search_company = GETPOST('search_company', 'alpha'); +$search_payment_type = GETPOST('search_payment_type'); +$search_cheque_num = GETPOST('search_cheque_num', 'alpha'); +$search_bank_account = GETPOST('search_bank_account', 'int'); +$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x' + +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); + +if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "p.datep"; + +// TODO: add global search for this list + +$arrayfields = array( + 'p.ref' =>array('label'=>"RefPayment", 'checked'=>1, 'position'=>10), + 'p.datep' =>array('label'=>"Date", 'checked'=>1, 'position'=>20), + 's.nom' =>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), + 'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40), + 'p.num_paiement' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"), + 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(!empty($conf->banque->enabled))), + 'p.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70), +); +$arrayfields = dol_sort_array($arrayfields, 'position'); + +$hookmanager->initHooks(array('paymentsupplierlist')); +$object = new PaiementFourn($db); + +/* +* Actions +*/ + +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + 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 + $search_ref = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; + $search_company = ''; + $search_payment_type = ''; + $search_cheque_num = ''; + $search_bank_account = ''; + $search_amount = ''; + } +} + +/* + * View + */ + +llxHeader('', $langs->trans('ListPayment')); + +$form = new Form($db); +$formother = new FormOther($db); +$companystatic = new Societe($db); +$paymentfournstatic = new PaiementFourn($db); + +$sql = 'SELECT p.rowid, p.ref, p.datep, p.amount as pamount, p.num_paiement'; +$sql .= ', s.rowid as socid, s.nom as name, s.email'; +$sql .= ', c.code as paiement_type, c.libelle as paiement_libelle'; +$sql .= ', ba.rowid as bid, ba.label'; +if (!$user->rights->societe->client->voir) $sql .= ', sc.fk_soc, sc.fk_user'; +$sql .= ', SUM(pf.amount)'; + +$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; +if (!$user->rights->societe->client->voir) $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc'; + +$sql .= ' WHERE f.entity = '.$conf->entity; +if (!$user->rights->societe->client->voir) $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.$user->id; +if ($socid > 0) $sql .= ' AND f.fk_soc = '.$socid; +if ($search_ref) $sql .= natural_search('p.ref', $search_ref); +$sql .= dolSqlDateFilter('p.datep', $search_day, $search_month, $search_year); +if ($search_company) $sql .= natural_search('s.nom', $search_company); +if ($search_payment_type != '') $sql .= " AND c.code='".$db->escape($search_payment_type)."'"; +if ($search_cheque_num != '') $sql .= natural_search('p.num_paiement', $search_cheque_num); +if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); +if ($search_bank_account > 0) $sql .= ' AND b.fk_account='.$search_bank_account."'"; + +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + +$sql .= ' GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label'; +if (!$user->rights->societe->client->voir) $sql .= ', sc.fk_soc, sc.fk_user'; + +$sql .= $db->order($sortfield, $sortorder); + +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + $page = 0; + $offset = 0; + } +} + +$sql .= $db->plimit($limit + 1, $offset); + +$resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + llxFooter(); + $db->close(); + exit; +} + +$num = $db->num_rows($resql); +$i = 0; + +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + +if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); +if ($saerch_day) $param .= '&search_day='.urlencode($search_day); +if ($saerch_month) $param .= '&search_month='.urlencode($search_month); +if ($search_year) $param .= '&search_year='.urlencode($search_year); +if ($search_company) $param .= '&search_company='.urlencode($search_company); +if ($search_payment_type) $param .= '&search_company='.urlencode($search_payment_type); +if ($search_cheque_num) $param .= '&search_cheque_num='.urlencode($search_cheque_num); +if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1); + +$moreforfilter = ''; + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if ($moreforfilter) { + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + +print '
'; +print ''; + +print ''; + +// Filter: Ref +if (!empty($arrayfields['p.ref']['checked'])) { + print ''; +} + +// Filter: Date +if (!empty($arrayfields['p.datep']['checked'])) { + print ''; +} + +// Filter: Thirdparty +if (!empty($arrayfields['s.nom']['checked'])) { + print ''; +} + +// Filter: Payment type +if (!empty($arrayfields['c.libelle']['checked'])) { + print ''; +} + +// Filter: Cheque number (fund transfer) +if (!empty($arrayfields['p.num_paiement']['checked'])) { + print ''; +} + +// Filter: Bank account +if (!empty($arrayfields['ba.label']['checked'])) { + print ''; +} + +// Filter: Amount +if (!empty($arrayfields['p.amount']['checked'])) { + print ''; +} + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +// Buttons +print ''; + +print ''; + +print ''; +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.datep']['checked'])) print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder); +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']); +if (!empty($arrayfields['ba.label']['checked'])) print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.amount']['checked'])) print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right '); + +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +print ''; + +$checkedCount = 0; +foreach($arrayfields as $column) { + if($column['checked']) { + $checkedCount++; + } +} + +$i = 0; +$totalarray = array(); +while ($i < min($num, $limit)) { + $objp = $db->fetch_object($resql); + + $paymentfournstatic->id = $objp->rowid; + $paymentfournstatic->ref = $objp->ref; + $paymentfournstatic->datepaye = $objp->datep; + + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; + $companystatic->email = $objp->email; + + print ''; + + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Date + if (!empty($arrayfields['p.datep']['checked'])) { + $dateformatforpayment = 'day'; + if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment = 'dayhour'; + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Thirdparty + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Pyament type + if (!empty($arrayfields['c.libelle']['checked'])) { + $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Cheque number (fund transfer) + if (!empty($arrayfields['p.num_paiement']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Account + if (!empty($arrayfields['ba.label']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Amount + if (!empty($arrayfields['p.amount']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + $totalarray['pos'][$checkedCount] = 'amount'; + $totalarray['val']['amount'] += $objp->pamount; + } + + // Buttons + print ''; + if (!$i) $totalarray['nbfield']++; + + print ''; + $i++; +} + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +print '
'; + print ''; + print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5); + print ''; + print ''; + print ''; + $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1); + print ''; + print ''; + print ''; + $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1); + print ''; + print ''; + print ''; +print $form->showFilterAndCheckAddButtons(0); +print '
'.(($offset * $limit) + $i).''.$paymentfournstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''; + if ($objp->socid > 0) { + print $companystatic->getNomUrl(1, '', 24); + } + print ''.$payment_type.' '.dol_trunc($objp->num_paiement, 32).''.$objp->num_paiement.''; + if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"), 'account').' '.dol_trunc($objp->label, 24).''; + else print ' '; + print ''.price($objp->pamount).'
'; +print '
'; +print '
'; + +// End of page +llxFooter(); +$db->close(); From e26ab93179d914c0d6de8c6599cad96f546a2c75 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Wed, 7 Oct 2020 11:22:23 +0200 Subject: [PATCH 2/3] missing code remove from last commit --- htdocs/fourn/facture/paiement.php | 249 ------------------------------ 1 file changed, 249 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 65b8936a592..8c2fdbdb5b6 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -787,255 +787,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } else dol_print_error($db); } -/* - * Show list - */ -if (empty($action) || $action == 'list') -{ - $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; - $sortfield = GETPOST("sortfield", 'alpha'); - $sortorder = GETPOST("sortorder", 'alpha'); - $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - if (empty($page) || $page == -1) { $page = 0; } - $offset = $limit * $page; - $pageprev = $page - 1; - $pagenext = $page + 1; - if (!$sortorder) $sortorder = 'DESC'; - if (!$sortfield) $sortfield = 'p.datep'; - - $sql = 'SELECT p.rowid as pid, p.ref, p.datep as dp, p.amount as pamount, p.num_paiement,'; - $sql .= ' s.rowid as socid, s.nom as name,'; - $sql .= ' c.code as paiement_type, c.libelle as paiement_libelle,'; - $sql .= ' ba.rowid as bid, ba.label,'; - if (!$user->rights->societe->client->voir) $sql .= ' sc.fk_soc, sc.fk_user,'; - $sql .= ' SUM(pf.amount)'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE f.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid > 0) $sql .= ' AND f.fk_soc = '.$socid; - $sql .= dolSqlDateFilter('p.datep', $day, $month, $year); - if ($search_ref) $sql .= natural_search('p.rowid', $search_ref); - if ($search_account > 0) $sql .= " AND b.fk_account=".$search_account; - if ($search_paymenttype != "") $sql .= " AND c.code='".$db->escape($search_paymenttype)."'"; - if ($search_payment_num != '') $sql .= natural_search('p.num_paiement', $search_payment_num); - if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); - if ($search_company) $sql .= natural_search('s.nom', $search_company); - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; - $sql .= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label"; - if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user"; - // Add where from extra fields - - $sql .= $db->order($sortfield, $sortorder); - - $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } - } - - $sql .= $db->plimit($limit + 1, $offset); - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($day) $param .= ($day ? "&day=".urlencode($day) : ""); - if ($month) $param .= ($month ? "&month=".urlencode($month) : ""); - if ($year) $param .= ($year ? "&year=".urlencode($year) : ""); - if ($search_ref) $param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : ""); - if ($search_company) $param .= ($search_company ? "&search_company=".urlencode($search_company) : ""); - if ($search_amount != '') $param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : ""); - if ($search_payment_num) $param .= ($search_payment_num ? "&search_payment_num=".urlencode($search_payment_num) : ""); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - - $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1); - - $moreforfilter = ''; - - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; - - if ($moreforfilter) - { - print '
'; - print $moreforfilter; - print '
'; - } - - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - - print '
'; - print ''."\n"; - - // Lines for filters fields - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) - { - print ''; - } - print ''; - print ''; - print "\n"; - - print ''; - print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], 'dp', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre("Type", $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "p.num_paiement", "", $param, "", $sortfield, $sortorder); - if (!empty($conf->banque->enabled)) - { - print_liste_field_titre("Account", $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder); - } - print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right '); - - $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); - print "\n"; - - $paymentfournstatic = new PaiementFourn($db); - - $i = 0; - $totalarray = array(); - while ($i < min($num, $limit)) - { - $objp = $db->fetch_object($resql); - - $paymentfournstatic->id = $objp->pid; - $paymentfournstatic->ref = $objp->ref; - $paymentfournstatic->datepaye = $objp->dp; - - print ''; - - // Ref payment - print ''; - if (!$i) $totalarray['nbfield']++; - - // Date - $dateformatforpayment = 'day'; - if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment = 'dayhour'; - print '\n"; - if (!$i) $totalarray['nbfield']++; - - // Thirdparty - print ''; - if (!$i) $totalarray['nbfield']++; - - // Type - $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; - print '\n"; - if (!$i) $totalarray['nbfield']++; - - // Payment number - print ''; - if (!$i) $totalarray['nbfield']++; - - // Account - if (!empty($conf->banque->enabled)) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Amount - print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'amount'; - $totalarray['val']['amount'] += $objp->pamount; - - // Ref invoice - /*$invoicesupplierstatic->ref=$objp->ref_supplier; - $invoicesupplierstatic->id=$objp->facid; - print '';*/ - - print ''; - if (!$i) $totalarray['nbfield']++; - - print ''; - $i++; - } - - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - - print "
'; - print ''; - print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); - print ''; - print ''; - print ''; - $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1); - print ''; - print ''; - print ''; - $form->select_comptes($search_account, 'search_account', 0, '', 1); - print ''; - print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; - print $paymentfournstatic->getNomUrl(1); - print ''.dol_print_date($db->jdate($objp->dp), $dateformatforpayment)."'; - if ($objp->socid) print ''.img_object($langs->trans('ShowCompany'), 'company').' '.dol_trunc($objp->name, 32).''; - else print ' '; - print ''.$payment_type.' '.dol_trunc($objp->num_paiement, 32)."'.$objp->num_paiement.''; - if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"), 'account').' '.dol_trunc($objp->label, 24).''; - else print ' '; - print ''.price($objp->pamount).''; - print $invoicesupplierstatic->getNomUrl(1); - print '
"; - print "
"; - print "
\n"; - } else { - dol_print_error($db); - } -} - // End of page llxFooter(); $db->close(); From 85b7458b021fe4831ad46f3999f86d3dae8e8860 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 7 Oct 2020 09:24:37 +0000 Subject: [PATCH 3/3] Fixing style errors. --- htdocs/fourn/paiement/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index 874a15bb8ac..1a89e7f6906 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -45,7 +45,7 @@ if ($user->socid) $socid = $user->socid; // $object = new PaiementFourn($db); // restrictedArea($user, $object->element); -if(!$user->rights->fournisseur->facture->lire) { +if (!$user->rights->fournisseur->facture->lire) { accessforbidden(); } @@ -327,8 +327,8 @@ print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'alig print ''; $checkedCount = 0; -foreach($arrayfields as $column) { - if($column['checked']) { +foreach ($arrayfields as $column) { + if ($column['checked']) { $checkedCount++; } }