wotk on declaration method OrderLine

This commit is contained in:
florian HENRY 2016-09-26 09:34:51 +02:00
parent 108537746c
commit 5a8f0491b3
4 changed files with 184 additions and 176 deletions

View File

@ -183,7 +183,7 @@ if (empty($reshook))
// Remove a product line // Remove a product line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer)
{ {
$result = $object->deleteline($lineid); $result = $object->deleteline($user, $lineid);
if ($result > 0) if ($result > 0)
{ {
// Define output language // Define output language

View File

@ -401,7 +401,7 @@ class CommandeApi extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$request_data = (object) $request_data; $request_data = (object) $request_data;
$updateRes = $this->commande->deleteline($lineid); $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
if ($updateRes == 1) { if ($updateRes == 1) {
return $this->get($id); return $this->get($id);
} }

View File

@ -365,7 +365,7 @@ class Orders extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$request_data = (object) $request_data; $request_data = (object) $request_data;
$updateRes = $this->commande->deleteline($lineid); $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
if ($updateRes == 1) { if ($updateRes == 1) {
return $this->get($id); return $this->get($id);
} }

View File

@ -1972,10 +1972,11 @@ class Commande extends CommonOrder
/** /**
* Delete an order line * Delete an order line
* *
* @param User $user User object
* @param int $lineid Id of line to delete * @param int $lineid Id of line to delete
* @return int >0 if OK, 0 if nothing to do, <0 if KO * @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) if ($this->statut == self::STATUS_DRAFT)
@ -2002,7 +2003,7 @@ class Commande extends CommonOrder
// For triggers // For triggers
$line->fetch($lineid); $line->fetch($lineid);
if ($line->delete() > 0) if ($line->delete($user) > 0)
{ {
$result=$this->update_price(1); $result=$this->update_price(1);
@ -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) 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"); 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'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -2885,7 +2886,7 @@ class Commande extends CommonOrder
$this->line->array_options=$array_options; $this->line->array_options=$array_options;
} }
$result=$this->line->update(); $result=$this->line->update($user);
if ($result > 0) if ($result > 0)
{ {
// Reorder if child line // Reorder if child line
@ -3805,9 +3806,11 @@ class OrderLine extends CommonOrderLine
/** /**
* Delete line in database * 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 * @return int <0 si ko, >0 si ok
*/ */
function delete() function delete($user=null, $notrigger=0)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
@ -3833,10 +3836,13 @@ class OrderLine extends CommonOrderLine
} }
} }
// Call trigger if (! $error && ! $notrigger)
$result=$this->call_trigger('LINEORDER_DELETE',$user); {
if ($result < 0) $error++; // Call trigger
// End call triggers $result=$this->call_trigger('LINEORDER_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (!$error) { if (!$error) {
$this->db->commit(); $this->db->commit();
@ -3861,12 +3867,13 @@ class OrderLine extends CommonOrderLine
/** /**
* Insert line into database * Insert line into database
* *
* @param User $user User that modify
* @param int $notrigger 1 = disable triggers * @param int $notrigger 1 = disable triggers
* @return int <0 if KO, >0 if OK * @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; $error=0;
@ -4004,12 +4011,13 @@ class OrderLine extends CommonOrderLine
/** /**
* Update the line object into db * Update the line object into db
* *
* @param User $user User that modify
* @param int $notrigger 1 = disable triggers * @param int $notrigger 1 = disable triggers
* @return int <0 si ko, >0 si ok * @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; $error=0;