From 5203ddc253c6575a5e6db3827ee9007ab4b0ddb3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Jul 2016 17:22:24 +0200 Subject: [PATCH] FIX Missing $user --- htdocs/commande/class/commande.class.php | 126 +---------------------- 1 file changed, 4 insertions(+), 122 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ac6386c0574..523efb99cae 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2301,127 +2301,6 @@ class Commande extends CommonOrder } } - /** - * Set availability - * - * @param User $user Object user making change - * @param int $id If of availability delay - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers - * @return int <0 if KO, >0 if OK - */ - function set_availability($user, $id, $notrigger=0) - { - if ($user->rights->commande->creer) - { - $error=0; - - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."commande "; - $sql.= " SET fk_availability = '".$id."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); - if (!$resql) - { - $this->errors[]=$this->db->error(); - $error++; - } - - if (! $error) - { - $this->oldcopy= clone $this; - $this->fk_availability = $id; - } - - if (! $notrigger && empty($error)) - { - // Call trigger - $result=$this->call_trigger('ORDER_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers - } - - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - foreach($this->errors as $errmsg) - { - dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - } - } - - /** - * Set source of demand - * - * @param User $user Object user making change - * @param int $id Id of source - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers - * @return int <0 if KO, >0 if OK - */ - function set_demand_reason($user, $id, $notrigger=0) - { - if ($user->rights->commande->creer) - { - - $error=0; - - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."commande "; - $sql.= " SET fk_input_reason = '".$id."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); - if (!$resql) - { - $this->errors[]=$this->db->error(); - $error++; - } - - if (! $error) - { - $this->oldcopy= clone $this; - $this->fk_input_reason = $id; - } - - if (! $notrigger && empty($error)) - { - // Call trigger - $result=$this->call_trigger('ORDER_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers - } - - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - foreach($this->errors as $errmsg) - { - dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - } - } - /** * Return list of orders (eventuelly filtered on a user) into an array * @@ -2504,6 +2383,8 @@ class Commande extends CommonOrder */ function availability($availability_id, $notrigger=0) { + global $user; + dol_syslog('Commande::availability('.$availability_id.')'); if ($this->statut >= self::STATUS_DRAFT) { @@ -2572,6 +2453,8 @@ 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) { @@ -2704,7 +2587,6 @@ class Commande extends CommonOrder */ function classifyBilled(User $user, $notrigger=0) { - global $user; $error = 0; $this->db->begin();