[proposals]Allow lines to be added from REST API
Prevously, only void lines was added. Need to convert array lines to object in this case.
This commit is contained in:
parent
7288c18574
commit
f3f182b5bc
@ -1005,48 +1005,56 @@ class Propal extends CommonObject
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Insertion du detail des produits dans la base
|
* Insertion du detail des produits dans la base
|
||||||
|
* Insert products detail in database
|
||||||
*/
|
*/
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
|
if (! is_object($this->lines[$i])) // If this->lines is not array of objects, coming from REST API
|
||||||
|
{ // Convert into object this->lines[$i].
|
||||||
|
$line = (object) $this->lines[$i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$line = $this->lines[$i];
|
||||||
|
}
|
||||||
$fk_parent_line=0;
|
$fk_parent_line=0;
|
||||||
$num=count($this->lines);
|
$num=count($this->lines);
|
||||||
|
|
||||||
for ($i=0;$i<$num;$i++)
|
for ($i=0;$i<$num;$i++)
|
||||||
{
|
{
|
||||||
// Reset fk_parent_line for line that are not child lines or special product
|
// Reset fk_parent_line for line that are not child lines or special product
|
||||||
if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) {
|
if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
|
||||||
$fk_parent_line = 0;
|
$fk_parent_line = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Complete vat rate with code
|
// Complete vat rate with code
|
||||||
$vatrate = $this->lines[$i]->tva_tx;
|
$vatrate = $line->tva_tx;
|
||||||
if ($this->lines[$i]->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$this->lines[$i]->vat_src_code.')';
|
if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')';
|
||||||
|
|
||||||
$result = $this->addline(
|
$result = $this->addline(
|
||||||
$this->lines[$i]->desc,
|
$line->desc,
|
||||||
$this->lines[$i]->subprice,
|
$line->subprice,
|
||||||
$this->lines[$i]->qty,
|
$line->qty,
|
||||||
$vatrate,
|
$vatrate,
|
||||||
$this->lines[$i]->localtax1_tx,
|
$line->localtax1_tx,
|
||||||
$this->lines[$i]->localtax2_tx,
|
$line->localtax2_tx,
|
||||||
$this->lines[$i]->fk_product,
|
$line->fk_product,
|
||||||
$this->lines[$i]->remise_percent,
|
$line->remise_percent,
|
||||||
'HT',
|
'HT',
|
||||||
0,
|
0,
|
||||||
$this->lines[$i]->info_bits,
|
$line->info_bits,
|
||||||
$this->lines[$i]->product_type,
|
$line->product_type,
|
||||||
$this->lines[$i]->rang,
|
$line->rang,
|
||||||
$this->lines[$i]->special_code,
|
$line->special_code,
|
||||||
$fk_parent_line,
|
$fk_parent_line,
|
||||||
$this->lines[$i]->fk_fournprice,
|
$line->fk_fournprice,
|
||||||
$this->lines[$i]->pa_ht,
|
$line->pa_ht,
|
||||||
$this->lines[$i]->label,
|
$line->label,
|
||||||
$this->lines[$i]->date_start,
|
$line->date_start,
|
||||||
$this->lines[$i]->date_end,
|
$line->date_end,
|
||||||
$this->lines[$i]->array_options,
|
$line->array_options,
|
||||||
$this->lines[$i]->fk_unit,
|
$line->fk_unit,
|
||||||
$this->element,
|
$this->element,
|
||||||
$this->lines[$i]->id
|
$line->id
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
@ -1057,7 +1065,7 @@ class Propal extends CommonObject
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Defined the new fk_parent_line
|
// Defined the new fk_parent_line
|
||||||
if ($result > 0 && $this->lines[$i]->product_type == 9) {
|
if ($result > 0 && $line->product_type == 9) {
|
||||||
$fk_parent_line = $result;
|
$fk_parent_line = $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user