Qual: Uniformisation du code

This commit is contained in:
Laurent Destailleur 2005-06-11 11:34:38 +00:00
parent 250718b637
commit c22a21cb90
6 changed files with 187 additions and 165 deletions

View File

@ -21,7 +21,8 @@
* *
*/ */
/** \file htdocs/fourn/commande/index.php /**
\file htdocs/fourn/commande/index.php
\ingroup commande \ingroup commande
\brief Page accueil commandes fournisseurs \brief Page accueil commandes fournisseurs
\version $Revision$ \version $Revision$
@ -43,17 +44,20 @@ if ($user->societe_id > 0)
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
print_barre_liste($langs->trans("SuppliersOrders"), $page, "index.php", "", $sortfield, $sortorder, '', $num); print_barre_liste($langs->trans("SuppliersOrders"), $page, "index.php", "", $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%">';
print '<tr><td width="30%">';
$sql = "SELECT count(cf.rowid), fk_statut"; print '<table class="noborder" width="100%">';
$sql .= " ,cf.rowid,cf.ref"; print '<tr valign="top"><td width="30%">';
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s ";
$sql .= " , ".MAIN_DB_PREFIX."commande_fournisseur as cf"; $sql = "SELECT count(cf.rowid), fk_statut,";
$sql .= " WHERE cf.fk_soc = s.idp "; $sql.= " cf.rowid,cf.ref";
$sql .= " GROUP BY 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 ";
$sql.= " GROUP BY cf.fk_statut";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
@ -127,7 +131,8 @@ else
print '</td></tr></table>'; print '</td></tr></table>';
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -30,6 +30,9 @@
require("./pre.inc.php"); require("./pre.inc.php");
$langs->load("orders");
$page = ( is_numeric($_GET["page"]) ? $_GET["page"] : 0 ); $page = ( is_numeric($_GET["page"]) ? $_GET["page"] : 0 );
$socid = ( is_numeric($_GET["socid"]) ? $_GET["socid"] : 0 ); $socid = ( is_numeric($_GET["socid"]) ? $_GET["socid"] : 0 );
$sortorder = $_GET["sortorder"]; $sortorder = $_GET["sortorder"];
@ -62,10 +65,10 @@ $offset = $conf->liste_limit * $page ;
* Mode Liste * Mode Liste
*/ */
$sql = "SELECT s.idp, s.nom, ".$db->pdate("cf.date_commande")." as dc"; $sql = "SELECT s.idp, s.nom, ".$db->pdate("cf.date_commande")." as dc,";
$sql .= " ,cf.rowid,cf.ref, cf.fk_statut"; $sql .= " cf.rowid,cf.ref, cf.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s "; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,";
$sql .= " , ".MAIN_DB_PREFIX."commande_fournisseur as cf"; $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur as cf";
$sql .= " WHERE cf.fk_soc = s.idp "; $sql .= " WHERE cf.fk_soc = s.idp ";
if ($socid) if ($socid)
@ -114,7 +117,7 @@ if ($resql)
print '</form>'; print '</form>';
print '</tr>'; print '</tr>';
$var=True; $var=true;
while ($i < min($num,$conf->liste_limit)) while ($i < min($num,$conf->liste_limit))
{ {
@ -150,5 +153,5 @@ else
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -68,12 +68,12 @@ if (strlen($stcomm)) {
} }
if (strlen($begin)) { if (strlen($begin)) {
$sql .= " AND upper(p.name) like '$begin%'"; $sql .= " AND p.name like '$begin%'";
} }
if ($contactname) { if ($contactname) {
$sql .= " AND lower(p.name) like '%".strtolower($contactname)."%'"; $sql .= " AND p.name like '%".strtolower($contactname)."%'";
$sortfield = "lower(p.name)"; $sortfield = "p.name";
$sortorder = "ASC"; $sortorder = "ASC";
} }
@ -91,9 +91,9 @@ if ($result) {
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Lastname"),"contact.php","lower(p.name)", $begin, "", "", $sortfield); print_liste_field_titre($langs->trans("Lastname"),"contact.php","p.name", $begin, "", "", $sortfield);
print_liste_field_titre($langs->trans("Firstname"),"contact.php","lower(p.firstname)", $begin, "", "", $sortfield); print_liste_field_titre($langs->trans("Firstname"),"contact.php","p.firstname", $begin, "", "", $sortfield);
print_liste_field_titre($langs->trans("Company"),"contact.php","lower(s.nom)", $begin, "", "", $sortfield); print_liste_field_titre($langs->trans("Company"),"contact.php","s.nom", $begin, "", "", $sortfield);
print '<td class="liste_titre">'.$langs->trans("Email").'</td>'; print '<td class="liste_titre">'.$langs->trans("Email").'</td>';
print '<td class="liste_titre">'.$langs->trans("Phone").'</td>'; print '<td class="liste_titre">'.$langs->trans("Phone").'</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -187,6 +187,8 @@ if ($result)
$fac = new FactureFournisseur($db); $fac = new FactureFournisseur($db);
$var=true; $var=true;
$total=0;
$total_ttc=0;
while ($i < min($num,$limit)) while ($i < min($num,$limit))
{ {
$obj = $db->fetch_object(); $obj = $db->fetch_object();
@ -200,6 +202,8 @@ if ($result)
print '<a href="../fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.'</a</td>'; print '<a href="../fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.'</a</td>';
print '<td align="right">'.price($obj->total_ht).'</td>'; print '<td align="right">'.price($obj->total_ht).'</td>';
print '<td align="right">'.price($obj->total_ttc).'</td>'; print '<td align="right">'.price($obj->total_ttc).'</td>';
$total+=$obj->total_ht;
$total_ttc+=$obj->total_ttc;
// Affiche statut de la facture // Affiche statut de la facture
if ($obj->paye) if ($obj->paye)
@ -244,7 +248,17 @@ if ($result)
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
if ($i == min($num,$limit)) {
// Print total
print '<tr class="liste_total">';
print '<td class="liste_total" colspan="4" align="left">'.$langs->trans("Total").'</td>';
print '<td class="liste_total" align="right">'.price($total).'</td>';
print '<td class="liste_total" align="right">'.price($total_ttc).'</td>';
print '<td class="liste_total" align="center">&nbsp;</td>';
print "</tr>\n";
} }
}
print "</table>"; print "</table>";
$db->free(); $db->free();
} }
@ -255,5 +269,7 @@ else
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -46,11 +46,10 @@ if ($user->societe_id > 0)
$action = ''; $action = '';
$socid = $user->societe_id; $socid = $user->societe_id;
} }
/* /*
*
* Mode fiche * Mode fiche
*
*
*/ */
$societe = new Fournisseur($db); $societe = new Fournisseur($db);
@ -125,7 +124,11 @@ if ( $societe->fetch($socid) )
*/ */
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Name").'</td><td width="80%" colspan="3">'.$societe->nom.'</td></tr>'; print '<tr><td width="20%">'.$langs->trans("Name").'</td><td width="80%" colspan="3">'.$societe->nom.'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'.nl2br($societe->adresse).'<br>'.$societe->cp.' '.$societe->ville.'</td></tr>'; print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'.nl2br($societe->adresse).'</td></tr>';
print '<tr><td>'.$langs->trans("Zip").'</td><td>'.$societe->cp.'</td>';
print '<td>'.$langs->trans("Town").'</td><td>'.$societe->ville.'</td></tr>';
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'.$societe->pays.'</td></tr>';
print '<tr><td>'.$langs->trans("Phone").'</td><td>'.dolibarr_print_phone($societe->tel).'&nbsp;</td><td>'.$langs->trans("Fax").'</td><td>'.dolibarr_print_phone($societe->fax).'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Phone").'</td><td>'.dolibarr_print_phone($societe->tel).'&nbsp;</td><td>'.$langs->trans("Fax").'</td><td>'.dolibarr_print_phone($societe->fax).'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\"><a href=\"http://$societe->url\">$societe->url</a>&nbsp;</td></tr>"; print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\"><a href=\"http://$societe->url\">$societe->url</a>&nbsp;</td></tr>";
@ -135,7 +138,7 @@ if ( $societe->fetch($socid) )
*/ */
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';
$var=false; $var=true;
/* /*
* *
@ -145,12 +148,11 @@ if ( $societe->fetch($socid) )
if ($conf->produit->enabled || $conf->service->enabled) if ($conf->produit->enabled || $conf->service->enabled)
{ {
$langs->load("products"); $langs->load("products");
print '<table class="border" width="100%">'; print '<table class="noborder" width="100%">';
$var=!$var; print '<tr class="liste_titre">';
print "<tr $bc[$var]>"; print '<td>'.$langs->trans("ProductsAndServices").'</td><td align="right">';
print '<td><a href="'.DOL_URL_ROOT.'/fourn/product/liste.php?fourn_id='.$societe->id.'">'.$langs->trans("ProductsAndServices").'</td><td align="center">'; print '<a href="'.DOL_URL_ROOT.'/fourn/product/liste.php?fourn_id='.$societe->id.'">'.$langs->trans("All").' ('.$societe->NbProduct().')';
print $societe->NbProduct(); print '</a></td></tr></table><br>';
print '</td></tr></table><br>';
} }
/* /*
@ -164,13 +166,12 @@ if ( $societe->fetch($socid) )
$sql .= " ORDER BY p.rowid DESC LIMIT 4"; $sql .= " ORDER BY p.rowid DESC LIMIT 4";
if ( $db->query($sql) ) if ( $db->query($sql) )
{ {
$var=!$var;
$i = 0 ; $i = 0 ;
$num = $db->num_rows(); $num = $db->num_rows();
if ($num > 0) if ($num > 0)
{ {
print '<table class="border" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr $bc[$var]>"; print '<tr class="liste_titre">';
print "<td colspan=\"2\"><a href=\"commande/liste.php?socid=$societe->id\">".$langs->trans("LastOrders",$num)."</td></tr>"; print "<td colspan=\"2\"><a href=\"commande/liste.php?socid=$societe->id\">".$langs->trans("LastOrders",$num)."</td></tr>";
} }
while ($i < $num && $i < 5) while ($i < $num && $i < 5)
@ -207,9 +208,7 @@ if ( $societe->fetch($socid) )
/* /*
*
* Liste des factures associées * Liste des factures associées
*
*/ */
$langs->load("bills"); $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 = "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 .= " FROM ".MAIN_DB_PREFIX."facture_fourn as p WHERE p.fk_soc = $societe->id";
$sql .= " ORDER BY p.datef"; $sql .= " ORDER BY p.datef";
if ( $db->query($sql) ) $resql=$db->query($sql);
if ($resql)
{ {
$var=!$var;
$i = 0 ; $i = 0 ;
$num = $db->num_rows(); $num = $db->num_rows($resql);
if ($num > 0) if ($num > 0)
{ {
print '<table class="border" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr $bc[$var]>"; print '<tr class="liste_titre">';
print "<td colspan=\"4\">"; print "<td colspan=\"4\">";
print "<table class=\"noborder\" width=\"100%\"><tr><td>".$langs->trans("LastSuppliersBills",min($num,$max))."</td><td align=\"right\"><a href=\"facture/index.php?socid=$societe->id\">".$langs->trans("AllBills")." (".$num.")</td></tr></table>"; print "<table class=\"noborder\" width=\"100%\"><tr><td>".$langs->trans("LastSuppliersBills",min($num,$max))."</td><td align=\"right\"><a href=\"facture/index.php?socid=$societe->id\">".$langs->trans("AllBills")." (".$num.")</td></tr></table>";
print "</td></tr>"; print "</td></tr>";
@ -234,13 +233,13 @@ if ( $societe->fetch($socid) )
while ($i < $num && $i < $max) while ($i < $num && $i < $max)
{ {
$obj = $db->fetch_object(); $obj = $db->fetch_object($resql);
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'; print '<td>';
print '<a href="facture/fiche.php?facid='.$obj->rowid.'">'; print '<a href="facture/fiche.php?facid='.$obj->rowid.'">';
print img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber.'</a> '.dolibarr_trunc($obj->libelle,40).'</td>'; print img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber.'</a> '.dolibarr_trunc($obj->libelle,14).'</td>';
print "<td align=\"right\" width=\"80\">".dolibarr_print_date($obj->df)."</td>"; print "<td align=\"right\" width=\"80\">".dolibarr_print_date($obj->df)."</td>";
print '<td align="right">'.$obj->amount.'</td>'; print '<td align="right">'.$obj->amount.'</td>';
$fac = new FactureFournisseur($db); $fac = new FactureFournisseur($db);
@ -248,7 +247,7 @@ if ( $societe->fetch($socid) )
print "</tr>"; print "</tr>";
$i++; $i++;
} }
$db->free(); $db->free($resql);
if ($num > 0) { if ($num > 0) {
print "</table><br>"; print "</table><br>";
} }
@ -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 = "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"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p WHERE p.fk_soc = $societe->id ORDER by p.datec";
$result = $db->query($sql); $result = $db->query($sql);
$i = 0 ; $num = $db->num_rows();
$i = 0 ;
$num = $db->num_rows($result);
$var=true;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object(); $obj = $db->fetch_object($result);
$var = !$var; $var = !$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";

View File

@ -127,7 +127,6 @@ $sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit($limit + 1 ,$offset); $sql .= $db->plimit($limit + 1 ,$offset);
$resql = $db->query($sql) ; $resql = $db->query($sql) ;
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@ -142,6 +141,8 @@ if ($resql)
$texte = $langs->trans("List"); $texte = $langs->trans("List");
llxHeader("","",$texte); llxHeader("","",$texte);
if ($sref || $snom || $_POST["sall"] || $_POST["search"]) if ($sref || $snom || $_POST["sall"] || $_POST["search"])
@ -154,20 +155,15 @@ if ($resql)
} }
/*
*
*
*/
print "<div id='ways'>";
print '<a href="liste.php">Top</a>';
if (isset($catid)) if (isset($catid))
{ {
print "<div id='ways'>";
$c = new Categorie ($db, $catid); $c = new Categorie ($db, $catid);
$ways = $c->print_all_ways(' &gt; ','fourn/product/liste.php'); $ways = $c->print_all_ways(' &gt; ','fourn/product/liste.php');
print " &gt; ".$ways[0]."<br />\n"; print " &gt; ".$ways[0]."<br />\n";
}
print "</div><br />"; print "</div><br />";
}
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -176,7 +172,7 @@ if ($resql)
print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&amp;envente=$envente".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield); print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&amp;envente=$envente".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield);
print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield); print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield);
print_liste_field_titre($langs->trans("Supplier"),"liste.php", "pf.fk_soc","","","",$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)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="right"',$sortfield); print_liste_field_titre($langs->trans("BuyingPrice"),"liste.php", "ppf.price","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="right"',$sortfield);
print "</tr>\n"; print "</tr>\n";
// Lignes des champs de filtre // Lignes des champs de filtre
@ -191,9 +187,9 @@ if ($resql)
print '<td valign="right">'; print '<td valign="right">';
print '<input class="flat" type="text" name="snom" value="'.$snom.'">'; print '<input class="flat" type="text" name="snom" value="'.$snom.'">';
print '</td>'; print '</td>';
print '<td colspan="2" align="center">'; print '<td colspan="2" align="right">';
print '<input type="submit" class="button" name="button_search" value="'.$langs->trans("Search").'">'; print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
print '&nbsp; <input type="submit" class="button" name="button_removefilter" value="'.$langs->trans("RemoveFilter").'">'; print '&nbsp; <input type="image" class="liste_titre" name="button_removefilter" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" alt="'.$langs->trans("RemoveFilter").'">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</form>'; print '</form>';