From 3984d8c2b8de3c72a277651c5603264c5f5e040b Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 5 Oct 2020 11:27:44 +0200 Subject: [PATCH 1/4] Add selectable columns on cust. invoice pay. list --- htdocs/compta/paiement/list.php | 564 ++++++++++++++++++-------------- 1 file changed, 322 insertions(+), 242 deletions(-) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index eb2523960f3..74c198b96c2 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -1,13 +1,14 @@ - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Juanjo Menent - * Copyright (C) 2017 Alexandre Spangaro - * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018 Charlene Benke +/* Copyright (C) 2001-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2018 Charlene Benke + * 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 @@ -30,6 +31,11 @@ */ require '../../main.inc.php'; + +// Security check +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'facture', $facid, ''); + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -39,36 +45,30 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; // Load translation files required by the page $langs->loadLangs(array('bills', 'banks', 'compta', 'companies')); -$action = GETPOST('action', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); -$optioncss = GETPOST('optioncss', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'paymentlist'; -$facid = GETPOST('facid', 'int'); -$socid = GETPOST('socid', 'int'); -$userid = GETPOST('userid', 'int'); -$day = GETPOST('day', 'int'); -$month = GETPOST('month', 'int'); -$year = GETPOST('year', 'int'); +$facid = GETPOST('facid', 'int'); +$socid = GETPOST('socid', 'int'); +$userid = GETPOST('userid', 'int'); +$day = GETPOST('day', 'int'); +$month = GETPOST('month', 'int'); +$year = GETPOST('year', 'int'); -// Security check -if ($user->socid) $socid = $user->socid; -$result = restrictedArea($user, 'facture', $facid, ''); +$search_ref = GETPOST("search_ref", "alpha"); +$search_account = GETPOST("search_account", "int"); +$search_paymenttype = GETPOST("search_paymenttype"); +$search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x" +$search_company = GETPOST("search_company", 'alpha'); -$paymentstatic = new Paiement($db); -$accountstatic = new Account($db); -$companystatic = new Societe($db); +$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'); -$search_ref = GETPOST("search_ref", "alpha"); -$search_account = GETPOST("search_account", "int"); -$search_paymenttype = GETPOST("search_paymenttype"); -$search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x" -$search_company = GETPOST("search_company", 'alpha'); -$search_payment_num = GETPOST('search_payment_num', 'alpha'); - -$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; @@ -77,98 +77,120 @@ if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "p.rowid"; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new Paiement($db); $hookmanager->initHooks(array('paymentlist')); $extrafields = new ExtraFields($db); -$arrayfields = array(); +$arrayfields = array( + 'p.rowid' => 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), + 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'enabled'=>(!empty($conf->banque->enabled)), 'position'=>50), + 'ba.label' => array('label'=>"Account", 'checked'=>1, 'enabled'=>(!empty($conf->banque->enabled)), 'position'=>60), + 'p.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>70), + 'p.statut' => array('label'=>"Status", 'enabled'=>1, 'checked'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)), 'position'=>80), +); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* * Actions */ -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_account = ""; - $search_amount = ""; - $search_paymenttype = ""; - $search_payment_num = ""; - $search_company = ""; - $day = ''; - $year = ''; - $month = ''; - $search_array_options = array(); -} +$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_account = ""; + $search_amount = ""; + $search_paymenttype = ""; + $search_company = ""; + $day = ''; + $year = ''; + $month = ''; + $search_array_options = array(); + } +} + /* * View */ $form = new Form($db); $formother = new FormOther($db); +$accountstatic = new Account($db); +$companystatic = new Societe($db); +$bankline = new AccountLine($db); llxHeader('', $langs->trans('ListPayment')); if (GETPOST("orphelins", "alpha")) { - // Payments not linked to an invoice. Should not happend. For debug only. - $sql = "SELECT p.rowid, p.ref, p.datep as dp, p.amount,"; - $sql .= " p.statut, p.num_paiement as num_payment,"; - $sql .= " c.code as paiement_code"; + // Payments not linked to an invoice. Should not happend. For debug only. + $sql = "SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.amount, p.statut"; + $sql .= ", c.code as paiement_code"; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; - $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; - $sql .= " AND pf.fk_facture IS NULL"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; + $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; + $sql .= " AND pf.fk_facture IS NULL"; // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -} else { - $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep as dp, p.amount,"; // DISTINCT is to avoid duplicate when there is a link to sales representatives - $sql .= " p.statut, p.num_paiement as num_payment,"; - $sql .= " c.code as paiement_code,"; - $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,"; - $sql .= " s.rowid as socid, s.nom as name, s.email"; +} +else +{ + // DISTINCT is to avoid duplicate when there is a link to sales representatives + $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep, p.fk_bank, p.amount, p.statut"; + $sql .= ", c.code as paiement_code"; + $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"; + $sql .= ", s.rowid as socid, s.nom as name, s.email"; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; - $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"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) - { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - } - $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$socid) - { - $sql .= " AND sc.fk_user = ".$user->id; - } - if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; - if ($userid) - { - if ($userid == -1) $sql .= " AND f.fk_user_author IS NULL"; - else $sql .= " AND f.fk_user_author = ".$userid; - } - // Search criteria - $sql .= dolSqlDateFilter("p.datep", $day, $month, $year); - if ($search_ref) $sql .= natural_search('p.ref', $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); + $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; + $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"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) + { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + } + $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$socid) + { + $sql .= " AND sc.fk_user = ".$user->id; + } + if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + if ($userid) + { + if ($userid == -1) $sql .= " AND f.fk_user_author IS NULL"; + else $sql .= " AND f.fk_user_author = ".$userid; + } + // Search criteria + $sql .= dolSqlDateFilter("p.datep", $day, $month, $year); + if ($search_ref) $sql .= natural_search('p.ref', $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_amount) $sql .= natural_search('p.amount', $search_amount, 1); + if ($search_company) $sql .= natural_search('s.nom', $search_company); // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -189,195 +211,253 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } $sql .= $db->plimit($limit + 1, $offset); -//print "$sql"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - $param .= (GETPOST("orphelins") ? "&orphelins=1" : ""); - $param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : ""); - $param .= ($search_company ? "&search_company=".urlencode($search_company) : ""); - $param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : ""); - $param .= ($search_payment_num ? "&search_payment_num=".urlencode($search_payment_num) : ""); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + $param .= (GETPOST("orphelins") ? "&orphelins=1" : ""); + $param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : ""); + $param .= ($search_company ? "&search_company=".urlencode($search_company) : ""); + $param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : ""); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); - print '
'; - print ''."\n"; + $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); - // Lines for filters fields - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) - { - print ''; - } - 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 '
'; + print ''; + + print ''; + + // Filters: Lines (placeholder) + print ''; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; + } + + // Filter: Ref + if (!empty($arrayfields['p.rowid']['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: Bank transaction number + if (!empty($arrayfields['transaction']['checked'])) { + print ''; + } + + // Filter: Bank account + if (!empty($arrayfields['ba.label']['checked'])) { + print ''; + } + + // Filter: Amount + if (!empty($arrayfields['p.amount']['checked'])) { + print ''; + } + + // Filter: Status (only placeholder) + if (!empty($arrayfields['p.statut']['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; + + print ''; - print ''; - if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) - { - 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, 'class="right"', $sortfield, $sortorder); - //print_liste_field_titre("Invoices"),"","","",$param,'class="left"',$sortfield,$sortorder); + 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.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['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['transaction']['checked'])) print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); + 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, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.statut']['checked'])) print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, 'class="right"', $sortfield, $sortorder); + + // 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; + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.statut", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); - print "\n"; + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); - $i = 0; - $totalarray = array(); - while ($i < min($num, $limit)) - { - $objp = $db->fetch_object($resql); + print ""; - $paymentstatic->id = $objp->rowid; - $paymentstatic->ref = $objp->ref; + $i = 0; + $totalarray = array(); + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($resql); - $companystatic->id = $objp->socid; - $companystatic->name = $objp->name; - $companystatic->email = $objp->email; + $object->id = $objp->rowid; + $object->ref = $objp->ref; - print ''; + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; + $companystatic->email = $objp->email; - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; - // Date - $dateformatforpayment = 'day'; - if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment = 'dayhour'; - print ''; - if (!$i) $totalarray['nbfield']++; + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; + } - // Thirdparty - print ''; - if (!$i) $totalarray['nbfield']++; + // Ref + if (!empty($arrayfields['p.rowid']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } - // Type - 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']++; + } - // Payment number - print ''; - if (!$i) $totalarray['nbfield']++; + // Thirdparty + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } - // Account - if (!empty($conf->banque->enabled)) - { - print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Bank transaction + if (!empty($arrayfields['transaction']['checked'])) { + $bankline->fetch($objp->fk_bank); + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Bank account + if (!empty($arrayfields['ba.label']['checked'])) { + print ''; - if (!$i) $totalarray['nbfield']++; - } + print $accountstatic->getNomUrl(1); + } + print ''; + if (!$i) $totalarray['nbfield']++; + } - // Amount - print ''; - if (!$i) $totalarray['nbfield']++; - $totalarray['pos'][7] = 'amount'; - $totalarray['val']['amount'] += $objp->amount; + // Amount + if (!empty($arrayfields['p.amount']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + $totalarray['pos'][7] = 'amount'; + $totalarray['val']['amount'] += $objp->amount; + } - if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } + // Status + if (!empty($arrayfields['p.statut']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Buttons print ''; if (!$i) $totalarray['nbfield']++; print ''; - $i++; - } + $i++; + } - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - print "
'; + 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 ''; + $form->select_comptes($search_account, 'search_account', 0, '', 1); + print ''; + print ''; + print ''; + print ''; + print $form->showFilterAndCheckAddButtons(0); print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; - print '
'; - print $paymentstatic->getNomUrl(1); - print '
'.dol_print_date($db->jdate($objp->dp), $dateformatforpayment).''.(($offset * $limit) + $i).''; - if ($objp->socid > 0) - { - print $companystatic->getNomUrl(1, '', 24); - } - print ''.print $object->getNomUrl(1).''.$langs->trans("PaymentTypeShort".$objp->paiement_code).''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''.$objp->num_payment.''; + if ($objp->socid > 0) + { + print $companystatic->getNomUrl(1, '', 24); + } + print ''; - if ($objp->bid > 0) - { - $accountstatic->id = $objp->bid; - $accountstatic->ref = $objp->bref; - $accountstatic->label = $objp->blabel; - $accountstatic->number = $objp->number; - $accountstatic->account_number = $objp->account_number; + // Payment type + if (!empty($arrayfields['c.libelle']['checked'])) { + print ''.$langs->trans("PaymentTypeShort".$objp->paiement_code).''.$bankline->getNomUrl(1, 0).''; + if ($objp->bid > 0) + { + $accountstatic->id = $objp->bid; + $accountstatic->ref = $objp->bref; + $accountstatic->label = $objp->blabel; + $accountstatic->number = $objp->number; + $accountstatic->account_number = $objp->account_number; $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($objp->accountancy_journal); $accountstatic->accountancy_journal = $accountingjournal->code; - print $accountstatic->getNomUrl(1); - } - print ''.price($objp->amount).''.price($objp->amount).''; - if ($objp->statut == 0) print ''; - print $paymentstatic->LibStatut($objp->statut, 5); - if ($objp->statut == 0) print ''; - print ''; + if ($objp->statut == 0) print ''; + print $object->LibStatut($objp->statut, 5); + if ($objp->statut == 0) print ''; + print '
\n"; - print "
"; - print "\n"; -} else { - dol_print_error($db); + print "
"; + print "
"; + print ""; +} +else +{ + dol_print_error($db); } // End of page From 8447817f8c6c4be71d6aa757ccd91ad8dc276805 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 5 Oct 2020 11:38:07 +0200 Subject: [PATCH 2/4] fix swapped array entries --- htdocs/compta/paiement/list.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 74c198b96c2..e45f8f3a14a 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -82,14 +82,14 @@ $hookmanager->initHooks(array('paymentlist')); $extrafields = new ExtraFields($db); $arrayfields = array( - 'p.rowid' => 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), - 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'enabled'=>(!empty($conf->banque->enabled)), 'position'=>50), - 'ba.label' => array('label'=>"Account", 'checked'=>1, 'enabled'=>(!empty($conf->banque->enabled)), 'position'=>60), - 'p.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>70), - 'p.statut' => array('label'=>"Status", 'enabled'=>1, 'checked'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)), 'position'=>80), + 'p.rowid'=>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), + 'transaction'=>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(!empty($conf->banque->enabled))), + 'ba.label'=>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(!empty($conf->banque->enabled))), + 'p.amount'=>array('label'=>"Amount", 'checked'=>1, 'position'=>70), + 'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>80, 'enabled'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))), ); $arrayfields = dol_sort_array($arrayfields, 'position'); From 33b7d06bb9b796bd82aa8ff07a80b5113e6eb45f Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Tue, 6 Oct 2020 08:46:53 +0200 Subject: [PATCH 3/4] address feedback + tooltip + reduce indent --- htdocs/compta/paiement/list.php | 586 ++++++++++++++++---------------- 1 file changed, 302 insertions(+), 284 deletions(-) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index e45f8f3a14a..90f3458918a 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -63,16 +63,18 @@ $search_account = GETPOST("search_account", "int"); $search_paymenttype = GETPOST("search_paymenttype"); $search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x" $search_company = GETPOST("search_company", 'alpha'); +$search_payment_num = GETPOST('search_payment_num', 'alpha'); $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 +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.rowid"; @@ -82,14 +84,15 @@ $hookmanager->initHooks(array('paymentlist')); $extrafields = new ExtraFields($db); $arrayfields = array( - 'p.rowid'=>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), - 'transaction'=>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(!empty($conf->banque->enabled))), - 'ba.label'=>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(!empty($conf->banque->enabled))), - 'p.amount'=>array('label'=>"Amount", 'checked'=>1, 'position'=>70), - 'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>80, 'enabled'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))), + 'p.rowid' => 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), + 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(!empty($conf->banque->enabled))), + 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(!empty($conf->banque->enabled))), + 'p.num_payment' => array('label'=>"Numero", 'checked'=>1, 'position'=>70, 'tooltip'=>"ChequeOrTransferNumber"), + 'p.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>80), + 'p.statut' => array('label'=>"Status", 'checked'=>1, 'position'=>90, 'enabled'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))), ); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -103,26 +106,28 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if(empty($reshook)) -{ +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_account = ""; - $search_amount = ""; - $search_paymenttype = ""; - $search_company = ""; + // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_ref = ''; + $search_account = ''; + $search_amount = ''; + $search_paymenttype = ''; + $search_payment_num = ''; + $search_company = ''; $day = ''; $year = ''; $month = ''; + $option = ''; + $toselect = ''; $search_array_options = array(); } } /* - * View + * View */ $form = new Form($db); @@ -133,11 +138,11 @@ $bankline = new AccountLine($db); llxHeader('', $langs->trans('ListPayment')); -if (GETPOST("orphelins", "alpha")) -{ +if (GETPOST("orphelins", "alpha")) { // Payments not linked to an invoice. Should not happend. For debug only. - $sql = "SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.amount, p.statut"; + $sql = "SELECT p.rowid, p.ref, p.datep, p.amount, p.statut, p.num_paiement as num_payment"; $sql .= ", c.code as paiement_code"; + // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -146,18 +151,18 @@ if (GETPOST("orphelins", "alpha")) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; $sql .= " AND pf.fk_facture IS NULL"; + // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -} -else -{ +} else { // DISTINCT is to avoid duplicate when there is a link to sales representatives - $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep, p.fk_bank, p.amount, p.statut"; + $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep, p.fk_bank, p.amount, p.statut, p.num_paiement as num_payment"; $sql .= ", c.code as paiement_code"; $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"; $sql .= ", s.rowid as socid, s.nom as name, s.email"; + // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -169,28 +174,30 @@ else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) - { + if (!$user->rights->societe->client->voir && !$socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; } $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$socid) - { + if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND sc.fk_user = ".$user->id; } - if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; - if ($userid) - { - if ($userid == -1) $sql .= " AND f.fk_user_author IS NULL"; - else $sql .= " AND f.fk_user_author = ".$userid; + if ($socid > 0) { + $sql .= " AND f.fk_soc = ".$socid; } + if ($userid) { + if ($userid == -1) $sql .= " AND f.fk_user_author IS NULL"; + else $sql .= " AND f.fk_user_author = ".$userid; + } + // Search criteria $sql .= dolSqlDateFilter("p.datep", $day, $month, $year); if ($search_ref) $sql .= natural_search('p.ref', $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_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); + // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -199,12 +206,12 @@ else $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +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 - { + + // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { $page = 0; $offset = 0; } @@ -213,253 +220,264 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - $param .= (GETPOST("orphelins") ? "&orphelins=1" : ""); - $param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : ""); - $param .= ($search_company ? "&search_company=".urlencode($search_company) : ""); - $param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : ""); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); - - $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 ''; - - // Filters: Lines (placeholder) - print ''; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; - } - - // Filter: Ref - if (!empty($arrayfields['p.rowid']['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: Bank transaction number - if (!empty($arrayfields['transaction']['checked'])) { - print ''; - } - - // Filter: Bank account - if (!empty($arrayfields['ba.label']['checked'])) { - print ''; - } - - // Filter: Amount - if (!empty($arrayfields['p.amount']['checked'])) { - print ''; - } - - // Filter: Status (only placeholder) - if (!empty($arrayfields['p.statut']['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; - - 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.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['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['transaction']['checked'])) print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); - 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, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['p.statut']['checked'])) print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, 'class="right"', $sortfield, $sortorder); - - // 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 ""; - - $i = 0; - $totalarray = array(); - while ($i < min($num, $limit)) - { - $objp = $db->fetch_object($resql); - - $object->id = $objp->rowid; - $object->ref = $objp->ref; - - $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 ''; - } - - // Ref - if (!empty($arrayfields['p.rowid']['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']++; - } - - // Payment type - if (!empty($arrayfields['c.libelle']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Bank transaction - if (!empty($arrayfields['transaction']['checked'])) { - $bankline->fetch($objp->fk_bank); - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Bank 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'][7] = 'amount'; - $totalarray['val']['amount'] += $objp->amount; - } - - // Status - if (!empty($arrayfields['p.statut']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // 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 ''; - 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 ''; - $form->select_comptes($search_account, 'search_account', 0, '', 1); - print ''; - print ''; - print ''; - print ''; - print $form->showFilterAndCheckAddButtons(0); - print '
'.(($offset * $limit) + $i).''.print $object->getNomUrl(1).''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''; - if ($objp->socid > 0) - { - print $companystatic->getNomUrl(1, '', 24); - } - print ''.$langs->trans("PaymentTypeShort".$objp->paiement_code).''.$bankline->getNomUrl(1, 0).''; - if ($objp->bid > 0) - { - $accountstatic->id = $objp->bid; - $accountstatic->ref = $objp->bref; - $accountstatic->label = $objp->blabel; - $accountstatic->number = $objp->number; - $accountstatic->account_number = $objp->account_number; - - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objp->accountancy_journal); - $accountstatic->accountancy_journal = $accountingjournal->code; - - print $accountstatic->getNomUrl(1); - } - print ''.price($objp->amount).''; - if ($objp->statut == 0) print ''; - print $object->LibStatut($objp->statut, 5); - if ($objp->statut == 0) print ''; - print '
"; - print "
"; - print "
"; -} -else -{ +if (!$resql) { dol_print_error($db); + llxFooter(); + $db->close(); + exit; } +$num = $db->num_rows($resql); + +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +$param .= (GETPOST("orphelins") ? "&orphelins=1" : ''); +$param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : ''); +$param .= ($search_company ? "&search_company=".urlencode($search_company) : ''); +$param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : ''); +$param .= ($search_payment_num ? "&search_payment_num=".urlencode($search_payment_num) : ''); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); + +$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 ''; + +// Filters: Lines (placeholder) +print ''; +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; +} + +// Filter: Ref +if (!empty($arrayfields['p.rowid']['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: Bank transaction number +if (!empty($arrayfields['transaction']['checked'])) { + print ''; +} + +// Filter: Cheque number (fund transfer) +if (!empty($arrayfields['p.num_payment']['checked'])) { + print ''; +} + +// Filter: Bank account +if (!empty($arrayfields['ba.label']['checked'])) { + print ''; +} + +// Filter: Amount +if (!empty($arrayfields['p.amount']['checked'])) { + print ''; +} + +// Filter: Status (only placeholder) +if (!empty($arrayfields['p.statut']['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; + +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.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['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_payment']['checked'])) print_liste_field_titre($arrayfields['p.num_payment']['label'], $_SERVER["PHP_SELF"], "p.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_payment']['tooltip']); +if (!empty($arrayfields['transaction']['checked'])) print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); +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, 'class="right"', $sortfield, $sortorder); +if (!empty($arrayfields['p.statut']['checked'])) print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", '', $param, 'class="right"', $sortfield, $sortorder); + +// 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 ""; + +$i = 0; +$totalarray = array(); +while ($i < min($num, $limit)) { + $objp = $db->fetch_object($resql); + + $object->id = $objp->rowid; + $object->ref = $objp->ref; + + $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.rowid']['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']++; + } + + // Payment type + if (!empty($arrayfields['c.libelle']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Filter: Cheque number (fund transfer) + if (!empty($arrayfields['p.num_payment']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Bank transaction + if (!empty($arrayfields['transaction']['checked'])) { + $bankline->fetch($objp->fk_bank); + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Bank 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'][8] = 'amount'; + $totalarray['val']['amount'] += $objp->amount; + } + + // Status + if (!empty($arrayfields['p.statut']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // 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 ''; + 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 ''; + print ''; + $form->select_comptes($search_account, 'search_account', 0, '', 1); + print ''; + print ''; + print ''; + print ''; +print $form->showFilterAndCheckAddButtons(0); +print '
'.(($offset * $limit) + $i).''.$object->getNomUrl(1).''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''; + if ($objp->socid > 0) { + print $companystatic->getNomUrl(1, '', 24); + } + print ''.$langs->trans("PaymentTypeShort".$objp->paiement_code).''.$objp->num_payment.''.$bankline->getNomUrl(1, 0).''; + if ($objp->bid > 0) { + $accountstatic->id = $objp->bid; + $accountstatic->ref = $objp->bref; + $accountstatic->label = $objp->blabel; + $accountstatic->number = $objp->number; + $accountstatic->account_number = $objp->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->accountancy_journal); + $accountstatic->accountancy_journal = $accountingjournal->code; + + print $accountstatic->getNomUrl(1); + } + print ''.price($objp->amount).''; + if ($objp->statut == 0) print ''; + print $object->LibStatut($objp->statut, 5); + if ($objp->statut == 0) print ''; + print '
"; +print "
"; +print "
"; + // End of page llxFooter(); $db->close(); From 8f542a857215b34e5a8f8b10e4c8cf188522f0a4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 6 Oct 2020 06:56:08 +0000 Subject: [PATCH 4/4] Fixing style errors. --- htdocs/compta/paiement/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 90f3458918a..e2f3ea9012b 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -106,7 +106,7 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if(empty($reshook)) { +if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // All tests are required to be compatible with all browsers @@ -186,7 +186,7 @@ if (GETPOST("orphelins", "alpha")) { } if ($userid) { if ($userid == -1) $sql .= " AND f.fk_user_author IS NULL"; - else $sql .= " AND f.fk_user_author = ".$userid; + else $sql .= " AND f.fk_user_author = ".$userid; } // Search criteria