Fix Propal class doesn't have fetch_lines method yet
This commit is contained in:
parent
676ff84a4e
commit
88515c306f
@ -1366,30 +1366,58 @@ class Propal extends CommonObject
|
|||||||
$this->lines = array();
|
$this->lines = array();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lignes propales liees a un produit ou non
|
* Lines
|
||||||
*/
|
*/
|
||||||
$sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,";
|
$result=$this->fetch_lines();
|
||||||
$sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,";
|
if ($result < 0)
|
||||||
$sql.= " d.fk_unit,";
|
{
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->error="Record Not Found";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load array lines
|
||||||
|
*
|
||||||
|
* @param int $only_product Return only physical products
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function fetch_lines($only_product=0)
|
||||||
|
{
|
||||||
|
$this->lines=array();
|
||||||
|
|
||||||
|
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
|
||||||
|
$sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,';
|
||||||
|
$sql.= ' d.fk_unit,';
|
||||||
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
|
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
|
||||||
$sql.= ' d.date_start, d.date_end';
|
$sql.= ' d.date_start, d.date_end';
|
||||||
$sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
|
$sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d";
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as d';
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (d.fk_product = p.rowid)';
|
||||||
$sql.= " WHERE d.fk_propal = ".$this->id;
|
$sql.= ' WHERE d.fk_propal = '.$this->id;
|
||||||
$sql.= " ORDER by d.rang";
|
if ($only_product) $sql .= ' AND p.fk_product_type = 0';
|
||||||
|
$sql.= ' ORDER by d.rang';
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
$extrafieldsline=new ExtraFields($this->db);
|
|
||||||
$line = new PropaleLigne($this->db);
|
|
||||||
$extralabelsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true);
|
|
||||||
|
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$objp = $this->db->fetch_object($result);
|
$objp = $this->db->fetch_object($result);
|
||||||
@ -1447,32 +1475,22 @@ class Propal extends CommonObject
|
|||||||
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
|
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
|
||||||
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
|
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
|
||||||
|
|
||||||
$line->fetch_optionals($line->id,$extralabelsline);
|
$line->fetch_optionals();
|
||||||
|
|
||||||
$this->lines[$i] = $line;
|
$this->lines[$i] = $line;
|
||||||
//dol_syslog("1 ".$line->fk_product);
|
//dol_syslog("1 ".$line->fk_product);
|
||||||
//print "xx $i ".$this->lines[$i]->fk_product;
|
//print "xx $i ".$this->lines[$i]->fk_product;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->db->free($result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->error=$this->db->lasterror();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$this->db->free($result);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->error="Record Not Found";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
return -1;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user