';
+$accident->fields['Custom']['Victim'] = $arrayfields['Victim'] ;
+
// We manually add progress field here because it is a redundant information that doesn't need to be stored in db
$accident->fields['progress'] = ['type' => 'integer:', 'label' => 'Progress', 'enabled' => '1', 'position' => 70, 'notnull' => 0, 'visible' => 2, 'index' => 0,];
$arrayfields['t.progress'] = ['label' => 'Progress', 'checked' => 1, 'enabled' => 0, 'position' => 70, 'disablesort' => 1];
@@ -378,13 +380,18 @@
if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_' . $key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75');
elseif (strpos($val['type'], 'integer:') === 0) {
- if ($key == 'fk_user_victim' && $fromiduser > 0) {
- $search[$key] = $fromiduser;
- }
print $accident->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif ( ! preg_match('/^(date|timestamp)/', $val['type'])) print '';
print '';
}
+ if ($key == 'Custom') {
+ foreach ($val as $resource) {
+ if ($resource['checked']) {
+ print '';
+ print ' | ';
+ }
+ }
+ }
}
// Extra fields
@@ -413,8 +420,22 @@
$cssforfield .= ($cssforfield ? ' ' : '') . 'center';
}
if ( ! empty($arrayfields['t.' . $key]['checked'])) {
+ if (preg_match('/Victim/', $arrayfields['t.' . $key]['label'])) {
+ $disablesort = 1;
+ } else {
+ $disablesort = 0;
+ }
print getTitleFieldOfList($arrayfields['t.' . $key]['label'], 0, $_SERVER['PHP_SELF'], 't.' . $key, '', $param, ($cssforfield ? 'class="' . $cssforfield . '"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield . ' ' : ''), $disablesort) . "\n";
}
+ if ($key == 'Custom') {
+ foreach ($val as $resource) {
+ if ($resource['checked']) {
+ print '';
+ print $langs->trans($resource['label']);
+ print ' | ';
+ }
+ }
+ }
}
// Extra fields
@@ -447,6 +468,7 @@
// Store properties in $accidentdocument
$accident->setVarsFromFetchObj($obj);
+ $userVictim = $accident->getUserVictim();
$json = json_decode($accident->json, false, 512, JSON_UNESCAPED_UNICODE)->Accident;
@@ -486,7 +508,10 @@
$arrayAccident[] = $accident->accident_location;
break;
}
- $arrayAccident[] = $accident->fk_user_victim;
+ $arrayAccident[] = $userVictim->id;
+
+ $accidentLesions = $accidentLesion->fetchAll('', '', 0, 0, ['customsql' => 't.fk_accident = ' . $accident->id]);
+ $arrayAccident[] = (is_array($accidentLesions) && !empty($accidentLesions)) ? count($accidentLesions) : '';
$maxnumber = count($arrayAccident);
@@ -513,11 +538,6 @@
if ($usertmp > 0) {
print getNomUrlUser($usertmp, 1, 'blank', 0, 0, 0, 0, '', '', -1, 0);
}
- } elseif ($key == 'fk_user_victim') {
- $usertmp->fetch($accident->fk_user_victim);
- if ($usertmp > 0) {
- print getNomUrlUser($usertmp, 1, 'blank', 0, 0, 0, 0, '', '', -1, 0);
- }
} elseif ($key == 'accident_type') {
if ($accident->accident_type == 0) {
print $langs->trans('WorkAccidentStatement');
@@ -553,7 +573,20 @@
$totalarray['val']['t.' . $key] += $accident->$key;
}
}
- }
+ if ($key == 'Custom') {
+ foreach ($val as $name => $resource) {
+ if ($resource['checked']) {
+ print '';
+
+ if ($resource['label'] == 'Victim') {
+ print getNomUrlUser($userVictim, 1, 'blank', 0, 0, 0, 0, '', '', -1, 0);
+ }
+ print ' | ';
+ }
+ }
+ }
+
+ }
// Action column
print '';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
diff --git a/view/accident/accident_metadata_lesion.php b/view/accident/accident_metadata_lesion.php
index 4f475dcd4..fef63f616 100644
--- a/view/accident/accident_metadata_lesion.php
+++ b/view/accident/accident_metadata_lesion.php
@@ -102,102 +102,7 @@
exit;
}
- // Action to add line
- if ($action == 'addLine' && $permissiontoadd) {
- // Get parameters
- $lesion_localization = GETPOST('lesion_localization');
- $lesion_nature = GETPOST('lesion_nature');
- $parent_id = GETPOST('parent_id');
- $error = 0;
-
- // Initialize object accident line
- $now = dol_now();
- $objectline->ref = $objectline->getNextNumRef();
- $objectline->date_creation = $object->db->idate($now);
- $objectline->entity = $conf->entity;
- $objectline->lesion_localization = $lesion_localization;
- $objectline->lesion_nature = $lesion_nature;
- $objectline->fk_accident = $parent_id;
-
- // Check parameters
- if ($lesion_localization < 0) {
- setEventMessages($langs->trans('ErrorFieldNotEmpty', $langs->transnoentitiesnoconv('LesionLocalization')), null, 'errors');
- $error++;
- }
-
- if ($lesion_nature < 0) {
- setEventMessages($langs->trans('ErrorFieldNotEmpty', $langs->transnoentitiesnoconv('LesionNature')), null, 'errors');
- $error++;
- }
-
- if ( ! $error) {
- $result = $objectline->create($user, false);
- if ($result > 0) {
- // Creation accident lesion OK
- setEventMessages($langs->trans('AddAccidentLesion') . ' ' . $object->ref, array());
- $urltogo = str_replace('__ID__', $result, $backtopage);
- $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation
- header("Location: " . $urltogo);
- exit;
- } else {
- // Creation accident lesion KO
- if ( ! empty($objectline->errors)) setEventMessages(null, $objectline->errors, 'errors');
- else setEventMessages($objectline->error, null, 'errors');
- }
- }
- }
-
- // Action to update line
- if ($action == 'updateLine' && $permissiontoadd) {
- // Get parameters
- $lesion_localization = GETPOST('lesion_localization');
- $lesion_nature = GETPOST('lesion_nature');
- $parent_id = GETPOST('parent_id');
-
- $objectline->fetch($lineid);
-
- // Initialize object accident line
- $objectline->lesion_localization = $lesion_localization;
- $objectline->lesion_nature = $lesion_nature;
- $objectline->fk_accident = $parent_id;
-
- if ( ! $error) {
- $result = $objectline->update($user, false);
- if ($result > 0) {
- // Update accident lesion OK
- setEventMessages($langs->trans('UpdateAccidentLesion') . ' ' . $object->ref, array());
- $urltogo = str_replace('__ID__', $result, $backtopage);
- $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $parent_id, $urltogo); // New method to autoselect project after a New on another form object creation
- header("Location: " . $urltogo);
- exit;
- } else {
- // Update accident lesion KO
- if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
- else setEventMessages($object->error, null, 'errors');
- }
- }
- }
-
- // Action to delete line
- if ($action == 'deleteline' && $permissiontodelete) {
- $objectline->fetch($lineid);
- $result = $objectline->delete($user, false, false);
- if ($result > 0) {
- // Deletion accident lesion OK
- setEventMessages($langs->trans('DeleteAccidentLesion') . ' ' . $object->ref, array());
- $urltogo = str_replace('__ID__', $result, $backtopage);
- $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $parent_id, $urltogo); // New method to autoselect project after a New on another form object creation
- header("Location: " . $urltogo);
- exit;
- } else {
- // Deletion accident lesion KO
- if (!empty($object->errors)) {
- setEventMessages('', $object->errors, 'errors');
- } else {
- setEventMessages($object->error, [], 'errors');
- }
- }
- }
+ include_once __DIR__ . '/../../core/tpl/accident/digiriskdolibarr_accident_lesion_actions.tpl.php';
// Actions set_thirdparty, set_project
require_once __DIR__ . '/../../../saturne/core/tpl/actions/banner_actions.tpl.php';
@@ -222,138 +127,7 @@
saturne_banner_tab($object, 'id', '', 1, 'rowid', 'ref', $moreHtmlRef, dol_strlen($object->photo) > 0, $moreParams);
-// ACCIDENT LESION
-print '';
-print load_fiche_titre($langs->trans("AccidentLesionList"), '', '');
-print ' ';
-
-global $forceall, $forcetoshowtitlelines;
-
-if (empty($forceall)) $forceall = 0;
-
-// Define colspan for the button 'Add'
-$colspan = 3; // Columns: total ht + col edit + col delete
-
-// Accident Lines
-$accidentlines = $objectline->fetchAll('', '', 0, 0, ['customsql' => 't.fk_accident = ' . $object->id]);
-
-print '';
-print '' . $langs->trans('Ref.') . ' | ';
-print '' . $langs->trans('LesionLocalization') . ' | ';
-print '' . $langs->trans('LesionNature') . ' | ';
-print '' . $langs->trans('ActionsLine') . ' | ';
-print ' ';
-
-if (!empty($accidentlines) && $accidentlines > 0) {
- foreach ($accidentlines as $key => $item) {
- if ($action == 'editline' && $lineid == $key) {
- print '';
- } else {
- print '';
- print $item->ref;
- print ' | ';
-
- $coldisplay++;
- print '';
- print $langs->transnoentities($item->lesion_localization);
- print ' | ';
-
- $coldisplay++;
- print '';
- print $langs->transnoentities($item->lesion_nature);
- print ' | ';
-
- $coldisplay += $colspan;
-
- //Actions buttons
- if ($object->status == 1) {
- print '';
- $coldisplay++;
- print 'id . '" style="padding-right: 20px">';
- print 'id . '&token='. newToken(). '">';
- print img_delete();
- print '';
- print ' | ';
- } else {
- print '';
- print '-';
- print ' | ';
- }
-
- print '';
- }
- }
- print '';
-}
-if ($object->status == 1 && $permissiontoadd) {
- print '';
-}
-print ' ';
-print ' ';
+include_once __DIR__ . '/../../core/tpl/accident/digiriskdolibarr_accident_lesion.tpl.php';
print dol_get_fiche_end();
// End of page
diff --git a/view/accidentinvestigation/accidentinvestigation_card.php b/view/accidentinvestigation/accidentinvestigation_card.php
index 29fc52b4f..10b5e544c 100644
--- a/view/accidentinvestigation/accidentinvestigation_card.php
+++ b/view/accidentinvestigation/accidentinvestigation_card.php
@@ -70,7 +70,6 @@
$project = new Project($db);
$task = new Task($db);
$signatory = new SaturneSignature($db, $object->module, $object->element);
-$victim = new User($db);
$numRefConf = strtoupper($task->element) . '_ADDON';
@@ -185,30 +184,6 @@
exit();
}
- if ($action == 'confirm_archive') {
- $modelList = saturne_get_list_of_models($db, 'accidentinvestigationdocument');
- if (!empty($modelList)) {
- asort($modelList);
- $modelList = array_filter($modelList, 'saturne_remove_index');
- if (is_array($modelList)) {
- $models = array_keys($modelList);
- }
- }
-
- $moreParams['object'] = $object;
- $moreParams['user'] = $user;
- $moreParams['zone'] = 'private';
- $moreParams['specimen'] = 0;
- $result = $document->generateDocument((!empty($models) ? $models[0] : ''), $langs, 0, 0, 0, $moreParams);
-
- if ($result > 0) {
- setEventMessages('AccidentInvestigationClassified', []);
- } else {
- setEventMessages($document->error, [], 'errors');
- $action = '';
- }
- }
-
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
require_once DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php';
@@ -303,9 +278,10 @@
} else if ($id > 0 || (!empty($ref) && empty($action))) {
$object->fetch($id);
$accident->fetch($object->fk_accident);
- $victim->fetch($accident->fk_user_victim);
- saturne_get_fiche_head($object, 'card', $title);
+ $victim = $accident->getUserVictim();
+
+ saturne_get_fiche_head($object, 'card', $title);
saturne_banner_tab($object);
$formConfirm = '';
@@ -314,38 +290,17 @@
if (($action == 'set_draft' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
$formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ReOpenObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmReOpenObject', $langs->transnoentities('The' . ucfirst($object->element)), $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_setdraft', '', 'yes', 'actionButtonInProgress', 350, 600);
}
- // New version confirmation
- if (($action == 'set_new_version' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
- $imgPath = dol_buildpath('custom/saturne/img/formconfirm/object_version_versioning.png', 1);
- $img = img_picto($langs->trans('NewVersion'), $imgPath, '', 1);
- $formQuestion = [
- ['type' => 'other', 'name' => 'lock_validation', 'label' => '' . img_picto('', 'info') . ' ' . $langs->trans('ConfirmReOpenInvestigation'). ''],
- ['type' => 'other', 'name' => 'OK', 'label' => '', 'value' => $img, 'moreattr' => 'readonly'],
- ];
-
- $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('NewVersionObject', $langs->transnoentities('The' . ucfirst($object->element))), '', 'confirm_setdraft', $formQuestion, 'yes', 'actionButtonNewVersion', 650, 600);
- }
// Validate confirmation
if (($action == 'set_validate' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
- $imgPath = dol_buildpath('custom/saturne/img/formconfirm/object_version_draft.png', 1);
- $img = img_picto($langs->trans('Validate'), $imgPath, '', 1);
- $formQuestion = [
- ['type' => 'other', 'name' => 'lock_validation', 'label' => '' . img_picto('', 'info') . ' ' . $langs->trans('ConfirmValidateObject', $langs->transnoentities('The' . ucfirst($object->element)), $langs->transnoentities('The' . ucfirst($object->element))) . ''],
- ['type' => 'other', 'name' => 'OK', 'label' => '', 'value' => $img, 'moreattr' => 'readonly'],
- ];
-
- $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ValidateObject', $langs->transnoentities('The' . ucfirst($object->element))), '', 'confirm_set_validate', $formQuestion, 'yes', 'actionButtonValidate', 650, 600);
+ $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ValidateObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmValidateObject', $langs->transnoentities('The' . ucfirst($object->element)), $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_set_validate', '', 'yes', 'actionButtonValidate', 350, 600);
}
+ // Lock confirmation
+ if (($action == 'lock' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
+ $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_lock', '', 'yes', 'actionButtonLock', 350, 600);
+ }
// Archive confirmation
if (($action == 'set_archive' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
- $imgPath = dol_buildpath('custom/saturne/img/formconfirm/object_version_validate.png', 1);
- $img = img_picto($langs->trans('Versioning'), $imgPath, '', 1);
- $formQuestion = [
- ['type' => 'other', 'name' => 'lock_validation', 'label' => '' . img_picto('', 'info') . ' ' . $langs->trans('ConfirmVersionObject', $langs->transnoentities('The' . ucfirst($object->element))). ''],
- ['type' => 'other', 'name' => 'OK', 'label' => '', 'value' => $img, 'moreattr' => 'readonly'],
- ];
-
- $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('VersionObject', $langs->transnoentities('The' . ucfirst($object->element))), '', 'confirm_archive', $formQuestion, 'yes', 'actionButtonArchive', 650, 600);
+ $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmArchiveObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_archive', '', 'yes', 'actionButtonArchive', 350, 600);
}
// Clone confirmation
if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
@@ -442,6 +397,16 @@
print '' . $displayButton . '';
}
+ // Lock.
+ $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Lock');
+ if ($object->status == AccidentInvestigation::STATUS_VALIDATED && $allSigned) {
+ print '' . $displayButton . '';
+ } else if ($object->status < AccidentInvestigation::STATUS_VALIDATED) {
+ print '' . $displayButton . '';
+ } else {
+ print '' . $displayButton . '';
+ }
+
// Send email.
$displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('SendMail') . ' ';
if ($object->status >= AccidentInvestigation::STATUS_VALIDATED) {
@@ -450,20 +415,12 @@
print '' . $displayButton . '';
}
- // Versioning.
- $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Versioning');
- if ($object->status == AccidentInvestigation::STATUS_VALIDATED && $allSigned) {
+ // Archive.
+ $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive');
+ if ($object->status == AccidentInvestigation::STATUS_LOCKED) {
print '' . $displayButton . '';
} else {
- print '' . $displayButton . '';
- }
-
- // New version.
- $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('NewVersion');
- if ($object->status == AccidentInvestigation::STATUS_ARCHIVED) {
- print '' . $displayButton . '';
- } else {
- print '' . $displayButton . '';
+ print '' . $displayButton . '';
}
// Clone.
@@ -490,8 +447,7 @@
$fileDir = $upload_dir . '/' . $dirFiles;
$urlSource = $_SERVER['PHP_SELF'] . '?id=' . $object->id;
- print saturne_show_documents('digiriskdolibarr:' . ucfirst('AccidentInvestigation') . 'Document', $dirFiles, $fileDir, $urlSource, $permissiontoadd, 0, $conf->global->DIGIRISKDOLIBARR_ACCIDENTINVESTIGATIONDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, 0, '', '', $langs->defaultlang, '', $object, 0, 'remove_file', 0, $langs->trans('DocumentGeneratedWithVersioning'));
-
+ print saturne_show_documents('digiriskdolibarr:' . ucfirst('AccidentInvestigation') . 'Document', $dirFiles, $fileDir, $urlSource, $permissiontoadd, 0, $conf->global->DIGIRISKDOLIBARR_ACCIDENTINVESTIGATIONDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, 0, '', '', $langs->defaultlang, '', $object, 0, 'remove_file', (($object->status > $object::STATUS_VALIDATED) ? 1 : 0), $langs->trans('ObjectMustBeLockedToGenerate', ucfirst($langs->transnoentities('The' . ucfirst($object->element)))));
print '';
$moreHtmlCenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/saturne/view/saturne_agenda.php', 1) . '?id=' . $object->id . '&module_name=digiriskdolibarr&object_type=' . $object->element);
diff --git a/view/digiriskelement/digiriskelement_card.php b/view/digiriskelement/digiriskelement_card.php
index a55a66532..3b5b3dd6e 100644
--- a/view/digiriskelement/digiriskelement_card.php
+++ b/view/digiriskelement/digiriskelement_card.php
@@ -298,8 +298,15 @@
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
if ($id != $conf->global->DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH) {
- print ' ' . $langs->trans("ParentElement") . ' | ';
- print $object->selectDigiriskElementList($object->fk_parent, 'fk_parent', ['customsql' => 'element_type="groupment" AND t.rowid NOT IN (' . implode(',', $deletedElements) . ')'], 0, 0, [], 0, 0, 'minwidth100', GETPOST('id'), false);
+ $children = $object->fetchDigiriskElementFlat($id);
+ $childrenElements = [];
+ if (is_array($children) && !empty($children)) {
+ foreach ($children as $key => $value) {
+ $childrenElements[$key] .= $key;
+ }
+ }
+ print ' | ' . $langs->trans("ParentElement") . ' | ';
+ print $object->selectDigiriskElementList($object->fk_parent, 'fk_parent', ['customsql' => 'element_type="groupment" AND t.rowid NOT IN (' . implode(',', $deletedElements) . ',' . implode(',', $childrenElements) . ')'], 0, 0, [], 0, 0, 'minwidth100', GETPOST('id'));
}
print ' | ';
diff --git a/view/digiriskelement/digiriskelement_risk.php b/view/digiriskelement/digiriskelement_risk.php
index 2ab881b50..b20591276 100644
--- a/view/digiriskelement/digiriskelement_risk.php
+++ b/view/digiriskelement/digiriskelement_risk.php
@@ -205,6 +205,12 @@
digirisk_header($title, $helpUrl);
+if ($conf->browser->layout == 'phone') {
+ $onPhone = 1;
+} else {
+ $onPhone = 0;
+}
+
print ' ';
if ($sharedrisks) {
diff --git a/view/digiriskstandard/digiriskstandard_registerdocument.php b/view/digiriskstandard/digiriskstandard_registerdocument.php
new file mode 100644
index 000000000..2430e6ab2
--- /dev/null
+++ b/view/digiriskstandard/digiriskstandard_registerdocument.php
@@ -0,0 +1,143 @@
+
+ *
+ * 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 .
+ */
+
+/**
+ * \file view/digiriskstandard/digiriskstandard_registerdocument.php
+ * \ingroup digiriskdolibarr
+ * \brief Page to view registerdocument
+ */
+
+// Load DigiriskDolibarr environment
+if (file_exists('../digiriskdolibarr.main.inc.php')) {
+ require_once __DIR__ . '/../digiriskdolibarr.main.inc.php';
+} elseif (file_exists('../../digiriskdolibarr.main.inc.php')) {
+ require_once __DIR__ . '/../../digiriskdolibarr.main.inc.php';
+} else {
+ die('Include of digiriskdolibarr main fails');
+}
+
+require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
+
+require_once __DIR__ . '/../../class/digiriskstandard.class.php';
+require_once __DIR__ . '/../../class/digiriskresources.class.php';
+require_once __DIR__ . '/../../class/digiriskdolibarrdocuments/registerdocument.class.php';
+require_once __DIR__ . '/../../lib/digiriskdolibarr_digiriskstandard.lib.php';
+require_once __DIR__ . '/../../lib/digiriskdolibarr_function.lib.php';
+
+global $db, $conf, $langs, $hookmanager, $user;
+
+// Load translation files required by the page
+saturne_load_langs(['other']);
+
+// Get parameters
+$action = GETPOST('action', 'aZ09');
+$subaction = GETPOST('subaction', 'aZ09');
+
+// Initialize technical objects
+$object = new DigiriskStandard($db);
+$document = new RegisterDocument($db);
+$contact = new Contact($db);
+$project = new Project($db);
+
+$hookmanager->initHooks(array('digiriskelementregisterdocument', 'digiriskstandardview', 'globalcard')); // Note that conf->hooks_modules contains array
+
+$object->fetch($conf->global->DIGIRISKDOLIBARR_ACTIVE_STANDARD);
+
+$upload_dir = $conf->digiriskdolibarr->multidir_output[isset($conf->entity) ? $conf->entity : 1];
+
+// Security check - Protection if external user
+$permissiontoread = $user->rights->digiriskdolibarr->digiriskstandard->read && $user->rights->digiriskdolibarr->registerdocument->read;
+$permissiontoadd = $user->rights->digiriskdolibarr->registerdocument->write;
+$permissiontodelete = $user->rights->digiriskdolibarr->registerdocument->delete;
+saturne_check_access($permissiontoread);
+
+/*
+ * Actions
+ */
+
+$parameters = array();
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook)) {
+ $error = 0;
+ $previousRef = $object->ref;
+ $object->ref = '';
+ $removeDocumentFromName = 1;
+
+ // Actions builddoc, forcebuilddoc, remove_file.
+ require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php';
+
+ // Action to generate pdf from odt file
+ require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php';
+
+ $object->ref = $previousRef;
+}
+
+/*
+ * View
+ */
+
+$title = $langs->trans('RegisterDocument');
+$helpUrl = 'FR:Module_Digirisk#Soci.C3.A9t.C3.A9.2FOrganisation';
+
+digirisk_header($title, $helpUrl); ?>
+
+
+
+fetch_optionals();
+
+saturne_get_fiche_head($object, 'standardRegisterDocument', $title);
+
+// Object card
+// ------------------------------------------------------------
+// Project
+$morehtmlref = ' ';
+$project->fetch($conf->global->DIGIRISKDOLIBARR_DU_PROJECT);
+$morehtmlref .= $langs->trans('Project') . ' : ' . getNomUrlProject($project, 1, 'blank', 1);
+$morehtmlref .= ' ';
+
+$moduleNameLowerCase = 'mycompany';
+saturne_banner_tab($object,'ref','none', 0, 'ref', 'ref', $morehtmlref, true);
+$moduleNameLowerCase = 'digiriskdolibarr';
+
+print ' ';
+
+print dol_get_fiche_end();
+
+// Document Generation -- Génération des documents
+$dirFiles = 'registerdocument';
+$filedir = $upload_dir . '/' . $dirFiles ;
+$urlsource = $_SERVER["PHP_SELF"];
+$modulepart = 'digiriskdolibarr:RegisterDocument';
+
+if ($permissiontoadd || $permissiontoread) {
+ $genallowed = 1;
+}
+
+print saturne_show_documents($modulepart, $dirFiles, $filedir, $urlsource, 1,1, '', 1, 0, 0, 0, 0, '', 0, '', empty($soc->default_lang) ? '' : $soc->default_lang, $object);
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/view/firepermit/firepermit_card.php b/view/firepermit/firepermit_card.php
index e65cf6634..3dbd36d2f 100644
--- a/view/firepermit/firepermit_card.php
+++ b/view/firepermit/firepermit_card.php
@@ -690,6 +690,7 @@
print $htmltext;
print ' | ';
print $form->selectcontacts((empty(GETPOST('ext_society', 'int')) ? -1 : GETPOST('ext_society', 'int')), $extSocietyResponsibleId, 'ext_society_responsible', 1, '', '', 1, 'minwidth100imp widthcentpercentminusxx maxwidth400');
+ print '';
print ' |
';
//Labour inspector Society -- Entreprise Inspecteur du travail
@@ -821,7 +822,8 @@
print $htmltext;
print '';
diff --git a/view/preventionplan/preventionplan_list.php b/view/preventionplan/preventionplan_list.php
index 5e93367c4..0b6f4c032 100644
--- a/view/preventionplan/preventionplan_list.php
+++ b/view/preventionplan/preventionplan_list.php
@@ -281,9 +281,9 @@
$sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object->table_element . "_extrafields as ef on (t.rowid = ef.fk_object)";
-if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (" . getEntity($object->element) . ")";
-else $sql .= " WHERE 1 = 1";
-$sql .= ' AND status !=0';
+if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (" . getEntity($object->element) . ")";
+else $sql .= " WHERE 1 = 1";
+$sql .= ' AND status != -1';
foreach ($search as $key => $val) {
@@ -348,10 +348,10 @@
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
-$arrayfields['MasterWorker'] = array('label' => 'MasterWorker', 'checked' => 1);
-$arrayfields['ExtSociety'] = array('label' => 'ExtSociety', 'checked' => 1);
-$arrayfields['ExtSocietyResponsible'] = array('label' => 'ExtSocietyResponsible', 'checked' => 1);
-$arrayfields['ExtSocietyAttendant'] = array('label' => 'ExtSocietyAttendant', 'checked' => 1);
+$arrayfields['MasterWorker'] = array('label' => 'MasterWorker', 'checked' => 1);
+$arrayfields['ExtSociety'] = array('label' => 'ExtSociety', 'checked' => 1);
+$arrayfields['ExtSocietyResponsible'] = array('label' => 'ExtSocietyResponsible', 'checked' => 1);
+$arrayfields['ExtSocietyAttendant'] = array('label' => 'ExtSocietyAttendant', 'checked' => 1);
print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
@@ -362,10 +362,10 @@
print '' . "\n";
print '';
-$object->fields['Custom']['MasterWorker'] = $arrayfields['MasterWorker'] ;
-$object->fields['Custom']['ExtSociety'] = $arrayfields['ExtSociety'];
-$object->fields['Custom']['ExtSocietyResponsible'] = $arrayfields['ExtSocietyResponsible'];
-$object->fields['Custom']['ExtSocietyAttendant'] = $arrayfields['ExtSocietyAttendant'] ;
+$object->fields['Custom']['MasterWorker'] = $arrayfields['MasterWorker'] ;
+$object->fields['Custom']['ExtSociety'] = $arrayfields['ExtSociety'];
+$object->fields['Custom']['ExtSocietyResponsible'] = $arrayfields['ExtSocietyResponsible'];
+$object->fields['Custom']['ExtSocietyAttendant'] = $arrayfields['ExtSocietyAttendant'] ;
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
diff --git a/view/ticket/ticketstatscsv.php b/view/ticket/ticketstatscsv.php
index c01aedc76..efc08c3af 100644
--- a/view/ticket/ticketstatscsv.php
+++ b/view/ticket/ticketstatscsv.php
@@ -21,20 +21,14 @@
* \brief Page with tickets statistics CSV
*/
-// Load Dolibarr environment
-$res = 0;
-// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
-if ( ! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php";
-// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
-$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
-while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
-if ( ! $res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php";
-if ( ! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php";
-// Try main.inc.php using relative path
-if ( ! $res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
-if ( ! $res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
-if ( ! $res && file_exists("../../../../main.inc.php")) $res = @include "../../../../main.inc.php";
-if ( ! $res) die("Include of main fails");
+// Load DigiriskDolibarr environment
+if (file_exists('../../digiriskdolibarr.main.inc.php')) {
+ require_once __DIR__ . '/../../digiriskdolibarr.main.inc.php';
+} elseif (file_exists('../../../digiriskdolibarr.main.inc.php')) {
+ require_once __DIR__ . '/../../../digiriskdolibarr.main.inc.php';
+} else {
+ die('Include of digiriskdolibarr main fails');
+}
// Global variables definitions
global $conf, $db, $langs, $user;
@@ -46,7 +40,7 @@
require_once __DIR__ . '/../../class/ticketdigiriskstats.class.php';
// Load translation files required by the page
-$langs->loadLangs(array('other'));
+saturne_load_langs();
// Get parameters
$action = GETPOST('action', 'aZ09');
@@ -55,19 +49,20 @@
$stats = new TicketDigiriskStats($db);
// Security check
-if (!$user->rights->ticket->read) {
- accessforbidden();
-}
+$permissiontoread = $user->rights->ticket->read;
$upload_dir = $conf->digiriskdolibarr->multidir_output[$conf->entity];
$upload_dir = $upload_dir . '/ticketstats/';
dol_mkdir($upload_dir);
+saturne_check_access($permissiontoread);
+
/*
* Action
*/
if ($action == 'generate_csv') {
+ $categorie = new Categorie($db);
// Open a file in write mode ('w')
$now = dol_now();
$filename = dol_print_date($now, 'dayxcard') . '_ticketstats.csv';
@@ -78,18 +73,49 @@
$fp = fopen($upload_dir . $filename, 'w');
- $data = $stats->getNbTicketByDigiriskElementAndTicketTags((!empty($daterange) ? $date_start : 0), (!empty($daterange) ? $date_end : 0));
- if (is_array($data) && !empty($data)) {
+ list($data, $ticketCategoriesCounter) = $stats->getNbTicketByDigiriskElementAndTicketTags((!empty($daterange) ? $date_start : 0), (!empty($daterange) ? $date_end : 0));
+
+ fputcsv($fp, [$langs->transnoentities('ConcernedTimePeriod') . ' : ' . dol_print_date($date_start) . ' ' . $langs->trans('To') . ' ' . dol_print_date($date_end)]);
+
+ fputcsv($fp, []);
+ fputcsv($fp, []);
+ fputcsv($fp, []);
+
+ if (is_array($ticketCategoriesCounter) && !empty($ticketCategoriesCounter)) {
+ foreach($ticketCategoriesCounter as $ticketCategoryName => $ticketCategoryCounter) {
+ fputcsv($fp, [$ticketCategoryName => $ticketCategoryName . ' : ' . $ticketCategoryCounter]);
+ }
+ }
+
+ fputcsv($fp, []);
+ fputcsv($fp, []);
+ fputcsv($fp, []);
+
+ if (is_array($data) && !empty($data)) {
+
// Loop through file pointer and a line
- $arrayCat = array_keys(reset($data));
- array_unshift($arrayCat, $langs->trans('GP/UT'));
- fputcsv($fp, $arrayCat);
+ $arrayCat = array_keys($data['labels']);
+
+ foreach($arrayCat as $categoryId) {
+ if (is_int($categoryId)) {
+ $categorie->fetch($categoryId);
+ $arrayCatWithLabels[$categoryId] = $categorie->label;
+ } else {
+ $arrayCatWithLabels[$categoryId] = $categoryId;
+ }
+ }
+
+ unset($data['labels']);
+
+ array_unshift($arrayCatWithLabels, $langs->trans('GP/UT'));
+ fputcsv($fp, $arrayCatWithLabels);
$i = 0;
foreach ($data as $row) {
array_unshift($row, array_keys($data)[$i]);
fputcsv($fp, $row);
$i++;
}
+
fclose($fp);
setEventMessages($langs->trans('SuccessGenerateCSV', $filename), null);
} else {
|