Modif =product_prepare_head($product, $user);

BUG 18583
This commit is contained in:
Rodolphe Quiedeville 2007-01-02 15:30:33 +00:00
parent c9b1b81c31
commit a8cda44cca

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,192 +22,190 @@
*/ */
/** /**
\file htdocs/lib/product.lib.php \file htdocs/lib/product.lib.php
\brief Ensemble de fonctions de base pour le module produit et service \brief Ensemble de fonctions de base pour le module produit et service
\version $Revision$ \version $Revision$
Ensemble de fonctions de base de dolibarr sous forme d'include
*/ */
function product_prepare_head($product) function product_prepare_head($product, $user)
{ {
global $langs, $conf; global $langs, $conf;
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans("Card"); $head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
$head[$h][1] = $langs->trans("Price"); $head[$h][1] = $langs->trans("Price");
$head[$h][2] = 'price'; $head[$h][2] = 'price';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
$head[$h][1] = $langs->trans("Photos"); $head[$h][1] = $langs->trans("Photos");
$head[$h][2] = 'photos'; $head[$h][2] = 'photos';
$h++; $h++;
//affichage onglet catégorie //affichage onglet catégorie
if ($conf->categorie->enabled) if ($conf->categorie->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/product/categorie.php?id=".$product->id;
$head[$h][1] = $langs->trans('Categories');
$head[$h][2] = 'category';
$h++;
}
if($product->type == 0)
{
if ($user->rights->barcode->lire)
{ {
$head[$h][0] = DOL_URL_ROOT."/product/categorie.php?id=".$product->id; if ($conf->barcode->enabled)
$head[$h][1] = $langs->trans('Categories'); {
$head[$h][2] = 'category'; $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id;
$h++; $head[$h][1] = $langs->trans("BarCode");
$head[$h][2] = 'barcode';
$h++;
}
} }
}
if($product->type == 0)
// Multilangs
// TODO Ecran a virer et à remplacer par
if($conf->global->MAIN_MULTILANGS)
{
$head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$product->id;
$head[$h][1] = $langs->trans("Translation");
$head[$h][2] = 'translation';
$h++;
}
// sousproduits
if($conf->global->PRODUIT_SOUSPRODUITS == 1)
{
$head[$h][0] = DOL_URL_ROOT."/product/sousproduits/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans('AssociatedProducts');
$head[$h][2] = 'subproduct';
$h++;
}
if ($conf->fournisseur->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
$head[$h][1] = $langs->trans("Suppliers");
$head[$h][2] = 'suppliers';
$h++;
}
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans('Statistics');
$head[$h][2] = 'stats';
$h++;
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
$head[$h][1] = $langs->trans('Referers');
$head[$h][2] = 'referers';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id;
$head[$h][1] = $langs->trans('Documents');
$head[$h][2] = 'documents';
$h++;
if($product->type == 0) // Si produit stockable
{
if ($conf->stock->enabled)
{ {
if ($user->rights->barcode->lire) $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
{ $head[$h][1] = $langs->trans("Stock");
if ($conf->barcode->enabled) $head[$h][2] = 'stock';
{ $h++;
$head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id;
$head[$h][1] = $langs->trans("BarCode");
$head[$h][2] = 'barcode';
$h++;
}
}
} }
}
// Multilangs
// TODO Ecran a virer et à remplacer par return $head;
if($conf->global->MAIN_MULTILANGS)
{
$head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$product->id;
$head[$h][1] = $langs->trans("Translation");
$head[$h][2] = 'translation';
$h++;
}
// sousproduits
if($conf->global->PRODUIT_SOUSPRODUITS == 1)
{
$head[$h][0] = DOL_URL_ROOT."/product/sousproduits/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans('AssociatedProducts');
$head[$h][2] = 'subproduct';
$h++;
}
if ($conf->fournisseur->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
$head[$h][1] = $langs->trans("Suppliers");
$head[$h][2] = 'suppliers';
$h++;
}
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans('Statistics');
$head[$h][2] = 'stats';
$h++;
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
$head[$h][1] = $langs->trans('Referers');
$head[$h][2] = 'referers';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id;
$head[$h][1] = $langs->trans('Documents');
$head[$h][2] = 'documents';
$h++;
if($product->type == 0) // Si produit stockable
{
if ($conf->stock->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
$head[$h][1] = $langs->trans("Stock");
$head[$h][2] = 'stock';
$h++;
}
}
return $head;
} }
function show_stats_for_company($product,$socid) function show_stats_for_company($product,$socid)
{ {
global $conf,$langs,$user,$db; global $conf,$langs,$user,$db;
print '<tr>'; print '<tr>';
print '<td align="left" width="25%" valign="top">'.$langs->trans("Referers").'</td>'; 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("NbOfThirdParties").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>'; print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>'; print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
print '</tr>'; print '</tr>';
// Propals // Propals
if ($conf->propal->enabled && $user->rights->propale->lire) if ($conf->propal->enabled && $user->rights->propale->lire)
{ {
$ret=$product->load_stats_propale($socid); $ret=$product->load_stats_propale($socid);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("propal"); $langs->load("propal");
print '<tr><td>'; print '<tr><td>';
print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>'; print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_propale['customers']; print $product->stats_propale['customers'];
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_propale['nb']; print $product->stats_propale['nb'];
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_propale['qty']; print $product->stats_propale['qty'];
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Commandes clients // Commandes clients
if ($conf->commande->enabled && $user->rights->commande->lire) if ($conf->commande->enabled && $user->rights->commande->lire)
{ {
$ret=$product->load_stats_commande($socid); $ret=$product->load_stats_commande($socid);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders"); $langs->load("orders");
print '<tr><td>'; print '<tr><td>';
print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>'; print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_commande['customers']; print $product->stats_commande['customers'];
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_commande['nb']; print $product->stats_commande['nb'];
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_commande['qty']; print $product->stats_commande['qty'];
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Commandes fournisseurs // Commandes fournisseurs
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire)
{ {
$ret=$product->load_stats_commande_fournisseur($socid); $ret=$product->load_stats_commande_fournisseur($socid);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("orders"); $langs->load("orders");
print '<tr><td>'; print '<tr><td>';
print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>'; print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>';
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_commande_fournisseur['suppliers']; print $product->stats_commande_fournisseur['suppliers'];
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_commande_fournisseur['nb']; print $product->stats_commande_fournisseur['nb'];
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_commande_fournisseur['qty']; print $product->stats_commande_fournisseur['qty'];
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Contrats // Contrats
if ($conf->contrat->enabled && $user->rights->contrat->lire) if ($conf->contrat->enabled && $user->rights->contrat->lire)
{ {
$ret=$product->load_stats_contrat($socid); $ret=$product->load_stats_contrat($socid);
if ($ret < 0) dolibarr_print_error($db); if ($ret < 0) dolibarr_print_error($db);
$langs->load("contracts"); $langs->load("contracts");
print '<tr><td>'; print '<tr><td>';
print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>'; print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_contrat['customers']; print $product->stats_contrat['customers'];
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_contrat['nb']; print $product->stats_contrat['nb'];
print '</td><td align="right">'; print '</td><td align="right">';
print $product->stats_contrat['qty']; print $product->stats_contrat['qty'];
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Factures clients // Factures clients
if ($conf->facture->enabled && $user->rights->facture->lire) if ($conf->facture->enabled && $user->rights->facture->lire)
@ -243,8 +242,8 @@ function show_stats_for_company($product,$socid)
print '</tr>'; print '</tr>';
} }
return 0; return 0;
} }
?> ?>