diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 2dbadb02a68..2d80a4327c6 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -979,39 +979,43 @@ class Propal } } - /** - * \brief Renvoie un tableau contenant les commandes associées - * \remarks Fonction plus lourde que commande_liste_array - * \sa commande_liste_array - */ - function associated_orders () + /** + * \brief Renvoie un tableau contenant les commandes associées + * \remarks Fonction plus lourde que commande_liste_array + * \sa commande_liste_array + */ + function associated_orders() { - $ga = array(); + $ga = array(); + + $sql = "SELECT fk_commande FROM ".MAIN_DB_PREFIX."co_pr"; + $sql.= " WHERE fk_propale = " . $this->id; + if ($this->db->query($sql) ) + { + $nump = $this->db->num_rows(); + + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = $this->db->fetch_object(); + $order=new Commande($this->db); - $sql = "SELECT fk_commande FROM ".MAIN_DB_PREFIX."co_pr"; - $sql .= " WHERE fk_propale = " . $this->id; - if ($this->db->query($sql) ) - { - $nump = $this->db->num_rows(); - - if ($nump) - { - $i = 0; - while ($i < $nump) - { - $obj = $this->db->fetch_object(); - $order=new Commande($this->db); - $order->fetch($obj->fk_commande); - $ga[$i] = $order; - $i++; - } - } - return $ga; - } - else - { - print $this->db->error(); - } + if ($obj->fk_commande) + { + $order->fetch($obj->fk_commande); + $ga[$i] = $order; + } + $i++; + } + } + return $ga; + } + else + { + print $this->db->error(); + } } /**