diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index c0f92cc9288..b2e8bad1f03 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -1084,21 +1084,28 @@ class Categorie
*/
function get_all_ways ()
{
- $ways = array ();
+ $ways = array();
- foreach ($this->get_meres() as $mere)
+ $parents=$this->get_meres();
+ if (! empty($parents))
{
- foreach ($mere->get_all_ways() as $way)
+ foreach ($parents as $parent)
{
- $w = $way;
- $w[] = $this;
-
- $ways[] = $w;
+ $allways=$parent->get_all_ways();
+ if (! empty($allways))
+ {
+ foreach ($allways as $way)
+ {
+ $w = $way;
+ $w[] = $this;
+ $ways[] = $w;
+ }
+ }
}
- }
- if (count($ways) == 0)
- $ways[0][0] = $this;
+ if (count($ways) == 0)
+ $ways[0][0] = $this;
+ }
return $ways;
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 1811aa0575f..35e158231e4 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2055,7 +2055,7 @@ abstract class CommonObject
$error=0;
- if (count($this->array_options) > 0)
+ if (! empty($this->array_options))
{
// Check parameters
$langs->load('admin');
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 88ee6d23682..68b26800d75 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -700,7 +700,7 @@ class Product extends CommonObject
}
if (!$this->db->query($sql2)) return -1;
}
- else
+ else if (isset($this->multilangs["$key"]))
{
if ($this->db->num_rows($result)) // si aucune ligne dans la base
{
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 58a62e9496b..b7694adb377 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -34,23 +34,24 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
-if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
-if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
-if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
+if (! empty($conf->propal->enabled)) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
+if (! empty($conf->facture->enabled)) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
+if (! empty($conf->commande->enabled)) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
$langs->load("products");
$langs->load("other");
-if ($conf->stock->enabled) $langs->load("stocks");
-if ($conf->facture->enabled) $langs->load("bills");
+if (! empty($conf->stock->enabled)) $langs->load("stocks");
+if (! empty($conf->facture->enabled)) $langs->load("bills");
-$mesg=''; $error=0; $errors=array();
+$mesg=''; $error=0; $errors=array(); $_error=0;
-$id = GETPOST('id', 'int');
-$ref = GETPOST('ref', 'alpha');
+$id=GETPOST('id', 'int');
+$ref=GETPOST('ref', 'alpha');
+$type=GETPOST('type','int');
$action=(GETPOST('action','alpha') ? GETPOST('action','alpha') : 'view');
$confirm=GETPOST('confirm','alpha');
$socid=GETPOST('socid','int');
-if ($user->societe_id) $socid=$user->societe_id;
+if (! empty($user->societe_id)) $socid=$user->societe_id;
$object = new Product($db);
$extrafields = new ExtraFields($db);
@@ -58,6 +59,7 @@ $extrafields = new ExtraFields($db);
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$object->getCanvas($id,$ref);
$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
+$objcanvas='';
if (! empty($canvas))
{
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
@@ -91,7 +93,7 @@ if (empty($reshook))
if ($action == 'setfk_product_type' && $user->rights->produit->creer)
{
$object->fetch($id);
- $result = $object->setValueFrom('fk_product_type', $_POST['fk_product_type']);
+ $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type'));
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
@@ -100,7 +102,7 @@ if (empty($reshook))
if ($action == 'setfk_barcode_type' && $user->rights->barcode->creer)
{
$object->fetch($id);
- $result = $object->setValueFrom('fk_barcode_type', $_POST['fk_barcode_type']);
+ $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type'));
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
@@ -110,7 +112,7 @@ if (empty($reshook))
{
$object->fetch($id);
//Todo: ajout verification de la validite du code barre en fonction du type
- $result = $object->setValueFrom('barcode', $_POST['barcode']);
+ $result = $object->setValueFrom('barcode', GETPOST('barcode'));
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
@@ -118,7 +120,7 @@ if (empty($reshook))
if ($action == 'setaccountancy_code_buy')
{
$object->fetch($id,$ref);
- $result = $object->setValueFrom('accountancy_code_buy', $_POST['accountancy_code_buy']);
+ $result = $object->setValueFrom('accountancy_code_buy', GETPOST('accountancy_code_buy'));
if ($result < 0)
{
$mesg=join(',',$object->errors);
@@ -129,7 +131,7 @@ if (empty($reshook))
if ($action == 'setaccountancy_code_sell')
{
$object->fetch($id,$ref);
- $result = $object->setValueFrom('accountancy_code_sell', $_POST['accountancy_code_sell']);
+ $result = $object->setValueFrom('accountancy_code_sell', GETPOST('accountancy_code_sell'));
if ($result < 0)
{
$mesg=join(',',$object->errors);
@@ -142,63 +144,59 @@ if (empty($reshook))
{
$error=0;
- if (empty($_POST["libelle"]))
+ if (GETPOST('libelle'))
{
$mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')).'
';
$action = "create";
- $_GET["canvas"] = $_POST["canvas"];
- $_GET["type"] = $_POST["type"];
$error++;
}
if (empty($ref))
{
$mesg=''.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'
';
$action = "create";
- $_GET["canvas"] = $_POST["canvas"];
- $_GET["type"] = $_POST["type"];
$error++;
}
if (! $error)
{
$object->ref = $ref;
- $object->libelle = $_POST["libelle"];
- $object->price_base_type = $_POST["price_base_type"];
- if ($object->price_base_type == 'TTC') $object->price_ttc = $_POST["price"];
- else $object->price = $_POST["price"];
- if ($object->price_base_type == 'TTC') $object->price_min_ttc = $_POST["price_min"];
- else $object->price_min = $_POST["price_min"];
- $object->tva_tx = str_replace('*','',$_POST['tva_tx']);
- $object->tva_npr = preg_match('/\*/',$_POST['tva_tx'])?1:0;
+ $object->libelle = GETPOST('libelle');
+ $object->price_base_type = GETPOST('price_base_type');
+ if ($object->price_base_type == 'TTC') $object->price_ttc = GETPOST('price');
+ else $object->price = GETPOST('price');
+ if ($object->price_base_type == 'TTC') $object->price_min_ttc = GETPOST('price_min');
+ else $object->price_min = GETPOST('price_min');
+ $object->tva_tx = str_replace('*','',GETPOST('tva_tx'));
+ $object->tva_npr = preg_match('/\*/',GETPOST('tva_tx'))?1:0;
// local taxes.
$object->localtax1_tx = get_localtax($object->tva_tx,1);
$object->localtax2_tx = get_localtax($object->tva_tx,2);
- $object->type = $_POST["type"];
- $object->status = $_POST["statut"];
- $object->status_buy = $_POST["statut_buy"];
- $object->description = dol_htmlcleanlastbr($_POST["desc"]);
- $object->note = dol_htmlcleanlastbr($_POST["note"]);
- $object->customcode = $_POST["customcode"];
- $object->country_id = $_POST["country_id"];
- $object->duration_value = $_POST["duration_value"];
- $object->duration_unit = $_POST["duration_unit"];
- $object->seuil_stock_alerte = $_POST["seuil_stock_alerte"]?$_POST["seuil_stock_alerte"]:0;
- $object->canvas = $_POST["canvas"];
- $object->weight = $_POST["weight"];
- $object->weight_units = $_POST["weight_units"];
- $object->length = $_POST["size"];
- $object->length_units = $_POST["size_units"];
- $object->surface = $_POST["surface"];
- $object->surface_units = $_POST["surface_units"];
- $object->volume = $_POST["volume"];
- $object->volume_units = $_POST["volume_units"];
- $object->finished = $_POST["finished"];
- $object->hidden = $_POST["hidden"]=='yes'?1:0;
+ $object->type = $type;
+ $object->status = GETPOST('statut');
+ $object->status_buy = GETPOST('statut_buy');
+ $object->description = dol_htmlcleanlastbr(GETPOST('desc'));
+ $object->note = dol_htmlcleanlastbr(GETPOST('note'));
+ $object->customcode = GETPOST('customcode');
+ $object->country_id = GETPOST('country_id');
+ $object->duration_value = GETPOST('duration_value');
+ $object->duration_unit = GETPOST('duration_unit');
+ $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0;
+ $object->canvas = GETPOST('canvas');
+ $object->weight = GETPOST('weight');
+ $object->weight_units = GETPOST('weight_units');
+ $object->length = GETPOST('size');
+ $object->length_units = GETPOST('size_units');
+ $object->surface = GETPOST('surface');
+ $object->surface_units = GETPOST('surface_units');
+ $object->volume = GETPOST('volume');
+ $object->volume_units = GETPOST('volume_units');
+ $object->finished = GETPOST('finished');
+ $object->hidden = GETPOST('hidden')=='yes'?1:0;
// MultiPrix
- if($conf->global->PRODUIT_MULTIPRICES)
+ if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
{
@@ -234,7 +232,6 @@ if (empty($reshook))
{
$mesg=''.$langs->trans($object->error).'
';
$action = "create";
- $_GET["type"] = $_POST["type"];
}
}
}
@@ -242,7 +239,7 @@ if (empty($reshook))
// Update a product or service
if ($action == 'update' && ($user->rights->produit->creer || $user->rights->service->creer))
{
- if (! empty($_POST["cancel"]))
+ if (GETPOST('cancel'))
{
$action = '';
}
@@ -253,27 +250,27 @@ if (empty($reshook))
$object->oldcopy=dol_clone($object);
$object->ref = $ref;
- $object->libelle = $_POST["libelle"];
- $object->description = dol_htmlcleanlastbr($_POST["desc"]);
- $object->note = dol_htmlcleanlastbr($_POST["note"]);
- $object->customcode = $_POST["customcode"];
- $object->country_id = $_POST["country_id"];
- $object->status = $_POST["statut"];
- $object->status_buy = $_POST["statut_buy"];
- $object->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
- $object->duration_value = $_POST["duration_value"];
- $object->duration_unit = $_POST["duration_unit"];
- $object->canvas = $_POST["canvas"];
- $object->weight = $_POST["weight"];
- $object->weight_units = $_POST["weight_units"];
- $object->length = $_POST["size"];
- $object->length_units = $_POST["size_units"];
- $object->surface = $_POST["surface"];
- $object->surface_units = $_POST["surface_units"];
- $object->volume = $_POST["volume"];
- $object->volume_units = $_POST["volume_units"];
- $object->finished = $_POST["finished"];
- $object->hidden = $_POST["hidden"]=='yes'?1:0;
+ $object->libelle = GETPOST('libelle');
+ $object->description = dol_htmlcleanlastbr(GETPOST('desc'));
+ $object->note = dol_htmlcleanlastbr(GETPOST('note'));
+ $object->customcode = GETPOST('customcode');
+ $object->country_id = GETPOST('country_id');
+ $object->status = GETPOST('statut');
+ $object->status_buy = GETPOST('statut_buy');
+ $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte');
+ $object->duration_value = GETPOST('duration_value');
+ $object->duration_unit = GETPOST('duration_unit');
+ $object->canvas = GETPOST('canvas');
+ $object->weight = GETPOST('weight');
+ $object->weight_units = GETPOST('weight_units');
+ $object->length = GETPOST('size');
+ $object->length_units = GETPOST('size_units');
+ $object->surface = GETPOST('surface');
+ $object->surface_units = GETPOST('surface_units');
+ $object->volume = GETPOST('volume');
+ $object->volume_units = GETPOST('volume_units');
+ $object->finished = GETPOST('finished');
+ $object->hidden = GETPOST('hidden')=='yes'?1:0;
// Get extra fields
foreach($_POST as $key => $value)
@@ -348,7 +345,7 @@ if (empty($reshook))
{
$db->rollback();
- $_error = 1;
+ $_error++;
$action = "";
$mesg=''.$langs->trans("ErrorProductAlreadyExists",$object->ref);
@@ -403,7 +400,7 @@ if (empty($reshook))
if ($action == 'addinpropal')
{
$propal = new Propal($db);
- $result=$propal->fetch($_POST["propalid"]);
+ $result=$propal->fetch(GETPOST('propalid'));
if ($result <= 0)
{
dol_print_error($db,$propal->error);
@@ -462,12 +459,12 @@ if (empty($reshook))
$propal->id,
$desc,
$pu_ht,
- $_POST["qty"],
+ GETPOST('qty'),
$tva_tx,
$localtax1_tx, // localtax1
$localtax2_tx, // localtax2
$prod->id,
- $_POST["remise_percent"],
+ GETPOST('remise_percent'),
$price_base_type,
$pu_ttc
);
@@ -484,7 +481,7 @@ if (empty($reshook))
if ($action == 'addincommande')
{
$commande = new Commande($db);
- $result=$commande->fetch($_POST["commandeid"]);
+ $result=$commande->fetch(GETPOST('commandeid'));
if ($result <= 0)
{
dol_print_error($db,$commande->error);
@@ -544,12 +541,12 @@ if (empty($reshook))
$commande->id,
$desc,
$pu_ht,
- $_POST["qty"],
+ GETPOST('qty'),
$tva_tx,
$localtax1_tx, // localtax1
$localtax2_tx, // localtax2
$prod->id,
- $_POST["remise_percent"],
+ GETPOST('remise_percent'),
'',
'', // TODO voir si fk_remise_except est encore valable car n'apparait plus dans les propales
$price_base_type,
@@ -567,7 +564,7 @@ if (empty($reshook))
if ($action == 'addinfacture' && $user->rights->facture->creer)
{
$facture = New Facture($db);
- $result=$facture->fetch($_POST["factureid"]);
+ $result=$facture->fetch(GETPOST('factureid'));
if ($result <= 0)
{
dol_print_error($db,$facture->error);
@@ -626,12 +623,12 @@ if (empty($reshook))
$facture->id,
$desc,
$pu_ht,
- $_POST["qty"],
+ GETPOST('qty'),
$tva_tx,
$localtax1_tx,
$localtax2_tx,
$prod->id,
- $_POST["remise_percent"],
+ GETPOST('remise_percent'),
'',
'',
'',
@@ -697,9 +694,9 @@ else
print '