From e56cb710c6b551053d130f1f14b2e7428a695b73 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Wed, 31 Jan 2024 12:26:08 +0100 Subject: [PATCH 01/23] #529 [Trigger] fix: check version error --- .../interface_99_modDoliMeet_DoliMeetTriggers.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/triggers/interface_99_modDoliMeet_DoliMeetTriggers.class.php b/core/triggers/interface_99_modDoliMeet_DoliMeetTriggers.class.php index 6542e93..52c6b90 100644 --- a/core/triggers/interface_99_modDoliMeet_DoliMeetTriggers.class.php +++ b/core/triggers/interface_99_modDoliMeet_DoliMeetTriggers.class.php @@ -219,7 +219,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf break; case 'CONTRAT_ADD_CONTACT' : - if (isset($object->array_options['options_trainingsession_type']) && !empty($object->array_options['options_trainingsession_type']) && isModEnabled('digiquali') && getDolGlobalString('DIGIQUALI_VERSION') >= '1.11.0') { + if (isset($object->array_options['options_trainingsession_type']) && !empty($object->array_options['options_trainingsession_type']) && isModEnabled('digiquali') && version_compare(getDolGlobalString('DIGIQUALI_VERSION'), '1.11.0', '>=')) { require_once __DIR__ . '/../../lib/dolimeet_function.lib.php'; if (GETPOST('userid')) { From 82d51845289ec1671df5794d41370f76e5e51a73 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Wed, 31 Jan 2024 15:24:27 +0100 Subject: [PATCH 02/23] #524 [Langs] add: info tooltip on trainingsession contract extrafields --- core/modules/modDoliMeet.class.php | 16 ++++++++-------- langs/en_US/dolimeet.lang | 4 ++++ langs/fr_FR/dolimeet.lang | 4 ++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/core/modules/modDoliMeet.class.php b/core/modules/modDoliMeet.class.php index 745a348..97c7c6e 100644 --- a/core/modules/modDoliMeet.class.php +++ b/core/modules/modDoliMeet.class.php @@ -586,17 +586,17 @@ public function init($options = ''): int $extraFields->update('label', $langs->transnoentities('Label'), 'varchar', '', 'contrat', 0, 0, 1040, '', '', '', 1); $extraFields->addExtraField('label', $langs->transnoentities('Label'), 'varchar', 1040, '', 'contrat', 0, 0, '', '', '', '', 1); - $extraFields->update('trainingsession_start', $langs->transnoentities('TrainingSessionStart'), 'datetime', '', 'contrat', 0, 0, 1800, '', '', '', 1); - $extraFields->addExtraField('trainingsession_start', $langs->transnoentities('TrainingSessionStart'), 'datetime', 1040, '', 'contrat', 0, 0, '', '', '', '', 1); + $extraFields->update('trainingsession_start', $langs->transnoentities('TrainingSessionStart'), 'datetime', '', 'contrat', 0, 0, 1800, '', '', '', 1, 'TrainingSessionStartHelp'); + $extraFields->addExtraField('trainingsession_start', $langs->transnoentities('TrainingSessionStart'), 'datetime', 1040, '', 'contrat', 0, 0, '', '', '', '', 1, 'TrainingSessionStartHelp'); - $extraFields->update('trainingsession_end', $langs->transnoentities('TrainingSessionEnd'), 'datetime', '', 'contrat', 0, 0, 1810, '', '', '', 1); - $extraFields->addExtraField('trainingsession_end', $langs->transnoentities('TrainingSessionEnd'), 'datetime', 1040, '', 'contrat', 0, 0, '', '', '', '', 1); + $extraFields->update('trainingsession_end', $langs->transnoentities('TrainingSessionEnd'), 'datetime', '', 'contrat', 0, 0, 1810, '', '', '', 1, 'TrainingSessionEndHelp'); + $extraFields->addExtraField('trainingsession_end', $langs->transnoentities('TrainingSessionEnd'), 'datetime', 1040, '', 'contrat', 0, 0, '', '', '', '', 'TrainingSessionEndHelp'); - $extraFields->update('trainingsession_type', $langs->transnoentities('TrainingSessionType'), 'sellist', '', 'contrat', 0, 0, 1830, 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', '', '', 1); - $extraFields->addExtraField('trainingsession_type', $langs->transnoentities('TrainingSessionType'), 'sellist', 1830, '', 'contrat', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', '', '', 1); + $extraFields->update('trainingsession_type', $langs->transnoentities('TrainingSessionType'), 'sellist', '', 'contrat', 0, 0, 1830, 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', '', '', 1, 'TrainingSessionTypeHelp'); + $extraFields->addExtraField('trainingsession_type', $langs->transnoentities('TrainingSessionType'), 'sellist', 1830, '', 'contrat', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', '', '', 1, 'TrainingSessionTypeHelp'); - $extraFields->update('trainingsession_location', $langs->transnoentities('TrainingSessionLocation'), 'varchar', '', 'contrat', 0, 0, 1850, '', '', '', 1); - $extraFields->addExtraField('trainingsession_location', $langs->transnoentities('TrainingSessionLocation'), 'varchar', 1850, '', 'contrat', 0, 0, '', '', '', '', 1); + $extraFields->update('trainingsession_location', $langs->transnoentities('TrainingSessionLocation'), 'varchar', '', 'contrat', 0, 0, 1850, '', '', '', 1, 'TrainingSessionLocationHelp'); + $extraFields->addExtraField('trainingsession_location', $langs->transnoentities('TrainingSessionLocation'), 'varchar', 1850, '', 'contrat', 0, 0, '', '', '', '', 1, 'TrainingSessionLocationHelp'); return $this->_init($sql, $options); } diff --git a/langs/en_US/dolimeet.lang b/langs/en_US/dolimeet.lang index 57bbc19..3451658 100644 --- a/langs/en_US/dolimeet.lang +++ b/langs/en_US/dolimeet.lang @@ -115,6 +115,10 @@ 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 +TrainingSessionStartHelp = Start date of the first training session of the contract +TrainingSessionEndHelp = End date of the last training session of the contract +TrainingSessionTypeHelp = Type of training session linked to the contract +TrainingSessionLocationHelp = Place where the training session linked to the contract took place # Attendant role diff --git a/langs/fr_FR/dolimeet.lang b/langs/fr_FR/dolimeet.lang index 20bb094..9205622 100644 --- a/langs/fr_FR/dolimeet.lang +++ b/langs/fr_FR/dolimeet.lang @@ -128,6 +128,10 @@ LinkDolimeet_trainsessDescription = Permet la liaison entre les sessions de 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 +TrainingSessionStartHelp = Date de début de la première session de formation du contrat +TrainingSessionEndHelp = Date de fin de la dernière session de formation du contrat +TrainingSessionTypeHelp = Type de formation liée au contrat +TrainingSessionLocationHelp = Lieu où s'est réalisé la formation liée au contrat From ad983867c0a350e48212327649a5a0622d65ba43 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Wed, 7 Feb 2024 11:40:57 +0100 Subject: [PATCH 03/23] #531 [Session] fix: navigation between objects fromType --- view/session/session_list.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/view/session/session_list.php b/view/session/session_list.php index 86db1f8..b64a99c 100644 --- a/view/session/session_list.php +++ b/view/session/session_list.php @@ -224,6 +224,15 @@ $permissiontodelete = $user->rights->dolimeet->$objectType->delete; saturne_check_access($permissionToRead, null, true); +// For the custom navigation, get the next/prev id from the ref +// If the fromID doesn't correspond to the id from the ref then we reload page with good ID +if (!empty($objectLinked) && is_object($objectLinked)) { + $objectLinked->fetch(0, $ref); + if ($objectLinked->id != $fromID) { + header('Location: ' . dol_buildpath('/custom/dolimeet/view/session/session_list.php', 1) . '?fromtype='. $fromType .'&fromid=' . $objectLinked->id . '&object_type=trainingsession'); + } +} + /* * Actions */ @@ -460,8 +469,9 @@ if (!empty($fromType) && !$error) { saturne_get_fiche_head($objectLinked, 'sessionList', $langs->trans($objectType)); - //TODO Shownav must be 0 because navigation between fromObject can't be done while saturne_banner_tab not fix - saturne_banner_tab($objectLinked, 'ref', $moreHtml, 0); + + $moreParams['bannerTab'] = '&fromtype='. $fromType .'&fromid=' . $objectLinked->id . '&object_type=trainingsession'; + saturne_banner_tab($objectLinked, 'ref', $moreHtml, 1, 'ref', 'ref', '', false, $moreParams); } $arrayofselected = is_array($toselect) ? $toselect : []; From f50cac0e1ff679d5d2f7f3f6c8114e6aff0caaa3 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Wed, 7 Feb 2024 12:17:07 +0100 Subject: [PATCH 04/23] #524 [Hook] add: picto before contrat extrafields --- class/actions_dolimeet.class.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index 3bac708..0696b88 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -400,6 +400,9 @@ function fillTable(data) { saturne_load_langs(); + $pictoPath = dol_buildpath('/custom/dolimeet/img/dolimeet_color.png', 1); + $picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule'); + // Handle consistency of contract trainingsession dates $session = new Session($this->db); @@ -411,6 +414,7 @@ function fillTable(data) { $out = $form->textwithpicto('', $langs->trans('TrainingSessionStartErrorMatchingDate', $session->ref), 1, 'warning'); } ?> textwithpicto('', $langs->trans('TrainingSessionEndErrorMatchingDate', $session->ref), 1, 'warning'); } ?> duration; } $out = '' . $langs->transnoentities('TrainingSessionDurations') . ''; - $out .= '' . ($sessionDurations > 0 ? convertSecondToTime($sessionDurations, 'allhourmin') : '00:00') . ''; - } ?> + $out .= '' . $picto . ($sessionDurations > 0 ? convertSecondToTime($sessionDurations, 'allhourmin') : '00:00') . ''; + ?> + + Date: Wed, 7 Feb 2024 14:37:34 +0100 Subject: [PATCH 05/23] #531 [Session] fix: remove fetch and use PHP_SELF --- view/session/session_list.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/view/session/session_list.php b/view/session/session_list.php index b64a99c..ecdb046 100644 --- a/view/session/session_list.php +++ b/view/session/session_list.php @@ -182,7 +182,7 @@ $objectLinked = null; } if (!$error) { - $objectLinked->fetch($fromID); + !empty($ref) ? $objectLinked->fetch(0, $ref) : $objectLinked->fetch($fromID); } $linkedObjectsArray = ['thirdparty', 'project', 'contrat']; $signatoryObjectsArray = ['user', 'socpeople']; @@ -227,9 +227,8 @@ // For the custom navigation, get the next/prev id from the ref // If the fromID doesn't correspond to the id from the ref then we reload page with good ID if (!empty($objectLinked) && is_object($objectLinked)) { - $objectLinked->fetch(0, $ref); if ($objectLinked->id != $fromID) { - header('Location: ' . dol_buildpath('/custom/dolimeet/view/session/session_list.php', 1) . '?fromtype='. $fromType .'&fromid=' . $objectLinked->id . '&object_type=trainingsession'); + header('Location: ' . $_SERVER['PHP_SELF'] . '?fromtype='. $fromType .'&fromid=' . $objectLinked->id . '&object_type=trainingsession'); } } From aba2e27695f8a87ae6104d98cf66292de8915fa9 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Wed, 7 Feb 2024 15:39:46 +0100 Subject: [PATCH 06/23] #527 [Hook] fix: dont generate certificate for absent --- class/actions_dolimeet.class.php | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index 3bac708..2bcfd6b 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -845,10 +845,16 @@ public function saturneBuildDoc(array $parameters, CommonObject $object, string $document = new CompletioncertificateDocument($this->db); $signatory = new SaturneSignature($this->db, 'dolimeet', $object->element); - $duration = 0; - $sessions = $session->fetchAll('', '', 0, 0, ['customsql' => 't.fk_contrat = ' . $object->id . ' AND t.status >= 0']); + $duration = 0; + $signedTrainee = []; + $sessions = $session->fetchAll('', '', 0, 0, ['customsql' => 't.fk_contrat = ' . $object->id . ' AND t.status >= 0']); if (is_array($sessions) && !empty($sessions)) { foreach ($sessions as $session) { + $signatories = $signatory->fetchSignatories($session->id, 'trainingsession', 'role = "Trainee" AND status = 5'); + foreach ($signatories as $signatory) { + $signedTrainee[] = $signatory->element_id; + } + $signedTrainee = array_unique($signedTrainee); $duration += $session->duration; } $lastSession = end($sessions); @@ -872,16 +878,18 @@ public function saturneBuildDoc(array $parameters, CommonObject $object, string if (!empty($contactList)) { foreach ($contactList as $contact) { - $parameters['moreparams']['attendant'] = $signatory; - $parameters['moreparams']['attendant']->firstname = $contact['firstname']; - $parameters['moreparams']['attendant']->lastname = $contact['lastname']; - $parameters['moreparams']['attendant']->element_type = ($contact['source'] == 'external' ? 'socpeople' : 'user'); - $parameters['moreparams']['attendant']->element_id = $contact['id']; - - $document->element = 'trainingsessiondocument'; - $result = $document->generateDocument((!empty($parameters['models']) ? $parameters['models'][1] : $parameters['model']), $parameters['outputlangs'], $parameters['hidedetails'], $parameters['hidedesc'], $parameters['hideref'], $parameters['moreparams']); - if ($result <= 0) { - setEventMessages($document->error, $document->errors, 'errors'); + if (in_array($contact['id'], $signedTrainee)) { + $parameters['moreparams']['attendant'] = $signatory; + $parameters['moreparams']['attendant']->firstname = $contact['firstname']; + $parameters['moreparams']['attendant']->lastname = $contact['lastname']; + $parameters['moreparams']['attendant']->element_type = ($contact['source'] == 'external' ? 'socpeople' : 'user'); + $parameters['moreparams']['attendant']->element_id = $contact['id']; + + $document->element = 'trainingsessiondocument'; + $result = $document->generateDocument((!empty($parameters['models']) ? $parameters['models'][1] : $parameters['model']), $parameters['outputlangs'], $parameters['hidedetails'], $parameters['hidedesc'], $parameters['hideref'], $parameters['moreparams']); + if ($result <= 0) { + setEventMessages($document->error, $document->errors, 'errors'); + } } } From 2d42433f32c4fdf1b2a14d337545b10d8b439a34 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Fri, 9 Feb 2024 11:00:40 +0100 Subject: [PATCH 07/23] #536 [Substitutions] fix: delete parameter in public url signature --- core/substitutions/functions_dolimeet.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/substitutions/functions_dolimeet.lib.php b/core/substitutions/functions_dolimeet.lib.php index 203ae84..4b6ff4c 100644 --- a/core/substitutions/functions_dolimeet.lib.php +++ b/core/substitutions/functions_dolimeet.lib.php @@ -62,7 +62,7 @@ function dolimeet_completesubstitutionarray(array &$substitutionarray, Translate foreach ($signatories as $signatory) { $substitutionarray['__DOLIMEET_CONTRACT_TRAININGSESSION_INFOS__'] .= '
  • ' . strtoupper($signatory->lastname) . ' ' . $signatory->firstname . ' - ' . $signatory->getLibStatut(5) . (($signatory->status == SaturneSignature::STATUS_REGISTERED) ? ' - ' . $langs->transnoentities('PendingSignature') : '') . ''; if ($signatoryRole != 'SessionTrainer') { - $signatureUrl = dol_buildpath('/custom/saturne/public/signature/add_signature.php?track_id=' . $signatory->signature_url . '&entity=' . $conf->entity . '&module_name=dolimeet&object_type=' . $session->type . '&document_type=AttendanceSheetDocument&modal_to_open=modal-signature' . $signatory->id, 3); + $signatureUrl = dol_buildpath('/custom/saturne/public/signature/add_signature.php?track_id=' . $signatory->signature_url . '&entity=' . $conf->entity . '&module_name=dolimeet&object_type=' . $session->type . '&document_type=AttendanceSheetDocument', 3); $substitutionarray['__DOLIMEET_CONTRACT_TRAININGSESSION_INFOS__'] .= ' - ' . $langs->transnoentities('SignAttendanceSheetOnline') . ''; } $substitutionarray['__DOLIMEET_CONTRACT_TRAININGSESSION_INFOS__'] .= '
