Merge pull request #6904 from OPEN-DSI/core_holiday_add_triggers
NEW Core Holiday: Add triggers for create, update and delete functions of the class Holiday
This commit is contained in:
commit
d9cdad6a77
@ -248,7 +248,7 @@ if ($action == 'update')
|
|||||||
$object->halfday = $halfday;
|
$object->halfday = $halfday;
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
$verif = $object->update($user->id);
|
$verif = $object->update($user);
|
||||||
if ($verif > 0)
|
if ($verif > 0)
|
||||||
{
|
{
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||||
@ -285,7 +285,7 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights-
|
|||||||
// Si l'utilisateur à le droit de lire cette demande, il peut la supprimer
|
// Si l'utilisateur à le droit de lire cette demande, il peut la supprimer
|
||||||
if ($canedit)
|
if ($canedit)
|
||||||
{
|
{
|
||||||
$result=$object->delete($object->id);
|
$result=$object->delete($user);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -318,7 +318,7 @@ if ($action == 'confirm_send')
|
|||||||
{
|
{
|
||||||
$object->statut = 2;
|
$object->statut = 2;
|
||||||
|
|
||||||
$verif = $object->update($user->id);
|
$verif = $object->update($user);
|
||||||
|
|
||||||
// Si pas d'erreur SQL on redirige vers la fiche de la demande
|
// Si pas d'erreur SQL on redirige vers la fiche de la demande
|
||||||
if ($verif > 0)
|
if ($verif > 0)
|
||||||
@ -419,7 +419,7 @@ if ($action == 'confirm_valid')
|
|||||||
$object->fk_user_valid = $user->id;
|
$object->fk_user_valid = $user->id;
|
||||||
$object->statut = 3;
|
$object->statut = 3;
|
||||||
|
|
||||||
$verif = $object->update($user->id);
|
$verif = $object->update($user);
|
||||||
|
|
||||||
// Si pas d'erreur SQL on redirige vers la fiche de la demande
|
// Si pas d'erreur SQL on redirige vers la fiche de la demande
|
||||||
if ($verif > 0)
|
if ($verif > 0)
|
||||||
@ -506,7 +506,7 @@ if ($action == 'confirm_refuse')
|
|||||||
$object->statut = 5;
|
$object->statut = 5;
|
||||||
$object->detail_refuse = $_POST['detail_refuse'];
|
$object->detail_refuse = $_POST['detail_refuse'];
|
||||||
|
|
||||||
$verif = $object->update($user->id);
|
$verif = $object->update($user);
|
||||||
|
|
||||||
// Si pas d'erreur SQL on redirige vers la fiche de la demande
|
// Si pas d'erreur SQL on redirige vers la fiche de la demande
|
||||||
if ($verif > 0)
|
if ($verif > 0)
|
||||||
@ -586,7 +586,7 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes')
|
|||||||
$object->fk_user_cancel = $user->id;
|
$object->fk_user_cancel = $user->id;
|
||||||
$object->statut = 4;
|
$object->statut = 4;
|
||||||
|
|
||||||
$result = $object->update($user->id);
|
$result = $object->update($user);
|
||||||
|
|
||||||
if ($result >= 0 && $oldstatus == 3) // holiday was already validated, status 3, so we must increase back sold
|
if ($result >= 0 && $oldstatus == 3) // holiday was already validated, status 3, so we must increase back sold
|
||||||
{
|
{
|
||||||
|
|||||||
@ -167,6 +167,14 @@ class Holiday extends CommonObject
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday");
|
||||||
|
|
||||||
|
if (! $notrigger)
|
||||||
|
{
|
||||||
|
// Call trigger
|
||||||
|
$result=$this->call_trigger('HOLIDAY_CREATE',$user);
|
||||||
|
if ($result < 0) { $error++; }
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit or rollback
|
// Commit or rollback
|
||||||
@ -603,7 +611,13 @@ class Holiday extends CommonObject
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
|
if (! $notrigger)
|
||||||
|
{
|
||||||
|
// Call trigger
|
||||||
|
$result=$this->call_trigger('HOLIDAY_MODIFY',$user);
|
||||||
|
if ($result < 0) { $error++; }
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit or rollback
|
// Commit or rollback
|
||||||
@ -650,7 +664,13 @@ class Holiday extends CommonObject
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
|
if (! $notrigger)
|
||||||
|
{
|
||||||
|
// Call trigger
|
||||||
|
$result=$this->call_trigger('HOLIDAY_DELETE',$user);
|
||||||
|
if ($result < 0) { $error++; }
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit or rollback
|
// Commit or rollback
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user