mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 17:13:03 +01:00
Fixed bug which didn't show documents in auto GED when an object had '/' in its ref
This commit is contained in:
@@ -54,6 +54,12 @@ abstract class CommonObject
|
||||
|
||||
// No constructor as it is an abstract class
|
||||
|
||||
/**
|
||||
* Column name of the ref field.
|
||||
* @var string
|
||||
*/
|
||||
protected $table_ref_field = '';
|
||||
|
||||
|
||||
/**
|
||||
* Check an object id/ref exists
|
||||
@@ -631,6 +637,32 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Looks for an object with ref matching the wildcard provided
|
||||
* It does only work when $this->table_ref_field is set
|
||||
*
|
||||
* @param string $ref Wildcard
|
||||
* @return int >1 = OK, 0 = Not found or table_ref_field not defined, <0 = KO
|
||||
*/
|
||||
public function fetchOneLike($ref)
|
||||
{
|
||||
if (!$this->table_ref_field) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE '.$this->table_ref_field.' LIKE "'.$this->db->escape($ref).'" LIMIT 1';
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
if (!$this->db->num_rows($query)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$result = $this->db->fetch_object($query);
|
||||
|
||||
return $this->fetch($result->rowid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data for barcode into properties ->barcode_type*
|
||||
* Properties ->barcode_type that is id of barcode. Type is used to find other properties, but
|
||||
|
||||
Reference in New Issue
Block a user