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
\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 '<table class="noborder" width="100%">';
print '<tr><td width="30%">';
$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 '<table class="noborder" width="100%">';
print '<tr valign="top"><td width="30%">';
$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 '</td></tr></table>';
$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");
$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 '</form>';
print '</tr>';
$var=True;
$var=true;
while ($i < min($num,$conf->liste_limit))
{
@ -150,5 +153,5 @@ else
$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)) {
$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 '<table class="liste" width="100%">';
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("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 '<td class="liste_titre">'.$langs->trans("Email").'</td>';
print '<td class="liste_titre">'.$langs->trans("Phone").'</td>';
print "</tr>\n";

View File

@ -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","&amp;socidp=$socidp",$sortfield,$sortorder,'',$num);
$num = $db->num_rows($result);
$i = 0;
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),"index.php","facnumber","&amp;socid=$socid","","",$sortfield);
print_liste_field_titre($langs->trans("Date"),"index.php","fac.datef","&amp;socid=$socid","","",$sortfield);
print_liste_field_titre($langs->trans("Label"),"index.php","fac.libelle","&amp;socid=$socid","","",$sortfield);
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","&amp;socid=$socid","","",$sortfield);
print_liste_field_titre($langs->trans("AmountHT"),"index.php","fac.total_ht","&amp;socid=$socid","",'align="right"',$sortfield);
print_liste_field_titre($langs->trans("AmountTTC"),"index.php","fac.total_ttc","&amp;socid=$socid","",'align="right"',$sortfield);
print_liste_field_titre($langs->trans("Status"),"index.php","fk_statut,paye","&amp;socid=$socid","",'align="center"',$sortfield);
print "</tr>\n";
// Lignes des champs de filtre
print '<form method="get" action="index.php">';
print '<tr class="liste_titre">';
print '<td class="liste_titre" valign="right">';
print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET["search_ref"].'">';
print '</td><td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" name="search_libelle" value="'.$_GET["search_libelle"].'">';
print '</td>';
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" name="search_societe" value="'.$_GET["search_societe"].'">';
print '</td><td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_GET["search_montant_ht"].'">';
print '</td><td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET["search_montant_ttc"].'">';
print '</td><td class="liste_titre" colspan="2" align="center">';
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 '</td>';
print "</tr>\n";
print '</form>';
$fac = new FactureFournisseur($db);
$var=true;
while ($i < min($num,$limit))
{
$obj = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print "<td nowrap><a href=\"fiche.php?facid=$obj->facid\">".img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber."</a></td>\n";
print "<td nowrap>".strftime("%d %b %Y",$obj->datef)."</td>\n";
print '<td>'.stripslashes("$obj->libelle").'</td>';
print '<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_ttc).'</td>';
// Affiche statut de la facture
if ($obj->paye)
{
$class = "normal";
}
else
{
if ($obj->fk_statut == 0)
{
$class = "normal";
}
else
{
$class = "impayee";
}
}
print '<td align="center">';
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 '<a class="'.$class.'" href=""index.php?filtre=paye:0,fk_statut:1">'.($fac->PayedLibStatut($obj->paye,$obj->fk_statut,$obj->am)).'</a>';
}
if ($socid) {
$soc = new Societe($db);
$soc->fetch($socid);
}
else
{
print $fac->PayedLibStatut($obj->paye,$obj->fk_statut);
}
print '</td>';
print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,"index.php","&amp;socidp=$socidp",$sortfield,$sortorder,'',$num);
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),"index.php","facnumber","&amp;socid=$socid","","",$sortfield);
print_liste_field_titre($langs->trans("Date"),"index.php","fac.datef","&amp;socid=$socid","","",$sortfield);
print_liste_field_titre($langs->trans("Label"),"index.php","fac.libelle","&amp;socid=$socid","","",$sortfield);
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","&amp;socid=$socid","","",$sortfield);
print_liste_field_titre($langs->trans("AmountHT"),"index.php","fac.total_ht","&amp;socid=$socid","",'align="right"',$sortfield);
print_liste_field_titre($langs->trans("AmountTTC"),"index.php","fac.total_ttc","&amp;socid=$socid","",'align="right"',$sortfield);
print_liste_field_titre($langs->trans("Status"),"index.php","fk_statut,paye","&amp;socid=$socid","",'align="center"',$sortfield);
print "</tr>\n";
$i++;
// Lignes des champs de filtre
print '<form method="get" action="index.php">';
print '<tr class="liste_titre">';
print '<td class="liste_titre" valign="right">';
print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET["search_ref"].'">';
print '</td><td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" name="search_libelle" value="'.$_GET["search_libelle"].'">';
print '</td>';
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" name="search_societe" value="'.$_GET["search_societe"].'">';
print '</td><td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_GET["search_montant_ht"].'">';
print '</td><td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET["search_montant_ttc"].'">';
print '</td><td class="liste_titre" colspan="2" align="center">';
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 '</td>';
print "</tr>\n";
print '</form>';
$fac = new FactureFournisseur($db);
$var=true;
$total=0;
$total_ttc=0;
while ($i < min($num,$limit))
{
$obj = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print "<td nowrap><a href=\"fiche.php?facid=$obj->facid\">".img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber."</a></td>\n";
print "<td nowrap>".strftime("%d %b %Y",$obj->datef)."</td>\n";
print '<td>'.stripslashes("$obj->libelle").'</td>';
print '<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_ttc).'</td>';
$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 '<td align="center">';
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 '<a class="'.$class.'" href=""index.php?filtre=paye:0,fk_statut:1">'.($fac->PayedLibStatut($obj->paye,$obj->fk_statut,$obj->am)).'</a>';
}
}
else
{
print $fac->PayedLibStatut($obj->paye,$obj->fk_statut);
}
print '</td>';
print "</tr>\n";
$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>";
$db->free();
}
else
{
dolibarr_print_error($db);
dolibarr_print_error($db);
}
$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 = '';
$socid = $user->societe_id;
}
/*
*
* Mode fiche
*
*
*/
$societe = new Fournisseur($db);
@ -125,7 +124,11 @@ if ( $societe->fetch($socid) )
*/
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 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("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%">';
$var=false;
$var=true;
/*
*
@ -145,12 +148,11 @@ if ( $societe->fetch($socid) )
if ($conf->produit->enabled || $conf->service->enabled)
{
$langs->load("products");
print '<table class="border" width="100%">';
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/fourn/product/liste.php?fourn_id='.$societe->id.'">'.$langs->trans("ProductsAndServices").'</td><td align="center">';
print $societe->NbProduct();
print '</td></tr></table><br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ProductsAndServices").'</td><td align="right">';
print '<a href="'.DOL_URL_ROOT.'/fourn/product/liste.php?fourn_id='.$societe->id.'">'.$langs->trans("All").' ('.$societe->NbProduct().')';
print '</a></td></tr></table><br>';
}
/*
@ -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 '<table class="border" width="100%">';
print "<tr $bc[$var]>";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print "<td colspan=\"2\"><a href=\"commande/liste.php?socid=$societe->id\">".$langs->trans("LastOrders",$num)."</td></tr>";
}
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 '<table class="border" width="100%">';
print "<tr $bc[$var]>";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
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 "</td></tr>";
@ -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 "<tr $bc[$var]>";
print '<td>';
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">'.$obj->amount.'</td>';
$fac = new FactureFournisseur($db);
@ -248,7 +247,7 @@ if ( $societe->fetch($socid) )
print "</tr>";
$i++;
}
$db->free();
$db->free($resql);
if ($num > 0) {
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 .= " 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 "<tr $bc[$var]>";

View File

@ -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 "<div id='ways'>";
print '<a href="liste.php">Top</a>';
if (isset($catid))
if (isset($catid))
{
$c = new Categorie ($db, $catid);
$ways = $c->print_all_ways(' &gt; ','fourn/product/liste.php');
print " &gt; ".$ways[0]."<br />\n";
print "<div id='ways'>";
$c = new Categorie ($db, $catid);
$ways = $c->print_all_ways(' &gt; ','fourn/product/liste.php');
print " &gt; ".$ways[0]."<br />\n";
print "</div><br />";
}
print "</div><br />";
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("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("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";
// Lignes des champs de filtre
@ -191,9 +187,9 @@ if ($resql)
print '<td valign="right">';
print '<input class="flat" type="text" name="snom" value="'.$snom.'">';
print '</td>';
print '<td colspan="2" align="center">';
print '<input type="submit" class="button" name="button_search" value="'.$langs->trans("Search").'">';
print '&nbsp; <input type="submit" class="button" name="button_removefilter" value="'.$langs->trans("RemoveFilter").'">';
print '<td colspan="2" align="right">';
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="image" class="liste_titre" name="button_removefilter" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" alt="'.$langs->trans("RemoveFilter").'">';
print '</td>';
print '</tr>';
print '</form>';