Factorisation du code des onglets produits
Débuggage fiche produits fournisseurs Affichage du nombre de commande en cours d'un produit
This commit is contained in:
parent
2e643bfa7b
commit
377aecf983
@ -1136,19 +1136,19 @@ class Commande extends CommonObject
|
|||||||
// Recherche total en stock pour chaque produit
|
// Recherche total en stock pour chaque produit
|
||||||
if (sizeof($array_of_product))
|
if (sizeof($array_of_product))
|
||||||
{
|
{
|
||||||
$sql = "SELECT fk_product, sum(ps.reel)";
|
$sql = "SELECT fk_product, sum(ps.reel) as total";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
||||||
$sql.= " WHERE ps.fk_product in (".join(',',$array_of_product).")";
|
$sql.= " WHERE ps.fk_product in (".join(',',$array_of_product).")";
|
||||||
$sql.= ' GROUP BY fk_product ';
|
$sql.= ' GROUP BY fk_product ';
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows($result);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row( $i);
|
$obj = $this->db->fetch_object($result);
|
||||||
$this->stocks[$row[0]] = $row[1];
|
$this->stocks[$obj->fk_product] = $obj->total;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->db->free();
|
$this->db->free();
|
||||||
@ -1426,13 +1426,12 @@ class Commande extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi la liste des commandes (éventuellement filtrée sur un user) dans un tableau
|
* \brief Renvoi la liste des commandes (éventuellement filtrée sur un user) dans un tableau
|
||||||
* \param brouillon 0=non brouillon, 1=brouillon
|
* \param brouillon 0=non brouillon, 1=brouillon
|
||||||
* \param user Objet user de filtre
|
* \param user Objet user de filtre
|
||||||
* \return int -1 si erreur, tableau résultat si ok
|
* \return int -1 si erreur, tableau résultat si ok
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function liste_array ($brouillon=0, $user='')
|
function liste_array ($brouillon=0, $user='')
|
||||||
{
|
{
|
||||||
$ga = array();
|
$ga = array();
|
||||||
|
|||||||
@ -438,16 +438,8 @@ if ($_GET["id"] > 0)
|
|||||||
{
|
{
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
print '<td><a href="'.DOL_URL_ROOT.'/fourn/product/fiche.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.'</a></td>';
|
print '<td><a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.'</a></td>';
|
||||||
if ($objp->fk_product > 0)
|
print "<td>".nl2br($objp->description)."</td>";
|
||||||
{
|
|
||||||
print '<td>';
|
|
||||||
print '<a href="'.DOL_URL_ROOT.'/fourn/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->description)).'</a></td>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
|
|
||||||
}
|
|
||||||
print '<td align="center">'.$objp->tva_tx.'%</td>';
|
print '<td align="center">'.$objp->tva_tx.'%</td>';
|
||||||
print '<td align="center">'.$objp->qty.'</td>';
|
print '<td align="center">'.$objp->qty.'</td>';
|
||||||
if ($objp->remise_percent > 0)
|
if ($objp->remise_percent > 0)
|
||||||
|
|||||||
@ -49,10 +49,11 @@ $types[1] = $langs->trans("Service");
|
|||||||
|
|
||||||
if ($_GET["action"] == 'fastappro')
|
if ($_GET["action"] == 'fastappro')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$product->fetch($_GET["id"]);
|
$product->fetch($_GET["id"]);
|
||||||
$result = $product->fastappro($user);
|
$result = $product->fastappro($user);
|
||||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -572,27 +573,28 @@ else
|
|||||||
|
|
||||||
print "\n<div class=\"tabsAction\">\n";
|
print "\n<div class=\"tabsAction\">\n";
|
||||||
|
|
||||||
if ($_GET["action"] == '')
|
if ($_GET["action"] == '')
|
||||||
{
|
|
||||||
|
|
||||||
print '<a class="butAction" href="fiche.php?id='.$product->id.'&action=ajout_fourn">'.$langs->trans("AddSupplier").'</a>';
|
|
||||||
|
|
||||||
if ($product->type == 0 && $user->rights->produit->commander && $num_fournisseur == 1)
|
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="fiche.php?action=fastappro&id='.$product->id.'">';
|
if ( $user->rights->produit->creer)
|
||||||
print $langs->trans("Order").'</a>';
|
{
|
||||||
}
|
print '<a class="tabAction" href="fiche.php?action=edit&id='.$product->id.'">'.$langs->trans("Edit").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
if ( $user->rights->produit->creer)
|
if ($product->type == 0 && $conf->stock->enabled)
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="fiche.php?action=edit&id='.$product->id.'">'.$langs->trans("Edit").'</a>';
|
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/stock/product.php?id='.$product->id.'&action=correction">'.$langs->trans("CorrectStock").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print '<a class="butAction" href="fiche.php?id='.$product->id.'&action=ajout_fourn">'.$langs->trans("AddSupplier").'</a>';
|
||||||
|
|
||||||
|
if ($product->type == 0 && $user->rights->commande->creer)
|
||||||
|
{
|
||||||
|
$langs->load('orders');
|
||||||
|
print '<a class="tabAction" href="fiche.php?action=fastappro&id='.$product->id.'">';
|
||||||
|
print $langs->trans("CreateOrder").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
if ($product->type == 0 && $conf->stock->enabled)
|
|
||||||
{
|
|
||||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/stock/product.php?id='.$product->id.'&action=correction">'.$langs->trans("CorrectStock").'</a>';
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
print "\n</div>\n";
|
print "\n</div>\n";
|
||||||
|
|
||||||
|
|||||||
@ -67,17 +67,6 @@ function product_prepare_head($product)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Multilangs
|
// Multilangs
|
||||||
// TODO Ecran a virer et à remplacer par
|
// TODO Ecran a virer et à remplacer par
|
||||||
if($conf->global->MAIN_MULTILANGS)
|
if($conf->global->MAIN_MULTILANGS)
|
||||||
@ -126,6 +115,17 @@ function product_prepare_head($product)
|
|||||||
$head[$h][2] = 'document';
|
$head[$h][2] = 'document';
|
||||||
$h++;
|
$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;
|
return $head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -964,14 +964,14 @@ class Product
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Charge tableau des stats commande pour le produit/service
|
* \brief Charge tableau des stats commande client pour le produit/service
|
||||||
* \param socid Id societe
|
* \param socid Id societe pour filtrer sur une société
|
||||||
* \return array Tableau des stats
|
* \param filtrestatut Id statut pour filtrer sur un statut
|
||||||
|
* \return array Tableau des stats
|
||||||
*/
|
*/
|
||||||
function load_stats_commande($socid=0)
|
function load_stats_commande($socid=0,$filtrestatut='')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf,$user;
|
||||||
global $user;
|
|
||||||
|
|
||||||
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,";
|
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,";
|
||||||
$sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty";
|
$sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty";
|
||||||
@ -980,11 +980,14 @@ class Product
|
|||||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.rowid = cd.fk_commande AND cd.fk_product = ".$this->id;
|
$sql.= " WHERE c.rowid = cd.fk_commande AND cd.fk_product = ".$this->id;
|
||||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
//$sql.= " AND c.fk_statut != 0";
|
|
||||||
if ($socid > 0)
|
if ($socid > 0)
|
||||||
{
|
{
|
||||||
$sql .= " AND c.fk_soc = $socid";
|
$sql.= " AND c.fk_soc = ".$socid;
|
||||||
}
|
}
|
||||||
|
if ($filtrestatut)
|
||||||
|
{
|
||||||
|
$sql.= " AND c.fk_statut = ".$filtrestatut;
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->db->query($sql) ;
|
$result = $this->db->query($sql) ;
|
||||||
if ( $result )
|
if ( $result )
|
||||||
@ -1003,6 +1006,49 @@ class Product
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Charge tableau des stats commande fournisseur pour le produit/service
|
||||||
|
* \param socid Id societe pour filtrer sur une société
|
||||||
|
* \param filtrestatut Id statut pour filtrer sur un statut
|
||||||
|
* \return array Tableau des stats
|
||||||
|
*/
|
||||||
|
function load_stats_commande_fournisseur($socid=0,$filtrestatut='')
|
||||||
|
{
|
||||||
|
global $conf,$user;
|
||||||
|
|
||||||
|
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_suppliers, COUNT(DISTINCT c.rowid) as nb,";
|
||||||
|
$sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,";
|
||||||
|
$sql.= " ".MAIN_DB_PREFIX."commande_fournisseur as c";
|
||||||
|
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
|
$sql.= " WHERE c.rowid = cd.fk_commande AND cd.fk_product = ".$this->id;
|
||||||
|
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
|
if ($socid > 0)
|
||||||
|
{
|
||||||
|
$sql.= " AND c.fk_soc = ".$socid;
|
||||||
|
}
|
||||||
|
if ($filtrestatut)
|
||||||
|
{
|
||||||
|
$sql.= " AND c.fk_statut = ".$filtrestatut;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->db->query($sql) ;
|
||||||
|
if ( $result )
|
||||||
|
{
|
||||||
|
$obj=$this->db->fetch_object($result);
|
||||||
|
$this->stats_commande_fournisseur['suppliers']=$obj->nb_suppliers;
|
||||||
|
$this->stats_commande_fournisseur['nb']=$obj->nb;
|
||||||
|
$this->stats_commande_fournisseur['rows']=$obj->nb_rows;
|
||||||
|
$this->stats_commande_fournisseur['qty']=$obj->qty?$obj->qty:0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Charge tableau des stats contrat pour le produit/service
|
* \brief Charge tableau des stats contrat pour le produit/service
|
||||||
* \param socid Id societe
|
* \param socid Id societe
|
||||||
@ -1361,60 +1407,54 @@ class Product
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie le nombre de fournisseurs
|
* \brief Renvoie la liste des fournisseurs du produit/service
|
||||||
* \return int nombre de fournisseur
|
* \return array Tableau des id de fournisseur
|
||||||
*/
|
*/
|
||||||
|
function list_suppliers()
|
||||||
function count_fournisseur()
|
|
||||||
{
|
|
||||||
$sql = "SELECT fk_soc";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur as p";
|
|
||||||
$sql .= " WHERE p.fk_product = ".$this->id;
|
|
||||||
|
|
||||||
$result = $this->db->query($sql) ;
|
|
||||||
|
|
||||||
if ( $result )
|
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows();
|
$list = array();
|
||||||
|
|
||||||
if ($num == 1)
|
$sql = "SELECT fk_soc";
|
||||||
{
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur as p";
|
||||||
$row = $this->db->fetch_row();
|
$sql.= " WHERE p.fk_product = ".$this->id;
|
||||||
$this->fourn_appro_open = $row[0];
|
|
||||||
return 1;
|
$result = $this->db->query($sql);
|
||||||
}
|
if ($result)
|
||||||
else
|
{
|
||||||
{
|
$num = $this->db->num_rows($result);
|
||||||
return 0;
|
$i=0;
|
||||||
}
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
$list[$i] = $obj->fk_soc;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/**
|
||||||
|
* \brief Saisie une commande fournisseur
|
||||||
|
* \param user Objet user de celui qui demande
|
||||||
|
* \param int <0 si ko, >0 si ok
|
||||||
|
*/
|
||||||
|
function fastappro($user)
|
||||||
{
|
{
|
||||||
return 0;
|
include_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.class.php";
|
||||||
|
|
||||||
|
$list = $this->list_suppliers();
|
||||||
|
if (sizeof($list) > 0)
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Product::fastappro");
|
||||||
|
$fournisseur = new Fournisseur($this->db);
|
||||||
|
$fournisseur->fetch($this->fourn_appro_open);
|
||||||
|
|
||||||
|
$fournisseur->ProductCommande($user, $this->id);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function fastappro($user)
|
|
||||||
{
|
|
||||||
include_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.class.php";
|
|
||||||
|
|
||||||
$nbf = $this->count_fournisseur();
|
|
||||||
if ($nbf == 1)
|
|
||||||
{
|
|
||||||
dolibarr_syslog("Product::fastappro");
|
|
||||||
$fournisseur = new Fournisseur($this->db);
|
|
||||||
$fournisseur->fetch($this->fourn_appro_open);
|
|
||||||
|
|
||||||
$fournisseur->ProductCommande($user, $this->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -353,24 +353,6 @@ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer)
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'add_fourn' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
|
||||||
{
|
|
||||||
|
|
||||||
$product = new Product($db);
|
|
||||||
if( $product->fetch($_GET["id"]) )
|
|
||||||
{
|
|
||||||
if ($product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]) > 0)
|
|
||||||
{
|
|
||||||
$action = '';
|
|
||||||
$mesg = $langs->trans("SupplierAdded");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$action = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_POST["cancel"] == $langs->trans("Cancel"))
|
if ($_POST["cancel"] == $langs->trans("Cancel"))
|
||||||
{
|
{
|
||||||
$action = '';
|
$action = '';
|
||||||
@ -500,7 +482,7 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Fiche produit
|
* Fiche produit
|
||||||
*/
|
*/
|
||||||
if ($_GET["id"] || $_GET["ref"])
|
if ($_GET["id"] || $_GET["ref"])
|
||||||
@ -509,8 +491,15 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
if ($_GET["action"] <> 're-edit')
|
if ($_GET["action"] <> 're-edit')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
|
if ($_GET["ref"])
|
||||||
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
|
{
|
||||||
|
$result = $product->fetch('',$_GET["ref"]);
|
||||||
|
$_GET["id"] = $product->id;
|
||||||
|
}
|
||||||
|
elseif ($_GET["id"])
|
||||||
|
{
|
||||||
|
$result = $product->fetch($_GET["id"]);
|
||||||
|
}
|
||||||
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,7 +589,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
// Stock
|
// Stock
|
||||||
if ($product->type == 0 && $conf->stock->enabled)
|
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>'.$langs->trans("Stock").'</td>';
|
||||||
if ($product->no_stock)
|
if ($product->no_stock)
|
||||||
{
|
{
|
||||||
print "<td>Pas de définition de stock pour ce produit";
|
print "<td>Pas de définition de stock pour ce produit";
|
||||||
@ -762,12 +751,6 @@ print "\n<div class=\"tabsAction\">\n";
|
|||||||
|
|
||||||
if ($_GET["action"] == '')
|
if ($_GET["action"] == '')
|
||||||
{
|
{
|
||||||
if ($product->type == 0 && $user->rights->produit->commander && $num_fournisseur == 1)
|
|
||||||
{
|
|
||||||
print '<a class="tabAction" href="fiche.php?action=fastappro&id='.$product->id.'">';
|
|
||||||
print $langs->trans("Order").'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $user->rights->produit->creer)
|
if ( $user->rights->produit->creer)
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="fiche.php?action=edit&id='.$product->id.'">'.$langs->trans("Edit").'</a>';
|
print '<a class="tabAction" href="fiche.php?action=edit&id='.$product->id.'">'.$langs->trans("Edit").'</a>';
|
||||||
@ -775,9 +758,24 @@ if ($_GET["action"] == '')
|
|||||||
print '<a class="tabAction" href="fiche.php?action=clone&id='.$product->id.'">'.$langs->trans("CreateCopy").'</a>';
|
print '<a class="tabAction" href="fiche.php?action=clone&id='.$product->id.'">'.$langs->trans("CreateCopy").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$prod_use = $product->verif_prod_use($product->id);
|
/*
|
||||||
|
if ($product->type == 0 && $user->rights->commande->creer)
|
||||||
|
{
|
||||||
|
$langs->load('orders');
|
||||||
|
print '<a class="tabAction" href="fiche.php?action=fastappro&id='.$product->id.'">';
|
||||||
|
print $langs->trans("CreateCustomerOrder").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
if ($user->rights->produit->supprimer && $prod_use == 0)
|
if ($product->type == 0 && $user->rights->fournisseur->commande->creer)
|
||||||
|
{
|
||||||
|
$langs->load('orders');
|
||||||
|
print '<a class="tabAction" href="fiche.php?action=fastappro&id='.$product->id.'">';
|
||||||
|
print $langs->trans("CreateSupplierOrder").'</a>';
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
$product_is_used = $product->verif_prod_use($product->id);
|
||||||
|
if ($user->rights->produit->supprimer && ! $product_is_used)
|
||||||
{
|
{
|
||||||
print '<a class="butActionDelete" href="fiche.php?action=delete&id='.$product->id.'">'.$langs->trans("Delete").'</a>';
|
print '<a class="butActionDelete" href="fiche.php?action=delete&id='.$product->id.'">'.$langs->trans("Delete").'</a>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,9 +40,9 @@ $langs->load("bills");
|
|||||||
$user->getrights('produit');
|
$user->getrights('produit');
|
||||||
$mesg = '';
|
$mesg = '';
|
||||||
|
|
||||||
if (!$user->rights->produit->lire)
|
if (! $user->rights->produit->lire || ! $product->type == 0 || ! $conf->stock->enabled)
|
||||||
{
|
{
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -142,31 +142,53 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print $product->getLibStatut(2);
|
print $product->getLibStatut(2);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// TVA
|
|
||||||
$langs->load("bills");
|
|
||||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.'%</td></tr>';
|
|
||||||
|
|
||||||
// Stock
|
// Stock
|
||||||
if ($product->type == 0 && $conf->stock->enabled)
|
print '<tr><td>'.$langs->trans("TotalStock").'</td>';
|
||||||
|
if ($product->no_stock)
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("TotalStock").'</td>';
|
print "<td>Pas de définition de stock pour ce produit";
|
||||||
if ($product->no_stock)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($product->stock_reel <= $product->seuil_stock_alerte)
|
||||||
{
|
{
|
||||||
print "<td>Pas de définition de stock pour ce produit";
|
print '<td class="alerte">'.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($product->stock_reel <= $product->seuil_stock_alerte)
|
print "<td>".$product->stock_reel;
|
||||||
{
|
|
||||||
print '<td class="alerte">'.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "<td>".$product->stock_reel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
|
||||||
}
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
|
||||||
|
// Nbre de commande clients en cours
|
||||||
|
if ($conf->commande->enabled)
|
||||||
|
{
|
||||||
|
$result=$product->load_stats_commande(0,'1');
|
||||||
|
if ($result < 0) dolibarr_print_error($db,$product->error);
|
||||||
|
print '<tr><td>'.$langs->trans("CustomersOrders").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
print $product->stats_commande['qty'];
|
||||||
|
$result=$product->load_stats_commande(0,'0');
|
||||||
|
if ($result < 0) dolibarr_print_error($db,$product->error);
|
||||||
|
print ' ('.$langs->trans("Draft").': '.$product->stats_commande['qty'].')';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nbre de commande fournisseurs en cours
|
||||||
|
if ($conf->fournisseur->enabled)
|
||||||
|
{
|
||||||
|
$result=$product->load_stats_commande_fournisseur(0,'1');
|
||||||
|
if ($result < 0) dolibarr_print_error($db,$product->error);
|
||||||
|
print '<tr><td>'.$langs->trans("SuppliersOrders").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
print $product->stats_commande_fournisseur['qty'];
|
||||||
|
$result=$product->load_stats_commande_fournisseur(0,'0');
|
||||||
|
if ($result < 0) dolibarr_print_error($db,$product->error);
|
||||||
|
print ' ('.$langs->trans("Draft").': '.$product->stats_commande_fournisseur['qty'].')';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user