FIX when multicompany was enabled, this function didn't check just on the good entity (problem when both company use same mask)
This commit is contained in:
parent
2f5d1f5965
commit
91885c9d6f
@ -65,13 +65,17 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
static function isExistingObject($element, $id, $ref='', $ref_ext='')
|
static function isExistingObject($element, $id, $ref='', $ref_ext='')
|
||||||
{
|
{
|
||||||
global $db;
|
global $db,$conf;
|
||||||
|
|
||||||
$sql = "SELECT rowid, ref, ref_ext";
|
$sql = "SELECT rowid, ref, ref_ext";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX.$element;
|
$sql.= " FROM ".MAIN_DB_PREFIX.$element;
|
||||||
if ($id > 0) $sql.= " WHERE rowid = ".$db->escape($id);
|
|
||||||
else if ($ref) $sql.= " WHERE ref = '".$db->escape($ref)."'";
|
if($conf->multicompany->enabled)$sql.= " WHERE entity=".$conf->entity;
|
||||||
else if ($ref_ext) $sql.= " WHERE ref_ext = '".$db->escape($ref_ext)."'";
|
else $sql.=" WHERE 1 ";
|
||||||
|
|
||||||
|
if ($id > 0) $sql.= " AND rowid = ".$db->escape($id);
|
||||||
|
else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'";
|
||||||
|
else if ($ref_ext) $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'";
|
||||||
else {
|
else {
|
||||||
$error='ErrorWrongParameters';
|
$error='ErrorWrongParameters';
|
||||||
dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR);
|
dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user