Fix: bug sur la cration des catgories
This commit is contained in:
parent
ccdc535d21
commit
10bcacc831
@ -326,7 +326,7 @@ class Categorie
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajout d'un produit à la catégorie
|
||||
* Ajout d'un objet à la catégorie
|
||||
* retour : 1 : OK
|
||||
* -1 : erreur SQL
|
||||
* -2 : id non renseign
|
||||
@ -338,7 +338,7 @@ class Categorie
|
||||
return -2;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".$type.")";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".($type=='fournisseur'?'societe':$type).")";
|
||||
$sql .= " VALUES (".$this->id.", ".$obj->id.")";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
@ -362,7 +362,7 @@ class Categorie
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$type;
|
||||
$sql .= " WHERE fk_categorie = ".$this->id;
|
||||
$sql .= " AND fk_".$type." = ".$obj->id;
|
||||
$sql .= " AND fk_".($type=='fournisseur'?'societe':$type)." = ".$obj->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
@ -868,7 +868,7 @@ class Categorie
|
||||
$sql = "SELECT ct.fk_categorie";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON ct.fk_categorie = c.rowid";
|
||||
$sql.= " WHERE ct.fk_".$type." = ".$id." AND c.type = ".$typeid;
|
||||
$sql.= " WHERE ct.fk_".($type=='fournisseur'?'societe':$type)." = ".$id." AND c.type = ".$typeid;
|
||||
|
||||
$res = $this->db->query ($sql);
|
||||
if ($res)
|
||||
|
||||
@ -34,11 +34,14 @@ require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
|
||||
|
||||
$langs->load("categories");
|
||||
|
||||
$user->getrights();
|
||||
|
||||
$mesg=isset($_GET["mesg"])?'<div class="ok">'.$_GET["mesg"].'</div>':'';
|
||||
|
||||
if ($_REQUEST["socid"])
|
||||
{
|
||||
$type = 'societe';
|
||||
if ($_REQUEST["typeid"] == 1) $type = 'fournisseur';
|
||||
if ($_REQUEST["typeid"] == 2) $type = 'societe';
|
||||
$objectid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
|
||||
}
|
||||
else if ($_REQUEST["id"] || $_REQUEST["ref"])
|
||||
@ -186,11 +189,11 @@ if ($_GET["socid"])
|
||||
|
||||
if ($mesg) print($mesg);
|
||||
|
||||
if ($soc->client) formCategory($db,$soc,$type,2);
|
||||
if ($soc->client) formCategory($db,$soc,'societe',2);
|
||||
|
||||
if ($soc->client && $soc->fournisseur) print '<br><br>';
|
||||
|
||||
if ($soc->fournisseur) formCategory($db,$soc,$type,1);
|
||||
if ($soc->fournisseur) formCategory($db,$soc,'fournisseur',1);
|
||||
}
|
||||
else if ($_GET["id"] || $_GET["ref"])
|
||||
{
|
||||
@ -262,11 +265,11 @@ function formCategory($db,$object,$type,$typeid)
|
||||
if ($typeid == 0) $title = $langs->trans("ProductsCategoriesShort");
|
||||
if ($typeid == 1) $title = $langs->trans("SuppliersCategoriesShort");
|
||||
if ($typeid == 2) $title = $langs->trans("CustomersCategoriesShort");
|
||||
if ($type == 'societe')
|
||||
if ($type == 'societe' || $type == 'fournisseur')
|
||||
{
|
||||
$nameId = 'socid';
|
||||
}
|
||||
else
|
||||
else if ($type == 'product')
|
||||
{
|
||||
$nameId = 'id';
|
||||
}
|
||||
@ -277,6 +280,7 @@ function formCategory($db,$object,$type,$typeid)
|
||||
print '<br>';
|
||||
print_fiche_titre($title);
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/categories/categorie.php?'.$nameId.'='.$object->id.'">';
|
||||
print '<input type="hidden" name="typeid" value="'.$typeid.'">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>';
|
||||
print $langs->trans("ClassifyInCategory").' ';
|
||||
@ -318,9 +322,10 @@ function formCategory($db,$object,$type,$typeid)
|
||||
|
||||
// Lien supprimer
|
||||
print '<td align="right">';
|
||||
if ($user->rights->$type->creer)
|
||||
$module = ($type=='fournisseur'?'societe':$type);
|
||||
if ($user->rights->$module->creer)
|
||||
{
|
||||
print "<a href= '".DOL_URL_ROOT."/categories/categorie.php?".$nameId."=".$object->id."&removecat=".$cat->id."'>";
|
||||
print "<a href= '".DOL_URL_ROOT."/categories/categorie.php?".$nameId."=".$object->id."&typeid=".$typeid."&removecat=".$cat->id."'>";
|
||||
print img_delete($langs->trans("DeleteFromCat")).' ';
|
||||
print $langs->trans("DeleteFromCat")."</a>";
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ if ($search_ville)
|
||||
}
|
||||
$sql .= " AND ca.year > (date_format(now(),'%Y') - 5)";
|
||||
|
||||
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
|
||||
$sql .= " ORDER BY ".$sortfield $sortorder $db->plimit($conf->liste_limit+1, $offset);
|
||||
|
||||
dolibarr_syslog("fourn/stats.php sql=".$sql);
|
||||
$resql = $db->query($sql);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user