Fixed bug which didn't show documents in auto GED when an object had '/' in its ref
This commit is contained in:
parent
f60d7ea2de
commit
1f00794c98
@ -47,6 +47,11 @@ class Propal extends CommonObject
|
||||
public $fk_element='fk_propal';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $table_ref_field = 'ref';
|
||||
|
||||
var $id;
|
||||
|
||||
var $socid; // Id client
|
||||
|
||||
@ -44,6 +44,11 @@ class Commande extends CommonOrder
|
||||
public $fk_element = 'fk_commande';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $table_ref_field = 'ref';
|
||||
|
||||
var $id;
|
||||
|
||||
var $socid; // Id client
|
||||
|
||||
@ -50,6 +50,11 @@ class Facture extends CommonInvoice
|
||||
public $fk_element = 'fk_facture';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $table_ref_field = 'facnumber';
|
||||
|
||||
var $id;
|
||||
//! Id client
|
||||
var $socid;
|
||||
@ -833,7 +838,6 @@ class Facture extends CommonInvoice
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get object and lines from database
|
||||
*
|
||||
|
||||
@ -34,6 +34,11 @@ class ChargeSociales extends CommonObject
|
||||
public $table='chargesociales';
|
||||
public $table_element='chargesociales';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $table_ref_field = 'ref';
|
||||
|
||||
var $id;
|
||||
var $ref;
|
||||
var $date_ech;
|
||||
|
||||
@ -44,6 +44,11 @@ class Contrat extends CommonObject
|
||||
public $fk_element='fk_contrat';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $table_ref_field = 'ref';
|
||||
|
||||
var $id;
|
||||
var $ref;
|
||||
var $ref_ext;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -997,7 +997,6 @@ class FormFile
|
||||
if ($modulepart == 'user') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:'');}
|
||||
|
||||
if (! $id && ! $ref) continue;
|
||||
|
||||
$found=0;
|
||||
if (! empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref]))
|
||||
{
|
||||
@ -1006,7 +1005,19 @@ class FormFile
|
||||
else
|
||||
{
|
||||
//print 'Fetch '.$id." - ".$ref.'<br>';
|
||||
$result=$object_instance->fetch($id,$ref);
|
||||
|
||||
if ($id) {
|
||||
$result = $object_instance->fetch($id);
|
||||
} else {
|
||||
//fetchOneLike looks for objects with wildcards in its reference.
|
||||
//It is useful for those masks who get underscores instead of their actual symbols
|
||||
//fetchOneLike requires some info in the object. If it doesn't have it, then 0 is returned
|
||||
//that's why we look only look fetchOneLike when fetch returns 0
|
||||
if (!$result = $object_instance->fetch('', $ref)) {
|
||||
$result = $object_instance->fetchOneLike($ref);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result > 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]=dol_clone($object_instance); } // Save object into a cache
|
||||
if ($result == 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]='notfound'; unset($filearray[$key]); }
|
||||
}
|
||||
|
||||
@ -37,6 +37,11 @@ class Fichinter extends CommonObject
|
||||
public $fk_element='fk_fichinter';
|
||||
public $table_element_line='fichinterdet';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $table_ref_field = 'ref';
|
||||
|
||||
var $id;
|
||||
|
||||
var $socid; // Id client
|
||||
|
||||
@ -45,6 +45,11 @@ class CommandeFournisseur extends CommonOrder
|
||||
public $fk_element = 'fk_commande';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $table_ref_field = 'ref';
|
||||
|
||||
var $id;
|
||||
|
||||
var $ref; // TODO deprecated
|
||||
|
||||
@ -43,6 +43,11 @@ class FactureFournisseur extends CommonInvoice
|
||||
public $fk_element='fk_facture_fourn';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $table_ref_field = 'ref';
|
||||
|
||||
var $rowid;
|
||||
var $ref;
|
||||
var $product_ref;
|
||||
|
||||
@ -46,6 +46,11 @@ class Product extends CommonObject
|
||||
protected $isnolinkedbythird = 1; // No field fk_soc
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $table_ref_field = 'ref';
|
||||
|
||||
var $regeximgext='\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff';
|
||||
|
||||
//! Identifiant unique
|
||||
|
||||
@ -38,6 +38,11 @@ class Project extends CommonObject
|
||||
public $fk_element = 'fk_projet';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $table_ref_field = 'ref';
|
||||
|
||||
var $id;
|
||||
var $ref;
|
||||
var $description;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user