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 '
'; print ''; print ''; - print ''."\n"; + print ''."\n"; - if ($_GET["type"]==1) $title=$langs->trans("NewService"); + if ($type==1) $title=$langs->trans("NewService"); else $title=$langs->trans("NewProduct"); print_fiche_titre($title); @@ -708,32 +705,32 @@ else print ''; print ''; print ''; // Label - print ''; + print ''; // On sell print ''; // To buy print ''; // Stock min level - if ($_GET["type"] != 1 && $conf->stock->enabled) + if ($type != 1 && $conf->stock->enabled) { print ''; } else @@ -745,24 +742,24 @@ else print '"; // Nature - if ($_GET["type"] != 1) + if ($type != 1) { print ''; } // Duration - if ($_GET["type"] == 1) + if ($type == 1) { - print ''; } - if ($_GET["type"] != 1) // Le poids et le volume ne concerne que les produits et pas les services + if ($type != 1) // Le poids et le volume ne concerne que les produits et pas les services { // Weight print ''; // Length print ''; // Surface print ''; // Volume print ''; } // Customs code - print ''; + print ''; // Origin country print ''; @@ -811,7 +808,7 @@ else { foreach($extrafields->attribute_label as $key=>$label) { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + $value=(GETPOST('options_'.$key)?GETPOST('options_'.$key):$object->array_options["options_".$key]); print ''."\n"; @@ -821,7 +818,7 @@ else // Note (private, no output on invoices, propales...) print '"; diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 11c9b8eb456..2c2a0a5b469 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -27,7 +27,8 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php'); require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.product.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); -if ($conf->categorie->enabled) require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); +if (! empty($conf->categorie->enabled)) + require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); $langs->load("products"); $langs->load("stocks"); @@ -43,6 +44,7 @@ $search_categ = GETPOST("search_categ",'int'); $tosell = GETPOST("tosell"); $tobuy = GETPOST("tobuy"); $fourn_id = GETPOST("fourn_id",'int'); +$catid = GETPOST('catid','int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -59,7 +61,8 @@ $limit = $conf->liste_limit; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) //$object->getCanvas($id); -$canvas = GETPOST("canvas"); +$canvas=GETPOST("canvas"); +$objcanvas=''; if (! empty($canvas)) { require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); @@ -85,12 +88,6 @@ if (isset($_POST["button_removefilter_x"])) $search_categ=0; } -if ($conf->categorie->enabled && GETPOST('catid')) -{ - $catid = GETPOST('catid','int'); -} - - /* * View @@ -108,7 +105,7 @@ else { $title=$langs->trans("ProductsAndServices"); - if (isset($_GET["type"])) + if (isset($type)) { if ($type==1) { @@ -129,7 +126,7 @@ else $sql.= ' p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte,'; $sql.= ' MIN(pfp.unitprice) as minsellprice'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; - if ($search_categ || $catid) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ + if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; if ($sall) $sql.= " AND (p.ref LIKE '%".$db->escape($sall)."%' OR p.label LIKE '%".$db->escape($sall)."%' OR p.description LIKE '%".$db->escape($sall)."%' OR p.note LIKE '%".$db->escape($sall)."%')"; @@ -146,7 +143,7 @@ else if (isset($tobuy) && dol_strlen($tobuy) > 0) $sql.= " AND p.tobuy = ".$db->escape($tobuy); if (dol_strlen($canvas) > 0) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; if ($catid > 0) $sql.= " AND cp.fk_categorie = ".$catid; - if ($catid == -2) $sql.= " AND cp.fk_categorie IS NULL"; + if ($catid == -2) $sql.= " AND cp.fk_categorie IS NULL"; if ($search_categ > 0) $sql.= " AND cp.fk_categorie = ".$search_categ; if ($search_categ == -2) $sql.= " AND cp.fk_categorie IS NULL"; if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id; @@ -173,13 +170,16 @@ else } $helpurl=''; - if (isset($_GET["type"]) && $_GET["type"] == 0) + if (isset($type)) { - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; - } - if (isset($_GET["type"]) && $_GET["type"] == 1) - { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + if ($type == 0) + { + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + } + else if ($type == 1) + { + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + } } llxHeader('',$title,$helpurl,''); @@ -193,16 +193,16 @@ else $param.=isset($type)?"&type=".$type:""; print_barre_liste($texte, $page, "liste.php", $param, $sortfield, $sortorder,'',$num); - if (isset($catid)) + if (! empty($catid)) { print "
"; - $c = new Categorie($db, $catid); + $c = new Categorie($db); $ways = $c->print_all_ways(' > ','product/liste.php'); print " > ".$ways[0]."
\n"; print "

