diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php
index fa611cc0d39..011a40b7679 100644
--- a/htdocs/fourn/facture/document.php
+++ b/htdocs/fourn/facture/document.php
@@ -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');
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index d0d820908cc..d8cbc42af7e 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -651,7 +651,6 @@ else
* Liste des paiements
*/
print '
';
- print $langs->trans('Payments').' : ';
$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 '';
print '';
- print '| '.$langs->trans('Date').' | ';
+ print ''.$langs->trans('Payments').' | ';
print ''.$langs->trans('Type').' | ';
if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0)
@@ -744,7 +743,12 @@ else
$var=!$var;
print ' ';
- print '| '.$fac->lignes[$i][0].' | ';
+
+ print '';
+ //print ''.img_object($langs->trans("ShowProduct"),'product').' ';
+ print $fac->lignes[$i][0];
+ //print '';
+ print ' | ';
print ''.price($fac->lignes[$i][1]).' | ';
print ''.$fac->lignes[$i][3].' | ';
print ''.price($fac->lignes[$i][4]).' | ';
diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php
index 3727e0e6c20..8944e76fd8b 100644
--- a/htdocs/fourn/fournisseur.facture.class.php
+++ b/htdocs/fourn/fournisseur.facture.class.php
@@ -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)
diff --git a/htdocs/fourn/product/liste.php b/htdocs/fourn/product/liste.php
index 4af79500682..6bc2e228340 100644
--- a/htdocs/fourn/product/liste.php
+++ b/htdocs/fourn/product/liste.php
@@ -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)?"&type=$type":""), $sortfield, $sortorder,'',$num);
- }
+ $param="&envente=$envente&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&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 " ";
- print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&envente=$envente".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield);
- print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield);
- print_liste_field_titre($langs->trans("Supplier"),"liste.php", "pf.fk_soc","","","",$sortfield);
- print_liste_field_titre($langs->trans("BuyingPrice"),"liste.php", "ppf.price","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield);
+ print_liste_field_titre($langs->trans("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 " \n";
// Lignes des champs de filtre
diff --git a/htdocs/lib/product.lib.php b/htdocs/lib/product.lib.php
index 7fb269e65a8..e594c5511db 100644
--- a/htdocs/lib/product.lib.php
+++ b/htdocs/lib/product.lib.php
@@ -129,4 +129,123 @@ function product_prepare_head($product)
return $head;
}
+
+function show_stats_for_company($product,$socidp)
+{
+ global $conf,$langs,$user,$db;
+
+ print '';
+ print '| '.$langs->trans("Referers").' | ';
+ print ''.$langs->trans("NbOfThirdParties").' | ';
+ print ''.$langs->trans("NbOfReferers").' | ';
+ print ''.$langs->trans("TotalQuantity").' | ';
+ print ' ';
+
+ // 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 '| ';
+ print ''.img_object('','propal').' '.$langs->trans("Proposals").'';
+ print ' | ';
+ print $product->stats_propale['customers'];
+ print ' | ';
+ print $product->stats_propale['nb'];
+ print ' | ';
+ print $product->stats_propale['qty'];
+ print ' | ';
+ print ' ';
+ }
+ // 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 '| ';
+ print ''.img_object('','order').' '.$langs->trans("CustomersOrders").'';
+ print ' | ';
+ print $product->stats_commande['customers'];
+ print ' | ';
+ print $product->stats_commande['nb'];
+ print ' | ';
+ print $product->stats_commande['qty'];
+ print ' | ';
+ print ' ';
+ }
+ // 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 '| ';
+ print ''.img_object('','order').' '.$langs->trans("SuppliersOrders").'';
+ print ' | ';
+ print $product->stats_commande_fournisseur['suppliers'];
+ print ' | ';
+ print $product->stats_commande_fournisseur['nb'];
+ print ' | ';
+ print $product->stats_commande_fournisseur['qty'];
+ print ' | ';
+ print ' ';
+ }
+ // 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 '| ';
+ print ''.img_object('','contract').' '.$langs->trans("Contracts").'';
+ print ' | ';
+ print $product->stats_contrat['customers'];
+ print ' | ';
+ print $product->stats_contrat['nb'];
+ print ' | ';
+ print $product->stats_contrat['qty'];
+ print ' | ';
+ print ' ';
+ }
+ // 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 '| ';
+ print ''.img_object('','bill').' '.$langs->trans("CustomersInvoices").'';
+ print ' | ';
+ print $product->stats_facture['customers'];
+ print ' | ';
+ print $product->stats_facture['nb'];
+ print ' | ';
+ print $product->stats_facture['qty'];
+ print ' | ';
+ print ' ';
+ }
+ // 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 '| ';
+ print ''.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'';
+ print ' | ';
+ print $product->stats_facture_fournisseur['suppliers'];
+ print ' | ';
+ print $product->stats_facture_fournisseur['nb'];
+ print ' | ';
+ print $product->stats_facture_fournisseur['qty'];
+ print ' | ';
+ print ' ';
+ }
+
+ return 0;
+}
+
+
?>
\ No newline at end of file
diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php
index 4af885e4fdd..d7f3af0b4aa 100644
--- a/htdocs/product/stats/commande.php
+++ b/htdocs/product/stats/commande.php
@@ -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 '';
- print '| '.$langs->trans("Referers").' | ';
- print ''.$langs->trans("NbOfCustomers").' | ';
- print ''.$langs->trans("NbOfReferers").' | ';
- print ''.$langs->trans("TotalQuantity").' | ';
- print ' ';
-
- // Propals
- if ($conf->propal->enabled)
- {
- $ret=$product->load_stats_propale($socidp);
- if ($ret < 0) dolibarr_print_error($db);
- $langs->load("propal");
- print '| ';
- print ''.img_object('','propal').' '.$langs->trans("Proposals").'';
- print ' | ';
- print $product->stats_propale['customers'];
- print ' | ';
- print $product->stats_propale['nb'];
- print ' | ';
- print $product->stats_propale['qty'];
- print ' | ';
- print ' ';
- }
- // Commandes clients
- if ($conf->commande->enabled)
- {
- $ret=$product->load_stats_commande($socidp);
- if ($ret < 0) dolibarr_print_error($db);
- $langs->load("orders");
- print '| ';
- print ''.img_object('','order').' '.$langs->trans("CustomersOrders").'';
- print ' | ';
- print $product->stats_commande['customers'];
- print ' | ';
- print $product->stats_commande['nb'];
- print ' | ';
- print $product->stats_commande['qty'];
- print ' | ';
- print ' ';
- }
- // Contrats
- if ($conf->contrat->enabled)
- {
- $ret=$product->load_stats_contrat($socidp);
- if ($ret < 0) dolibarr_print_error($db);
- $langs->load("contracts");
- print '| ';
- print ''.img_object('','contract').' '.$langs->trans("Contracts").'';
- print ' | ';
- print $product->stats_contrat['customers'];
- print ' | ';
- print $product->stats_contrat['nb'];
- print ' | ';
- print $product->stats_contrat['qty'];
- print ' | ';
- print ' ';
- }
- // Factures
- if ($conf->facture->enabled)
- {
- $ret=$product->load_stats_facture($socidp);
- if ($ret < 0) dolibarr_print_error($db);
- $langs->load("bills");
- print '| ';
- print ''.img_object('','bill').' '.$langs->trans("CustomersInvoices").'';
- print ' | ';
- print $product->stats_facture['customers'];
- print ' | ';
- print $product->stats_facture['nb'];
- print ' | ';
- print $product->stats_facture['qty'];
- print ' | ';
- print ' ';
- }
+ show_stats_for_company($product,$socidp);
print " ";
diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php
new file mode 100644
index 00000000000..1234db06cb2
--- /dev/null
+++ b/htdocs/product/stats/commande_fournisseur.php
@@ -0,0 +1,200 @@
+
+ * Copyright (C) 2004-2006 Laurent Destailleur
+ * Copyright (C) 2005 Regis Houssin
+ *
+ * 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 '';
+
+ // Reference
+ print '';
+ print '| '.$langs->trans("Ref").' | ';
+ $product->load_previous_next_ref();
+ $previous_ref = $product->ref_previous?'ref_previous.'">'.img_previous().'':'';
+ $next_ref = $product->ref_next?'ref_next.'">'.img_next().'':'';
+ if ($previous_ref || $next_ref) print '';
+ print ' | ';
+ print ' ';
+
+ // Libelle
+ print '| '.$langs->trans("Label").' | '.$product->libelle.' | ';
+ print ' ';
+
+ // Prix
+ print '| '.$langs->trans("SellingPrice").' | '.price($product->price).' | ';
+
+ // Statut
+ print '| '.$langs->trans("Status").' | ';
+ print $product->getLibStatut(2);
+ print ' | ';
+
+ show_stats_for_company($product,$socidp);
+
+ print " ";
+
+ print '';
+
+
+ $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"],"&id=$product->id",$sortfield,$sortorder,'',$num);
+
+ $i = 0;
+ print "";
+
+ print '';
+ print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","","&id=".$_GET["id"],'',$sortfield);
+ print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield);
+ print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield);
+ print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"c.date_creation","","&id=".$_GET["id"],'align="center"',$sortfield);
+ print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.amount_ht","","&id=".$_GET["id"],'align="right"',$sortfield);
+ print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield);
+ print " \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 "";
+ print '| '.img_object($langs->trans("ShowOrder"),"order").' ';
+ print $objp->ref;
+ print " | \n";
+ print ''.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).' | ';
+ print "".$objp->code_client." | \n";
+ print "";
+ print dolibarr_print_date($objp->date)." | ";
+ print "".price($objp->amount)." | \n";
+ print ''.$commandestatic->LibStatut($objp->statut,$objp->facture,5).' | ';
+ print " \n";
+ $i++;
+ }
+ }
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+ print " ";
+ print ' ';
+ $db->free($result);
+ }
+}
+else
+{
+ dolibarr_print_error();
+}
+
+$db->close();
+
+llxFooter('$Date$ - $Revision$');
+?>
diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php
index 48efdcdcf17..fea1b8d7f42 100644
--- a/htdocs/product/stats/contrat.php
+++ b/htdocs/product/stats/contrat.php
@@ -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 ' |
';
- print '