From f91b786de6d058738c9eae25499ef8ef76d9961f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2010 20:55:32 +0000 Subject: [PATCH] Fix: Correct a no more working request --- htdocs/expedition/class/expedition.class.php | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 802cd5eb20a..34a489edbb3 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -237,13 +237,13 @@ class Expedition extends CommonObject $this->rang = 0; // TODO en attendant une gestion de la disposition $this->addRangOfLine($this->rowid,$this->element,$this->rang); - + return 1; } else { return -1; - } + } } /** @@ -560,7 +560,7 @@ class Expedition extends CommonObject if ($this->db->query($sql) ) { $this->update_price(); - + $this->delRangOfLine($lineid, $this->element); return 1; @@ -689,7 +689,7 @@ class Expedition extends CommonObject { // Delete all rang of lines $this->delAllRangOfLines(); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element"; $sql.= " WHERE fk_target = ".$this->id; $sql.= " AND targettype = '".$this->element."'"; @@ -757,20 +757,21 @@ class Expedition extends CommonObject */ function fetch_lines() { - // TODO: recuperer les champs du document associe a part - $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.qty as qty_asked"; $sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; $sql.= ", p.ref, p.fk_product_type, p.label, p.weight, p.weight_units, p.volume, p.volume_units"; $sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,"; $sql.= " ".MAIN_DB_PREFIX."commandedet as cd)"; // FIXME utiliser llx_element_element - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'"; + // FIXME: There is a bug when using a join with element_rang and + // condition outside of left join. This give unpredicable results. + // $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'"; + // Getting a "sort order" must be done outside of the request to get values $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; $sql.= " WHERE ed.fk_expedition = ".$this->id; - $sql.= " AND r.fk_child = ed.rowid"; - $sql.= " AND r.childtype = '".$this->element."'"; + //$sql.= " AND r.fk_child = ed.rowid"; + //$sql.= " AND r.childtype = '".$this->element."'"; $sql.= " AND ed.fk_origin_line = cd.rowid"; // FIXME utiliser llx_element_element - $sql.= " ORDER by r.rang"; + //$sql.= " ORDER by r.rang"; dol_syslog("Expedition::fetch_lines sql=".$sql); $resql = $this->db->query($sql);