* 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/fourn/facture/index.php \ingroup fournisseur,facture \brief Lsite des factures fournisseurs \version $Revision$ */ require("./pre.inc.php"); require("../../contact.class.php"); require("../../facturefourn.class.php"); llxHeader(); $socid = $_GET["socid"]; /* * Sécurité accés client */ if ($user->societe_id > 0) { $_GET["action"] = ''; $socid = $user->societe_id; } if ($_GET["action"] == 'delete') { $fac = new FactureFourn($db); $fac->delete($_GET["facid"]); $facid = 0 ; } $page=$_GET["page"]; $sortorder=$_GET["sortorder"]; $sortfield=$_GET["sortfield"]; if ($page == -1) { $page = 0 ; } $limit = $conf->liste_limit; $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; /* * Recherche * */ if ($_POST["mode"] == 'search') { if ($_POST["mode-search"] == 'soc') { $sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s "; $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'"; } if ( $db->query($sql) ) { if ( $db->num_rows() == 1) { $obj = $db->fetch_object(); $socid = $obj->idp; } $db->free(); } } /* * Mode Liste * */ $sortorder = $_GET["sortorder"]; $sortfield = $_GET["sortfield"]; if ($sortorder == "") { $sortorder="DESC"; } if ($sortfield == "") { $sortfield="fac.datef"; } $sql = "SELECT s.idp as socid, s.nom, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, s.prefix_comm, fac.total_ht, fac.total_ttc, fac.paye as paye, fac.fk_statut as fk_statut, fac.libelle, ".$db->pdate("fac.datef")." as datef, fac.rowid as facid, fac.facnumber"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as fac "; $sql .= " WHERE fac.fk_soc = s.idp"; if ($socid) { $sql .= " AND s.idp = $socid"; } if ($_GET["filtre"]) { $filtrearr = split(",", $_GET["filtre"]); foreach ($filtrearr as $fil) { $filt = split(":", $fil); $sql .= " AND " . $filt[0] . " = " . $filt[1]; } } $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit+1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; if ($socid) { $soc = new Societe($db); $soc->fetch($socid); } print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,"index.php","&socidp=$socidp",$sortfield,$sortorder,'',$num); print ''; print ''; print_liste_field_titre($langs->trans("Ref"),"index.php","facnumber","&socid=$socid","","",$sortfield); print_liste_field_titre($langs->trans("Date"),"index.php","fac.datef","&socid=$socid","","",$sortfield); print_liste_field_titre($langs->trans("Label"),"index.php","fac.libelle","&socid=$socid","","",$sortfield); print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","&socid=$socid","","",$sortfield); print_liste_field_titre($langs->trans("AmountHT"),"index.php","fac.total_ht","&socid=$socid","",'align="right"',$sortfield); print_liste_field_titre($langs->trans("AmountTTC"),"index.php","fac.total_ttc","&socid=$socid","",'align="right"',$sortfield); print_liste_field_titre($langs->trans("Status"),"index.php","fk_statut,paye","&socid=$socid","",'align="center"',$sortfield); print "\n"; $var=True; while ($i < min($num,$limit)) { $obj = $db->fetch_object(); $var=!$var; print ""; print "\n"; print "\n"; print ''; print ''; print ''; // Affiche statut de la facture if ($obj->paye) { $class = "normal"; } else { if ($obj->fk_statut == 0) { $class = "normal"; } else { $class = "impayee"; } } if (! $obj->paye) { if ($obj->fk_statut == 0) { print ''; } elseif ($obj->fk_statut == 3) { print ''; } else { print ''; } } else { print ''; } print "\n"; $i++; } print "
facid\">".img_object($langs->trans("ShowBill"),"bill")."\n"; print " facid\">$obj->facnumber".strftime("%d %b %Y",$obj->datef)."'.stripslashes("$obj->libelle").''; print ''.img_object($langs->trans("ShowSupplier"),"company").''; print ' '.$obj->nom.''; print ''.price($obj->total_ht).''.price($obj->total_ttc).'brouillonannulée'.($obj->am?"commencé":"impayée").'payée
"; $db->free(); } else { dolibarr_print_error($db); } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>