"; } - if (!empty($_GET["canvas"]) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/actions_card_'.$_GET["canvas"].'.class.php')) + if (! empty($canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$canvas.'/actions_card_'.$canvas.'.class.php')) { $fieldlist = $object->field_list; $datas = $object->list_datas; @@ -211,14 +211,14 @@ else $title_text = $title; // Default templates directory - $template_dir = DOL_DOCUMENT_ROOT . '/product/canvas/'.$_GET["canvas"].'/tpl/'; + $template_dir = DOL_DOCUMENT_ROOT . '/product/canvas/'.$canvas.'/tpl/'; // Check if a custom template is present - if (file_exists(DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$_GET["canvas"].'/list.tpl.php')) + if (file_exists(DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/list.tpl.php')) { - $template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$_GET["canvas"].'/'; + $template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/'; } - include($template_dir.'list.tpl.php'); // Include native PHP templates + include($template_dir.'list.tpl.php'); // Include native PHP templates } else { @@ -233,7 +233,7 @@ else // Filter on categories $moreforfilter=''; - if ($conf->categorie->enabled) + if (! empty($conf->categorie->enabled)) { $moreforfilter.=$langs->trans('Categories'). ': '; $moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ',1); @@ -251,12 +251,12 @@ else print "
"; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder); - if ($conf->barcode->enabled) print_liste_field_titre($langs->trans("BarCode"), $_SERVER["PHP_SELF"], "p.barcode",$param,'','',$sortfield,$sortorder); + if (! empty($conf->barcode->enabled)) print_liste_field_titre($langs->trans("BarCode"), $_SERVER["PHP_SELF"], "p.barcode",$param,'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateModification"), $_SERVER["PHP_SELF"], "p.tms",$param,"",'align="center"',$sortfield,$sortorder); - if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); + if (! empty($conf->service->enabled) && $type != 0) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellingPrice"), $_SERVER["PHP_SELF"], "p.price",$param,"",'align="right"',$sortfield,$sortorder); print ''; - if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1) print ''; + if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) print ''; print_liste_field_titre($langs->trans("Sell"), $_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Buy"), $_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder); print "\n"; @@ -269,7 +269,7 @@ else print ''; - if ($conf->barcode->enabled) + if (! empty($conf->barcode->enabled)) { print ''; // Duration - if ($conf->service->enabled && $type != 0) + if (! empty($conf->service->enabled) && $type != 0) { print ''; // Stock - if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1) + if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) { print ''; // Barcode - if ($conf->barcode->enabled) + if (! empty($conf->barcode->enabled)) { print ''; } @@ -368,7 +368,7 @@ else print '\n"; // Duration - if ($conf->service->enabled && $type != 0) + if (! empty($conf->service->enabled) && $type != 0) { print ''; // Show stock - if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1) + if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) { if ($objp->fk_product_type != 1) { @@ -435,7 +435,7 @@ else if ($num > $conf->liste_limit) { - if ($sref || $snom || $sall || $sbarcode || $_POST["search"]) + if ($sref || $snom || $sall || $sbarcode || GETPOST('search')) { print_barre_liste('', $page, "liste.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num); } @@ -458,7 +458,6 @@ else } -$db->close(); - llxFooter(); +$db->close(); ?> diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index af75586dc21..70ca91c4f8c 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2003 Rodolphe Quiedeville * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -27,13 +27,15 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php'); +$type=GETPOST("type","int"); + // Security check -if ($user->societe_id) $socid=$user->societe_id; +if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service'); -$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; -$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; -$page = $_GET["page"]; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); if ($page < 0) $page = 0; if (! $sortfield) $sortfield="c"; if (! $sortorder) $sortorder="DESC"; @@ -51,22 +53,22 @@ $staticproduct=new Product($db); */ $helpurl=''; -if (isset($_GET["type"]) && $_GET["type"] == 0) +if ($type == 0) { $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } -if (isset($_GET["type"]) && $_GET["type"] == 1) +else if ($type == 1) { $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } -llxHeader('',$title,$helpurl,''); +llxHeader('','',$helpurl); //On n'affiche le lien page suivante que s'il y a une page suivante ... $sql = "SELECT count(*) as c"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= ' WHERE entity IN ('.getEntity('product', 1).')'; -if (isset($_GET['type'])) $sql.= " AND fk_product_type = ".$_GET['type']; +if (isset($type)) $sql.= " AND fk_product_type = ".$type; $result=$db->query($sql); if ($result) @@ -77,11 +79,11 @@ if ($result) $param = ''; $title = $langs->trans("ListProductServiceByPopularity"); -if (isset($_GET['type'])) +if (isset($type)) { - $param = '&type='.$_GET['type']; + $param = '&type='.$type; $title = $langs->trans("ListProductByPopularity"); - if ($_GET['type'] == 1) $title = $langs->trans("ListServiceByPopularity"); + if ($type == 1) $title = $langs->trans("ListServiceByPopularity"); } print_barre_liste($title, $page, "popuprop.php",$param,"","","",$num); @@ -101,7 +103,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= " AND p.rowid = pd.fk_product"; -if (isset($_GET['type'])) $sql.= " AND fk_product_type = ".$_GET['type']; +if (isset($type)) $sql.= " AND fk_product_type = ".$type; $sql.= " GROUP BY (p.rowid)"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit, $offset); @@ -109,52 +111,54 @@ $sql.= $db->plimit($limit, $offset); $result=$db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; + $num = $db->num_rows($result); + $i = 0; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); - // Multilangs - if ($conf->global->MAIN_MULTILANGS) // si l'option est active - { - $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$objp->rowid; - $sql.= " AND lang='". $langs->getDefaultLang() ."'"; - $sql.= " LIMIT 1"; + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$objp->rowid; + $sql.= " AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; - $resultp = $db->query($sql); - if ($resultp) - { - $objtp = $db->fetch_object($resultp); - if ($objtp->label != '') $objp->label = $objtp->label; - } - } + $resultp = $db->query($sql); + if ($resultp) + { + $objtp = $db->fetch_object($resultp); + if (! empty($objtp->label)) $objp->label = $objtp->label; + } + } - $var=!$var; - print ""; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $i++; - } - $db->free(); + $var=!$var; + print ""; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $i++; + } + + $db->free(); } + print "
'.$langs->trans("Ref").''; - if ($_error == 1) + if ($_error) { print $langs->trans("RefAlreadyExists"); } print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - print $form->selectarray('statut',$statutarray,$_POST["statut"]); + print $form->selectarray('statut',$statutarray,GETPOST('statut')); print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); - print $form->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]); + print $form->selectarray('statut_buy',$statutarray,GETPOST('statut_buy"')); print '
'.$langs->trans("StockLimit").''; - print ''; + print ''; print '
'.$langs->trans("Description").''; require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor('desc',$_POST["desc"],'',160,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,4,90); + $doleditor=new DolEditor('desc',GETPOST('desc'),'',160,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,4,90); $doleditor->Create(); print "
'.$langs->trans("Nature").''; $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - print $form->selectarray('finished',$statutarray,$_POST["finished"]); + print $form->selectarray('finished',$statutarray,GETPOST('finished')); print '
'.$langs->trans("Duration").'  '; + print '
'.$langs->trans("Duration").'  '; print ''.$langs->trans("Hour").' '; print ''.$langs->trans("Day").' '; print ''.$langs->trans("Week").' '; @@ -771,36 +768,36 @@ else print '
'.$langs->trans("Weight").''; - print ''; + print ''; print $formproduct->select_measuring_units("weight_units","weight"); print '
'.$langs->trans("Length").''; - print ''; + print ''; print $formproduct->select_measuring_units("size_units","size"); print '
'.$langs->trans("Surface").''; - print ''; + print ''; print $formproduct->select_measuring_units("surface_units","surface"); print '
'.$langs->trans("Volume").''; - print ''; + print ''; print $formproduct->select_measuring_units("volume_units","volume"); print '
'.$langs->trans("CustomCode").'
'.$langs->trans("CustomCode").'
'.$langs->trans("CountryOrigin").''; - print $form->select_country($_POST["country_id"],'country_id'); + print $form->select_country(GETPOST('country_id','int'),'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print '
'.$label.''; print $extrafields->showInputField($key,$value); print '
'.$langs->trans("NoteNotVisibleOnBill").''; require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor('note',$_POST["note"],'',180,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70); + $doleditor=new DolEditor('note',GETPOST('note'),'',180,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70); $doleditor->Create(); print "
'.$langs->trans("BuyingPriceMinShort").''.$langs->trans("PhysicalStock").''.$langs->trans("PhysicalStock").'
'; print ''; print ''; print ''; @@ -280,7 +280,7 @@ else print ''; print ' '; @@ -301,7 +301,7 @@ else print ''; print ' '; @@ -328,7 +328,7 @@ else $objp = $db->fetch_object($resql); // Multilangs - if ($conf->global->MAIN_MULTILANGS) // si l'option est active + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; @@ -340,7 +340,7 @@ else if ($result) { $objtp = $db->fetch_object($result); - if ($objtp->label != '') $objp->label = $objtp->label; + if (! empty($objtp->label)) $objp->label = $objtp->label; } } @@ -359,7 +359,7 @@ else print ''.dol_trunc($objp->label,40).''.$objp->barcode.''.dol_print_date($db->jdate($objp->datem),'day')."'; if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); @@ -406,7 +406,7 @@ else print '
'; - if ($objp->type==1) print img_object($langs->trans("ShowService"),"service"); - else print img_object($langs->trans("ShowProduct"),"product"); - print " "; - print $objp->ref.''; - if ($objp->type==1) print $langs->trans("ShowService"); - else print $langs->trans("ShowProduct"); - print ''.$objp->label.''.$objp->c.'
'; + if ($objp->type==1) print img_object($langs->trans("ShowService"),"service"); + else print img_object($langs->trans("ShowProduct"),"product"); + print " "; + print $objp->ref.''; + if ($objp->type==1) print $langs->trans("ShowService"); + else print $langs->trans("ShowProduct"); + print ''.$objp->label.''.$objp->c.'
"; -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 5d77302d953..b3f229c5ffb 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -36,30 +36,41 @@ if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service'); -$sref=isset($_GET["sref"])?$_GET["sref"]:$_POST["sref"]; -$snom=isset($_GET["snom"])?$_GET["snom"]:$_POST["snom"]; -$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"]; -$type=isset($_GET["type"])?$_GET["type"]:$_POST["type"]; -$sref=trim($sref); -$snom=trim($snom); -$sall=trim($sall); -$type=trim($type); +$action=GETPOST('action','alpha'); +$sref=GETPOST("sref"); +$snom=GETPOST("snom"); +$sall=GETPOST("sall"); +$type=GETPOST("type","int"); +$sbarcode=GETPOST("sbarcode"); +$catid=GETPOST('catid','int'); +$toolowstock=GETPOST('toolowstock'); +$tosell = GETPOST("tosell"); +$tobuy = GETPOST("tobuy"); +$fourn_id = GETPOST("fourn_id",'int'); -$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; -$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); if (! $sortfield) $sortfield="stock_physique"; if (! $sortorder) $sortorder="ASC"; -$page = $_GET["page"]; $limit = $conf->liste_limit; $offset = $limit * $page ; -$catid=GETPOST('catid'); -$toolowstock=GETPOST('toolowstock'); - // Load sale and categ filters $search_sale = GETPOST("search_sale"); $search_categ = GETPOST("search_categ"); +// Get object canvas (By default, this is not defined, so standard usage of dolibarr) +//$object->getCanvas($id); +$canvas=GETPOST("canvas"); +$objcanvas=''; +if (! empty($canvas)) +{ + require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); + $objcanvas = new Canvas($db,$action); + $objcanvas->getCanvas('product','list',$canvas); +} + if (! empty($_POST["button_removefilter_x"])) { $sref=""; @@ -118,15 +129,15 @@ if (dol_strlen($type)) if ($sref) $sql.= " AND p.ref LIKE '%".$sref."%'"; if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'"; if ($snom) $sql.= " AND p.label LIKE '%".$db->escape($snom)."%'"; -if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) +if (! empty($tosell)) { - $sql.= " AND p.tosell = ".$_GET["tosell"]; + $sql.= " AND p.tosell = ".$tosell; } -if (isset($_GET["tobuy"]) && dol_strlen($_GET["tobuy"]) > 0) +if (! empty($tobuy)) { - $sql.= " AND p.tobuy = ".$_GET["tobuy"]; + $sql.= " AND p.tobuy = ".$tobuy; } -if (dol_strlen($canvas) > 0) +if (! empty($canvas)) { $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; } @@ -164,21 +175,10 @@ if ($resql) exit; } - if (isset($_GET["tosell"]) || isset($_POST["tosell"])) - { - $tosell = (isset($_GET["tosell"])?$_GET["tosell"]:$_POST["tosell"]); - } - if (isset($_GET["tobuy"]) || isset($_POST["tobuy"])) - { - $tobuy = (isset($_GET["tobuy"])?$_GET["tobuy"]:$_POST["tobuy"]); - } - - - $helpurl=''; $helpurl='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; - if (isset($_GET["type"]) || isset($_POST["type"])) + if (isset($type)) { if ($type==1) { $texte = $langs->trans("Services"); } else { $texte = $langs->trans("Products"); } @@ -190,16 +190,16 @@ if ($resql) llxHeader("",$title,$helpurl,$texte); - if ($sref || $snom || $sall || $_POST["search"]) + if ($sref || $snom || $sall || GETPOST('search')) { - print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$_POST["tosell"]."&tobuy=".$_POST["tobuy"], $sortfield, $sortorder,'',$num); + print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num); } else { print_barre_liste($texte, $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num); } - if ($catid) + if (! empty($catid)) { print "
"; $c = new Categorie($db); @@ -219,7 +219,7 @@ if ($resql) // Filter on categories $moreforfilter=''; - if ($conf->categorie->enabled) + if (! empty($conf->categorie->enabled)) { $moreforfilter.=$langs->trans('Categories'). ': '; $moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ'); @@ -258,7 +258,7 @@ if ($resql) print ''; print ''; print ''; - if ($conf->service->enabled && $type == 1) + if (! empty($conf->service->enabled) && $type == 1) { print ''; print ' '; @@ -282,7 +282,7 @@ if ($resql) $objp = $db->fetch_object($resql); // Multilangs - if ($conf->global->MAIN_MULTILANGS) // si l'option est active + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; @@ -294,7 +294,7 @@ if ($resql) if ($result) { $objtp = $db->fetch_object($result); - if ($objtp->label != '') $objp->label = $objtp->label; + if (! empty($objtp->label)) $objp->label = $objtp->label; } } @@ -308,7 +308,7 @@ if ($resql) print ''; print ''.$objp->label.''; - if ($conf->service->enabled && $type == 1) + if (! empty($conf->service->enabled) && $type == 1) { print ''; if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); @@ -335,7 +335,7 @@ if ($resql) if ($num > $conf->liste_limit) { - if ($sref || $snom || $sall || $_POST["search"]) + if ($sref || $snom || $sall || GETPOST('search')) { print_barre_liste('', $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num, 0, ''); } @@ -354,7 +354,6 @@ else } -$db->close(); - llxFooter(); +$db->close(); ?> \ No newline at end of file