Skip to content

Commit

Permalink
Merge pull request #552 from Evarisk/develop
Browse files Browse the repository at this point in the history
1.4.0
  • Loading branch information
nicolas-eoxia authored Mar 7, 2024
2 parents 996db52 + 0e89a44 commit 14a29e0
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 107 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@

print '<td class="minwidth400 maxwidth500">';
$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 '</td></tr>';
}

Expand Down
186 changes: 150 additions & 36 deletions class/actions_dolimeet.class.php

Large diffs are not rendered by default.

This file was deleted.

60 changes: 47 additions & 13 deletions core/modules/modDoliMeet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -221,6 +222,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'],
Expand Down Expand Up @@ -549,7 +552,7 @@ public function __construct($db)
*/
public function init($options = ''): int
{
global $conf, $langs;
global $conf, $langs, $user;

// Permissions.
$this->remove($options);
Expand Down Expand Up @@ -579,24 +582,55 @@ 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');

$position = 100;
$satisfactionSurveys = ['customer', 'billing', 'trainee', 'sessiontrainer', 'opco'];
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;
$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);
$position += 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);

$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_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_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_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_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_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_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_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_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_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);
}
Expand Down
49 changes: 47 additions & 2 deletions core/substitutions/functions_dolimeet.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -62,7 +62,7 @@ function dolimeet_completesubstitutionarray(array &$substitutionarray, Translate
foreach ($signatories as $signatory) {
$substitutionarray['__DOLIMEET_CONTRACT_TRAININGSESSION_INFOS__'] .= '<ul><li>' . strtoupper($signatory->lastname) . ' ' . $signatory->firstname . ' - <strong>' . $signatory->getLibStatut(5) . (($signatory->status == SaturneSignature::STATUS_REGISTERED) ? ' - ' . $langs->transnoentities('PendingSignature') : '') . '</strong>';
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__'] .= ' - <a href=' . $signatureUrl . ' target="_blank">' . $langs->transnoentities('SignAttendanceSheetOnline') . '</a>';
}
$substitutionarray['__DOLIMEET_CONTRACT_TRAININGSESSION_INFOS__'] .= '</li></ul>';
Expand All @@ -80,5 +80,50 @@ 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 (!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__'] .= '<br><strong>' . dol_strtoupper($signatory->lastname) . ' ' . ucfirst($signatory->firstname) . '</strong>';
if (is_array($sessions) && !empty($sessions)) {
foreach ($sessions as $session) {
$substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '<ul><li>' . $session->ref . ' - ' . $session->label . '</li>';
$substitutionarray['__DOLIMEET_CONTRACT_SURVEY_INFOS__'] .= '<li>' . $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') . ')' . '</li></ul>';
}
$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__'] .= '<a href=' . $publicAnswerUrl . ' target="_blank">' . $langs->transnoentities('FillSatisfactionSurvey', dol_strtolower($langs->transnoentities(ucfirst(dol_strtolower($contact['code']))))) . '</a><br>';
}
break;
}
}
}
}
}
}
}
}
}
Loading

0 comments on commit 14a29e0

Please sign in to comment.