Skip to content

Commit

Permalink
Merge pull request #3597 from Evarisk/develop
Browse files Browse the repository at this point in the history
9.14.0
  • Loading branch information
nicolas-eoxia authored Dec 5, 2023
2 parents e6076d3 + c85898e commit c9ff765
Show file tree
Hide file tree
Showing 64 changed files with 2,716 additions and 1,064 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
## Informations

- Numéro du module : 436302
- Dernière mise à jour : 24/10/2023
- Dernière mise à jour : 30/11/2023
- Éditeur : [Evarisk](https://evarisk.com)
- Thème : Eldy Menu
- Licence : GPLv3
- Disponible sur : Windows - MacOS - Linux

### Version

- Version : 9.13.0
- Version : 9.14.0
- PHP : 7.4.33
- Compatibilité : Dolibarr 16.0.0 - 18.0.1
- Compatibilité : Dolibarr 16.0.0 - 18.0.3
- Saturne Framework : 1.2.0

## Liens
Expand All @@ -22,6 +22,7 @@
- Demo : [Demo Digirisk](https://demodoli.digirisk.com) - ID: demo - Password: demo
- Documentation : [Wiki Digirisk](https://wiki.dolibarr.org/index.php/Module_DigiriskDolibarr)
- Projet GitHub : [Projet Digirisk](https://github.com/Evarisk/Digirisk/projects?type=classic)
- Saturne Framework : [Télécharger Saturne](https://dolistore.com/fr/modules/1906-Saturne.html)
- Forum : [Forum Digirisk](https://dolibarr.fr/forum/t/module-digirisk-document-unique/37119)
- D'autres modules développés par Evarisk disponibles sur [Dolistore.com](https://dolistore.com)

Expand All @@ -47,5 +48,6 @@ Gérez les risques de votre entreprise et créez votre Document Unique en toute
- Dans le dossier "dolibarr/htdocs/custom" copier la ligne suivante :
```
git clone -b main https://github.com/Evarisk/Digirisk.git digiriskdolibarr
git clone -b main https://github.com/Evarisk/Saturne.git saturne
```
- Activer le module dans la liste des Modules/Applications installés
128 changes: 127 additions & 1 deletion admin/ticket/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,51 @@
setEventMessages($langs->transnoentities('QRCodeGenerated'), array());
}

if ($action == 'createTimeRange') {
$comparatorPost = GETPOST('comparator');
$rangeNumberPost = GETPOST('range_value');
$timeRangePost = GETPOST('time_range');
$constraintLabel = GETPOST('range_label');

if (empty($rangeNumberPost)) {
setEventMessage($langs->trans('MissingRangeValue'), 'errors');
header("Location: " . $_SERVER["PHP_SELF"]);
exit;
}
if (dol_strlen($constraintLabel) == 0) {
$constraintLabel = $langs->trans($langs->transnoentities(ucfirst($comparatorPost) . 'Than') . ' ' . $rangeNumberPost . ' ' . $langs->transnoentities(ucfirst($timeRangePost)));
}

$accidentWorkStopTimeRangesJson = $conf->global->DIGIRISKDOLIBARR_TICKET_STATISTICS_ACCIDENT_TIME_RANGE;
$accidentWorkStopTimeRanges = json_decode($accidentWorkStopTimeRangesJson, true);
$accidentWorkStopTimeRanges[$constraintLabel] = $comparatorPost . ':' . $rangeNumberPost . ':' . $timeRangePost;

$newTimeRangeJson = json_encode($accidentWorkStopTimeRanges);

dolibarr_set_const($db, 'DIGIRISKDOLIBARR_TICKET_STATISTICS_ACCIDENT_TIME_RANGE', $newTimeRangeJson, 'chaine', 0, '', $conf->entity);

setEventMessages($langs->transnoentities('TimeRangeAdded'), array());

header("Location: " . $_SERVER["PHP_SELF"]);
exit;
}

if ($action == 'deleteTimeRange') {
$constraintLabel = GETPOST('value');
$accidentWorkStopTimeRangesJson = $conf->global->DIGIRISKDOLIBARR_TICKET_STATISTICS_ACCIDENT_TIME_RANGE;
$accidentWorkStopTimeRanges = json_decode($accidentWorkStopTimeRangesJson, true);
unset($accidentWorkStopTimeRanges[$constraintLabel]);

$newTimeRangeJson = json_encode($accidentWorkStopTimeRanges);

dolibarr_set_const($db, 'DIGIRISKDOLIBARR_TICKET_STATISTICS_ACCIDENT_TIME_RANGE', $newTimeRangeJson, 'chaine', 0, '', $conf->entity);

setEventMessages($langs->transnoentities('TimeRangeDeleted'), array());

header("Location: " . $_SERVER["PHP_SELF"]);
exit;
}

/*
* View
*/
Expand Down Expand Up @@ -361,7 +406,7 @@
print '</tr>';
print '</form>';

if (getDolGlobalInt('DIGIRISKDOLIBARR_TICKET_EXTRAFIELDS') > 0) {
if (dolibarr_get_const($db, 'DIGIRISKDOLIBARR_TICKET_EXTRAFIELDS', 0)) {
print load_fiche_titre($langs->transnoentities("PublicInterfaceConfiguration"), '', '');

print '<div class="div-table-responsive-no-min">';
Expand Down Expand Up @@ -792,6 +837,87 @@
print '<span class="opacitymedium">' . $langs->transnoentities("TicketPublicInterfaceConfigDocumentation") . '</span> : <a href="https://wiki.dolibarr.org/index.php?title=Module_Digirisk#DigiRisk_-_Registre_de_s.C3.A9curit.C3.A9_et_Tickets" target="_blank" >' . $langs->transnoentities('DigiriskDocumentation') . '</a>';
}

print load_fiche_titre($langs->transnoentities("TicketStatistics"), '', '');

$comparators = [
'less' => $langs->trans('Inferior'),
'more' => $langs->trans('Superior')
];
$range = [
'days' => $langs->trans('Days'),
'weeks' => $langs->trans('Weeks'),
'months' => $langs->trans('Months'),
'years' => $langs->trans('Years')
];

$accidentWorkStopTimeRangesJson = $conf->global->DIGIRISKDOLIBARR_TICKET_STATISTICS_ACCIDENT_TIME_RANGE;
$accidentWorkStopTimeRanges = json_decode($accidentWorkStopTimeRangesJson, true);

print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->transnoentities("RangeLabel") . '</td>';
print '<td>' . $langs->transnoentities("Comparator") . '</td>';
print '<td>' . $langs->transnoentities("RangeNumber") . '</td>';
print '<td>' . $langs->transnoentities("TimeRange") . '</td>';
print '<td>' . $langs->transnoentities("Action") . '</td>';
print '</tr>';

// Existing constraints
if (is_array($accidentWorkStopTimeRanges) && !empty($accidentWorkStopTimeRanges)) {
foreach ($accidentWorkStopTimeRanges as $rangeName => $rangeConstraint) {
if (strstr($rangeConstraint, ':')) {
$rangeConstraintDetails = explode(':', $rangeConstraint);
$rangeComparator = $rangeConstraintDetails[0] == 'less' ? $langs->trans('LessThan') : $langs->trans('MoreThan');
$rangeNumber = $rangeConstraintDetails[1];
$rangeUnit = $langs->trans(ucfirst($rangeConstraintDetails[2]));
}
print '<tr>';
print '<td>';
print $rangeName;
print '</td>';
print '<td>';
print $rangeComparator;
print '</td>';
print '<td>';
print $rangeNumber;
print '</td>';
print '<td>';
print $rangeUnit;
print '</td>';
print '<td>';
print '<a href="'. $_SERVER['PHP_SELF'] . '?action=deleteTimeRange&value=' . $rangeName.'" class="wpeo-button button-grey">';
print '<i class="fas fa-trash"></i>';
print '</a>';
print '</td>';
}
}

// Add new constraint
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="createTimeRange">';
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
print '<tr>';
print '<td>';
print '<input type="text" name="range_label" />';
print '</td>';
print '<td>';
print $form::selectarray('comparator', $comparators);
print '</td>';
print '<td>';
print '<input type="number" min="0" name="range_value" />';
print '</td>';
print '<td>';
print $form::selectarray('time_range', $range);
print '</td>';
print '<td>';
print '<button type="submit" class="wpeo-button button-blue"><i class="fas fa-plus"></i></button>';
print '</td>';
print '</td>';
print '</tr>';
print '</form>';

// End of page
llxFooter();
$db->close();
Loading

0 comments on commit c9ff765

Please sign in to comment.