Ajout onglet commande fournisseurs et factures fournisseurs rfrente un produit

This commit is contained in:
Laurent Destailleur 2006-08-18 23:16:40 +00:00
parent 6316c76b02
commit 8cb0402445
13 changed files with 595 additions and 507 deletions

View File

@ -35,6 +35,7 @@ require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php');
$langs->load('bills');
$langs->load('other');
$langs->load("companies");
$user->getrights('fournisseur');

View File

@ -651,7 +651,6 @@ else
* Liste des paiements
*/
print '<tr><td colspan="2">';
print $langs->trans('Payments').' :<br>';
$sql = 'SELECT '.$db->pdate('datep').' as dp, pf.amount,';
$sql .= ' c.libelle as paiement_type, p.num_paiement, p.rowid';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p';
@ -667,7 +666,7 @@ else
$i = 0; $totalpaye = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Date').'</td>';
print '<td>'.$langs->trans('Payments').'</td>';
print '<td>'.$langs->trans('Type').'</td>';
if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0)
@ -744,7 +743,12 @@ else
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$fac->lignes[$i][0].'</td>';
print '<td>';
//print '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' ';
print $fac->lignes[$i][0];
//print '</a>';
print '</td>';
print '<td align="right">'.price($fac->lignes[$i][1]).'</td>';
print '<td align="right">'.$fac->lignes[$i][3].'</td>';
print '<td align="right">'.price($fac->lignes[$i][4]).'</td>';

View File

