|
65 | 65 |
|
66 | 66 | $allLinks = $resources->digirisk_dolibarr_fetch_resources(); |
67 | 67 |
|
68 | | -$hookmanager->initHooks(array('admincompany', 'globaladmin')); |
| 68 | +$hookmanager->initHooks(array('adminsocial', 'globaladmin')); |
69 | 69 |
|
70 | | -$electionDateCSE = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int')); |
71 | | -$electionDateDP = dol_mktime(0, 0, 0, GETPOST('date_finmonth', 'int'), GETPOST('date_finday', 'int'), GETPOST('date_finyear', 'int')); |
72 | | -$date = dol_mktime(0, 0, 0, GETPOST('datemonth', 'int'), GETPOST('dateday', 'int'), GETPOST('dateyear', 'int')); |
| 70 | +$submissionElectionDateCSE = dol_mktime(0, 0, 0, GETPOST('SubmissionElectionDateCSEmonth', 'int'), GETPOST('SubmissionElectionDateCSEday', 'int'), GETPOST('SubmissionElectionDateCSEyear', 'int')); |
| 71 | +$electionDateCSE = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int')); |
| 72 | +$secondElectionDateCSE = dol_mktime(0, 0, 0, GETPOST('SecondElectionDateCSEmonth', 'int'), GETPOST('SecondElectionDateCSEday', 'int'), GETPOST('SecondElectionDateCSEyear', 'int')); |
| 73 | +$electionDateDP = dol_mktime(0, 0, 0, GETPOST('date_finmonth', 'int'), GETPOST('date_finday', 'int'), GETPOST('date_finyear', 'int')); |
| 74 | +$date = dol_mktime(0, 0, 0, GETPOST('datemonth', 'int'), GETPOST('dateday', 'int'), GETPOST('dateyear', 'int')); |
73 | 75 |
|
74 | 76 | /* |
75 | 77 | * Actions |
|
81 | 83 |
|
82 | 84 | if (empty($reshook)) { |
83 | 85 | if (($action == 'update' && ! GETPOST("cancel", 'alpha')) || ($action == 'updateedit')) { |
84 | | - $electionDateCSE = GETPOST('ElectionDateCSE', 'none'); |
85 | | - $electionDateCSE = explode('/', $electionDateCSE); |
86 | | - $electionDateCSE = $electionDateCSE[2] . '-' . $electionDateCSE[1] . '-' . $electionDateCSE[0]; |
| 86 | + $submissionElectionDateCSE = GETPOST('SubmissionElectionDateCSE'); |
| 87 | + $submissionElectionDateCSE = dol_print_date(dol_stringtotime($submissionElectionDateCSE), 'dayrfc'); |
87 | 88 |
|
88 | | - $electionDateDP = GETPOST('ElectionDateDP', 'none'); |
89 | | - $electionDateDP = explode('/', $electionDateDP); |
90 | | - $electionDateDP = $electionDateDP[2] . '-' . $electionDateDP[1] . '-' . $electionDateDP[0]; |
| 89 | + $electionDateCSE = GETPOST('ElectionDateCSE'); |
| 90 | + $electionDateCSE = dol_print_date(dol_stringtotime($electionDateCSE), 'dayrfc'); |
| 91 | + |
| 92 | + $secondElectionDateCSE = GETPOST('SecondElectionDateCSE'); |
| 93 | + $secondElectionDateCSE = dol_print_date(dol_stringtotime($secondElectionDateCSE), 'dayrfc'); |
| 94 | + |
| 95 | + $electionDateDP = GETPOST('ElectionDateDP'); |
| 96 | + $electionDateDP = dol_print_date(dol_stringtotime($electionDateDP), 'dayrfc'); |
91 | 97 |
|
92 | 98 | dolibarr_set_const($db, "DIGIRISKDOLIBARR_PARTICIPATION_AGREEMENT_INFORMATION_PROCEDURE", GETPOST("modalites", 'none'), 'chaine', 0, '', $conf->entity); |
93 | 99 | dolibarr_set_const($db, "DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_PERMANENT", GETPOST("permanent", 'none'), 'chaine', 0, '', $conf->entity); |
94 | 100 | dolibarr_set_const($db, "DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_OCCASIONAL", GETPOST("occasional", 'none'), 'chaine', 0, '', $conf->entity); |
| 101 | + dolibarr_set_const($db, "DIGIRISKDOLIBARR_CSE_SUBMISSION_ELECTION_DATE", $submissionElectionDateCSE, 'date', 0, '', $conf->entity); |
95 | 102 | dolibarr_set_const($db, "DIGIRISKDOLIBARR_CSE_ELECTION_DATE", $electionDateCSE, 'date', 0, '', $conf->entity); |
| 103 | + dolibarr_set_const($db, "DIGIRISKDOLIBARR_CSE_SECOND_ELECTION_DATE", $secondElectionDateCSE, 'date', 0, '', $conf->entity); |
96 | 104 | dolibarr_set_const($db, "DIGIRISKDOLIBARR_DP_ELECTION_DATE", $electionDateDP, 'date', 0, '', $conf->entity); |
97 | 105 |
|
98 | 106 | $CSEtitulaires = ! empty(GETPOST('TitularsCSE', 'array')) ? GETPOST('TitularsCSE', 'array') : (GETPOST('TitularsCSE', 'int') > 0 ? array(GETPOST('TitularsCSE', 'int')) : array()); |
|
111 | 119 | $resources->digirisk_dolibarr_set_resources($db, $user->id, 'HarassmentOfficer', 'user', array($HarassmentOfficer), $conf->entity); |
112 | 120 | $resources->digirisk_dolibarr_set_resources($db, $user->id, 'HarassmentOfficerCSE', 'user', array($HarassmentOfficerCSE), $conf->entity); |
113 | 121 |
|
| 122 | + // Submit file |
| 123 | + if (!empty($conf->global->MAIN_UPLOAD_DOC)) { |
| 124 | + if (!empty($_FILES) && ! empty($_FILES['userfile']['name'][0])) { |
| 125 | + if (is_array($_FILES['userfile']['tmp_name'])) { |
| 126 | + $userFiles = $_FILES['userfile']['tmp_name']; |
| 127 | + } else { |
| 128 | + $userFiles = [$_FILES['userfile']['tmp_name']]; |
| 129 | + } |
| 130 | + |
| 131 | + foreach ($userFiles as $key => $userFile) { |
| 132 | + if (empty($_FILES['userfile']['tmp_name'][$key])) { |
| 133 | + $error++; |
| 134 | + if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { |
| 135 | + setEventMessages($langs->trans('ErrorFileSizeTooLarge'), [], 'errors'); |
| 136 | + } |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + $fileDir = $conf->digiriskdolibarr->multidir_output[$conf->entity] . '/informationssharing/deficiencyreport/'; |
| 141 | + if (!file_exists($fileDir)) { |
| 142 | + if (dol_mkdir($fileDir) < 0) { |
| 143 | + $db->error = $langs->transnoentities('ErrorCanNotCreateDir', $fileDir); |
| 144 | + $error++; |
| 145 | + } |
| 146 | + } |
| 147 | + |
| 148 | + if (!$error) { |
| 149 | + digirisk_dol_add_file_process($fileDir, 0, 1, 'userfile', '', null, '', 0); |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + |
114 | 154 | if ($action != 'updateedit' && ! $error) { |
115 | 155 | header("Location: " . $_SERVER["PHP_SELF"]); |
116 | 156 | exit; |
117 | 157 | } |
118 | 158 | } |
| 159 | + |
| 160 | + if ($action == 'delete_file' && !empty($user->admin)) { |
| 161 | + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
| 162 | + $fileToDelete = $conf->digiriskdolibarr->multidir_output[$conf->entity] . '/informationssharing/deficiencyreport/' . GETPOST('file'); |
| 163 | + $result = dol_delete_file($fileToDelete); |
| 164 | + if ($result > 0) { |
| 165 | + setEventMessage($langs->trans('FileWasRemoved', GETPOST('file'))); |
| 166 | + header('Location: ' . $_SERVER['PHP_SELF']); |
| 167 | + } |
| 168 | + } |
119 | 169 | } |
120 | 170 |
|
121 | 171 | /* |
|
131 | 181 | $counter = 0; |
132 | 182 |
|
133 | 183 | $socialResources = array("TitularsCSE", "AlternatesCSE", "TitularsDP", "AlternatesDP"); |
134 | | -$socialConsts = array("DIGIRISKDOLIBARR_PARTICIPATION_AGREEMENT_INFORMATION_PROCEDURE", "DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_PERMANENT", "DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_OCCASIONAL", "DIGIRISKDOLIBARR_CSE_ELECTION_DATE", "DIGIRISKDOLIBARR_DP_ELECTION_DATE"); |
| 184 | +$socialConsts = array("DIGIRISKDOLIBARR_PARTICIPATION_AGREEMENT_INFORMATION_PROCEDURE", "DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_PERMANENT", "DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_OCCASIONAL", 'DIGIRISKDOLIBARR_CSE_SUBMISSION_ELECTION_DATE', "DIGIRISKDOLIBARR_CSE_ELECTION_DATE", "DIGIRISKDOLIBARR_DP_ELECTION_DATE"); |
135 | 185 |
|
136 | 186 | $maxnumber = count($socialResources) + count($socialConsts); |
137 | 187 |
|
|
159 | 209 |
|
160 | 210 | $allLinks = $resources->digirisk_dolibarr_fetch_resources(); |
161 | 211 |
|
162 | | -$electionDateCSE = $conf->global->DIGIRISKDOLIBARR_CSE_ELECTION_DATE; |
163 | | -$electionDateDP = $conf->global->DIGIRISKDOLIBARR_DP_ELECTION_DATE; |
| 212 | +$submissionElectionDateCSE = $conf->global->DIGIRISKDOLIBARR_CSE_SUBMISSION_ELECTION_DATE; |
| 213 | +$electionDateCSE = $conf->global->DIGIRISKDOLIBARR_CSE_ELECTION_DATE; |
| 214 | +$secondElectionDateCSE = $conf->global->DIGIRISKDOLIBARR_CSE_SECOND_ELECTION_DATE; |
| 215 | +$electionDateDP = $conf->global->DIGIRISKDOLIBARR_DP_ELECTION_DATE; |
164 | 216 |
|
165 | 217 | print '<span class="opacitymedium">' . $langs->trans("DigiriskMenu") . "</span><br>\n"; |
166 | 218 | print "<br>"; |
167 | 219 |
|
168 | | -print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '" name="social_form">'; |
| 220 | +print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '" name="social_form" enctype="multipart/form-data">'; |
169 | 221 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
170 | 222 | print '<input type="hidden" name="action" value="update">'; ?> |
171 | 223 |
|
|
225 | 277 | if ( ! GETPOSTISSET('backtopage')) print ' <a href="' . DOL_URL_ROOT . '/user/card.php?action=create&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create') . '"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans("AddUser") . '"></span></a>'; |
226 | 278 | print '</td></tr>'; |
227 | 279 |
|
228 | | -/* |
229 | | -* Harassment officer CSE |
230 | | -*/ |
231 | | - |
232 | | -print '<tr class="liste_titre"><th class="titlefield wordbreak">' . $langs->trans("HarassmentOfficerCSE") . '</th><th>' . $langs->trans("") . '</th></tr>' . "\n"; |
233 | | -$HarassmentOfficerCSE = $allLinks['HarassmentOfficerCSE']; |
234 | | -print '<tr>'; |
235 | | -print '<td>' . $langs->trans("ActionOnUser") . '</td>'; |
236 | | -print '<td colspan="3" class="maxwidthonsmartphone">'; |
237 | | -print $form->select_dolusers($HarassmentOfficerCSE->id, 'HarassmentOfficerCSE', 1, null, 0, '', '', $conf->entity, 0, 0, 'AND u.statut = 1', 0, '', 'minwidth300'); |
238 | | -if ( ! GETPOSTISSET('backtopage')) print ' <a href="' . DOL_URL_ROOT . '/user/card.php?action=create&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create') . '"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans("AddUser") . '"></span></a>'; |
239 | | -print '</td></tr>'; |
| 280 | +if (!empty($allLinks['TitularsCSE']) || !empty($allLinks['AlternatesCSE'])) { |
| 281 | + /* |
| 282 | + * Harassment officer CSE |
| 283 | + */ |
| 284 | + |
| 285 | + print '<tr class="liste_titre"><th class="titlefield wordbreak">' . $langs->trans("HarassmentOfficerCSE") . '</th><th>' . $langs->trans("") . '</th></tr>' . "\n"; |
| 286 | + $HarassmentOfficerCSE = $allLinks['HarassmentOfficerCSE']; |
| 287 | + print '<tr>'; |
| 288 | + print '<td>' . $langs->trans("ActionOnUser") . '</td>'; |
| 289 | + print '<td colspan="3" class="maxwidthonsmartphone">'; |
| 290 | + print $form->select_dolusers($HarassmentOfficerCSE->id, 'HarassmentOfficerCSE', 1, null, 0, '', '', $conf->entity, 0, 0, 'AND u.statut = 1', 0, '', 'minwidth300'); |
| 291 | + if ( ! GETPOSTISSET('backtopage')) print ' <a href="' . DOL_URL_ROOT . '/user/card.php?action=create&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create') . '"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans("AddUser") . '"></span></a>'; |
| 292 | + print '</td></tr>'; |
| 293 | +} |
240 | 294 |
|
241 | 295 | /* |
242 | 296 | *** ESC -- CSE *** |
243 | 297 | */ |
244 | 298 |
|
245 | 299 | print '<tr class="liste_titre"><th class="titlefield wordbreak">' . $langs->trans("ESC") . '</th><th>' . $langs->trans("") . '</th></tr>' . "\n"; |
246 | 300 |
|
247 | | -// * ESC Election Date - Date d'élection du CSE * |
248 | | - |
249 | | -print '<tr class="oddeven"><td><label for="ElectionDateCSE">' . $langs->trans("ElectionDate") . '</label></td><td>'; |
250 | | -print $form->selectDate(strtotime($electionDateCSE) ? $electionDateCSE : -1, 'ElectionDateCSE', 0, 0, 0, 'social_form', 1, 1); |
251 | | -print '</td></tr>'; |
252 | | - |
253 | | -// * ESC Titulars - Titulaires CSE * |
254 | | - |
255 | | -$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', $conf->entity, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1); |
256 | | -$titulars_cse = $allLinks['TitularsCSE']; |
257 | | - |
258 | | -print '<tr>'; |
259 | | -print '<td>' . $form->editfieldkey('Titulars', 'TitularsCSE_id', '', $object, 0) . '</td>'; |
260 | | -print '<td colspan="3" class="maxwidthonsmartphone">'; |
261 | | - |
262 | | - |
263 | | -print $form->multiselectarray('TitularsCSE', $userlist, $titulars_cse->id, null, null, null, null, "300"); |
264 | | - |
265 | | -if ( ! GETPOSTISSET('backtopage')) print ' <a href="' . DOL_URL_ROOT . '/user/card.php?action=create&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create') . '"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans("AddUser") . '"></span></a>'; |
266 | | - |
| 301 | +// ESC submission election date - Date de présentation de l'élection du CSE |
| 302 | +print '<tr class="oddeven"><td><label for="SubmissionElectionDateCSE">' . $langs->trans('SubmissionElectionDate') . '</label></td><td>'; |
| 303 | +print $form->selectDate(strtotime($submissionElectionDateCSE) ? $submissionElectionDateCSE : -1, 'SubmissionElectionDateCSE', 0, 0, 0, 'social_form', 1, 1); |
267 | 304 | print '</td></tr>'; |
268 | 305 |
|
269 | | -// * ESC Alternates - Suppléants CSE * |
270 | | - |
271 | | -$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', $conf->entity, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1); |
272 | | -$alternates_cse = $allLinks['AlternatesCSE']; |
273 | | - |
274 | | -print '<tr>'; |
275 | | -print '<td>' . $form->editfieldkey('Alternates', 'AlternatesCSE_id', '', $object, 0) . '</td>'; |
276 | | -print '<td colspan="3" class="maxwidthonsmartphone">'; |
277 | | - |
278 | | -print $form->multiselectarray('AlternatesCSE', $userlist, $alternates_cse->id, null, null, null, null, "300"); |
279 | | - |
280 | | -if ( ! GETPOSTISSET('backtopage')) print ' <a href="' . DOL_URL_ROOT . '/user/card.php?action=create&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create') . '"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans("AddUser") . '"></span></a>'; |
281 | | - |
282 | | -print '</td></tr>'; |
| 306 | +if (!empty($submissionElectionDateCSE)) { |
| 307 | + $deficiencyReportDate = dol_time_plus_duree(dol_stringtotime($submissionElectionDateCSE), '30', 'd'); |
| 308 | + if ((dol_now() > $deficiencyReportDate) || (!empty($secondElectionDateCSE) && dol_now() > dol_stringtotime($secondElectionDateCSE) && empty($allLinks['TitularsCSE']) && empty($allLinks['AlternatesCSE']))) { |
| 309 | + // Deficiency report - Procès-verbal de carence |
| 310 | + print '<tr class="oddeven"><td><label for="DeficiencyReport">' . $langs->trans('DeficiencyReport') . '</label></td><td>'; |
| 311 | + print ajax_constantonoff('DIGIRISKDOLIBARR_DEFICIENCY_REPORT'); |
| 312 | + print '<input class="flat" type="file" name="userfile[]" id="DeficiencyReportFile" />'; |
| 313 | + $fileArray = dol_dir_list($conf->digiriskdolibarr->multidir_output[$conf->entity] . '/informationssharing/deficiencyreport/', 'files'); |
| 314 | + // Scan directories |
| 315 | + if (is_array($fileArray) && !empty($fileArray)) { |
| 316 | + $out = '<div>'; |
| 317 | + // Show list of found files |
| 318 | + foreach ($fileArray as $file) { |
| 319 | + $out .= $file['name'] . ' <a class="reposition" href="' . DOL_URL_ROOT . '/document.php?modulepart=digiriskdolibarr&file=informationssharing/deficiencyreport/' . urlencode(basename($file['name'])) . '">' . img_picto('', 'listlight') . '</a>'; |
| 320 | + $out .= ' <a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=delete_file&token=' . newToken() . '&file=' . urlencode(basename($file['name'])) . '">' . img_picto('', 'delete') . '</a>'; |
| 321 | + $out .= '<br>'; |
| 322 | + } |
| 323 | + $out .= '</div>'; |
| 324 | + print $out; |
| 325 | + } |
| 326 | + print '</td></tr>'; |
| 327 | + |
| 328 | + // Deficiency report date - Date du procès-verbal de carence |
| 329 | + print '<tr class="oddeven"><td><label for="DeficiencyReportDate">' . $langs->trans('DeficiencyReportDate') . '</label></td><td>'; |
| 330 | + print dol_print_date($deficiencyReportDate, 'day'); |
| 331 | + print '</td></tr>'; |
| 332 | + } else { |
| 333 | + // ESC election date - Date d'élection du CSE |
| 334 | + print '<tr class="oddeven"><td><label for="ElectionDateCSE">' . $langs->trans("ElectionDate") . '</label></td><td>'; |
| 335 | + print $form->selectDate(strtotime($electionDateCSE) ? $electionDateCSE : -1, 'ElectionDateCSE', 0, 0, 0, 'social_form', 1, 1); |
| 336 | + print '</td></tr>'; |
| 337 | + |
| 338 | + // ESC Second election date - Date d'élection du second tour du CSE |
| 339 | + print '<tr class="oddeven"><td><label for="SecondElectionDateCSE">' . $langs->trans("SecondElectionDate") . '</label></td><td>'; |
| 340 | + print $form->selectDate(strtotime($secondElectionDateCSE) ? $secondElectionDateCSE : -1, 'SecondElectionDateCSE', 0, 0, 0, 'social_form', 1, 1); |
| 341 | + print '</td></tr>'; |
| 342 | + |
| 343 | + // ESC titulars - Titulaires CSE |
| 344 | + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', $conf->entity, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1); |
| 345 | + $titulars_cse = $allLinks['TitularsCSE']; |
| 346 | + print '<tr>'; |
| 347 | + print '<td>' . $form->editfieldkey('Titulars', 'TitularsCSE_id', '', $object, 0) . '</td>'; |
| 348 | + print '<td colspan="3" class="maxwidthonsmartphone">'; |
| 349 | + print $form->multiselectarray('TitularsCSE', $userlist, $titulars_cse->id, null, null, null, null, "300"); |
| 350 | + if (!GETPOSTISSET('backtopage')) print ' <a href="' . DOL_URL_ROOT . '/user/card.php?action=create&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create') . '"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans("AddUser") . '"></span></a>'; |
| 351 | + print '</td></tr>'; |
| 352 | + |
| 353 | + // ESC alternates - Suppléants CSE |
| 354 | + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', $conf->entity, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1); |
| 355 | + $alternates_cse = $allLinks['AlternatesCSE']; |
| 356 | + print '<tr>'; |
| 357 | + print '<td>' . $form->editfieldkey('Alternates', 'AlternatesCSE_id', '', $object, 0) . '</td>'; |
| 358 | + print '<td colspan="3" class="maxwidthonsmartphone">'; |
| 359 | + print $form->multiselectarray('AlternatesCSE', $userlist, $alternates_cse->id, null, null, null, null, "300"); |
| 360 | + if (!GETPOSTISSET('backtopage')) print ' <a href="' . DOL_URL_ROOT . '/user/card.php?action=create&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create') . '"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans("AddUser") . '"></span></a>'; |
| 361 | + print '</td></tr>'; |
| 362 | + } |
| 363 | +} |
283 | 364 |
|
284 | 365 | /* |
285 | 366 | *** Staff Representative -- Délégués du Personnel *** |
|
0 commit comments