Add warehouse modify and create triggers.
Clean and remove deprecated vars.
This commit is contained in:
parent
902351cbaa
commit
9b164b907c
@ -182,16 +182,17 @@ class Entrepot extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Creation d'un entrepot en base
|
* Creation d'un entrepot en base
|
||||||
*
|
*
|
||||||
* @param User $user Object user that create the warehouse
|
* @param User $user Object user that create the warehouse
|
||||||
|
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||||
* @return int >0 if OK, =<0 if KO
|
* @return int >0 if OK, =<0 if KO
|
||||||
*/
|
*/
|
||||||
public function create($user)
|
public function create($user, $notrigger = false)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$this->label = trim(!empty($this->label) ? $this->label : $this->libelle);
|
$this->label = trim($this->label);
|
||||||
|
|
||||||
// Error if label not defined
|
// Error if label not defined
|
||||||
if ($this->label == '') {
|
if ($this->label == '') {
|
||||||
@ -222,14 +223,21 @@ class Entrepot extends CommonObject
|
|||||||
|
|
||||||
// Actions on extra fields
|
// Actions on extra fields
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
if (!$error) {
|
$result = $this->insertExtraFields();
|
||||||
$result = $this->insertExtraFields();
|
if ($result < 0) {
|
||||||
if ($result < 0) {
|
$error++;
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$error && !$notrigger) {
|
||||||
|
// Call triggers
|
||||||
|
$result = $this->call_trigger('WAREHOUSE_CREATE', $user);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $id;
|
return $id;
|
||||||
@ -254,11 +262,12 @@ class Entrepot extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Update properties of a warehouse
|
* Update properties of a warehouse
|
||||||
*
|
*
|
||||||
* @param int $id id of warehouse to modify
|
* @param int $id id of warehouse to modify
|
||||||
* @param User $user User object
|
* @param User $user User object
|
||||||
|
* @param bool $notrigger false=launch triggers after, true=disable trigge
|
||||||
* @return int >0 if OK, <0 if KO
|
* @return int >0 if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function update($id, $user)
|
public function update($id, $user, $notrigger = false)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -267,9 +276,6 @@ class Entrepot extends CommonObject
|
|||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
$id = $this->id;
|
$id = $this->id;
|
||||||
}
|
}
|
||||||
if (empty($this->label)) {
|
|
||||||
$this->label = $this->libelle; // For backward compatibility
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if new parent is already a child of current warehouse
|
// Check if new parent is already a child of current warehouse
|
||||||
if (!empty($this->fk_parent)) {
|
if (!empty($this->fk_parent)) {
|
||||||
@ -281,7 +287,7 @@ class Entrepot extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->label = trim(!empty($this->label) ? $this->label : $this->libelle);
|
$this->label = trim($this->label);
|
||||||
|
|
||||||
$this->description = trim($this->description);
|
$this->description = trim($this->description);
|
||||||
|
|
||||||
@ -324,6 +330,15 @@ class Entrepot extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$error && !$notrigger) {
|
||||||
|
// Call triggers
|
||||||
|
$result = $this->call_trigger('WAREHOUSE_MODIFY', $user);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
@ -461,7 +476,6 @@ class Entrepot extends CommonObject
|
|||||||
$this->fk_project = $obj->fk_project;
|
$this->fk_project = $obj->fk_project;
|
||||||
$this->ref = $obj->label;
|
$this->ref = $obj->label;
|
||||||
$this->label = $obj->label;
|
$this->label = $obj->label;
|
||||||
$this->libelle = $obj->label; // deprecated
|
|
||||||
$this->description = $obj->description;
|
$this->description = $obj->description;
|
||||||
$this->statut = $obj->statut;
|
$this->statut = $obj->statut;
|
||||||
$this->lieu = $obj->lieu;
|
$this->lieu = $obj->lieu;
|
||||||
@ -705,7 +719,7 @@ class Entrepot extends CommonObject
|
|||||||
if (isset($this->statut)) {
|
if (isset($this->statut)) {
|
||||||
$label .= ' '.$this->getLibStatut(5);
|
$label .= ' '.$this->getLibStatut(5);
|
||||||
}
|
}
|
||||||
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.(empty($this->ref) ? (empty($this->label) ? $this->libelle : $this->label) : $this->ref);
|
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.(empty($this->ref) ? $this->label : $this->ref);
|
||||||
if (!empty($this->lieu)) {
|
if (!empty($this->lieu)) {
|
||||||
$label .= '<br><b>'.$langs->trans('LocationSummary').':</b> '.$this->lieu;
|
$label .= '<br><b>'.$langs->trans('LocationSummary').':</b> '.$this->lieu;
|
||||||
}
|
}
|
||||||
@ -742,7 +756,7 @@ class Entrepot extends CommonObject
|
|||||||
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||||
}
|
}
|
||||||
if ($withpicto != 2) {
|
if ($withpicto != 2) {
|
||||||
$result .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : (empty($this->label) ? $this->libelle : $this->label));
|
$result .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : $this->label);
|
||||||
}
|
}
|
||||||
$result .= $linkend;
|
$result .= $linkend;
|
||||||
|
|
||||||
@ -798,7 +812,7 @@ class Entrepot extends CommonObject
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $user, $langs, $conf;
|
global $user, $langs, $conf;
|
||||||
|
|
||||||
$TArbo = array(empty($this->label) ? $this->libelle : $this->label);
|
$TArbo = array($this->label);
|
||||||
|
|
||||||
$protection = 100; // We limit depth of warehouses to 100
|
$protection = 100; // We limit depth of warehouses to 100
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user