mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 09:02:59 +01:00
Mutualize code
This commit is contained in:
@@ -489,6 +489,82 @@ class MyObject extends CommonObject
|
||||
return $this->deleteLineCommon($user, $idline, $notrigger);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set draft status
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function setDraft($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status <= self::STATUS_DRAFT)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate))))
|
||||
{
|
||||
$this->error='Permission denied';
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'BOM_UNVALIDATE');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cancel status
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @return int <0 if KO, 0=Nothing done, >0 if OK
|
||||
*/
|
||||
public function cancel($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_VALIDATED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate))))
|
||||
{
|
||||
$this->error='Permission denied';
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'BOM_CLOSE');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set back to validated status
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @return int <0 if KO, 0=Nothing done, >0 if OK
|
||||
*/
|
||||
public function reopen($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_CANCELED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate))))
|
||||
{
|
||||
$this->error='Permission denied';
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'BOM_REOPEN');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a link to the object card (with optionaly the picto)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user