From 69f0d596ba0527548050d5e7d80f339f49d83abb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Nov 2013 12:20:53 +0100 Subject: [PATCH] Fix: Pagination --- htdocs/compta/charges/index.php | 59 +++++++++++++++---------------- htdocs/core/lib/functions.lib.php | 16 ++++----- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 909417d0e71..21d68d42663 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -65,28 +65,26 @@ llxHeader('',$langs->trans("TaxAndDividendsArea")); $title=$langs->trans("TaxAndDividendsArea"); if ($_GET["mode"] == 'sconly') $title=$langs->trans("SocialContributionsPayments"); -print_fiche_titre($title,($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":"")); +$param=''; +if (GETPOST("mode") == 'sconly') $param='&mode=sconly'; +if ($sortfield) $param.='&sortfield='.$sortfield; +if ($sortorder) $param.='&sortorder='.$sortorder; -if ($_GET["mode"] != 'sconly') +print_fiche_titre($title, ($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":"")); + +if ($year) $param.='&year='.$year; + +// Social contributions only +if (GETPOST("mode") != 'sconly') { print $langs->trans("DescTaxAndDividendsArea").'
'; print "
"; -} - -// Social contributions -if ($_GET["mode"] != 'sconly') -{ - print_titre($langs->trans("SocialContributionsPayments")); -} - -if ($_GET["mode"] == 'sconly') -{ - $param='&mode=sconly'; + print_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); } print ''; -print ""; +print ''; print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'width="120"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"c.libelle","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"cs.fk_type","",$param,'',$sortfield,$sortorder); @@ -110,10 +108,10 @@ if ($year > 0) // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire $sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; - $sql .= "OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; + $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; $sql .= ")"; } -$sql.= $db->order($sortfield,$sortorder); +if (! preg_match('/^pv/',$sortfield)) $sql.= $db->order($sortfield,$sortorder); //$sql.= $db->plimit($limit+1,$offset); //print $sql; @@ -184,18 +182,18 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly') $tva = new Tva($db); - print_titre($langs->trans("VATPayments")); + print_fiche_titre($langs->trans("VATPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); - $sql = "SELECT f.rowid, f.amount, f.label, f.datev as dm"; - $sql.= " FROM ".MAIN_DB_PREFIX."tva as f "; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm"; + $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; + $sql.= " WHERE pv.entity = ".$conf->entity; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql.= " AND f.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } - $sql.= " ORDER BY dm DESC"; + if (preg_match('/^pv/',$sortfield)) $sql.= $db->order($sortfield,$sortorder); $result = $db->query($sql); if ($result) @@ -205,12 +203,12 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly') $total = 0 ; print '
'; print ''; - print ''; - print ""; - print '"; - print '"; - print '"; - print '"; + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="120"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder); print "\n"; $var=1; while ($i < $num) @@ -227,12 +225,13 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly') print '"; + // Ref payment $tva_static->id=$obj->rowid; $tva_static->ref=$obj->rowid; - print '\n"; + print '\n"; print '\n"; - print ""; + print '"; print "\n"; $i++; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a311c78b496..220721d6f5e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1212,7 +1212,7 @@ function dol_print_skype($skype,$cid=0,$socid=0,$addlink=0,$max=64) $newskype.=' '; $newskype.=dol_trunc($skype,$max); $newskype.=''; - + if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { $type='AC_SKYPE'; $link=''; @@ -2372,7 +2372,7 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $morepar * Get title line of an array * * @param string $name Label of field - * @param int $thead 0=To use with standard table forat, 1=To use inside , 2=To use with
+ * @param int $thead 0=To use with standard table forat, 1=To use inside
, 2=To use with
* @param string $file Url used when we click on sort picto * @param string $field Field to use for new sorting. Empty if this field is not sortable. * @param string $begin ("" by defaut) @@ -2392,7 +2392,7 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m $tag='th'; if ($thead==2) $tag='div'; - + // If field is used as sort criteria we use a specific class // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom") if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) $out.= '<'.$tag.' class="liste_titre_sel" '. $moreattrib.'>'; @@ -2449,7 +2449,7 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m } /** - * Show a title (deprecated. use print_fiche_titre instrad) + * Show a title (deprecated. use print_fiche_titre instead) * * @param string $title Title to show * @return string Title to show @@ -2462,16 +2462,16 @@ function print_titre($title) /** * Show a title with picto * - * @param string $titre Title to show + * @param string $title Title to show * @param string $mesg Added message to show on right * @param string $picto Icon to use before title (should be a 32x32 transparent png file) * @param int $pictoisfullpath 1=Icon name is a full absolute url of image * @param int $id To force an id on html objects * @return void */ -function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='') +function print_fiche_titre($title, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='') { - print load_fiche_titre($titre, $mesg, $picto, $pictoisfullpath, $id); + print load_fiche_titre($title, $mesg, $picto, $pictoisfullpath, $id); } /** @@ -3004,7 +3004,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr $sql.= " WHERE t.active=1 AND t.fk_pays = p.rowid AND p.code='".$thirdparty_seller->country_code."'"; $sql.= " ORDER BY t.taux DESC, t.recuperableonly ASC"; $sql.= $db->plimit(1); - + $resql=$db->query($sql); if ($resql) {
'.$langs->trans("PeriodEndDate").'".$langs->trans("Label")."'.$langs->trans("ExpectedToPay")."'.$langs->trans("RefPayment")."'.$langs->trans("DatePayment")."'.$langs->trans("PayedByThisPayment")."
'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm),'day')."".price($obj->amount)."'.price($obj->amount)."