Skip to content

Commit

Permalink
Merge pull request #3666 from Evarisk/develop
Browse files Browse the repository at this point in the history
9.14.1
  • Loading branch information
nicolas-eoxia authored Jan 19, 2024
2 parents 61cfa59 + ad36833 commit 2787bfc
Show file tree
Hide file tree
Showing 58 changed files with 682 additions and 422 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
## Informations

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

### Version

- Version : 9.14.0
- Version : 9.14.1
- PHP : 7.4.33
- Compatibilité : Dolibarr 16.0.0 - 18.0.3
- Saturne Framework : 1.2.0
- Compatibilité : Dolibarr 16.0.0 - 18.0.4
- Saturne Framework : 1.2.1

## Liens

- Support & Assistance : [Forum dolibarr.fr](https://dolibarr.fr) / Par mail à [email protected]
- 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)
- Projet GitHub : [Projet Digirisk](https://github.com/Evarisk/Digirisk/projects?query=is%3Aopen)
- 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 Down
49 changes: 48 additions & 1 deletion admin/ticket/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@
exit;
}

if ($action == 'set_multi_company_ticket_public_interface') {
$multiCompanyTicketPublicInterfaceTitle = GETPOST('multiCompanyTicketPublicInterfaceTitle', 'none');
$multiCompanyTicketPublicInterfaceSubtitle = GETPOST('multiCompanyTicketPublicInterfaceSubtitle', 'none');
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_TICKET_MULTI_COMPANY_PUBLIC_INTERFACE_TITLE', $multiCompanyTicketPublicInterfaceTitle, 'chaine', 0, '', 0);
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_TICKET_MULTI_COMPANY_PUBLIC_INTERFACE_SUBTITLE', $multiCompanyTicketPublicInterfaceSubtitle, 'chaine', 0, '', 0);

setEventMessage('SavedConfig');
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}

/*
* View
*/
Expand Down Expand Up @@ -565,6 +576,42 @@

print '</div>';

// Multi company ticket public interface config
print load_fiche_titre($langs->transnoentities('MultiCompanyTicketPublicInterfaceConfig'), '', '');

print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="set_multi_company_ticket_public_interface">';

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Parameters') . '</td>';
print '<td>' . $langs->trans('Description') . '</td>';
print '<td class="center">' . $langs->trans('Action') . '</td>';
print '</tr>';

