From 8412a915762bf7a6a60986dc7a2e9f93290e2ada Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 14:58:46 +0100 Subject: [PATCH] Fix do not send email if approval error --- htdocs/holiday/card.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 165c65d8cc6..af6772828dc 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -334,7 +334,7 @@ if ($action == 'confirm_send') $object->fetch($id); // Si brouillon et créateur - if($object->statut == Holiday::STATUS_DRAFT && $cancreate) + if ($object->statut == Holiday::STATUS_DRAFT && $cancreate) { $object->oldcopy = dol_clone($object); @@ -379,7 +379,7 @@ if ($action == 'confirm_send') $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); // Si l'option pour avertir le valideur en cas de délai trop court - if($object->getConfCP('AlertValidatorDelay')) + if ($object->getConfCP('AlertValidatorDelay')) { if($object->date_debut < $nextMonth) { @@ -460,7 +460,7 @@ if ($action == 'confirm_valid') if (! $error) { // Calculcate number of days consummed - $nbopenedday=num_open_day($object->date_debut_gmt,$object->date_fin_gmt,0,1,$object->halfday); + $nbopenedday=num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); $newSolde = ($soldeActuel - $nbopenedday); @@ -469,7 +469,7 @@ if ($action == 'confirm_valid') if ($result < 0) { $error++; - setEventMessages(null, $object->errors,'errors'); + setEventMessages(null, $object->errors, 'errors'); } //Update balance @@ -477,9 +477,12 @@ if ($action == 'confirm_valid') if ($result < 0) { $error++; - setEventMessages(null, $object->errors,'errors'); + setEventMessages(null, $object->errors, 'errors'); } + } + if (! $error) + { // To $destinataire = new User($db); $destinataire->fetch($object->fk_user); @@ -505,7 +508,7 @@ if ($action == 'confirm_valid') // Content $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; $message.= "\n"; - $message.= $langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut,'day'),dol_print_date($object->date_fin,'day'))."\n"; + $message.= $langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; $message.= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; @@ -594,7 +597,7 @@ if ($action == 'confirm_refuse' && GETPOST('confirm','alpha') == 'yes') // Content $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; $message.= "\n"; - $message.= $langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut,'day'), dol_print_date($object->date_fin,'day'))."\n"; + $message.= $langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; $message.= GETPOST('detail_refuse','alpha')."\n\n"; $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n";