'; From 02bf5ae47c7fdc25d8b9a7abf064e048a0eb79b5 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Fri, 9 Feb 2024 15:45:24 +0100 Subject: [PATCH 08/23] #535 [Hook] fix: generate certificate with personal duration --- class/actions_dolimeet.class.php | 43 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index 2bcfd6b..d720c7b 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -845,17 +845,18 @@ public function saturneBuildDoc(array $parameters, CommonObject $object, string $document = new CompletioncertificateDocument($this->db); $signatory = new SaturneSignature($this->db, 'dolimeet', $object->element); - $duration = 0; $signedTrainee = []; $sessions = $session->fetchAll('', '', 0, 0, ['customsql' => 't.fk_contrat = ' . $object->id . ' AND t.status >= 0']); if (is_array($sessions) && !empty($sessions)) { foreach ($sessions as $session) { - $signatories = $signatory->fetchSignatories($session->id, 'trainingsession', 'role = "Trainee" AND status = 5'); + $signatories = $signatory->fetchSignatories($session->id, 'trainingsession', 'role = "Trainee" AND status = ' . SaturneSignature::STATUS_SIGNED . ' AND attendance IS NULL'); foreach ($signatories as $signatory) { - $signedTrainee[] = $signatory->element_id; + if ($signatory->element_type == 'user') { + $signedTrainee['internal'][$signatory->element_id] += $session->duration; + } else { + $signedTrainee['external'][$signatory->element_id] += $session->duration; + } } - $signedTrainee = array_unique($signedTrainee); - $duration += $session->duration; } $lastSession = end($sessions); $dateEnd = $lastSession->date_end; @@ -866,29 +867,31 @@ public function saturneBuildDoc(array $parameters, CommonObject $object, string $contactList = []; foreach (['internal', 'external'] as $source) { - $contactList = array_merge($contactList, $object->liste_contact(-1, $source, 0, 'TRAINEE')); + $contactList[$source] = $object->liste_contact(-1, $source, 0, 'TRAINEE'); } $parameters['moreparams']['object'] = $object; $parameters['moreparams']['object']->element = 'trainingsession'; $parameters['moreparams']['object']->date_start = $object->array_options['options_trainingsession_start']; $parameters['moreparams']['object']->date_end = $object->array_options['options_trainingsession_end']; - $parameters['moreparams']['object']->duration = $duration; $parameters['moreparams']['object']->fk_contrat = $object->id; - if (!empty($contactList)) { - foreach ($contactList as $contact) { - if (in_array($contact['id'], $signedTrainee)) { - $parameters['moreparams']['attendant'] = $signatory; - $parameters['moreparams']['attendant']->firstname = $contact['firstname']; - $parameters['moreparams']['attendant']->lastname = $contact['lastname']; - $parameters['moreparams']['attendant']->element_type = ($contact['source'] == 'external' ? 'socpeople' : 'user'); - $parameters['moreparams']['attendant']->element_id = $contact['id']; - - $document->element = 'trainingsessiondocument'; - $result = $document->generateDocument((!empty($parameters['models']) ? $parameters['models'][1] : $parameters['model']), $parameters['outputlangs'], $parameters['hidedetails'], $parameters['hidedesc'], $parameters['hideref'], $parameters['moreparams']); - if ($result <= 0) { - setEventMessages($document->error, $document->errors, 'errors'); + if (!empty($contactList) && !empty($signedTrainee)) { + foreach ($contactList as $contactType) { + foreach($contactType as $contact) { + if (array_key_exists($contact['id'], $signedTrainee[$contact['source']])) { + $parameters['moreparams']['attendant'] = $signatory; + $parameters['moreparams']['attendant']->firstname = $contact['firstname']; + $parameters['moreparams']['attendant']->lastname = $contact['lastname']; + $parameters['moreparams']['attendant']->element_type = ($contact['source'] == 'external' ? 'socpeople' : 'user'); + $parameters['moreparams']['attendant']->element_id = $contact['id']; + $parameters['moreparams']['object']->duration = $signedTrainee[$contact['source']][$contact['id']]; + + $document->element = 'trainingsessiondocument'; + $result = $document->generateDocument((!empty($parameters['models']) ? $parameters['models'][1] : $parameters['model']), $parameters['outputlangs'], $parameters['hidedetails'], $parameters['hidedesc'], $parameters['hideref'], $parameters['moreparams']); + if ($result <= 0) { + setEventMessages($document->error, $document->errors, 'errors'); + } } } } From 98a5a15ea8914472271f160521cd41fd1e9f4655 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Wed, 21 Feb 2024 17:09:51 +0100 Subject: [PATCH 09/23] #535 [Hook] fix: separate duration time and calculated session time --- class/actions_dolimeet.class.php | 34 +++++++++++++++++++++++++----- core/modules/modDoliMeet.class.php | 3 +++ langs/en_US/dolimeet.lang | 4 +++- langs/fr_FR/dolimeet.lang | 3 +++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index 0696b88..9a76419 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -440,11 +440,25 @@ function fillTable(data) { foreach ($sessions as $session) { $sessionDurations += $session->duration; } - $out = '' . $langs->transnoentities('TrainingSessionDurations') . ''; - $out .= '' . $picto . ($sessionDurations > 0 ? convertSecondToTime($sessionDurations, 'allhourmin') : '00:00') . ''; - ?> + if (GETPOST('action') == 'edit_extras' && GETPOST('attribute') == 'trainingsession_durations') { + $out = '' . $picto; + $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= $form->select_duration('duration', $object->array_options['options_trainingsession_durations'], 0, 'text', 0, 1); + $out .= '' . ''; + } else { + $out = '' . $picto . ($object->array_options['options_trainingsession_durations'] > 0 ? convertSecondToTime($object->array_options['options_trainingsession_durations'], 'allhourmin') : '00:00') . ' - '; + $out .= $langs->trans('CalculatedTotalSessionDuration') . ' ' . ($sessionDurations > 0 ? convertSecondToTime($sessionDurations, 'allhourmin') : '00:00'); + if ($sessionDurations != $object->array_options['options_trainingsession_durations']) { + $out .= $form->textwithpicto('', $langs->trans('TrainingSessionDurationErrorMatching', $session->ref), 1, 'warning'); + } + $out .= ''; + } ?> array_options['options_trainingsession_durations'] = $duration; + $object->updateExtrafield('trainingsession_durations'); + return 1; + } } return 0; // or return 1 to replace standard code. diff --git a/core/modules/modDoliMeet.class.php b/core/modules/modDoliMeet.class.php index 97c7c6e..7b25d49 100644 --- a/core/modules/modDoliMeet.class.php +++ b/core/modules/modDoliMeet.class.php @@ -598,6 +598,9 @@ public function init($options = ''): int $extraFields->update('trainingsession_location', $langs->transnoentities('TrainingSessionLocation'), 'varchar', '', 'contrat', 0, 0, 1850, '', '', '', 1, 'TrainingSessionLocationHelp'); $extraFields->addExtraField('trainingsession_location', $langs->transnoentities('TrainingSessionLocation'), 'varchar', 1850, '', 'contrat', 0, 0, '', '', '', '', 1, 'TrainingSessionLocationHelp'); + $extraFields->update('trainingsession_durations', $langs->transnoentities('TrainingSessionDurations'), 'int', '', 'contrat', 0, 0, 1860, '', '', '', 1, 'TrainingSessionDurationHelp'); + $extraFields->addExtraField('trainingsession_durations', $langs->transnoentities('TrainingSessionDurations'), 'int', 1860, '', 'contrat', 0, 0, '', '', '', '', 1, 'TrainingSessionDurationHelp'); + return $this->_init($sql, $options); } diff --git a/langs/en_US/dolimeet.lang b/langs/en_US/dolimeet.lang index 3451658..b3abe30 100644 --- a/langs/en_US/dolimeet.lang +++ b/langs/en_US/dolimeet.lang @@ -119,7 +119,9 @@ TrainingSessionStartHelp = Start date of the first training session TrainingSessionEndHelp = End date of the last training session of the contract TrainingSessionTypeHelp = Type of training session linked to the contract TrainingSessionLocationHelp = Place where the training session linked to the contract took place - +TrainingSessionDurationHelp = Total duration of the sessions HH:MM (ex: 60:30)
The duration shown on the certificate corresponds to the total number of hours of sessions attended by a trainee. +CalculatedTotalSessionDuration = Total calculated duration time: +TrainingSessionDurationErrorMatching = Error: consistency of training session duration.
The total duration of the sessions indicated in the contract is different from the calculated duration of all the sessions linked to the contract. # Attendant role SessionTrainer = Trainer diff --git a/langs/fr_FR/dolimeet.lang b/langs/fr_FR/dolimeet.lang index 9205622..9dcca59 100644 --- a/langs/fr_FR/dolimeet.lang +++ b/langs/fr_FR/dolimeet.lang @@ -132,6 +132,9 @@ TrainingSessionStartHelp = Date de début de la première session d TrainingSessionEndHelp = Date de fin de la dernière session de formation du contrat TrainingSessionTypeHelp = Type de formation liée au contrat TrainingSessionLocationHelp = Lieu où s'est réalisé la formation liée au contrat +TrainingSessionDurationHelp = Durée totale des sessions HH:MM (ex: 60:30)
La durée affichée sur le certificat correspond aux heures additionnées des sessions où un stagiaire a été présent. +CalculatedTotalSessionDuration = Durée totale calculée : +TrainingSessionDurationErrorMatching = Erreur : cohérence de la durée des sessions de formation.
La durée totale des sessions indiqué dans le contrat est différente de la durée calculé de l'ensemble des sessions liées au contrat. From 5cfef66c435c140310592efb1b49c72e112c9e5e Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Thu, 22 Feb 2024 14:44:44 +0100 Subject: [PATCH 10/23] #539 [Hook] add: notifiate user for what trainee no certificate generate --- class/actions_dolimeet.class.php | 43 +++++++++++++++++++++++++------- langs/en_US/dolimeet.lang | 1 + langs/fr_FR/dolimeet.lang | 2 +- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index d720c7b..3a1891c 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -845,16 +845,38 @@ public function saturneBuildDoc(array $parameters, CommonObject $object, string $document = new CompletioncertificateDocument($this->db); $signatory = new SaturneSignature($this->db, 'dolimeet', $object->element); + $contactList = []; $signedTrainee = []; $sessions = $session->fetchAll('', '', 0, 0, ['customsql' => 't.fk_contrat = ' . $object->id . ' AND t.status >= 0']); + // We retrieve internal & external user linked to the contract + foreach (['internal', 'external'] as $source) { + $contactList[$source] = $object->liste_contact(-1, $source, 0, 'TRAINEE'); + // We need our array keys to start with 1 for further logic + array_unshift($contactList[$source],''); + unset($contactList[$source][0]); + } + // Because of the structure of $contactList we need a second array where we will remove someone if he is present for ONE session + $absentTrainee = $contactList; + if (is_array($sessions) && !empty($sessions)) { foreach ($sessions as $session) { - $signatories = $signatory->fetchSignatories($session->id, 'trainingsession', 'role = "Trainee" AND status = ' . SaturneSignature::STATUS_SIGNED . ' AND attendance IS NULL'); + $signatories = $signatory->fetchSignatories($session->id, 'trainingsession', 'role = "Trainee"'); foreach ($signatories as $signatory) { - if ($signatory->element_type == 'user') { - $signedTrainee['internal'][$signatory->element_id] += $session->duration; - } else { - $signedTrainee['external'][$signatory->element_id] += $session->duration; + $type = ($signatory->element_type == 'user' ? 'internal' : 'external'); + $absentId = array_column($absentTrainee[$type], 'id'); + + // We search for the key in $contactList corresponding to the current $signatory->element_id + array_unshift($absentId,''); + unset($absentId[0]); + // array_search return false (0) if it doesn't find, that's why we need our $absentTrainee array to start by 1 + $key = array_search($signatory->element_id, $absentId); + + if ($signatory->attendance != SaturneSignature::ATTENDANCE_ABSENT) { + // If the $signatory is present then we will remove it from the $absentTrainee array + if ($key > 0) { + unset($absentTrainee[$type][$key]); + } + $signedTrainee[$type][$signatory->element_id] += $session->duration; } } } @@ -865,9 +887,12 @@ public function saturneBuildDoc(array $parameters, CommonObject $object, string } } - $contactList = []; - foreach (['internal', 'external'] as $source) { - $contactList[$source] = $object->liste_contact(-1, $source, 0, 'TRAINEE'); + if (!empty($absentTrainee)) { + foreach ($absentTrainee as $absentType) { + foreach($absentType as $contact) { + setEventMessages($langs->trans('NoCertificateBecauseAbsent', $contact['lastname'], $contact['firstname']), [], 'warnings'); + } + } } $parameters['moreparams']['object'] = $object; @@ -879,7 +904,7 @@ public function saturneBuildDoc(array $parameters, CommonObject $object, string if (!empty($contactList) && !empty($signedTrainee)) { foreach ($contactList as $contactType) { foreach($contactType as $contact) { - if (array_key_exists($contact['id'], $signedTrainee[$contact['source']])) { + if (is_array($signedTrainee[$contact['source']]) && array_key_exists($contact['id'], $signedTrainee[$contact['source']])) { $parameters['moreparams']['attendant'] = $signatory; $parameters['moreparams']['attendant']->firstname = $contact['firstname']; $parameters['moreparams']['attendant']->lastname = $contact['lastname']; diff --git a/langs/en_US/dolimeet.lang b/langs/en_US/dolimeet.lang index 57bbc19..bb5ee69 100644 --- a/langs/en_US/dolimeet.lang +++ b/langs/en_US/dolimeet.lang @@ -115,6 +115,7 @@ 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 +NoCertificateBecauseAbsent = No certificate was generated for %s %s because it was absent from all sessions. # Attendant role diff --git a/langs/fr_FR/dolimeet.lang b/langs/fr_FR/dolimeet.lang index 20bb094..9db9e2f 100644 --- a/langs/fr_FR/dolimeet.lang +++ b/langs/fr_FR/dolimeet.lang @@ -128,7 +128,7 @@ LinkDolimeet_trainsessDescription = Permet la liaison entre les sessions de 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 - +NoCertificateBecauseAbsent = Aucun certificat n'a été généré pour %s %s parcequ'il a été absent à toute les sessions. # Attendant role - Rôle participant From aadf17310b765601c9e5bc0a31d89885b6cde9af Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Wed, 28 Feb 2024 20:41:15 +0100 Subject: [PATCH 11/23] #506 [Mod] add: email template for satisfaction survey --- core/modules/modDoliMeet.class.php | 31 +++++++++++- core/substitutions/functions_dolimeet.lib.php | 49 ++++++++++++++++++- langs/fr_FR/dolimeet.lang | 13 +++++ 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/core/modules/modDoliMeet.class.php b/core/modules/modDoliMeet.class.php index 745a348..21ef232 100644 --- a/core/modules/modDoliMeet.class.php +++ b/core/modules/modDoliMeet.class.php @@ -221,6 +221,8 @@ public function __construct($db) $i++ => ['DOLIMEET_VERSION','chaine', $this->version, '', 0, 'current'], $i++ => ['DOLIMEET_DB_VERSION', 'chaine', $this->version, '', 0, 'current'], $i++ => ['DOLIMEET_SHOW_PATCH_NOTE', 'integer', 1, '', 0, 'current'], + $i++ => ['DOLIMEET_EMAIL_TEMPLATE_SET', 'integer', 0, '', 0, 'current'], + $i++ => ['DOLIMEET_EMAIL_TEMPLATE_SATISFACTION_SURVEY', 'integer', 0, '', 0, 'current'], // CONST GENERAL CONST. $i++ => ['CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST', 'integer', 1, '', 0, 'current'], @@ -549,7 +551,7 @@ public function __construct($db) */ public function init($options = ''): int { - global $conf, $langs; + global $conf, $langs, $user; // Permissions. $this->remove($options); @@ -579,6 +581,33 @@ public function init($options = ''): int addDocumentModel('completioncertificatedocument_odt', 'trainingsessiondocument', 'ODT templates', 'DOLIMEET_COMPLETIONCERTIFICATEDOCUMENT_ADDON_ODT_PATH'); addDocumentModel('completioncertificatedocument_odt', 'completioncertificatedocument', 'ODT templates', 'DOLIMEET_COMPLETIONCERTIFICATEDOCUMENT_ADDON_ODT_PATH'); + if (getDolGlobalInt('DOLIMEET_EMAIL_TEMPLATE_SET') == 0 && isModEnabled('digiquali') && version_compare(getDolGlobalString('DIGIQUALI_VERSION'), '1.11.0', '>=')) { + // Load Saturne libraries + require_once __DIR__ . '/../../../saturne/class/saturnemail.class.php'; + + $saturneMail = new SaturneMail($this->db, 'contrat'); + + $i = 10; + $satisfactionSurveys = ['customer', 'billing', 'trainee', 'sessiontrainer', 'opco']; + foreach ($satisfactionSurveys as $satisfactionSurvey) { + $saturneMail->entity = 0; + $saturneMail->type_template = 'contract'; + $saturneMail->datec = $this->db->idate(dol_now()); + $saturneMail->label = $langs->transnoentities('SatisfactionSurveyLabel', $langs->transnoentities(ucfirst($satisfactionSurvey))); + $saturneMail->position = $i; + $saturneMail->enabled = "isModEnabled('contrat')"; + $saturneMail->topic = $langs->transnoentities('SatisfactionSurveyTopic', dol_strtolower($langs->transnoentities(ucfirst($satisfactionSurvey)))); + $saturneMail->joinfiles = 1; + $saturneMail->content = $langs->transnoentities('SatisfactionSurveyContent', dol_strtolower($langs->transnoentities(ucfirst($satisfactionSurvey)))); + + $emailTemplateSatisfactionSurvey[$satisfactionSurvey] = $saturneMail->create($user); + $i += 10; + } + + dolibarr_set_const($this->db, 'DOLIMEET_EMAIL_TEMPLATE_SATISFACTION_SURVEY', json_encode($emailTemplateSatisfactionSurvey), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($this->db, 'DOLIMEET_EMAIL_TEMPLATE_SET', 1, 'integer', 0, '', $conf->entity); + } + // Create extrafields during init. require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extraFields = new ExtraFields($this->db); diff --git a/core/substitutions/functions_dolimeet.lib.php b/core/substitutions/functions_dolimeet.lib.php index 4b6ff4c..0f0ca1c 100644 --- a/core/substitutions/functions_dolimeet.lib.php +++ b/core/substitutions/functions_dolimeet.lib.php @@ -34,7 +34,7 @@ */ function dolimeet_completesubstitutionarray(array &$substitutionarray, Translate $langs, $object) { - global $conf, $db; + global $conf, $db, $user; if ($object->element == 'contrat') { // Load Saturne libraries @@ -80,5 +80,52 @@ function dolimeet_completesubstitutionarray(array &$substitutionarray, Translate $substitutionarray['__DOLIMEET_CONTRACT_TRAININGSESSION_END__'] = $object->array_options['options_trainingsession_end']; $substitutionarray['__DOLIMEET_CONTRACT_TRAININGSESSION_TYPE__'] = $object->array_options['options_trainingsession_type']; $substitutionarray['__DOLIMEET_CONTRACT_TRAININGSESSION_LOCATION__'] = $object->array_options['options_trainingsession_location']; + + if (isModEnabled('digiquali') && version_compare(getDolGlobalString('DIGIQUALI_VERSION'), '1.11.0', '>=')) { + // Load DigiQuali libraries + require_once __DIR__ . '/../../../digiquali/class/survey.class.php'; + + $survey = new Survey($db); + + $confEmailTemplateSatisfactionSurvey = json_decode(getDolGlobalString('DOLIMEET_EMAIL_TEMPLATE_SATISFACTION_SURVEY'), true); + $emailModelSelected = GETPOST('modelmailselected', 'int'); + $key = array_search($emailModelSelected, $confEmailTemplateSatisfactionSurvey); + + if ($key !== false) { + $contacts = array_merge($object->liste_contact(-1, 'internal', 0, dol_strtoupper($key)), $object->liste_contact(-1, 'external', 0, dol_strtoupper($key))); + } + + $object->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); + if (is_array($sessions) && !empty($sessions)) { + foreach ($sessions as $session) { + $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '' . $session->ref . ' - ' . $session->label . ''; + $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '
  • ' . $langs->transnoentities('DateAndTime') . ' : ' . dol_strtolower($langs->transnoentities('From')) . ' ' . dol_print_date($session->date_start, 'day', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('At')) . ' ' . dol_print_date($session->date_start, 'hour', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('To')) . ' ' . dol_print_date($session->date_end, 'day', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('At')) . ' ' . dol_print_date($session->date_end, 'hour', 'tzuserrel') . ' (' . dol_strtolower($langs->transnoentities('Duration')) . ' : ' . (($session->duration > 0) ? convertSecondToTime($session->duration, 'allhourmin') : '00:00') . ')' . '
  • '; + if (!empty($contacts)) { + foreach ($contacts as $contact) { + if (isset($object->linkedObjectsIds['digiquali_survey']) && !empty($object->linkedObjectsIds['digiquali_survey'])) { + $surveyIDs = $object->linkedObjectsIds['digiquali_survey']; + arsort($surveyIDs); + foreach ($surveyIDs as $surveyID) { + $confName = 'DOLIMEET_' . $contact['code'] . '_SATISFACTION_SURVEY_SHEET'; + $filter = ' AND e.fk_sheet = ' . $conf->global->$confName; + if (getDolGlobalInt($confName) > 0) { + if ($signatory->checkSignatoryHasObject($surveyID, $survey->table_element, $contact['id'], $contact['source'] == 'internal' ? 'user' : 'socpeople', $filter)) { + $survey->fetch($surveyID); + $signatory->fetch($signatory->id); + $publicAnswerUrl = dol_buildpath('custom/digiquali/public/public_answer.php?track_id=' . $survey->track_id . '&object_type=' . $survey->element . '&entity=' . $conf->entity, 3); + $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= ''; + break; + } + } + } + } + } + } + $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '
