Fix: missing type of category

This commit is contained in:
Regis Houssin 2012-03-20 12:26:02 +01:00
parent dea518875d
commit 82cff13b66
2 changed files with 20 additions and 17 deletions

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
@ -38,6 +38,8 @@ $ref = GETPOST('ref');
$type = GETPOST('type');
$mesg = GETPOST('mesg');
$removecat = GETPOST('removecat','int');
$dbtablename = '';
@ -87,7 +89,7 @@ $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid
*/
//Suppression d'un objet d'une categorie
if ($_REQUEST["removecat"])
if ($removecat > 0)
{
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{
@ -113,7 +115,7 @@ if ($_REQUEST["removecat"])
$result = $object->fetch($objectid);
}
$cat = new Categorie($db);
$result=$cat->fetch($_REQUEST["removecat"]);
$result=$cat->fetch($removecat);
$result=$cat->del_type($object,$elementtype);
}
@ -270,11 +272,11 @@ if ($socid)
dol_htmloutput_mesg($mesg);
if ($soc->client) formCategory($db,$soc,2);
if ($soc->client) formCategory($db,$soc,2,$socid);
if ($soc->client && $soc->fournisseur) print '<br><br>';
if ($soc->fournisseur) formCategory($db,$soc,1);
if ($soc->fournisseur) formCategory($db,$soc,1,$socid);
}
else if ($id || $ref)
{
@ -424,7 +426,7 @@ else if ($id || $ref)
* @param int $typeid Type of category (0, 1, 2, 3)
* @return int 0
*/
function formCategory($db,$object,$typeid)
function formCategory($db,$object,$typeid,$socid=0)
{
global $user,$langs,$form,$bc;
@ -499,7 +501,7 @@ function formCategory($db,$object,$typeid)
if ($typeid == 3) $permission=$user->rights->adherent->creer;
if ($permission)
{
print "<a href= '".DOL_URL_ROOT."/categories/categorie.php?".(empty($_REQUEST["socid"])?'id':'socid')."=".$object->id.(empty($_REQUEST["socid"])?"&amp;type=".$typeid."&amp;typeid=".$typeid:'')."&amp;removecat=".$cat->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removecat=".$cat->id."'>";
print img_delete($langs->trans("DeleteFromCat")).' ';
print $langs->trans("DeleteFromCat")."</a>";
}
@ -530,7 +532,7 @@ function formCategory($db,$object,$typeid)
return 0;
}
$db->close();
llxFooter();
?>
$db->close();
?>

View File

@ -3,7 +3,7 @@
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -29,12 +29,13 @@ require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/treeview.lib.php");
$type=(GETPOST('type') ? GETPOST('type') : 0);
if (!$user->rights->categorie->lire) accessforbidden();
$langs->load("categories");
if (! $user->rights->categorie->lire) accessforbidden();
$id=GETPOST('id','int');
$type=(GETPOST('type') ? GETPOST('type') : 0);
/*
* View
@ -88,9 +89,9 @@ print '</td><td valign="top" width="70%">';
/*
* Categories found
*/
if($_POST['catname'] || $_REQUEST['id'])
if($_POST['catname'] || $id > 0)
{
$cats = $categstatic->rechercher($_REQUEST['id'],$_POST['catname'],$_POST['type']);
$cats = $categstatic->rechercher($id,$_POST['catname'],$type);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("FoundCats").'</td></tr>';
@ -309,7 +310,7 @@ if ($nbofentries == 0)
print "</table>";
$db->close();
llxFooter();
$db->close();
?>