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 444b5e3e8..415eed8bc 100644 --- a/class/accident.class.php +++ b/class/accident.class.php @@ -653,6 +653,58 @@ public function getGravityRate() { 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; + + 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; + } + /** * Get more html ref on object. * @param int $id Id of the accident to retrieve the info from @@ -768,6 +820,25 @@ 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('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; + } } /** @@ -1022,4 +1093,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/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 975f06e05..58ab3f1be 100644 --- a/core/modules/modDigiriskDolibarr.class.php +++ b/core/modules/modDigiriskDolibarr.class.php @@ -482,86 +482,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'], @@ -578,12 +578,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'], @@ -600,17 +600,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'], @@ -621,16 +621,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'], @@ -656,7 +658,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'], @@ -802,13 +806,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'], @@ -846,7 +843,8 @@ public function __construct($db) $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_ACCIDENT_INVESTIGATION_VALIDATE', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_ACCIDENT_INVESTIGATION_UNVALIDATE', 'integer', 1, '', 0, 'current'], $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_ACCIDENT_INVESTIGATION_ARCHIVE', 'integer', 1, '', 0, 'current'], - $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_ACCIDENT_INVESTIGATION_LOCK', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_ACCIDENT_INVESTIGATION_LOCK', 'integer', 1, '', 0, 'current'], + $i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_ACCIDENT_INVESTIGATION_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/triggers/interface_99_modDigiriskdolibarr_DigiriskdolibarrTriggers.class.php b/core/triggers/interface_99_modDigiriskdolibarr_DigiriskdolibarrTriggers.class.php index e617a12c7..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' : @@ -425,474 +243,143 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $actioncomm->elementtype = 'digiriskelement@digiriskdolibarr'; $actioncomm->elementid = $object->id; - $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->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 @@ -1041,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; @@ -1178,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); } @@ -1215,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); } @@ -1251,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); @@ -1268,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; @@ -1299,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; @@ -1331,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; @@ -1781,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; @@ -1798,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; @@ -1816,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/lib/digiriskdolibarr.lib.php b/lib/digiriskdolibarr.lib.php index 268d8616a..2b168b6e4 100644 --- a/lib/digiriskdolibarr.lib.php +++ b/lib/digiriskdolibarr.lib.php @@ -65,6 +65,11 @@ function digiriskdolibarr_admin_prepare_head() $head[$h][2] = 'ticket'; $h++; + $head[$h][0] = dol_buildpath("/digiriskdolibarr/admin/event.php", 1); + $head[$h][1] = ' ' . $langs->trans("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 5cd7b2d0f..b9157c1ab 100644 --- a/sql/data.sql +++ b/sql/data.sql @@ -901,4 +901,9 @@ INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, desc INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('accident_investigation@digiriskdolibarr', 'ACCIDENT_INVESTIGATION_UNVALIDATE', 'AccidentInvestigationUnValidate', 'Executed when an accident investigation is re-opened'); INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('accident_investigation@digiriskdolibarr', 'ACCIDENT_INVESTIGATION_ARCHIVE', 'AccidentInvestigationArchive', 'Executed when an accident investigation is archived'); INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('accident_investigation@digiriskdolibarr', 'ACCIDENT_INVESTIGATION_LOCK', 'AccidentInvestigationLock', 'Executed when an accident investigation is signed'); +INSERT INTO llx_c_digiriskdolibarr_action_trigger (elementtype, ref, label, description) VALUES ('accident_investigation@digiriskdolibarr', 'ACCIDENT_INVESTIGATION_SENTBYMAIL', 'AccidentInvestigationSentByMail', 'Executed when an accident investigation is sent by mail'); +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'); 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; } /*