Ajout filtre sur les annes et les mois

This commit is contained in:
Rodolphe Quiedeville 2003-11-17 10:12:30 +00:00
parent 92524592cc
commit 55b8f24cab

View File

@ -20,11 +20,6 @@
*
*/
/**
* Gestion d'une proposition commerciale
* @package propale
*/
require("./pre.inc.php");
$user->getrights('commande');
@ -40,22 +35,8 @@ if ($user->societe_id > 0)
$socidp = $user->societe_id;
}
llxHeader();
/******************************************************************************/
/* Fin des Actions */
/******************************************************************************/
/****************************************************************************
* *
* *
* Mode Liste des propales *
* *
* *
****************************************************************************/
if ($sortfield == "")
{
$sortfield="c.rowid";
@ -72,7 +53,7 @@ $offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
$sql = "SELECT s.nom, s.idp, c.rowid, c.ref, c.total_ht,".$db->pdate("c.date_commande")." as date_commande" ;
$sql = "SELECT s.nom, s.idp, c.rowid, c.ref, c.total_ht,".$db->pdate("c.date_commande")." as date_commande, c.fk_statut" ;
$sql .= " FROM llx_societe as s, llx_commande as c WHERE c.fk_soc = s.idp";
if ($socidp)
@ -80,6 +61,14 @@ if ($socidp)
$sql .= " AND s.idp = $socidp";
}
if ($_GET["month"] > 0)
{
$sql .= " AND date_format(c.date_commande, '%Y-%m') = '$year-$month'";
}
if ($_GET["year"] > 0)
{
$sql .= " AND date_format(c.date_commande, '%Y') = $year";
}
if (strlen($HTTP_POST_VARS["sf_ref"]) > 0)
{
@ -93,32 +82,32 @@ if ( $db->query($sql) )
{
$num = $db->num_rows();
print_barre_liste("Commandes", $page, $PHP_SELF,"&socidp=$socidp",$sortfield,$sortorder,'',$num);
$i = 0;
print '<TABLE border="0" width="100%" cellspacing="0" cellpadding="4">';
print '<TR class="liste_titre">';
print_liste_field_titre_new ("Réf",$PHP_SELF,"p.ref","","&amp;socidp=$socidp",'width="15%"',$sortfield);
print_liste_field_titre_new ("Réf",$PHP_SELF,"c.ref","","&amp;socidp=$socidp",'width="15%"',$sortfield);
print_liste_field_titre_new ("Société",$PHP_SELF,"s.nom","","&amp;socidp=$socidp",'width="30%"',$sortfield);
print_liste_field_titre_new ("Date",$PHP_SELF,"c.date_commande","","&amp;socidp=$socidp", 'width="25%" align="right" colspan="2"',$sortfield);
print_liste_field_titre_new ("Prix",$PHP_SELF,"p.price","","&amp;socidp=$socidp", ' width="20%" align="right"',$sortfield);
print_liste_field_titre_new ("Statut",$PHP_SELF,"p.fk_statut","","&amp;socidp=$socidp",'width="10%" align="center"',$sortfield);
print_liste_field_titre_new ("Statut",$PHP_SELF,"c.fk_statut","","&amp;socidp=$socidp",'width="10%" align="center"',$sortfield);
print "</tr>\n";
$var=True;
$generic_commande = new Commande($db);
while ($i < min($num,$limit))
{
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></TD>\n";
print "<TD><a href=\"../comm/fiche.php?socid=$objp->idp\">$objp->nom</a></TD>\n";
print "<tr $bc[$var]>";
print "<td><a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></td>\n";
print "<td><a href=\"../comm/fiche.php?socid=$objp->idp\">$objp->nom</a></td>\n";
$now = time();
$lim = 3600 * 24 * 15 ;
@ -132,19 +121,18 @@ if ( $db->query($sql) )
print "<td>&nbsp;</td>";
}
print "<TD align=\"right\">";
print "<td align=\"right\">";
$y = strftime("%Y",$objp->date_commande);
$m = strftime("%m",$objp->date_commande);
print strftime("%d",$objp->date_commande)."\n";
print " <a href=\"propal.php?year=$y&amp;month=$m\">";
print " <a href=\"liste.php?year=$y&amp;month=$m\">";
print strftime("%B",$objp->date_commande)."</a>\n";
print " <a href=\"propal.php?year=$y\">";
print " <a href=\"liste.php?year=$y\">";
print strftime("%Y",$objp->date_commande)."</a></TD>\n";
print "<TD align=\"right\">".price($objp->total_ht)."</TD>\n";
print "<TD align=\"center\">$objp->statut</TD>\n";
print "</TR>\n";
print '<td align="center">'.$generic_commande->statuts[$objp->fk_statut].'</td>';
print "</tr>\n";
$total = $total + $objp->price;
$subtotal = $subtotal + $objp->price;