From 9cd3b7add3546a227efd37d00f27d04f37a70409 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Fri, 19 Jan 2024 12:16:29 +0100 Subject: [PATCH] #509 [Hook] add: training session durations info on contract --- class/actions_dolimeet.class.php | 20 ++++++++++++++++++-- langs/en_US/dolimeet.lang | 2 +- langs/fr_FR/dolimeet.lang | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index 80c8fe5..3bac708 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -403,7 +403,7 @@ function fillTable(data) { // Handle consistency of contract trainingsession dates $session = new Session($this->db); - $filter = ' AND t.type = "trainingsession" AND t.fk_contrat = ' . $object->id . ' ORDER BY t.date_start ASC'; + $filter = ' AND t.status >= 0 AND t.type = "trainingsession" AND t.fk_contrat = ' . $object->id . ' ORDER BY t.date_start ASC'; $session->fetch('', '', $filter); $out = img_picto('', 'check', 'class="marginleftonly"'); @@ -415,7 +415,7 @@ function fillTable(data) { id . ' ORDER BY t.date_end DESC'; + $filter = ' AND t.status >= 0 AND t.type = "trainingsession" AND t.fk_contrat = ' . $object->id . ' ORDER BY t.date_end DESC'; $session->fetch('', '', $filter); $out = img_picto('', 'check', 'class="marginleftonly"'); @@ -427,6 +427,22 @@ function fillTable(data) { = 0 AND t.type = "trainingsession" AND t.fk_contrat = ' . $object->id; + $sessions = $session->fetchAll('', '', 0, 0, ['customsql' => $filter]); + if (is_array($sessions) && !empty($sessions)) { + foreach ($sessions as $session) { + $sessionDurations += $session->duration; + } + $out = '' . $langs->transnoentities('TrainingSessionDurations') . ''; + $out .= '' . ($sessionDurations > 0 ? convertSecondToTime($sessionDurations, 'allhourmin') : '00:00') . ''; + } ?> + + id > 0) { print ''; diff --git a/langs/en_US/dolimeet.lang b/langs/en_US/dolimeet.lang index a3719c7..57bbc19 100644 --- a/langs/en_US/dolimeet.lang +++ b/langs/en_US/dolimeet.lang @@ -114,7 +114,7 @@ DontForgotAddSessionTrainerAndTrainee = Remember to add at least one trainer and AttendantsFromContract = Contract attendants TrainingSessionStartErrorMatchingDate = Error: consistency of course start dates.
The start date of the contract is not equal to the start date of the first training session %s. TrainingSessionEndErrorMatchingDate = Error: consistency of course end dates.
The end date of the training contract is not equal to the end date of the last training session %s. - +TrainingSessionDurations = Duration of training sessions # Attendant role diff --git a/langs/fr_FR/dolimeet.lang b/langs/fr_FR/dolimeet.lang index cc0ec40..20bb094 100644 --- a/langs/fr_FR/dolimeet.lang +++ b/langs/fr_FR/dolimeet.lang @@ -127,6 +127,7 @@ LinkDolimeet_trainsess = Activer le lien avec les sessions de for LinkDolimeet_trainsessDescription = Permet la liaison entre les sessions de formations et les modèles de contrôle TrainingSessionStartErrorMatchingDate = Erreur : cohérence des dates de début de la formation.
La date de début de la formation du contrat n'est pas égale à la date début de la première session de formation %s. TrainingSessionEndErrorMatchingDate = Erreur : cohérence des dates de fin de la formation.
La date de fin de la formation du contrat n'est pas égale à la date fin de la dernière session de formation %s. +TrainingSessionDurations = Durée des sessions de formation