--- /tmp/dsg/dolibarr/htdocs/resource/class/github_dolresource.class.php
+++ /tmp/dsg/dolibarr/htdocs/resource/class/client_dolresource.class.php
@@ -52,8 +52,8 @@
public $mandatory;
/**
- * @var int ID
- */
+ * @var int ID
+ */
public $fk_user_create;
public $type_label;
@@ -63,75 +63,79 @@
public $oldcopy;
- /**
- * Constructor
- *
- * @param DoliDb $db Database handler
- */
- public function __construct($db)
- {
- $this->db = $db;
- }
-
- /**
- * Create object into database
- *
- * @param User $user User that creates
- * @param int $notrigger 0=launch triggers after, 1=disable triggers
- * @return int <0 if KO, Id of created object if OK
- */
- public function create($user, $notrigger = 0)
- {
- global $conf, $langs, $hookmanager;
- $error = 0;
-
- // Clean parameters
-
- if (isset($this->ref)) $this->ref = trim($this->ref);
- if (isset($this->description)) $this->description = trim($this->description);
- if (!is_numeric($this->country_id)) $this->country_id = 0;
- if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource);
- if (isset($this->note_public)) $this->note_public = trim($this->note_public);
- if (isset($this->note_private)) $this->note_private = trim($this->note_private);
-
-
- // Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
- $sql .= "entity,";
- $sql .= "ref,";
- $sql .= "description,";
- $sql .= "fk_country,";
- $sql .= "fk_code_type_resource,";
- $sql .= "note_public,";
- $sql .= "note_private";
- $sql .= ") VALUES (";
- $sql .= $conf->entity.", ";
- $sql .= " ".(!isset($this->ref) ? 'NULL' : "'".$this->db->escape($this->ref)."'").",";
- $sql .= " ".(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").",";
- $sql .= " ".($this->country_id > 0 ? $this->country_id : 'null').",";
- $sql .= " ".(!isset($this->fk_code_type_resource) ? 'NULL' : "'".$this->db->escape($this->fk_code_type_resource)."'").",";
- $sql .= " ".(!isset($this->note_public) ? 'NULL' : "'".$this->db->escape($this->note_public)."'").",";
- $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'");
- $sql .= ")";
-
- $this->db->begin();
-
- dol_syslog(get_class($this)."::create", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (!$resql) {
- $error++; $this->errors[] = "Error ".$this->db->lasterror();
- }
-
- if (!$error)
- {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
- }
-
- if (!$error)
- {
- $action = 'create';
-
- // Actions on extra fields
+ /**
+ * Constructor
+ *
+ * @param DoliDb $db Database handler
+ */
+ public function __construct($db)
+ {
+ $this->db = $db;
+ }
+
+ /**
+ * Create object into database
+ *
+ * @param User $user User that creates
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, Id of created object if OK
+ */
+ public function create($user, $notrigger = 0)
+ {
+ global $conf, $langs, $hookmanager;
+ $error = 0;
+
+ // Clean parameters
+
+ if (isset($this->ref)) $this->ref = trim($this->ref);
+ if (isset($this->description)) $this->description = trim($this->description);
+ if (!is_numeric($this->country_id)) $this->country_id = 0;
+ if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource);
+ if (isset($this->note_public)) $this->note_public = trim($this->note_public);
+ if (isset($this->note_private)) $this->note_private = trim($this->note_private);
+
+
+ // Insert request
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
+
+ $sql .= "entity,";
+ $sql .= "ref,";
+ $sql .= "description,";
+ $sql .= "fk_country,";
+ $sql .= "fk_code_type_resource,";
+ $sql .= "note_public,";
+ $sql .= "note_private";
+
+ $sql .= ") VALUES (";
+
+ $sql .= $conf->entity.", ";
+ $sql .= " ".(!isset($this->ref) ? 'NULL' : "'".$this->db->escape($this->ref)."'").",";
+ $sql .= " ".(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").",";
+ $sql .= " ".($this->country_id > 0 ? $this->country_id : 'null').",";
+ $sql .= " ".(!isset($this->fk_code_type_resource) ? 'NULL' : "'".$this->db->escape($this->fk_code_type_resource)."'").",";
+ $sql .= " ".(!isset($this->note_public) ? 'NULL' : "'".$this->db->escape($this->note_public)."'").",";
+ $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'");
+
+ $sql .= ")";
+
+ $this->db->begin();
+
+ dol_syslog(get_class($this)."::create", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (!$resql) {
+ $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ }
+
+ if (!$error)
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
+ }
+
+ if (!$error)
+ {
+ $action = 'create';
+
+ // Actions on extra fields
if (!$error)
{
$result = $this->insertExtraFields();
@@ -139,100 +143,104 @@
{
$error++;
}
- }
- }
-
- if (!$error && !$notrigger)
- {
- // Call trigger
- $result = $this->call_trigger('RESOURCE_CREATE', $user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- // Commit or rollback
- if ($error)
- {
- foreach ($this->errors as $errmsg)
- {
- dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
- $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
- }
- $this->db->rollback();
- return -1 * $error;
- } else {
- $this->db->commit();
- return $this->id;
- }
- }
-
- /**
- * Load object in memory from database
- *
- * @param int $id Id of object
- * @param string $ref Ref of object
- * @return int <0 if KO, >0 if OK
- */
- public function fetch($id, $ref = '')
- {
- global $langs;
- $sql = "SELECT";
- $sql .= " t.rowid,";
- $sql .= " t.entity,";
- $sql .= " t.ref,";
- $sql .= " t.description,";
+ }
+ }
+
+ if (!$error && !$notrigger)
+ {
+ // Call trigger
+ $result = $this->call_trigger('RESOURCE_CREATE', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach ($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
+ $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
+ }
+ $this->db->rollback();
+ return -1 * $error;
+ }
+ else
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ }
+
+ /**
+ * Load object in memory from database
+ *
+ * @param int $id Id of object
+ * @param string $ref Ref of object
+ * @return int <0 if KO, >0 if OK
+ */
+ public function fetch($id, $ref = '')
+ {
+ global $langs;
+ $sql = "SELECT";
+ $sql .= " t.rowid,";
+ $sql .= " t.entity,";
+ $sql .= " t.ref,";
+ $sql .= " t.description,";
$sql .= " t.fk_country,";
- $sql .= " t.fk_code_type_resource,";
- $sql .= " t.note_public,";
- $sql .= " t.note_private,";
- $sql .= " t.tms,";
- $sql .= " ty.label as type_label";
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
- if ($id) $sql .= " WHERE t.rowid = ".$this->db->escape($id);
- else $sql .= " WHERE t.ref = '".$this->db->escape($ref)."'";
-
- dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
- $obj = $this->db->fetch_object($resql);
-
- $this->id = $obj->rowid;
- $this->entity = $obj->entity;
- $this->ref = $obj->ref;
- $this->description = $obj->description;
- $this->country_id = $obj->fk_country;
- $this->fk_code_type_resource = $obj->fk_code_type_resource;
- $this->note_public = $obj->note_public;
- $this->note_private = $obj->note_private;
- $this->type_label = $obj->type_label;
-
- // Retrieve all extrafield
- // fetch optionals attributes and labels
- $this->fetch_optionals();
- }
- $this->db->free($resql);
-
- return $this->id;
- } else {
- $this->error = "Error ".$this->db->lasterror();
- dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
- return -1;
- }
- }
-
-
- /**
- * Update object into database
- *
- * @param User $user User that modifies
- * @param int $notrigger 0=launch triggers after, 1=disable triggers
- * @return int <0 if KO, >0 if OK
- */
- public function update($user = null, $notrigger = 0)
+ $sql .= " t.fk_code_type_resource,";
+ $sql .= " t.note_public,";
+ $sql .= " t.note_private,";
+ $sql .= " t.tms,";
+ $sql .= " ty.label as type_label";
+ $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
+ if ($id) $sql .= " WHERE t.rowid = ".$this->db->escape($id);
+ else $sql .= " WHERE t.ref = '".$this->db->escape($ref)."'";
+
+ dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+ $this->entity = $obj->entity;
+ $this->ref = $obj->ref;
+ $this->description = $obj->description;
+ $this->country_id = $obj->fk_country;
+ $this->fk_code_type_resource = $obj->fk_code_type_resource;
+ $this->note_public = $obj->note_public;
+ $this->note_private = $obj->note_private;
+ $this->type_label = $obj->type_label;
+
+ // Retreive all extrafield
+ // fetch optionals attributes and labels
+ $this->fetch_optionals();
+ }
+ $this->db->free($resql);
+
+ return $this->id;
+ }
+ else
+ {
+ $this->error = "Error ".$this->db->lasterror();
+ dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
+ return -1;
+ }
+ }
+
+
+ /**
+ * Update object into database
+ *
+ * @param User $user User that modifies
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function update($user = null, $notrigger = 0)
{
global $conf, $langs, $hookmanager;
$error = 0;
@@ -241,7 +249,7 @@
if (isset($this->ref)) $this->ref = trim($this->ref);
if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource);
if (isset($this->description)) $this->description = trim($this->description);
- if (!is_numeric($this->country_id)) $this->country_id = 0;
+ if (!is_numeric($this->country_id)) $this->country_id = 0;
if (empty($this->oldcopy))
{
@@ -321,25 +329,27 @@
}
$this->db->rollback();
return -1 * $error;
- } else {
+ }
+ else
+ {
$this->db->commit();
return 1;
}
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Load object in memory from database
- *
- * @param int $id id object
- * @return int <0 if KO, >0 if OK
- */
- public function fetch_element_resource($id)
- {
- // phpcs:enable
- global $langs;
- $sql = "SELECT";
- $sql .= " t.rowid,";
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Load object in memory from database
+ *
+ * @param int $id id object
+ * @return int <0 if KO, >0 if OK
+ */
+ public function fetch_element_resource($id)
+ {
+ // phpcs:enable
+ global $langs;
+ $sql = "SELECT";
+ $sql .= " t.rowid,";
$sql .= " t.resource_id,";
$sql .= " t.resource_type,";
$sql .= " t.element_id,";
@@ -349,24 +359,24 @@
$sql .= " t.fk_user_create,";
$sql .= " t.tms";
$sql .= " FROM ".MAIN_DB_PREFIX."element_resources as t";
- $sql .= " WHERE t.rowid = ".$this->db->escape($id);
-
- dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
- $obj = $this->db->fetch_object($resql);
-
- $this->id = $obj->rowid;
- $this->resource_id = $obj->resource_id;
- $this->resource_type = $obj->resource_type;
- $this->element_id = $obj->element_id;
- $this->element_type = $obj->element_type;
- $this->busy = $obj->busy;
- $this->mandatory = $obj->mandatory;
- $this->fk_user_create = $obj->fk_user_create;
+ $sql .= " WHERE t.rowid = ".$this->db->escape($id);
+
+ dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+ $this->resource_id = $obj->resource_id;
+ $this->resource_type = $obj->resource_type;
+ $this->element_id = $obj->element_id;
+ $this->element_type = $obj->element_type;
+ $this->busy = $obj->busy;
+ $this->mandatory = $obj->mandatory;
+ $this->fk_user_create = $obj->fk_user_create;
if ($obj->resource_id && $obj->resource_type) {
$this->objresource = fetchObjectByElement($obj->resource_id, $obj->resource_type);
@@ -374,27 +384,29 @@
if ($obj->element_id && $obj->element_type) {
$this->objelement = fetchObjectByElement($obj->element_id, $obj->element_type);
}
- }
- $this->db->free($resql);
-
- return $this->id;
- } else {
- $this->error = "Error ".$this->db->lasterror();
- return -1;
- }
- }
-
- /**
- * Delete a resource object
- *
- * @param int $rowid Id of resource line to delete
- * @param int $notrigger Disable all triggers
- * @return int >0 if OK, <0 if KO
- */
- public function delete($rowid, $notrigger = 0)
+ }
+ $this->db->free($resql);
+
+ return $this->id;
+ }
+ else
+ {
+ $this->error = "Error ".$this->db->lasterror();
+ return -1;
+ }
+ }
+
+ /**
+ * Delete a resource object
+ *
+ * @param int $rowid Id of resource line to delete
+ * @param int $notrigger Disable all triggers
+ * @return int >0 if OK, <0 if KO
+ */
+ public function delete($rowid, $notrigger = 0)
{
global $user, $langs, $conf;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error = 0;
@@ -415,7 +427,9 @@
$this->error = $this->db->lasterror();
$error++;
}
- } else {
+ }
+ else
+ {
$this->error = $this->db->lasterror();
$error++;
}
@@ -461,114 +475,120 @@
{
$this->db->commit();
return 1;
- } else {
+ }
+ else
+ {
$this->db->rollback();
return -1;
}
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Load resource objects into $this->lines
- *
- * @param string $sortorder sort order
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Load resource objects into $this->lines
+ *
+ * @param string $sortorder sort order
+ * @param string $sortfield sort field
+ * @param int $limit limit page
+ * @param int $offset page
+ * @param array $filter filter output
+ * @return int <0 if KO, >0 if OK
+ */
+ public function fetch_all($sortorder, $sortfield, $limit, $offset, $filter = '')
+ {
+ // phpcs:enable
+ global $conf;
+
+ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+ $extrafields = new ExtraFields($this->db);
+
+ $sql = "SELECT ";
+ $sql .= " t.rowid,";
+ $sql .= " t.entity,";
+ $sql .= " t.ref,";
+ $sql .= " t.description,";
+ $sql .= " t.fk_code_type_resource,";
+ $sql .= " t.tms,";
+ // Add fields from extrafields
+ if (!empty($extrafields->attributes[$this->table_element]['label']))
+ foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
+ $sql .= " ty.label as type_label";
+ $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element."_extrafields as ef ON ef.fk_object=t.rowid";
+ $sql .= " WHERE t.entity IN (".getEntity('resource').")";
+ // Manage filter
+ if (!empty($filter)) {
+ foreach ($filter as $key => $value) {
+ if (strpos($key, 'date')) {
+ $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\'';
+ }
+ elseif (strpos($key, 'ef.') !== false) {
+ $sql .= $value;
+ }
+ else {
+ $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\'';
+ }
+ }
+ }
+ $sql .= $this->db->order($sortfield, $sortorder);
+ $this->num_all = 0;
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+ {
+ $result = $this->db->query($sql);
+ $this->num_all = $this->db->num_rows($result);
+ }
+ if ($limit) $sql .= $this->db->plimit($limit, $offset);
+ dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
+
+ $this->lines = array();
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ if ($num)
+ {
+ while ($obj = $this->db->fetch_object($resql))
+ {
+ $line = new Dolresource($this->db);
+ $line->id = $obj->rowid;
+ $line->ref = $obj->ref;
+ $line->description = $obj->description;
+ $line->country_id = $obj->fk_country;
+ $line->fk_code_type_resource = $obj->fk_code_type_resource;
+ $line->type_label = $obj->type_label;
+
+ // fetch optionals attributes and labels
+
+ $line->fetch_optionals();
+
+ $this->lines[] = $line;
+ }
+ $this->db->free($resql);
+ }
+ return $num;
+ }
+ else
+ {
+ $this->error = $this->db->lasterror();
+ return -1;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Load all objects into $this->lines
+ *
+ * @param string $sortorder sort order
* @param string $sortfield sort field
* @param int $limit limit page
* @param int $offset page
* @param array $filter filter output
* @return int <0 if KO, >0 if OK
- */
- public function fetch_all($sortorder, $sortfield, $limit, $offset, $filter = '')
- {
- // phpcs:enable
- global $conf;
-
- require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- $extrafields = new ExtraFields($this->db);
-
- $sql = "SELECT ";
- $sql .= " t.rowid,";
- $sql .= " t.entity,";
- $sql .= " t.ref,";
- $sql .= " t.description,";
- $sql .= " t.fk_code_type_resource,";
- $sql .= " t.tms,";
- // Add fields from extrafields
- if (!empty($extrafields->attributes[$this->table_element]['label']))
- foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
- $sql .= " ty.label as type_label";
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element."_extrafields as ef ON ef.fk_object=t.rowid";
- $sql .= " WHERE t.entity IN (".getEntity('resource').")";
- // Manage filter
- if (!empty($filter)) {
- foreach ($filter as $key => $value) {
- if (strpos($key, 'date')) {
- $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\'';
- } elseif (strpos($key, 'ef.') !== false) {
- $sql .= $value;
- } else {
- $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\'';
- }
- }
- }
- $sql .= $this->db->order($sortfield, $sortorder);
- $this->num_all = 0;
- if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
- {
- $result = $this->db->query($sql);
- $this->num_all = $this->db->num_rows($result);
- }
- if ($limit) $sql .= $this->db->plimit($limit, $offset);
- dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
-
- $this->lines = array();
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- if ($num)
- {
- while ($obj = $this->db->fetch_object($resql))
- {
- $line = new Dolresource($this->db);
- $line->id = $obj->rowid;
- $line->ref = $obj->ref;
- $line->description = $obj->description;
- $line->country_id = $obj->fk_country;
- $line->fk_code_type_resource = $obj->fk_code_type_resource;
- $line->type_label = $obj->type_label;
-
- // fetch optionals attributes and labels
-
- $line->fetch_optionals();
-
- $this->lines[] = $line;
- }
- $this->db->free($resql);
- }
- return $num;
- } else {
- $this->error = $this->db->lasterror();
- return -1;
- }
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Load all objects into $this->lines
- *
- * @param string $sortorder sort order
- * @param string $sortfield sort field
- * @param int $limit limit page
- * @param int $offset page
- * @param array $filter filter output
- * @return int <0 if KO, >0 if OK
- */
- public function fetch_all_resources($sortorder, $sortfield, $limit, $offset, $filter = '')
- {
- // phpcs:enable
+ */
+ public function fetch_all_resources($sortorder, $sortfield, $limit, $offset, $filter = '')
+ {
+ // phpcs:enable
global $conf;
$sql = "SELECT ";
$sql .= " t.rowid,";
@@ -588,12 +608,13 @@
foreach ($filter as $key => $value) {
if (strpos($key, 'date')) {
$sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\'';
- } else {
+ }
+ else {
$sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\'';
}
}
}
- $sql .= $this->db->order($sortfield, $sortorder);
+ $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) $sql .= $this->db->plimit($limit + 1, $offset);
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
@@ -619,128 +640,133 @@
$line->objresource = fetchObjectByElement($obj->resource_id, $obj->resource_type);
if ($obj->element_id && $obj->element_type)
$line->objelement = fetchObjectByElement($obj->element_id, $obj->element_type);
- $this->lines[] = $line;
+ $this->lines[] = $line;
}
$this->db->free($resql);
}
return $num;
- } else {
+ }
+ else
+ {
$this->error = $this->db->lasterror();
return -1;
}
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Load all objects into $this->lines
- *
- * @param string $sortorder sort order
- * @param string $sortfield sort field
- * @param int $limit limit page
- * @param int $offset page
- * @param array $filter filter output
- * @return int <0 if KO, >0 if OK
- */
- public function fetch_all_used($sortorder, $sortfield, $limit, $offset = 1, $filter = '')
- {
- // phpcs:enable
- global $conf;
-
- if (!$sortorder) $sortorder = "ASC";
- if (!$sortfield) $sortfield = "t.rowid";
-
- $sql = "SELECT ";
- $sql .= " t.rowid,";
- $sql .= " t.resource_id,";
- $sql .= " t.resource_type,";
- $sql .= " t.element_id,";
- $sql .= " t.element_type,";
- $sql .= " t.busy,";
- $sql .= " t.mandatory,";
- $sql .= " t.fk_user_create,";
- $sql .= " t.tms";
- $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources as t ';
- $sql .= " WHERE t.entity IN (".getEntity('resource').")";
-
- //Manage filter
- if (!empty($filter)) {
- foreach ($filter as $key => $value) {
- if (strpos($key, 'date')) {
- $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\'';
- } else {
- $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\'';
- }
- }
- }
- $sql .= $this->db->order($sortfield, $sortorder);
- if ($limit) $sql .= $this->db->plimit($limit + 1, $offset);
- dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
-
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- if ($num)
- {
- $this->lines = array();
- while ($obj = $this->db->fetch_object($resql))
- {
- $line = new Dolresource($this->db);
- $line->id = $obj->rowid;
- $line->resource_id = $obj->resource_id;
- $line->resource_type = $obj->resource_type;
- $line->element_id = $obj->element_id;
- $line->element_type = $obj->element_type;
- $line->busy = $obj->busy;
- $line->mandatory = $obj->mandatory;
- $line->fk_user_create = $obj->fk_user_create;
-
- $this->lines[] = fetchObjectByElement($obj->resource_id, $obj->resource_type);
- }
- $this->db->free($resql);
- }
- return $num;
- } else {
- $this->error = $this->db->lasterror();
- return -1;
- }
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Fetch all resources available, declared by modules
- * Load available resource in array $this->available_resources
- *
- * @return int number of available resources declared by modules
- * @deprecated, remplaced by hook getElementResources
- * @see getElementResources()
- */
- public function fetch_all_available()
- {
- // phpcs:enable
- global $conf;
-
- if (!empty($conf->modules_parts['resources']))
- {
- $this->available_resources = (array) $conf->modules_parts['resources'];
-
- return count($this->available_resources);
- }
- return 0;
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Update element resource into database
- *
- * @param User $user User that modifies
- * @param int $notrigger 0=launch triggers after, 1=disable triggers
- * @return int <0 if KO, >0 if OK
- */
- public function update_element_resource($user = null, $notrigger = 0)
- {
- // phpcs:enable
- global $conf, $langs;
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Load all objects into $this->lines
+ *
+ * @param string $sortorder sort order
+ * @param string $sortfield sort field
+ * @param int $limit limit page
+ * @param int $offset page
+ * @param array $filter filter output
+ * @return int <0 if KO, >0 if OK
+ */
+ public function fetch_all_used($sortorder, $sortfield, $limit, $offset = 1, $filter = '')
+ {
+ // phpcs:enable
+ global $conf;
+
+ if (!$sortorder) $sortorder = "ASC";
+ if (!$sortfield) $sortfield = "t.rowid";
+
+ $sql = "SELECT ";
+ $sql .= " t.rowid,";
+ $sql .= " t.resource_id,";
+ $sql .= " t.resource_type,";
+ $sql .= " t.element_id,";
+ $sql .= " t.element_type,";
+ $sql .= " t.busy,";
+ $sql .= " t.mandatory,";
+ $sql .= " t.fk_user_create,";
+ $sql .= " t.tms";
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources as t ';
+ $sql .= " WHERE t.entity IN (".getEntity('resource').")";
+
+ //Manage filter
+ if (!empty($filter)) {
+ foreach ($filter as $key => $value) {
+ if (strpos($key, 'date')) {
+ $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\'';
+ }
+ else {
+ $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\'';
+ }
+ }
+ }
+ $sql .= $this->db->order($sortfield, $sortorder);
+ if ($limit) $sql .= $this->db->plimit($limit + 1, $offset);
+ dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
+
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ if ($num)
+ {
+ $this->lines = array();
+ while ($obj = $this->db->fetch_object($resql))
+ {
+ $line = new Dolresource($this->db);
+ $line->id = $obj->rowid;
+ $line->resource_id = $obj->resource_id;
+ $line->resource_type = $obj->resource_type;
+ $line->element_id = $obj->element_id;
+ $line->element_type = $obj->element_type;
+ $line->busy = $obj->busy;
+ $line->mandatory = $obj->mandatory;
+ $line->fk_user_create = $obj->fk_user_create;
+
+ $this->lines[] = fetchObjectByElement($obj->resource_id, $obj->resource_type);
+ }
+ $this->db->free($resql);
+ }
+ return $num;
+ }
+ else
+ {
+ $this->error = $this->db->lasterror();
+ return -1;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Fetch all resources available, declared by modules
+ * Load available resource in array $this->available_resources
+ *
+ * @return int number of available resources declared by modules
+ * @deprecated, remplaced by hook getElementResources
+ * @see getElementResources()
+ */
+ public function fetch_all_available()
+ {
+ // phpcs:enable
+ global $conf;
+
+ if (!empty($conf->modules_parts['resources']))
+ {
+ $this->available_resources = (array) $conf->modules_parts['resources'];
+
+ return count($this->available_resources);
+ }
+ return 0;
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Update element resource into database
+ *
+ * @param User $user User that modifies
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function update_element_resource($user = null, $notrigger = 0)
+ {
+ // phpcs:enable
+ global $conf, $langs;
$error = 0;
// Clean parameters
@@ -751,8 +777,8 @@
if (isset($this->busy)) $this->busy = trim($this->busy);
if (isset($this->mandatory)) $this->mandatory = trim($this->mandatory);
- // Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX."element_resources SET";
+ // Update request
+ $sql = "UPDATE ".MAIN_DB_PREFIX."element_resources SET";
$sql .= " resource_id=".(isset($this->resource_id) ? "'".$this->db->escape($this->resource_id)."'" : "null").",";
$sql .= " resource_type=".(isset($this->resource_type) ? "'".$this->db->escape($this->resource_type)."'" : "null").",";
$sql .= " element_id=".(isset($this->element_id) ? $this->element_id : "null").",";
@@ -761,234 +787,239 @@
$sql .= " mandatory=".(isset($this->mandatory) ? $this->mandatory : "null").",";
$sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null')."";
- $sql .= " WHERE rowid=".$this->id;
+ $sql .= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::update", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
+ $resql = $this->db->query($sql);
+ if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$error)
{
if (!$notrigger)
{
- // Call trigger
- $result = $this->call_trigger('RESOURCE_MODIFY', $user);
- if ($result < 0) $error++;
- // End call triggers
- }
- }
-
- // Commit or rollback
+ // Call trigger
+ $result = $this->call_trigger('RESOURCE_MODIFY', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+ }
+
+ // Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
- dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
- $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
+ dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
+ $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
- } else {
+ }
+ else
+ {
$this->db->commit();
return 1;
}
- }
-
-
- /**
- * Return an array with resources linked to the element
- *
- * @param string $element Element
- * @param int $element_id Id
- * @param string $resource_type Type
- * @return array Aray of resources
- */
- public function getElementResources($element, $element_id, $resource_type = '')
- {
- $resources = array();
-
- // Links beetween objects are stored in this table
- $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources';
- $sql .= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'";
- if ($resource_type)
- $sql .= " AND resource_type LIKE '%".$this->db->escape($resource_type)."%'";
- $sql .= ' ORDER BY resource_type';
-
- dol_syslog(get_class($this)."::getElementResources", LOG_DEBUG);
-
- $resources = array();
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
-
- $resources[$i] = array(
- 'rowid' => $obj->rowid,
- 'resource_id' => $obj->resource_id,
- 'resource_type'=>$obj->resource_type,
- 'busy'=>$obj->busy,
- 'mandatory'=>$obj->mandatory
- );
- $i++;
- }
- }
-
- return $resources;
- }
-
- /**
- * Return an int number of resources linked to the element
- *
- * @param string $element Element type
- * @param int $element_id Element id
- * @return int Nb of resources loaded
- */
- public function fetchElementResources($element, $element_id)
- {
- $resources = $this->getElementResources($element, $element_id);
- $i = 0;
- foreach ($resources as $nb => $resource) {
- $this->lines[$i] = fetchObjectByElement($resource['resource_id'], $resource['resource_type']);
- $i++;
- }
- return $i;
- }
-
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Load in cache resource type code (setup in dictionary)
- *
- * @return int Number of lines loaded, 0 if already loaded, <0 if KO
- */
- public function load_cache_code_type_resource()
- {
- // phpcs:enable
- global $langs;
-
- if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge
-
- $sql = "SELECT rowid, code, label, active";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_type_resource";
- $sql .= " WHERE active > 0";
- $sql .= " ORDER BY rowid";
- dol_syslog(get_class($this)."::load_cache_code_type_resource", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
- // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
- $label = ($langs->trans("ResourceTypeShort".$obj->code) != ("ResourceTypeShort".$obj->code) ? $langs->trans("ResourceTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
- $this->cache_code_type_resource[$obj->rowid]['code'] = $obj->code;
- $this->cache_code_type_resource[$obj->rowid]['label'] = $label;
- $this->cache_code_type_resource[$obj->rowid]['active'] = $obj->active;
- $i++;
- }
- return $num;
- } else {
- dol_print_error($this->db);
- return -1;
- }
- }
-
- /**
- * Return clicable link of object (with eventually picto)
- *
- * @param int $withpicto Add picto into link
- * @param string $option Where point the link ('compta', 'expedition', 'document', ...)
- * @param string $get_params Parametres added to url
- * @param int $notooltip 1=Disable tooltip
- * @param string $morecss Add more css on link
- * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
- * @return string String with URL
- */
- public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
- {
- global $conf, $langs;
-
- $result = '';
- $label = img_picto('', $this->picto).' '.$langs->trans("Resource").'';
- $label .= '
';
- $label .= ''.$langs->trans('Ref').': '.$this->ref;
- /*if (isset($this->status)) {
+ }
+
+
+ /**
+ * Return an array with resources linked to the element
+ *
+ * @param string $element Element
+ * @param int $element_id Id
+ * @param string $resource_type Type
+ * @return array Aray of resources
+ */
+ public function getElementResources($element, $element_id, $resource_type = '')
+ {
+ $resources = array();
+
+ // Links beetween objects are stored in this table
+ $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources';
+ $sql .= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'";
+ if ($resource_type)
+ $sql .= " AND resource_type LIKE '%".$this->db->escape($resource_type)."%'";
+ $sql .= ' ORDER BY resource_type';
+
+ dol_syslog(get_class($this)."::getElementResources", LOG_DEBUG);
+
+ $resources = array();
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $resources[$i] = array(
+ 'rowid' => $obj->rowid,
+ 'resource_id' => $obj->resource_id,
+ 'resource_type'=>$obj->resource_type,
+ 'busy'=>$obj->busy,
+ 'mandatory'=>$obj->mandatory
+ );
+ $i++;
+ }
+ }
+
+ return $resources;
+ }
+
+ /**
+ * Return an int number of resources linked to the element
+ *
+ * @param string $element Element type
+ * @param int $element_id Element id
+ * @return int Nb of resources loaded
+ */
+ public function fetchElementResources($element, $element_id)
+ {
+ $resources = $this->getElementResources($element, $element_id);
+ $i = 0;
+ foreach ($resources as $nb => $resource) {
+ $this->lines[$i] = fetchObjectByElement($resource['resource_id'], $resource['resource_type']);
+ $i++;
+ }
+ return $i;
+ }
+
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Load in cache resource type code (setup in dictionary)
+ *
+ * @return int Number of lines loaded, 0 if already loaded, <0 if KO
+ */
+ public function load_cache_code_type_resource()
+ {
+ // phpcs:enable
+ global $langs;
+
+ if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge
+
+ $sql = "SELECT rowid, code, label, active";
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_type_resource";
+ $sql .= " WHERE active > 0";
+ $sql .= " ORDER BY rowid";
+ dol_syslog(get_class($this)."::load_cache_code_type_resource", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
+ $label = ($langs->trans("ResourceTypeShort".$obj->code) != ("ResourceTypeShort".$obj->code) ? $langs->trans("ResourceTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
+ $this->cache_code_type_resource[$obj->rowid]['code'] = $obj->code;
+ $this->cache_code_type_resource[$obj->rowid]['label'] = $label;
+ $this->cache_code_type_resource[$obj->rowid]['active'] = $obj->active;
+ $i++;
+ }
+ return $num;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
+
+ /**
+ * Return clicable link of object (with eventually picto)
+ *
+ * @param int $withpicto Add picto into link
+ * @param string $option Where point the link ('compta', 'expedition', 'document', ...)
+ * @param string $get_params Parametres added to url
+ * @param int $notooltip 1=Disable tooltip
+ * @param string $morecss Add more css on link
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string String with URL
+ */
+ public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
+ {
+ global $conf, $langs;
+
+ $result = '';
+ $label = ''.$langs->trans("ShowResource").'';
+ $label .= '
';
+ $label .= ''.$langs->trans('Ref').': '.$this->ref;
+ /*if (isset($this->status)) {
$label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(5);
}*/
- if (isset($this->type_label)) {
- $label .= '
'.$langs->trans("ResourceType").": ".$this->type_label;
- }
-
- $url = DOL_URL_ROOT.'/resource/card.php?id='.$this->id;
-
- if ($option != 'nolink')
- {
- // Add param to save lastsearch_values or not
- $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
- if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
- }
-
- $linkclose = '';
- if (empty($notooltip))
- {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
- $label = $langs->trans("ShowMyObject");
- $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
- }
- $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
- } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
-
- $linkstart = '';
- $linkend = '';
- /*$linkstart = '';
+ if (isset($this->type_label)) {
+ $label .= '
'.$langs->trans("ResourceType").": ".$this->type_label;
+ }
+
+ $url = DOL_URL_ROOT.'/resource/card.php?id='.$this->id;
+
+ if ($option != 'nolink')
+ {
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
+ if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ }
+
+ $linkclose = '';
+ if (empty($notooltip))
+ {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ {
+ $label = $langs->trans("ShowMyObject");
+ $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
+ }
+ else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+
+ $linkstart = '';
+ $linkend = '';
+ /*$linkstart = '';
$linkend = '';*/
- $result .= $linkstart;
- if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
- if ($withpicto != 2) $result .= $this->ref;
- $result .= $linkend;
-
- return $result;
- }
-
-
- /**
- * Retourne le libelle du status d'un user (actif, inactif)
- *
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
- * @return string Label of status
- */
- public function getLibStatut($mode = 0)
- {
- return $this->LibStatut($this->status, $mode);
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Return the status
- *
- * @param int $status Id status
- * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
- * @return string Label of status
- */
- public static function LibStatut($status, $mode = 0)
- {
- // phpcs:enable
- global $langs;
-
- return '';
- }
+ $result .= $linkstart;
+ if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ if ($withpicto != 2) $result .= $this->ref;
+ $result .= $linkend;
+
+ return $result;
+ }
+
+
+ /**
+ * Retourne le libelle du status d'un user (actif, inactif)
+ *
+ * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @return string Label of status
+ */
+ public function getLibStatut($mode = 0)
+ {
+ return $this->LibStatut($this->status, $mode);
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Return the status
+ *
+ * @param int $status Id status
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
+ * @return string Label of status
+ */
+ public static function LibStatut($status, $mode = 0)
+ {
+ // phpcs:enable
+ global $langs;
+
+ return '';
+ }
}
--- /tmp/dsg/dolibarr/htdocs/resource/class/github_html.formresource.class.php
+++ /tmp/dsg/dolibarr/htdocs/resource/class/client_html.formresource.class.php
@@ -34,177 +34,181 @@
*/
class FormResource
{
- /**
- * @var DoliDB Database handler.
- */
- public $db;
-
- public $substit = array();
-
- public $param = array();
-
- /**
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ public $substit = array();
+
+ public $param = array();
+
+ /**
* @var string Error code (or message)
*/
public $error = '';
/**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
- $this->db = $db;
- }
-
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Output html form to select a resource
- *
- * @param int $selected Preselected resource id
- * @param string $htmlname Name of field in form
- * @param string $filter Optionnal filters criteras (example: 's.rowid <> x')
- * @param int $showempty Add an empty field
- * @param int $showtype Show third party type in combolist (customer, prospect or supplier)
- * @param int $forcecombo Force to use combo box
- * @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
- * @param string $filterkey Filter on key value
- * @param int $outputmode 0=HTML select string, 1=Array, 2=without form tag
- * @param int $limit Limit number of answers
- * @param string $morecss More css
- * @return string HTML string with
- */
- public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '')
- {
- // phpcs:enable
- global $conf, $user, $langs;
-
- $out = '';
- $outarray = array();
-
- $resourcestat = new Dolresource($this->db);
-
- $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, 0, $filter);
-
- if ($outputmode != 2)
- {
- $out = '