'; + } + } + } } } diff --git a/langs/fr_FR/dolimeet.lang b/langs/fr_FR/dolimeet.lang index 20bb094..6f59260 100644 --- a/langs/fr_FR/dolimeet.lang +++ b/langs/fr_FR/dolimeet.lang @@ -215,6 +215,15 @@ AttendancePresentAuditRate = Taux de présence aux audits AttendanceDelayAuditRate = Taux de retard aux audits AttendanceAbsentAuditRate = Taux d'absence aux audits +# +# Email - Email +# + +# Data - Donnée +SatisfactionSurveyLabel = Questionnaire_Satisfaction_%s +SatisfactionSurveyTopic = [__[MAIN_INFO_SOCIETE_NOM]__] Remise des liens de questionnaire de satisfaction %s pour la convention de formation __REF__ +SatisfactionSurveyContent = Bonjour,

Nous vous envoyons ce mail afin de vous mettre au courant des questionnaires de satisfaction %s liées avec votre convention de formation "__REF__" - "__DOLIMEET_CONTRACT_LABEL__".
Ci-dessous, vous trouverez un aperçu des questionnaires, incluant les détails pertinents :

__DOLIMEET_CONTRACT_SURVEY_INFOS__

Nous vous prions de bien vouloir transmettre ces liens aux parties concernées.
Nous restons à votre disposition pour toute information supplémentaire.

