Skip to content

Commit

Permalink
Merge pull request #521 from nicolas-eoxia/add_TrainingSessionDurations
Browse files Browse the repository at this point in the history
#509 [Hook] add: training session durations info on contract
  • Loading branch information
nicolas-eoxia authored Jan 19, 2024
2 parents 9db6630 + 9cd3b7a commit c5dc3a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
20 changes: 18 additions & 2 deletions class/actions_dolimeet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"');
Expand All @@ -415,7 +415,7 @@ function fillTable(data) {
</script>
<?php

$filter = ' AND t.type = "trainingsession" AND t.fk_contrat = ' . $object->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"');
Expand All @@ -427,6 +427,22 @@ function fillTable(data) {
</script>
<?php

// Handle session durations
$sessionDurations = 0;
$filter = 't.status >= 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 = '<tr class="trextrafields_collapse_' . $object->id . '"><td class="titlefield">' . $langs->transnoentities('TrainingSessionDurations') . '</td>';
$out .= '<td id="' . $object->element . '_extras_trainingsession_durations_' . $object->id . '" class="valuefield ' . $object->element . '_extras_trainingsession_durations">' . ($sessionDurations > 0 ? convertSecondToTime($sessionDurations, 'allhourmin') : '00:00') . '</td></tr>';
} ?>
<script>
jQuery('.contrat_extras_trainingsession_location').closest('.trextrafields_collapse_' + <?php echo $object->id; ?>).after(<?php echo json_encode($out); ?>);
</script>
<?php

// Handle saturne_show_documents for completion certificate document generation
if ($session->id > 0) {
print '<link rel="stylesheet" type="text/css" href="../custom/saturne/css/saturne.min.css">';
Expand Down
2 changes: 1 addition & 1 deletion langs/en_US/dolimeet.lang
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ DontForgotAddSessionTrainerAndTrainee = Remember to add at least one trainer and
AttendantsFromContract = Contract attendants
TrainingSessionStartErrorMatchingDate = <strong> Error: consistency of course start dates. </strong><br> The start date of the contract is not equal to the start date of the first training session %s.
TrainingSessionEndErrorMatchingDate = <strong> Error: consistency of course end dates. </strong><br> 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
Expand Down
1 change: 1 addition & 0 deletions langs/fr_FR/dolimeet.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <strong> Erreur : cohérence des dates de début de la formation. </strong><br> 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 = <strong> Erreur : cohérence des dates de fin de la formation. </strong><br> 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



Expand Down

0 comments on commit c5dc3a4

Please sign in to comment.