From c22a21cb90ec362606a4de89e37be48a8a14bc65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Jun 2005 11:34:38 +0000 Subject: [PATCH] Qual: Uniformisation du code --- htdocs/fourn/commande/index.php | 25 ++-- htdocs/fourn/commande/liste.php | 15 ++- htdocs/fourn/contact.php | 12 +- htdocs/fourn/facture/index.php | 216 +++++++++++++++++--------------- htdocs/fourn/fiche.php | 54 ++++---- htdocs/fourn/product/liste.php | 30 ++--- 6 files changed, 187 insertions(+), 165 deletions(-) diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 7cd19c31de7..9e9a41f946d 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -21,7 +21,8 @@ * */ -/** \file htdocs/fourn/commande/index.php +/** + \file htdocs/fourn/commande/index.php \ingroup commande \brief Page accueil commandes fournisseurs \version $Revision$ @@ -43,17 +44,20 @@ if ($user->societe_id > 0) $commande = new CommandeFournisseur($db); + + print_barre_liste($langs->trans("SuppliersOrders"), $page, "index.php", "", $sortfield, $sortorder, '', $num); -print ''; -print ''; - $var=True; + $var=true; while ($i < min($num,$conf->liste_limit)) { @@ -150,5 +153,5 @@ else $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/fourn/contact.php b/htdocs/fourn/contact.php index bdd50d6cbaa..651ec5e8ed3 100644 --- a/htdocs/fourn/contact.php +++ b/htdocs/fourn/contact.php @@ -68,12 +68,12 @@ if (strlen($stcomm)) { } if (strlen($begin)) { - $sql .= " AND upper(p.name) like '$begin%'"; + $sql .= " AND p.name like '$begin%'"; } if ($contactname) { - $sql .= " AND lower(p.name) like '%".strtolower($contactname)."%'"; - $sortfield = "lower(p.name)"; + $sql .= " AND p.name like '%".strtolower($contactname)."%'"; + $sortfield = "p.name"; $sortorder = "ASC"; } @@ -91,9 +91,9 @@ if ($result) { print '
'; -$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"; +print ''; +print '
'; + +$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) @@ -127,7 +131,8 @@ else print '
'; + $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/fourn/commande/liste.php b/htdocs/fourn/commande/liste.php index 396998d221c..9e156dc2f17 100644 --- a/htdocs/fourn/commande/liste.php +++ b/htdocs/fourn/commande/liste.php @@ -30,6 +30,9 @@ require("./pre.inc.php"); +$langs->load("orders"); + + $page = ( is_numeric($_GET["page"]) ? $_GET["page"] : 0 ); $socid = ( is_numeric($_GET["socid"]) ? $_GET["socid"] : 0 ); $sortorder = $_GET["sortorder"]; @@ -62,10 +65,10 @@ $offset = $conf->liste_limit * $page ; * Mode Liste */ -$sql = "SELECT s.idp, s.nom, ".$db->pdate("cf.date_commande")." as dc"; -$sql .= " ,cf.rowid,cf.ref, cf.fk_statut"; -$sql .= " FROM ".MAIN_DB_PREFIX."societe as s "; -$sql .= " , ".MAIN_DB_PREFIX."commande_fournisseur as cf"; +$sql = "SELECT s.idp, s.nom, ".$db->pdate("cf.date_commande")." as dc,"; +$sql .= " cf.rowid,cf.ref, cf.fk_statut"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,"; +$sql .= " ".MAIN_DB_PREFIX."commande_fournisseur as cf"; $sql .= " WHERE cf.fk_soc = s.idp "; if ($socid) @@ -114,7 +117,7 @@ if ($resql) print ''; print '
'; print ''; - print_liste_field_titre($langs->trans("Lastname"),"contact.php","lower(p.name)", $begin, "", "", $sortfield); - print_liste_field_titre($langs->trans("Firstname"),"contact.php","lower(p.firstname)", $begin, "", "", $sortfield); - print_liste_field_titre($langs->trans("Company"),"contact.php","lower(s.nom)", $begin, "", "", $sortfield); + print_liste_field_titre($langs->trans("Lastname"),"contact.php","p.name", $begin, "", "", $sortfield); + print_liste_field_titre($langs->trans("Firstname"),"contact.php","p.firstname", $begin, "", "", $sortfield); + print_liste_field_titre($langs->trans("Company"),"contact.php","s.nom", $begin, "", "", $sortfield); print ''; print ''; print "\n"; diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php index 4e7e81e469d..0ebef580e43 100644 --- a/htdocs/fourn/facture/index.php +++ b/htdocs/fourn/facture/index.php @@ -142,118 +142,134 @@ $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $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); + $num = $db->num_rows($result); + $i = 0; - print '
'.$langs->trans("Email").''.$langs->trans("Phone").'
'; - 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"; - - // Lignes des champs de filtre - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - print ''; - - $fac = new FactureFournisseur($db); - - $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"; - } - } - - print ''; - + + print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,"index.php","&socidp=$socidp",$sortfield,$sortorder,'',$num); + + print '
'; - print ''; - print ' '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
facid\">".img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber."".strftime("%d %b %Y",$obj->datef)."'.stripslashes("$obj->libelle").''; - print ''.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.''; - print ''.price($obj->total_ht).''.price($obj->total_ttc).''; - if (! $obj->paye) - { - if ($obj->fk_statut == 0) - { - print $fac->PayedLibStatut($obj->paye,$obj->fk_statut); - } - elseif ($obj->fk_statut == 3) - { - print $fac->PayedLibStatut($obj->paye,$obj->fk_statut); - } - else - { - // \todo le montant deja payé obj->am n'est pas définie - print ''.($fac->PayedLibStatut($obj->paye,$obj->fk_statut,$obj->am)).''; - } + if ($socid) { + $soc = new Societe($db); + $soc->fetch($socid); } - else - { - print $fac->PayedLibStatut($obj->paye,$obj->fk_statut); - } - 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"; - $i++; + // Lignes des champs de filtre + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + print ''; + + $fac = new FactureFournisseur($db); + + $var=true; + $total=0; + $total_ttc=0; + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object(); + $var=!$var; + + print ""; + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + $total+=$obj->total_ht; + $total_ttc+=$obj->total_ttc; + + // Affiche statut de la facture + if ($obj->paye) + { + $class = "normal"; + } + else + { + if ($obj->fk_statut == 0) + { + $class = "normal"; + } + else + { + $class = "impayee"; + } + } + + print ''; + + print "\n"; + $i++; + + if ($i == min($num,$limit)) { + // Print total + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } } + print "
'; + print ''; + print ' '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
facid\">".img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber."".strftime("%d %b %Y",$obj->datef)."'.stripslashes("$obj->libelle").''; + print ''.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.''; + print ''.price($obj->total_ht).''.price($obj->total_ttc).''; + if (! $obj->paye) + { + if ($obj->fk_statut == 0) + { + print $fac->PayedLibStatut($obj->paye,$obj->fk_statut); + } + elseif ($obj->fk_statut == 3) + { + print $fac->PayedLibStatut($obj->paye,$obj->fk_statut); + } + else + { + // \todo le montant deja payé obj->am n'est pas définie + print ''.($fac->PayedLibStatut($obj->paye,$obj->fk_statut,$obj->am)).''; + } + } + else + { + print $fac->PayedLibStatut($obj->paye,$obj->fk_statut); + } + print '
'.$langs->trans("Total").''.price($total).''.price($total_ttc).' 
"; $db->free(); } else { - dolibarr_print_error($db); + dolibarr_print_error($db); } $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); + +llxFooter('$Date$ - $Revision$'); + ?> diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index 8ca60fead88..8dcb30dfca7 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -46,11 +46,10 @@ if ($user->societe_id > 0) $action = ''; $socid = $user->societe_id; } + + /* - * * Mode fiche - * - * */ $societe = new Fournisseur($db); @@ -125,7 +124,11 @@ if ( $societe->fetch($socid) ) */ print ''; print ''; - print ''; + print ''; + + print ''; + print ''; + print ''; print ''; print '"; @@ -135,7 +138,7 @@ if ( $societe->fetch($socid) ) */ print '"; diff --git a/htdocs/fourn/product/liste.php b/htdocs/fourn/product/liste.php index 41eccd7b3ba..5a32f052935 100644 --- a/htdocs/fourn/product/liste.php +++ b/htdocs/fourn/product/liste.php @@ -127,7 +127,6 @@ $sql .= " ORDER BY $sortfield $sortorder "; $sql .= $db->plimit($limit + 1 ,$offset); $resql = $db->query($sql) ; - if ($resql) { $num = $db->num_rows($resql); @@ -142,6 +141,8 @@ if ($resql) $texte = $langs->trans("List"); + + llxHeader("","",$texte); if ($sref || $snom || $_POST["sall"] || $_POST["search"]) @@ -154,20 +155,15 @@ if ($resql) } -/* - * - * - */ - print "
"; - print 'Top'; - - if (isset($catid)) + if (isset($catid)) { - $c = new Categorie ($db, $catid); - $ways = $c->print_all_ways(' > ','fourn/product/liste.php'); - print " > ".$ways[0]."
\n"; + print "
"; + $c = new Categorie ($db, $catid); + $ways = $c->print_all_ways(' > ','fourn/product/liste.php'); + print " > ".$ways[0]."
\n"; + print "

