diff --git a/admin/event.php b/admin/event.php new file mode 100644 index 000000000..37f5a6133 --- /dev/null +++ b/admin/event.php @@ -0,0 +1,186 @@ + + * + * 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 . + * or see https://www.gnu.org/ + */ + +/** + * \file admin/event.php + * \ingroup digiriskdolibarr + * \brief Digiriskdolibarr config event auto page. + */ + +// 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 $conf, $db, $langs, $module, $user; + +// Libraries +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once __DIR__ . '/../lib/digiriskdolibarr.lib.php'; + +saturne_check_access($user->admin); + +// Load translation files required by the page +saturne_load_langs(['admin', 'other', 'agenda']); + +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$searchEvent = GETPOST('search_event', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Get list of triggers available +$triggers = saturne_fetch_dictionary('c_digiriskdolibarr_action_trigger', 'ASC', 't.rowid'); + +/* + * Actions + */ + +// Purge search criteria +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + $searchEvent = ''; + $action = ''; +} + +if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { // To avoid the save when we click on search + $action = ''; +} + +if ($action == "save" && empty($cancel)) { + $db->begin(); + + foreach ($triggers as $trigger) { + $keyparam = 'DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_'.$trigger->ref; + if ($searchEvent === '' || preg_match('/'.preg_quote($searchEvent, '/').'/i', $keyparam)) { + $res = dolibarr_set_const($db, $keyparam, GETPOST($keyparam, 'alpha') == 'on' ? 1 : 0, 'integer', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + } + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + $db->commit(); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + $db->rollback(); + } +} + +/* + * View + */ + +$form = new Form($db); + +$title = $langs->trans("ModuleSetup", $moduleName); +$helpUrl = 'FR:Module_DigiriskDolibarr'; + +saturne_header(0, '', $title, $helpUrl); + +// Subheader +$linkback = '' . $langs->trans("BackToModuleList") . ''; + +print load_fiche_titre($langs->trans($title), $linkback, 'title_setup'); + +print '
'; +print ''; +print ''; + +// Configuration header +$head = digiriskdolibarr_admin_prepare_head(); +print dol_get_fiche_head($head, 'event', '', -1, $module->picto); + +print load_fiche_titre(' ' . $langs->trans('ConfTrigger'), '', ''); +print '
'; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print ''; + +print ''; +print ''; +print '
' . $langs->trans('Name') . '' . $langs->trans('Description') . '' . $langs->trans('Status') . '
'; +print $langs->trans('AdvancedTriggers'); +print ''; +print $langs->trans('AdvancedTriggersDescription', ucfirst($module)); +print ''; +print ajax_constantonoff('DIGIRISKDOLIBARR_ADVANCED_TRIGGER'); +print '
'; + +print load_fiche_titre($langs->trans('ConfEventAuto'), '', ''); + +print ''.$langs->trans("DigiriskEventAutoDesc").'
'; +print "
\n"; + +print '
'; +print ''; +print ''; +print ''; +print ''; +// Action column +print ''; +print ''; +print ''.'\n'; + +$param = ''; +$param .= '&search_event='.urlencode($searchEvent); + +print ''; +print ''; +print ''; +print ''.'\n'; + +// Show each trigger (list is in c_digiriskdolibarr_action_trigger) +if (!empty($triggers)) { + foreach ($triggers as $trigger) { + if ($searchEvent === '' || preg_match('/' . preg_quote($searchEvent, '/') . '/i', $trigger->ref)) { + print ''; + print ''; + print ''; + print ''; + } + } +} +print '
'; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'.$langs->trans("DigiriskActionsEvents").''.$langs->trans("All").'/'.$langs->trans("None").'
' . $trigger->ref . '' . $langs->trans($trigger->label) . ''; + $key = 'DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_' . $trigger->ref; + $value = $conf->global->$key; + print ''; + print '
'; +print '
'; + +print $form->buttonsSaveCancel(); +print '
'; +print '
'; + +// Page end +print dol_get_fiche_end(); +llxFooter(); +$db->close(); diff --git a/class/accident.class.php b/class/accident.class.php index f34aac360..5bf1627e5 100644 --- a/class/accident.class.php +++ b/class/accident.class.php @@ -659,8 +659,59 @@ public function getGravityRate() { } /** - * Return banner tab content. + * Write information of trigger description * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $conf, $langs; + + require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; + + $userVictim = new User($this->db); + $userEmployer = new User($this->db); + $userVictim->fetch($object->fk_user_victim); + $userEmployer->fetch($object->fk_user_employer); + + //1 : Accident in DU / GP, 2 : Accident in society, 3 : Accident in another location + switch ($object->external_accident) { + case 1: + if (!empty($object->fk_standard)) { + require_once __DIR__ . '/digiriskstandard.class.php'; + $digiriskStandard = new DigiriskStandard($this->db); + $digiriskStandard->fetch($object->fk_standard); + $accidentLocation = $digiriskStandard->ref . " - " . $conf->global->MAIN_INFO_SOCIETE_NOM; + } else if (!empty($object->fk_element)) { + require_once __DIR__ . '/digiriskelement.class.php'; + $digiriskElement = new DigiriskElement($this->db); + $digiriskElement->fetch($object->fk_element); + $accidentLocation = $digiriskElement->ref . " - " . $digiriskElement->label; + } + break; + case 2: + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; + $society = new Societe($this->db); + $society->fetch($object->fk_soc); + $accidentLocation = $society->ref . " - " . $society->label; + case 3: + $accidentLocation = (dol_strlen($object->accident_location) > 0 ? $object->accident_location : $langs->trans('NoData')); + break; + } + + $ret = parent::getTriggerDescription($object); + $ret .= $langs->trans('UserVictim') . ' : ' . $userVictim->firstname . $userVictim->lastname . '
'; + $ret .= $langs->trans('UserEmployer') . ' : ' . $userEmployer->firstname . $userEmployer->lastname . '
'; + $ret .= $langs->trans('AccidentLocation') . ' : ' . $accidentLocation . '
'; + $ret .= $langs->trans('AccidentType') . ' : ' . ($object->accident_type ? $langs->trans('CommutingAccident') : $langs->trans('WorkAccidentStatement')) . '
'; + $ret .= (dol_strlen($object->accident_date) > 0 ? $langs->trans('AccidentDate') . ' : ' . dol_print_date($object->accident_date, 'dayhoursec') . '
' : ''); + + return $ret; + } + + /** + * Return banner tab content. * @return array * @throws Exception */ @@ -774,7 +825,6 @@ public function __construct(DoliDB $db) return parent::__construct($db, $this->module, $this->element); } - /** * Load object in memory from the database * * @param int $parent_id Id parent object @@ -787,6 +837,24 @@ public function fetchFromParent(int $parent_id) return $this->fetchAll('', '', 0, 0, $filter); } + + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $langs; + + $ret = parent::getTriggerDescription($object); + $ret .= $langs->transnoentities('WorkStopDays') . ' : ' . $object->workstop_days . '
'; + $ret .= $langs->transnoentities('WorkStopDocument') . ' : ' . (!empty($object->declaration_link) ? $object->declaration_link : 'N/A') . '
'; + $ret .= (dol_strlen($object->date_start_workstop) > 0 ? $langs->transnoentities('DateStartWorkStop') . ' : ' . dol_print_date($object->date_start_workstop, 'dayhoursec') . '
' : ''); + $ret .= (dol_strlen($object->date_end_workstop) > 0 ? $langs->transnoentities('DateEndWorkStop') . ' : ' . dol_print_date($object->date_end_workstop, 'dayhoursec') . '
' : ''); + + return $ret; + } } /** @@ -1041,4 +1109,21 @@ public function __construct(DoliDB $db) { return parent::__construct($db, $this->module, $this->element); } + + /** + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $langs; + + $ret = parent::getTriggerDescription($object); + $ret .= $langs->transnoentities('LesionLocalization') . ' : ' . $object->lesion_localization . '
'; + $ret .= $langs->transnoentities('LesionNature') . ' : ' . $object->lesion_nature . '
'; + + return $ret; + } } diff --git a/class/digiriskdocuments.class.php b/class/digiriskdocuments.class.php index e45045b9b..1af0d26fa 100644 --- a/class/digiriskdocuments.class.php +++ b/class/digiriskdocuments.class.php @@ -60,8 +60,6 @@ public function __construct(DoliDB $db, $module, $element) */ public function create(User $user, bool $notrigger = false, object $parentObject = null): int { - global $conf; - $now = dol_now(); $this->ref_ext = 'digirisk_' . $this->ref; @@ -72,17 +70,10 @@ public function create(User $user, bool $notrigger = false, object $parentObject $this->type = $this->element; $this->module_name = $this->module; $this->fk_user_creat = $user->id ?: 1; - - if ($parentObject->id > 0) { - $this->parent_id = $parentObject->id; - $this->parent_type = $parentObject->element_type ?: $parentObject->element; - } else { - $this->parent_id = $conf->global->DIGIRISKDOLIBARR_ACTIVE_STANDARD; - $this->parent_type = 'digiriskstandard'; - } + $this->parent_id = $parentObject->id; + $this->parent_type = $parentObject->element; $this->DigiriskFillJSON(); - $this->element = $this->element . '@digiriskdolibarr'; return $this->createCommon($user, $notrigger); } @@ -408,4 +399,28 @@ public function fillRiskData($odfHandler, $object, $outputlangs, $tmparray, $fil } } + + /** + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $langs; + + $className = $object->parent_type; + require_once __DIR__ . '/' . $className .'.class.php'; + $parentElement = new $className($this->db); + $parentElement->fetch($object->parent_id); + + $ret = parent::getTriggerDescription($object); + + $ret .= $langs->transnoentities('ElementType') . ' : ' . $object->parent_type . '
'; + $ret .= $langs->transnoentities('ParentElement') . ' : ' . $parentElement->ref . ' ' . $parentElement->label . '
'; + $ret .= $langs->transnoentities('LastMainDoc') . ' : ' . $object->last_main_doc . '
'; + + return $ret; + } } diff --git a/class/digiriskelement.class.php b/class/digiriskelement.class.php index d26ff82c5..9fb916ea6 100644 --- a/class/digiriskelement.class.php +++ b/class/digiriskelement.class.php @@ -472,21 +472,18 @@ public function getBannerTabContent(): array $digiriskstandard = new DigiriskStandard($db); - dol_strlen($this->label) ? $morehtmlref = ' - ' . $this->label : ''; - // ParentElement $parent_element = new self($db); $result = $parent_element->fetch($this->fk_parent); if ($result > 0) { - $morehtmlref .= '
' . $langs->trans("Description") . ' : ' . $this->description; + $morehtmlref .= $langs->trans("Description") . ' : ' . $this->description; $morehtmlref .= '
' . $langs->trans("ParentElement") . ' : ' . $parent_element->getNomUrl(1, 'blank', 1); } else { $digiriskstandard->fetch($conf->global->DIGIRISKDOLIBARR_ACTIVE_STANDARD); - $morehtmlref .= '
' . $langs->trans("Description") . ' : ' . $this->description; + $morehtmlref .= $langs->trans("Description") . ' : ' . $this->description; $morehtmlref .= '
' . $langs->trans("ParentElement") . ' : ' . $digiriskstandard->getNomUrl(1, 'blank', 1); } $morehtmlref .= '
'; - $linkback = '' . $langs->trans("BackToList") . ''; $this->fetch($this->id); $this->fk_project = $conf->global->DIGIRISKDOLIBARR_DU_PROJECT; $moreParams['project']['disable_edit'] = 1; diff --git a/class/evaluator.class.php b/class/evaluator.class.php index 767e11587..9bdb4ca50 100644 --- a/class/evaluator.class.php +++ b/class/evaluator.class.php @@ -194,4 +194,35 @@ public function getNbEmployees() { } return $array; } + + /** + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $langs; + + require_once __DIR__ . '/digiriskelement.class.php'; + + $ret = parent::getTriggerDescription($object); + + $now = dol_now(); + $userstat = new User($this->db); + $digiriskelement = new DigiriskElement($this->db); + + $digiriskelement->fetch($object->fk_parent); + $userstat->fetch($object->fk_user); + $langs->load('companies'); + + $ret .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; + $ret .= $langs->trans('UserAssigned') . ' : ' . $userstat->firstname . " " . $userstat->lastname . '
'; + $ret .= $langs->trans('PostOrFunction') . ' : ' . (!empty($object->job) ? $object->job : 'N/A') . '
'; + $ret .= $langs->trans('AssignmentDate') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; + $ret .= $langs->trans('EvaluationDuration') . ' : ' . convertSecondToTime($object->duration * 60, 'allhourmin') . ' min' . '
'; + + return $ret; + } } diff --git a/class/firepermit.class.php b/class/firepermit.class.php index 06bdcff0a..c688b95f2 100644 --- a/class/firepermit.class.php +++ b/class/firepermit.class.php @@ -324,6 +324,57 @@ public function LibStatut($status, $mode = 0): string return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } + + /** + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $langs; + + require_once __DIR__ . '/digiriskresources.class.php'; + require_once __DIR__ . '/preventionplan.class.php'; + require_once __DIR__ . '/../../saturne/class/saturnesignature.class.php'; + + $digiriskResources = new DigiriskResources($this->db); + $saturneSignature = new SaturneSignature($this->db, $object->module, $object->element); + $preventionplan = new PreventionPlan($this->db); + $societies = $digiriskResources->fetchResourcesFromObject('', $object); + $signatories = $saturneSignature->fetchSignatories($object->id, $object->element); + $preventionplan->fetch($object->fk_preventionplan); + + $ret = parent::getTriggerDescription($object); + + $ret .= (dol_strlen($object->date_start) > 0 ? $langs->transnoentities('StartDate') . ' : ' . dol_print_date($object->date_start, 'dayhoursec') . '
' : ''); + $ret .= (dol_strlen($object->date_end) > 0 ? $langs->transnoentities('EndDate') . ' : ' . dol_print_date($object->date_end, 'dayhoursec') . '
' : ''); + if (is_array($signatories) && !empty($signatories)) { + foreach($signatories as $signatory) { + $ret .= $langs->transnoentities($signatory->role) . ' : ' . $signatory->firstname . ' ' . $signatory->lastname . '
'; + } + } + if (is_array($societies) && !empty($societies)) { + foreach ($societies as $societename => $key) { + $ret .= $langs->transnoentities($societename) . ' : '; + foreach ($key as $societe) { + if ($societename == 'LabourInspectorAssigned') { + $ret .= $societe->firstname . ' ' . $societe->lastname . '
'; + } else { + $ret .= $societe->name . '
'; + } + if ($societename == 'ExtSociety') { + $ret .= (dol_strlen($societe->address) > 0 ? $langs->transnoentities('Address') . ' : ' . $societe->address . '
' : ''); + $ret .= (dol_strlen($societe->idprof2) > 0 ? $langs->transnoentities('SIRET') . ' : ' . $societe->idprof2 . '
' : ''); + } + } + } + } + $ret .= $langs->transnoentities('PreventionPlan') . ' : ' . $preventionplan->ref . (!empty($preventionplan->label) ? ' ' . $preventionplan->label : '') . '
'; + + return $ret; + } } /** @@ -385,4 +436,30 @@ public function __construct(DoliDB $db) { parent::__construct($db, $this->module, $this->element); } + + /** + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $langs; + + require_once __DIR__ . '/digiriskelement.class.php'; + require_once __DIR__ . '/riskanalysis/risk.class.php'; + + $ret = parent::getTriggerDescription($object); + + $risk = new Risk($this->db); + $digiriskelement = new DigiriskElement($this->db); + $digiriskelement->fetch($object->fk_element); + + $ret .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; + $ret .= $langs->trans('INRSRisk') . ' : ' . $risk->getFirePermitDangerCategoryName($object) . '
'; + $ret .= $langs->trans('UsedEquipment') . ' : ' . (!empty($object->used_equipment) ? $object->used_equipment : 'N/A') . '
'; + + return $ret; + } } diff --git a/class/preventionplan.class.php b/class/preventionplan.class.php index f8e2cca1e..911bf3b53 100644 --- a/class/preventionplan.class.php +++ b/class/preventionplan.class.php @@ -379,6 +379,59 @@ public function select_preventionplan_list($selected = '', $htmlname = 'fk_preve return $form::selectarray($htmlname, $preventionPlansData, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss); } + + /** + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $langs; + + require_once __DIR__ . '/digiriskresources.class.php'; + require_once __DIR__ . '/../../saturne/class/saturnesignature.class.php'; + + $digiriskResources = new DigiriskResources($this->db); + $saturneSignature = new SaturneSignature($this->db, $object->module, $object->element); + $societies = $digiriskResources->fetchResourcesFromObject('', $object); + $signatories = $saturneSignature->fetchSignatories($object->id, $object->element); + + $ret = parent::getTriggerDescription($object); + + $ret .= (dol_strlen($object->date_start) > 0 ? $langs->transnoentities('StartDate') . ' : ' . dol_print_date($object->date_start, 'dayhoursec') . '
' : ''); + $ret .= (dol_strlen($object->date_end) > 0 ? $langs->transnoentities('EndDate') . ' : ' . dol_print_date($object->date_end, 'dayhoursec') . '
' : ''); + if (is_array($signatories) && !empty($signatories)) { + foreach($signatories as $signatory) { + $ret .= $langs->transnoentities($signatory->role) . ' : ' . $signatory->firstname . ' ' . $signatory->lastname . '
'; + } + } + if (is_array($societies) && !empty($societies)) { + foreach ($societies as $societename => $key) { + $ret .= $langs->transnoentities($societename) . ' : '; + foreach ($key as $societe) { + if ($societename == 'LabourInspectorAssigned') { + $ret .= $societe->firstname . ' ' . $societe->lastname . '
'; + } else { + $ret .= $societe->name . '
'; + } + if ($societename == 'ExtSociety') { + $ret .= (dol_strlen($societe->address) > 0 ? $langs->transnoentities('Address') . ' : ' . $societe->address . '
' : ''); + $ret .= (dol_strlen($societe->idprof2) > 0 ? $langs->transnoentities('SIRET') . ' : ' . $societe->idprof2 . '
' : ''); + } + } + } + } + $ret .= $langs->transnoentities('CSSCTIntervention') . ' : ' . ($object->cssct_intervention ? $langs->transnoentities("Yes") : $langs->transnoentities("No")) . '
'; + $ret .= $langs->transnoentities('PriorVisit') . ' : ' . ($object->prior_visit_bool ? $langs->transnoentities("Yes") : $langs->transnoentities("No")) . '
'; + if ($object->prior_visit_bool) { + $ret .= $langs->transnoentities('PriorVisitText') . ' : ' . (!empty($object->prior_visit_text) ? $object->prior_visit_text : 'N/A') . '
'; + $ret .= (dol_strlen($object->prior_visit_date) > 0 ? $langs->transnoentities('PriorVisitDate') . ' : ' . dol_print_date($object->prior_visit_date, 'dayhoursec') . '
' : ''); + } + + return $ret; + } } /** @@ -454,4 +507,30 @@ public function __construct(DoliDB $db) { parent::__construct($db, $this->module, $this->element); } + + /** + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $langs; + + require_once __DIR__ . '/digiriskelement.class.php'; + require_once __DIR__ . '/riskanalysis/risk.class.php'; + + $ret = parent::getTriggerDescription($object); + + $risk = new Risk($this->db); + $digiriskelement = new DigiriskElement($this->db); + $digiriskelement->fetch($object->fk_element); + + $ret .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; + $ret .= $langs->trans('INRSRisk') . ' : ' . $risk->getDangerCategoryName($object) . '
'; + $ret .= $langs->trans('PreventionMethod') . ' : ' . (!empty($object->prevention_method) ? $object->prevention_method : 'N/A') . '
'; + + return $ret; + } } diff --git a/class/riskanalysis/risk.class.php b/class/riskanalysis/risk.class.php index 2fefaa223..b12bbc17d 100644 --- a/class/riskanalysis/risk.class.php +++ b/class/riskanalysis/risk.class.php @@ -582,4 +582,30 @@ public function getRisksByCotation() return $array; } + + /** + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $conf, $langs; + + $ret = parent::getTriggerDescription($object); + + $digiriskelement = new DigiriskElement($this->db); + $digiriskelement->fetch($object->fk_element); + + $ret .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; + $ret .= $langs->trans('RiskCategory') . ' : ' . $object->getDangerCategoryName($object) . '
'; + + if (dol_strlen($object->applied_on) > 0) { + $digiriskelement->fetch($object->applied_on); + $ret .= $langs->trans('RiskSharedWithEntityRefLabel', $object->ref) . ' S' . $conf->entity . ' ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; + } + + return $ret; + } } diff --git a/class/riskanalysis/riskassessment.class.php b/class/riskanalysis/riskassessment.class.php index d9fbfdc98..a12a7cf34 100644 --- a/class/riskanalysis/riskassessment.class.php +++ b/class/riskanalysis/riskassessment.class.php @@ -270,4 +270,35 @@ public function getRiskAssessmentCategoriesNumber($riskAssessmentList = [], $ris return $scaleCounter; } + + /** + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $conf, $langs; + + $risk = new Risk($this->db); + $risk->fetch($object->fk_risk); + + $ret = parent::getTriggerDescription($object); + + $ret .= $langs->trans('ParentRisk') . ' : ' . $risk->ref . '
'; + $ret .= $langs->trans('Comment') . ' : ' . (!empty($object->comment) ? $object->comment : 'N/A') . '
'; + $ret .= ((!empty($object->date_riskassessment) && $conf->global->DIGIRISKDOLIBARR_SHOW_RISKASSESSMENT_DATE) ? $langs->trans('RiskAssessmentDate') . ' : ' . dol_print_date($object->date_riskassessment, 'day') . '
' : ''); + $ret .= $langs->trans('Photo') . ' : ' . (!empty($object->photo) ? $object->photo : 'N/A') . '
'; + if ($object->method == 'advanced') { + $ret .= $langs->trans('Evaluation') . ' : ' . $object->cotation . '
'; + $ret .= $langs->trans('Gravity') . ' : ' . $object->gravite . '
'; + $ret .= $langs->trans('Protection') . ' : ' . $object->protection . '
'; + $ret .= $langs->trans('Occurrence') . ' : ' . $object->occurrence . '
'; + $ret .= $langs->trans('Formation') . ' : ' . $object->formation . '
'; + $ret .= $langs->trans('Exposition') . ' : ' . $object->exposition . '
'; + } + + return $ret; + } } diff --git a/class/riskanalysis/risksign.class.php b/class/riskanalysis/risksign.class.php index 835389aa8..2177ba476 100644 --- a/class/riskanalysis/risksign.class.php +++ b/class/riskanalysis/risksign.class.php @@ -131,7 +131,7 @@ public function fetchFromParent($parent_id) */ public function getRiskSignCategories() { - $json_categories = file_get_contents(DOL_DOCUMENT_ROOT . '/custom/digiriskdolibarr/js/json/signalisationCategories.json'); + $json_categories = file_get_contents(DOL_DOCUMENT_ROOT . '/custom/digiriskdolibarr/js/json/signalisationCategories.json'); return json_decode($json_categories, true); } @@ -309,4 +309,34 @@ public function fetchRiskSign($parent_id, $get_parents_data = false, $get_shared return -1; } } + + /** + * Write information of trigger description + * + * @param Object $object Object calling the trigger + * @return string Description to display in actioncomm->note_private + */ + public function getTriggerDescription(SaturneObject $object): string + { + global $conf, $langs; + + require_once __DIR__ . '/../digiriskelement.class.php'; + require_once __DIR__ . '/risk.class.php'; + + $ret = parent::getTriggerDescription($object); + + $digiriskelement = new DigiriskElement($this->db); + $risk = new Risk($this->db); + $digiriskelement->fetch($object->fk_element); + + $ret .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; + $ret .= $langs->trans('RiskCategory') . ' : ' . $risk->getDangerCategoryName($object) . '
'; + + if (dol_strlen($object->applied_on) > 0) { + $digiriskelement->fetch($object->applied_on); + $ret .= $langs->trans('RiskSignSharedWithEntityRefLabel', $object->ref) . ' S' . $conf->entity . ' ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; + } + + return $ret; + } } diff --git a/core/modules/modDigiriskDolibarr.class.php b/core/modules/modDigiriskDolibarr.class.php index e295e8ad5..e5be2752e 100644 --- a/core/modules/modDigiriskDolibarr.class.php +++ b/core/modules/modDigiriskDolibarr.class.php @@ -484,86 +484,86 @@ public function __construct($db) $i = 0; $this->const = [ // CONST CONFIGURATION - $i++ => array('DIGIRISKDOLIBARR_GENERAL_MEANS', 'chaine', $langs->transnoentities('GeneralMeansAtDisposalValue'), '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_GENERAL_RULES', 'chaine', $langs->transnoentities('GeneralInstructionsValue'), '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_IDCC_DICTIONNARY', 'chaine', '', 'IDCC of company', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_SOCIETY_DESCRIPTION', 'chaine', '', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_PEE_ENABLED', 'integer', 0, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_PERCO_ENABLED', 'integer', 0, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_SECURITY_SOCIAL_CONF_UPDATED', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_NB_EMPLOYEES', 'integer', '', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_NB_WORKED_HOURS', 'integer', '', '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_GENERAL_MEANS', 'chaine', $langs->transnoentities('GeneralMeansAtDisposalValue'), '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_GENERAL_RULES', 'chaine', $langs->transnoentities('GeneralInstructionsValue'), '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_IDCC_DICTIONNARY', 'chaine', '', 'IDCC of company', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_SOCIETY_DESCRIPTION', 'chaine', '', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_PEE_ENABLED', 'integer', 0, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_PERCO_ENABLED', 'integer', 0, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_SECURITY_SOCIAL_CONF_UPDATED', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_NB_EMPLOYEES', 'integer', '', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_NB_WORKED_HOURS', 'integer', '', '', 0, 'current'], // CONST RISK ASSESSMENTDOCUMENT - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_AUDIT_START_DATE', 'date', '', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_AUDIT_END_DATE', 'date', '', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT', 'integer', 0, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_METHOD', 'chaine', $langs->transnoentities('RiskAssessmentDocumentMethod'), '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_SOURCES', 'chaine', $langs->transnoentities('RiskAssessmentDocumentSources'), '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_IMPORTANT_NOTES', 'chaine', $langs->transnoentities('RiskAssessmentDocumentImportantNote'), '', 0, 'current'), - - $i++ => array('MAIN_AGENDA_ACTIONAUTO_RISKASSESSMENTDOCUMENT_CREATE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_ADDON','chaine', 'mod_riskassessmentdocument_standard', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/riskassessmentdocument/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/riskassessmentdocument/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_DEFAULT_MODEL', 'chaine', 'riskassessmentdocument_odt', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_SHOW_TASK_DONE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_GENERATE_ARCHIVE_WITH_DIGIRISKELEMENT_DOCUMENTS', 'integer', 1, '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_AUDIT_START_DATE', 'date', '', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_AUDIT_END_DATE', 'date', '', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_RECIPIENT', 'integer', 0, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_METHOD', 'chaine', $langs->transnoentities('RiskAssessmentDocumentMethod'), '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_SOURCES', 'chaine', $langs->transnoentities('RiskAssessmentDocumentSources'), '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_IMPORTANT_NOTES', 'chaine', $langs->transnoentities('RiskAssessmentDocumentImportantNote'), '', 0, 'current'], + + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISKASSESSMENTDOCUMENT_GENERATE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_ADDON','chaine', 'mod_riskassessmentdocument_standard', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/riskassessmentdocument/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/riskassessmentdocument/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_DEFAULT_MODEL', 'chaine', 'riskassessmentdocument_odt', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RISKASSESSMENTDOCUMENT_SHOW_TASK_DONE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_GENERATE_ARCHIVE_WITH_DIGIRISKELEMENT_DOCUMENTS', 'integer', 1, '', 0, 'current'], // CONST LEGAL DISPLAY - $i++ => array('DIGIRISKDOLIBARR_LOCATION_OF_DETAILED_INSTRUCTION', 'chaine', $langs->transnoentities('LocationOfDetailedInstructionsValue'), '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_PERMANENT', 'chaine', $langs->transnoentities('PermanentDerogationValue'), '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_OCCASIONAL', 'chaine', $langs->transnoentities('OccasionalDerogationValue'), '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_COLLECTIVE_AGREEMENT_TITLE', 'chaine', '', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_COLLECTIVE_AGREEMENT_LOCATION', 'chaine', $langs->transnoentities('CollectiveAgreementValue'), '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_DUER_LOCATION','chaine', '', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_RULES_LOCATION', 'chaine', $langs->transnoentities('RulesOfProcedureValue'), '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_PARTICIPATION_AGREEMENT_INFORMATION_PROCEDURE', 'chaine', $langs->transnoentities('ParticipationAgreementValue'), '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_FIRST_AID', 'chaine', $langs->transnoentities('FirstAidValue'), '', 0, 'current'), - - $i++ => array('MAIN_AGENDA_ACTIONAUTO_LEGALDISPLAY_CREATE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LEGALDISPLAY_ADDON', 'chaine', 'mod_legaldisplay_standard', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LEGALDISPLAY_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/legaldisplay/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LEGALDISPLAY_CUSTOM_ADDON_ODT_PATH','chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/legaldisplay/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LEGALDISPLAY_DEFAULT_MODEL', 'chaine', 'legaldisplay_odt', '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_LOCATION_OF_DETAILED_INSTRUCTION', 'chaine', $langs->transnoentities('LocationOfDetailedInstructionsValue'), '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_PERMANENT', 'chaine', $langs->transnoentities('PermanentDerogationValue'), '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_DEROGATION_SCHEDULE_OCCASIONAL', 'chaine', $langs->transnoentities('OccasionalDerogationValue'), '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_COLLECTIVE_AGREEMENT_TITLE', 'chaine', '', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_COLLECTIVE_AGREEMENT_LOCATION', 'chaine', $langs->transnoentities('CollectiveAgreementValue'), '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_DUER_LOCATION','chaine', '', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_RULES_LOCATION', 'chaine', $langs->transnoentities('RulesOfProcedureValue'), '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_PARTICIPATION_AGREEMENT_INFORMATION_PROCEDURE', 'chaine', $langs->transnoentities('ParticipationAgreementValue'), '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_FIRST_AID', 'chaine', $langs->transnoentities('FirstAidValue'), '', 0, 'current'], + + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_LEGALDISPLAY_GENERATE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LEGALDISPLAY_ADDON', 'chaine', 'mod_legaldisplay_standard', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LEGALDISPLAY_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/legaldisplay/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LEGALDISPLAY_CUSTOM_ADDON_ODT_PATH','chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/legaldisplay/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LEGALDISPLAY_DEFAULT_MODEL', 'chaine', 'legaldisplay_odt', '', 0, 'current'], // CONST INFORMATIONS SHARING - $i++ => array('MAIN_AGENDA_ACTIONAUTO_INFORMATIONSSHARING_CREATE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_INFORMATIONSSHARING_ADDON', 'chaine', 'mod_informationssharing_standard', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_INFORMATIONSSHARING_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/informationssharing/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_INFORMATIONSSHARING_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/informationssharing/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_INFORMATIONSSHARING_DEFAULT_MODEL', 'chaine', 'informationssharing_odt', '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_INFORMATIONSSHARING_GENERATE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_INFORMATIONSSHARING_ADDON', 'chaine', 'mod_informationssharing_standard', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_INFORMATIONSSHARING_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/informationssharing/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_INFORMATIONSSHARING_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/informationssharing/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_INFORMATIONSSHARING_DEFAULT_MODEL', 'chaine', 'informationssharing_odt', '', 0, 'current'], // CONST LISTING RISKS ACTION - $i++ => array('MAIN_AGENDA_ACTIONAUTO_LISTINGRISKSACTION_CREATE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LISTINGRISKSACTION_ADDON', 'chaine', 'mod_listingrisksaction_standard', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LISTINGRISKSACTION_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/listingrisksaction/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LISTINGRISKSACTION_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/listingrisksaction/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LISTINGRISKSACTION_DEFAULT_MODEL', 'chaine', 'listingrisksaction_odt', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LISTINGRISKSACTION_SHOW_TASK_DONE', 'integer', 1, '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_LISTINGRISKSACTION_GENERATE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LISTINGRISKSACTION_ADDON', 'chaine', 'mod_listingrisksaction_standard', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LISTINGRISKSACTION_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/listingrisksaction/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LISTINGRISKSACTION_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/listingrisksaction/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LISTINGRISKSACTION_DEFAULT_MODEL', 'chaine', 'listingrisksaction_odt', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LISTINGRISKSACTION_SHOW_TASK_DONE', 'integer', 1, '', 0, 'current'], // CONST LISTING RISKS PHOTO - $i++ => array('MAIN_AGENDA_ACTIONAUTO_LISTINGRISKSPHOTO_CREATE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LISTINGRISKSPHOTO_ADDON', 'chaine', 'mod_listingrisksphoto_standard', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LISTINGRISKSPHOTO_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/listingrisksphoto/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LISTINGRISKSPHOTO_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/listingrisksphoto/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_LISTINGRISKSPHOTO_DEFAULT_MODEL', 'chaine', 'listingrisksphoto_odt', '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_LISTINGRISKSPHOTO_GENERATE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LISTINGRISKSPHOTO_ADDON', 'chaine', 'mod_listingrisksphoto_standard', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LISTINGRISKSPHOTO_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/listingrisksphoto/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LISTINGRISKSPHOTO_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/listingrisksphoto/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_LISTINGRISKSPHOTO_DEFAULT_MODEL', 'chaine', 'listingrisksphoto_odt', '', 0, 'current'], // CONST GROUPMENT DOCUMENT - $i++ => array('MAIN_AGENDA_ACTIONAUTO_GROUPMENTDOCUMENT_CREATE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_ADDON', 'chaine', 'mod_groupmentdocument_standard', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/groupmentdocument/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/groupmentdocument/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_DEFAULT_MODEL', 'chaine', 'groupmentdocument_odt', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_SHOW_TASK_DONE', 'integer', 1, '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_GROUPMENTDOCUMENT_GENERATE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_ADDON', 'chaine', 'mod_groupmentdocument_standard', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/groupmentdocument/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/groupmentdocument/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_DEFAULT_MODEL', 'chaine', 'groupmentdocument_odt', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_SHOW_TASK_DONE', 'integer', 1, '', 0, 'current'], // CONST WORKUNIT DOCUMENT - $i++ => array('MAIN_AGENDA_ACTIONAUTO_WORKUNITDOCUMENT_CREATE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_WORKUNITDOCUMENT_ADDON', 'chaine', 'mod_workunitdocument_standard', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_WORKUNITDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/workunitdocument/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_WORKUNITDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/workunitdocument/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_WORKUNITDOCUMENT_DEFAULT_MODEL', 'chaine', 'workunitdocument_odt', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_WORKUNITDOCUMENT_SHOW_TASK_DONE', 'integer', 1, '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_WORKUNITDOCUMENT_GENERATE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_WORKUNITDOCUMENT_ADDON', 'chaine', 'mod_workunitdocument_standard', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_WORKUNITDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/workunitdocument/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_WORKUNITDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/workunitdocument/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_WORKUNITDOCUMENT_DEFAULT_MODEL', 'chaine', 'workunitdocument_odt', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_WORKUNITDOCUMENT_SHOW_TASK_DONE', 'integer', 1, '', 0, 'current'], // CONST PREVENTION PLAN $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_PREVENTIONPLAN_CREATE', 'integer', 1, '', 0, 'current'], @@ -580,12 +580,12 @@ public function __construct($db) $i++ => ['DIGIRISKDOLIBARR_PREVENTIONPLAN_MAITRE_OEUVRE', 'integer', 0, '', 0, 'current'], // CONST PREVENTION PLAN DOCUMENT - $i++ => array('MAIN_AGENDA_ACTIONAUTO_PREVENTIONPLANDOCUMENT_CREATE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_PREVENTIONPLANDOCUMENT_ADDON', 'chaine', 'mod_preventionplandocument_standard', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_PREVENTIONPLANDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/preventionplandocument/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_PREVENTIONPLANDOCUMENT_SPECIMEN_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/preventionplandocument/specimen/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_PREVENTIONPLANDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/preventionplandocument/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_PREVENTIONPLANDOCUMENT_DEFAULT_MODEL', 'chaine', 'preventionplandocument_odt', '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_PREVENTIONPLANDOCUMENT_GENERATE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_PREVENTIONPLANDOCUMENT_ADDON', 'chaine', 'mod_preventionplandocument_standard', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_PREVENTIONPLANDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/preventionplandocument/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_PREVENTIONPLANDOCUMENT_SPECIMEN_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/preventionplandocument/specimen/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_PREVENTIONPLANDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/preventionplandocument/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_PREVENTIONPLANDOCUMENT_DEFAULT_MODEL', 'chaine', 'preventionplandocument_odt', '', 0, 'current'], // CONST FIRE PERMIT $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_FIREPERMIT_CREATE','integer', 1, '', 0, 'current'], @@ -602,17 +602,17 @@ public function __construct($db) $i++ => ['DIGIRISKDOLIBARR_FIREPERMIT_MAITRE_OEUVRE', 'integer', 0, '', 0, 'current'], // CONST FIRE PERMIT DOCUMENT - $i++ => array('MAIN_AGENDA_ACTIONAUTO_FIREPERMITDOCUMENT_CREATE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_FIREPERMITDOCUMENT_ADDON', 'chaine', 'mod_firepermitdocument_standard', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_FIREPERMITDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/firepermitdocument/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_FIREPERMITDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/firepermitdocument/', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_FIREPERMITDOCUMENT_DEFAULT_MODEL', 'chaine', 'firepermitdocument_odt', '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_FIREPERMITDOCUMENT_GENERATE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_FIREPERMITDOCUMENT_ADDON', 'chaine', 'mod_firepermitdocument_standard', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_FIREPERMITDOCUMENT_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/firepermitdocument/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_FIREPERMITDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT' . (($conf->entity == 1 ) ? '/' : '/' . $conf->entity . '/') . 'ecm/digiriskdolibarr/firepermitdocument/', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_FIREPERMITDOCUMENT_DEFAULT_MODEL', 'chaine', 'firepermitdocument_odt', '', 0, 'current'], //CONST DIGIRISKELEMENT - $i++ => array('DIGIRISKDOLIBARR_DIGIRISKELEMENT_MEDIAS_BACKWARD_COMPATIBILITY', 'integer', 0, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH', 'integer', 0, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH_UPDATED', 'integer', 0, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_SHOW_HIDDEN_DIGIRISKELEMENT', 'integer', 0, '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_DIGIRISKELEMENT_MEDIAS_BACKWARD_COMPATIBILITY', 'integer', 0, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH', 'integer', 0, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH_UPDATED', 'integer', 0, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_SHOW_HIDDEN_DIGIRISKELEMENT', 'integer', 0, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_DIGIRISKSIGNATURE_PENDING_SIGNATURE', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_DIGIRISKELEMENT_CREATE', 'integer', 1, '', 0, 'current'], @@ -623,16 +623,18 @@ public function __construct($db) $i++ => ['DIGIRISKDOLIBARR_WORKUNIT_ADDON', 'chaine', 'mod_workunit_standard', '', 0, 'current'], // CONST EVALUATOR - $i++ => array('MAIN_AGENDA_ACTIONAUTO_EVALUATOR_CREATE', 'integer', 1, '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_EVALUATOR_ADDON', 'chaine', 'mod_evaluator_standard', '', 0, 'current'), - $i++ => array('DIGIRISKDOLIBARR_EVALUATOR_DURATION', 'integer', 15, '', 0, 'current'), + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_EVALUATOR_CREATE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_EVALUATOR_ADDON', 'chaine', 'mod_evaluator_standard', '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_EVALUATOR_DURATION', 'integer', 15, '', 0, 'current'], // CONST RISK ANALYSIS // CONST RISK $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISK_CREATE', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISK_MODIFY', 'integer', 1, '', 0, 'current'], - $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISK_DELETE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISK_DELETE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISK_IMPORT', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISK_UNLINK', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_RISK_ADDON', 'chaine', 'mod_risk_standard', '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_RISK_DESCRIPTION', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_RISK_CATEGORY_EDIT', 'integer', 0, '', 0, 'current'], @@ -658,7 +660,9 @@ public function __construct($db) // CONST RISK SIGN $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISKSIGN_CREATE', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISKSIGN_MODIFY', 'integer', 1, '', 0, 'current'], - $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISKSIGN_DELETE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISKSIGN_DELETE', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISKSIGN_IMPORT', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISKSIGN_UNLINK', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_RISKSIGN_ADDON', 'chaine', 'mod_risksign_standard', '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_SHOW_RISKSIGNS', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_SHOW_INHERITED_RISKSIGNS', 'integer', 0, '', 0, 'current'], @@ -804,13 +808,6 @@ public function __construct($db) // CONST PROJECT DOCUMENT $i++ => ['DIGIRISKDOLIBARR_PROJECTDOCUMENT_ADDON', 'chaine', 'mod_projectdocument_standard', '', 0, 'current'], -// // CONST ACCIDENT DOCUMENT -// $i++ => ['MAIN_AGENDA_ACTIONAUTO_ACCIDENTDOCUMENT_CREATE', 'integer', 1, '', 0, 'current'], -// $i++ => ['DIGIRISKDOLIBARR_ACCIDENTDOCUMENT_ADDON', 'chaine', 'mod_accidentdocument_standard', '', 0, 'current'], -// $i++ => ['DIGIRISKDOLIBARR_ACCIDENTDOCUMENT_ADDON_ODT_PATH','chaine', 'DOL_DOCUMENT_ROOT/custom/digiriskdolibarr/documents/doctemplates/accidentdocument/', '', 0, 'current'], -// $i++ => ['DIGIRISKDOLIBARR_ACCIDENTDOCUMENT_CUSTOM_ADDON_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/ecm/digiriskdolibarr/accidentdocument/', '', 0, 'current'], -// $i++ => ['DIGIRISKDOLIBARR_ACCIDENTDOCUMENT_DEFAULT_MODEL', 'chaine', 'accidentdocument_odt', '', 0, 'current'], - // GENERAL CONSTS $i++ => ['MAIN_ODT_AS_PDF', 'chaine', 'libreoffice', '', 0, 'current'], $i++ => ['MAIN_USE_EXIF_ROTATION', 'integer', 1, '', 0, 'current'], @@ -849,6 +846,7 @@ public function __construct($db) $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_ACCIDENTINVESTIGATION_UNVALIDATE', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_ACCIDENTINVESTIGATION_ARCHIVE', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_ACCIDENTINVESTIGATION_LOCK', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_ACCIDENTINVESTIGATION_SENTBYMAIL', 'integer', 1, '', 0, 'current'], // CONST ACCIDENT INVESTIGATION DOCUMENT $i++ => ['DIGIRISKDOLIBARR_ACCIDENTINVESTIGATIONDOCUMENT_ADDON', 'chaine', 'mod_accident_investigation_document_standard', '', 0, 'current'], diff --git a/core/tpl/digiriskdocuments/digiriskdolibarr_riskassessmentdocumentfields_view.tpl.php b/core/tpl/digiriskdocuments/digiriskdolibarr_riskassessmentdocumentfields_view.tpl.php index 6dfa73916..0af660c57 100644 --- a/core/tpl/digiriskdocuments/digiriskdolibarr_riskassessmentdocumentfields_view.tpl.php +++ b/core/tpl/digiriskdocuments/digiriskdolibarr_riskassessmentdocumentfields_view.tpl.php @@ -81,21 +81,7 @@ print ''; print '' . $form->editfieldkey($langs->trans("SitePlans"), 'SitePlans', '', $object, 0) . ''; print ''; - $filearray = dol_dir_list($conf->digiriskdolibarr->multidir_output[$conf->entity] . '/riskassessmentdocument/', "files", 0, '', '(\.odt|\.zip)', 'date', 'asc', 1); - if (count($filearray)) : ?> - - - entity . '&file=' . urlencode('/riskassessmentdocument/thumbs/' . $thumb_name) . '" >'; ?> - - - - - No photo - - digiriskdolibarr->multidir_output[$conf->entity] . '/riskassessmentdocument/siteplans', 'small', '', 0, 0, 0, 200, 200, 0, 0, 0, 'riskassessmentdocument/siteplans', null, '', 0, 0); print ''; print ''; } else { @@ -141,22 +127,8 @@ print ''; print '' . $langs->trans("SitePlans") . ''; print ''; - $filearray = dol_dir_list($conf->digiriskdolibarr->multidir_output[$conf->entity] . '/riskassessmentdocument/', "files", 0, '', '(\.odt|\.zip)', 'date', 'asc', 1); - if (count($filearray)) : ?> - - - entity . '&file=' . urlencode('/riskassessmentdocument/thumbs/' . $thumb_name) . '" >'; ?> - - - - - No photo - - - '; + print saturne_show_medias_linked('digiriskdolibarr', $conf->digiriskdolibarr->multidir_output[$conf->entity] . '/riskassessmentdocument/siteplans', 'small', '', 0, 0, 0, 200, 200, 0, 0, 0, 'riskassessmentdocument/siteplans', null, '', 0, 0); + print ''; } ?> diff --git a/core/triggers/interface_99_modDigiriskdolibarr_DigiriskdolibarrTriggers.class.php b/core/triggers/interface_99_modDigiriskdolibarr_DigiriskdolibarrTriggers.class.php index 6297beb06..d0c0a108e 100644 --- a/core/triggers/interface_99_modDigiriskdolibarr_DigiriskdolibarrTriggers.class.php +++ b/core/triggers/interface_99_modDigiriskdolibarr_DigiriskdolibarrTriggers.class.php @@ -101,27 +101,32 @@ public function getDesc() * All functions "runTrigger" are triggered if file * is inside directory core/triggers * - * @param string $action Event action code + * @param string $action Event action code * @param CommonObject $object Object - * @param User $user Object user - * @param Translate $langs Object langs - * @param Conf $conf Object conf - * @return int <0 if KO, 0 if no triggered ran, >0 if OK + * @param User $user Object user + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK * @throws Exception */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - $active = getDolGlobalInt('DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_' . $action); - - if (!isModEnabled('digiriskdolibarr') || $active != 1) { - return 0; // If module is not enabled or trigger is deactivated, we do nothing + $action = str_replace('@DIGIRISKDOLIBARR', '', $action); + $active = getDolGlobalInt('DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_' . $action); + + if (!isModEnabled('digiriskdolibarr') || !$active) { + $allowedTriggers = ['COMPANY_DELETE', 'CONTACT_DELETE', 'TICKET_CREATE']; + if (!in_array($action, $allowedTriggers)) { + return 0; // If module is not enabled or trigger is deactivated, we do nothing + } } // Data and type of action are stored into $object and $action dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . '. id=' . $object->id); require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; - require_once __DIR__ . '/../../class/digiriskresources.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; + require_once __DIR__ . '/../../class/digiriskresources.class.php'; require_once __DIR__ . '/../../class/digiriskelement.class.php'; require_once __DIR__ . '/../../class/digiriskstandard.class.php'; @@ -139,31 +144,12 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $actioncomm->userownerid = $user->id; $actioncomm->percentage = -1; + // Trigger descriptions are handled by class function getTriggerDescription if (getDolGlobalInt('DIGIRISKDOLIBARR_ADVANCED_TRIGGER') && !empty($object->fields)) { $actioncomm->note_private = method_exists($object, 'getTriggerDescription') ? $object->getTriggerDescription($object) : ''; } switch ($action) { - case 'INFORMATIONSSHARING_GENERATE' : - $digiriskstandard->fetch($object->parent_id); - $actioncomm->elementtype = $object->parent_type . '@digiriskdolibarr'; - $actioncomm->elementid = $object->parent_id; - - $actioncomm->label = $langs->trans('ObjectGenerateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $object->parent_type . '
'; - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskstandard->ref . ' ' . $digiriskstandard->label . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LastMainDoc') . ' : ' . $object->last_main_doc . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Type') . ' : ' . $object->type . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->parent_id; - - $result = $actioncomm->create($user); - break; - case 'COMPANY_DELETE' : require_once __DIR__ . '/../../class/preventionplan.class.php'; require_once __DIR__ . '/../../class/firepermit.class.php'; @@ -227,190 +213,22 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf } break; - case 'LEGALDISPLAY_GENERATE' : - $digiriskstandard->fetch($object->parent_id); - - $actioncomm->elementtype = $object->parent_type . '@digiriskdolibarr'; - $actioncomm->elementid = $object->parent_id; - - $actioncomm->label = $langs->trans('ObjectGenerateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $object->parent_type . '
'; - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskstandard->ref . ' ' . $digiriskstandard->label . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LastMainDoc') . ' : ' . $object->last_main_doc . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Type') . ' : ' . $object->type . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->parent_id; - - $result = $actioncomm->create($user); - break; - + case 'RISKASSESSMENTDOCUMENT_GENERATE' : + case 'LEGALDISPLAY_GENERATE' : + case 'INFORMATIONSSHARING_GENERATE' : + case 'FIREPERMITDOCUMENT_GENERATE' : case 'PREVENTIONPLANDOCUMENT_GENERATE' : - $preventionplan = new PreventionPlan($this->db); - $preventionplan->fetch($object->parent_id); - - $actioncomm->elementtype = $object->parent_type . '@digiriskdolibarr'; - $actioncomm->elementid = $object->parent_id; - - $actioncomm->label = $langs->trans('ObjectGenerateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $object->parent_type . '
'; - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $preventionplan->ref . ' ' . $preventionplan->label . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LastMainDoc') . ' : ' . $object->last_main_doc . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Type') . ' : ' . $object->type . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->parent_id; - - $result = $actioncomm->create($user); - break; - - case 'FIREPERMITDOCUMENT_GENERATE' : - $firepermit = new FirePermit($this->db); - $firepermit->fetch($object->parent_id); - - $actioncomm->elementtype = $object->parent_type . '@digiriskdolibarr'; - $actioncomm->elementid = $object->parent_id; - - $actioncomm->label = $langs->trans('ObjectGenerateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $object->parent_type . '
'; - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $firepermit->ref . ' ' . $firepermit->label . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LastMainDoc') . ' : ' . $object->last_main_doc . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Type') . ' : ' . $object->type . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->parent_id; - - $result = $actioncomm->create($user); - break; - + case 'LISTINGRISKSACTION_GENERATE' : + case 'LISTINGRISKSPHOTO_GENERATE' : + case 'WORKUNITDOCUMENT_GENERATE' : case 'GROUPMENTDOCUMENT_GENERATE' : - $digiriskelement->fetch($object->parent_id); - - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->elementid = $object->parent_id; + $actioncomm->elementtype = $object->parent_type . '@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectGenerateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $object->parent_type . '
'; - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . ' ' . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LastMainDoc') . ' : ' . $object->last_main_doc . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Type') . ' : ' . $object->type . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->parent_id; + $actioncomm->label = $langs->trans('ObjectGenerateTrigger', $langs->transnoentities(ucfirst(get_class($object))), $object->ref); + $actioncomm->elementid = $object->parent_id; + $actioncomm->fk_element = $object->parent_id; - $result = $actioncomm->create($user); - break; - - case 'WORKUNITDOCUMENT_GENERATE' : - $digiriskelement->fetch($object->parent_id); - - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->elementid = $object->parent_id; - - $actioncomm->label = $langs->trans('ObjectGenerateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $object->parent_type . '
'; - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . ' ' . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LastMainDoc') . ' : ' . $object->last_main_doc . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Type') . ' : ' . $object->type . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->parent_id; - - $result = $actioncomm->create($user); - break; - - case 'LISTINGRISKSPHOTO_GENERATE' : - - if ($object->parent_type == 'digiriskstandard') { - $actioncomm->elementtype = 'digiriskstandard@digiriskdolibarr'; - $parentelement = new DigiriskStandard($this->db); - $parentelement->fetch($object->parent_id); - } else { - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $parentelement = new DigiriskElement($this->db); - $parentelement->fetch($object->parent_id); - } - - $actioncomm->elementid = $object->parent_id; - - $actioncomm->label = $langs->trans('ObjectGenerateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $object->parent_type . '
'; - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $parentelement->ref . ' ' . $parentelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LastMainDoc') . ' : ' . $object->last_main_doc . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Type') . ' : ' . $object->type . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->parent_id; - - $result = $actioncomm->create($user); - break; - - case 'LISTINGRISKSACTION_GENERATE' : - - if ($object->parent_type == 'digiriskstandard') { - $actioncomm->elementtype = 'digiriskstandard@digiriskdolibarr'; - $parentelement = new DigiriskStandard($this->db); - $parentelement->fetch($object->parent_id); - } else { - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $parentelement = new DigiriskElement($this->db); - $parentelement->fetch($object->parent_id); - } - - $actioncomm->elementid = $object->parent_id; - - $actioncomm->label = $langs->trans('ObjectGenerateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $object->parent_type . '
'; - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $parentelement->ref . ' ' . $parentelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LastMainDoc') . ' : ' . $object->last_main_doc . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Type') . ' : ' . $object->type . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->parent_id; - - $result = $actioncomm->create($user); - break; - - case 'RISKASSESSMENTDOCUMENT_GENERATE' : - $digiriskstandard->fetch($object->parent_id); - - $actioncomm->elementtype = $object->parent_type . '@digiriskdolibarr'; - $actioncomm->elementid = $object->parent_id; - - $actioncomm->label = $langs->trans('ObjectGenerateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $object->parent_type . '
'; - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskstandard->ref . ' ' . $digiriskstandard->label . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LastMainDoc') . ' : ' . $object->last_main_doc . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Type') . ' : ' . $object->type . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->parent_id; - - $result = $actioncomm->create($user); + $result = $actioncomm->create($user); break; case 'DIGIRISKELEMENT_CREATE' : @@ -420,478 +238,148 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $digiriskelement->fetch($object->fk_parent); $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . ' - ' . $digiriskelement->label . '
'; } + $object->fetch($object->id); $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; $actioncomm->elementid = $object->id; - $actioncomm->label = $langs->transnoentities('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Standard') . ' : ' . $digiriskstandard->ref . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM . '
'; + $actioncomm->label = $langs->transnoentities('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element_type)), $object->ref); + $actioncomm->note_private .= $langs->trans('Standard') . ' : ' . $digiriskstandard->ref . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM . '
'; $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; $actioncomm->note_private .= $langs->trans('Label') . ' : ' . $object->label . '
'; $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; $actioncomm->note_private .= $langs->trans('Photo') . ' : ' . (!empty($object->photo) ? $object->photo : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; $actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $langs->trans($object->element_type) . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : 1' . '
'; ($object->ranks != 0 ? $actioncomm->note_private .= $langs->trans('Order') . ' : ' . $object->ranks . '
' : ''); $actioncomm->note_private .= $langs->trans('ShowInSelectOnPublicTicketInterface') . ' : ' . ($object->show_in_selector ? $langs->trans('Yes') : $langs->trans('No')) . '
'; $result = $actioncomm->create($user); break; - case 'PREVENTIONPLAN_MODIFY' : - $societies = $digiriskresources->fetchResourcesFromObject('', $object); - $digirisksignature = new SaturneSignature($this->db, $object->module, $object->element); - $signatories = $digirisksignature->fetchSignatories($object->id, $object->element); + case 'ACCIDENT_CREATE' : + case 'ACCIDENTINVESTIGATION_CREATE' : + case 'FIREPERMIT_CREATE' : + case 'PREVENTIONPLAN_CREATE' : + $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->elementtype = 'preventionplan@digiriskdolibarr'; + $result = $actioncomm->create($user); + break; - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . (!empty($object->label) ? $object->label : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('StartDate') . ' : ' . dol_print_date($object->date_start, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('EndDate') . ' : ' . dol_print_date($object->date_end, 'dayhoursec') . '
'; - if (is_array($signatories) && !empty($signatories)) { - $check = 0; - foreach($signatories as $signatory) { - $check++; - $actioncomm->note_private .= $langs->trans($signatory->role) . ' : ' . $signatory->firstname . ' ' . $signatory->lastname . '
'; - if ($check == 2) break; - } - } - if ($societies) { - foreach ($societies as $societename => $key) { - $actioncomm->note_private .= $langs->trans($societename) . ' : '; - foreach ($key as $societe) { - if ($societename == 'LabourInspectorAssigned') { - $actioncomm->note_private .= $societe->firstname . ' ' . $societe->lastname . '
'; - } else { - $actioncomm->note_private .= $societe->name . '
'; - } - if ($societename == 'ExtSociety') { - $actioncomm->note_private .= $langs->trans('Address') . ' : ' . $societe->address . '
'; - $actioncomm->note_private .= $langs->trans('SIRET') . ' : ' . $societe->idprof2 . '
'; - } - } - } - } - $actioncomm->note_private .= $langs->trans('CSSCTIntervention') . ' : ' . ($object->cssct_intervention ? $langs->trans("Yes") : $langs->trans("No")) . '
'; - $actioncomm->note_private .= $langs->trans('PriorVisit') . ' : ' . ($object->prior_visit_bool ? $langs->trans("Yes") : $langs->trans("No")) . '
'; - if ($object->prior_visit_bool) { - $actioncomm->note_private .= $langs->trans('PriorVisitText') . ' : ' . (!empty($object->prior_visit_text) ? $object->prior_visit_text : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('PriorVisitDate') . ' : ' . dol_print_date($object->prior_visit_date, 'dayhoursec') . '
'; - } - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; + case 'ACCIDENT_MODIFY' : + case 'ACCIDENTINVESTIGATION_MODIFY' : + case 'FIREPERMIT_MODIFY' : + case 'PREVENTIONPLAN_MODIFY' : + $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); $result = $actioncomm->create($user); break; + case 'ACCIDENT_DELETE' : + case 'ACCIDENTINVESTIGATION_DELETE' : + case 'FIREPERMIT_DELETE' : case 'PREVENTIONPLAN_DELETE' : - $societies = $digiriskresources->fetchResourcesFromObject('', $object); - $digirisksignature = new SaturneSignature($this->db, $object->module, $object->element); - $signatories = $digirisksignature->fetchSignatories($object->id, $object->element); - - $actioncomm->elementtype = 'preventionplan@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . (!empty($object->label) ? $object->label : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('StartDate') . ' : ' . dol_print_date($object->date_start, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('EndDate') . ' : ' . dol_print_date($object->date_end, 'dayhoursec') . '
'; - if (is_array($signatories) && !empty($signatories)) { - $check = 0; - foreach($signatories as $signatory) { - $check++; - $actioncomm->note_private .= $langs->trans($signatory->role) . ' : ' . $signatory->firstname . ' ' . $signatory->lastname . '
'; - if ($check == 2) break; - } - } - if ($societies) { - foreach ($societies as $societename => $key) { - $actioncomm->note_private .= $langs->trans($societename) . ' : '; - foreach ($key as $societe) { - if ($societename == 'LabourInspectorAssigned') { - $actioncomm->note_private .= $societe->firstname . ' ' . $societe->lastname . '
'; - } else { - $actioncomm->note_private .= $societe->name . '
'; - } - if ($societename == 'ExtSociety') { - $actioncomm->note_private .= $langs->trans('Address') . ' : ' . $societe->address . '
'; - $actioncomm->note_private .= $langs->trans('SIRET') . ' : ' . $societe->idprof2 . '
'; - } - } - } - } - $actioncomm->note_private .= $langs->trans('CSSCTIntervention') . ' : ' . ($object->cssct_intervention ? $langs->trans("Yes") : $langs->trans("No")) . '
'; - $actioncomm->note_private .= $langs->trans('PriorVisit') . ' : ' . ($object->prior_visit_bool ? $langs->trans("Yes") : $langs->trans("No")) . '
'; - if ($object->prior_visit_bool) { - $actioncomm->note_private .= $langs->trans('PriorVisitText') . ' : ' . (!empty($object->prior_visit_text) ? $object->prior_visit_text : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('PriorVisitDate') . ' : ' . dol_print_date($object->prior_visit_date, 'dayhoursec') . '
'; - } - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - - $result = $actioncomm->create($user); - break; - - case 'PREVENTIONPLAN_INPROGRESS' : - $actioncomm->elementtype = 'preventionplan@digiriskdolibarr'; - - $actioncomm->label = $langs->transnoentities('PreventionPlanInprogressTrigger'); + $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); $result = $actioncomm->create($user); break; + case 'ACCIDENTINVESTIGATION_VALIDATE' : + case 'FIREPERMIT_PENDINGSIGNATURE' : case 'PREVENTIONPLAN_PENDINGSIGNATURE' : - $actioncomm->elementtype = 'preventionplan@digiriskdolibarr'; - - $actioncomm->label = $langs->transnoentities('PreventionPlanPendingSignatureTrigger'); + $actioncomm->label = $langs->transnoentities('ObjectValidateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); $result = $actioncomm->create($user); break; - case 'PREVENTIONPLAN_LOCKED' : - $actioncomm->elementtype = 'preventionplan@digiriskdolibarr'; - + case 'ACCIDENTINVESTIGATION_LOCK' : + case 'FIREPERMIT_LOCK' : + case 'PREVENTIONPLAN_LOCK' : $actioncomm->label = $langs->trans('ObjectLockedTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); $result = $actioncomm->create($user); break; - case 'PREVENTIONPLAN_ARCHIVED' : - $actioncomm->elementtype = 'preventionplan@digiriskdolibarr'; - + case 'ACCIDENTINVESTIGATION_ARCHIVE' : + case 'FIREPERMIT_ARCHIVE' : + case 'PREVENTIONPLAN_ARCHIVE' : $actioncomm->label = $langs->trans('ObjectArchivedTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); $result = $actioncomm->create($user); break; - case 'PREVENTIONPLANLINE_CREATE' : - $risk = new Risk($this->db); - $digiriskelement->fetch($object->fk_element); + case 'ACCIDENTINVESTIGATION_UNVALIDATE' : + case 'FIREPERMIT_UNVALIDATE' : + case 'PREVENTIONPLAN_UNVALIDATE' : + $actioncomm->label = $langs->trans('ObjectUnValidateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $result = $actioncomm->create($user); + break; + + case 'PREVENTIONPLANLINE_CREATE' : $actioncomm->elementtype = 'preventionplan@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('INRSRisk') . ' : ' . $risk->getDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('PreventionMethod') . ' : ' . (!empty($object->prevention_method) ? $object->prevention_method : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $object->fk_preventionplan; + $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_preventionplan; $result = $actioncomm->create($user); break; case 'PREVENTIONPLANLINE_MODIFY' : - $risk = new Risk($this->db); - $digiriskelement->fetch($object->fk_element); - $actioncomm->elementtype = 'preventionplan@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('INRSRisk') . ' : ' . $risk->getDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('PreventionMethod') . ' : ' . (!empty($object->prevention_method) ? $object->prevention_method : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $object->fk_preventionplan; + $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_preventionplan; $result = $actioncomm->create($user); break; case 'PREVENTIONPLANLINE_DELETE' : - $risk = new Risk($this->db); - $digiriskelement->fetch($object->fk_element); - $actioncomm->elementtype = 'preventionplan@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('INRSRisk') . ' : ' . $risk->getDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('PreventionMethod') . ' : ' . (!empty($object->prevention_method) ? $object->prevention_method : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $object->fk_preventionplan; + $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_preventionplan; $result = $actioncomm->create($user); break; + case 'FIREPERMIT_SENTBYMAIL' : case 'PREVENTIONPLAN_SENTBYMAIL' : - $actioncomm->elementtype = 'preventionplan@digiriskdolibarr'; - - $actioncomm->label = $langs->transnoentities('PreventionPlanSentByMailTrigger'); + $actioncomm->label = $langs->transnoentities('ObjectSentByMailTrigger'); $result = $actioncomm->create($user); $object->last_email_sent_date = $now; $object->update($user, true); break; - case 'FIREPERMIT_CREATE' : - $object->element = 'firepermit'; - $preventionplan = new PreventionPlan($this->db); - $preventionplan->fetch($object->fk_preventionplan); - $societies = $digiriskresources->fetchResourcesFromObject('', $object); - $digirisksignature = new SaturneSignature($this->db, $object->module, $object->element); - $signatories = $digirisksignature->fetchSignatories($object->id, $object->element); - - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . (!empty($object->label) ? $object->label : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('StartDate') . ' : ' . dol_print_date($object->date_start, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('EndDate') . ' : ' . dol_print_date($object->date_end, 'dayhoursec') . '
'; - if (is_array($signatories) && !empty($signatories)) { - foreach($signatories as $signatory) { - $actioncomm->note_private .= $langs->trans($signatory->role) . ' : ' . $signatory->firstname . ' ' . $signatory->lastname . '
'; - } - } - foreach ($societies as $societename => $key) { - $actioncomm->note_private .= $langs->trans($societename) . ' : '; - foreach ($key as $societe) { - if ($societename == 'LabourInspectorAssigned') { - $actioncomm->note_private .= $societe->firstname . ' ' . $societe->lastname . '
'; - } else { - $actioncomm->note_private .= $societe->name . '
'; - } - if ($societename == 'ExtSociety') { - $actioncomm->note_private .= $langs->trans('Address') . ' : ' . $societe->address . '
'; - $actioncomm->note_private .= $langs->trans('SIRET') . ' : ' . $societe->idprof2 . '
'; - } - } - } - $actioncomm->note_private .= $langs->trans('PreventionPlan') . ' : ' . $preventionplan->ref . (!empty($preventionplan->label) ? ' ' . $preventionplan->label : '') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - - $result = $actioncomm->create($user); - break; - - case 'FIREPERMIT_MODIFY' : - $preventionplan = new PreventionPlan($this->db); - $preventionplan->fetch($object->fk_preventionplan); - $societies = $digiriskresources->fetchResourcesFromObject('', $object); - $digirisksignature = new SaturneSignature($this->db, $object->module, $object->element); - $signatories = $digirisksignature->fetchSignatories($object->id, $object->element); - - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . (!empty($object->label) ? $object->label : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('StartDate') . ' : ' . dol_print_date($object->date_start, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('EndDate') . ' : ' . dol_print_date($object->date_end, 'dayhoursec') . '
'; - - if (is_array($signatories) && !empty($signatories)) { - $check = 0; - foreach($signatories as $signatory) { - $check++; - $actioncomm->note_private .= $langs->trans($signatory->role) . ' : ' . $signatory->firstname . ' ' . $signatory->lastname . '
'; - if ($check == 2) break; - } - } - if ($societies) { - foreach ($societies as $societename => $key) { - $actioncomm->note_private .= $langs->trans($societename) . ' : '; - foreach ($key as $societe) { - if ($societename == 'LabourInspectorAssigned') { - $actioncomm->note_private .= $societe->firstname . ' ' . $societe->lastname . '
'; - } else { - $actioncomm->note_private .= $societe->name . '
'; - } - if ($societename == 'ExtSociety') { - $actioncomm->note_private .= $langs->trans('Address') . ' : ' . $societe->address . '
'; - $actioncomm->note_private .= $langs->trans('SIRET') . ' : ' . $societe->idprof2 . '
'; - } - } - } - } - $actioncomm->note_private .= $langs->trans('PreventionPlan') . ' : ' . $preventionplan->ref . (!empty($preventionplan->label) ? ' ' . $preventionplan->label : '') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - - $result = $actioncomm->create($user); - break; - - case 'FIREPERMIT_DELETE' : - $preventionplan = new PreventionPlan($this->db); - $preventionplan->fetch($object->fk_preventionplan); - $societies = $digiriskresources->fetchResourcesFromObject('', $object); - $digirisksignature = new DigiriskSignature($this->db); - $signatories = $digirisksignature->fetchSignatories($object->id, $object->element); - - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . (!empty($object->label) ? $object->label : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('StartDate') . ' : ' . dol_print_date($object->date_start, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('EndDate') . ' : ' . dol_print_date($object->date_end, 'dayhoursec') . '
'; - - if (is_array($signatories) && !empty($signatories)) { - $check = 0; - foreach($signatories as $signatory) { - $check++; - $actioncomm->note_private .= $langs->trans($signatory->role) . ' : ' . $signatory->firstname . ' ' . $signatory->lastname . '
'; - if ($check == 2) break; - } - } - if ($societies) { - foreach ($societies as $societename => $key) { - $actioncomm->note_private .= $langs->trans($societename) . ' : '; - foreach ($key as $societe) { - if ($societename == 'LabourInspectorAssigned') { - $actioncomm->note_private .= $societe->firstname . ' ' . $societe->lastname . '
'; - } else { - $actioncomm->note_private .= $societe->name . '
'; - } - if ($societename == 'ExtSociety') { - $actioncomm->note_private .= $langs->trans('Address') . ' : ' . $societe->address . '
'; - $actioncomm->note_private .= $langs->trans('SIRET') . ' : ' . $societe->idprof2 . '
'; - } - } - } - } - $actioncomm->note_private .= $langs->trans('PreventionPlan') . ' : ' . $preventionplan->ref . (!empty($preventionplan->label) ? ' ' . $preventionplan->label : '') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - - $result = $actioncomm->create($user); - break; - - case 'FIREPERMIT_INPROGRESS' : - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - - $actioncomm->label = $langs->transnoentities('FirePermitInProgressTrigger'); - - $result = $actioncomm->create($user); - break; - - case 'FIREPERMIT_PENDINGSIGNATURE' : - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - - $actioncomm->label = $langs->transnoentities('FirePermitPendingSignatureTrigger'); - - $result = $actioncomm->create($user); - break; - - case 'FIREPERMIT_LOCKED' : - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectLockedTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - - $result = $actioncomm->create($user); - break; - - case 'FIREPERMIT_ARCHIVED' : - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectArchivedTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - - $result = $actioncomm->create($user); - break; - case 'FIREPERMITLINE_CREATE' : - $risk = new Risk($this->db); - $digiriskelement->fetch($object->fk_element); - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('INRSRisk') . ' : ' . $risk->getFirePermitDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('UsedEquipment') . ' : ' . (!empty($object->used_equipment) ? $object->used_equipment : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $object->fk_firepermit; + $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_firepermit; $result = $actioncomm->create($user); break; case 'FIREPERMITLINE_MODIFY' : - $risk = new Risk($this->db); - $digiriskelement->fetch($object->fk_element); - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('INRSRisk') . ' : ' . $risk->getFirePermitDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('UsedEquipment') . ' : ' . (!empty($object->used_equipment) ? $object->used_equipment : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $object->fk_firepermit; + $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_firepermit; $result = $actioncomm->create($user); break; case 'FIREPERMITLINE_DELETE' : - $risk = new Risk($this->db); - $digiriskelement->fetch($object->fk_element); - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('INRSRisk') . ' : ' . $risk->getFirePermitDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('UsedEquipment') . ' : ' . (!empty($object->used_equipment) ? $object->used_equipment : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $object->fk_firepermit; + $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_firepermit; $result = $actioncomm->create($user); break; - case 'FIREPERMIT_SENTBYMAIL' : - $actioncomm->elementtype = 'firepermit@digiriskdolibarr'; - - $actioncomm->label = $langs->transnoentities('FirePermitSentByMailTrigger'); - - $result = $actioncomm->create($user); - $object->last_email_sent_date = $now; - $object->update($user, true); - break; - case 'TICKET_CREATE' : if ($conf->global->DIGIRISKDOLIBARR_SEND_EMAIL_ON_TICKET_SUBMIT) { // envoi du mail avec les infos de l'objet aux adresses mail configurées @@ -1040,115 +528,52 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf } break; + case 'RISKSIGN_CREATE' : case 'RISK_CREATE' : - $project = new Project($this->db); - $digiriskelement->fetch($object->fk_element); - $project->fetch($object->fk_projet); - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Projet') . ' : ' . $project->ref . " " . $project->title . '
'; - $actioncomm->note_private .= $langs->trans('RiskCategory') . ' : ' . $object->getDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->fk_element; + $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(get_class($object)), $object->ref); + $actioncomm->fk_element = $object->fk_element; + $result = $actioncomm->create($user); break; + case 'RISKSIGN_MODIFY' : case 'RISK_MODIFY' : - $project = new Project($this->db); - $digiriskelement->fetch($object->fk_element); - $project->fetch($object->fk_projet); $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Projet') . ' : ' . $project->ref . " " . $project->title . '
'; - $actioncomm->note_private .= $langs->trans('RiskCategory') . ' : ' . $object->getDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->fk_element; + $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(get_class($object)), $object->ref); + $actioncomm->fk_element = $object->fk_element; $result = $actioncomm->create($user); break; + case 'RISKSIGN_DELETE' : case 'RISK_DELETE' : - $project = new Project($this->db); - $digiriskelement->fetch($object->fk_element); - $project->fetch($object->fk_projet); - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; + $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Projet') . ' : ' . $project->ref . " " . $project->title . '
'; - $actioncomm->note_private .= $langs->trans('RiskCategory') . ' : ' . $object->getDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->fk_element; + $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(get_class($object)), $object->ref); + $actioncomm->fk_element = $object->fk_element; $result = $actioncomm->create($user); break; + case 'RISKSIGN_IMPORT': case 'RISK_IMPORT' : - $project = new Project($this->db); - $project->fetch($object->fk_projet); + $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - - $actioncomm->label = $langs->transnoentities('RiskImportTrigger', $object->ref); - $digiriskelement->fetch($object->applied_on); - $actioncomm->note_private .= $langs->trans('RiskSharedWithEntityRefLabel', $object->ref) . ' S' . $conf->entity . ' ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $digiriskelement->fetch($object->fk_element); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $object->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Projet') . ' : ' . $project->ref . " " . $project->title . '
'; - $actioncomm->note_private .= $langs->trans('RiskCategory') . ' : ' . $object->getDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->applied_on; + $actioncomm->label = $langs->transnoentities('ObjectImportTrigger', $langs->transnoentities(get_class($object)), $object->ref); + $actioncomm->fk_element = $object->applied_on; $result = $actioncomm->create($user); break; + case 'RISKSIGN_UNLINK': case 'RISK_UNLINK' : - $project = new Project($this->db); - $project->fetch($object->fk_projet); + $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - - $actioncomm->label = $langs->transnoentities('RiskUnlinkTrigger', $object->ref); - $digiriskelement->fetch($object->applied_on); - $actioncomm->note_private .= $langs->trans('RiskUnlinkedFromEntityRefLabel', $object->ref) . ' S' . $conf->entity . ' ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $digiriskelement->fetch($object->fk_element); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $object->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Projet') . ' : ' . $project->ref . " " . $project->title . '
'; - $actioncomm->note_private .= $langs->trans('RiskCategory') . ' : ' . $object->getDangerCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->applied_on; + $actioncomm->label = $langs->transnoentities('ObjectUnlinkTrigger', $langs->transnoentities(get_class($object)), $object->ref); + $actioncomm->fk_element = $object->applied_on; $result = $actioncomm->create($user); break; @@ -1177,13 +602,8 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . $object->label . '
'; $actioncomm->note_private .= $langs->trans($label_progress) . ' : ' . $task_progress . '%' . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_c, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $risk->fk_element; + $actioncomm->fk_element = $risk->fk_element; $result = $actioncomm->create($user); } @@ -1214,14 +634,8 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . $object->label . '
'; $actioncomm->note_private .= $langs->trans($label_progress) . ' : ' . $task_progress . '%' . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_c, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $risk->fk_element; + $actioncomm->fk_element = $risk->fk_element; $result = $actioncomm->create($user); } @@ -1250,13 +664,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . $object->label . '
'; $actioncomm->note_private .= $langs->trans($label_progress) . ' : ' . $task_progress . '%' . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_c, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; $actioncomm->fk_element = $risk->fk_element; $result = $actioncomm->create($user); @@ -1267,29 +675,11 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf require_once __DIR__ . '/../../class/riskanalysis/risk.class.php'; $risk = new Risk($this->db); $risk->fetch($object->fk_risk); - $digiriskelement->fetch($risk->fk_element); $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentRisk') . ' : ' . $risk->ref . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Comment') . ' : ' . (!empty($object->comment) ? $object->comment : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - ((!empty($object->date_riskassessment) && $conf->global->DIGIRISKDOLIBARR_SHOW_RISKASSESSMENT_DATE) ? $actioncomm->note_private .= $langs->trans('RiskAssessmentDate') . ' : ' . dol_print_date($object->date_riskassessment, 'day') . '
' : ''); - $actioncomm->note_private .= $langs->trans('Photo') . ' : ' . (!empty($object->photo) ? $object->photo : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - if ($object->method == 'advanced') { - $actioncomm->note_private .= $langs->trans('Evaluation') . ' : ' . $object->cotation . '
'; - $actioncomm->note_private .= $langs->trans('Gravity') . ' : ' . $object->gravite . '
'; - $actioncomm->note_private .= $langs->trans('Protection') . ' : ' . $object->protection . '
'; - $actioncomm->note_private .= $langs->trans('Occurrence') . ' : ' . $object->occurrence . '
'; - $actioncomm->note_private .= $langs->trans('Formation') . ' : ' . $object->formation . '
'; - $actioncomm->note_private .= $langs->trans('Exposition') . ' : ' . $object->exposition . '
'; - } - $actioncomm->fk_element = $risk->fk_element; + $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $risk->fk_element; $result = $actioncomm->create($user); break; @@ -1298,30 +688,11 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf require_once __DIR__ . '/../../class/riskanalysis/risk.class.php'; $risk = new Risk($this->db); $risk->fetch($object->fk_risk); - $digiriskelement->fetch($risk->fk_element); $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentRisk') . ' : ' . $risk->ref . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Comment') . ' : ' . (!empty($object->comment) ? $object->comment : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - ((!empty($object->date_riskassessment) && $conf->global->DIGIRISKDOLIBARR_SHOW_RISKASSESSMENT_DATE) ? $actioncomm->note_private .= $langs->trans('RiskAssessmentDate') . ' : ' . dol_print_date($object->date_riskassessment, 'day') . '
' : ''); - $actioncomm->note_private .= $langs->trans('Photo') . ' : ' . (!empty($object->photo) ? $object->photo : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - if ($object->method == 'advanced') { - $actioncomm->note_private .= $langs->trans('Evaluation') . ' : ' . $object->cotation . '
'; - $actioncomm->note_private .= $langs->trans('Gravity') . ' : ' . $object->gravite . '
'; - $actioncomm->note_private .= $langs->trans('Protection') . ' : ' . $object->protection . '
'; - $actioncomm->note_private .= $langs->trans('Occurrence') . ' : ' . $object->occurrence . '
'; - $actioncomm->note_private .= $langs->trans('Formation') . ' : ' . $object->formation . '
'; - $actioncomm->note_private .= $langs->trans('Exposition') . ' : ' . $object->exposition . '
'; - } - $actioncomm->fk_element = $risk->fk_element; + $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $risk->fk_element; $result = $actioncomm->create($user); break; @@ -1330,447 +701,68 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf require_once __DIR__ . '/../../class/riskanalysis/risk.class.php'; $risk = new Risk($this->db); $risk->fetch($object->fk_risk); - $digiriskelement->fetch($risk->fk_element); $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentRisk') . ' : ' . $risk->ref . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Comment') . ' : ' . (!empty($object->comment) ? $object->comment : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - ((!empty($object->date_riskassessment) && $conf->global->DIGIRISKDOLIBARR_SHOW_RISKASSESSMENT_DATE) ? $actioncomm->note_private .= $langs->trans('RiskAssessmentDate') . ' : ' . dol_print_date($object->date_riskassessment, 'day') . '
' : ''); - $actioncomm->note_private .= $langs->trans('Photo') . ' : ' . (!empty($object->photo) ? $object->photo : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - if ($object->method == 'advanced') { - $actioncomm->note_private .= $langs->trans('Evaluation') . ' : ' . $object->cotation . '
'; - $actioncomm->note_private .= $langs->trans('Gravity') . ' : ' . $object->gravite . '
'; - $actioncomm->note_private .= $langs->trans('Protection') . ' : ' . $object->protection . '
'; - $actioncomm->note_private .= $langs->trans('Occurrence') . ' : ' . $object->occurrence . '
'; - $actioncomm->note_private .= $langs->trans('Formation') . ' : ' . $object->formation . '
'; - $actioncomm->note_private .= $langs->trans('Exposition') . ' : ' . $object->exposition . '
'; - } + $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); $actioncomm->fk_element = $risk->fk_element; $result = $actioncomm->create($user); break; case 'EVALUATOR_CREATE' : - require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; - $userstat = new User($this->db); - $digiriskelement->fetch($object->fk_parent); - $userstat->fetch($object->fk_user); - $langs->load('companies'); - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref_ext . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('UserAssigned') . ' : ' . $userstat->firstname . " " . $userstat->lastname . '
'; - $actioncomm->note_private .= $langs->trans('PostOrFunction') . ' : ' . (!empty($object->job) ? $object->job : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('AssignmentDate') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('EvaluationDuration') . ' : ' . convertSecondToTime($object->duration * 60, 'allhourmin') . ' min' . '
'; - $actioncomm->fk_element = $object->fk_parent; + $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_parent; $result = $actioncomm->create($user); break; case 'EVALUATOR_MODIFY' : - require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; - $userstat = new User($this->db); - $digiriskelement->fetch($object->fk_parent); - $userstat->fetch($object->fk_user); - $langs->load('companies'); - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('UserAssigned') . ' : ' . $userstat->firstname . " " . $userstat->lastname . '
'; - $actioncomm->note_private .= $langs->trans('PostOrFunction') . ' : ' . (!empty($object->job) ? $object->job : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('AssignmentDate') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('EvaluationDuration') . ' : ' . convertSecondToTime($object->duration * 60, 'allhourmin') . ' min' . '
'; - $actioncomm->fk_element = $object->fk_parent; + $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_parent; $result = $actioncomm->create($user); break; case 'EVALUATOR_DELETE' : - require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; - $userstat = new User($this->db); - $digiriskelement->fetch($object->fk_parent); - $userstat->fetch($object->fk_user); - $langs->load('companies'); - - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('UserAssigned') . ' : ' . $userstat->firstname . " " . $userstat->lastname . '
'; - $actioncomm->note_private .= $langs->trans('PostOrFunction') . ' : ' . (!empty($object->job) ? $object->job : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('AssignmentDate') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('EvaluationDuration') . ' : ' . convertSecondToTime($object->duration * 60, 'allhourmin') . ' min' . '
'; - $actioncomm->fk_element = $object->fk_parent; - - $result = $actioncomm->create($user); - break; - - case 'RISKSIGN_CREATE' : - $digiriskelement->fetch($object->fk_element); - - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('RiskCategory') . ' : ' . $object->getRiskSignCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->fk_element; - - $result = $actioncomm->create($user); - break; - - case 'RISKSIGN_MODIFY' : - $digiriskelement->fetch($object->fk_element); - - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('RiskCategory') . ' : ' . $object->getRiskSignCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->fk_element; - - $result = $actioncomm->create($user); - break; - - case 'RISKSIGN_DELETE' : - $digiriskelement->fetch($object->fk_element); - - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('RiskCategory') . ' : ' . $object->getRiskSignCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->fk_element; - - $result = $actioncomm->create($user); - break; - - case 'RISKSIGN_IMPORT' : $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - $actioncomm->label = $langs->transnoentities('RiskSignImportTrigger', $object->ref); - $digiriskelement->fetch($object->applied_on); - $actioncomm->note_private .= $langs->trans('RiskSignSharedWithEntityRefLabel', $object->ref) . ' S' . $conf->entity . ' ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $digiriskelement->fetch($object->fk_element); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $object->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('RiskCategory') . ' : ' . $object->getRiskSignCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->applied_on; - - $result = $actioncomm->create($user); - break; - - case 'RISKSIGN_UNLINK' : - $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; - - $actioncomm->label = $langs->transnoentities('RiskSignUnlinkTrigger', $object->ref); - $digiriskelement->fetch($object->applied_on); - $actioncomm->note_private .= $langs->trans('RiskSignUnlinkedFromEntityRefLabel', $object->ref) . ' S' . $conf->entity . ' ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $digiriskelement->fetch($object->fk_element); - $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . " - " . $digiriskelement->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $object->entity . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('RiskCategory') . ' : ' . $object->getRiskSignCategoryName($object) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->applied_on; - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENT_CREATE' : - $society = new Societe($this->db); - $uservictim = new User($this->db); - $uservictim->fetch($object->fk_user_victim); - $useremployer = new User($this->db); - $useremployer->fetch($object->fk_user_employer); - - $actioncomm->elementtype = 'accident@digiriskdolibarr'; - //1 : Accident in DU / GP, 2 : Accident in society, 3 : Accident in another location - switch ($object->external_accident) { - case 1: - if (!empty($object->fk_standard)) { - $digiriskstandard->fetch($object->fk_standard); - $accidentLocation = $digiriskstandard->ref . " - " . $conf->global->MAIN_INFO_SOCIETE_NOM; - } else if (!empty($object->fk_element)) { - $digiriskelement->fetch($object->fk_element); - $accidentLocation = $digiriskelement->ref . " - " . $digiriskelement->label; - } - break; - case 2: - $society->fetch($object->fk_soc); - $accidentLocation = $society->ref . " - " . $society->label; - case 3: - $accidentLocation = $object->accident_location; - break; - } - - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . $object->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . getEntity($object->element) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('UserVictim') . ' : ' . $uservictim->firstname . $uservictim->lastname . '
'; - $actioncomm->note_private .= $langs->trans('UserEmployer') . ' : ' . $useremployer->firstname . $useremployer->lastname . '
'; - $actioncomm->note_private .= $langs->trans('AccidentLocation') . ' : ' . $accidentLocation . '
'; - $actioncomm->note_private .= $langs->trans('AccidentType') . ' : ' . ($object->accident_type ? $langs->trans('CommutingAccident') : $langs->trans('WorkAccidentStatement')) . '
'; - $actioncomm->note_private .= $langs->trans('AccidentDate') . ' : ' . dol_print_date($object->accident_date, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENT_MODIFY' : - $society = new Societe($this->db); - $uservictim = new User($this->db); - $uservictim->fetch($object->fk_user_victim); - $useremployer = new User($this->db); - $useremployer->fetch($object->fk_user_employer); - - //1 : Accident in DU / GP, 2 : Accident in society, 3 : Accident in another location - switch ($object->external_accident) { - case 1: - if (!empty($object->fk_standard)) { - $digiriskstandard->fetch($object->fk_standard); - $accidentLocation = $digiriskstandard->ref . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - } elseif (!empty($object->fk_element)) { - $digiriskelement->fetch($object->fk_element); - $actioncomm->fk_element = $object->fk_element; - $accidentLocation = $digiriskelement->ref . ' - ' . $digiriskelement->label; - } - break; - case 2: - $society->fetch($object->fk_soc); - $accidentLocation = $society->ref . ' - ' . $society->label; - break; - case 3: - $accidentLocation = $object->accident_location; - break; - } - - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . $object->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . getEntity($object->element) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('UserVictim') . ' : ' . $uservictim->firstname . $uservictim->lastname . '
'; - $actioncomm->note_private .= $langs->trans('UserEmployer') . ' : ' . $useremployer->firstname . $useremployer->lastname . '
'; - $actioncomm->note_private .= $langs->trans('AccidentLocation') . ' : ' . $accidentLocation . '
'; - $actioncomm->note_private .= $langs->trans('AccidentType') . ' : ' . ($object->accident_type ? $langs->trans('CommutingAccident') : $langs->trans('WorkAccidentStatement')) . '
'; - $actioncomm->note_private .= $langs->trans('AccidentDate') . ' : ' . dol_print_date($object->accident_date, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENT_DELETE' : - $society = new Societe($this->db); - $uservictim = new User($this->db); - $uservictim->fetch($object->fk_user_victim); - $useremployer = new User($this->db); - $useremployer->fetch($object->fk_user_employer); - - $actioncomm->elementtype = 'accident@digiriskdolibarr'; - //1 : Accident in DU / GP, 2 : Accident in society, 3 : Accident in another location - switch ($object->external_accident) { - case 1: - if (!empty($object->fk_standard)) { - $digiriskstandard->fetch($object->fk_standard); - $accidentLocation = $digiriskstandard->ref . " - " . $conf->global->MAIN_INFO_SOCIETE_NOM; - } else if (!empty($object->fk_element)) { - $digiriskelement->fetch($object->fk_element); - $accidentLocation = $digiriskelement->ref . " - " . $digiriskelement->label; - } - break; - case 2: - $society->fetch($object->fk_soc); - $accidentLocation = $society->ref . " - " . $society->label; - case 3: - $accidentLocation = $object->accident_location; - break; - } - - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Label') . ' : ' . $object->label . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . getEntity($object->element) . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('UserVictim') . ' : ' . $uservictim->firstname . $uservictim->lastname . '
'; - $actioncomm->note_private .= $langs->trans('UserEmployer') . ' : ' . $useremployer->firstname . $useremployer->lastname . '
'; - $actioncomm->note_private .= $langs->trans('AccidentLocation') . ' : ' . $accidentLocation . '
'; - $actioncomm->note_private .= $langs->trans('AccidentType') . ' : ' . ($object->accident_type ? $langs->trans('CommutingAccident') : $langs->trans('WorkAccidentStatement')) . '
'; - $actioncomm->note_private .= $langs->trans('AccidentDate') . ' : ' . dol_print_date($object->accident_date, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; + $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_parent; $result = $actioncomm->create($user); break; + case 'ACCIDENTMETADATA_CREATE' : + case 'ACCIDENTLESION_CREATE' : case 'ACCIDENTWORKSTOP_CREATE' : $actioncomm->elementtype = 'accident@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $object->entity . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('WorkStopDays') . ' : ' . $object->workstop_days . '
'; - $actioncomm->note_private .= $langs->trans('WorkStopDocument') . ' : ' . (!empty($object->declaration_link) ? $object->declaration_link : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateStartWorkStop') . ' : ' . dol_print_date($object->date_start_workstop, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('DateEndWorkStop') . ' : ' . dol_print_date($object->date_end_workstop, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->fk_accident; - + $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_accident; $result = $actioncomm->create($user); break; + case 'ACCIDENTLESION_MODIFY' : case 'ACCIDENTWORKSTOP_MODIFY' : $actioncomm->elementtype = 'accident@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $object->entity . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('WorkStopDays') . ' : ' . $object->workstop_days . '
'; - $actioncomm->note_private .= $langs->trans('WorkStopDocument') . ' : ' . (!empty($object->declaration_link) ? $object->declaration_link : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateStartWorkStop') . ' : ' . dol_print_date($object->date_start_workstop, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('DateEndWorkStop') . ' : ' . dol_print_date($object->date_end_workstop, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->fk_accident; + $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_accident; $result = $actioncomm->create($user); break; + case 'ACCIDENTLESION_DELETE' : case 'ACCIDENTWORKSTOP_DELETE' : $actioncomm->elementtype = 'accident@digiriskdolibarr'; - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $object->entity . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('WorkStopDays') . ' : ' . $object->workstop_days . '
'; - $actioncomm->note_private .= $langs->trans('WorkStopDocument') . ' : ' . (!empty($object->declaration_link) ? $object->declaration_link : 'N/A') . '
'; - $actioncomm->note_private .= $langs->trans('DateStartWorkStop') . ' : ' . dol_print_date($object->date_start_workstop, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('DateEndWorkStop') . ' : ' . dol_print_date($object->date_end_workstop, 'dayhoursec') . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('Status') . ' : ' . $object->status . '
'; - $actioncomm->fk_element = $object->fk_accident; - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENTLESION_CREATE' : - $actioncomm->elementtype = 'accident@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $object->entity . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LesionLocalization') . ' : ' . $object->lesion_localization . '
'; - $actioncomm->note_private .= $langs->trans('LesionNature') . ' : ' . $object->lesion_nature . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $object->fk_accident; - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENTLESION_MODIFY' : - $actioncomm->elementtype = 'accident@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $object->entity . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LesionLocalization') . ' : ' . $object->lesion_localization . '
'; - $actioncomm->note_private .= $langs->trans('LesionNature') . ' : ' . $object->lesion_nature . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $object->fk_accident; - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENTLESION_DELETE' : - $actioncomm->elementtype = 'accident@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $object->entity . '
'; - $actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '
'; - $actioncomm->note_private .= $langs->trans('LesionLocalization') . ' : ' . $object->lesion_localization . '
'; - $actioncomm->note_private .= $langs->trans('LesionNature') . ' : ' . $object->lesion_nature . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_creation, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->fk_element = $object->fk_accident; - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENTMETADATA_CREATE' : - $actioncomm->elementtype = 'accident@digiriskdolibarr'; - - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $actioncomm->fk_element = $object->fk_accident; + $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); + $actioncomm->fk_element = $object->fk_accident; $result = $actioncomm->create($user); break; @@ -1780,12 +772,8 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $object->ref . ' - ' . $object->label . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->timespent_id . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; $actioncomm->note_private .= $langs->trans('TaskTimeSpentDate') . ' : ' . dol_print_date($object->timespent_datehour, 'dayhoursec') . '
'; $actioncomm->note_private .= $langs->trans('TaskTimeSpentDuration') . ' : ' . convertSecondToTime($object->timespent_duration * 60, 'allhourmin') . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->timespent_note) ? $object->timespent_note : 'N/A') . '
'; $actioncomm->fk_element = $object->fk_element; $actioncomm->fk_project = $object->fk_project; @@ -1797,13 +785,8 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $object->ref . ' - ' . $object->label . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->timespent_id . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_c, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; $actioncomm->note_private .= $langs->trans('TaskTimeSpentDate') . ' : ' . dol_print_date($object->timespent_datehour, 'dayhoursec') . '
'; $actioncomm->note_private .= $langs->trans('TaskTimeSpentDuration') . ' : ' . convertSecondToTime($object->timespent_duration * 60, 'allhourmin') . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->timespent_note) ? $object->timespent_note : 'N/A') . '
'; $actioncomm->fk_element = $object->fk_element; $actioncomm->fk_project = $object->fk_project; @@ -1815,61 +798,15 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); $actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $object->ref . ' - ' . $object->label . '
'; - $actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->timespent_id . '
'; - $actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '
'; - $actioncomm->note_private .= $langs->trans('DateCreation') . ' : ' . dol_print_date($object->date_c, 'dayhoursec', 'tzuser') . '
'; - $actioncomm->note_private .= $langs->trans('DateModification') . ' : ' . dol_print_date($now, 'dayhoursec', 'tzuser') . '
'; $actioncomm->note_private .= $langs->trans('TaskTimeSpentDate') . ' : ' . dol_print_date($object->timespent_datehour, 'dayhoursec') . '
'; $actioncomm->note_private .= $langs->trans('TaskTimeSpentDuration') . ' : ' . convertSecondToTime($object->timespent_duration * 60, 'allhourmin') . '
'; - $actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->timespent_note) ? $object->timespent_note : 'N/A') . '
'; $actioncomm->fk_element = $object->fk_element; - $actioncomm->userownerid = $user->id; $actioncomm->fk_project = $object->fk_project; $result = $actioncomm->create($user); break; - case 'ACCIDENTINVESTIGATION_CREATE' : - $actioncomm->label = $langs->trans('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $result = $actioncomm->create($user); - break; - - case 'ACCIDENTINVESTIGATION_MODIFY' : - $actioncomm->label = $langs->trans('ObjectModifyTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - $result = $actioncomm->create($user); - break; - - case 'ACCIDENTINVESTIGATION_DELETE' : - $actioncomm->label = $langs->trans('ObjectDeleteTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENT_INVESTIGATION_VALIDATE' : - $actioncomm->label = $langs->trans('ObjectValidateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENT_INVESTIGATION_UNVALIDATE' : - $actioncomm->label = $langs->trans('ObjectUnValidateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENT_INVESTIGATION_ARCHIVE' : - $actioncomm->label = $langs->trans('ObjectArchivedTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENT_INVESTIGATION_LOCK' : - $actioncomm->label = $langs->trans('ObjectLockedTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref); - - $result = $actioncomm->create($user); - break; - - case 'ACCIDENT_INVESTIGATION_SENTBYMAIL' : + case 'ACCIDENTINVESTIGATION_SENTBYMAIL' : $actioncomm->label = $langs->trans('ObjectSentByMailTrigger'); $result = $actioncomm->create($user); diff --git a/js/digiriskdolibarr.min.js b/js/digiriskdolibarr.min.js index cebd8284d..401b1cbe3 100644 --- a/js/digiriskdolibarr.min.js +++ b/js/digiriskdolibarr.min.js @@ -1 +1 @@ -"use strict";window.digiriskdolibarr||(window.digiriskdolibarr={},window.digiriskdolibarr.scriptsLoaded=!1),window.digiriskdolibarr.scriptsLoaded||(window.digiriskdolibarr.init=function(){window.digiriskdolibarr.load_list_script()},window.digiriskdolibarr.load_list_script=function(){if(!window.digiriskdolibarr.scriptsLoaded){var i=void 0,e=void 0;for(i in window.digiriskdolibarr)for(e in window.digiriskdolibarr[i].init&&window.digiriskdolibarr[i].init(),window.digiriskdolibarr[i])window.digiriskdolibarr[i]&&window.digiriskdolibarr[i][e]&&window.digiriskdolibarr[i][e].init&&window.digiriskdolibarr[i][e].init();window.digiriskdolibarr.scriptsLoaded=!0}},window.digiriskdolibarr.refresh=function(){var i=void 0,e=void 0;for(i in window.digiriskdolibarr)for(e in window.digiriskdolibarr[i].refresh&&window.digiriskdolibarr[i].refresh(),window.digiriskdolibarr[i])window.digiriskdolibarr[i]&&window.digiriskdolibarr[i][e]&&window.digiriskdolibarr[i][e].refresh&&window.digiriskdolibarr[i][e].refresh()},$(document).ready(window.digiriskdolibarr.init)),window.digiriskdolibarr.accident={},window.digiriskdolibarr.accident.init=function(){window.digiriskdolibarr.accident.event()},window.digiriskdolibarr.accident.event=function(){$(document).on("submit",".sendfile",window.digiriskdolibarr.accident.tmpStockFile),$(document).on("click",".linked-file-delete-workstop",window.digiriskdolibarr.accident.removeFile),$(document).on("change","#external_accident",window.digiriskdolibarr.accident.showExternalAccidentLocation)},window.digiriskdolibarr.accident.tmpStockFile=function(e,i=""){var s=$("#sendfile").prop("files"),t=new FormData;for(let i=0;ii.json()).then(i=>{i=i[0].option.matrix[e];t.find(".risk-evaluation-calculated-cotation").find(".risk-evaluation-cotation").attr("data-scale",window.digiriskdolibarr.evaluation.getDynamicScale(i)),t.find(".risk-evaluation-calculated-cotation").find(".risk-evaluation-cotation span").text(i),t.find(".risk-evaluation-content").find(".risk-evaluation-seuil").val(i),window.digiriskdolibarr.risk.haveDataInInput(t)})}},window.digiriskdolibarr.evaluator={},window.digiriskdolibarr.evaluator.init=function(){window.digiriskdolibarr.evaluator.event()},window.digiriskdolibarr.evaluator.event=function(){$(document).on("click",".evaluator-create",window.digiriskdolibarr.evaluator.createEvaluator),$(document).on("change","#fk_user_employer",window.digiriskdolibarr.evaluator.selectUser)},window.digiriskdolibarr.evaluator.selectUser=function(i){var e=window.saturne.toolbox.getToken(),s=$(this).closest(".modal-container"),t=s.find("#fk_user_employer").val();window.saturne.loader.display(s.find('input[name="evaluatorJob"]')),$.ajax({url:document.URL+"&action=getEvaluatorJob&token="+e,type:"POST",processData:!1,data:JSON.stringify({userID:t}),contentType:!1,success:function(i){s.find('input[name="evaluatorJob"]').val($(i).find('input[name="evaluatorJob"]').val()),s.find('input[name="evaluatorJob"]').removeClass("wpeo-loader")},error:function(i){}}),window.digiriskdolibarr.evaluator.haveDataInInput(s)},window.digiriskdolibarr.evaluator.haveDataInInput=function(i){i=i.parent().parent();i.hasClass("evaluator-add-modal")&&(0 div:nth-child(1)").text();$.ajax({url:document.URL+"&action=saveRisk&token="+e,type:"POST",processData:!1,data:JSON.stringify({riskID:t,category:s,comment:r,newParent:o}),contentType:!1,success:function(i){$(".wpeo-loader").removeClass("wpeo-loader");var e=$(".messageSuccessRiskEdit"),s=(o==a||n?($(".modal-active").removeClass("modal-active"),$(".risk-description-"+t).html($(i).find(".risk-description-"+t)),$(".risk-row-content-"+t).find(".risk-category .cell-risk").html($(i).find(".risk-row-content-"+t).find(".risk-category .cell-risk").children()),$(".risk-row-content-"+t).find(".risk-category").fadeOut(800),$(".risk-row-content-"+t).find(".risk-category").fadeIn(800),$(".risk-row-content-"+t).find(".risk-description-"+t).fadeOut(800),$(".risk-row-content-"+t).find(".risk-description-"+t).fadeIn(800)):$(".risk-row-content-"+t).fadeOut(800,function(){$(".fichecenter .opacitymedium.colorblack.paddingleft").html($(i).find("#searchFormListRisks .opacitymedium.colorblack.paddingleft"))}),""),s=(s=(s+=e.find(".valueForEditRisk1").val())+d)+e.find(".valueForEditRisk2").val();e.find("a").attr("href","#risk_row_"+t),e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")},error:function(i){var e=$(".messageErrorRiskEdit"),s="",s=(s=(s+=e.find(".valueForEditRisk1").val())+d)+e.find(".valueForEditRisk2").val();e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")}})},window.digiriskdolibarr.risk.unlinkSharedRisk=function(i){var e=window.saturne.toolbox.getToken();let s=$(this).attr("value"),t=(window.saturne.loader.display($(this)),$(".risk_row_"+s).find(".risk-container > div:nth-child(1)").text());var a=document.URL.split(/#/);$.ajax({url:a[0]+"&action=unlinkSharedRisk&token="+e,type:"POST",processData:!1,data:JSON.stringify({riskID:s}),contentType:!1,success:function(i){$(".confirmquestions").html($(i).find(".confirmquestions").children()),$(".fichecenter.sharedrisklist .opacitymedium.colorblack.paddingleft").html($(i).find("#searchFormSharedListRisks .opacitymedium.colorblack.paddingleft"));var i=$(".messageSuccessRiskUnlinkShared"),e=($("#risk_row_"+s).fadeOut(800),""),e=(e=(e+=i.find(".valueForUnlinkSharedRisk1").val())+t)+i.find(".valueForUnlinkSharedRisk2").val();i.find(".notice-subtitle .text").text(e),i.removeClass("hidden")},error:function(i){var e=$(".messageErrorRiskUnlinkShared"),s="",s=(s=(s+=e.find(".valueForUnlinkSharedRisk1").val())+t)+e.find(".valueForUnlinkSharedRisk2").val();e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")}})},window.digiriskdolibarr.risk.sharedRiskBoxLoader=function(i){"Oui"==$(this).text()&&window.saturne.loader.display($("#searchFormSharedListRisks"))},window.digiriskdolibarr.evaluation={},window.digiriskdolibarr.evaluation.init=function(){window.digiriskdolibarr.evaluation.event()},window.digiriskdolibarr.evaluation.event=function(){$(document).on("click",".select-evaluation-method",window.digiriskdolibarr.evaluation.selectEvaluationMethod),$(document).on("click",".cotation-container .risk-evaluation-cotation.cotation",window.digiriskdolibarr.evaluation.selectSeuil),$(document).on("click",".risk-evaluation-create",window.digiriskdolibarr.evaluation.createEvaluation),$(document).on("click",".risk-evaluation-save",window.digiriskdolibarr.evaluation.saveEvaluation),$(document).on("click",".risk-evaluation-delete",window.digiriskdolibarr.evaluation.deleteEvaluation)},window.digiriskdolibarr.evaluation.selectEvaluationMethod=function(i){var e=$(this).closest(".modal-container");0"+e.split(/\(/)[0]+"("+(+s-1)+")"),s-1<1&&$(".fichecenter.risklist").html($(i).find("#searchFormListRisks")),t.removeClass("wpeo-loader"),""),e=(e=(e+=r.find(".valueForDeleteEvaluation1").val())+n)+r.find(".valueForDeleteEvaluation2").val();r.find(".notice-subtitle .text").text(e),r.removeClass("hidden")},error:function(i){var e="",e=(e=(e+=o.find(".valueForDeleteEvaluation1").val())+n)+o.find(".valueForDeleteEvaluation2").val();o.find(".notice-subtitle .text").text(e),o.removeClass("hidden")}})}},window.digiriskdolibarr.evaluation.saveEvaluation=function(i){var e=window.saturne.toolbox.getToken();let s=$(this).closest(".risk-evaluation-edit-modal"),t=s.attr("value");var a=s.find(".risk-evaluation-comment textarea").val();let n=$(this).closest(".risk-row").find(".risk-evaluations-list-content").attr("value"),r=$(".risk-evaluation-ref-"+t).attr("value"),o=$(".risk-evaluation-list-modal-"+n),d=$("#risk_evaluation_list"+n).hasClass("modal-active");var a=window.digiriskdolibarr.risk.sanitizeBeforeRequest(a),l=s.find(".risk-evaluation-method").val(),c=s.find(".risk-evaluation-seuil").val(),k=s.find("#RiskAssessmentDateEdit"+t).val(),u=s.find(".risk-evaluation-photo .filename").val();let m=[];Object.values($(".table-cell.active.cell-"+t)).forEach(function(i){-1<$(i).data("seuil")&&(m[$(i).data("type")]=$(i).data("seuil"))}),window.saturne.loader.display($(this)),$.ajax({url:document.URL+"&action=saveEvaluation&token="+e,type:"POST",processData:!1,data:JSON.stringify({cotation:c,comment:a,method:l,photo:u,date:k,evaluationID:t,criteres:{gravite:m.gravite||0,occurrence:m.occurrence||0,protection:m.protection||0,formation:m.formation||0,exposition:m.exposition||0}}),contentType:!1,success:function(i){$("#risk_evaluation_edit"+t).removeClass("modal-active"),0<$(i).find(".risk-evaluation-container.risk-evaluation-container-"+t+":not(.last-risk-assessment)").length?((d?($(".risk-evaluation-ref-"+t+":not(.last-risk-assessment)").fadeOut(800),$(".risk-evaluation-ref-"+t+":not(.last-risk-assessment)")):($(".risk-evaluation-container-"+t+":not(.last-risk-assessment)").fadeOut(800),$(".risk-evaluation-container-"+t+":not(.last-risk-assessment)"))).fadeIn(800),o.find(".risk-evaluation-ref-"+t).replaceWith($(i).find(".risk-evaluation-ref-"+t)),$(".risk-evaluation-container.risk-evaluation-container-"+t+":not(.last-risk-assessment)").replaceWith($(i).find(".risk-evaluation-container.risk-evaluation-container-"+t+":not(.last-risk-assessment)")),$("#risk_evaluation_add"+n).html($(i).find("#risk_evaluation_add"+n).children())):($(".div-table-responsive").html($(i).find(".div-table-responsive").children()),(d?($(".risk-evaluation-ref-"+t+":not(.last-risk-assessment)").fadeOut(800),$(".risk-evaluation-ref-"+t+":not(.last-risk-assessment)")):($(".risk-evaluation-container-"+t+":not(.last-risk-assessment)").fadeOut(800),$(".risk-evaluation-container-"+t+":not(.last-risk-assessment)"))).fadeIn(800)),$(".wpeo-loader").removeClass("wpeo-loader");var i=$(".messageSuccessEvaluationEdit"),e=(s.find("#risk_evaluation_edit"+t).removeClass("modal-active"),""),e=(e=(e+=i.find(".valueForEditEvaluation1").val())+r)+i.find(".valueForEditEvaluation2").val();i.find("a").attr("href","#risk_row_"+n),i.find(".notice-subtitle .text").text(e),i.removeClass("hidden")},error:function(){var i=$(".messageErrorEvaluationEdit"),e="",e=(e=(e+=i.find(".valueForEditEvaluation1").val())+r)+i.find(".valueForEditEvaluation2").val();i.find(".notice-subtitle .text").text(e),i.removeClass("hidden")}})},window.digiriskdolibarr.risksign={},window.digiriskdolibarr.risksign.init=function(){window.digiriskdolibarr.risksign.event()},window.digiriskdolibarr.risksign.event=function(){$(document).on("click",".risksign-category-danger .item, .wpeo-table .risksign-category-danger .item",window.digiriskdolibarr.risksign.selectRiskSign),$(document).on("click",".risksign-create:not(.button-disable)",window.digiriskdolibarr.risksign.createRiskSign),$(document).on("click",".risksign-save",window.digiriskdolibarr.risksign.saveRiskSign),$(document).on("click",".risksign-unlink-shared",window.digiriskdolibarr.risksign.unlinkSharedRiskSign)},window.digiriskdolibarr.risksign.selectRiskSign=function(i){var e=$(this),e=(e.closest(".content").removeClass("active"),e.closest(".wpeo-dropdown").find(".dropdown-toggle span").hide(),e.closest(".wpeo-dropdown").find(".dropdown-toggle img").show(),e.closest(".wpeo-dropdown").find(".dropdown-toggle img").attr("src",e.find("img").attr("src")),e.closest(".wpeo-dropdown").find(".dropdown-toggle img").attr("aria-label",e.closest(".wpeo-tooltip-event").attr("aria-label")),e.closest(".fichecenter").find(".input-hidden-danger").val(e.data("id")),$(this).closest(".modal-container"));window.digiriskdolibarr.risksign.haveDataInInput(e)},window.digiriskdolibarr.risksign.haveDataInInput=function(i){i=i.parent().parent();i.hasClass("risksign-add-modal")&&0<=i.find('input[name="risksign_category_id"]').val()&&i.find(".button-disable").removeClass("button-disable")},window.digiriskdolibarr.risksign.createRiskSign=function(i){var e=window.saturne.toolbox.getToken(),s=$(this).closest(".fichecenter").find(".risksign-content"),t=s.find(".risksign-category input").val(),s=s.find(".risksign-description textarea").val();window.saturne.loader.display($(".fichecenter.risksignlist")),$.ajax({url:document.URL+"&action=add&token="+e,type:"POST",data:JSON.stringify({riskSignCategory:t,riskSignDescription:s}),processData:!1,contentType:!1,success:function(i){$(".fichecenter.risksignlist").html($(i).find("#searchFormListRiskSigns"));var e=$(".messageSuccessRiskSignCreate");$(".fichecenter.risksignlist").removeClass("wpeo-loader"),e.html($(i).find(".risksign-create-success-notice")),e.removeClass("hidden")},error:function(i){var e=$(".messageErrorRiskCreate");e.html($(i).find(".risksign-create-error-notice")),e.removeClass("hidden")}})},window.digiriskdolibarr.risksign.saveRiskSign=function(i){var e=window.saturne.toolbox.getToken(),s=$(this).attr("value");let t=$(this).closest(".risksign-container").find(".risksign-content"),a="";var n=t.find(".risksign-category input").val(),r=t.find(".risksign-description textarea").val();let o=$(".risksign_row_"+s).find(".risksign-container > div:nth-child(1)").text();window.saturne.loader.display(t),$.ajax({url:document.URL+"&action=saveRiskSign&token="+e,data:JSON.stringify({riskSignID:s,riskSignCategory:n,riskSignDescription:r}),type:"POST",processData:!1,contentType:!1,success:function(i){$(".fichecenter.risksignlist").html($(i).find("#searchFormListRiskSigns"));i=$(".messageSuccessRiskSignEdit");t.removeClass("wpeo-loader"),a=(a=(a+=i.find(".valueForEditRiskSign1").val())+o)+i.find(".valueForEditRiskSign2").val(),i.find(".notice-subtitle .text").text(a),i.removeClass("hidden")},error:function(){var i=$(".messageErrorRiskSignEdit");t.removeClass("wpeo-loader"),a=(a=(a+=i.find(".valueForEditRiskSign1").val())+o)+i.find(".valueForEditRiskSign2").val(),i.find(".notice-subtitle .text").text(a),i.removeClass("hidden")}})},window.digiriskdolibarr.risksign.unlinkSharedRiskSign=function(i){var e=window.saturne.toolbox.getToken();let s=$(this).attr("value"),t=(window.saturne.loader.display($(this)),$(".risksign_row_"+s).find(".risksign-container > div:nth-child(1)").text());var a=document.URL.split(/#/);$.ajax({url:a[0]+"&action=unlinkSharedRiskSign&token="+e,type:"POST",processData:!1,data:JSON.stringify({risksignID:s}),contentType:!1,success:function(i){$(".fichecenter.sharedrisksignlist .opacitymedium.colorblack.paddingleft").html($(i).find("#searchFormSharedListRiskSigns .opacitymedium.colorblack.paddingleft"));var i=$(".messageSuccessRiskSignUnlinkShared"),e=($("#risksign_row_"+s).fadeOut(800),""),e=(e=(e+=i.find(".valueForUnlinkSharedRiskSign1").val())+t)+i.find(".valueForUnlinkSharedRiskSign2").val();i.find(".notice-subtitle .text").text(e),i.removeClass("hidden")},error:function(i){var e=$(".messageErrorRiskSignUnlinkShared"),s="",s=(s=(s+=e.find(".valueForUnlinkSharedRiskSign1").val())+t)+e.find(".valueForUnlinkSharedRiskSign2").val();e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")}})},window.digiriskdolibarr.riskassessmenttask={},window.digiriskdolibarr.riskassessmenttask.init=function(){window.digiriskdolibarr.riskassessmenttask.event()},window.digiriskdolibarr.riskassessmenttask.event=function(){$(document).on("input",".riskassessment-task-label",window.digiriskdolibarr.riskassessmenttask.fillRiskAssessmentTaskLabel),$(document).on("click",".riskassessment-task-create",window.digiriskdolibarr.riskassessmenttask.createRiskAssessmentTask),$(document).on("click",".riskassessment-task-save",window.digiriskdolibarr.riskassessmenttask.saveRiskAssessmentTask),$(document).on("click",".riskassessment-task-delete",window.digiriskdolibarr.riskassessmenttask.deleteRiskAssessmentTask),$(document).on("click",".riskassessment-task-timespent-create",window.digiriskdolibarr.riskassessmenttask.createRiskAssessmentTaskTimeSpent),$(document).on("click",".riskassessment-task-timespent-save",window.digiriskdolibarr.riskassessmenttask.saveRiskAssessmentTaskTimeSpent),$(document).on("click",".riskassessment-task-timespent-delete",window.digiriskdolibarr.riskassessmenttask.deleteRiskAssessmentTaskTimeSpent),$(document).on("click",".riskassessment-task-progress-checkbox:not(.riskassessment-task-progress-checkbox-readonly)",window.digiriskdolibarr.riskassessmenttask.checkTaskProgress),$(document).on("change","#RiskassessmentTaskTimespentDatehour",window.digiriskdolibarr.riskassessmenttask.selectRiskassessmentTaskTimespentDateHour),$(document).on("change","#RiskassessmentTaskTimespentDatemin",window.digiriskdolibarr.riskassessmenttask.selectRiskassessmentTaskTimespentDateMin),$(document).on("keyup",".riskassessment-task-label",window.digiriskdolibarr.riskassessmenttask.checkRiskassessmentTaskLabelLength),$(document).on("click",".listingHeaderTaskTooltip",window.digiriskdolibarr.riskassessmenttask.redirectOnSharedTaskConfig)},window.digiriskdolibarr.riskassessmenttask.fillRiskAssessmentTaskLabel=function(i){var e=$(this).closest(".modal-container");window.digiriskdolibarr.riskassessmenttask.haveDataInInput(e)},window.digiriskdolibarr.riskassessmenttask.haveDataInInput=function(i){i=i.parent().parent();i.hasClass("riskassessment-task-add-modal")&&i.find('input[name="label"]').val().length&&i.find(".button-disable").removeClass("button-disable")},window.digiriskdolibarr.riskassessmenttask.createRiskAssessmentTask=function(i){var e=window.saturne.toolbox.getToken(),s=$(this).closest(".riskassessment-task-add-modal"),t=s.find(".modal-risk").attr("value"),s=s.find(".riskassessment-task-container"),a=s.find(".riskassessment-task-label").val(),a=window.digiriskdolibarr.risk.sanitizeBeforeRequest(a),n=s.find("#RiskassessmentTaskDateStart"+t).val(),r=s.find("#RiskassessmentTaskDateStart"+t+"hour").val(),o=s.find("#RiskassessmentTaskDateStart"+t+"min").val(),d=s.find("#RiskassessmentTaskDateEnd"+t).val(),l=s.find("#RiskassessmentTaskDateEnd"+t+"hour").val(),c=s.find("#RiskassessmentTaskDateEnd"+t+"min").val(),s=s.find(".riskassessment-task-budget").val();window.saturne.loader.display($(this)),window.saturne.loader.display($(".riskassessment-tasks"+t)),$.ajax({url:document.URL+"&action=addRiskAssessmentTask&token="+e,type:"POST",data:JSON.stringify({tasktitle:a,dateStart:n,hourStart:r,minStart:o,dateEnd:d,hourEnd:l,minEnd:c,budget:s,riskToAssign:t}),processData:!1,contentType:!1,success:function(i){$(".tasks-list-container-"+t).replaceWith($(i).find(".tasks-list-container-"+t));var e=$(".messageSuccessTaskCreate");$(".riskassessment-tasks"+t).fadeOut(800),$(".riskassessment-tasks"+t).fadeIn(800),e.find("a").attr("href","#risk_row_"+t),e.html($(i).find(".task-create-success-notice")),e.removeClass("hidden")},error:function(i){$(".wpeo-loader").removeClass("wpeo-loader"),window.scrollTo(0,0);var i=JSON.parse(i.responseText),e=$(".messageErrorTaskCreate"),s=($("#risk_assessment_task_add"+t).removeClass("modal-active"),""),s=(s=(s+=e.find(".valueForCreateTask1").val())+e.find(".valueForCreateTask2").val())+" : "+i.message;e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")}})},window.digiriskdolibarr.riskassessmenttask.deleteRiskAssessmentTask=function(i){var e=window.saturne.toolbox.getToken(),t=$(this).closest(".wpeo-table.riskassessment-tasks").attr("value"),a=$(this).closest(".riskassessment-task-single-content").attr("value"),s=$(this).closest(".riskassessment-task-container-"+a).find(".labelForDelete").val();let n=$(".messageSuccessTaskDelete"),r=$(".messageErrorTaskDelete");if(1!=confirm(s))return!1;{let s=$(".riskassessment-task-container-"+a).attr("value");window.saturne.loader.display($(".riskassessment-task-container-"+a)),$.ajax({url:document.URL+"&action=deleteRiskAssessmentTask&deletedRiskAssessmentTaskId="+a+"&token="+e,type:"POST",processData:!1,contentType:!1,success:function(i){console.log($(".riskassessment-task-listing-wrapper-"+t)),console.log(t),$(".riskassessment-task-listing-wrapper-"+t).replaceWith($(i).find(".riskassessment-task-listing-wrapper-"+t)),$(".riskassessment-tasks"+t).fadeOut(800),$(".riskassessment-tasks"+t).fadeIn(800);i="",i=(i=(i+=n.find(".valueForDeleteTask1").val())+s)+n.find(".valueForDeleteTask2").val();n.find("a").attr("href","#risk_row_"+t),n.find(".notice-subtitle .text").text(i),n.removeClass("hidden")},error:function(i){$(".wpeo-loader").removeClass("wpeo-loader"),window.scrollTo(0,0);var i=JSON.parse(i.responseText),e="",e=(e=(e=(e+=r.find(".valueForDeleteTask1").val())+s)+r.find(".valueForDeleteTask2").val())+" : "+i.message;r.find(".notice-subtitle .text").text(e),r.removeClass("hidden")}})}},window.digiriskdolibarr.riskassessmenttask.saveRiskAssessmentTask=function(i){var e=window.saturne.toolbox.getToken();let s=$(this).attr("value");var t=$(this).closest(".modal-container"),a=$(this).closest(".modal-risk").attr("value");let n="";var r=t.find(".riskassessment-task-label"+s).val(),r=window.digiriskdolibarr.risk.sanitizeBeforeRequest(r);let o=$(".riskassessment-task-single-"+s+" .riskassessment-task-reference").attr("value"),d=0;t.find(".riskassessment-task-progress-checkbox"+s).is(":checked")&&(d=1);var l=t.find("#RiskassessmentTaskDateStart"+s).val(),c=t.find("#RiskassessmentTaskDateStart"+s+"hour").val(),k=t.find("#RiskassessmentTaskDateStart"+s+"min").val(),u=t.find("#RiskassessmentTaskDateEnd"+s).val(),m=t.find("#RiskassessmentTaskDateEnd"+s+"hour").val(),v=t.find("#RiskassessmentTaskDateEnd"+s+"min").val(),t=t.find(".riskassessment-task-budget"+s).val();window.saturne.loader.display($(this)),window.saturne.loader.display($(".riskassessment-task-single-"+s)),$.ajax({url:document.URL+"&action=saveRiskAssessmentTask&token="+e,data:JSON.stringify({riskAssessmentTaskID:s,tasktitle:r,dateStart:l,hourStart:c,minStart:k,dateEnd:u,hourEnd:m,minEnd:v,budget:t,taskProgress:d}),type:"POST",processData:!1,contentType:!1,success:function(i){$("#risk_assessment_task_edit"+s).removeClass("modal-active"),$(".riskassessment-task-container-"+s).replaceWith($(i).find(".riskassessment-task-container-"+s).first());i=$(".messageSuccessTaskEdit");$(".riskassessment-tasks"+a).fadeOut(800),$(".riskassessment-tasks"+a).fadeIn(800),n=(n=(n+=i.find(".valueForEditTask1").val())+o)+i.find(".valueForEditTask2").val(),$(".wpeo-loader").removeClass("wpeo-loader"),$(".loader-spin").remove(),i.find("a").attr("href","#risk_row_"+a),i.find(".notice-subtitle .text").text(n),i.removeClass("hidden")},error:function(i){$(".wpeo-loader").removeClass("wpeo-loader"),window.scrollTo(0,0);var i=JSON.parse(i.responseText),e=$(".messageErrorTaskEdit");$("#risk_assessment_task_edit"+s).removeClass("modal-active"),$(".wpeo-loader").removeClass("wpeo-loader"),n=(n=(n=(n+=e.find(".valueForEditTask1").val())+o)+e.find(".valueForEditTask2").val()+" : ")+i.message,e.find(".notice-subtitle .text").text(n),e.removeClass("hidden")}})},window.digiriskdolibarr.riskassessmenttask.createRiskAssessmentTaskTimeSpent=function(i){var e=window.saturne.toolbox.getToken();let s=$(this).attr("value");var t=$(this).closest(".riskassessment-task-edit-modal"),a=t.find(".riskassessment-task-timespent-container");let n=t.find("riskassessment-task-single").attr("value"),r="",o=t.find(".riskassessment-task-reference").attr("value"),d=$(".id-container").find(".riskassessment-total-task-timespent-"+s);var t=a.find("#RiskassessmentTaskTimespentDate"+s).val(),l=a.find("#RiskassessmentTaskTimespentDate"+s+"hour").val(),c=a.find("#RiskassessmentTaskTimespentDate"+s+"min").val(),k=a.find(".riskassessment-task-timespent-comment").val(),k=window.digiriskdolibarr.risk.sanitizeBeforeRequest(k),a=a.find(".riskassessment-task-timespent-duration").val();window.saturne.loader.display($(this)),window.saturne.loader.display($(".riskassessment-task-single-"+s)),$.ajax({url:document.URL+"&action=addRiskAssessmentTaskTimeSpent&token="+e,type:"POST",data:JSON.stringify({taskID:s,date:t,hour:l,min:c,comment:k,duration:a}),processData:!1,contentType:!1,success:function(i){var e=$(".messageSuccessTaskTimeSpentCreate"+s);$(".riskassessment-tasks"+n).fadeOut(800),$(".riskassessment-tasks"+n).fadeIn(800),r=(r=(r+=e.find(".valueForCreateTaskTimeSpent1").val())+o)+e.find(".valueForCreateTaskTimeSpent2").val(),$(".riskassessment-task-timespent-container").find(".riskassessment-task-timespent-list-"+s).html($(i).find(".riskassessment-task-timespent-container").find(".riskassessment-task-timespent-list-"+s)),$(".riskassessment-task-container-"+s).closest(".riskassessment-tasks").html($(i).find(".riskassessment-task-container-"+s).closest(".riskassessment-tasks")),$(".loader-spin").remove(),$(".wpeo-loader").removeClass("wpeo-loader"),e.find(".notice-subtitle .text").text(r),e.removeClass("hidden"),d.html($(i).find(".modal-content").find(".riskassessment-total-task-timespent-"+s).first())},error:function(i){$(this).closest(".risk-row-content-"+n).removeClass("wpeo-loader");var e=$(".messageErrorTaskTimeSpentCreate"+s);e.html($(i).find(".task-timespent-create-error-notice")),e.removeClass("hidden")},complete:function(){$("#risk_assessment_task_edit"+s+".wpeo-modal").addClass("modal-active")}})},window.digiriskdolibarr.riskassessmenttask.deleteRiskAssessmentTaskTimeSpent=function(i){var e=window.saturne.toolbox.getToken();let a=$(this).closest(".riskassessment-task-timespent-list").attr("value"),n=$(this).attr("value");var s=$(this).attr("value"),t=$(this).closest(".riskassessment-task-timespent-"+n).find(".labelForDelete").val();let r=$(".id-container").first().find(".riskassessment-total-task-timespent-"+a);if(1!=confirm(t))return!1;{let t=$(".riskassessment-task-container-"+a).attr("value");window.saturne.loader.display($(this)),$.ajax({url:document.URL+"&action=deleteRiskAssessmentTaskTimeSpent&deletedRiskAssessmentTaskTimeSpentId="+s+"&token="+e,type:"POST",processData:!1,contentType:!1,success:function(i){var e=$(".messageSuccessTaskTimeSpentDelete"+a),s=($(".riskassessment-task-timespent-"+n).fadeOut(800),""),s=(s=(s+=e.find(".valueForDeleteTaskTimeSpent1").val())+t)+e.find(".valueForDeleteTaskTimeSpent2").val();e.find(".notice-subtitle .text").text(s),e.removeClass("hidden"),r.html($(i).find(".modal-content").find(".riskassessment-total-task-timespent-"+a).first())},error:function(i){var e=$(".messageErrorTaskDeleteTimeSpent"+a),s="",s=(s=(s+=e.find(".valueForDeleteTaskTimeSpent1").val())+t)+e.find(".valueForDeleteTaskTimeSpent2").val();e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")}})}},window.digiriskdolibarr.riskassessmenttask.saveRiskAssessmentTaskTimeSpent=function(i){var e=window.saturne.toolbox.getToken();let s=$(this);var t=$(this).attr("value"),a=$(this).closest(".riskassessment-task-timespent-edit-modal").find(".riskassessment-task-timespent-container");let n=a.attr("value"),r="",o=$(".riskassessment-task-container-"+n).attr("value"),d=$(".id-container").first().find(".riskassessment-total-task-timespent-"+n);var l=a.find("#RiskassessmentTaskTimespentDateEdit"+t).val(),c=a.find("#RiskassessmentTaskTimespentDateEdit"+t+"hour").val(),k=a.find("#RiskassessmentTaskTimespentDateEdit"+t+"min").val(),u=a.find(".riskassessment-task-timespent-comment").val(),u=window.digiriskdolibarr.risk.sanitizeBeforeRequest(u),a=a.find(".riskassessment-task-timespent-duration").val();window.saturne.loader.display($(this)),window.saturne.loader.display($(".riskassessment-task-single-"+n)),$.ajax({url:document.URL+"&action=saveRiskAssessmentTaskTimeSpent&token="+e,data:JSON.stringify({riskAssessmentTaskTimeSpentID:t,taskID:n,date:l,hour:c,min:k,comment:u,duration:a}),type:"POST",processData:!1,contentType:!1,success:function(i){s.closest(".modal-active").removeClass("modal-active");var e=$(".messageSuccessTaskTimeSpentEdit"+n);$(".wpeo-loader").removeClass("wpeo-loader"),r=(r=(r+=e.find(".valueForEditTaskTimeSpent1").val())+o)+e.find(".valueForEditTaskTimeSpent2").val(),d.html($(i).find(".modal-content").find(".riskassessment-total-task-timespent-"+n).first()),$(".riskassessment-task-timespent-list-"+n).html($(i).find(".riskassessment-task-timespent-list-"+n).children()),e.find(".notice-subtitle .text").text(r),e.removeClass("hidden")},error:function(i){var e=$(".messageSuccessTaskTimeSpentEdit"+n);r=(r=(r+=e.find(".valueForEditTaskTimeSpent1").val())+o)+e.find(".valueForEditTaskTimeSpent2").val(),e.find(".notice-subtitle .text").text(r),e.removeClass("hidden")}})},window.digiriskdolibarr.riskassessmenttask.checkTaskProgress=function(i){var e=window.saturne.toolbox.getToken(),s=$(this).closest(".riskassessment-task-container"),t=s.find(".riskassessment-task-single-content").attr("value");let a=$(this).closest(".riskassessment-tasks").attr("value"),n="",r=s.attr("value"),o="";s.find(".riskassessment-task-progress-checkbox"+t).hasClass("progress-checkbox-check")?(o=0,s.find(".riskassessment-task-progress-checkbox"+t).toggleClass("progress-checkbox-check").toggleClass("progress-checkbox-uncheck")):s.find(".riskassessment-task-progress-checkbox"+t).hasClass("progress-checkbox-uncheck")&&(o=1,s.find(".riskassessment-task-progress-checkbox"+t).toggleClass("progress-checkbox-uncheck").toggleClass("progress-checkbox-check")),window.saturne.loader.display($(".riskassessment-task-single-"+t));s=window.location.href.replace(/#.*/,"");$.ajax({url:s+"&action=checkTaskProgress&token="+e,data:JSON.stringify({riskAssessmentTaskID:t,taskProgress:o}),type:"POST",processData:!1,contentType:!1,success:function(i){$(".fichecenter.risklist").html($(i).find("#searchFormListRisks"));i=$(".messageSuccessTaskEdit");$(".riskassessment-tasks"+a).fadeOut(800),$(".riskassessment-tasks"+a).fadeIn(800),n=(n=(n+=i.find(".valueForEditTask1").val())+r)+i.find(".valueForEditTask2").val(),i.find(".notice-subtitle .text").text(n),i.removeClass("hidden")},error:function(i){var e=$(".messageErrorTaskEdit");n=(n=(n+=e.find(".valueForEditTask1").val())+r)+e.find(".valueForEditTask2").val(),e.find(".notice-subtitle .text").text(n),e.removeClass("hidden")}})},window.digiriskdolibarr.riskassessmenttask.selectRiskassessmentTaskTimespentDateHour=function(i){$(this).closest(".nowraponall").find(".select-riskassessmenttask-timespent-datehour").remove(),$(this).before('{$("#sendFileForm").load(document.URL+n+"ticket_id="+a+" #fileLinkedTable")})},window.digiriskdolibarr.ticket.removeFile=function(i){let e=$(this).attr("value");e=e.replace("_mini","");var s=$("#ticket_id").val(),t=window.saturne.toolbox.getQuerySeparator();fetch(document.URL+t+"action=removefile&filetodelete="+e+"&ticket_id="+s,{method:"POST"}).then(i=>{$(this).parent().parent().hide()})},window.digiriskdolibarr.ticket.addDashBoardTicketInfo=function(){var i=window.saturne.toolbox.getToken(),e=$("#select2-boxcombo-container").attr("title"),s=e.split(" : ")[0],e=e.split(" : ")[2],t=window.saturne.toolbox.getQuerySeparator();$.ajax({url:document.URL+t+"action=adddashboardinfo&token="+i,type:"POST",processData:!1,data:JSON.stringify({digiriskelementID:s,catID:e}),contentType:!1,success:function(i){window.location.reload()},error:function(){}})},window.digiriskdolibarr.ticket.closeDashBoardTicketInfo=function(){var i=window.saturne.toolbox.getToken();let e=$(this);var s=e.attr("data-digiriskelementid"),t=e.attr("data-catid"),a=window.saturne.toolbox.getQuerySeparator();$.ajax({url:document.URL+a+"action=closedashboardinfo&token="+i,type:"POST",processData:!1,data:JSON.stringify({digiriskelementID:s,catID:t}),contentType:!1,success:function(i){e.closest(".box-flex-item").fadeOut(400),$(".add-widget-box").attr("style",""),$(".add-widget-box").html($(i).find(".add-widget-box").children())},error:function(){}})},window.digiriskdolibarr.ticket.checkValidEmail=function(){0==/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(this.value)?$(this).css("border","3px solid red"):$(this).css("border","3px solid green")},window.digiriskdolibarr.ticket.checkValidPhone=function(){0==/^(?:(?:(?:\+|00)\d{2}[\s]?(?:\(0\)[\s]?)?)|0){1}[1-9]{1}([\s.-]?)(?:\d{2}\1?){3}\d{2}$/.test(this.value)?$(this).css("border","3px solid red"):$(this).css("border","3px solid green")},window.digiriskdolibarr.digiriskusers={},window.digiriskdolibarr.digiriskusers.init=function(){window.digiriskdolibarr.digiriskusers.event()},window.digiriskdolibarr.digiriskusers.event=function(){$(document).on("input",".digirisk-users #firstname",window.digiriskdolibarr.digiriskusers.fillEmail),$(document).on("input",".digirisk-users #lastname",window.digiriskdolibarr.digiriskusers.fillEmail)},window.digiriskdolibarr.digiriskusers.fillEmail=function(i){var e=$(".digirisk-users #firstname").val(),s=$(".digirisk-users #lastname").val(),t=$(".input-domain-mail").val(),e=window.digiriskdolibarr.digiriskusers.removeDiacritics(e+"."+s+"@"+t).toLowerCase();$(".digirisk-users #email").val(e)},window.digiriskdolibarr.digiriskusers.removeDiacritics=function(i){for(var e="",s=i.normalize("NFD"),t=0,a=0;ti.json()).then(i=>{i=i[0].option.matrix[e];t.find(".risk-evaluation-calculated-cotation").find(".risk-evaluation-cotation").attr("data-scale",window.digiriskdolibarr.evaluation.getDynamicScale(i)),t.find(".risk-evaluation-calculated-cotation").find(".risk-evaluation-cotation span").text(i),t.find(".risk-evaluation-content").find(".risk-evaluation-seuil").val(i),window.digiriskdolibarr.risk.haveDataInInput(t)})}},window.digiriskdolibarr.evaluator={},window.digiriskdolibarr.evaluator.init=function(){window.digiriskdolibarr.evaluator.event()},window.digiriskdolibarr.evaluator.event=function(){$(document).on("click",".evaluator-create",window.digiriskdolibarr.evaluator.createEvaluator),$(document).on("change","#fk_user_employer",window.digiriskdolibarr.evaluator.selectUser)},window.digiriskdolibarr.evaluator.selectUser=function(i){var e=window.saturne.toolbox.getToken(),s=$(this).closest(".modal-container"),t=s.find("#fk_user_employer").val();window.saturne.loader.display(s.find('input[name="evaluatorJob"]')),$.ajax({url:document.URL+"&action=getEvaluatorJob&token="+e,type:"POST",processData:!1,data:JSON.stringify({userID:t}),contentType:!1,success:function(i){s.find('input[name="evaluatorJob"]').val($(i).find('input[name="evaluatorJob"]').val()),s.find('input[name="evaluatorJob"]').removeClass("wpeo-loader")},error:function(i){}}),window.digiriskdolibarr.evaluator.haveDataInInput(s)},window.digiriskdolibarr.evaluator.haveDataInInput=function(i){i=i.parent().parent();i.hasClass("evaluator-add-modal")&&(0 div:nth-child(1)").text();$.ajax({url:document.URL+"&action=saveRisk&token="+e,type:"POST",processData:!1,data:JSON.stringify({riskID:t,category:s,comment:r,newParent:o}),contentType:!1,success:function(i){$(".wpeo-loader").removeClass("wpeo-loader");var e=$(".messageSuccessRiskEdit"),s=(o==a||n?($(".modal-active").removeClass("modal-active"),$(".risk-description-"+t).html($(i).find(".risk-description-"+t)),$(".risk-row-content-"+t).find(".risk-category .cell-risk").html($(i).find(".risk-row-content-"+t).find(".risk-category .cell-risk").children()),$(".risk-row-content-"+t).find(".risk-category").fadeOut(800),$(".risk-row-content-"+t).find(".risk-category").fadeIn(800),$(".risk-row-content-"+t).find(".risk-description-"+t).fadeOut(800),$(".risk-row-content-"+t).find(".risk-description-"+t).fadeIn(800)):$(".risk-row-content-"+t).fadeOut(800,function(){$(".fichecenter .opacitymedium.colorblack.paddingleft").html($(i).find("#searchFormListRisks .opacitymedium.colorblack.paddingleft"))}),""),s=(s=(s+=e.find(".valueForEditRisk1").val())+d)+e.find(".valueForEditRisk2").val();e.find("a").attr("href","#risk_row_"+t),e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")},error:function(i){var e=$(".messageErrorRiskEdit"),s="",s=(s=(s+=e.find(".valueForEditRisk1").val())+d)+e.find(".valueForEditRisk2").val();e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")}})},window.digiriskdolibarr.risk.unlinkSharedRisk=function(i){var e=window.saturne.toolbox.getToken();let s=$(this).attr("value"),t=(window.saturne.loader.display($(this)),$(".risk_row_"+s).find(".risk-container > div:nth-child(1)").text());var a=document.URL.split(/#/);$.ajax({url:a[0]+"&action=unlinkSharedRisk&token="+e,type:"POST",processData:!1,data:JSON.stringify({riskID:s}),contentType:!1,success:function(i){$(".confirmquestions").html($(i).find(".confirmquestions").children()),$(".fichecenter.sharedrisklist .opacitymedium.colorblack.paddingleft").html($(i).find("#searchFormSharedListRisks .opacitymedium.colorblack.paddingleft"));var i=$(".messageSuccessRiskUnlinkShared"),e=($("#risk_row_"+s).fadeOut(800),""),e=(e=(e+=i.find(".valueForUnlinkSharedRisk1").val())+t)+i.find(".valueForUnlinkSharedRisk2").val();i.find(".notice-subtitle .text").text(e),i.removeClass("hidden")},error:function(i){var e=$(".messageErrorRiskUnlinkShared"),s="",s=(s=(s+=e.find(".valueForUnlinkSharedRisk1").val())+t)+e.find(".valueForUnlinkSharedRisk2").val();e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")}})},window.digiriskdolibarr.risk.sharedRiskBoxLoader=function(i){"Oui"==$(this).text()&&window.saturne.loader.display($("#searchFormSharedListRisks"))},window.digiriskdolibarr.evaluation={},window.digiriskdolibarr.evaluation.init=function(){window.digiriskdolibarr.evaluation.event()},window.digiriskdolibarr.evaluation.event=function(){$(document).on("click",".select-evaluation-method",window.digiriskdolibarr.evaluation.selectEvaluationMethod),$(document).on("click",".cotation-container .risk-evaluation-cotation.cotation",window.digiriskdolibarr.evaluation.selectSeuil),$(document).on("click",".risk-evaluation-create",window.digiriskdolibarr.evaluation.createEvaluation),$(document).on("click",".risk-evaluation-save",window.digiriskdolibarr.evaluation.saveEvaluation),$(document).on("click",".risk-evaluation-delete",window.digiriskdolibarr.evaluation.deleteEvaluation)},window.digiriskdolibarr.evaluation.selectEvaluationMethod=function(i){var e=$(this).closest(".modal-container");0"+e.split(/\(/)[0]+"("+(+s-1)+")"),s-1<1&&$(".fichecenter.risklist").html($(i).find("#searchFormListRisks")),t.removeClass("wpeo-loader"),""),e=(e=(e+=r.find(".valueForDeleteEvaluation1").val())+n)+r.find(".valueForDeleteEvaluation2").val();r.find(".notice-subtitle .text").text(e),r.removeClass("hidden")},error:function(i){var e="",e=(e=(e+=o.find(".valueForDeleteEvaluation1").val())+n)+o.find(".valueForDeleteEvaluation2").val();o.find(".notice-subtitle .text").text(e),o.removeClass("hidden")}})}},window.digiriskdolibarr.evaluation.saveEvaluation=function(i){var e=window.saturne.toolbox.getToken();let s=$(this).closest(".risk-evaluation-edit-modal"),t=s.attr("value");var a=s.find(".risk-evaluation-comment textarea").val();let n=$(this).closest(".risk-row").find(".risk-evaluations-list-content").attr("value"),r=$(".risk-evaluation-ref-"+t).attr("value"),o=$(".risk-evaluation-list-modal-"+n),d=$("#risk_evaluation_list"+n).hasClass("modal-active");var a=window.digiriskdolibarr.risk.sanitizeBeforeRequest(a),l=s.find(".risk-evaluation-method").val(),c=s.find(".risk-evaluation-seuil").val(),k=s.find("#RiskAssessmentDateEdit"+t).val(),u=s.find(".risk-evaluation-photo .filename").val();let m=[];Object.values($(".table-cell.active.cell-"+t)).forEach(function(i){-1<$(i).data("seuil")&&(m[$(i).data("type")]=$(i).data("seuil"))}),window.saturne.loader.display($(this)),$.ajax({url:document.URL+"&action=saveEvaluation&token="+e,type:"POST",processData:!1,data:JSON.stringify({cotation:c,comment:a,method:l,photo:u,date:k,evaluationID:t,criteres:{gravite:m.gravite||0,occurrence:m.occurrence||0,protection:m.protection||0,formation:m.formation||0,exposition:m.exposition||0}}),contentType:!1,success:function(i){$("#risk_evaluation_edit"+t).removeClass("modal-active"),0<$(i).find(".risk-evaluation-container.risk-evaluation-container-"+t+":not(.last-risk-assessment)").length?((d?($(".risk-evaluation-ref-"+t+":not(.last-risk-assessment)").fadeOut(800),$(".risk-evaluation-ref-"+t+":not(.last-risk-assessment)")):($(".risk-evaluation-container-"+t+":not(.last-risk-assessment)").fadeOut(800),$(".risk-evaluation-container-"+t+":not(.last-risk-assessment)"))).fadeIn(800),o.find(".risk-evaluation-ref-"+t).replaceWith($(i).find(".risk-evaluation-ref-"+t)),$(".risk-evaluation-container.risk-evaluation-container-"+t+":not(.last-risk-assessment)").replaceWith($(i).find(".risk-evaluation-container.risk-evaluation-container-"+t+":not(.last-risk-assessment)")),$("#risk_evaluation_add"+n).html($(i).find("#risk_evaluation_add"+n).children())):($(".div-table-responsive").html($(i).find(".div-table-responsive").children()),(d?($(".risk-evaluation-ref-"+t+":not(.last-risk-assessment)").fadeOut(800),$(".risk-evaluation-ref-"+t+":not(.last-risk-assessment)")):($(".risk-evaluation-container-"+t+":not(.last-risk-assessment)").fadeOut(800),$(".risk-evaluation-container-"+t+":not(.last-risk-assessment)"))).fadeIn(800)),$(".wpeo-loader").removeClass("wpeo-loader");var i=$(".messageSuccessEvaluationEdit"),e=(s.find("#risk_evaluation_edit"+t).removeClass("modal-active"),""),e=(e=(e+=i.find(".valueForEditEvaluation1").val())+r)+i.find(".valueForEditEvaluation2").val();i.find("a").attr("href","#risk_row_"+n),i.find(".notice-subtitle .text").text(e),i.removeClass("hidden")},error:function(){var i=$(".messageErrorEvaluationEdit"),e="",e=(e=(e+=i.find(".valueForEditEvaluation1").val())+r)+i.find(".valueForEditEvaluation2").val();i.find(".notice-subtitle .text").text(e),i.removeClass("hidden")}})},window.digiriskdolibarr.risksign={},window.digiriskdolibarr.risksign.init=function(){window.digiriskdolibarr.risksign.event()},window.digiriskdolibarr.risksign.event=function(){$(document).on("click",".risksign-category-danger .item, .wpeo-table .risksign-category-danger .item",window.digiriskdolibarr.risksign.selectRiskSign),$(document).on("click",".risksign-create:not(.button-disable)",window.digiriskdolibarr.risksign.createRiskSign),$(document).on("click",".risksign-save",window.digiriskdolibarr.risksign.saveRiskSign),$(document).on("click",".risksign-unlink-shared",window.digiriskdolibarr.risksign.unlinkSharedRiskSign)},window.digiriskdolibarr.risksign.selectRiskSign=function(i){var e=$(this),e=(e.closest(".content").removeClass("active"),e.closest(".wpeo-dropdown").find(".dropdown-toggle span").hide(),e.closest(".wpeo-dropdown").find(".dropdown-toggle img").show(),e.closest(".wpeo-dropdown").find(".dropdown-toggle img").attr("src",e.find("img").attr("src")),e.closest(".wpeo-dropdown").find(".dropdown-toggle img").attr("aria-label",e.closest(".wpeo-tooltip-event").attr("aria-label")),e.closest(".fichecenter").find(".input-hidden-danger").val(e.data("id")),$(this).closest(".modal-container"));window.digiriskdolibarr.risksign.haveDataInInput(e)},window.digiriskdolibarr.risksign.haveDataInInput=function(i){i=i.parent().parent();i.hasClass("risksign-add-modal")&&0<=i.find('input[name="risksign_category_id"]').val()&&i.find(".button-disable").removeClass("button-disable")},window.digiriskdolibarr.risksign.createRiskSign=function(i){var e=window.saturne.toolbox.getToken(),s=$(this).closest(".fichecenter").find(".risksign-content"),t=s.find(".risksign-category input").val(),s=s.find(".risksign-description textarea").val();window.saturne.loader.display($(".fichecenter.risksignlist")),$.ajax({url:document.URL+"&action=add&token="+e,type:"POST",data:JSON.stringify({riskSignCategory:t,riskSignDescription:s}),processData:!1,contentType:!1,success:function(i){$(".fichecenter.risksignlist").html($(i).find("#searchFormListRiskSigns"));var e=$(".messageSuccessRiskSignCreate");$(".fichecenter.risksignlist").removeClass("wpeo-loader"),e.html($(i).find(".risksign-create-success-notice")),e.removeClass("hidden")},error:function(i){var e=$(".messageErrorRiskCreate");e.html($(i).find(".risksign-create-error-notice")),e.removeClass("hidden")}})},window.digiriskdolibarr.risksign.saveRiskSign=function(i){var e=window.saturne.toolbox.getToken(),s=$(this).attr("value");let t=$(this).closest(".risksign-container").find(".risksign-content"),a="";var n=t.find(".risksign-category input").val(),r=t.find(".risksign-description textarea").val();let o=$(".risksign_row_"+s).find(".risksign-container > div:nth-child(1)").text();window.saturne.loader.display(t),$.ajax({url:document.URL+"&action=saveRiskSign&token="+e,data:JSON.stringify({riskSignID:s,riskSignCategory:n,riskSignDescription:r}),type:"POST",processData:!1,contentType:!1,success:function(i){$(".fichecenter.risksignlist").html($(i).find("#searchFormListRiskSigns"));i=$(".messageSuccessRiskSignEdit");t.removeClass("wpeo-loader"),a=(a=(a+=i.find(".valueForEditRiskSign1").val())+o)+i.find(".valueForEditRiskSign2").val(),i.find(".notice-subtitle .text").text(a),i.removeClass("hidden")},error:function(){var i=$(".messageErrorRiskSignEdit");t.removeClass("wpeo-loader"),a=(a=(a+=i.find(".valueForEditRiskSign1").val())+o)+i.find(".valueForEditRiskSign2").val(),i.find(".notice-subtitle .text").text(a),i.removeClass("hidden")}})},window.digiriskdolibarr.risksign.unlinkSharedRiskSign=function(i){var e=window.saturne.toolbox.getToken();let s=$(this).attr("value"),t=(window.saturne.loader.display($(this)),$(".risksign_row_"+s).find(".risksign-container > div:nth-child(1)").text());var a=document.URL.split(/#/);$.ajax({url:a[0]+"&action=unlinkSharedRiskSign&token="+e,type:"POST",processData:!1,data:JSON.stringify({risksignID:s}),contentType:!1,success:function(i){$(".fichecenter.sharedrisksignlist .opacitymedium.colorblack.paddingleft").html($(i).find("#searchFormSharedListRiskSigns .opacitymedium.colorblack.paddingleft"));var i=$(".messageSuccessRiskSignUnlinkShared"),e=($("#risksign_row_"+s).fadeOut(800),""),e=(e=(e+=i.find(".valueForUnlinkSharedRiskSign1").val())+t)+i.find(".valueForUnlinkSharedRiskSign2").val();i.find(".notice-subtitle .text").text(e),i.removeClass("hidden")},error:function(i){var e=$(".messageErrorRiskSignUnlinkShared"),s="",s=(s=(s+=e.find(".valueForUnlinkSharedRiskSign1").val())+t)+e.find(".valueForUnlinkSharedRiskSign2").val();e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")}})},window.digiriskdolibarr.riskassessmenttask={},window.digiriskdolibarr.riskassessmenttask.init=function(){window.digiriskdolibarr.riskassessmenttask.event()},window.digiriskdolibarr.riskassessmenttask.event=function(){$(document).on("input",".riskassessment-task-label",window.digiriskdolibarr.riskassessmenttask.fillRiskAssessmentTaskLabel),$(document).on("click",".riskassessment-task-create",window.digiriskdolibarr.riskassessmenttask.createRiskAssessmentTask),$(document).on("click",".riskassessment-task-save",window.digiriskdolibarr.riskassessmenttask.saveRiskAssessmentTask),$(document).on("click",".riskassessment-task-delete",window.digiriskdolibarr.riskassessmenttask.deleteRiskAssessmentTask),$(document).on("click",".riskassessment-task-timespent-create",window.digiriskdolibarr.riskassessmenttask.createRiskAssessmentTaskTimeSpent),$(document).on("click",".riskassessment-task-timespent-save",window.digiriskdolibarr.riskassessmenttask.saveRiskAssessmentTaskTimeSpent),$(document).on("click",".riskassessment-task-timespent-delete",window.digiriskdolibarr.riskassessmenttask.deleteRiskAssessmentTaskTimeSpent),$(document).on("click",".riskassessment-task-progress-checkbox:not(.riskassessment-task-progress-checkbox-readonly)",window.digiriskdolibarr.riskassessmenttask.checkTaskProgress),$(document).on("change","#RiskassessmentTaskTimespentDatehour",window.digiriskdolibarr.riskassessmenttask.selectRiskassessmentTaskTimespentDateHour),$(document).on("change","#RiskassessmentTaskTimespentDatemin",window.digiriskdolibarr.riskassessmenttask.selectRiskassessmentTaskTimespentDateMin),$(document).on("keyup",".riskassessment-task-label",window.digiriskdolibarr.riskassessmenttask.checkRiskassessmentTaskLabelLength),$(document).on("click",".listingHeaderTaskTooltip",window.digiriskdolibarr.riskassessmenttask.redirectOnSharedTaskConfig)},window.digiriskdolibarr.riskassessmenttask.fillRiskAssessmentTaskLabel=function(i){var e=$(this).closest(".modal-container");window.digiriskdolibarr.riskassessmenttask.haveDataInInput(e)},window.digiriskdolibarr.riskassessmenttask.haveDataInInput=function(i){i=i.parent().parent();i.hasClass("riskassessment-task-add-modal")&&i.find('input[name="label"]').val().length&&i.find(".button-disable").removeClass("button-disable")},window.digiriskdolibarr.riskassessmenttask.createRiskAssessmentTask=function(i){var e=window.saturne.toolbox.getToken(),s=$(this).closest(".riskassessment-task-add-modal"),t=s.find(".modal-risk").attr("value"),s=s.find(".riskassessment-task-container"),a=s.find(".riskassessment-task-label").val(),a=window.digiriskdolibarr.risk.sanitizeBeforeRequest(a),n=s.find("#RiskassessmentTaskDateStart"+t).val(),r=s.find("#RiskassessmentTaskDateStart"+t+"hour").val(),o=s.find("#RiskassessmentTaskDateStart"+t+"min").val(),d=s.find("#RiskassessmentTaskDateEnd"+t).val(),l=s.find("#RiskassessmentTaskDateEnd"+t+"hour").val(),c=s.find("#RiskassessmentTaskDateEnd"+t+"min").val(),s=s.find(".riskassessment-task-budget").val();window.saturne.loader.display($(this)),window.saturne.loader.display($(".riskassessment-tasks"+t)),$.ajax({url:document.URL+"&action=addRiskAssessmentTask&token="+e,type:"POST",data:JSON.stringify({tasktitle:a,dateStart:n,hourStart:r,minStart:o,dateEnd:d,hourEnd:l,minEnd:c,budget:s,riskToAssign:t}),processData:!1,contentType:!1,success:function(i){$(".tasks-list-container-"+t).replaceWith($(i).find(".tasks-list-container-"+t));var e=$(".messageSuccessTaskCreate");$(".riskassessment-tasks"+t).fadeOut(800),$(".riskassessment-tasks"+t).fadeIn(800),e.find("a").attr("href","#risk_row_"+t),e.html($(i).find(".task-create-success-notice")),e.removeClass("hidden")},error:function(i){$(".wpeo-loader").removeClass("wpeo-loader"),window.scrollTo(0,0);var i=JSON.parse(i.responseText),e=$(".messageErrorTaskCreate"),s=($("#risk_assessment_task_add"+t).removeClass("modal-active"),""),s=(s=(s+=e.find(".valueForCreateTask1").val())+e.find(".valueForCreateTask2").val())+" : "+i.message;e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")}})},window.digiriskdolibarr.riskassessmenttask.deleteRiskAssessmentTask=function(i){var e=window.saturne.toolbox.getToken(),t=$(this).closest(".wpeo-table.riskassessment-tasks").attr("value"),a=$(this).closest(".riskassessment-task-single-content").attr("value"),s=$(this).closest(".riskassessment-task-container-"+a).find(".labelForDelete").val();let n=$(".messageSuccessTaskDelete"),r=$(".messageErrorTaskDelete");if(1!=confirm(s))return!1;{let s=$(".riskassessment-task-container-"+a).attr("value");window.saturne.loader.display($(".riskassessment-task-container-"+a)),$.ajax({url:document.URL+"&action=deleteRiskAssessmentTask&deletedRiskAssessmentTaskId="+a+"&token="+e,type:"POST",processData:!1,contentType:!1,success:function(i){console.log($(".riskassessment-task-listing-wrapper-"+t)),console.log(t),$(".riskassessment-task-listing-wrapper-"+t).replaceWith($(i).find(".riskassessment-task-listing-wrapper-"+t)),$(".riskassessment-tasks"+t).fadeOut(800),$(".riskassessment-tasks"+t).fadeIn(800);i="",i=(i=(i+=n.find(".valueForDeleteTask1").val())+s)+n.find(".valueForDeleteTask2").val();n.find("a").attr("href","#risk_row_"+t),n.find(".notice-subtitle .text").text(i),n.removeClass("hidden")},error:function(i){$(".wpeo-loader").removeClass("wpeo-loader"),window.scrollTo(0,0);var i=JSON.parse(i.responseText),e="",e=(e=(e=(e+=r.find(".valueForDeleteTask1").val())+s)+r.find(".valueForDeleteTask2").val())+" : "+i.message;r.find(".notice-subtitle .text").text(e),r.removeClass("hidden")}})}},window.digiriskdolibarr.riskassessmenttask.saveRiskAssessmentTask=function(i){var e=window.saturne.toolbox.getToken();let s=$(this).attr("value");var t=$(this).closest(".modal-container"),a=$(this).closest(".modal-risk").attr("value");let n="";var r=t.find(".riskassessment-task-label"+s).val(),r=window.digiriskdolibarr.risk.sanitizeBeforeRequest(r);let o=$(".riskassessment-task-single-"+s+" .riskassessment-task-reference").attr("value"),d=0;t.find(".riskassessment-task-progress-checkbox"+s).is(":checked")&&(d=1);var l=t.find("#RiskassessmentTaskDateStart"+s).val(),c=t.find("#RiskassessmentTaskDateStart"+s+"hour").val(),k=t.find("#RiskassessmentTaskDateStart"+s+"min").val(),u=t.find("#RiskassessmentTaskDateEnd"+s).val(),m=t.find("#RiskassessmentTaskDateEnd"+s+"hour").val(),v=t.find("#RiskassessmentTaskDateEnd"+s+"min").val(),t=t.find(".riskassessment-task-budget"+s).val();window.saturne.loader.display($(this)),window.saturne.loader.display($(".riskassessment-task-single-"+s)),$.ajax({url:document.URL+"&action=saveRiskAssessmentTask&token="+e,data:JSON.stringify({riskAssessmentTaskID:s,tasktitle:r,dateStart:l,hourStart:c,minStart:k,dateEnd:u,hourEnd:m,minEnd:v,budget:t,taskProgress:d}),type:"POST",processData:!1,contentType:!1,success:function(i){$("#risk_assessment_task_edit"+s).removeClass("modal-active"),$(".riskassessment-task-container-"+s).replaceWith($(i).find(".riskassessment-task-container-"+s).first());i=$(".messageSuccessTaskEdit");$(".riskassessment-tasks"+a).fadeOut(800),$(".riskassessment-tasks"+a).fadeIn(800),n=(n=(n+=i.find(".valueForEditTask1").val())+o)+i.find(".valueForEditTask2").val(),$(".wpeo-loader").removeClass("wpeo-loader"),$(".loader-spin").remove(),i.find("a").attr("href","#risk_row_"+a),i.find(".notice-subtitle .text").text(n),i.removeClass("hidden")},error:function(i){$(".wpeo-loader").removeClass("wpeo-loader"),window.scrollTo(0,0);var i=JSON.parse(i.responseText),e=$(".messageErrorTaskEdit");$("#risk_assessment_task_edit"+s).removeClass("modal-active"),$(".wpeo-loader").removeClass("wpeo-loader"),n=(n=(n=(n+=e.find(".valueForEditTask1").val())+o)+e.find(".valueForEditTask2").val()+" : ")+i.message,e.find(".notice-subtitle .text").text(n),e.removeClass("hidden")}})},window.digiriskdolibarr.riskassessmenttask.createRiskAssessmentTaskTimeSpent=function(i){var e=window.saturne.toolbox.getToken();let s=$(this).attr("value");var t=$(this).closest(".riskassessment-task-edit-modal"),a=t.find(".riskassessment-task-timespent-container");let n=t.find("riskassessment-task-single").attr("value"),r="",o=t.find(".riskassessment-task-reference").attr("value"),d=$(".id-container").find(".riskassessment-total-task-timespent-"+s);var t=a.find("#RiskassessmentTaskTimespentDate"+s).val(),l=a.find("#RiskassessmentTaskTimespentDate"+s+"hour").val(),c=a.find("#RiskassessmentTaskTimespentDate"+s+"min").val(),k=a.find(".riskassessment-task-timespent-comment").val(),k=window.digiriskdolibarr.risk.sanitizeBeforeRequest(k),a=a.find(".riskassessment-task-timespent-duration").val();window.saturne.loader.display($(this)),window.saturne.loader.display($(".riskassessment-task-single-"+s)),$.ajax({url:document.URL+"&action=addRiskAssessmentTaskTimeSpent&token="+e,type:"POST",data:JSON.stringify({taskID:s,date:t,hour:l,min:c,comment:k,duration:a}),processData:!1,contentType:!1,success:function(i){var e=$(".messageSuccessTaskTimeSpentCreate"+s);$(".riskassessment-tasks"+n).fadeOut(800),$(".riskassessment-tasks"+n).fadeIn(800),r=(r=(r+=e.find(".valueForCreateTaskTimeSpent1").val())+o)+e.find(".valueForCreateTaskTimeSpent2").val(),$(".riskassessment-task-timespent-container").find(".riskassessment-task-timespent-list-"+s).html($(i).find(".riskassessment-task-timespent-container").find(".riskassessment-task-timespent-list-"+s)),$(".riskassessment-task-container-"+s).closest(".riskassessment-tasks").html($(i).find(".riskassessment-task-container-"+s).closest(".riskassessment-tasks")),$(".loader-spin").remove(),$(".wpeo-loader").removeClass("wpeo-loader"),e.find(".notice-subtitle .text").text(r),e.removeClass("hidden"),d.html($(i).find(".modal-content").find(".riskassessment-total-task-timespent-"+s).first())},error:function(i){$(this).closest(".risk-row-content-"+n).removeClass("wpeo-loader");var e=$(".messageErrorTaskTimeSpentCreate"+s);e.html($(i).find(".task-timespent-create-error-notice")),e.removeClass("hidden")},complete:function(){$("#risk_assessment_task_edit"+s+".wpeo-modal").addClass("modal-active")}})},window.digiriskdolibarr.riskassessmenttask.deleteRiskAssessmentTaskTimeSpent=function(i){var e=window.saturne.toolbox.getToken();let a=$(this).closest(".riskassessment-task-timespent-list").attr("value"),n=$(this).attr("value");var s=$(this).attr("value"),t=$(this).closest(".riskassessment-task-timespent-"+n).find(".labelForDelete").val();let r=$(".id-container").first().find(".riskassessment-total-task-timespent-"+a);if(1!=confirm(t))return!1;{let t=$(".riskassessment-task-container-"+a).attr("value");window.saturne.loader.display($(this)),$.ajax({url:document.URL+"&action=deleteRiskAssessmentTaskTimeSpent&deletedRiskAssessmentTaskTimeSpentId="+s+"&token="+e,type:"POST",processData:!1,contentType:!1,success:function(i){var e=$(".messageSuccessTaskTimeSpentDelete"+a),s=($(".riskassessment-task-timespent-"+n).fadeOut(800),""),s=(s=(s+=e.find(".valueForDeleteTaskTimeSpent1").val())+t)+e.find(".valueForDeleteTaskTimeSpent2").val();e.find(".notice-subtitle .text").text(s),e.removeClass("hidden"),r.html($(i).find(".modal-content").find(".riskassessment-total-task-timespent-"+a).first())},error:function(i){var e=$(".messageErrorTaskDeleteTimeSpent"+a),s="",s=(s=(s+=e.find(".valueForDeleteTaskTimeSpent1").val())+t)+e.find(".valueForDeleteTaskTimeSpent2").val();e.find(".notice-subtitle .text").text(s),e.removeClass("hidden")}})}},window.digiriskdolibarr.riskassessmenttask.saveRiskAssessmentTaskTimeSpent=function(i){var e=window.saturne.toolbox.getToken();let s=$(this);var t=$(this).attr("value"),a=$(this).closest(".riskassessment-task-timespent-edit-modal").find(".riskassessment-task-timespent-container");let n=a.attr("value"),r="",o=$(".riskassessment-task-container-"+n).attr("value"),d=$(".id-container").first().find(".riskassessment-total-task-timespent-"+n);var l=a.find("#RiskassessmentTaskTimespentDateEdit"+t).val(),c=a.find("#RiskassessmentTaskTimespentDateEdit"+t+"hour").val(),k=a.find("#RiskassessmentTaskTimespentDateEdit"+t+"min").val(),u=a.find(".riskassessment-task-timespent-comment").val(),u=window.digiriskdolibarr.risk.sanitizeBeforeRequest(u),a=a.find(".riskassessment-task-timespent-duration").val();window.saturne.loader.display($(this)),window.saturne.loader.display($(".riskassessment-task-single-"+n)),$.ajax({url:document.URL+"&action=saveRiskAssessmentTaskTimeSpent&token="+e,data:JSON.stringify({riskAssessmentTaskTimeSpentID:t,taskID:n,date:l,hour:c,min:k,comment:u,duration:a}),type:"POST",processData:!1,contentType:!1,success:function(i){s.closest(".modal-active").removeClass("modal-active");var e=$(".messageSuccessTaskTimeSpentEdit"+n);$(".wpeo-loader").removeClass("wpeo-loader"),r=(r=(r+=e.find(".valueForEditTaskTimeSpent1").val())+o)+e.find(".valueForEditTaskTimeSpent2").val(),d.html($(i).find(".modal-content").find(".riskassessment-total-task-timespent-"+n).first()),$(".riskassessment-task-timespent-list-"+n).html($(i).find(".riskassessment-task-timespent-list-"+n).children()),e.find(".notice-subtitle .text").text(r),e.removeClass("hidden")},error:function(i){var e=$(".messageSuccessTaskTimeSpentEdit"+n);r=(r=(r+=e.find(".valueForEditTaskTimeSpent1").val())+o)+e.find(".valueForEditTaskTimeSpent2").val(),e.find(".notice-subtitle .text").text(r),e.removeClass("hidden")}})},window.digiriskdolibarr.riskassessmenttask.checkTaskProgress=function(i){var e=window.saturne.toolbox.getToken(),s=$(this).closest(".riskassessment-task-container"),t=s.find(".riskassessment-task-single-content").attr("value");let a=$(this).closest(".riskassessment-tasks").attr("value"),n="",r=s.attr("value"),o="";s.find(".riskassessment-task-progress-checkbox"+t).hasClass("progress-checkbox-check")?(o=0,s.find(".riskassessment-task-progress-checkbox"+t).toggleClass("progress-checkbox-check").toggleClass("progress-checkbox-uncheck")):s.find(".riskassessment-task-progress-checkbox"+t).hasClass("progress-checkbox-uncheck")&&(o=1,s.find(".riskassessment-task-progress-checkbox"+t).toggleClass("progress-checkbox-uncheck").toggleClass("progress-checkbox-check")),window.saturne.loader.display($(".riskassessment-task-single-"+t));s=window.location.href.replace(/#.*/,"");$.ajax({url:s+"&action=checkTaskProgress&token="+e,data:JSON.stringify({riskAssessmentTaskID:t,taskProgress:o}),type:"POST",processData:!1,contentType:!1,success:function(i){$(".fichecenter.risklist").html($(i).find("#searchFormListRisks"));i=$(".messageSuccessTaskEdit");$(".riskassessment-tasks"+a).fadeOut(800),$(".riskassessment-tasks"+a).fadeIn(800),n=(n=(n+=i.find(".valueForEditTask1").val())+r)+i.find(".valueForEditTask2").val(),i.find(".notice-subtitle .text").text(n),i.removeClass("hidden")},error:function(i){var e=$(".messageErrorTaskEdit");n=(n=(n+=e.find(".valueForEditTask1").val())+r)+e.find(".valueForEditTask2").val(),e.find(".notice-subtitle .text").text(n),e.removeClass("hidden")}})},window.digiriskdolibarr.riskassessmenttask.selectRiskassessmentTaskTimespentDateHour=function(i){$(this).closest(".nowraponall").find(".select-riskassessmenttask-timespent-datehour").remove(),$(this).before('{$("#sendFileForm").load(document.URL+n+"ticket_id="+a+" #fileLinkedTable")})},window.digiriskdolibarr.ticket.removeFile=function(i){let e=$(this).attr("value");e=e.replace("_mini","");var s=$("#ticket_id").val(),t=window.saturne.toolbox.getQuerySeparator(document.URL);fetch(document.URL+t+"action=removefile&filetodelete="+e+"&ticket_id="+s,{method:"POST"}).then(i=>{$(this).parent().parent().hide()})},window.digiriskdolibarr.ticket.addDashBoardTicketInfo=function(){var i=window.saturne.toolbox.getToken(),e=$("#select2-boxcombo-container").attr("title"),s=e.split(" : ")[0],e=e.split(" : ")[2],t=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+t+"action=adddashboardinfo&token="+i,type:"POST",processData:!1,data:JSON.stringify({digiriskelementID:s,catID:e}),contentType:!1,success:function(i){window.location.reload()},error:function(){}})},window.digiriskdolibarr.ticket.closeDashBoardTicketInfo=function(){var i=window.saturne.toolbox.getToken();let e=$(this);var s=e.attr("data-digiriskelementid"),t=e.attr("data-catid"),a=window.saturne.toolbox.getQuerySeparator(document.URL);$.ajax({url:document.URL+a+"action=closedashboardinfo&token="+i,type:"POST",processData:!1,data:JSON.stringify({digiriskelementID:s,catID:t}),contentType:!1,success:function(i){e.closest(".box-flex-item").fadeOut(400),$(".add-widget-box").attr("style",""),$(".add-widget-box").html($(i).find(".add-widget-box").children())},error:function(){}})},window.digiriskdolibarr.ticket.checkValidEmail=function(){0==/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(this.value)?$(this).css("border","3px solid red"):$(this).css("border","3px solid green")},window.digiriskdolibarr.ticket.checkValidPhone=function(){0==/^(?:(?:(?:\+|00)\d{2}[\s]?(?:\(0\)[\s]?)?)|0){1}[1-9]{1}([\s.-]?)(?:\d{2}\1?){3}\d{2}$/.test(this.value)?$(this).css("border","3px solid red"):$(this).css("border","3px solid green")},window.digiriskdolibarr.digiriskusers={},window.digiriskdolibarr.digiriskusers.init=function(){window.digiriskdolibarr.digiriskusers.event()},window.digiriskdolibarr.digiriskusers.event=function(){$(document).on("input",".digirisk-users #firstname",window.digiriskdolibarr.digiriskusers.fillEmail),$(document).on("input",".digirisk-users #lastname",window.digiriskdolibarr.digiriskusers.fillEmail)},window.digiriskdolibarr.digiriskusers.fillEmail=function(i){var e=$(".digirisk-users #firstname").val(),s=$(".digirisk-users #lastname").val(),t=$(".input-domain-mail").val(),e=window.digiriskdolibarr.digiriskusers.removeDiacritics(e+"."+s+"@"+t).toLowerCase();$(".digirisk-users #email").val(e)},window.digiriskdolibarr.digiriskusers.removeDiacritics=function(i){for(var e="",s=i.normalize("NFD"),t=0,a=0;ttrans("Events"); + $head[$h][2] = 'event'; + $h++; + $head[$h][0] = dol_buildpath("/saturne/admin/documents.php?module_name=DigiriskDolibarr", 1); $head[$h][1] = ' ' . $langs->trans("YourDocuments"); $head[$h][2] = 'documents'; diff --git a/sql/data.sql b/sql/data.sql index f53590e6c..731fb1fc7 100644 --- a/sql/data.sql +++ b/sql/data.sql @@ -890,7 +890,6 @@ INSERT INTO `llx_c_firepermit_attendants_role` (`rowid`, `entity`, `ref`, `label INSERT INTO `llx_c_firepermit_attendants_role` (`rowid`, `entity`, `ref`, `label`, `description`, `active`, `position`) VALUES(2, 0, 'ExtSocietyResponsible', 'ExtSocietyResponsible', '', 1, 10); INSERT INTO `llx_c_firepermit_attendants_role` (`rowid`, `entity`, `ref`, `label`, `description`, `active`, `position`) VALUES(3, 0, 'ExtSocietyAttendant', 'ExtSocietyAttendant', '', 1, 20); --- 9.13.0 INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('accidentinvestigation@digiriskdolibarr', 'ACCIDENTINVESTIGATION_CREATE', 'AccidentInvestigationCreated', 'Executed when an accident investigation is created'); INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('accidentinvestigation@digiriskdolibarr', 'ACCIDENTINVESTIGATION_MODIFY', 'AccidentInvestigationModified', 'Executed when an accident investigation is modified'); INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('accidentinvestigation@digiriskdolibarr', 'ACCIDENTINVESTIGATION_DELETE', 'AccidentInvestigationDeleted', 'Executed when an accident investigation is deleted'); @@ -898,6 +897,10 @@ INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, desc INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('accidentinvestigation@digiriskdolibarr', 'ACCIDENTINVESTIGATION_UNVALIDATE', 'AccidentInvestigationUnValidate', 'Executed when an accident investigation is re-opened'); INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('accidentinvestigation@digiriskdolibarr', 'ACCIDENTINVESTIGATION_ARCHIVE', 'AccidentInvestigationArchive', 'Executed when an accident investigation is archived'); INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('accidentinvestigation@digiriskdolibarr', 'ACCIDENTINVESTIGATION_LOCK', 'AccidentInvestigationLock', 'Executed when an accident investigation is signed'); +INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('risk@digiriskdolibarr', 'RISK_IMPORT', 'RiskImport', 'Executed when a risk is imported'); +INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('risk@digiriskdolibarr', 'RISK_UNLINK', 'RiskUnlink', 'Executed when a risk is unlinked'); +INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('risk@digiriskdolibarr', 'RISKSIGN_IMPORT', 'RiskSignImport', 'Executed when a risk sign is imported'); +INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('risk@digiriskdolibarr', 'RISKSIGN_UNLINK', 'RiskSignUnlink', 'Executed when a risk sign is unlinked'); INSERT INTO `llx_c_accidentinvestigation_attendants_role` (`rowid`, `entity`, `ref`, `label`, `description`, `active`, `position`) VALUES(1, 0, 'Witness', 'Witness', '', 1, 1); INSERT INTO `llx_c_accidentinvestigation_attendants_role` (`rowid`, `entity`, `ref`, `label`, `description`, `active`, `position`) VALUES(2, 0, 'Investigator', 'Investigator', '', 1, 10); diff --git a/view/digiriskelement/digiriskelement_card.php b/view/digiriskelement/digiriskelement_card.php index f0be61868..5313b37fa 100644 --- a/view/digiriskelement/digiriskelement_card.php +++ b/view/digiriskelement/digiriskelement_card.php @@ -131,10 +131,8 @@ if ($action == 'view' && $permissiontoadd) { header('Location: ' . $backtopage); } - $object->element = $object->element_type; // Actions builddoc, forcebuilddoc, remove_file. require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; - $object->element = 'digiriskelement'; // Action to generate pdf from odt file require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; diff --git a/view/digiriskelement/digiriskelement_listingrisksaction.php b/view/digiriskelement/digiriskelement_listingrisksaction.php index 7dfd4d442..32e618f2e 100644 --- a/view/digiriskelement/digiriskelement_listingrisksaction.php +++ b/view/digiriskelement/digiriskelement_listingrisksaction.php @@ -82,12 +82,9 @@ if (empty($reshook)) { $error = 0; - - $previousElement = $object->element; if ($object->element == 'digiriskstandard') { $object->ref = ''; } - $object->element = 'listingrisksaction'; $removeDocumentFromName = 1; // Actions builddoc, forcebuilddoc, remove_file. @@ -95,7 +92,6 @@ // Action to generate pdf from odt file require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; - $object->element = $previousElement; } /* diff --git a/view/digiriskelement/digiriskelement_listingrisksphoto.php b/view/digiriskelement/digiriskelement_listingrisksphoto.php index 2fbdbfd6f..354318d3c 100644 --- a/view/digiriskelement/digiriskelement_listingrisksphoto.php +++ b/view/digiriskelement/digiriskelement_listingrisksphoto.php @@ -82,12 +82,9 @@ if (empty($reshook)) { $error = 0; - - $previousElement = $object->element; - if ($object->element == 'digiriskstandard') { - $object->ref = ''; - } - $object->element = 'listingrisksphoto'; + if ($object->element == 'digiriskstandard') { + $object->ref = ''; + } $removeDocumentFromName = 1; // Actions builddoc, forcebuilddoc, remove_file. @@ -95,8 +92,6 @@ // Action to generate pdf from odt file require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; - $object->element = $previousElement; - } /* diff --git a/view/digiriskstandard/digiriskstandard_informationssharing.php b/view/digiriskstandard/digiriskstandard_informationssharing.php index 9496dbaf5..31a68058c 100644 --- a/view/digiriskstandard/digiriskstandard_informationssharing.php +++ b/view/digiriskstandard/digiriskstandard_informationssharing.php @@ -77,17 +77,14 @@ if (empty($reshook)) { $error = 0; + $object->ref = ''; + $removeDocumentFromName = 1; - $previousElement = $object->element; - $object->ref = ''; - $object->element = 'informationssharing'; - $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->element = $previousElement; } /* diff --git a/view/digiriskstandard/digiriskstandard_legaldisplay.php b/view/digiriskstandard/digiriskstandard_legaldisplay.php index 7a10ac8a4..a28bf546a 100644 --- a/view/digiriskstandard/digiriskstandard_legaldisplay.php +++ b/view/digiriskstandard/digiriskstandard_legaldisplay.php @@ -80,10 +80,7 @@ if (empty($reshook)) { $error = 0; - - $previousElement = $object->element; $object->ref = ''; - $object->element = 'legaldisplay'; $removeDocumentFromName = 1; // Actions builddoc, forcebuilddoc, remove_file. @@ -91,7 +88,6 @@ // Action to generate pdf from odt file require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; - $object->element = $previousElement; } /* diff --git a/view/digiriskstandard/digiriskstandard_riskassessmentdocument.php b/view/digiriskstandard/digiriskstandard_riskassessmentdocument.php index 2e1ea5610..91931709b 100644 --- a/view/digiriskstandard/digiriskstandard_riskassessmentdocument.php +++ b/view/digiriskstandard/digiriskstandard_riskassessmentdocument.php @@ -141,8 +141,9 @@ } if ( ! $error) { - $filedir = $upload_dir . '/riskassessmentdocument/'; - if ( ! empty($filedir)) { + $filedir = $upload_dir . '/riskassessmentdocument/siteplans/'; + array_map('unlink', array_filter((array) glob($filedir . '*'))); + if ( ! empty($filedir)) { $result = digirisk_dol_add_file_process($filedir, 0, 1, 'userfile', '', null, '', 1, $object); } }