Fixed bug which didn't show documents in auto GED when an object had '/' in its ref

This commit is contained in:
Marcos García de La Fuente
2014-12-25 21:47:39 +01:00
parent f60d7ea2de
commit 1f00794c98
12 changed files with 95 additions and 3 deletions

View File

@@ -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