New: Ajout statut produit/service sur liste des produits/service
This commit is contained in:
parent
dbb2eca405
commit
1597359398
@ -33,6 +33,10 @@ Movement=Movement
|
|||||||
Movements=Movements
|
Movements=Movements
|
||||||
OnSell=On sell
|
OnSell=On sell
|
||||||
NotOnSell=Out of Sell
|
NotOnSell=Out of Sell
|
||||||
|
ProductStatusOnSell=On sell
|
||||||
|
ProductStatusNotOnSell=Out of sell
|
||||||
|
ProductStatusOnSellShort=On sell
|
||||||
|
ProductStatusNotOnSellShort=Out of sell
|
||||||
UpdatePrice=Update price
|
UpdatePrice=Update price
|
||||||
AppliedPricesFrom=Applied prices from
|
AppliedPricesFrom=Applied prices from
|
||||||
SellingPrice=Selling price
|
SellingPrice=Selling price
|
||||||
|
|||||||
@ -37,6 +37,10 @@ Movement=Mouvement
|
|||||||
Movements=Mouvements
|
Movements=Mouvements
|
||||||
OnSell=En vente
|
OnSell=En vente
|
||||||
NotOnSell=Hors vente
|
NotOnSell=Hors vente
|
||||||
|
ProductStatusOnSell=En vente
|
||||||
|
ProductStatusNotOnSell=Hors vente
|
||||||
|
ProductStatusOnSellShort=En vente
|
||||||
|
ProductStatusNotOnSellShort=Hors vente
|
||||||
UpdatePrice=Changer le prix
|
UpdatePrice=Changer le prix
|
||||||
AppliedPricesFrom=Prix de vente pratiqués à partir du
|
AppliedPricesFrom=Prix de vente pratiqués à partir du
|
||||||
SellingPrice=Prix de vente
|
SellingPrice=Prix de vente
|
||||||
|
|||||||
@ -48,6 +48,7 @@ class Product
|
|||||||
var $seuil_stock_alerte;
|
var $seuil_stock_alerte;
|
||||||
var $duration_value;
|
var $duration_value;
|
||||||
var $duration_unit;
|
var $duration_unit;
|
||||||
|
var $status;
|
||||||
|
|
||||||
var $stats_propale=array();
|
var $stats_propale=array();
|
||||||
var $stats_commande=array();
|
var $stats_commande=array();
|
||||||
@ -66,7 +67,8 @@ class Product
|
|||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
$this->id = $id ;
|
$this->id = $id ;
|
||||||
$this->envente = 0;
|
$this->envente = 0; // deprecated
|
||||||
|
$this->status = 0;
|
||||||
$this->seuil_stock_alerte = 0;
|
$this->seuil_stock_alerte = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +112,8 @@ class Product
|
|||||||
|
|
||||||
if (strlen($this->tva_tx)==0) $this->tva_tx = 0;
|
if (strlen($this->tva_tx)==0) $this->tva_tx = 0;
|
||||||
if (strlen($this->price)==0) $this->price = 0;
|
if (strlen($this->price)==0) $this->price = 0;
|
||||||
if (strlen($this->envente)==0) $this->envente = 0;
|
if (strlen($this->envente)==0) $this->envente = 0; // deprecated
|
||||||
|
if (strlen($this->status)==0) $this->status = 0;
|
||||||
$this->price = ereg_replace(",",".",$this->price);
|
$this->price = ereg_replace(",",".",$this->price);
|
||||||
|
|
||||||
dolibarr_syslog("Product::Create ref=".$this->ref." Categorie : ".$this->catid);
|
dolibarr_syslog("Product::Create ref=".$this->ref." Categorie : ".$this->catid);
|
||||||
@ -425,7 +428,8 @@ class Product
|
|||||||
$this->tva_tx = $result["tva_tx"];
|
$this->tva_tx = $result["tva_tx"];
|
||||||
$this->type = $result["fk_product_type"];
|
$this->type = $result["fk_product_type"];
|
||||||
$this->nbvente = $result["nbvente"];
|
$this->nbvente = $result["nbvente"];
|
||||||
$this->envente = $result["envente"];
|
$this->envente = $result["envente"]; // deprecated
|
||||||
|
$this->status = $result["envente"];
|
||||||
$this->duration = $result["duration"];
|
$this->duration = $result["duration"];
|
||||||
$this->duration_value = substr($result["duration"],0,strlen($result["duration"])-1);
|
$this->duration_value = substr($result["duration"],0,strlen($result["duration"])-1);
|
||||||
$this->duration_unit = substr($result["duration"],-1);
|
$this->duration_unit = substr($result["duration"],-1);
|
||||||
@ -947,6 +951,31 @@ class Product
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
|
||||||
|
* \param mode 0=libellé long, 1=libellé court
|
||||||
|
* \return string Libelle
|
||||||
|
*/
|
||||||
|
function getLibStatut($mode=0)
|
||||||
|
{
|
||||||
|
return $this->LibStatut($this->status,$mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Renvoi le libellé d'un statut donne
|
||||||
|
* \param status Statut
|
||||||
|
* \param mode 0=libellé long, 1=libellé court
|
||||||
|
* \return string Libellé du statut
|
||||||
|
*/
|
||||||
|
function LibStatut($status,$mode=0)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
$langs->load('products');
|
||||||
|
if ($status == 0) return $langs->trans('ProductStatusNotOnSell'.($mode?'Short':''));
|
||||||
|
if ($status == 1) return $langs->trans('ProductStatusOnSell'.($mode?'Short':''));
|
||||||
|
return $langs->trans('Unknown');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Entre un nombre de piece du produit en stock dans un entrepôt
|
* \brief Entre un nombre de piece du produit en stock dans un entrepôt
|
||||||
* \param id_entrepot id de l'entrepot
|
* \param id_entrepot id de l'entrepot
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT.'/product.class.php');
|
||||||
|
|
||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
|
|
||||||
@ -62,15 +63,15 @@ if (isset($_POST["button_removefilter_x"]))
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mode Liste
|
* Affichage mode liste
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$title=$langs->trans("ProductsAndServices");
|
$title=$langs->trans("ProductsAndServices");
|
||||||
|
|
||||||
$sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type, '.$db->pdate('p.tms').' as datem';
|
$sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type, '.$db->pdate('p.tms').' as datem,';
|
||||||
|
$sql.= ' p.duration, p.envente as statut';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p';
|
||||||
|
|
||||||
if ($_GET["fourn_id"] > 0)
|
if ($_GET["fourn_id"] > 0)
|
||||||
{
|
{
|
||||||
$fourn_id = $_GET["fourn_id"];
|
$fourn_id = $_GET["fourn_id"];
|
||||||
@ -97,16 +98,9 @@ if (isset($_GET["envente"]) && strlen($_GET["envente"]) > 0)
|
|||||||
{
|
{
|
||||||
$sql .= " AND p.envente = ".$_GET["envente"];
|
$sql .= " AND p.envente = ".$_GET["envente"];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($fourn_id == 0)
|
|
||||||
{
|
|
||||||
$sql .= " AND p.envente = 1";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($fourn_id > 0)
|
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 .= " ORDER BY $sortfield $sortorder ";
|
$sql .= " ORDER BY $sortfield $sortorder ";
|
||||||
$sql .= $db->plimit($limit + 1 ,$offset);
|
$sql .= $db->plimit($limit + 1 ,$offset);
|
||||||
@ -133,96 +127,103 @@ if ($resql)
|
|||||||
$envente=1;
|
$envente=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $envente)
|
if (isset($_GET["type"]) || isset($_POST["type"]))
|
||||||
{
|
{
|
||||||
if (isset($_GET["type"]) || isset($_POST["type"])) {
|
$type=isset($_GET["type"])?$_GET["type"]:$_POST["type"];
|
||||||
$type=isset($_GET["type"])?$_GET["type"]:$_POST["type"];
|
if ($type) { $texte = $langs->trans("Services"); }
|
||||||
if ($type) { $texte = $langs->trans("ServicesNotOnSell"); }
|
else { $texte = $langs->trans("Products"); }
|
||||||
else { $texte = $langs->trans("ProductsNotOnSell"); }
|
} else {
|
||||||
} else {
|
$texte = $langs->trans("ProductsAndServices");
|
||||||
$texte = $langs->trans("ProductsAndServicesNotOnSell");
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
llxHeader("","",$texte);
|
||||||
|
|
||||||
|
if ($sref || $snom || $_POST["sall"] || $_POST["search"])
|
||||||
|
{
|
||||||
|
print_barre_liste($texte, $page, "liste.php", "&sref=".$sref."&snom=".$snom."&envente=".$_POST["envente"], $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);
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<table class="liste" width="100%">';
|
||||||
|
|
||||||
|
// Lignes des titres
|
||||||
|
print "<tr class=\"liste_titre\">";
|
||||||
|
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("DateModification"),"liste.php", "p.tms","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="center"',$sortfield);
|
||||||
|
if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"),"liste.php", "p.duration","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="center"',$sortfield);
|
||||||
|
print_liste_field_titre($langs->trans("SellingPrice"),"liste.php", "p.price","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield);
|
||||||
|
print_liste_field_titre($langs->trans("Status"),"liste.php", "p.envente","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="center"',$sortfield);
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
// Lignes des champs de filtre
|
||||||
|
print '<form action="liste.php" method="post" name="formulaire">';
|
||||||
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||||
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
|
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print '<input class="flat" type="text" name="sref" value="'.$sref.'">';
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="liste_titre" valign="right">';
|
||||||
|
print '<input class="flat" type="text" name="snom" value="'.$snom.'">';
|
||||||
|
print '</td>';
|
||||||
|
if ($conf->service->enabled && $type != 0)
|
||||||
|
{
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print ' ';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print ' ';
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print ' ';
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="liste_titre" align="right">';
|
||||||
|
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
|
||||||
|
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" alt="'.$langs->trans("RemoveFilter").'">';
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
print '</form>';
|
||||||
|
|
||||||
|
$product_static=new Product($db);
|
||||||
|
|
||||||
|
$var=True;
|
||||||
|
while ($i < min($num,$limit))
|
||||||
|
{
|
||||||
|
$objp = $db->fetch_object($resql);
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr $bc[$var]><td>";
|
||||||
|
print "<a href=\"fiche.php?id=$objp->rowid\">";
|
||||||
|
if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service");
|
||||||
|
else print img_object($langs->trans("ShowProduct"),"product");
|
||||||
|
print '</a> ';
|
||||||
|
print '<a href="fiche.php?id='.$objp->rowid.'">'.$objp->ref.'</a></td>';
|
||||||
|
print '<td>'.$objp->label.'</td>';
|
||||||
|
print '<td align="center">'.dolibarr_print_date($objp->datem).'</td>';
|
||||||
|
if ($conf->service->enabled && $type != 0)
|
||||||
{
|
{
|
||||||
if (isset($_POST["type"]) || isset($_GET["type"])) {
|
print '<td align="center">'.$objp->duration.'</td>';
|
||||||
if ($type) { $texte = $langs->trans("ServicesOnSell"); }
|
|
||||||
else { $texte = $langs->trans("ProductsOnSell"); }
|
|
||||||
} else {
|
|
||||||
$texte = $langs->trans("ProductsAndServicesOnSell");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
llxHeader("","",$texte);
|
|
||||||
|
|
||||||
if ($sref || $snom || $_POST["sall"] || $_POST["search"])
|
|
||||||
{
|
|
||||||
print_barre_liste($texte, $page, "liste.php", "&sref=".$sref."&snom=".$snom."&envente=".$_POST["envente"], $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);
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<table class="liste" width="100%">';
|
|
||||||
|
|
||||||
// Lignes des titres
|
|
||||||
print "<tr class=\"liste_titre\">";
|
|
||||||
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("DateModification"),"liste.php", "p.tms","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="center"',$sortfield);
|
|
||||||
print_liste_field_titre($langs->trans("SellingPrice"),"liste.php", "p.price","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield);
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
// Lignes des champs de filtre
|
|
||||||
print '<form action="liste.php" method="post" name="formulaire">';
|
|
||||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
|
||||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
|
||||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td class="liste_titre">';
|
|
||||||
print '<input class="flat" type="text" name="sref" value="'.$sref.'">';
|
|
||||||
print '</td>';
|
|
||||||
print '<td class="liste_titre" valign="right">';
|
|
||||||
print '<input class="flat" type="text" name="snom" value="'.$snom.'">';
|
|
||||||
print '</td>';
|
|
||||||
print '<td class="liste_titre">';
|
|
||||||
print ' ';
|
|
||||||
print '</td>';
|
|
||||||
print '<td class="liste_titre" align="right">';
|
|
||||||
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
|
|
||||||
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" alt="'.$langs->trans("RemoveFilter").'">';
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
print '</form>';
|
|
||||||
|
|
||||||
|
|
||||||
$var=True;
|
|
||||||
while ($i < min($num,$limit))
|
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($resql);
|
|
||||||
$var=!$var;
|
|
||||||
print "<tr $bc[$var]><td>";
|
|
||||||
print "<a href=\"fiche.php?id=$objp->rowid\">";
|
|
||||||
if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service");
|
|
||||||
else print img_object($langs->trans("ShowProduct"),"product");
|
|
||||||
print '</a> ';
|
|
||||||
print '<a href="fiche.php?id='.$objp->rowid.'">'.$objp->ref.'</a></td>';
|
|
||||||
print '<td>'.$objp->label.'</td>';
|
|
||||||
print '<td align="center">'.dolibarr_print_date($objp->datem).'</td>';
|
|
||||||
print '<td align="right">'.price($objp->price).'</td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$db->free($resql);
|
|
||||||
|
|
||||||
print "</table>";
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
print '<td align="right">'.price($objp->price).'</td>';
|
||||||
|
print '<td align="center">'.$product_static->LibStatut($objp->statut).'</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$db->free($resql);
|
||||||
|
|
||||||
|
print "</table>";
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user