mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 00:52:01 +01:00
FIX getObjectsInCateg must not return corrupted orphelins
This commit is contained in:
@@ -885,7 +885,7 @@ class Categorie extends CommonObject
|
||||
$classnameforobj = $this->MAP_OBJ_CLASS[$type];
|
||||
$obj = new $classnameforobj($this->db);
|
||||
|
||||
$sql = "SELECT c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]);
|
||||
$sql = "SELECT c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." as fk_object";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as c";
|
||||
$sql .= ", ".MAIN_DB_PREFIX.(empty($this->MAP_OBJ_TABLE[$type]) ? $type : $this->MAP_OBJ_TABLE[$type])." as o";
|
||||
$sql .= " WHERE o.entity IN (".getEntity($obj->element).")";
|
||||
@@ -920,14 +920,15 @@ class Categorie extends CommonObject
|
||||
if ($resql) {
|
||||
while ($rec = $this->db->fetch_array($resql)) {
|
||||
if ($onlyids) {
|
||||
$objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])];
|
||||
$objs[] = $rec['fk_object'];
|
||||
} else {
|
||||
$classnameforobj = $this->MAP_OBJ_CLASS[$type];
|
||||
|
||||
$obj = new $classnameforobj($this->db);
|
||||
$obj->fetch($rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]);
|
||||
|
||||
$objs[] = $obj;
|
||||
$obj->fetch($rec['fk_object']);
|
||||
if ($obj->id > 0) {
|
||||
$objs[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $objs;
|
||||
|
||||
@@ -678,6 +678,7 @@ if ($type == Categorie::TYPE_SUPPLIER) {
|
||||
$permission = $user->hasRight('societe', 'creer');
|
||||
|
||||
$socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
|
||||
|
||||
if ($socs < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
} else {
|
||||
@@ -738,7 +739,7 @@ if ($type == Categorie::TYPE_SUPPLIER) {
|
||||
// Link to delete from category
|
||||
print '<td class="right">';
|
||||
if ($permission) {
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$soc->id."'>";
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$soc->id.($limit?'&limit='.$limit:'').'">';
|
||||
print $langs->trans("DeleteFromCat");
|
||||
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
|
||||
print "</a>";
|
||||
|
||||
Reference in New Issue
Block a user