Fix: Fetching category on label is not enough. We must introduce type
This commit is contained in:
parent
b476153b8b
commit
b410aa57b9
@ -167,9 +167,10 @@ class Categorie extends CommonObject
|
||||
*
|
||||
* @param int $id Id of category
|
||||
* @param string $label Label of category
|
||||
* @param string $type Type of category
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id,$label='')
|
||||
function fetch($id,$label='',$type='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -182,10 +183,10 @@ class Categorie extends CommonObject
|
||||
{
|
||||
$sql.= " WHERE rowid = '".$id."'";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ($label) $sql.= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category',1).")";
|
||||
$sql.= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category',1).")";
|
||||
if ($type) $sql.= " AND type = '".$this->db->escape($type)."'";
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
@ -255,9 +256,9 @@ class Categorie extends CommonObject
|
||||
|
||||
if ($this->already_exists())
|
||||
{
|
||||
$this->error=$langs->trans("ImpossibleAddCat");
|
||||
$this->error=$langs->trans("ImpossibleAddCat", $this->label);
|
||||
$this->error.=" : ".$langs->trans("CategoryExistsAtSameLevel");
|
||||
dol_syslog($this->error, LOG_ERR);
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -4;
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ ErrForgotCat=You forgot to choose the tag/category
|
||||
ErrForgotField=You forgot to inform the fields
|
||||
ErrCatAlreadyExists=This name is already used
|
||||
AddProductToCat=Add this product to a tag/category?
|
||||
ImpossibleAddCat=Impossible to add the tag/category
|
||||
ImpossibleAddCat=Impossible to add the tag/category %s
|
||||
ImpossibleAssociateCategory=Impossible to associate the tag/category to
|
||||
WasAddedSuccessfully=<b>%s</b> was added successfully.
|
||||
ObjectAlreadyLinkedToCategory=Element is already linked to this tag/category.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user