@ -340,7 +340,7 @@ class FactureFournisseur extends Facture
* \param tauxtva taux de tva
* \param qty quantité
*/
function addline($desc, $pu, $tauxtva, $qty)
function addline($desc, $pu, $tauxtva, $qty, $idproduct)
{
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)';
$sql .= ' VALUES ('.$this->id.');';
@ -348,14 +348,18 @@ class FactureFournisseur extends Facture
if ($resql)
{
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
$this->updateline($idligne, $desc, $pu, $tauxtva, $qty);
$this->updateline($idligne, $desc, $pu, $tauxtva, $qty, $idproduct);
// Mise a jour prix facture
$this->update_price($this->id);
return 1;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
// Mise a jour prix facture
$this->update_price($this->id);
}
/**
@ -367,7 +371,7 @@ class FactureFournisseur extends Facture
* \param qty quantité
* \return int <0 si ko, >0 si ok
*/
function updateline($id, $label, $puht, $tauxtva, $qty=1)
function updateline($id, $label, $puht, $tauxtva, $qty=1, $idproduct)
{
$puht = price2num($puht);
$qty = price2num($qty);
@ -379,15 +383,17 @@ class FactureFournisseur extends Facture
$totalttc = $totalht + $tva;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn_det ';
$sql .= 'SET ';
$sql .= 'description =\''.addslashes($label).'\'';
$sql .= ', pu_ht = ' .$puht;
$sql .= ', qty =' .$qty;
$sql .= ', total_ht=' .price2num($totalht);
$sql .= ', tva=' .price2num($tva);
$sql .= ', tva_taux=' .price2num($tauxtva);
$sql .= ', total_ttc='.price2num($totalttc);
$sql .= ' WHERE rowid = '.$id.';';
$sql.= 'SET ';
$sql.= 'description =\''.addslashes($label).'\'';
$sql.= ', pu_ht = ' .$puht;
$sql.= ', qty =' .$qty;
$sql.= ', total_ht=' .price2num($totalht);
$sql.= ', tva=' .price2num($tva);
$sql.= ', tva_taux=' .price2num($tauxtva);
$sql.= ', total_ttc='.price2num($totalttc);
if ($idproduct) $sql.= ', fk_product='.$idproduct;
else $sql.= ', fk_product=null';
$sql.= ' WHERE rowid = '.$id;
$resql=$this->db->query($sql);
if ($resql)

View File

@ -21,10 +21,10 @@
*/
/**
\file htdocs/fourn/product/liste.php
\ingroup produit
\brief Page liste des produits ou services
\version $Revision$
\file htdocs/fourn/product/liste.php
\ingroup produit
\brief Page liste des produits ou services
\version $Revision$
*/
require("./pre.inc.php");
@ -43,34 +43,34 @@ $type=isset($_GET["type"])?$_GET["type"]:$_POST["type"];
$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
$page = $_GET["page"];
if ($page < 0) {
$page = 0 ; }
if ($page < 0) {
$page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if (! $sortfield) $sortfield="p.ref";
if (! $sortorder) $sortorder="DESC";
if ($_POST["button_removefilter"] == $langs->trans("RemoveFilter")) {
$sref="";
$snom="";
$sref="";
$snom="";
}
if ($_GET["fourn_id"] > 0)
{
$fourn_id = $_GET["fourn_id"];
$fourn_id = $_GET["fourn_id"];
}
if (isset($_REQUEST['catid']))
{
$catid = $_REQUEST['catid'];
$catid = $_REQUEST['catid'];
}
/*
* Mode Liste
*
*/
* Mode Liste
*
*/
$title=$langs->trans("ProductsAndServices");
@ -81,7 +81,7 @@ $sql .= ", s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
if ($catid)
{
$sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp";
$sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.idp = pf.fk_soc";
@ -89,39 +89,40 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON ppf.fk
if ($_POST["mode"] == 'search')
{
$sql .= " WHERE p.ref like '%".$_POST["sall"]."%'";
$sql .= " OR p.label like '%".$_POST["sall"]."%'";
$sql .= " WHERE p.ref like '%".$_POST["sall"]."%'";
$sql .= " OR p.label like '%".$_POST["sall"]."%'";
}
else
{
$sql .= " WHERE 1=1";
if (isset($_GET["type"]) || isset($_POST["type"]))
{
$sql .= " AND p.fk_product_type = ".(isset($_GET["type"])?$_GET["type"]:$_POST["type"]);
}
if ($sref)
{
$sql .= " AND p.ref like '%".$sref."%'";
}
if ($snom)
{
$sql .= " AND p.label like '%".$snom."%'";
}
if($catid)
{
$sql .= " AND cp.fk_product = p.rowid";
$sql .= " AND cp.fk_categorie = ".$catid;
}
$sql .= " WHERE 1=1";
if ($_GET["type"] || $_POST["type"])
{
$sql .= " AND p.fk_product_type = ".(isset($_GET["type"])?$_GET["type"]:$_POST["type"]);
}
if ($sref)
{
$sql .= " AND p.ref like '%".$sref."%'";
}
if ($snom)
{
$sql .= " AND p.label like '%".$snom."%'";
}
if($catid)
{
$sql .= " AND cp.fk_product = p.rowid";
$sql .= " AND cp.fk_categorie = ".$catid;
}
}
if ($fourn_id > 0)
{
$sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = $fourn_id";
$sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
}
$sql .= " GROUP BY p.rowid";
$sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit($limit + 1 ,$offset);
dolibarr_syslog("fourn/product/liste: sql=$sql");
$resql = $db->query($sql) ;
@ -141,14 +142,8 @@ if ($resql)
$texte = $langs->trans("List");
llxHeader("","",$texte);
if ($sref || $snom || $_POST["sall"] || $_POST["search"])
{
print_barre_liste($texte, $page, "liste.php", "&sref=".$sref."&snom=".$snom, $sortfield, $sortorder,'',$num);
}
else
{
print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&amp;type=$type":""), $sortfield, $sortorder,'',$num);
}
$param="&envente=$envente&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&amp;type=$type":"");
print_barre_liste($texte, $page, "liste.php", $param, $sortfield, $sortorder,'',$num);
if (isset($catid))
@ -165,10 +160,10 @@ if ($resql)
// Lignes des titres
print "<tr class=\"liste_titre\">";
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("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_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref",$param,"","",$sortfield);
print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label",$param,"","",$sortfield);
print_liste_field_titre($langs->trans("Supplier"),"liste.php", "pf.fk_soc",$param,"","",$sortfield);
print_liste_field_titre($langs->trans("BuyingPrice"),"liste.php", "ppf.price",$param,"",'align="right"',$sortfield);
print "</tr>\n";
// Lignes des champs de filtre

View File

@ -129,4 +129,123 @@ function product_prepare_head($product)
return $head;
}
function show_stats_for_company($product,$socidp)
{
global $conf,$langs,$user,$db;
print '<tr>';
print '<td align="left" width="25%" valign="top">'.$langs->trans("Referers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfThirdParties").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
print '</tr>';
// Propals
if ($conf->propal->enabled && $user->rights->propale->lire)
{
$ret=$product->load_stats_propale($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("propal");
print '<tr><td>';
print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
print '</td><td align="right">';
print $product->stats_propale['customers'];
print '</td><td align="right">';
print $product->stats_propale['nb'];
print '</td><td align="right">';
print $product->stats_propale['qty'];
print '</td>';
print '</tr>';
}
// Commandes clients
if ($conf->commande->enabled && $user->rights->commande->lire)
{
$ret=$product->load_stats_commande($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders");
print '<tr><td>';
print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
print '</td><td align="right">';
print $product->stats_commande['customers'];
print '</td><td align="right">';
print $product->stats_commande['nb'];
print '</td><td align="right">';
print $product->stats_commande['qty'];
print '</td>';
print '</tr>';
}
// Commandes fournisseurs
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire)
{
$ret=$product->load_stats_commande_fournisseur($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders");
print '<tr><td>';
print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>';
print '</td><td align="right">';
print $product->stats_commande_fournisseur['suppliers'];
print '</td><td align="right">';
print $product->stats_commande_fournisseur['nb'];
print '</td><td align="right">';
print $product->stats_commande_fournisseur['qty'];
print '</td>';
print '</tr>';
}
// Contrats
if ($conf->contrat->enabled && $user->rights->contrat->lire)
{
$ret=$product->load_stats_contrat($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("contracts");
print '<tr><td>';
print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
print '</td><td align="right">';
print $product->stats_contrat['customers'];
print '</td><td align="right">';
print $product->stats_contrat['nb'];
print '</td><td align="right">';
print $product->stats_contrat['qty'];
print '</td>';
print '</tr>';
}
// Factures clients
if ($conf->facture->enabled && $user->rights->facture->lire)
{
$ret=$product->load_stats_facture($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills");
print '<tr><td>';
print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>';
print '</td><td align="right">';
print $product->stats_facture['customers'];
print '</td><td align="right">';
print $product->stats_facture['nb'];
print '</td><td align="right">';
print $product->stats_facture['qty'];
print '</td>';
print '</tr>';
}
// Factures fournisseurs
if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire)
{
$ret=$product->load_stats_facture_fournisseur($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills");
print '<tr><td>';
print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>';
print '</td><td align="right">';
print $product->stats_facture_fournisseur['suppliers'];
print '</td><td align="right">';
print $product->stats_facture_fournisseur['nb'];
print '</td><td align="right">';
print $product->stats_facture_fournisseur['qty'];
print '</td>';
print '</tr>';
}
return 0;
}
?>

View File

@ -24,7 +24,7 @@
/**
\file htdocs/product/stats/commande.php
\ingroup product, service, commande
\brief Page des stats des commandes pour un produit
\brief Page des stats des commandes clients pour un produit
\version $Revision$
*/
@ -36,6 +36,7 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php");
$langs->load("orders");
$langs->load("products");
$langs->load("companies");
$mesg = '';
@ -113,80 +114,7 @@ if ($_GET["id"] || $_GET["ref"])
print $product->getLibStatut(2);
print '</td></tr>';
print '<tr><td valign="top" width="25%">'.$langs->trans("Referers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfCustomers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
print '</tr>';
// Propals
if ($conf->propal->enabled)
{
$ret=$product->load_stats_propale($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("propal");
print '<tr><td>';
print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
print '</td><td align="right">';
print $product->stats_propale['customers'];
print '</td><td align="right">';
print $product->stats_propale['nb'];
print '</td><td align="right">';
print $product->stats_propale['qty'];
print '</td>';
print '</tr>';
}
// Commandes clients
if ($conf->commande->enabled)
{
$ret=$product->load_stats_commande($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders");
print '<tr><td>';
print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
print '</td><td align="right">';
print $product->stats_commande['customers'];
print '</td><td align="right">';
print $product->stats_commande['nb'];
print '</td><td align="right">';
print $product->stats_commande['qty'];
print '</td>';
print '</tr>';
}
// Contrats
if ($conf->contrat->enabled)
{
$ret=$product->load_stats_contrat($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("contracts");
print '<tr><td>';
print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
print '</td><td align="right">';
print $product->stats_contrat['customers'];
print '</td><td align="right">';
print $product->stats_contrat['nb'];
print '</td><td align="right">';
print $product->stats_contrat['qty'];
print '</td>';
print '</tr>';
}
// Factures
if ($conf->facture->enabled)
{
$ret=$product->load_stats_facture($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills");
print '<tr><td>';
print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>';
print '</td><td align="right">';
print $product->stats_facture['customers'];
print '</td><td align="right">';
print $product->stats_facture['nb'];
print '</td><td align="right">';
print $product->stats_facture['qty'];
print '</td>';
print '</tr>';
}
show_stats_for_company($product,$socidp);
print "</table>";

View File

@ -0,0 +1,200 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com>
*
* 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/product/stats/commande_fournisseur.php
\ingroup product, service, commande
\brief Page des stats des commandes fournisseurs pour un produit
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
$langs->load("orders");
$langs->load("products");
$langs->load("companies");
$mesg = '';
$page = $_GET["page"];
$sortfield=$_GET["sortfield"];
$sortorder=$_GET["sortorder"];
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $_GET["page"] ;
$pageprev = $_GET["page"] - 1;
$pagenext = $_GET["page"] + 1;
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="c.date_creation";
// Securite
$socidp = 0;
if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
}
else
{
$socidp = 0;
}
/*
* Affiche fiche
*
*/
if ($_GET["id"] || $_GET["ref"])
{
$product = new Product($db);
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
llxHeader("","",$langs->trans("CardProduct".$product->type));
if ($result > 0)
{
/*
* En mode visu
*/
$head=product_prepare_head($product);
$titre=$langs->trans("CardProduct".$product->type);
dolibarr_fiche_head($head, 'referers', $titre);
print '<table class="border" width="100%">';
// Reference
print '<tr>';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="3">';
$product->load_previous_next_ref();
$previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':'';
$next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':'';
if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>';
if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>';
print '</td>';
print '</tr>';
// Libelle
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td>';
print '</tr>';
// Prix
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="3">'.price($product->price).'</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
print $product->getLibStatut(2);
print '</td></tr>';
show_stats_for_company($product,$socidp);
print "</table>";
print '</div>';
$sql = "SELECT distinct(s.nom), s.idp, s.code_client, c.rowid, c.total_ht as amount, c.ref,";
$sql.= " ".$db->pdate("c.date_creation")." as date, c.fk_statut as statut, c.rowid as commandeid";
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."commande_fournisseurdet as d";
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.idp";
$sql.= " AND d.fk_commande = c.rowid AND d.fk_product =".$product->id;
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socidp)
{
$sql .= " AND c.fk_soc = ".$socidp;
}
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit($conf->liste_limit +1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
print_barre_liste($langs->trans("SuppliersOrders"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num);
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","","&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("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&amp;id=".$_GET["id"],'',$sortfield);
print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"c.date_creation","","&amp;id=".$_GET["id"],'align="center"',$sortfield);
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.amount_ht","","&amp;id=".$_GET["id"],'align="right"',$sortfield);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&amp;id=".$_GET["id"],'align="right"',$sortfield);
print "</tr>\n";
$commandestatic=new Commande($db);
if ($num > 0)
{
$var=True;
while ($i < $num && $i < $conf->liste_limit)
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$objp->commandeid.'">'.img_object($langs->trans("ShowOrder"),"order").' ';
print $objp->ref;
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=\"center\">";
print dolibarr_print_date($objp->date)."</td>";
print "<td align=\"right\">".price($objp->amount)."</td>\n";
print '<td align="right">'.$commandestatic->LibStatut($objp->statut,$objp->facture,5).'</td>';
print "</tr>\n";
$i++;
}
}
}
else
{
dolibarr_print_error($db);
}
print "</table>";
print '<br>';
$db->free($result);
}
}
else
{
dolibarr_print_error();
}
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -28,7 +28,6 @@
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
@ -36,6 +35,7 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php");
$langs->load("contracts");
$langs->load("products");
$langs->load("companies");
$mesg = '';
@ -112,80 +112,7 @@ if ($_GET["id"] || $_GET["ref"])
print $product->getLibStatut(2);
print '</td></tr>';
print '<tr><td valign="top" width="25%">'.$langs->trans("Referers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfCustomers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
print '</tr>';
// Propals
if ($conf->propal->enabled)
{
$ret=$product->load_stats_propale($socid);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("propal");
print '<tr><td>';
print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
print '</td><td align="right">';
print $product->stats_propale['customers'];
print '</td><td align="right">';
print $product->stats_propale['nb'];
print '</td><td align="right">';
print $product->stats_propale['qty'];
print '</td>';
print '</tr>';
}
// Commandes
if ($conf->commande->enabled)
{
$ret=$product->load_stats_commande($socid);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders");
print '<tr><td>';
print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
print '</td><td align="right">';
print $product->stats_commande['customers'];
print '</td><td align="right">';
print $product->stats_commande['nb'];
print '</td><td align="right">';
print $product->stats_commande['qty'];
print '</td>';
print '</tr>';
}
// Contrats
if ($conf->contrat->enabled)
{
$ret=$product->load_stats_contrat($socid);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("contracts");
print '<tr><td>';
print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
print '</td><td align="right">';
print $product->stats_contrat['customers'];
print '</td><td align="right">';
print $product->stats_contrat['nb'];
print '</td><td align="right">';
print $product->stats_contrat['qty'];
print '</td>';
print '</tr>';
}
// Factures
if ($conf->facture->enabled)
{
$ret=$product->load_stats_facture($socid);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills");
print '<tr><td>';
print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>';
print '</td><td align="right">';
print $product->stats_facture['customers'];
print '</td><td align="right">';
print $product->stats_facture['nb'];
print '</td><td align="right">';
print $product->stats_facture['qty'];
print '</td>';
print '</tr>';
}
show_stats_for_company($product,$socidp);
print "</table>";

View File

@ -24,7 +24,7 @@
/**
\file htdocs/product/stats/facture.php
\ingroup product, service, facture
\brief Page des stats des factures pour un produit
\brief Page des stats des factures clients pour un produit
\version $Revision$
*/
@ -108,114 +108,8 @@ if ($_GET["id"] || $_GET["ref"])
print $product->getLibStatut(2);
print '</td></tr>';
print '<tr><td valign="top" width="25%">'.$langs->trans("Referers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfThirdParties").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
print '</tr>';
// Propals
if ($conf->propal->enabled)
{
$ret=$product->load_stats_propale($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("propal");
print '<tr><td>';
print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
print '</td><td align="right">';
print $product->stats_propale['customers'];
print '</td><td align="right">';
print $product->stats_propale['nb'];
print '</td><td align="right">';
print $product->stats_propale['qty'];
print '</td>';
print '</tr>';
}
// Commandes clients
if ($conf->commande->enabled)
{
$ret=$product->load_stats_commande($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders");
print '<tr><td>';
print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
print '</td><td align="right">';
print $product->stats_commande['customers'];
print '</td><td align="right">';
print $product->stats_commande['nb'];
print '</td><td align="right">';
print $product->stats_commande['qty'];
print '</td>';
print '</tr>';
}
// Commandes fournisseurs
if ($conf->fournisseur->enabled)
{
$ret=$product->load_stats_commande_fournisseur($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders");
print '<tr><td>';
print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>';
print '</td><td align="right">';
print $product->stats_commande_fournisseur['suppliers'];
print '</td><td align="right">';
print $product->stats_commande_fournisseur['nb'];
print '</td><td align="right">';
print $product->stats_commande_fournisseur['qty'];
print '</td>';
print '</tr>';
}
// Contrats
if ($conf->contrat->enabled)
{
$ret=$product->load_stats_contrat($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("contracts");
print '<tr><td>';
print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
print '</td><td align="right">';
print $product->stats_contrat['customers'];
print '</td><td align="right">';
print $product->stats_contrat['nb'];
print '</td><td align="right">';
print $product->stats_contrat['qty'];
print '</td>';
print '</tr>';
}
// Factures clients
if ($conf->facture->enabled)
{
$ret=$product->load_stats_facture($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills");
print '<tr><td>';
print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>';
print '</td><td align="right">';
print $product->stats_facture['customers'];
print '</td><td align="right">';
print $product->stats_facture['nb'];
print '</td><td align="right">';
print $product->stats_facture['qty'];
print '</td>';
print '</tr>';
}
// Factures fournisseurs
if ($conf->fournisseur->enabled)
{
$ret=$product->load_stats_facture_fournisseur($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills");
print '<tr><td>';
print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>';
print '</td><td align="right">';
print $product->stats_facture_fournisseur['suppliers'];
print '</td><td align="right">';
print $product->stats_facture_fournisseur['nb'];
print '</td><td align="right">';
print $product->stats_facture_fournisseur['qty'];
print '</td>';
print '</tr>';
}
show_stats_for_company($product,$socidp);
print "</table>";
print '</div>';

View File

@ -0,0 +1,194 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
*
* 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/product/stats/facture_fournisseur.php
\ingroup product, service, facture
\brief Page des stats des factures fournisseurs pour un produit
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
$langs->load("companies");
$langs->load("bills");
$langs->load("products");
$langs->load("companies");
$mesg = '';
$page = $_GET["page"];
$sortfield=$_GET["sortfield"];
$sortorder=$_GET["sortorder"];
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $_GET["page"] ;
$pageprev = $_GET["page"] - 1;
$pagenext = $_GET["page"] + 1;
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="f.datef";
// Securite
$socidp = 0;
if ($user->societe_id > 0)
{
$socidp = $user->societe_id;
}
/*
* Affiche fiche
*
*/
if ($_GET["id"] || $_GET["ref"])
{
$product = new Product($db);
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
llxHeader("","",$langs->trans("CardProduct".$product->type));
if ($result > 0)
{
/*
* En mode visu
*/
$head=product_prepare_head($product);
$titre=$langs->trans("CardProduct".$product->type);
dolibarr_fiche_head($head, 'referers', $titre);
print '<table class="border" width="100%">';
// Reference
print '<tr>';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="3">';
$product->load_previous_next_ref();
$previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':'';
$next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':'';
if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>';
if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>';
print '</td>';
print '</tr>';
// Libelle
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td>';
print '</tr>';
// Prix
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="3">'.price($product->price).'</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
print $product->getLibStatut(2);
print '</td></tr>';
show_stats_for_company($product,$socidp);
print "</table>";
print '</div>';
$sql = "SELECT distinct(s.nom), s.idp, s.code_client, f.facnumber, f.amount as amount,";
$sql.= " ".$db->pdate("f.datef")." as date, f.paye, f.fk_statut as statut, f.rowid as facid";
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."facture_fourn_det as d";
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.fk_soc = s.idp";
$sql.= " AND d.fk_facture_fourn = f.rowid AND d.fk_product =".$product->id;
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";
}
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit($conf->liste_limit +1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
print_barre_liste($langs->trans("SuppliersInvoices"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num);
$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("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&amp;id=".$_GET["id"],'',$sortfield);
print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"f.datef","","&amp;id=".$_GET["id"],'align="center"',$sortfield);
print_liste_field_titre($langs->trans("AmountHT"),$_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="right"',$sortfield);
print "</tr>\n";
if ($num > 0)
{
$var=True;
while ($i < $num && $conf->liste_limit)
{
$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?socidp='.$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=\"center\">";
print dolibarr_print_date($objp->date)."</td>";
print "<td align=\"right\">".price($objp->amount)."</td>\n";
$fac=new Facture($db);
print '<td align="right">'.$fac->LibStatut($objp->paye,$objp->statut,5).'</td>';
print "</tr>\n";
$i++;
}
}
}
else
{
dolibarr_print_error($db);
}
print "</table>";
print '<br>';
$db->free($result);
}
}
else
{
dolibarr_print_error();
}
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -174,114 +174,7 @@ if ($_GET["id"] || $_GET["ref"])
print $product->getLibStatut(2);
print '</td></tr>';
print '<tr><td valign="top" width="25%">'.$langs->trans("Referers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfThirdParties").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
print '</tr>';
// Propals
if ($conf->propal->enabled)
{
$ret=$product->load_stats_propale($socid);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("propal");
print '<tr><td>';
print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
print '</td><td align="right">';
print $product->stats_propale['customers'];
print '</td><td align="right">';
print $product->stats_propale['nb'];
print '</td><td align="right">';
print $product->stats_propale['qty'];
print '</td>';
print '</tr>';
}
// Commandes clients
if ($conf->commande->enabled)
{
$ret=$product->load_stats_commande($socid);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders");
print '<tr><td>';
print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
print '</td><td align="right">';
print $product->stats_commande['customers'];
print '</td><td align="right">';
print $product->stats_commande['nb'];
print '</td><td align="right">';
print $product->stats_commande['qty'];
print '</td>';
print '</tr>';
}
// Commandes fournisseurs
if ($conf->fournisseur->enabled)
{
$ret=$product->load_stats_commande_fournisseur($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders");
print '<tr><td>';
print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>';
print '</td><td align="right">';
print $product->stats_commande_fournisseur['suppliers'];
print '</td><td align="right">';
print $product->stats_commande_fournisseur['nb'];
print '</td><td align="right">';
print $product->stats_commande_fournisseur['qty'];
print '</td>';
print '</tr>';
}
// Contrats
if ($conf->contrat->enabled)
{
$ret=$product->load_stats_contrat($socid);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("contracts");
print '<tr><td>';
print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
print '</td><td align="right">';
print $product->stats_contrat['customers'];
print '</td><td align="right">';
print $product->stats_contrat['nb'];
print '</td><td align="right">';
print $product->stats_contrat['qty'];
print '</td>';
print '</tr>';
}
// Factures clients
if ($conf->facture->enabled)
{
$ret=$product->load_stats_facture($socid);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills");
print '<tr><td>';
print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>';
print '</td><td align="right">';
print $product->stats_facture['customers'];
print '</td><td align="right">';
print $product->stats_facture['nb'];
print '</td><td align="right">';
print $product->stats_facture['qty'];
print '</td>';
print '</tr>';
}
// Factures fournisseurs
if ($conf->fournisseur->enabled)
{
$ret=$product->load_stats_facture_fournisseur($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills");
print '<tr><td>';
print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>';
print '</td><td align="right">';
print $product->stats_facture_fournisseur['suppliers'];
print '</td><td align="right">';
print $product->stats_facture_fournisseur['nb'];
print '</td><td align="right">';
print $product->stats_facture_fournisseur['qty'];
print '</td>';
print '</tr>';
}
show_stats_for_company($product,$socidp);
print '</table>';
print '</div>';

View File

@ -194,5 +194,5 @@ $db->free();
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
llxFooter('$Date$ - $Revision$');
?>

View File

@ -111,80 +111,7 @@ if ($_GET["id"] || $_GET["ref"])
print $product->getLibStatut(2);
print '</td></tr>';
print '<tr><td valign="top" width="25%">'.$langs->trans("Referers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfCustomers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
print '</tr>';
// Propals
if ($conf->propal->enabled)
{
$ret=$product->load_stats_propale($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("propal");
print '<tr><td>';
print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
print '</td><td align="right">';
print $product->stats_propale['customers'];
print '</td><td align="right">';
print $product->stats_propale['nb'];
print '</td><td align="right">';
print $product->stats_propale['qty'];
print '</td>';
print '</tr>';
}
// Commandes
if ($conf->commande->enabled)
{
$ret=$product->load_stats_commande($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders");
print '<tr><td>';
print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
print '</td><td align="right">';
print $product->stats_commande['customers'];
print '</td><td align="right">';
print $product->stats_commande['nb'];
print '</td><td align="right">';
print $product->stats_commande['qty'];
print '</td>';
print '</tr>';
}
// Contrats
if ($conf->contrat->enabled)
{
$ret=$product->load_stats_contrat($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("contracts");
print '<tr><td>';
print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
print '</td><td align="right">';
print $product->stats_contrat['customers'];
print '</td><td align="right">';
print $product->stats_contrat['nb'];
print '</td><td align="right">';
print $product->stats_contrat['qty'];
print '</td>';
print '</tr>';
}
// Factures
if ($conf->facture->enabled)
{
$ret=$product->load_stats_facture($socidp);
if ($ret < 0) dolibarr_print_error($db);
$langs->load("bills");
print '<tr><td>';
print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>';
print '</td><td align="right">';
print $product->stats_facture['customers'];
print '</td><td align="right">';
print $product->stats_facture['nb'];
print '</td><td align="right">';
print $product->stats_facture['qty'];
print '</td>';
print '</tr>';
}
show_stats_for_company($product,$socidp);
print "</table>";