Bien cordialement,

__USER_FULLNAME__
__USER_EMAIL__
__MYCOMPANY_NAME__
__MYCOMPANY_FULLADDRESS__
__MYCOMPANY_EMAIL__ + # @@ -231,3 +240,7 @@ SignAttendanceSheetOnline = Signer la feuille de présence en ligne SetSatisfactionSurvey = Créer enquête de satisfaction NeedToSetSatisfactionSurvey = Configuration de l'enquête de satisfaction %s requise DefineSessionTrainerResponsible = Vous devez définir le responsable du dispensateur de formation dans la configuration de DoliMeet. +FillSatisfactionSurvey = Remplir l'enquête de satisfaction %s +Sessiontrainer = Formateur +Billing = Commanditaire +Customer = Client From 36c5e8eb9083e2d20b2d4b28d34665180e5cf873 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Thu, 22 Feb 2024 15:37:06 +0100 Subject: [PATCH 12/23] #531 [Session] fix: fetch only fromid now that bannertab fixed in saturn --- view/session/session_list.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/view/session/session_list.php b/view/session/session_list.php index ecdb046..46e15a1 100644 --- a/view/session/session_list.php +++ b/view/session/session_list.php @@ -182,7 +182,7 @@ $objectLinked = null; } if (!$error) { - !empty($ref) ? $objectLinked->fetch(0, $ref) : $objectLinked->fetch($fromID); + $objectLinked->fetch($fromID); } $linkedObjectsArray = ['thirdparty', 'project', 'contrat']; $signatoryObjectsArray = ['user', 'socpeople']; @@ -224,14 +224,6 @@ $permissiontodelete = $user->rights->dolimeet->$objectType->delete; saturne_check_access($permissionToRead, null, true); -// For the custom navigation, get the next/prev id from the ref -// If the fromID doesn't correspond to the id from the ref then we reload page with good ID -if (!empty($objectLinked) && is_object($objectLinked)) { - if ($objectLinked->id != $fromID) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?fromtype='. $fromType .'&fromid=' . $objectLinked->id . '&object_type=trainingsession'); - } -} - /* * Actions */ @@ -469,8 +461,8 @@ if (!empty($fromType) && !$error) { saturne_get_fiche_head($objectLinked, 'sessionList', $langs->trans($objectType)); - $moreParams['bannerTab'] = '&fromtype='. $fromType .'&fromid=' . $objectLinked->id . '&object_type=trainingsession'; - saturne_banner_tab($objectLinked, 'ref', $moreHtml, 1, 'ref', 'ref', '', false, $moreParams); + $moreParams['bannerTab'] = '&fromtype='. $fromType . '&object_type=trainingsession'; + saturne_banner_tab($objectLinked, 'fromid', $moreHtml, 1, 'rowid', 'ref', '', false, $moreParams); } $arrayofselected = is_array($toselect) ? $toselect : []; From cfb1e1c70ec0489e1b839d02786ee36a6b114498 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Thu, 29 Feb 2024 15:16:45 +0100 Subject: [PATCH 13/23] #535 [Hook] fix: better check handling --- class/actions_dolimeet.class.php | 68 ++++++++++++++++---------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index 9a76419..920e6ff 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -389,6 +389,20 @@ function fillTable(data) { if (strpos($parameters['context'], 'contractcard') !== false) { global $object; + $pictoPath = dol_buildpath('/custom/dolimeet/img/dolimeet_color.png', 1); + $picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule'); + + ?> + + array_options['options_trainingsession_type']) && !empty($object->array_options['options_trainingsession_type'])) { // Load Saturne libraries require_once __DIR__ . '/../../saturne/lib/documents.lib.php'; @@ -400,9 +414,6 @@ function fillTable(data) { saturne_load_langs(); - $pictoPath = dol_buildpath('/custom/dolimeet/img/dolimeet_color.png', 1); - $picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule'); - // Handle consistency of contract trainingsession dates $session = new Session($this->db); @@ -414,7 +425,6 @@ function fillTable(data) { $out = $form->textwithpicto('', $langs->trans('TrainingSessionStartErrorMatchingDate', $session->ref), 1, 'warning'); } ?> textwithpicto('', $langs->trans('TrainingSessionEndErrorMatchingDate', $session->ref), 1, 'warning'); } ?> = 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; + foreach ($sessions as $sessionSingle) { + $sessionDurations += $sessionSingle->duration; } - if (GETPOST('action') == 'edit_extras' && GETPOST('attribute') == 'trainingsession_durations') { - $out = '' . $picto; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= $form->select_duration('duration', $object->array_options['options_trainingsession_durations'], 0, 'text', 0, 1); - $out .= '' . ''; - } else { - $out = '' . $picto . ($object->array_options['options_trainingsession_durations'] > 0 ? convertSecondToTime($object->array_options['options_trainingsession_durations'], 'allhourmin') : '00:00') . ' - '; - $out .= $langs->trans('CalculatedTotalSessionDuration') . ' ' . ($sessionDurations > 0 ? convertSecondToTime($sessionDurations, 'allhourmin') : '00:00'); - if ($sessionDurations != $object->array_options['options_trainingsession_durations']) { - $out .= $form->textwithpicto('', $langs->trans('TrainingSessionDurationErrorMatching', $session->ref), 1, 'warning'); - } - $out .= ''; - } ?> - - + if (GETPOST('action') == 'edit_extras' && GETPOST('attribute') == 'trainingsession_durations') { + $out = '' . $picto; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= $form->select_duration('duration', $object->array_options['options_trainingsession_durations'], 0, 'text', 0, 1); + $out .= '' . ''; + } else { + $out = '' . $picto . ($object->array_options['options_trainingsession_durations'] > 0 ? convertSecondToTime($object->array_options['options_trainingsession_durations'], 'allhourmin') : '00:00') . ' - '; + $out .= $langs->trans('CalculatedTotalSessionDuration') . ' ' . ($sessionDurations > 0 ? convertSecondToTime($sessionDurations, 'allhourmin') : '00:00'); + if ($sessionDurations != $object->array_options['options_trainingsession_durations']) { + $out .= $form->textwithpicto('', $langs->trans('TrainingSessionDurationErrorMatching', $session->ref), 1, 'warning'); + } + $out .= ''; + } ?> Date: Thu, 29 Feb 2024 19:22:31 +0100 Subject: [PATCH 14/23] #543 [Hook] fix: extendSheetLinkableObjectsList missing require lib file --- class/actions_dolimeet.class.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index 3bac708..3b3b765 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -584,20 +584,23 @@ public function doActions(array $parameters, $object, string $action): int public function extendSheetLinkableObjectsList(array $linkableObjectTypes): int { require_once __DIR__ . '/../class/trainingsession.class.php'; + require_once __DIR__ . '/../lib/dolimeet_trainingsession.lib.php'; $trainingSession = new Trainingsession($this->db); $linkableObjectTypes['dolimeet_trainsess'] = [ - 'langs' => 'Trainingsession', - 'langfile' => 'dolimeet@dolimeet', - 'picto' => $trainingSession->picto, - 'className' => 'Trainingsession', - 'post_name' => 'fk_trainingsession', - 'link_name' => 'dolimeet_trainsess', - 'name_field' => 'ref', - 'create_url' => 'custom/dolimeet/view/trainingsession/session_card.php?action=create&object_type=trainingsession', - 'class_path' => 'custom/dolimeet/class/trainingsession.class.php', - 'lib_path' => 'custom/dolimeet/lib/dolimeet_trainingsession.lib.php', + 'langs' => 'Trainingsession', + 'langfile' => 'dolimeet@dolimeet', + 'picto' => $trainingSession->picto, + 'className' => 'Trainingsession', + 'name_field' => 'ref', + 'post_name' => 'fk_trainingsession', + 'link_name' => 'dolimeet_trainsess', + 'tab_type' => 'trainingsession', + 'hook_name_list' => 'trainingsessionlist', + 'hook_name_card' => 'trainingsessioncard', + 'create_url' => 'custom/dolimeet/view/trainingsession/session_card.php?action=create&object_type=trainingsession', + 'class_path' => 'custom/dolimeet/class/trainingsession.class.php' ]; $this->results = $linkableObjectTypes; From ab006335c07485d3a0a83171b8b750dc60db910f Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Thu, 29 Feb 2024 19:32:13 +0100 Subject: [PATCH 15/23] #541 [Admin] add: check sheet type before select --- admin/setup.php | 2 +- langs/fr_FR/dolimeet.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/setup.php b/admin/setup.php index 919ae5d..5ac7ac1 100644 --- a/admin/setup.php +++ b/admin/setup.php @@ -201,7 +201,7 @@ print ''; $confName = 'DOLIMEET_' . dol_strtoupper($satisfactionSurvey) . '_SATISFACTION_SURVEY_SHEET'; - print img_picto($langs->trans('Sheet'), $sheet->picto, 'class="pictofixedwidth"') . $sheet->selectSheetList($conf->global->$confName, $satisfactionSurvey . '_satisfaction_survey_model', '', '1', 0, 0, [], '', 0, 0, 'minwidth400 maxwidth500'); + print img_picto($langs->trans('Sheet'), $sheet->picto, 'class="pictofixedwidth"') . $sheet->selectSheetList($conf->global->$confName, $satisfactionSurvey . '_satisfaction_survey_model', 's.type = "survey" AND s.status = ' . Sheet::STATUS_LOCKED, '1', 0, 0, [], '', 0, 0, 'minwidth400 maxwidth500'); print ''; } diff --git a/langs/fr_FR/dolimeet.lang b/langs/fr_FR/dolimeet.lang index 20bb094..2dcf2ac 100644 --- a/langs/fr_FR/dolimeet.lang +++ b/langs/fr_FR/dolimeet.lang @@ -124,7 +124,7 @@ SessionTrainerResponsible = Responsable du dispensateur de formation SessionTrainerResponsibleDesc = Définit le responsable du dispensateur de formation SessionTrainerResponsibleIdSet = Responsable du dispensateur de formation défini : %s LinkDolimeet_trainsess = Activer le lien avec les sessions de formation -LinkDolimeet_trainsessDescription = Permet la liaison entre les sessions de formations et les modèles de contrôle +LinkDolimeet_trainsessDescription = Permet la liaison entre les sessions de formations et les modèles 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 From 3eb7ee7c746c1d255249b9fb15c76b00b22967ce Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Thu, 29 Feb 2024 20:11:57 +0100 Subject: [PATCH 16/23] #506 [Mod] add: rework substitution __DOLIMEET_CONTRACT_SURVEY_INFOS__ --- core/modules/modDoliMeet.class.php | 6 +-- core/substitutions/functions_dolimeet.lib.php | 42 +++++++++---------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/core/modules/modDoliMeet.class.php b/core/modules/modDoliMeet.class.php index 21ef232..1ef75fc 100644 --- a/core/modules/modDoliMeet.class.php +++ b/core/modules/modDoliMeet.class.php @@ -587,21 +587,21 @@ public function init($options = ''): int $saturneMail = new SaturneMail($this->db, 'contrat'); - $i = 10; + $position = 100; $satisfactionSurveys = ['customer', 'billing', 'trainee', 'sessiontrainer', 'opco']; foreach ($satisfactionSurveys as $satisfactionSurvey) { $saturneMail->entity = 0; $saturneMail->type_template = 'contract'; $saturneMail->datec = $this->db->idate(dol_now()); $saturneMail->label = $langs->transnoentities('SatisfactionSurveyLabel', $langs->transnoentities(ucfirst($satisfactionSurvey))); - $saturneMail->position = $i; + $saturneMail->position = $position; $saturneMail->enabled = "isModEnabled('contrat')"; $saturneMail->topic = $langs->transnoentities('SatisfactionSurveyTopic', dol_strtolower($langs->transnoentities(ucfirst($satisfactionSurvey)))); $saturneMail->joinfiles = 1; $saturneMail->content = $langs->transnoentities('SatisfactionSurveyContent', dol_strtolower($langs->transnoentities(ucfirst($satisfactionSurvey)))); $emailTemplateSatisfactionSurvey[$satisfactionSurvey] = $saturneMail->create($user); - $i += 10; + $position += 10; } dolibarr_set_const($this->db, 'DOLIMEET_EMAIL_TEMPLATE_SATISFACTION_SURVEY', json_encode($emailTemplateSatisfactionSurvey), 'chaine', 0, '', $conf->entity); diff --git a/core/substitutions/functions_dolimeet.lib.php b/core/substitutions/functions_dolimeet.lib.php index 0f0ca1c..624814b 100644 --- a/core/substitutions/functions_dolimeet.lib.php +++ b/core/substitutions/functions_dolimeet.lib.php @@ -96,34 +96,32 @@ function dolimeet_completesubstitutionarray(array &$substitutionarray, Translate } $object->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); - if (is_array($sessions) && !empty($sessions)) { - foreach ($sessions as $session) { - $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '' . $session->ref . ' - ' . $session->label . ''; - $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '

  • ' . $langs->transnoentities('DateAndTime') . ' : ' . dol_strtolower($langs->transnoentities('From')) . ' ' . dol_print_date($session->date_start, 'day', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('At')) . ' ' . dol_print_date($session->date_start, 'hour', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('To')) . ' ' . dol_print_date($session->date_end, 'day', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('At')) . ' ' . dol_print_date($session->date_end, 'hour', 'tzuserrel') . ' (' . dol_strtolower($langs->transnoentities('Duration')) . ' : ' . (($session->duration > 0) ? convertSecondToTime($session->duration, 'allhourmin') : '00:00') . ')' . '
  • '; - if (!empty($contacts)) { - foreach ($contacts as $contact) { - if (isset($object->linkedObjectsIds['digiquali_survey']) && !empty($object->linkedObjectsIds['digiquali_survey'])) { - $surveyIDs = $object->linkedObjectsIds['digiquali_survey']; - arsort($surveyIDs); - foreach ($surveyIDs as $surveyID) { - $confName = 'DOLIMEET_' . $contact['code'] . '_SATISFACTION_SURVEY_SHEET'; - $filter = ' AND e.fk_sheet = ' . $conf->global->$confName; - if (getDolGlobalInt($confName) > 0) { - if ($signatory->checkSignatoryHasObject($surveyID, $survey->table_element, $contact['id'], $contact['source'] == 'internal' ? 'user' : 'socpeople', $filter)) { - $survey->fetch($surveyID); - $signatory->fetch($signatory->id); - $publicAnswerUrl = dol_buildpath('custom/digiquali/public/public_answer.php?track_id=' . $survey->track_id . '&object_type=' . $survey->element . '&entity=' . $conf->entity, 3); - $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= ''; - break; + if (!empty($contacts)) { + foreach ($contacts as $contact) { + if (isset($object->linkedObjectsIds['digiquali_survey']) && !empty($object->linkedObjectsIds['digiquali_survey'])) { + $surveyIDs = $object->linkedObjectsIds['digiquali_survey']; + arsort($surveyIDs); + foreach ($surveyIDs as $surveyID) { + $confName = 'DOLIMEET_' . $contact['code'] . '_SATISFACTION_SURVEY_SHEET'; + $filter = ' AND e.fk_sheet = ' . $conf->global->$confName; + if (getDolGlobalInt($confName) > 0) { + if ($signatory->checkSignatoryHasObject($surveyID, $survey->table_element, $contact['id'], $contact['source'] == 'internal' ? 'user' : 'socpeople', $filter)) { + $survey->fetch($surveyID); + $signatory->fetch($signatory->id); + $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '
    ' . dol_strtoupper($signatory->lastname) . ' ' . ucfirst($signatory->firstname) . ''; + if (is_array($sessions) && !empty($sessions)) { + foreach ($sessions as $session) { + $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '
    • ' . $session->ref . ' - ' . $session->label . '
    • '; + $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '
    • ' . $langs->transnoentities('DateAndTime') . ' : ' . dol_strtolower($langs->transnoentities('From')) . ' ' . dol_print_date($session->date_start, 'day', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('At')) . ' ' . dol_print_date($session->date_start, 'hour', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('To')) . ' ' . dol_print_date($session->date_end, 'day', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('At')) . ' ' . dol_print_date($session->date_end, 'hour', 'tzuserrel') . ' (' . dol_strtolower($langs->transnoentities('Duration')) . ' : ' . (($session->duration > 0) ? convertSecondToTime($session->duration, 'allhourmin') : '00:00') . ')' . '
    '; } + $publicAnswerUrl = dol_buildpath('custom/digiquali/public/public_answer.php?track_id=' . $survey->track_id . '&object_type=' . $survey->element . '&entity=' . $conf->entity, 3); + $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '' . $langs->transnoentities('FillSatisfactionSurvey', dol_strtolower($langs->transnoentities(ucfirst(dol_strtolower($contact['code']))))) . '
    '; } + break; } } } } - $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '
