| '.$langs->trans("Duration").' | ';
print ' ';
@@ -939,14 +940,14 @@ if ($_GET["action"] == '')
}
/*
- if ($product->type == 0 && $user->rights->commande->creer)
+ if ($product->isproduct() && $user->rights->commande->creer)
{
$langs->load('orders');
print '';
print $langs->trans("CreateCustomerOrder").'';
}
- if ($product->type == 0 && $user->rights->fournisseur->commande->creer)
+ if ($product->isproduct() && $user->rights->fournisseur->commande->creer)
{
$langs->load('orders');
print '';
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 7721672c2b7..91e54a8c214 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -46,10 +46,6 @@ $mesg = '';
if (! $user->rights->produit->lire) accessforbidden();
-$types[0] = $langs->trans("Product");
-$types[1] = $langs->trans("Service");
-
-
/*
* Actions
*/
@@ -276,9 +272,10 @@ if ($_GET["id"] || $_GET["ref"])
print ' ';
+ if ($user->rights->fournisseur->lire) {
// Titre liste des fournisseurs
print '';
- if ($product->type == 0) $nblignefour=4;
+ if ($product->isproduct()) $nblignefour=4;
else $nblignefour=4;
print '| ';
print $langs->trans("Suppliers").' | ';
@@ -297,6 +294,7 @@ if ($_GET["id"] || $_GET["ref"])
$sql.= " WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id;
$sql.= " ORDER BY lower(s.nom), pfp.quantity";
+ $resql="";
$resql=$db->query($sql);
if ($resql)
{
@@ -355,6 +353,7 @@ if ($_GET["id"] || $_GET["ref"])
}
}
}
+}
else
{
print $langs->trans("ErrorUnknown");
diff --git a/htdocs/product/index.php b/htdocs/product/index.php
index 51f657a20d5..e273d545008 100644
--- a/htdocs/product/index.php
+++ b/htdocs/product/index.php
@@ -161,7 +161,10 @@ if ($result)
else print img_object($langs->trans("ShowProduct"),"product");
print " rowid\">$objp->ref\n";
print ''.dolibarr_trunc($objp->label,40).' | ';
- print ''.$staticproduct->typeprodser[$objp->fk_product_type]." | ";
+ print "";
+ if ($objp->type==1) print $langs->trans("ShowService");
+ else print $langs->trans("ShowProduct");
+ print " | ";
print '';
print $staticproduct->LibStatut($objp->envente,5);
print " | ";
diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php
index 49b47088111..9df3457a4d0 100644
--- a/htdocs/product/liste.php
+++ b/htdocs/product/liste.php
@@ -87,9 +87,8 @@ else
if (isset($_GET["type"]) || isset($_POST["type"]))
{
- $type=isset($_GET["type"])?$_GET["type"]:$_POST["type"];
- if ($type) { $texte = $langs->trans("Services"); }
- else { $texte = $langs->trans("Products"); }
+ if ($type==1) { $texte = $langs->trans("Services"); }
+ else { $texte = $langs->trans("Products"); }
} else {
$texte = $langs->trans("ProductsAndServices");
}
@@ -116,9 +115,14 @@ if ($sall)
{
$sql .= " AND (p.ref like '%".addslashes($sall)."%' OR p.label like '%".addslashes($sall)."%' OR p.description like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%')";
}
+# if the type is not 1, we show all products (type = 0,2,3)
if (strlen($_GET["type"]) || strlen($_POST["type"]))
{
- $sql .= " AND p.fk_product_type = ".(strlen($_GET["type"])?$_GET["type"]:$_POST["type"]);
+ if ($type==1) {
+ $sql .= " AND p.fk_product_type = '1'";
+ } else {
+ $sql .= " AND p.fk_product_type <> '1'";
+ }
}
if ($sref)
{
diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php
index 46834a29d52..2efbc93ceee 100644
--- a/htdocs/product/photos.php
+++ b/htdocs/product/photos.php
@@ -45,10 +45,6 @@ $mesg = '';
if (!$user->rights->produit->lire) accessforbidden();
-$types[0] = $langs->trans("Product");
-$types[1] = $langs->trans("Service");
-
-
/*
* Actions
*/
diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php
index 91d1e0b57aa..43f6931ae91 100644
--- a/htdocs/product/popuprop.php
+++ b/htdocs/product/popuprop.php
@@ -116,7 +116,10 @@ if ($result)
else print img_object($langs->trans("ShowProduct"),"product");
print " ";
print $objp->ref.'';
- print ''.$staticproduct->typeprodser[$objp->fk_product_type].' | ';
+ print '';
+ if ($objp->type==1) print $langs->trans("ShowService");
+ else print $langs->trans("ShowProduct");
+ print ' | ';
print ''.$objp->label.' | ';
print ''.$objp->c.' | ';
print " \n";
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index a8baad23ac3..74eee0bb7ba 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -42,9 +42,6 @@ $user->getrights('produit');
if (!$user->rights->produit->lire)
accessforbidden();
-$types[0] = $langs->trans("Product");
-$types[1] = $langs->trans("Service");
-
$html = new Form($db);
/*
diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php
index 2946a784ee3..a1ce4e55fbd 100644
--- a/htdocs/product/reassort.php
+++ b/htdocs/product/reassort.php
@@ -101,9 +101,11 @@ if ($sall)
{
$sql .= " AND (p.ref like '%".addslashes($sall)."%' OR p.label like '%".addslashes($sall)."%' OR p.description like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%')";
}
-if (strlen($_GET["type"]) || strlen($_POST["type"]))
+if ($type==1)
{
- $sql .= " AND p.fk_product_type = ".(strlen($_GET["type"])?$_GET["type"]:$_POST["type"]);
+ $sql .= " AND p.fk_product_type = '1';
+} else
+ $sql .= " AND p.fk_product_type <> '1';
}
if ($sref)
{
@@ -154,8 +156,7 @@ if ($resql)
if (isset($_GET["type"]) || isset($_POST["type"]))
{
- $type=isset($_GET["type"])?$_GET["type"]:$_POST["type"];
- if ($type) { $texte = $langs->trans("Services"); }
+ if ($type==1) { $texte = $langs->trans("Services"); }
else { $texte = $langs->trans("Products"); }
} else {
$texte = $langs->trans("ProductsAndServices");
@@ -189,7 +190,7 @@ if ($resql)
print_liste_field_titre($langs->trans("Ref"),"reassort.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"),"reassort.php", "p.label","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield);
print_liste_field_titre($langs->trans("StockAvailable"),"reassort.php", "p.stock_dispo","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield);
- if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"),"reassort.php", "p.duration","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="center"',$sortfield);
+ if ($conf->service->enabled && $type == 1) print_liste_field_titre($langs->trans("Duration"),"reassort.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("StockInstant"),"reassort.php", "stock","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield);
print_liste_field_titre($langs->trans("Status"),"reassort.php", "p.envente","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield);
print "\n";
@@ -206,7 +207,7 @@ if ($resql)
print '';
print '';
print ' | ';
- if ($conf->service->enabled && $type != 0)
+ if ($conf->service->enabled && $type == 1)
{
print '';
print ' ';
@@ -265,7 +266,7 @@ if ($resql)
print ''.$objp->ref.' | ';
print ''.$objp->label.' | ';
- if ($conf->service->enabled && $type != 0)
+ if ($conf->service->enabled && $type == 1)
{
print '';
if (eregi('([0-9]+)y',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear");
diff --git a/htdocs/product/sousproduits/fiche.php b/htdocs/product/sousproduits/fiche.php
index 0ca769f6934..ba0f678c987 100644
--- a/htdocs/product/sousproduits/fiche.php
+++ b/htdocs/product/sousproduits/fiche.php
@@ -59,8 +59,6 @@ if ($action <> 're-edit')
if (!$user->rights->produit->lire) accessforbidden();
$html = new Form($db);
-$types[0] = $langs->trans("Product");
-$types[1] = $langs->trans("Service");
// Action association d'un sousproduit
if ($action == 'add_prod' &&
@@ -102,7 +100,8 @@ if ($action == 'add_prod' &&
// action recherche des produits par mot-clé et/ou par catégorie
if($action == 'search' )
{
- $sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type';
+ #$sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type';
+ $sql = 'SELECT p.rowid, p.ref, p.label, p.price';
$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p';
if($conf->categorie->enabled && $catMere != -1)
{
@@ -160,8 +159,8 @@ if ($id || $ref)
print " | ";
$nblignes=6;
- if ($product->type == 0 && $conf->stock->enabled) $nblignes++;
- if ($product->type == 1) $nblignes++;
+ if ($product->isproduct() && $conf->stock->enabled) $nblignes++;
+ if ($product->isservice()) $nblignes++;
// Reference
print '| '.$langs->trans("Ref").' | ';
@@ -220,7 +219,11 @@ if ($id || $ref)
if (($action == 'edit' || $action == 'search' || $action == 're-edit') && $user->rights->produit->creer)
{
- print_fiche_titre($langs->trans('EditAssociate').' '.$types[$product->type].' : '.$product->ref, "");
+ if ($product->isservice()) {
+ print_fiche_titre($langs->trans('EditAssociate').' '.$langs->trans('Service').' : '.$product->ref, "");
+ } else {
+ print_fiche_titre($langs->trans('EditAssociate').' '.$langs->trans('Product').' : '.$product->ref, "");
+ }
if ($mesg) {
print '
'.$mesg.' ';
@@ -231,8 +234,8 @@ if ($id || $ref)
print " | ";
$nblignes=6;
- if ($product->type == 0 && $conf->stock->enabled) $nblignes++;
- if ($product->type == 1) $nblignes++;
+ if ($product->isproduct() && $conf->stock->enabled) $nblignes++;
+ if ($product->isservice()) $nblignes++;
// Reference
print '| '.$langs->trans("Ref").' | ';
@@ -294,6 +297,25 @@ if ($id || $ref)
$objp = $db->fetch_object($resql);
if($objp->rowid != $id)
{
+ // check if a product is not already a parent product of this one
+ $prod_arbo=new Product($db,$objp->rowid);
+ if ($prod_arbo->type==2 || $prod_arbo->type==3) {
+ $is_pere=0;
+ $prod_arbo->get_sousproduits_arbo ();
+ // associations sousproduits
+ $prods_arbo = $prod_arbo->get_arbo_each_prod();
+ if(sizeof($prods_arbo) > 0) {
+ foreach($prods_arbo as $key => $value) {
+ if ($value[1]==$id) {
+ $is_pere=1;
+ }
+ }
+ }
+ if ($is_pere==1) {
+ $i++;
+ continue;
+ }
+ }
print "\n | ";
print '| '.$objp->ref.' | ';
print ''.$objp->label.' | ';
diff --git a/htdocs/product/stats/fiche.php b/htdocs/product/stats/fiche.php
index 982a42c43fd..fb7cf539c60 100644
--- a/htdocs/product/stats/fiche.php
+++ b/htdocs/product/stats/fiche.php
@@ -39,9 +39,6 @@ $langs->load("companies");
$langs->load("products");
$langs->load("bills");
-$types[0] = $langs->trans("Product");
-$types[1] = $langs->trans("Service");
-
if ($user->societe_id > 0)
{
$action = '';
@@ -104,7 +101,7 @@ if ($_GET["id"] || $_GET["ref"])
print ' ';
// Stock
- if ($product->type == 0 && $conf->stock->enabled)
+ if ($product->isproduct() && $conf->stock->enabled)
{
print '| '.$langs->trans("Stock").' | ';
if ($product->no_stock)
diff --git a/htdocs/product/stats/index.php b/htdocs/product/stats/index.php
index 021c4cbd871..aefbab6903f 100644
--- a/htdocs/product/stats/index.php
+++ b/htdocs/product/stats/index.php
@@ -47,7 +47,7 @@ if ($conf->categorie->enabled && !$user->rights->categorie->voir)
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
-$sql .= " WHERE p.fk_product_type = 0";
+$sql .= " WHERE p.fk_product_type <> 1";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= ' AND IFNULL(c.visible,1)=1';
@@ -65,7 +65,7 @@ if ($conf->categorie->enabled && !$user->rights->categorie->voir)
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
-$sql .= " WHERE p.envente = 0 AND p.fk_product_type = 0";
+$sql .= " WHERE p.envente = 0 AND p.fk_product_type <> '1'";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= ' AND IFNULL(c.visible,1)=1';
@@ -111,7 +111,7 @@ if ($conf->service->enabled)
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
- $sql .= " WHERE p.fk_product_type = 1";
+ $sql .= " WHERE p.fk_product_type = '1'";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= ' AND IFNULL(c.visible,1)=1';
@@ -129,7 +129,7 @@ if ($conf->service->enabled)
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
- $sql .= " WHERE p.envente = 0 AND p.fk_product_type = 1";
+ $sql .= " WHERE p.envente = 0 AND p.fk_product_type = '1'";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= ' AND IFNULL(c.visible,1)=1';
diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php
index 31ac227e925..10189f53297 100644
--- a/htdocs/product/stock/product.php
+++ b/htdocs/product/stock/product.php
@@ -47,10 +47,6 @@ if (! $user->rights->produit->lire || ! $product->type == 0 || ! $conf->stock->e
}
-$types[0] = $langs->trans("Product");
-$types[1] = $langs->trans("Service");
-
-
if ($_POST["action"] == "create_stock")
{
$product = new Product($db);
@@ -231,7 +227,9 @@ if ($_GET["id"] || $_GET["ref"])
print '';
print '';
print '';
- print ''.$langs->trans("NumberOfUnit").' | | ';
+ print ''.$langs->trans("NumberOfUnit").' | | ';
+
+ print '';
print '| ';
print ' | ';
print ' ';
diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php
index 7d5ada34a15..39d67870ac2 100644
--- a/htdocs/product/traduction.php
+++ b/htdocs/product/traduction.php
@@ -40,9 +40,6 @@ $user->getrights('produit');
if (!$user->rights->produit->lire)
accessforbidden();
-$types[0] = $langs->trans("Product");
-$types[1] = $langs->trans("Service");
-
/*
* Actions
*/
|