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

@ -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);