Fix: Pagination

This commit is contained in:
Laurent Destailleur 2013-11-18 12:20:53 +01:00
parent e8101e3cde
commit 69f0d596ba
2 changed files with 37 additions and 38 deletions

View File

@ -65,28 +65,26 @@ llxHeader('',$langs->trans("TaxAndDividendsArea"));
$title=$langs->trans("TaxAndDividendsArea"); $title=$langs->trans("TaxAndDividendsArea");
if ($_GET["mode"] == 'sconly') $title=$langs->trans("SocialContributionsPayments"); if ($_GET["mode"] == 'sconly') $title=$langs->trans("SocialContributionsPayments");
print_fiche_titre($title,($year?"<a href='index.php?year=".($year-1)."'>".img_previous()."</a> ".$langs->trans("Year")." $year <a href='index.php?year=".($year+1)."'>".img_next()."</a>":"")); $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?"<a href='index.php?year=".($year-1).$param."'>".img_previous()."</a> ".$langs->trans("Year")." $year <a href='index.php?year=".($year+1).$param."'>".img_next()."</a>":""));
if ($year) $param.='&year='.$year;
// Social contributions only
if (GETPOST("mode") != 'sconly')
{ {
print $langs->trans("DescTaxAndDividendsArea").'<br>'; print $langs->trans("DescTaxAndDividendsArea").'<br>';
print "<br>"; print "<br>";
}
print_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
// Social contributions
if ($_GET["mode"] != 'sconly')
{
print_titre($langs->trans("SocialContributionsPayments"));
}
if ($_GET["mode"] == 'sconly')
{
$param='&mode=sconly';
} }
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">"; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'width="120"',$sortfield,$sortorder); 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("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); 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, // 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 // 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 .= " (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 .= ")";
} }
$sql.= $db->order($sortfield,$sortorder); if (! preg_match('/^pv/',$sortfield)) $sql.= $db->order($sortfield,$sortorder);
//$sql.= $db->plimit($limit+1,$offset); //$sql.= $db->plimit($limit+1,$offset);
//print $sql; //print $sql;
@ -184,18 +182,18 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
$tva = new Tva($db); $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 = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as f "; $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv";
$sql.= " WHERE f.entity = ".$conf->entity; $sql.= " WHERE pv.entity = ".$conf->entity;
if ($year > 0) if ($year > 0)
{ {
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // 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 // 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); $result = $db->query($sql);
if ($result) if ($result)
@ -205,12 +203,12 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
$total = 0 ; $total = 0 ;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="120" class="nowrap">'.$langs->trans("PeriodEndDate").'</td>'; print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="120"',$sortfield,$sortorder);
print "<td>".$langs->trans("Label")."</td>"; print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder);
print '<td align="right" width="10%">'.$langs->trans("ExpectedToPay")."</td>"; print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
print '<td align="right" width="10%">'.$langs->trans("RefPayment")."</td>"; print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder);
print '<td align="center" width="15%">'.$langs->trans("DatePayment")."</td>"; print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'align="center"',$sortfield,$sortorder);
print '<td align="right" width="10%">'.$langs->trans("PayedByThisPayment")."</td>"; print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
print "</tr>\n"; print "</tr>\n";
$var=1; $var=1;
while ($i < $num) while ($i < $num)
@ -227,12 +225,13 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
print '<td align="right">'.price($obj->amount)."</td>"; print '<td align="right">'.price($obj->amount)."</td>";
// Ref payment
$tva_static->id=$obj->rowid; $tva_static->id=$obj->rowid;
$tva_static->ref=$obj->rowid; $tva_static->ref=$obj->rowid;
print '<td align="right">'.$tva_static->getNomUrl(1)."</td>\n"; print '<td align="left">'.$tva_static->getNomUrl(1)."</td>\n";
print '<td align="center">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n"; print '<td align="center">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
print "<td align=\"right\">".price($obj->amount)."</td>"; print '<td align="right">'.price($obj->amount)."</td>";
print "</tr>\n"; print "</tr>\n";
$i++; $i++;

View File

@ -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 * @param string $title Title to show
* @return string Title to show * @return string Title to show
@ -2462,16 +2462,16 @@ function print_titre($title)
/** /**
* Show a title with picto * 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 $mesg Added message to show on right
* @param string $picto Icon to use before title (should be a 32x32 transparent png file) * @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 $pictoisfullpath 1=Icon name is a full absolute url of image
* @param int $id To force an id on html objects * @param int $id To force an id on html objects
* @return void * @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);
} }
/** /**