diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index ee0bf083dc1..c5ead2e504d 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -1,7 +1,7 @@ * Copyright (C) 2005 Brice Davoleau - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent @@ -32,50 +32,47 @@ require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); $langs->load("categories"); $langs->load("products"); -$socid=GETPOST('socid'); -$id=GETPOST('id'); -$ref=GETPOST('ref'); -$mesg=GETPOST('mesg'); +$socid = GETPOST('socid'); +$id = GETPOST('id'); +$ref = GETPOST('ref'); +$type = GETPOST('type'); +$mesg = GETPOST('mesg'); $dbtablename = ''; // For categories on third parties -if (! empty($_REQUEST["socid"])) { - $_REQUEST["id"]=$_REQUEST["socid"]; - $id=$socid; -} -if (! isset($_REQUEST["type"])) $_REQUEST["type"]=0; -if ($_REQUEST["type"] == 1) $socid=$id; -if ($_REQUEST["type"] == 2) $socid=$id; +if (! empty($socid)) $id = $socid; +if (! isset($type)) $type = 0; +if ($type == 1 || $type == 2) $socid = $id; -if ($_REQUEST["id"] || $_REQUEST["ref"]) +if ($id || $ref) { - if ($_REQUEST["type"] == 0) { - $type = 'product'; + if ($type == 0) { + $elementtype = 'product'; $objecttype = 'produit|service&categorie'; - $objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["ref"])?$_REQUEST["ref"]:''); + $objectid = isset($id)?$id:(isset($ref)?$ref:''); $dbtablename = 'product'; - $fieldid = isset($_REQUEST["ref"])?'ref':'rowid'; + $fieldid = isset($ref)?'ref':'rowid'; } - if ($_REQUEST["type"] == 1) { - $type = 'fournisseur'; + if ($type == 1) { + $elementtype = 'fournisseur'; $objecttype = 'societe&categorie'; - $objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["socid"])?$_REQUEST["socid"]:''); + $objectid = isset($id)?$id:(isset($socid)?$socid:''); $fieldid = 'rowid'; } - if ($_REQUEST["type"] == 2) { - $type = 'societe'; + if ($type == 2) { + $elementtype = 'societe'; $objecttype = 'societe&categorie'; - $objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["socid"])?$_REQUEST["socid"]:''); + $objectid = isset($id)?$id:(isset($socid)?$socid:''); $fieldid = 'rowid'; } - if ($_REQUEST["type"] == 3) { - $type = 'member'; + if ($type == 3) { + $elementtype = 'member'; $objecttype = 'adherent&categorie'; - $objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["ref"])?$_REQUEST["ref"]:''); + $objectid = isset($id)?$id:(isset($ref)?$ref:''); $dbtablename = 'adherent'; - $fieldid = isset($_REQUEST["ref"])?'ref':'rowid'; + $fieldid = isset($ref)?'ref':'rowid'; } } @@ -91,25 +88,24 @@ $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid //Suppression d'un objet d'une categorie if ($_REQUEST["removecat"]) { - if ($_REQUEST["type"]==0 && ($user->rights->produit->creer || $user->rights->service->creer)) + if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); $object = new Product($db); - if ($_REQUEST["ref"]) $result = $object->fetch('',$_REQUEST["ref"]); - if ($_REQUEST["id"]) $result = $object->fetch($_REQUEST["id"]); - $type = 'product'; + $result = $object->fetch($id, $ref); + $elementtype = 'product'; } - if ($_REQUEST["type"]==1 && $user->rights->societe->creer) + if ($type==1 && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); } - if ($_REQUEST["type"]==2 && $user->rights->societe->creer) + if ($type==2 && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); } - if ($_REQUEST["type"] == 3 && $user->rights->adherent->creer) + if ($type == 3 && $user->rights->adherent->creer) { require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); $object = new Adherent($db); @@ -118,46 +114,42 @@ if ($_REQUEST["removecat"]) $cat = new Categorie($db); $result=$cat->fetch($_REQUEST["removecat"]); - $result=$cat->del_type($object,$type); + $result=$cat->del_type($object,$elementtype); } // Add object into a category if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) { - $_GET["id"]=$_REQUEST["id"]; - $_GET["type"]=$_REQUEST["type"]; - - if ($_REQUEST["type"]==0 && ($user->rights->produit->creer || $user->rights->service->creer)) + if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); $object = new Product($db); - if ($_REQUEST["ref"]) $result = $object->fetch('',$_REQUEST["ref"]); - if ($_REQUEST["id"]) $result = $object->fetch($_REQUEST["id"]); - $type = 'product'; + $result = $object->fetch($id, $ref); + $elementtype = 'product'; } - if ($_REQUEST["type"]==1 && $user->rights->societe->creer) + if ($type==1 && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); - $type = 'fournisseur'; + $elementtype = 'fournisseur'; } - if ($_REQUEST["type"]==2 && $user->rights->societe->creer) + if ($type==2 && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); - $type = 'societe'; + $elementtype = 'societe'; } - if ($_REQUEST["type"]==3 && $user->rights->adherent->creer) + if ($type==3 && $user->rights->adherent->creer) { require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); $object = new Adherent($db); $result = $object->fetch($objectid); - $type = 'member'; + $elementtype = 'member'; } $cat = new Categorie($db); $result=$cat->fetch($_REQUEST["catMere"]); - $result=$cat->add_type($object,$type); + $result=$cat->add_type($object,$elementtype); if ($result >= 0) { $mesg='
'.$langs->trans("WasAddedSuccessfully",$cat->label).'
'; @@ -202,7 +194,7 @@ if ($socid) print ''; print ''; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field @@ -234,14 +226,15 @@ if ($socid) } // Address - print ""; + print ''; // Zip / Town print '"; print '"; // Country - if ($soc->pays) { + if ($soc->pays) + { print '
'.$langs->trans("ThirdPartyName").''; - print $html->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom'); + print $html->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom','','&type='.$type); print '
".$langs->trans('Address')."".nl2br($soc->address)."
'.$langs->trans('Address').''.nl2br($soc->address).'
'.$langs->trans('Zip').''.$soc->cp."'.$langs->trans('Town').''.$soc->ville."
'.$langs->trans('Country').''; $img=picto_from_langcode($soc->pays_code); print ($img?$img.' ':''); @@ -282,9 +275,9 @@ if ($socid) if ($soc->fournisseur) formCategory($db,$soc,1); } -else if ($_GET["id"] || $_GET["ref"]) +else if ($id || $ref) { - if ($_GET["type"] == 0) + if ($type == 0) { $langs->load("products"); @@ -296,8 +289,7 @@ else if ($_GET["id"] || $_GET["ref"]) // Produit $product = new Product($db); - if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); - if ($_GET["id"]) $result = $product->fetch($_GET["id"]); + $result = $product->fetch($id, $ref); llxHeader("","",$langs->trans("CardProduct".$product->type)); @@ -340,7 +332,7 @@ else if ($_GET["id"] || $_GET["ref"]) formCategory($db,$product,0); } - if ($_GET["type"] == 3) + if ($type == 3) { $langs->load("members"); @@ -353,8 +345,7 @@ else if ($_GET["id"] || $_GET["ref"]) // Produit $member = new Adherent($db); - if ($_GET["ref"]) $result = $member->fetch('',$_GET["ref"]); - if ($_GET["id"]) $result = $member->fetch($_GET["id"]); + $result = $member->fetch($id, $ref); $membert = new AdherentType($db); $membert->fetch($member->typeid);