'; } } } From b4f096f4c9c37a3571a244fdfc8cc2d5f341542d Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Fri, 1 Mar 2024 17:16:33 +0100 Subject: [PATCH 17/23] #535 [Hook] fix: check view to not hook on create --- class/actions_dolimeet.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index 920e6ff..dab2970 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -386,7 +386,7 @@ function fillTable(data) { } } - if (strpos($parameters['context'], 'contractcard') !== false) { + if (strpos($parameters['context'], 'contractcard') !== false && GETPOST('action') != 'create') { global $object; $pictoPath = dol_buildpath('/custom/dolimeet/img/dolimeet_color.png', 1); From a8ee46d43bcbed09f3481af52cb93ba0eee01a3d Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Mon, 4 Mar 2024 20:17:45 +0100 Subject: [PATCH 18/23] #506 [Mod] add: lang value and document_type --- core/modules/modDoliMeet.class.php | 1 + core/substitutions/functions_dolimeet.lib.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/modules/modDoliMeet.class.php b/core/modules/modDoliMeet.class.php index 1ef75fc..d71a6fd 100644 --- a/core/modules/modDoliMeet.class.php +++ b/core/modules/modDoliMeet.class.php @@ -592,6 +592,7 @@ public function init($options = ''): int foreach ($satisfactionSurveys as $satisfactionSurvey) { $saturneMail->entity = 0; $saturneMail->type_template = 'contract'; + $saturneMail->lang = 'fr_FR'; $saturneMail->datec = $this->db->idate(dol_now()); $saturneMail->label = $langs->transnoentities('SatisfactionSurveyLabel', $langs->transnoentities(ucfirst($satisfactionSurvey))); $saturneMail->position = $position; diff --git a/core/substitutions/functions_dolimeet.lib.php b/core/substitutions/functions_dolimeet.lib.php index 624814b..e6ff000 100644 --- a/core/substitutions/functions_dolimeet.lib.php +++ b/core/substitutions/functions_dolimeet.lib.php @@ -114,7 +114,7 @@ function dolimeet_completesubstitutionarray(array &$substitutionarray, Translate $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '
  • ' . $session->ref . ' - ' . $session->label . '
  • '; $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '
  • ' . $langs->transnoentities('DateAndTime') . ' : ' . dol_strtolower($langs->transnoentities('From')) . ' ' . dol_print_date($session->date_start, 'day', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('At')) . ' ' . dol_print_date($session->date_start, 'hour', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('To')) . ' ' . dol_print_date($session->date_end, 'day', 'tzuserrel') . ' ' . dol_strtolower($langs->transnoentities('At')) . ' ' . dol_print_date($session->date_end, 'hour', 'tzuserrel') . ' (' . dol_strtolower($langs->transnoentities('Duration')) . ' : ' . (($session->duration > 0) ? convertSecondToTime($session->duration, 'allhourmin') : '00:00') . ')' . '
