Fix: Correct a no more working request

This commit is contained in:
Laurent Destailleur 2010-09-06 20:55:32 +00:00
parent 264df5d3a6
commit f91b786de6

View File

@ -757,20 +757,21 @@ class Expedition extends CommonObject
*/ */
function fetch_lines() 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 = "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.= ", 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.= ", 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.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
$sql.= " ".MAIN_DB_PREFIX."commandedet as cd)"; // FIXME utiliser llx_element_element $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.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product";
$sql.= " WHERE ed.fk_expedition = ".$this->id; $sql.= " WHERE ed.fk_expedition = ".$this->id;
$sql.= " AND r.fk_child = ed.rowid"; //$sql.= " AND r.fk_child = ed.rowid";
$sql.= " AND r.childtype = '".$this->element."'"; //$sql.= " AND r.childtype = '".$this->element."'";
$sql.= " AND ed.fk_origin_line = cd.rowid"; // FIXME utiliser llx_element_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); dol_syslog("Expedition::fetch_lines sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);