* Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2007 Regis Houssin * * 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/index.php \ingroup fournisseur \brief Page accueil de la zone fournisseurs \version $Revision$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.commande.class.php'); require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.facture.class.php'); if (!$user->rights->societe->lire) accessforbidden(); $langs->load("suppliers"); $langs->load("orders"); $langs->load("companies"); // Sécurité accés client $socid=''; if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } /* * Affichage page */ $commandestatic=new CommandeFournisseur($db); $facturestatic=new FactureFournisseur($db); $companystatic=new Societe($db); llxHeader("",$langs->trans("SuppliersArea")); print_fiche_titre($langs->trans("SuppliersArea")); print ''; print '\n"; print '\n"; print "
'; /* * Liste des categories * \TODO Il n'y a aucun écran pour les saisir ! */ $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."fournisseur_categorie"; $sql.= " ORDER BY label ASC"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { print ''; print '\n"; $var=True; while ($obj = $db->fetch_object($resql)) { $var=!$var; print "\n"; print '\n"; } print "
'; print $langs->trans("Category"); print "
'.stripslashes($obj->label).''; print ''; print '('.$langs->trans("Stats").')'; print "
\n"; print "
\n"; } $db->free($resql); } else { dolibarr_print_error($db); } /* * */ $commande = new CommandeFournisseur($db); $sql = "SELECT count(cf.rowid), fk_statut,"; $sql.= " cf.rowid,cf.ref"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur as cf"; $sql.= " WHERE cf.fk_soc = s.idp "; $sql.= " GROUP BY cf.fk_statut"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; print ''; print ''; print "\n"; $var=True; while ($i < $num) { $row = $db->fetch_row($resql); $var=!$var; print ""; print ''; print ''; print ''; print "\n"; $i++; } print "
'.$langs->trans("Orders").''.$langs->trans("Nb").' 
'.$commande->statuts[$row[1]].''.$row[0].''.$commande->LibStatut($row[1],3).'
"; print "
\n"; $db->free($resql); } else { dolibarr_print_error($db); } /* * Commandes brouillons */ if ($conf->fournisseur->enabled) { $langs->load("orders"); $sql = "SELECT c.rowid, c.ref, c.total_ttc, s.nom, s.idp"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE c.fk_soc = s.idp AND c.fk_statut = 0"; if ($socid) { $sql .= " AND c.fk_soc = ".$socid; } $resql = $db->query($sql); if ($resql) { $total = 0; $num = $db->num_rows($resql); if ($num) { print ''; print ''; print ''; $i = 0; $var = true; while ($i < $num) { $var=!$var; $obj = $db->fetch_object($resql); print "'; print ''; print ''; $i++; $total += $obj->total_ttc; } if ($total>0) { $var=!$var; print '"; } print "
'.$langs->trans("DraftOrders").'
"; $commandestatic->id=$obj->rowid; $commandestatic->ref=$obj->ref; print $commandestatic->getNomUrl(1,'',16); print ''; $companystatic->id=$obj->idp; $companystatic->nom=$obj->nom; $companystatic->client=0; print $companystatic->getNomUrl(1,'',16); print ''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($total)."
"; print "
\n"; } } } /** * Factures brouillons */ if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) { $sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.type,"; $sql.= " s.nom, s.idp"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0"; if ($socid) { $sql .= " AND f.fk_soc = ".$socid; } $resql = $db->query($sql); if ( $resql ) { $num = $db->num_rows($resql); if ($num) { print ''; print ''; print ''; $i = 0; $tot_ttc = 0; $var = True; while ($i < $num && $i < 20) { $obj = $db->fetch_object($resql); $var=!$var; print ''; print ''; print ''; print ''; $tot_ttc+=$obj->total_ttc; $i++; } print ''; print ''; print ''; print "
'.$langs->trans("DraftBills").' ('.$num.')
'; $facturestatic->ref=$obj->facnumber; $facturestatic->id=$obj->rowid; $facturestatic->type=$obj->type; print $facturestatic->getNomUrl(1,''); print ''; $companystatic->id=$obj->idp; $companystatic->nom=$obj->nom; $companystatic->client=0; print $companystatic->getNomUrl(1,'',16); print ''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($tot_ttc).'
"; print "
\n"; } $db->free($resql); } else { dolibarr_print_error($db); } } /* * * */ print "
'; /* * Liste des 10 derniers saisis * */ $sql = "SELECT s.idp, s.nom, s.ville,".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm"; $sql.= " , code_fournisseur, code_compta_fournisseur"; if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st"; if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = st.id AND s.fournisseur=1"; if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql .= " AND s.idp=".$socid; $sql .= " ORDER BY s.datec DESC LIMIT 10; "; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; print ''; print ''; print "\n"; print "\n"; print '\n"; print "\n"; $var=True; while ($obj = $db->fetch_object($resql) ) { $var=!$var; print ""; print '\n"; print ''; print ''; print "\n"; } print "
".$langs->trans("Company")."".$langs->trans("SupplierCode")."'.$langs->trans("DateCreation")."
'.img_object($langs->trans("ShowSupplier"),"company").''; print " idp\">$obj->nom'.$obj->code_fournisseur.' '.dolibarr_print_date($obj->datec,'day').'
\n"; $db->free($resql); } else { dolibarr_print_error($db); } print "
\n"; $db->close(); llxFooter('$Date$ - $Revision$'); ?>