From 20d1a89c0740a304e57c2d8ee6ffcc17e3f6dba2 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Tue, 28 May 2013 10:05:49 +0200 Subject: [PATCH] Update contrat.class.php Add get_element_list function for return list of element (intervention linked to the contract) --- htdocs/contrat/class/contrat.class.php | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index f5bdfb0d0db..d0599d75ef9 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2071,6 +2071,48 @@ class ContratLigne return -2; } } + + /** + * Load elements linked to contract (only intervention for the moment) + * + * @param User $user Objet type + * @return array $elements array of linked elements + */ + function get_element_list($type) + { + $elements = array(); + + $sql = ''; + if ($type == 'intervention') + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "fichinter WHERE fk_contrat=" . $this->id; + if (! $sql) return -1; + + //print $sql; + dol_syslog(get_class($this)."::get_element_list sql=" . $sql); + $result = $this->db->query($sql); + if ($result) + { + $nump = $this->db->num_rows($result); + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = $this->db->fetch_object($result); + $elements[$i] = $obj->rowid; + $i++; + } + $this->db->free($result); + /* Return array */ + return $elements; + } + } + else + { + dol_print_error($this->db); + } + } + }