'; } - $publicAnswerUrl = dol_buildpath('custom/digiquali/public/public_answer.php?track_id=' . $survey->track_id . '&object_type=' . $survey->element . '&entity=' . $conf->entity, 3); + $publicAnswerUrl = dol_buildpath('custom/digiquali/public/public_answer.php?track_id=' . $survey->track_id . '&object_type=' . $survey->element . '&document_type=SurveyDocument&entity=' . $conf->entity, 3); $substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '' . $langs->transnoentities('FillSatisfactionSurvey', dol_strtolower($langs->transnoentities(ucfirst(dol_strtolower($contact['code']))))) . '
'; } break; From c0e173b4f0334febe3b62f03097d6143d4a99290 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Wed, 6 Mar 2024 15:55:19 +0100 Subject: [PATCH 19/23] #535 [Hook] fix: picto before key and not value --- class/actions_dolimeet.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index dab2970..4d6c3dc 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -394,12 +394,12 @@ function fillTable(data) { ?> Date: Wed, 6 Mar 2024 16:05:22 +0100 Subject: [PATCH 20/23] #546 [Mod] add: new version number 1.4.0 --- README.md | 6 +++--- core/modules/modDoliMeet.class.php | 2 +- .../interface_99_modDoliMeet_DoliMeetTriggers.class.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 756f7a4..40233eb 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Informations - Numéro du module : 436304 -- Dernière mise à jour : 19/01/2024 +- Dernière mise à jour : 07/03/2024 - Éditeur : [Evarisk](https://evarisk.com) - Thème : Eldy Menu - Licence : GPLv3 @@ -13,8 +13,8 @@ - Version : 1.3.0 - PHP : 7.4.33 -- Compatibilité : Dolibarr 16.0.0 - 18.0.4 -- Saturne framework : 1.2.1 +- Compatibilité : Dolibarr 16.0.0 - 18.0.5 +- Saturne framework : 1.3.0 ## Liens diff --git a/core/modules/modDoliMeet.class.php b/core/modules/modDoliMeet.class.php index d71a6fd..295f3a0 100644 --- a/core/modules/modDoliMeet.class.php +++ b/core/modules/modDoliMeet.class.php @@ -78,7 +78,7 @@ public function __construct($db) $this->editor_url = 'https://evarisk.com'; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'. - $this->version = '1.3.0'; + $this->version = '1.4.0'; // Url to the file with your last numberversion of this module. //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; diff --git a/core/triggers/interface_99_modDoliMeet_DoliMeetTriggers.class.php b/core/triggers/interface_99_modDoliMeet_DoliMeetTriggers.class.php index 52c6b90..32f907f 100644 --- a/core/triggers/interface_99_modDoliMeet_DoliMeetTriggers.class.php +++ b/core/triggers/interface_99_modDoliMeet_DoliMeetTriggers.class.php @@ -47,7 +47,7 @@ public function __construct(DoliDB $db) $this->name = preg_replace('/^Interface/i', '', get_class($this)); $this->family = 'demo'; $this->description = 'DoliMeet triggers.'; - $this->version = '1.3.0'; + $this->version = '1.4.0'; $this->picto = 'dolimeet@dolimeet'; } From 5a57366e338b775b9d8541ff10cd30b0b01ca5d5 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Wed, 6 Mar 2024 18:02:05 +0100 Subject: [PATCH 21/23] #535 [Hook] fix: rework extrafields and view picto on list/view --- class/actions_dolimeet.class.php | 70 ++++++++++++++++++++++-------- core/modules/modDoliMeet.class.php | 27 ++++++------ 2 files changed, 67 insertions(+), 30 deletions(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index 4d6c3dc..7bb1e0e 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -386,23 +386,9 @@ function fillTable(data) { } } - if (strpos($parameters['context'], 'contractcard') !== false && GETPOST('action') != 'create') { + if (strpos($parameters['context'], 'contractcard') !== false) { global $object; - $pictoPath = dol_buildpath('/custom/dolimeet/img/dolimeet_color.png', 1); - $picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule'); - - ?> - - array_options['options_trainingsession_type']) && !empty($object->array_options['options_trainingsession_type'])) { // Load Saturne libraries require_once __DIR__ . '/../../saturne/lib/documents.lib.php'; @@ -451,7 +437,7 @@ function fillTable(data) { } } if (GETPOST('action') == 'edit_extras' && GETPOST('attribute') == 'trainingsession_durations') { - $out = '' . $picto; + $out = ''; $out .= ''; $out .= ''; $out .= ''; @@ -460,7 +446,7 @@ function fillTable(data) { $out .= $form->select_duration('duration', $object->array_options['options_trainingsession_durations'], 0, 'text', 0, 1); $out .= '' . ''; } else { - $out = '' . $picto . ($object->array_options['options_trainingsession_durations'] > 0 ? convertSecondToTime($object->array_options['options_trainingsession_durations'], 'allhourmin') : '00:00') . ' - '; + $out = '' . ($object->array_options['options_trainingsession_durations'] > 0 ? convertSecondToTime($object->array_options['options_trainingsession_durations'], 'allhourmin') : '00:00') . ' - '; $out .= $langs->trans('CalculatedTotalSessionDuration') . ' ' . ($sessionDurations > 0 ? convertSecondToTime($sessionDurations, 'allhourmin') : '00:00'); if ($sessionDurations != $object->array_options['options_trainingsession_durations']) { $out .= $form->textwithpicto('', $langs->trans('TrainingSessionDurationErrorMatching', $session->ref), 1, 'warning'); @@ -614,6 +600,56 @@ public function doActions(array $parameters, $object, string $action): int return 0; // or return 1 to replace standard code. } + /** + * Overloading the formObjectOptions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object Current object + * @param string $action Current action + * @return int 0 < on error, 0 on success, 1 to replace standard code + */ + public function formObjectOptions(array $parameters, $object, string $action): int + { + global $extrafields, $langs; + + if (strpos($parameters['context'], 'contractcard') !== false) { + $pictoPath = dol_buildpath('/custom/dolimeet/img/dolimeet_color.png', 1); + $picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule'); + foreach ($extrafields->attributes['contrat']['enabled'] as $key => $moduleExtraFiels) { + if (strpos($moduleExtraFiels, 'dolimeet') !== false) { + $extrafields->attributes['contrat']['label'][$key] = $picto . $langs->transnoentities($extrafields->attributes['contrat']['label'][$key]); + } + } + } + + return 0; // or return 1 to replace standard code + } + + /** + * Overloading the printFieldListTitle function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object Current object + * @param string $action Current action + * @return int 0 < on error, 0 on success, 1 to replace standard code + */ + public function printFieldPreListTitle(array $parameters, $object, string $action): int + { + global $extrafields, $langs; + + if (strpos($parameters['context'], 'contractlist') !== false) { + $pictoPath = dol_buildpath('/custom/dolimeet/img/dolimeet_color.png', 1); + $picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule'); + foreach ($extrafields->attributes['contrat']['enabled'] as $key => $moduleExtraFiels) { + if (strpos($moduleExtraFiels, 'dolimeet') !== false) { + $extrafields->attributes['contrat']['label'][$key] = $picto . $langs->transnoentities($extrafields->attributes['contrat']['label'][$key]); + } + } + } + + return 0; // or return 1 to replace standard code + } + /** * Overloading the extendSheetLinkableObjectsList function : replacing the parent's function with the one below. * diff --git a/core/modules/modDoliMeet.class.php b/core/modules/modDoliMeet.class.php index 7b25d49..367a677 100644 --- a/core/modules/modDoliMeet.class.php +++ b/core/modules/modDoliMeet.class.php @@ -142,7 +142,8 @@ public function __construct($db) 'sessionlist', 'meetinglist', 'trainingsessionlist', - 'auditlist' + 'auditlist', + 'contractlist' ], // Set this to 1 if features of module are opened to external users. 'moduleforexternal' => 1, @@ -583,23 +584,23 @@ public function init($options = ''): int require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extraFields = new ExtraFields($this->db); - $extraFields->update('label', $langs->transnoentities('Label'), 'varchar', '', 'contrat', 0, 0, 1040, '', '', '', 1); - $extraFields->addExtraField('label', $langs->transnoentities('Label'), 'varchar', 1040, '', 'contrat', 0, 0, '', '', '', '', 1); + $extraFields->update('label', 'Label', 'varchar', 255, 'contrat', 0, 0, $this->numero . 1, '', '', '', 1, '', '', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')", 0, 0, ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']); + $extraFields->addExtraField('label', 'Label', 'varchar', $this->numero . 1, 255, 'contrat', 0, 0, '', '', '', '', 1, '', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')", 0, 0, ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']); - $extraFields->update('trainingsession_start', $langs->transnoentities('TrainingSessionStart'), 'datetime', '', 'contrat', 0, 0, 1800, '', '', '', 1, 'TrainingSessionStartHelp'); - $extraFields->addExtraField('trainingsession_start', $langs->transnoentities('TrainingSessionStart'), 'datetime', 1040, '', 'contrat', 0, 0, '', '', '', '', 1, 'TrainingSessionStartHelp'); + $extraFields->update('trainingsession_type', 'TrainingSessionType', 'sellist', '', 'contrat', 0, 0, $this->numero . 10, 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', '', '', 1, 'TrainingSessionTypeHelp', '', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')", 0, 0, ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']); + $extraFields->addExtraField('trainingsession_type', 'TrainingSessionType', 'sellist', $this->numero . 10, '', 'contrat', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', '', '', 1, 'TrainingSessionTypeHelp', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')", 0, 0, ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']); - $extraFields->update('trainingsession_end', $langs->transnoentities('TrainingSessionEnd'), 'datetime', '', 'contrat', 0, 0, 1810, '', '', '', 1, 'TrainingSessionEndHelp'); - $extraFields->addExtraField('trainingsession_end', $langs->transnoentities('TrainingSessionEnd'), 'datetime', 1040, '', 'contrat', 0, 0, '', '', '', '', 'TrainingSessionEndHelp'); + $extraFields->update('trainingsession_location', 'TrainingSessionLocation', 'varchar', 255, 'contrat', 0, 0, $this->numero . 20, '', '', '', 1, 'TrainingSessionLocationHelp', '', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')", 0, 0, ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']); + $extraFields->addExtraField('trainingsession_location', 'TrainingSessionLocation', 'varchar', $this->numero . 20, 255, 'contrat', 0, 0, '', '', '', '', 1, 'TrainingSessionLocationHelp', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')", 0, 0, ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']); - $extraFields->update('trainingsession_type', $langs->transnoentities('TrainingSessionType'), 'sellist', '', 'contrat', 0, 0, 1830, 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', '', '', 1, 'TrainingSessionTypeHelp'); - $extraFields->addExtraField('trainingsession_type', $langs->transnoentities('TrainingSessionType'), 'sellist', 1830, '', 'contrat', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', '', '', 1, 'TrainingSessionTypeHelp'); + $extraFields->update('trainingsession_start', 'TrainingSessionStart', 'datetime', '', 'contrat', 0, 0, $this->numero . 30, '', '', '', 1, 'TrainingSessionStartHelp', '', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')", 0, 0, ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']); + $extraFields->addExtraField('trainingsession_start', 'TrainingSessionStart', 'datetime', $this->numero . 30, '', 'contrat', 0, 0, '', '', '', '', 1, 'TrainingSessionStartHelp', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')", 0, 0, ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']); - $extraFields->update('trainingsession_location', $langs->transnoentities('TrainingSessionLocation'), 'varchar', '', 'contrat', 0, 0, 1850, '', '', '', 1, 'TrainingSessionLocationHelp'); - $extraFields->addExtraField('trainingsession_location', $langs->transnoentities('TrainingSessionLocation'), 'varchar', 1850, '', 'contrat', 0, 0, '', '', '', '', 1, 'TrainingSessionLocationHelp'); + $extraFields->update('trainingsession_end', 'TrainingSessionEnd', 'datetime', '', 'contrat', 0, 0, $this->numero . 40, '', '', '', 1, 'TrainingSessionEndHelp', '', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')"); + $extraFields->addExtraField('trainingsession_end', 'TrainingSessionEnd', 'datetime', $this->numero . 40, '', 'contrat', 0, 0, '', '', '', '', 'TrainingSessionEndHelp', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')"); - $extraFields->update('trainingsession_durations', $langs->transnoentities('TrainingSessionDurations'), 'int', '', 'contrat', 0, 0, 1860, '', '', '', 1, 'TrainingSessionDurationHelp'); - $extraFields->addExtraField('trainingsession_durations', $langs->transnoentities('TrainingSessionDurations'), 'int', 1860, '', 'contrat', 0, 0, '', '', '', '', 1, 'TrainingSessionDurationHelp'); + $extraFields->update('trainingsession_durations', 'TrainingSessionDurations', 'int', '', 'contrat', 0, 0, $this->numero . 50, '', '', '', 1, 'TrainingSessionDurationHelp', '', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')"); + $extraFields->addExtraField('trainingsession_durations', 'TrainingSessionDurations', 'int', $this->numero . 50, '', 'contrat', 0, 0, '', '', '', '', 1, 'TrainingSessionDurationHelp', '', 0, 'dolimeet@dolimeet', "isModEnabled('dolimeet') && isModEnabled('contrat')"); return $this->_init($sql, $options); } From bed4a220847d0226892015cb0259f727af19712d Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Wed, 6 Mar 2024 18:34:20 +0100 Subject: [PATCH 22/23] #548 [Hook] add: missing trad for link --- class/actions_dolimeet.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/actions_dolimeet.class.php b/class/actions_dolimeet.class.php index 2a500b6..3b0c5ac 100644 --- a/class/actions_dolimeet.class.php +++ b/class/actions_dolimeet.class.php @@ -247,7 +247,7 @@ public function printCommonFooter(array $parameters): int } else { $outputLine[$contact['rowid']] = ''; $outputLine[$contact['rowid']] .= ''; - $outputLine[$contact['rowid']] .= $form->textwithpicto($langs->trans('ClickHere'), $langs->trans('NeedToSetSatisfactionSurvey', $contact['code']), 1, 'warning') . ''; + $outputLine[$contact['rowid']] .= $form->textwithpicto($langs->trans('ClickHere'), $langs->trans('NeedToSetSatisfactionSurvey', dol_strtolower($langs->trans(ucfirst(dol_strtolower($contact['code']))))), 1, 'warning') . ''; $outputLine[$contact['rowid']] .= ''; } } From 83a22eba75e3efce6755b2d078feaea7a4200a9c Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Wed, 6 Mar 2024 19:16:39 +0100 Subject: [PATCH 23/23] #550 [Module] fix: remove useless file --- .../modules_trainingsessiondocument.php | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/modules_trainingsessiondocument.php diff --git a/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/modules_trainingsessiondocument.php b/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/modules_trainingsessiondocument.php deleted file mode 100644 index 1e981b0..0000000 --- a/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/modules_trainingsessiondocument.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see https://www.gnu.org/ - */ - -/** - * \file core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/modules_trainingsessiondocument.php - * \ingroup dolimeet - * \brief File that contains parent class for trainingsession document models. - */ - -// Load Saturne libraries. -require_once __DIR__ . '/../../../../../../saturne/core/modules/saturne/modules_saturne.php'; - -/** - * Parent class for trainingsession document models. - */ -abstract class ModeleODTTrainingSessionDocument extends SaturneDocumentModel -{ - /** - * Return list of active generation modules. - * - * @param DoliDB $db Database handler. - * @param string $type Document type. - * @param int $maxfilenamelength Max length of value to show. - * @return array|int 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename". - * @throws Exception - */ - public static function liste_modeles(DoliDB $db, string $type, int $maxfilenamelength = 0): array - { - return parent::liste_modeles($db, 'trainingsessiondocument', $maxfilenamelength); - } -}