New: Ajout onglet liste des factures liés sur fiche produit

This commit is contained in:
Laurent Destailleur 2005-06-26 15:37:57 +00:00
parent 51b81b211a
commit 5c93dea0d6
7 changed files with 259 additions and 221 deletions

View File

@ -144,6 +144,7 @@ if ($user->rights->facture->lire)
$i = 0; $i = 0;
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("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;socidp=$socidp","",$sortfield); print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;socidp=$socidp","",$sortfield);
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&amp;socidp=$socidp",'align="center"',$sortfield); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&amp;socidp=$socidp",'align="center"',$sortfield);
print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","","&amp;socidp=$socidp",'align="center"',$sortfield); print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","","&amp;socidp=$socidp",'align="center"',$sortfield);

View File

@ -32,6 +32,9 @@ require("./pre.inc.php");
require("../propal.class.php"); require("../propal.class.php");
require("../facture.class.php"); require("../facture.class.php");
$langs->load("bills");
$mesg = ''; $mesg = '';
if (!$user->rights->produit->lire) accessforbidden(); if (!$user->rights->produit->lire) accessforbidden();
@ -199,22 +202,6 @@ if ($_POST["action"] == 'add_fourn' && $_POST["cancel"] <> $langs->trans("Cancel
} }
} }
} }
if ($_GET["action"] == 'remove_fourn')
{
$product = new Product($db);
if( $product->fetch($_GET["id"]) )
{
if ($product->remove_fournisseur($user, $_GET["id_fourn"]) > 0)
{
$_GET["action"] = '';
$mesg = $langs->trans("SupplierRemoved");
}
else
{
$_GET["action"] = '';
}
}
}
if ($_POST["cancel"] == $langs->trans("Cancel")) if ($_POST["cancel"] == $langs->trans("Cancel"))
{ {
@ -233,7 +220,6 @@ llxHeader("","",$langs->trans("CardProduct0"));
if ($_GET["action"] == 'create' && $user->rights->produit->creer) if ($_GET["action"] == 'create' && $user->rights->produit->creer)
{ {
$html = new Form($db); $html = new Form($db);
$nbligne=0;
$product = new Product($db); $product = new Product($db);
if ($_error == 1) if ($_error == 1)
{ {
@ -356,52 +342,37 @@ if ($_GET["id"])
$head[$h][1] = $langs->trans('Statistics'); $head[$h][1] = $langs->trans('Statistics');
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
$head[$h][1] = $langs->trans('Bills');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
print($mesg); print($mesg);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print "<tr>"; print "<tr>";
print '<td width="10%">'.$langs->trans("Ref").'</td><td colspan="2" width="40%">'.$product->ref.'</td>';
$nblignes=6;
if ($product->type == 0 && $conf->stock->enabled) $nblignes++;
if ($product->type == 1) $nblignes++;
// Reference
print '<td width="10%">'.$langs->trans("Ref").'</td><td>'.$product->ref.'</td>';
print '<td valign="middle" align="center" rowspan="'.$nblignes.'">';
// Photo
$nbphoto=$product->show_photo($conf->produit->dir_output,1);
print '</td>';
print '</tr>'; print '</tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
// Libellé
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
print '</tr>'; print '</tr>';
// Prix // Prix
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>'; print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
if ($product->type == 0) $nbligne=5; print '</tr>';
else $nbligne=5;
print '<td valign="top" rowspan="'.$nbligne.'">';
$sql = "SELECT s.nom, s.idp";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
$sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id;
$sql .= " ORDER BY lower(s.nom)";
$result=$db->query($sql);
if ($result)
{
$num_fournisseur = $db->num_rows($result);
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Suppliers").'</td></tr>';
$var=True;
while ($i < $num_fournisseur)
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
print '<td align="right">';
print '<a href="fiche.php?id='.$product->id.'&amp;action=remove_fourn&amp;id_fourn='.$objp->idp.'">';
print img_disable($langs->trans("Remove")).'</a></td></tr>';
$i++;
}
print '</table>';
$db->free($result);
}
print '</td></tr>';
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'; print '<tr><td>'.$langs->trans("Status").'</td><td>';
@ -409,9 +380,12 @@ if ($_GET["id"])
else print $langs->trans("NotOnSell"); else print $langs->trans("NotOnSell");
print '</td></tr>'; print '</td></tr>';
// TVA
$langs->load("bills"); $langs->load("bills");
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.' %</td></tr>'; print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.' %</td></tr>';
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
// Stock
if ($product->type == 0 && $conf->stock->enabled)
{ {
print '<tr><td><a href="stock/product.php?id='.$product->id.'">'.$langs->trans("Stock").'</a></td>'; print '<tr><td><a href="stock/product.php?id='.$product->id.'">'.$langs->trans("Stock").'</a></td>';
if ($product->no_stock) if ($product->no_stock)
@ -431,8 +405,11 @@ if ($_GET["id"])
} }
print '</td></tr>'; print '</td></tr>';
} }
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>'; print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>';
// Durée
if ($product->type == 1) if ($product->type == 1)
{ {
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.'&nbsp;'; print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.'&nbsp;';
@ -448,36 +425,11 @@ if ($_GET["id"])
print '</td></tr>'; print '</td></tr>';
} }
print "</table><br>\n"; print "</table><br>\n";
print "</div>\n"; print "</div>\n";
} }
/*
* Ajouter un fournisseur
*/
if ($_GET["action"] == 'ajout_fourn' && $user->rights->produit->creer)
{
$langs->load("suppliers");
print_titre($langs->trans("AddSupplier"));
print '<form action="fiche.php?id='.$product->id.'" method="post">';
print '<input type="hidden" name="action" value="add_fourn">';
print '<input type="hidden" name="id" value="'.$product->id.'">';
print '<table class="border" width="100%"><tr>';
print '<td>'.$langs->trans("Suppliers").'</td><td>';
$html=new Form($db);
$html->select_societes('','id_fourn','fournisseur=1');
print '</td><td>'.$langs->trans("Ref").'</td>';
print '<td><input name="ref_fourn" size="25" value=""></td></tr>';
print '<tr><td colspan="4" align="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '</form>';
}
} }
/* /*
@ -587,24 +539,11 @@ if ($_GET["action"] == '')
print $langs->trans("AddPhoto").'</a>'; print $langs->trans("AddPhoto").'</a>';
} }
if ($user->rights->produit->modifier || $user->rights->produit->creer)
{
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$product->id.'&amp;action=ajout_fourn">';
print $langs->trans("AddSupplier").'</a>';
}
} }
print "\n</div><br>\n"; print "\n</div><br>\n";
/*
* Photo
*/
if ($_GET["id"] && $_GET["action"]=='')
{
$nbphoto=$product->show_photo($conf->produit->dir_output,1);
}
if ($_GET["id"] && $_GET["action"] == '' && $product->envente) if ($_GET["id"] && $_GET["action"] == '' && $product->envente)
{ {
$htmls = new Form($db); $htmls = new Form($db);

View File

@ -34,6 +34,7 @@ require("../facture.class.php");
$langs->load("products"); $langs->load("products");
$langs->load("suppliers"); $langs->load("suppliers");
$langs->load("bills");
$user->getrights('produit'); $user->getrights('produit');
$user->getrights('propale'); $user->getrights('propale');
@ -50,6 +51,36 @@ $types[1] = $langs->trans("Service");
* Actions * Actions
*/ */
if ($_GET["action"] == 'remove_fourn')
{
$product = new Product($db);
if( $product->fetch($_GET["id"]) )
{
if ($_GET["qty"]) { // On supprime une quantité
if ($product->remove_price($user, $_GET["id_fourn"], $_GET["qty"]) > 0)
{
$_GET["action"] = '';
$mesg = '<div class="ok">'.$langs->trans("PriceRemoved").'.</div>';
}
else
{
$_GET["action"] = '';
}
}
else { // On supprime un fournisseur
if ($product->remove_fournisseur($user, $_GET["id_fourn"]) > 0)
{
$_GET["action"] = '';
$mesg = '<div class="ok">'.$langs->trans("SupplierRemoved").'.</div>';
}
else
{
$_GET["action"] = '';
}
}
}
}
if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel")) if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
{ {
@ -67,8 +98,12 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
$mesg='<div class="error">'.$product->error.'</div>'; $mesg='<div class="error">'.$product->error.'</div>';
} }
} }
else {
if ($_POST["qty"]) { $error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Ref")).'</div>';
}
if ($_POST["qty"] && $_POST["price"] > 0) {
$ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user); $ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
if ($ret < 0) { if ($ret < 0) {
$error++; $error++;
@ -164,11 +199,12 @@ if ($_GET["id"])
$head[$h][1] = $langs->trans('Statistics'); $head[$h][1] = $langs->trans('Statistics');
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
$head[$h][1] = $langs->trans('Bills');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
print($mesg);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="2">'.$product->ref.'</td></tr>'; print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="2">'.$product->ref.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
@ -179,25 +215,32 @@ if ($_GET["id"])
if ($product->envente) print $langs->trans("OnSell"); if ($product->envente) print $langs->trans("OnSell");
else print $langs->trans("NotOnSell"); else print $langs->trans("NotOnSell");
print '</td></tr>'; print '</td></tr>';
print '</table><br />'; print '</table><br />';
print "</div>\n"; print "</div>\n";
if ($mesg) print($mesg);
// Formulaire ajout prix // Formulaire ajout prix
if ($_GET["action"] == 'add_price' && $user->rights->produit->creer) if ($_GET["action"] == 'add_price' && $user->rights->produit->creer)
{ {
$langs->load("suppliers"); $langs->load("suppliers");
print '<div class="titre">'.$langs->trans("ChangeSupplierPrice").'</div>'; if ($_GET["id_fourn"]) {
print '<div class="titre">'.$langs->trans("ChangeSupplierPrice").'</div>';
} else {
print '<div class="titre">'.$langs->trans("AddSupplierPrice").'</div>';
}
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">'; print '<form action="fournisseurs.php?id='.$product->id.'" method="post">';
print '<input type="hidden" name="action" value="updateprice">'; print '<input type="hidden" name="action" value="updateprice">';
if ($_GET["id_fourn"]) { if ($_GET["id_fourn"]) {
print '<input type="hidden" name="id_fourn" value="'.$_GET["id_fourn"].'">'; print '<input type="hidden" name="id_fourn" value="'.$_GET["id_fourn"].'">';
$product->fetch_fourn_data($_GET["id_fourn"]);
print '<input type="hidden" name="ref_fourn" value="'.$product->ref_fourn.'">';
} else { } else {
print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="3">';
$html=new Form($db); $html=new Form($db);
@ -210,7 +253,8 @@ if ($_GET["id"])
print '<tr><td>'.$langs->trans("Qty").'</td>'; print '<tr><td>'.$langs->trans("Qty").'</td>';
print '<td><input name="qty" size="5" value="'.$_GET["qty"].'"></td>'; print '<td><input name="qty" size="5" value="'.$_GET["qty"].'"></td>';
print '<td>'.$langs->trans("Price").'</td><td><input name="price" size="8" value="'.price($objp->price).'"></td></tr>'; print '<td>'.$langs->trans("Price").'</td>';
print '<td><input name="price" size="8" value="'.price($_GET["price"]).'"></td></tr>';
print '<tr><td colspan="4" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;'; print '<tr><td colspan="4" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
@ -229,7 +273,7 @@ if ($_GET["id"])
if ($_GET["action"] != 'add_price') { if ($_GET["action"] != 'add_price') {
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$product->id.'&amp;action=add_price">'; print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$product->id.'&amp;action=add_price">';
print $langs->trans("AddSupplierPrice").'</a>'; print $langs->trans("AddSupplier").'</a>';
} }
@ -271,7 +315,7 @@ if ($_GET["id"])
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>'; print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$objp->nom.'</a></td>';
// Fournisseur // Fournisseur
print '<td align="left">'.$objp->ref_fourn.'</td>'; print '<td align="left">'.$objp->ref_fourn.'</td>';
@ -291,10 +335,13 @@ if ($_GET["id"])
print $objp->quantity?price($objp->price / $objp->quantity):"&nbsp;"; print $objp->quantity?price($objp->price / $objp->quantity):"&nbsp;";
print '</td>'; print '</td>';
print '<td>'; // Modifier-Supprimer
if ($user->rights->produit->modifier) { print '<td align="center">';
print '<a href="fournisseurs.php?id='.$product->id.'&amp;action=add_price&amp;id_fourn='.$objp->idp.'&amp;qty='.$objp->quantity.'">'.img_edit()."</a>"; if ($user->rights->produit->creer) {
print '<a href="fournisseurs.php?id='.$product->id.'&amp;action=add_price&amp;id_fourn='.$objp->idp.'&amp;qty='.$objp->quantity.'&amp;price='.$objp->price.'">'.img_edit()."</a>";
print '<a href="fournisseurs.php?id='.$product->id.'&amp;action=remove_fourn&amp;id_fourn='.$objp->idp.'&amp;qty='.$objp->quantity.'">';
} }
print img_disable($langs->trans("Remove")).'</a>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';

View File

@ -32,6 +32,7 @@ require("../propal.class.php");
require("../facture.class.php"); require("../facture.class.php");
$langs->load("products"); $langs->load("products");
$langs->load("bills");
$user->getrights('produit'); $user->getrights('produit');
$user->getrights('propale'); $user->getrights('propale');
@ -115,6 +116,11 @@ if ($_GET["id"])
$head[$h][1] = $langs->trans('Statistics'); $head[$h][1] = $langs->trans('Statistics');
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
$head[$h][1] = $langs->trans('Bills');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
print($mesg); print($mesg);
@ -183,10 +189,13 @@ if ($_GET["id"])
// Affiche photos // Affiche photos
if ($_GET["action"] != 'ajout_photo') { if ($_GET["action"] != 'ajout_photo') {
print '<div class="photo">'; //print '<br>';
$nbphoto=$product->show_photos($conf->produit->dir_output,1); //print '<div class="photo">';
$nbphoto=$product->show_photos($conf->produit->dir_output,1,0,5);
if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."<br><br>"; if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."<br><br>";
print '</div>'; //print '</div>';
} }
} }
} }

View File

@ -31,6 +31,7 @@
require("./pre.inc.php"); require("./pre.inc.php");
$langs->load("products"); $langs->load("products");
$langs->load("bills");
$user->getrights('produit'); $user->getrights('produit');
@ -115,6 +116,9 @@ $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans("Statistics"); $head[$h][1] = $langs->trans("Statistics");
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
$head[$h][1] = $langs->trans('Bills');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);

View File

@ -18,156 +18,191 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** \file htdocs/product/stats/facture.php /**
\file htdocs/product/stats/facture.php
\ingroup product, service \ingroup product, service
\brief Page des stats des factures pour un produit \brief Page des stats des factures pour un produit
\version $Revision$ \version $Revision$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once("../../facture.class.php"); require_once("../../facture.class.php");
$langs->load("bills");
$mesg = ''; $mesg = '';
if ($page == -1) $page = $_GET["page"];
{ $sortfield=$_GET["sortfield"];
$page = 0 ; $sortorder=$_GET["sortorder"];
}
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="f.datef"; if (! $sortfield) $sortfield="f.datef";
if ($page == -1) $page = 0;
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socid = $user->societe_id; $socid = $user->societe_id;
} }
llxHeader(); llxHeader();
/* /*
* * Affiche fiche
* *
*/ */
if ($_GET["id"]) if ($_GET["id"])
{ {
$product = new Product($db); $product = new Product($db);
$result = $product->fetch($_GET["id"]); $result = $product->fetch($_GET["id"]);
if ( $result )
{
print_fiche_titre($langs->trans("Product").': '.$product->ref, $mesg);
print '<table class="border" width="100%"><tr>';
print '<td width="20%">'.$langs->trans("Ref").'</td><td width="40%"><a href="../fiche.php?id='.$product->id.'">'.$product->ref.'</a></td>';
print '<td><a href="fiche.php?id='.$product->id.'">'.$langs->trans("Statistics").'</a></td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
print '<td valign="top" rowspan="2">';
// Propals
if ($conf->propal->enabled) {
$langs->load("propal");
print '<a href="propal.php?id='.$product->id.'">'.$langs->trans("Proposals").'</a> : '.$product->count_propale($socid);
print " (Proposé à ".$product->count_propale_client($socid)." clients)<br>";
}
// Commande
if ($conf->commande->enabled) {
$langs->load("orders");
print '<a href="commande.php?id='.$product->id.'">'.$langs->trans("Orders").'</a> : '.$product->count_facture($socid)."<br>";
}
// Factures
if ($conf->facture->enabled) {
$langs->load("bills");
print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a> : '.$product->count_facture($socid);
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("CurrentPrice").'</td><td>'.price($product->price).'</td></tr>';
print "</table>";
if ($result > 0)
print "<br>"; {
print_barre_liste($langs->trans("Bills"),$page,"facture.php","&amp;id=$product->id",$sortfield,$sortorder); /*
* En mode visu
$sql = "SELECT distinct(f.rowid), s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.fk_statut as statut,f.rowid as facid"; */
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as d WHERE f.fk_soc = s.idp";
$sql .= " AND d.fk_facture = f.rowid AND d.fk_product =".$product->id;
if ($socid)
{
$sql .= " AND f.fk_soc = $socid";
}
$sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit( $limit ,$offset);
$result = $db->query($sql); $h=0;
if ($result) {
$num = $db->num_rows();
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">'; $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
print_liste_field_titre($langs->trans("Ref"),"facture.php","s.idp","","&amp;id=".$_GET["id"],'',$sortfield); $head[$h][1] = $langs->trans("Card");
print_liste_field_titre($langs->trans("Company"),"facture.php","s.nom","","&amp;id=".$_GET["id"],'',$sortfield); $h++;
print_liste_field_titre($langs->trans("Date"),"facture.php","f.datef","","&amp;id=".$_GET["id"],'align="right"',$sortfield);
print_liste_field_titre($langs->trans("Amount"),"facture.php","f.amount","","&amp;id=".$_GET["id"],'align="right"',$sortfield); $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
print_liste_field_titre($langs->trans("Status"),"facture.php","f.paye,f.fk_statut","","&amp;id=".$_GET["id"],'align="center"',$sortfield); $head[$h][1] = $langs->trans("Price");
print "</tr>\n"; $h++;
if ($num > 0) $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
{ $head[$h][1] = $langs->trans("Photos");
$var=True; $h++;
while ($i < $num)
{ if($product->type == 0)
$objp = $db->fetch_object( $i); {
$var=!$var; if ($conf->stock->enabled)
{
print "<tr $bc[$var]>"; $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '; $head[$h][1] = $langs->trans("Stock");
print $objp->facnumber; $h++;
print "</a></td>\n"; }
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$objp->nom.'</a></td>'; }
if ($objp->df > 0 ) if ($conf->fournisseur->enabled)
{ {
print "<td align=\"right\">"; $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
print strftime("%d %B %Y",$objp->df)."</td>"; $head[$h][1] = $langs->trans("Suppliers");
} $h++;
else }
{
print "<td align=\"right\"><b>!!!</b></td>\n"; $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
} $head[$h][1] = $langs->trans('Statistics');
$h++;
print "<td align=\"right\">".price($objp->amount)."</td>\n";
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
$fac=new Facture($db); $head[$h][1] = $langs->trans('Bills');
print '<td align="center">'.$fac->LibStatut($objp->paye,$objp->statut).'</td>'; $hselected=$h;
$h++;
print "</tr>\n";
$i++;
} dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
}
}
else { print '<table class="border" width="100%">';
dolibarr_print_error($db);
} print '<tr>';
print "</table>"; print '<td width="10%">'.$langs->trans("Ref").'</td><td colspan="2" width="40%">'.$product->ref.'</td>';
$db->free(); print '</tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
print '</tr>';
// Prix
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
if ($product->envente) print $langs->trans("OnSell");
else print $langs->trans("NotOnSell");
print '</td></tr>';
print "</table>";
print "<br>";
print '</div>';
print_barre_liste($langs->trans("Bills"),$page,"facture.php","&amp;id=$product->id",$sortfield,$sortorder);
$sql = "SELECT s.nom, s.idp, s.code_client, f.facnumber, f.amount,";
$sql.= " ".$db->pdate("f.datef")." as df, f.paye, f.fk_statut as statut, f.rowid as facid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as d WHERE f.fk_soc = s.idp";
$sql.= " AND d.fk_facture = f.rowid AND d.fk_product =".$product->id;
if ($socid)
{
$sql .= " AND f.fk_soc = $socid";
}
$sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit( $limit ,$offset);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.idp","","&amp;id=".$_GET["id"],'',$sortfield);
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;id=".$_GET["id"],'',$sortfield);
print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&amp;id=".$_GET["id"],'align="right"',$sortfield);
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&amp;id=".$_GET["id"],'align="right"',$sortfield);
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"f.amount","","&amp;id=".$_GET["id"],'align="right"',$sortfield);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&amp;id=".$_GET["id"],'align="center"',$sortfield);
print "</tr>\n";
if ($num > 0)
{
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' ';
print $objp->facnumber;
print "</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).'</a></td>';
print "<td>".$objp->code_client."</td>\n";
print "<td align=\"right\">";
print dolibarr_print_date($objp->df)."</td>";
print "<td align=\"right\">".price($objp->amount)."</td>\n";
$fac=new Facture($db);
print '<td align="center">'.$fac->LibStatut($objp->paye,$objp->statut).'</td>';
print "</tr>\n";
$i++;
}
}
}
else {
dolibarr_print_error($db);
}
print "</table>";
print '<br>';
$db->free($result);
} }
} }
else else
{ {
print "Error"; dolibarr_print_error();
} }
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -145,6 +145,9 @@ if ($_GET["id"])
$hselected=$h; $hselected=$h;
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
$head[$h][1] = $langs->trans('Bills');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);