forked from Wavyzz/dolibarr
NEW New REST API explorer. Can create invoice and orders with lines.
This commit is contained in:
@@ -693,8 +693,8 @@ class Commande extends CommonOrder
|
||||
* Note that this->ref can be set or empty. If empty, we will use "(PROV)"
|
||||
*
|
||||
* @param User $user Objet user that make creation
|
||||
* @param int $notrigger Disable all triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $notrigger Disable all triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function create($user, $notrigger=0)
|
||||
{
|
||||
@@ -808,37 +808,43 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$line = $this->lines[$i];
|
||||
|
||||
// Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
|
||||
//if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object.
|
||||
if (! is_object($line)) $line = (object) $line;
|
||||
|
||||
// Reset fk_parent_line for no child products and 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;
|
||||
}
|
||||
|
||||
$result = $this->addline(
|
||||
$this->lines[$i]->desc,
|
||||
$this->lines[$i]->subprice,
|
||||
$this->lines[$i]->qty,
|
||||
$this->lines[$i]->tva_tx,
|
||||
$this->lines[$i]->localtax1_tx,
|
||||
$this->lines[$i]->localtax2_tx,
|
||||
$this->lines[$i]->fk_product,
|
||||
$this->lines[$i]->remise_percent,
|
||||
$this->lines[$i]->info_bits,
|
||||
$this->lines[$i]->fk_remise_except,
|
||||
$line->desc,
|
||||
$line->subprice,
|
||||
$line->qty,
|
||||
$line->tva_tx,
|
||||
$line->localtax1_tx,
|
||||
$line->localtax2_tx,
|
||||
$line->fk_product,
|
||||
$line->remise_percent,
|
||||
$line->info_bits,
|
||||
$line->fk_remise_except,
|
||||
'HT',
|
||||
0,
|
||||
$this->lines[$i]->date_start,
|
||||
$this->lines[$i]->date_end,
|
||||
$this->lines[$i]->product_type,
|
||||
$this->lines[$i]->rang,
|
||||
$this->lines[$i]->special_code,
|
||||
$line->date_start,
|
||||
$line->date_end,
|
||||
$line->product_type,
|
||||
$line->rang,
|
||||
$line->special_code,
|
||||
$fk_parent_line,
|
||||
$this->lines[$i]->fk_fournprice,
|
||||
$this->lines[$i]->pa_ht,
|
||||
$this->lines[$i]->label,
|
||||
$this->lines[$i]->array_options,
|
||||
$this->lines[$i]->fk_unit,
|
||||
$line->fk_fournprice,
|
||||
$line->pa_ht,
|
||||
$line->label,
|
||||
$line->array_options,
|
||||
$line->fk_unit,
|
||||
$this->element,
|
||||
$this->lines[$i]->id
|
||||
$line->id
|
||||
);
|
||||
if ($result < 0)
|
||||
{
|
||||
@@ -851,7 +857,7 @@ class Commande extends CommonOrder
|
||||
return -1;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user