forked from Wavyzz/dolibarr
wotk on declaration method OrderLine
This commit is contained in:
@@ -48,7 +48,7 @@ class Commande extends CommonOrder
|
||||
public $fk_element = 'fk_commande';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
public $picto = 'order';
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -810,11 +810,11 @@ 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 (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
|
||||
$fk_parent_line = 0;
|
||||
@@ -906,10 +906,10 @@ class Commande extends CommonOrder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
|
||||
$sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
|
||||
|
||||
|
||||
$resqlcontact = $this->db->query($sqlcontact);
|
||||
if ($resqlcontact)
|
||||
{
|
||||
@@ -1972,10 +1972,11 @@ class Commande extends CommonOrder
|
||||
/**
|
||||
* Delete an order line
|
||||
*
|
||||
* @param User $user User object
|
||||
* @param int $lineid Id of line to delete
|
||||
* @return int >0 if OK, 0 if nothing to do, <0 if KO
|
||||
*/
|
||||
function deleteline($lineid)
|
||||
function deleteline($user=null, $lineid=0)
|
||||
{
|
||||
|
||||
if ($this->statut == self::STATUS_DRAFT)
|
||||
@@ -2002,7 +2003,7 @@ class Commande extends CommonOrder
|
||||
// For triggers
|
||||
$line->fetch($lineid);
|
||||
|
||||
if ($line->delete() > 0)
|
||||
if ($line->delete($user) > 0)
|
||||
{
|
||||
$result=$this->update_price(1);
|
||||
|
||||
@@ -2387,7 +2388,7 @@ class Commande extends CommonOrder
|
||||
function availability($availability_id, $notrigger=0)
|
||||
{
|
||||
global $user;
|
||||
|
||||
|
||||
dol_syslog('Commande::availability('.$availability_id.')');
|
||||
if ($this->statut >= self::STATUS_DRAFT)
|
||||
{
|
||||
@@ -2457,7 +2458,7 @@ class Commande extends CommonOrder
|
||||
function demand_reason($demand_reason_id, $notrigger=0)
|
||||
{
|
||||
global $user;
|
||||
|
||||
|
||||
dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
|
||||
if ($this->statut >= self::STATUS_DRAFT)
|
||||
{
|
||||
@@ -2740,7 +2741,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null)
|
||||
{
|
||||
global $conf, $mysoc, $langs;
|
||||
global $conf, $mysoc, $langs, $user;
|
||||
|
||||
dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
@@ -2885,7 +2886,7 @@ class Commande extends CommonOrder
|
||||
$this->line->array_options=$array_options;
|
||||
}
|
||||
|
||||
$result=$this->line->update();
|
||||
$result=$this->line->update($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
// Reorder if child line
|
||||
@@ -3805,9 +3806,11 @@ class OrderLine extends CommonOrderLine
|
||||
/**
|
||||
* Delete line in database
|
||||
*
|
||||
* @param User $user User that modify
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function delete()
|
||||
function delete($user=null, $notrigger=0)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
@@ -3833,10 +3836,13 @@ class OrderLine extends CommonOrderLine
|
||||
}
|
||||
}
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINEORDER_DELETE',$user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINEORDER_DELETE',$user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
@@ -3861,12 +3867,13 @@ class OrderLine extends CommonOrderLine
|
||||
/**
|
||||
* Insert line into database
|
||||
*
|
||||
* @param User $user User that modify
|
||||
* @param int $notrigger 1 = disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function insert($notrigger=0)
|
||||
function insert($user=null, $notrigger=0)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
global $langs, $conf;
|
||||
|
||||
$error=0;
|
||||
|
||||
@@ -4004,12 +4011,13 @@ class OrderLine extends CommonOrderLine
|
||||
/**
|
||||
* Update the line object into db
|
||||
*
|
||||
* @param User $user User that modify
|
||||
* @param int $notrigger 1 = disable triggers
|
||||
* @return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function update($notrigger=0)
|
||||
function update($user=null, $notrigger=0)
|
||||
{
|
||||
global $conf,$langs,$user;
|
||||
global $conf,$langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user