* Copyright (C) 2004-2005 Laurent Destailleur * * 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 2 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ * */ /** \file htdocs/commande/liste.php \ingroup commande \brief Page liste des commandes \version $Revision$ */ require("./pre.inc.php"); $langs->load("orders"); $user->getrights('commande'); if (!$user->rights->commande->lire) accessforbidden(); /* * Sécurité accés client */ if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } llxHeader(); $begin=$_GET["begin"]; $sortorder=$_GET["sortorder"]; $sortfield=$_GET["sortfield"]; if ($sortfield == "") { $sortfield="c.rowid"; } if ($sortorder == "") { $sortorder="DESC"; } $limit = $conf->liste_limit; $offset = $limit * $_GET["page"] ; $pageprev = $_GET["page"] - 1; $pagenext = $_GET["page"] + 1; $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 ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c WHERE c.fk_soc = s.idp"; 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($_POST["sf_ref"]) > 0) { $sql .= " AND c.ref like '%".$_POST["sf_ref"] . "%'"; } $sql .= " ORDER BY $sortfield $sortorder"; $sql .= $db->plimit($limit + 1,$offset); if ( $db->query($sql) ) { $num = $db->num_rows(); print_barre_liste($langs->trans("ListOfOrders"), $_GET["page"], "liste.php","&socidp=$socidp",$sortfield,$sortorder,'',$num); $i = 0; print ''; print ''; print_liste_field_titre($langs->trans("Ref"),"liste.php","c.ref","","&socidp=$socidp",'width="15%"',$sortfield); print_liste_field_titre($langs->trans("Company"),"liste.php","s.nom","","&socidp=$socidp",'width="30%"',$sortfield); print_liste_field_titre($langs->trans("Date"),"liste.php","c.date_commande","","&socidp=$socidp", 'width="25%" align="right" colspan="2"',$sortfield); print_liste_field_titre($langs->trans("Status"),"liste.php","c.fk_statut","","&socidp=$socidp",'width="10%" align="center"',$sortfield); print "\n"; $var=True; $generic_commande = new Commande($db); while ($i < min($num,$limit)) { $objp = $db->fetch_object(); $var=!$var; print ""; print "\n"; print "\n"; $now = time(); $lim = 3600 * 24 * 15 ; if ( ($now - $objp->date_commande) > $lim && $objp->statutid == 1 ) { print ""; } else { print ""; } print "\n"; print ''; print "\n"; $total = $total + $objp->price; $subtotal = $subtotal + $objp->price; $i++; } print "
rowid\">".img_object($langs->trans("ShowOrder"),"order")." ".$objp->ref."idp\">".img_object($langs->trans("ShowCompany"),"company")." ".$objp->nom." > 15 jours "; $y = strftime("%Y",$objp->date_commande); $m = strftime("%m",$objp->date_commande); print strftime("%d",$objp->date_commande)."\n"; print " "; print strftime("%B",$objp->date_commande)."\n"; print " "; print strftime("%Y",$objp->date_commande)."'.$generic_commande->statuts[$objp->fk_statut].'
"; $db->free(); } else { print dolibarr_print_error($db); } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>