"; } - print "

"; + print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans("Address").''.nl2br($societe->adresse).'
'.$societe->cp.' '.$societe->ville.'
'.$langs->trans("Address").''.nl2br($societe->adresse).'
'.$langs->trans("Zip").''.$societe->cp.''.$langs->trans("Town").''.$societe->ville.'
'.$langs->trans("Country").''.$societe->pays.'
'.$langs->trans("Phone").''.dolibarr_print_phone($societe->tel).' '.$langs->trans("Fax").''.dolibarr_print_phone($societe->fax).' 
'.$langs->trans("Web")."url\">$societe->url 
'; - $var=false; + $var=true; /* * @@ -145,12 +148,11 @@ if ( $societe->fetch($socid) ) if ($conf->produit->enabled || $conf->service->enabled) { $langs->load("products"); - print ''; - $var=!$var; - print ""; - print '
'.$langs->trans("ProductsAndServices").''; - print $societe->NbProduct(); - print '

'; + print ''; + print ''; + print '
'.$langs->trans("ProductsAndServices").''; + print ''.$langs->trans("All").' ('.$societe->NbProduct().')'; + print '

'; } /* @@ -164,13 +166,12 @@ if ( $societe->fetch($socid) ) $sql .= " ORDER BY p.rowid DESC LIMIT 4"; if ( $db->query($sql) ) { - $var=!$var; $i = 0 ; $num = $db->num_rows(); if ($num > 0) { - print ''; - print ""; + print '
'; + print ''; print ""; } while ($i < $num && $i < 5) @@ -207,9 +208,7 @@ if ( $societe->fetch($socid) ) /* - * * Liste des factures associées - * */ $langs->load("bills"); @@ -218,15 +217,15 @@ if ( $societe->fetch($socid) ) $sql = "SELECT p.rowid,p.libelle,p.facnumber,".$db->pdate("p.datef")." as df, total_ttc as amount, paye"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as p WHERE p.fk_soc = $societe->id"; $sql .= " ORDER BY p.datef"; - if ( $db->query($sql) ) + $resql=$db->query($sql); + if ($resql) { - $var=!$var; $i = 0 ; - $num = $db->num_rows(); + $num = $db->num_rows($resql); if ($num > 0) { - print '
id\">".$langs->trans("LastOrders",$num)."
'; - print ""; + print '
'; + print ''; print ""; @@ -234,13 +233,13 @@ if ( $societe->fetch($socid) ) while ($i < $num && $i < $max) { - $obj = $db->fetch_object(); + $obj = $db->fetch_object($resql); $var=!$var; print ""; print ''; + print img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber.' '.dolibarr_trunc($obj->libelle,14).''; print ""; print ''; $fac = new FactureFournisseur($db); @@ -248,7 +247,7 @@ if ( $societe->fetch($socid) ) print ""; $i++; } - $db->free(); + $db->free($resql); if ($num > 0) { print "
"; print "
".$langs->trans("LastSuppliersBills",min($num,$max))."id\">".$langs->trans("AllBills")." (".$num.")
"; print "
'; print ''; - print img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber.' '.dolibarr_trunc($obj->libelle,40).'".dolibarr_print_date($obj->df)."'.$obj->amount.'

"; } @@ -304,11 +303,14 @@ if ( $societe->fetch($socid) ) $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p WHERE p.fk_soc = $societe->id ORDER by p.datec"; $result = $db->query($sql); - $i = 0 ; $num = $db->num_rows(); + $i = 0 ; + $num = $db->num_rows($result); + $var=true; + while ($i < $num) { - $obj = $db->fetch_object(); + $obj = $db->fetch_object($result); $var = !$var; print "
'; @@ -176,7 +172,7 @@ if ($resql) print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&envente=$envente".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield); print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield); print_liste_field_titre($langs->trans("Supplier"),"liste.php", "pf.fk_soc","","","",$sortfield); - print_liste_field_titre($langs->trans("BuiingPrice"),"liste.php", "ppf.price","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield); + print_liste_field_titre($langs->trans("BuyingPrice"),"liste.php", "ppf.price","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield); print "\n"; // Lignes des champs de filtre @@ -191,9 +187,9 @@ if ($resql) print ''; - print ''; print ''; print '';
'; print ''; print ''; - print ''; - print '  '; + print ''; + print ''; + print '  '; print '