Clean code
This commit is contained in:
parent
bb436e556d
commit
e2ee74f8e0
@ -1662,8 +1662,8 @@ abstract class CommonObject
|
|||||||
* Looks for an object with ref matching the wildcard provided
|
* Looks for an object with ref matching the wildcard provided
|
||||||
* It does only work when $this->table_ref_field is set
|
* It does only work when $this->table_ref_field is set
|
||||||
*
|
*
|
||||||
* @param string $ref Wildcard
|
* @param string $ref Wildcard
|
||||||
* @return int >1 = OK, 0 = Not found or table_ref_field not defined, <0 = KO
|
* @return int >1 = OK, 0 = Not found or table_ref_field not defined, <0 = KO
|
||||||
*/
|
*/
|
||||||
public function fetchOneLike($ref)
|
public function fetchOneLike($ref)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -347,8 +347,7 @@ class EmailSenderProfile extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function info($id)
|
public function info($id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
|
$sql = 'SELECT rowid, date_creation as datec, tms as datem';
|
||||||
$sql .= ' fk_user_creat, fk_user_modif';
|
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||||
$sql .= ' WHERE t.rowid = '.((int) $id);
|
$sql .= ' WHERE t.rowid = '.((int) $id);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -356,27 +355,9 @@ class EmailSenderProfile extends CommonObject
|
|||||||
if ($this->db->num_rows($result)) {
|
if ($this->db->num_rows($result)) {
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
if ($obj->fk_user_author) {
|
|
||||||
$cuser = new User($this->db);
|
|
||||||
$cuser->fetch($obj->fk_user_author);
|
|
||||||
$this->user_creation = $cuser;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($obj->fk_user_valid) {
|
|
||||||
$vuser = new User($this->db);
|
|
||||||
$vuser->fetch($obj->fk_user_valid);
|
|
||||||
$this->user_validation = $vuser;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($obj->fk_user_cloture) {
|
|
||||||
$cluser = new User($this->db);
|
|
||||||
$cluser->fetch($obj->fk_user_cloture);
|
|
||||||
$this->user_cloture = $cluser;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->date_creation = $this->db->jdate($obj->datec);
|
$this->date_creation = $this->db->jdate($obj->datec);
|
||||||
$this->date_modification = $this->db->jdate($obj->datem);
|
$this->date_modification = $this->db->jdate($obj->datem);
|
||||||
$this->date_validation = $this->db->jdate($obj->datev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|||||||
@ -925,6 +925,7 @@ class ExtraFields
|
|||||||
// Old usage
|
// Old usage
|
||||||
$label = $this->attribute_label[$key];
|
$label = $this->attribute_label[$key];
|
||||||
$type = $this->attribute_type[$key];
|
$type = $this->attribute_type[$key];
|
||||||
|
$list = $this->attribute_list[$key];
|
||||||
$hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
|
$hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1646,6 +1646,7 @@ class FormFile
|
|||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
// To show ref or specific information according to view to show (defined by $module)
|
// To show ref or specific information according to view to show (defined by $module)
|
||||||
|
$object_instance = null;
|
||||||
if ($modulepart == 'company') {
|
if ($modulepart == 'company') {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||||
$object_instance = new Societe($this->db);
|
$object_instance = new Societe($this->db);
|
||||||
@ -1813,21 +1814,26 @@ class FormFile
|
|||||||
if (!$id && !$ref) {
|
if (!$id && !$ref) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$found = 0;
|
$found = 0;
|
||||||
if (!empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) {
|
if (!empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) {
|
||||||
$found = 1;
|
$found = 1;
|
||||||
} else {
|
} else {
|
||||||
//print 'Fetch '.$id." - ".$ref.' class='.get_class($object_instance).'<br>';
|
//print 'Fetch '.$id." - ".$ref.' class='.get_class($object_instance).'<br>';
|
||||||
|
|
||||||
if ($id) {
|
$result = 0;
|
||||||
$result = $object_instance->fetch($id);
|
if (is_object($object_instance)) {
|
||||||
} else {
|
if ($id) {
|
||||||
//fetchOneLike looks for objects with wildcards in its reference.
|
$result = $object_instance->fetch($id);
|
||||||
//It is useful for those masks who get underscores instead of their actual symbols
|
} else {
|
||||||
//fetchOneLike requires some info in the object. If it doesn't have it, then 0 is returned
|
if (!($result = $object_instance->fetch('', $ref))) {
|
||||||
//that's why we look only into fetchOneLike when fetch returns 0
|
//fetchOneLike looks for objects with wildcards in its reference.
|
||||||
if (!$result = $object_instance->fetch('', $ref)) {
|
//It is useful for those masks who get underscores instead of their actual symbols (because the _ had replaced a forbiddn char)
|
||||||
$result = $object_instance->fetchOneLike($ref);
|
//fetchOneLike requires some info in the object. If it doesn't have it, then 0 is returned
|
||||||
|
//that's why we look only into fetchOneLike when fetch returns 0
|
||||||
|
// TODO Remove this part ?
|
||||||
|
$result = $object_instance->fetchOneLike($ref);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,13 @@ class ActionsCardService
|
|||||||
public $field_list = array();
|
public $field_list = array();
|
||||||
public $list_datas = array();
|
public $list_datas = array();
|
||||||
|
|
||||||
|
public $id;
|
||||||
|
public $ref;
|
||||||
|
public $description;
|
||||||
|
public $note;
|
||||||
|
public $price;
|
||||||
|
public $price_min;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -196,6 +203,7 @@ class ActionsCardService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Duration
|
// Duration
|
||||||
|
$dur = array();
|
||||||
if ($this->object->duration_value > 1) {
|
if ($this->object->duration_value > 1) {
|
||||||
$dur = array("h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
|
$dur = array("h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
|
||||||
} elseif ($this->object->duration_value > 0) {
|
} elseif ($this->object->duration_value > 0) {
|
||||||
@ -286,6 +294,7 @@ class ActionsCardService
|
|||||||
if ($search_categ) {
|
if ($search_categ) {
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp";
|
$sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp";
|
||||||
}
|
}
|
||||||
|
$fourn_id = 0;
|
||||||
if (GETPOST("fourn_id", 'int') > 0) {
|
if (GETPOST("fourn_id", 'int') > 0) {
|
||||||
$fourn_id = GETPOST("fourn_id", 'int');
|
$fourn_id = GETPOST("fourn_id", 'int');
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
$sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user