// Multi company ticket public interface title
$multiCompanyTicketPublicInterfaceTitle = $langs->transnoentities(getDolGlobalString('DIGIRISKDOLIBARR_TICKET_MULTI_COMPANY_PUBLIC_INTERFACE_TITLE')) ?: $langs->transnoentities('WelcomeToPublicTicketInterface');
print '<tr class="oddeven"><td>' . $langs->trans('Title') . '</td>';
print '<td>';
$dolEditor = new DolEditor('multiCompanyTicketPublicInterfaceTitle', $multiCompanyTicketPublicInterfaceTitle, '100%', 120, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
$dolEditor->Create();
print '</td><td class="center">';
print $form->buttonsSaveCancel('Save', '', [], 1);
print '</td></tr>';

// Multi company ticket public interface subtitle
$multiCompanyTicketPublicInterfaceSubtitle = $langs->transnoentities(getDolGlobalString('DIGIRISKDOLIBARR_TICKET_MULTI_COMPANY_PUBLIC_INTERFACE_SUBTITLE')) ?: $langs->transnoentities('PleaseSelectAnEntity');
print '<tr class="oddeven"><td>' . $langs->trans('Subtitle') . '</td>';
print '<td>';
$dolEditor = new DolEditor('multiCompanyTicketPublicInterfaceSubtitle', $multiCompanyTicketPublicInterfaceSubtitle, '100%', 120, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
$dolEditor->Create();
print '</td><td class="center">';
print $form->buttonsSaveCancel('Save', '', [], 1);
print '</td></tr>';
print '</table>';
print '</form>';

// Project
if (isModEnabled('project')) {
print load_fiche_titre($langs->transnoentities("LinkedProject"), '', '');
Expand Down Expand Up @@ -874,7 +921,7 @@
}
print '<tr>';
print '<td>';
print $rangeName;
print $langs->transnoentities($rangeName);
print '</td>';
print '<td>';
print $rangeComparator;
Expand Down
60 changes: 29 additions & 31 deletions class/accident.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class Accident extends SaturneObject
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
const STATUS_LOCKED = 2;
const STATUS_ARCHIVED = 3;

/**
* 'type' field format:
Expand Down Expand Up @@ -156,7 +157,7 @@ class Accident extends SaturneObject
'entity' => ['type' => 'integer', 'label' => 'Entity', 'enabled' => '1', 'position' => 30, 'notnull' => 1, 'visible' => 0,],
'date_creation' => ['type' => 'datetime', 'label' => 'DateCreation', 'enabled' => '1', 'position' => 40, 'notnull' => 1, 'visible' => 2,],
'tms' => ['type' => 'timestamp', 'label' => 'DateModification', 'enabled' => '1', 'position' => 50, 'notnull' => 0, 'visible' => 0,],
'status' => ['type' => 'smallint', 'label' => 'Status', 'enabled' => '1', 'position' => 70, 'notnull' => 1, 'visible' => 2, 'index' => 0, 'arrayofkeyval' => [0 => 'StatusDraft', 1 => 'Validated', 2 => 'Locked']],
'status' => ['type' => 'smallint', 'label' => 'Status', 'enabled' => '1', 'position' => 70, 'notnull' => 1, 'visible' => 2, 'index' => 0, 'arrayofkeyval' => [0 => 'StatusDraft', 1 => 'Validated', 2 => 'Locked', 3 => 'Archived']],
'label' => ['type' => 'varchar(255)', 'label' => 'Label', 'enabled' => '1', 'position' => 80, 'notnull' => 0, 'visible' => 1, 'searchall' => 1, 'css' => 'minwidth200', 'help' => "Help text", 'showoncombobox' => '1',],
'fk_user_employer' => ['type' => 'integer:User:user/class/user.class.php', 'label' => 'UserEmployer', 'enabled' => '1', 'position' => 82, 'notnull' => -1, 'visible' => 1,],
'accident_type' => ['type' => 'text', 'label' => 'AccidentType', 'enabled' => '1', 'position' => 90, 'notnull' => -1, 'visible' => 1, 'css' => 'minwidth150',],
Expand Down Expand Up @@ -380,20 +381,21 @@ public function LibStatut(int $status, int $mode = 0): string
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('StatusDraft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
$this->labelStatus[self::STATUS_LOCKED] = $langs->transnoentitiesnoconv('Locked');
$this->labelStatus[self::STATUS_ARCHIVED] = $langs->transnoentitiesnoconv('Archived');

$this->labelStatusShort[self::STATUS_DELETED] = $langs->transnoentitiesnoconv('Deleted');
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('StatusDraft');
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
$this->labelStatusShort[self::STATUS_LOCKED] = $langs->transnoentitiesnoconv('Locked');

$this->labelStatusShort[self::STATUS_ARCHIVED] = $langs->transnoentitiesnoconv('Archived');
}

$statusType = 'status' . $status;
if ($status == self::STATUS_VALIDATED) {
$statusType = 'status4';
}
if ($status == self::STATUS_LOCKED) {
$statusType = 'status6';
if ($status == self::STATUS_LOCKED || $status == self::STATUS_ARCHIVED) {
$statusType = 'status8';
}
if ($status == self::STATUS_DELETED) {
$statusType = 'status9';
Expand Down Expand Up @@ -522,7 +524,6 @@ public function getNbAccidents(): array
return $array;
}


/**
* Get number accidents for last 3 years
*
Expand All @@ -546,11 +547,11 @@ public function getNbAccidentsLast3years(): array

$array['labels'] = [
'pastlastyear' => [
'label' => date("Y",strtotime("-2 year")),
'label' => date('Y', strtotime('-2 year')),
'color' => '#9567aa'
],
'lastyear' => [
'label' => date("Y",strtotime("-1 year")),
'label' => date('Y', strtotime('-1 year')),
'color' => '#4f9ebe'
],
'currentyear' => [
Expand All @@ -559,36 +560,34 @@ public function getNbAccidentsLast3years(): array
],
];

$arrayAccidents = [];

$accidentList = $this->fetchAll();

if (is_array($accidentList) && !empty($accidentList)) {
foreach($accidentList as $accident) {
$accidentDate = getdate($accident->accident_date);
$yearKey = $accidentDate['year'];
$monthKey = $accidentDate['mon'];
$accidentsByYear = [];
$accidentsArray = [];
$accidents = $this->fetchAll('', '', 0, 0, ['customsql' => 't.status > 0']);
if (is_array($accidents) && !empty($accidents)) {
foreach($accidents as $accident) {
$accidentDate = dol_getdate($accident->accident_date);
$yearKey = $accidentDate['year'];
$monthKey = $accidentDate['mon'];
$accidentsByYear[$yearKey][$monthKey - 1] += 1;
}
}

for ($i = 1; $i < 13; $i++) {
$month = $langs->transnoentitiesnoconv('MonthShort'.sprintf("%02d", $i));
$arrayAccidents[$i - 1] = array($month);
for ($j = 0; $j < 3; $j++) {
$arrayAccidents[$i - 1][date('Y') - 2 + $j] = 0;
for ($i = 1; $i < 13; $i++) {
$month = $langs->transnoentitiesnoconv('MonthShort'.sprintf('%02d', $i));
$accidentsArray[$i - 1] = [$month];
for ($j = 0; $j < 3; $j++) {
$accidentsArray[$i - 1][date('Y') - 2 + $j] = 0;
}
}
}


foreach($accidentsByYear as $year => $accidentByYear) {
foreach($accidentByYear as $month => $accidentByMonth) {
$arrayAccidents[$month][$year] = $accidentByMonth;
foreach($accidentsByYear as $year => $accidentByYear) {
foreach($accidentByYear as $month => $accidentByMonth) {
$accidentsArray[$month][$year] = $accidentByMonth;
}
}
}

foreach($arrayAccidents as $arrayAccident) {
$array['data'][] = array_values($arrayAccident);
foreach($accidentsArray as $accidentArray) {
$array['data'][] = array_values($accidentArray);
}
}

return $array;
Expand Down Expand Up @@ -852,7 +851,6 @@ public function getBannerTabContent() : array
$workstopLine = new AccidentWorkStop($this->db);
$accidentLines = $workstopLine->fetchFromParent($this->id);
$totalWorkStopDays = 0;
$moreHtmlRef = '';

if (!empty($accidentLines) && $accidentLines > 0) {
foreach ($accidentLines as $accidentLine) {
Expand Down
Loading

0 comments on commit 2787bfc

Please sign in to comment.