From 6d5770cd879c4b6dcf740aec3d959f252f7737ff Mon Sep 17 00:00:00 2001 From: evarisk-francois Date: Tue, 14 May 2024 16:39:18 +0200 Subject: [PATCH 01/25] #3791 [Configuration] fix: use object element instead of type --- admin/config/firepermit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/config/firepermit.php b/admin/config/firepermit.php index 5976f9be8..f46b2df1a 100644 --- a/admin/config/firepermit.php +++ b/admin/config/firepermit.php @@ -85,7 +85,7 @@ $masterWorkerId = GETPOST('maitre_oeuvre'); if ( ! $error) { - $constforval = 'DIGIRISKDOLIBARR_' . strtoupper($type) . "_MAITRE_OEUVRE"; + $constforval = 'DIGIRISKDOLIBARR_' . strtoupper($object->element) . "_MAITRE_OEUVRE"; dolibarr_set_const($db, $constforval, $masterWorkerId, 'integer', 0, '', $conf->entity); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } From 231f13f1466fc2b72abfc08f9621444d7fd85378 Mon Sep 17 00:00:00 2001 From: evarisk-francois Date: Tue, 14 May 2024 16:56:38 +0200 Subject: [PATCH 02/25] #3791 [Configuration] fix: type > object element in preventionplan --- admin/config/preventionplan.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/config/preventionplan.php b/admin/config/preventionplan.php index 350099116..9b5daeb32 100644 --- a/admin/config/preventionplan.php +++ b/admin/config/preventionplan.php @@ -86,7 +86,7 @@ $masterWorkerId = GETPOST('maitre_oeuvre'); if ( ! $error) { - $constForVal = 'DIGIRISKDOLIBARR_' . strtoupper($type) . "_MAITRE_OEUVRE"; + $constForVal = 'DIGIRISKDOLIBARR_' . strtoupper($object->element) . "_MAITRE_OEUVRE"; dolibarr_set_const($db, $constForVal, $masterWorkerId, 'integer', 0, '', $conf->entity); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } From f47c64c4b829ec73fb2d5d1fcb497a721671ac92 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Thu, 16 May 2024 03:45:28 +0200 Subject: [PATCH 03/25] #3624 [AccidentInvestigation] fix: transnoentities mandatory for insert SQL --- view/accidentinvestigation/accidentinvestigation_card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/view/accidentinvestigation/accidentinvestigation_card.php b/view/accidentinvestigation/accidentinvestigation_card.php index 10b5e544c..939013f79 100644 --- a/view/accidentinvestigation/accidentinvestigation_card.php +++ b/view/accidentinvestigation/accidentinvestigation_card.php @@ -153,14 +153,14 @@ $task->fk_project = $accident->fk_project; $task->ref = $modTask->getNextValue(0, $task); - $task->label = $accident->ref . ' - T1 - ' . $langs->trans('CurativeAction'); + $task->label = $accident->ref . ' - T1 - ' . $langs->transnoentities('CurativeAction'); $task->fk_task_parent = $result; $resOne = $task->create($user); $getNomResOne = $task->getNomUrl(1, '', 'task', 1); $task->fk_project = $accident->fk_project; $task->ref = $modTask->getNextValue(0, $task); - $task->label = $accident->ref . ' - T2 - ' . $langs->trans('PreventiveAction'); + $task->label = $accident->ref . ' - T2 - ' . $langs->transnoentities('PreventiveAction'); $task->fk_task_parent = $result; $resTwo = $task->create($user); $getNomResTwo = $task->getNomUrl(1, '', 'task', 1); From fdd3f842b9d383f9e8a79a91adc04787dbdcfb08 Mon Sep 17 00:00:00 2001 From: Charles Delachapelle Date: Fri, 17 May 2024 15:59:03 +0200 Subject: [PATCH 04/25] #3554 [RiskAssessment] fix: photo bug on shared risks --- .../digiriskdolibarr_riskassessment_view_single.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tpl/riskanalysis/riskassessment/digiriskdolibarr_riskassessment_view_single.tpl.php b/core/tpl/riskanalysis/riskassessment/digiriskdolibarr_riskassessment_view_single.tpl.php index e41dce1c3..8a2f9ea7e 100644 --- a/core/tpl/riskanalysis/riskassessment/digiriskdolibarr_riskassessment_view_single.tpl.php +++ b/core/tpl/riskanalysis/riskassessment/digiriskdolibarr_riskassessment_view_single.tpl.php @@ -9,7 +9,7 @@
entity > 1 ? $lastEvaluation->entity . '/' : '') . 'digiriskdolibarr/riskassessment/' . $lastEvaluation->ref, 'small', 1, 0, 0, 0, 50, 50, 0, 0, 0, '/riskassessment/' . $lastEvaluation->ref, $lastEvaluation, 'photo', 0, 0, 0, 1); + print saturne_show_medias_linked('digiriskdolibarr', DOL_DATA_ROOT . '/' . ($lastEvaluation->entity > 1 ? $lastEvaluation->entity . '/' : '') . 'digiriskdolibarr/riskassessment/' . $lastEvaluation->ref, 'small', 1, 0, 0, 0, 50, 50, 0, 0, 1, '/riskassessment/' . $lastEvaluation->ref, $lastEvaluation, 'photo', 0, 0, 0, 1); ?>
From 9b28d0ccd43b4b8aaabe524e8240dcda4492b5b8 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Tue, 21 May 2024 14:45:21 +0200 Subject: [PATCH 05/25] #3905 [Admin] fix: use global $mc instead of $conf->mc because remove in 19 --- admin/config/riskassessmentdocument.php | 10 +++++----- class/digiriskdocuments.class.php | 4 ++-- .../risk/digiriskdolibarr_risk_actions.tpl.php | 2 +- .../digiriskdolibarr_riskassessment_task_view.tpl.php | 2 +- view/digiriskelement/digiriskelement_risk.php | 2 +- view/digiriskelement/risk_list.php | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/admin/config/riskassessmentdocument.php b/admin/config/riskassessmentdocument.php index 413d402e7..a18387bb3 100644 --- a/admin/config/riskassessmentdocument.php +++ b/admin/config/riskassessmentdocument.php @@ -30,7 +30,7 @@ die('Include of digiriskdolibarr main fails'); } -global $conf, $db, $langs, $user; +global $conf, $db, $langs, $mc, $user; // Libraries require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; @@ -174,8 +174,8 @@ require __DIR__ . '/../../../saturne/core/tpl/admin/object/object_numbering_module_view.tpl.php'; -$areRisksShared = !empty($conf->mc->entities['risk']) ? strpos($conf->mc->entities['risk'], $conf->entity) : 0; -$areRisksSharable = isModEnabled('multicompany') && !empty($conf->mc->sharings['risk']) && $areRisksShared > 0; +$areRisksShared = !empty($mc->entities['risk']) ? strpos($mc->entities['risk'], $conf->entity) : 0; +$areRisksSharable = isModEnabled('multicompany') && !empty($mc->sharings['risk']) && $areRisksShared > 0; $constArray[$moduleNameLowerCase] = [ 'RiskDescription' => [ @@ -438,8 +438,8 @@ require __DIR__ . '/../../../saturne/core/tpl/admin/object/object_numbering_module_view.tpl.php'; -$areRiskSignsShared = !empty($conf->mc->entities['risksign']) ? strpos($conf->mc->entities['risksign'], $conf->entity) : 0; -$areRisksSignsSharable = isModEnabled('multicompany') && !empty($conf->mc->sharings['risksign']) && $areRiskSignsShared > 0; +$areRiskSignsShared = !empty($mc->entities['risksign']) ? strpos($mc->entities['risksign'], $conf->entity) : 0; +$areRisksSignsSharable = isModEnabled('multicompany') && !empty($mc->sharings['risksign']) && $areRiskSignsShared > 0; $constArray[$moduleNameLowerCase] = [ 'ShowInheritedRiskSigns' => [ diff --git a/class/digiriskdocuments.class.php b/class/digiriskdocuments.class.php index 624eb0cd7..8189a397b 100644 --- a/class/digiriskdocuments.class.php +++ b/class/digiriskdocuments.class.php @@ -163,7 +163,7 @@ public function info($id) */ public function fillRiskData(Odf $odfHandler, $object, Translate $outputLangs, $tmparray, $file, $risks, $allEntities = false) { - global $action, $conf, $hookmanager, $langs; + global $action, $conf, $hookmanager, $langs, $mc; $usertmp = new User($this->db); $project = new Project($this->db); @@ -249,7 +249,7 @@ public function fillRiskData(Odf $odfHandler, $object, Translate $outputLangs, $ if (!empty($conf->global->DIGIRISKDOLIBARR_SHOW_SHARED_RISKS)) { $project->fetch($related_task->fk_projet); if ($project->entity != $conf->entity) { - $result = !empty($conf->mc->sharings['project']) ? in_array($project->entity, $conf->mc->sharings['project']) : 0; + $result = !empty($mc->sharings['project']) ? in_array($project->entity, $mc->sharings['project']) : 0; } else { $result = 1; } diff --git a/core/tpl/riskanalysis/risk/digiriskdolibarr_risk_actions.tpl.php b/core/tpl/riskanalysis/risk/digiriskdolibarr_risk_actions.tpl.php index b1e07c5cc..99d1e91df 100644 --- a/core/tpl/riskanalysis/risk/digiriskdolibarr_risk_actions.tpl.php +++ b/core/tpl/riskanalysis/risk/digiriskdolibarr_risk_actions.tpl.php @@ -649,7 +649,7 @@ $digiriskelementtmp = new DigiriskElement($db); -// $AllSharingsRisks = $conf->mc->sharings['risk']; +// $AllSharingsRisks = $mc->sharings['risk']; // // foreach ($AllSharingsRisks as $Allsharingsrisk) { // $filter .= $Allsharingsrisk . ','; diff --git a/core/tpl/riskanalysis/riskassessmenttask/digiriskdolibarr_riskassessment_task_view.tpl.php b/core/tpl/riskanalysis/riskassessmenttask/digiriskdolibarr_riskassessment_task_view.tpl.php index 630f825f8..7116e3c32 100644 --- a/core/tpl/riskanalysis/riskassessmenttask/digiriskdolibarr_riskassessment_task_view.tpl.php +++ b/core/tpl/riskanalysis/riskassessmenttask/digiriskdolibarr_riskassessment_task_view.tpl.php @@ -18,7 +18,7 @@ } else { $project = $DUProject; } - $result = !empty($conf->mc->sharings['project']) ? in_array($project->entity, $conf->mc->sharings['project']) : 0; + $result = !empty($mc->sharings['project']) ? in_array($project->entity, $mc->sharings['project']) : 0; } else { $result = 1; } diff --git a/view/digiriskelement/digiriskelement_risk.php b/view/digiriskelement/digiriskelement_risk.php index c15266e08..7ec83465e 100644 --- a/view/digiriskelement/digiriskelement_risk.php +++ b/view/digiriskelement/digiriskelement_risk.php @@ -30,7 +30,7 @@ die('Include of digiriskdolibarr main fails'); } -global $conf, $db, $hookmanager, $langs, $user; +global $conf, $db, $hookmanager, $langs, $mc, $user; // Load Dolibarr libraries require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; diff --git a/view/digiriskelement/risk_list.php b/view/digiriskelement/risk_list.php index 666d4652e..20f80dae0 100644 --- a/view/digiriskelement/risk_list.php +++ b/view/digiriskelement/risk_list.php @@ -30,7 +30,7 @@ die('Include of digiriskdolibarr main fails'); } -global $langs, $user, $conf, $db, $hookmanager; +global $conf, $db, $hookmanager, $langs, $mc, $user; // Load Dolibarr libraries From 6eaa8909d1986b37ba08f9b2cda220b1212d9cb6 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Tue, 21 May 2024 15:51:36 +0200 Subject: [PATCH 06/25] #3903 [Admin] fix: init conf on if/elseif dont reset or use previous value --- core/modules/modDigiriskDolibarr.class.php | 316 ++++++++------------- 1 file changed, 118 insertions(+), 198 deletions(-) diff --git a/core/modules/modDigiriskDolibarr.class.php b/core/modules/modDigiriskDolibarr.class.php index a3f8c137b..982fe1548 100644 --- a/core/modules/modDigiriskDolibarr.class.php +++ b/core/modules/modDigiriskDolibarr.class.php @@ -2030,140 +2030,81 @@ public function init($options = '') dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_ACTIVE_STANDARD', $standard_id, 'integer', 0, '', $conf->entity); } - if ( $conf->global->DIGIRISKDOLIBARR_THIRDPARTY_SET == 0 ) { - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; - require_once __DIR__ . '/../../class/digiriskresources.class.php'; - - $societe = new Societe($this->db); - $resources = new DigiriskResources($this->db); - - $labour_doctor = $societe; - $labour_doctor->name = $langs->trans('LabourDoctorName') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $labour_doctor->client = 0; - $labour_doctor->phone = ''; - $labour_doctor->url = ''; - $labour_doctorID = $labour_doctor->create($user); - - $labour_inspector = $societe; - $labour_inspector->name = $langs->trans('LabourInspectorName') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $labour_inspector->client = 0; - $labour_inspector->phone = ''; - $labour_inspector->url = $langs->trans('UrlLabourInspector'); - $labour_inspectorID = $labour_inspector->create($user); - - $samu = $societe; - $samu->name = $langs->trans('SAMU') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $samu->client = 0; - $samu->phone = '15'; - $samu->url = ''; - $samuID = $samu->create($user); - - $pompiers = $societe; - $pompiers->name = $langs->trans('Pompiers') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $pompiers->client = 0; - $pompiers->phone = '18'; - $pompiers->url = ''; - $pompiersID = $pompiers->create($user); - - $police = $societe; - $police->name = $langs->trans('Police') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $police->client = 0; - $police->phone = '17'; - $police->url = ''; - $policeID = $police->create($user); - - $emergency = $societe; - $emergency->name = $langs->trans('AllEmergencies') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $emergency->client = 0; - $emergency->phone = '112'; - $emergency->url = ''; - $emergencyID = $emergency->create($user); - - $rights_defender = $societe; - $rights_defender->name = $langs->trans('RightsDefender') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $rights_defender->client = 0; - $rights_defender->phone = ''; - $rights_defender->url = ''; - $rights_defenderID = $rights_defender->create($user); - - $poison_control_center = $societe; - $poison_control_center->name = $langs->trans('PoisonControlCenter') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $poison_control_center->client = 0; - $poison_control_center->phone = ''; - $poison_control_center->url = ''; - $poison_control_centerID = $poison_control_center->create($user); - - $resources->setDigiriskResources($this->db, 1, 'LabourDoctorSociety', 'societe', [$labour_doctorID], $conf->entity); - $resources->setDigiriskResources($this->db, 1, 'LabourInspectorSociety', 'societe', [$labour_inspectorID], $conf->entity); - $resources->setDigiriskResources($this->db, 1, 'Police', 'societe', [$policeID], $conf->entity); - $resources->setDigiriskResources($this->db, 1, 'SAMU', 'societe', [$samuID], $conf->entity); - $resources->setDigiriskResources($this->db, 1, 'Pompiers', 'societe', [$pompiersID], $conf->entity); - $resources->setDigiriskResources($this->db, 1, 'AllEmergencies', 'societe', [$emergencyID], $conf->entity); - $resources->setDigiriskResources($this->db, 1, 'RightsDefender', 'societe', [$rights_defenderID], $conf->entity); - $resources->setDigiriskResources($this->db, 1, 'PoisonControlCenter', 'societe', [$poison_control_centerID], $conf->entity); - - dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_THIRDPARTY_SET', 3, 'integer', 0, '', $conf->entity); - } elseif ($conf->global->DIGIRISKDOLIBARR_THIRDPARTY_SET == 1) { - //Install after 8.1.2 - - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; - require_once __DIR__ . '/../../class/digiriskresources.class.php'; - - $societe = new Societe($this->db); - $resources = new DigiriskResources($this->db); - - $labour_doctor = $societe; - $labour_doctor->name = $langs->trans('LabourDoctorName') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $labour_doctor->client = 0; - $labour_doctor->phone = ''; - $labour_doctor->url = ''; - $labour_doctorID = $labour_doctor->create($user); - - $labour_inspector = $societe; - $labour_inspector->name = $langs->trans('LabourInspectorName') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $labour_inspector->client = 0; - $labour_inspector->phone = ''; - $labour_inspector->url = $langs->trans('UrlLabourInspector'); - $labour_inspectorID = $labour_inspector->create($user); - - $rights_defender = $societe; - $rights_defender->name = $langs->transnoentities('RightsDefender') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $rights_defender->client = 0; - $rights_defender->phone = ''; - $rights_defender->url = ''; - $rights_defenderID = $rights_defender->create($user); - - $poison_control_center = $societe; - $poison_control_center->name = $langs->trans('PoisonControlCenter') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $poison_control_center->client = 0; - $poison_control_center->phone = ''; - $poison_control_center->url = ''; - $poison_control_centerID = $poison_control_center->create($user); - - $resources->setDigiriskResources($this->db, 1, 'LabourDoctorSociety', 'societe', [$labour_doctorID], $conf->entity); - $resources->setDigiriskResources($this->db, 1, 'LabourInspectorSociety', 'societe', [$labour_inspectorID], $conf->entity); - $resources->setDigiriskResources($this->db, 1, 'RightsDefender', 'societe', [$rights_defenderID], $conf->entity); - $resources->setDigiriskResources($this->db, 1, 'PoisonControlCenter', 'societe', [$poison_control_centerID], $conf->entity); - - dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_THIRDPARTY_SET', 3, 'integer', 0, '', $conf->entity); - } elseif ($conf->global->DIGIRISKDOLIBARR_THIRDPARTY_SET == 2) { - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; - require_once __DIR__ . '/../../class/digiriskresources.class.php'; - - $societe = new Societe($this->db); - $resources = new DigiriskResources($this->db); - - $labour_doctor = $societe; - $labour_doctor->name = $langs->trans('LabourDoctorName') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; - $labour_doctor->client = 0; - $labour_doctor->phone = ''; - $labour_doctor->url = ''; - $labour_doctorID = $labour_doctor->create($user); + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; + require_once __DIR__ . '/../../class/digiriskresources.class.php'; + + $societe = new Societe($this->db); + $resources = new DigiriskResources($this->db); + + if (getDolGlobalInt('DIGIRISKDOLIBARR_THIRDPARTY_SET') == 0) { + $societe->name = $langs->trans('SAMU') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; + $societe->client = 0; + $societe->phone = '15'; + $societe->url = ''; + $samuID = $societe->create($user); + + $societe->name = $langs->trans('Pompiers') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; + $societe->client = 0; + $societe->phone = '18'; + $societe->url = ''; + $pompiersID = $societe->create($user); + + $societe->name = $langs->trans('Police') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; + $societe->client = 0; + $societe->phone = '17'; + $societe->url = ''; + $policeID = $societe->create($user); + + $societe->name = $langs->trans('AllEmergencies') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; + $societe->client = 0; + $societe->phone = '112'; + $societe->url = ''; + $emergencyID = $societe->create($user); + + $resources->setDigiriskResources($this->db, 1, 'Police', 'societe', [$policeID], $conf->entity); + $resources->setDigiriskResources($this->db, 1, 'SAMU', 'societe', [$samuID], $conf->entity); + $resources->setDigiriskResources($this->db, 1, 'Pompiers', 'societe', [$pompiersID], $conf->entity); + $resources->setDigiriskResources($this->db, 1, 'AllEmergencies', 'societe', [$emergencyID], $conf->entity); + + dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_THIRDPARTY_SET', 1, 'integer', 0, '', $conf->entity); + } + if (getDolGlobalInt('DIGIRISKDOLIBARR_THIRDPARTY_SET') == 1) { + //Install after 8.1.2 + $societe->name = $langs->trans('LabourInspectorName') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; + $societe->client = 0; + $societe->phone = ''; + $societe->url = $langs->trans('UrlLabourInspector'); + $labourInspectorID = $societe->create($user); + + $societe->name = $langs->trans('RightsDefender') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; + $societe->client = 0; + $societe->phone = ''; + $societe->url = ''; + $rightsDefenderID = $societe->create($user); + + $societe->name = $langs->trans('PoisonControlCenter') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; + $societe->client = 0; + $societe->phone = ''; + $societe->url = ''; + $poisonControlCenterID = $societe->create($user); + + $resources->setDigiriskResources($this->db, 1, 'LabourInspectorSociety', 'societe', [$labourInspectorID], $conf->entity); + $resources->setDigiriskResources($this->db, 1, 'RightsDefender', 'societe', [$rightsDefenderID], $conf->entity); + $resources->setDigiriskResources($this->db, 1, 'PoisonControlCenter', 'societe', [$poisonControlCenterID], $conf->entity); + + dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_THIRDPARTY_SET', 2, 'integer', 0, '', $conf->entity); + } + if (getDolGlobalInt('DIGIRISKDOLIBARR_THIRDPARTY_SET') == 2) { + $societe->name = $langs->trans('LabourDoctorName') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM; + $societe->client = 0; + $societe->phone = ''; + $societe->url = ''; + $labourDoctorID = $societe->create($user); - $resources->setDigiriskResources($this->db, 1, 'LabourDoctorSociety', 'societe', [$labour_doctorID], $conf->entity); + $resources->setDigiriskResources($this->db, 1, 'LabourDoctorSociety', 'societe', [$labourDoctorID], $conf->entity); - dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_THIRDPARTY_SET', 3, 'integer', 0, '', $conf->entity); - } + dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_THIRDPARTY_SET', 3, 'integer', 0, '', $conf->entity); + } if (getDolGlobalInt('DIGIRISKDOLIBARR_CONTACTS_SET') == 0) { require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; @@ -2330,78 +2271,56 @@ public function init($options = '') dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_DIGIRISKELEMENT_MEDIAS_BACKWARD_COMPATIBILITY', 1, 'integer', 0, '', $conf->entity); } - //Categorie - if ($conf->global->DIGIRISKDOLIBARR_PROJECT_TAGS_SET == 0) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - - $tags = new Categorie($this->db); - - $tags->label = 'QHSE'; - $tags->type = 'project'; - $tag_id = $tags->create($user); - - $tags->label = 'DU'; - $tags->type = 'project'; - $tags->fk_parent = $tag_id; - $tags->create($user); - - $tags->label = 'PP'; - $tags->type = 'project'; - $tags->fk_parent = $tag_id; - $tags->create($user); + //Categorie + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $tags->label = 'FP'; - $tags->type = 'project'; - $tags->fk_parent = $tag_id; - $tags->create($user); + $tags = new Categorie($this->db); - $tags->label = 'ACC'; - $tags->type = 'project'; - $tags->fk_parent = $tag_id; - $tags->create($user); + if (getDolGlobalInt('DIGIRISKDOLIBARR_PROJECT_TAGS_SET') == 0) { + $tags->label = 'QHSE'; + $tags->type = 'project'; + $tagID = $tags->create($user); - $tags->label = 'TS'; - $tags->type = 'project'; - $tags->fk_parent = $tag_id; - $tags->create($user); - - dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_PROJECT_TAGS_SET', 3, 'integer', 0, '', $conf->entity); - } elseif ($conf->global->DIGIRISKDOLIBARR_PROJECT_TAGS_SET == 1) { - //Install after 8.3.0 - - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - - $tags = new Categorie($this->db); - - $tags->fetch('', 'QHSE'); + $tags->label = 'DU'; + $tags->type = 'project'; + $tags->fk_parent = $tagID; + $tags->create($user); - $tags->label = 'FP'; - $tags->type = 'project'; - $tags->fk_parent = $tags->id; - $tags->create($user); + $tags->label = 'PP'; + $tags->type = 'project'; + $tags->fk_parent = $tagID; + $tags->create($user); - dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_PROJECT_TAGS_SET', 2, 'integer', 0, '', $conf->entity); - } elseif ($conf->global->DIGIRISKDOLIBARR_PROJECT_TAGS_SET == 2) { - //Install after 9.3.0 + $tags->label = 'ACC'; + $tags->type = 'project'; + $tags->fk_parent = $tagID; + $tags->create($user); - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_PROJECT_TAGS_SET', 3, 'integer', 0, '', $conf->entity); + } + if (getDolGlobalInt('DIGIRISKDOLIBARR_PROJECT_TAGS_SET') == 1) { + //Install after 8.3.0 + $tags->fetch('', 'QHSE'); - $tags = new Categorie($this->db); + $tags->label = 'FP'; + $tags->type = 'project'; + $tags->fk_parent = $tags->id; + $tags->create($user); - $tags->fetch('', 'QHSE'); - $tags->label = 'TS'; - $tags->type = 'project'; - $tags->fk_parent = $tags->id; - $tags->create($user); + dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_PROJECT_TAGS_SET', 2, 'integer', 0, '', $conf->entity); + } + if (getDolGlobalInt('DIGIRISKDOLIBARR_PROJECT_TAGS_SET') == 2) { + //Install after 9.3.0 + $tags->fetch('', 'QHSE'); + $tags->label = 'TS'; + $tags->type = 'project'; + $tags->fk_parent = $tags->id; + $tags->create($user); - dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_PROJECT_TAGS_SET', 3, 'integer', 0, '', $conf->entity); - } elseif ($conf->global->DIGIRISKDOLIBARR_PROJECT_TAGS_SET == 3) { + dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_PROJECT_TAGS_SET', 3, 'integer', 0, '', $conf->entity); + } + if (getDolGlobalInt('DIGIRISKDOLIBARR_PROJECT_TAGS_SET') == 3) { //Install after 10.0.0 - - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - - $tags = new Categorie($this->db); - $tags->fetch('', 'QHSE'); $tags->label = 'ENV'; $tags->type = 'project'; @@ -2531,7 +2450,8 @@ public function init($options = '') dolibarr_set_const($this->db, "MULTICOMPANY_EXTERNAL_MODULES_SHARING", $jsonformat, 'json', 0, '', 0); // BACKWARD NUM REF - if ($conf->global->DIGIRISKDOLIBARR_CUSTOM_NUM_REF_SET == 0) { + $objectTypeAndMod = []; + if (getDolGlobalInt('DIGIRISKDOLIBARR_CUSTOM_NUM_REF_SET') == 0) { $objectTypeAndMod = [ 'Risk' => ['tarqeq', 'RK{0}'], 'RiskAssessment' => ['jarnsaxa', 'RA{0}'], @@ -2564,15 +2484,15 @@ public function init($options = '') ]; dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_CUSTOM_NUM_REF_SET', 1, 'integer', 0, '', $conf->entity); - } else if ($conf->global->DIGIRISKDOLIBARR_CUSTOM_NUM_REF_SET > 0 || $conf->global->DIGIRISKDOLIBARR_CUSTOM_NUM_REF_SET < 3) { + } + if (getDolGlobalInt('DIGIRISKDOLIBARR_CUSTOM_NUM_REF_SET') > 0 || getDolGlobalInt('DIGIRISKDOLIBARR_CUSTOM_NUM_REF_SET') < 3) { $objectTypeAndMod['RegisterDocument'] = ['thiazzi', 'RD{0}']; $objectTypeAndMod['ListingRisksDocument'] = ['calypso', 'RLD{0}']; $objectTypeAndMod['AuditReportDocument'] = ['lindberg', 'ARD{0}']; $objectTypeAndMod['ListingRisksEnvironmentalAction'] = ['jocaste', 'RLE{0}']; dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_CUSTOM_NUM_REF_SET', 3, 'integer', 0, '', $conf->entity); } - - if ($conf->global->DIGIRISKDOLIBARR_CUSTOM_NUM_REF_SET >= 0) { + if (getDolGlobalInt('DIGIRISKDOLIBARR_CUSTOM_NUM_REF_SET') >= 0) { foreach($objectTypeAndMod as $type => $mod) { $confNumRef = 'DIGIRISKDOLIBARR_' . strtoupper($type) . '_' . strtoupper($mod[0]) . '_ADDON'; $confObjectRef = 'DIGIRISKDOLIBARR_' . strtoupper($type) . '_ADDON'; From 3e18709e24af3acacba15e47ed042bdd53864d81 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Tue, 21 May 2024 23:22:16 +0200 Subject: [PATCH 07/25] #3364 [ProjectDocument] fix: change hook action and use builddoc saturne --- class/actions_digiriskdolibarr.class.php | 42 +-- .../pdf_orque_projectdocument.modules.php | 279 +++++++++--------- 2 files changed, 150 insertions(+), 171 deletions(-) diff --git a/class/actions_digiriskdolibarr.class.php b/class/actions_digiriskdolibarr.class.php index ad5f1addb..82eedd5b1 100644 --- a/class/actions_digiriskdolibarr.class.php +++ b/class/actions_digiriskdolibarr.class.php @@ -596,7 +596,19 @@ public function doActions($parameters, $object, $action) } require __DIR__ . '/../../saturne/core/tpl/documents/documents_action.tpl.php'; - } elseif (in_array($parameters['currentcontext'] , array('ticketlist', 'thirdpartyticket', 'projectticket'))) { + } else if (strpos($parameters['context'], 'projectcard') !== false) { + if ($action == 'builddoc' && GETPOST('model') == 'orque_projectdocument') { + require_once __DIR__ . '/digiriskdolibarrdocuments/projectdocument.class.php'; + + $document = new ProjectDocument($this->db); + + $moduleNameLowerCase = 'digiriskdolibarr'; + $permissiontoadd = $user->rights->projet->creer; + $moreParams['modulePart'] = 'project'; + + require __DIR__ . '/../../saturne/core/tpl/documents/documents_action.tpl.php'; + } + } elseif (in_array($parameters['currentcontext'] , array('ticketlist', 'thirdpartyticket', 'projectticket'))) { if ($action == 'list') { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $searchCategoryTicketList = GETPOST('search_category_ticket_list', 'array'); @@ -849,34 +861,6 @@ public function printFieldListSearchParam($parameters, $object) } } - /** - * Overloading the commonGenerateDocument function : replacing the parent's function with the one below - * - * @param Hook $parameters Metadatas (context, etc...) - * @param object $object Current object - * @param string $action - * @return int 0 < on error, 0 on success, 1 to replace standard code - */ - public function commonGenerateDocument($parameters, $object, $action) { - global $db, $user; - - if ($parameters['currentcontext'] == 'projectcard') { - if ($parameters['modele'] == 'orque_projectdocument') { - require_once __DIR__ . '/../class/digiriskdolibarrdocuments/projectdocument.class.php'; - - $projectdocument = new ProjectDocument($db); - - $moreparams['object'] = $object; - $moreparams['user'] = $user; - $moreparams['objectType'] = 'project'; - if ($object->element == 'project') { - $projectdocument->generateDocument($parameters['modele'], $parameters['outputlangs'], $parameters['hidedetails'], $parameters['hidedesc'], $parameters['hideref'], $moreparams, true); - } - } - } - return 0; // return 0 or return 1 to replace standard code - } - /** * Overloading the saturneBannerTab function : replacing the parent's function with the one below * diff --git a/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/projectdocument/pdf_orque_projectdocument.modules.php b/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/projectdocument/pdf_orque_projectdocument.modules.php index 5e0d8554b..28bc4ecf7 100644 --- a/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/projectdocument/pdf_orque_projectdocument.modules.php +++ b/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/projectdocument/pdf_orque_projectdocument.modules.php @@ -53,11 +53,6 @@ class pdf_orque_projectdocument */ public $description; - /** - * @var int Save the name of generated file as the main doc when generating a doc with this template - */ - public $update_main_doc_field; - /** * @var string document type */ @@ -122,6 +117,16 @@ class pdf_orque_projectdocument */ public $emetteur; + /** + * @var string Module + */ + public string $module = 'digiriskdolibarr'; + + /** + * @var string Document type + */ + public string $document_type = 'orque_projectdocument'; + /** * Constructor * @@ -137,7 +142,6 @@ public function __construct($db) $this->db = $db; $this->name = 'orque'; $this->description = $langs->trans('DocumentModelOrque'); - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format $this->type = 'pdf'; @@ -201,98 +205,89 @@ public function __construct($db) } } - /** - * Function to build a document on disk using the generic pdf module. - * - * @param ProjectDocument $objectDocument Object source to build document - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @param array $moreParams Array to provide more information - * @return int 1 if OK, <=0 if KO - * @throws Exception - */ - public function write_file( SaturneDocuments $objectDocument, Translate $outputLangs, string $srcTemplatePath, int $hideDetails = 0, int $hideDesc = 0, int $hideRef = 0, array $moreParams): int - { - global $conf, $hookmanager, $langs, $user; - - $object = $moreParams['object']; - - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } - - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!empty($conf->global->MAIN_USE_FPDF)) { - $outputlangs->charset_output = 'ISO-8859-1'; - } - - // Load traductions files required by page - $outputlangs->loadLangs(array('main', 'dict', 'companies', 'projects')); - - if ($conf->projet->dir_output) { - // Load numbering modules - $numberingModules = [ - 'digiriskdolibarrdocuments/projectdocument' => $conf->global->DIGIRISKDOLIBARR_PROJECTDOCUMENT_ADDON, - ]; - list($refProjectDocumentMod) = saturne_require_objects_mod($numberingModules, 'digiriskdolibarr'); - - $ref = $refProjectDocumentMod->getNextValue($objectDocument); - - $objectDocument->ref = $ref; - $id = $objectDocument->create($user, true, $object); - $objectDocument->fetch($id); - - $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->projet->dir_output; - if ($objectDocument->specimen == 0) { - $dir .= '/' . $objectref; - } - $societyname = preg_replace('/\./', '_', $conf->global->MAIN_INFO_SOCIETE_NOM); + /** + * Function to build a document on disk using the generic pdf module. + * + * @param SaturneDocuments $objectDocument Object source to build document + * @param Translate $outputLangs Lang object to use for output + * @param string $srcTemplatePath Full path of source filename for generator using a template file + * @param int $hideDetails Do not show line details + * @param int $hideDesc Do not show desc + * @param int $hideRef Do not show ref + * @param array $moreParam More param (Object/user/etc) + * @return int 1 if OK, <=0 if KO + * @throws Exception + */ + public function write_file(SaturneDocuments $objectDocument, Translate $outputLangs, string $srcTemplatePath, int $hideDetails = 0, int $hideDesc = 0, int $hideRef = 0, array $moreParam): int + { + global $action, $conf, $hookmanager, $langs, $moduleNameLowerCase, $user; + + $object = $moreParam['object']; + + if (empty($moduleNameLowerCase)) { + $moduleNameLowerCase = $objectDocument->module; + } + + // Add PDF generation hook + $hookmanager->initHooks(['pdfgeneration']); + + if (!is_object($outputLangs)) { + $outputLangs = $langs; + $outputLangs->charset_output = 'UTF-8'; + } + + if ($conf->projet->dir_output) { + $numberingModules = ['digiriskdolibarrdocuments/projectdocument' => $conf->global->DIGIRISKDOLIBARR_PROJECTDOCUMENT_ADDON]; + list($refModName) = saturne_require_objects_mod($numberingModules, 'digiriskdolibarr'); + + $objectDocumentRef = $refModName->getNextValue($objectDocument); + $objectDocument->ref = $objectDocumentRef; + $objectDocument->type = $this->document_type; + $objectDocumentID = $objectDocument->create($moreParam['user'], true, $object); + + $objectDocument->fetch($objectDocumentID); + + $objectDocumentRef = dol_sanitizeFileName($objectDocument->ref); + + $dir = $conf->projet->dir_output . '/' . (dol_strlen($object->ref) > 0 ? $object->ref : ''); + + if ($moreParam['specimen'] == 1 && $moreParam['zone'] == 'public') { + $dir .= 'public_specimen'; + } - $date = dol_print_date(dol_now(), 'dayxcard'); - $filename = $date . '_' . $objectDocument->ref . '_' . $objectref . '_' . $societyname . '.pdf'; - $filename = str_replace(' ', '_', $filename); - $filename = dol_sanitizeFileName($filename); - $filename = preg_replace('/[’‘‹›‚]/u', '', $filename); + if (!file_exists($dir)) { + if (dol_mkdir($dir) < 0) { + $this->error = $langs->transnoentities('ErrorCanNotCreateDir', $dir); + return -1; + } + } - $objectDocument->last_main_doc = $filename; + if (file_exists($dir)) { + $societyName = preg_replace('/\./', '_', $conf->global->MAIN_INFO_SOCIETE_NOM); - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'saturne_object_documents'; - $sql .= ' SET last_main_doc =' . ( ! empty($filename) ? "'" . $this->db->escape($filename) . "'" : 'null'); - $sql .= ' WHERE rowid = ' . $objectDocument->id; + $date = dol_print_date(dol_now(), 'dayxcard'); + $newFileTmp = $date . (dol_strlen($object->ref) > 0 ? '_' . $object->ref : '') . '_' . $objectDocumentRef . '_' . $societyName; - dol_syslog('admin.lib::Insert last main doc', LOG_DEBUG); - $this->db->query($sql); + if ($moreParam['specimen'] == 1) { + $newFileTmp .= '_specimen'; + } + $newFileTmp = str_replace(' ', '_', $newFileTmp); + $fileName = dol_sanitizeFileName($newFileTmp) . '.pdf'; + $file = $dir . '/' . $fileName; - if ($objectDocument->specimen == 1) { - $filename = 'SPECIMEN.pdf'; - } - $file = $dir . '/' . $filename; + $objectDocument->setValueFrom('last_main_doc', $fileName, '', null, '', '', $moreParam['user'], '', ''); + if (!empty($objectDocument->error)) { + $objectDocument->errors[] = $objectDocument->ref; + setEventMessages($objectDocument->error, $objectDocument->errors, 'errors'); + return -1; + } - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { - $this->error = $langs->transnoentities('ErrorCanNotCreateDir', $dir); - return 0; - } - } - - if (file_exists($dir)) { - // Add pdfgeneration hook - if (!is_object($hookmanager)) { - include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($this->db); - } - $hookmanager->initHooks(array('pdfgeneration')); - $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); - global $action; - $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = ['file' => $file, 'object' => $object, 'outputlangs' => $outputLangs]; + $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Create pdf instance $pdf = pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $default_font_size = pdf_getPDFFontSize($outputLangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1, 0); $heightforinfotot = 40; // Height reserved to output the info and total part @@ -306,7 +301,7 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); + $pdf->SetFont(pdf_getPDFFont($outputLangs)); // Set path to the background PDF File if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); @@ -335,12 +330,12 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities('Project')); + $pdf->SetTitle($outputLangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputLangs->transnoentities('Project')); $pdf->SetCreator('Dolibarr ' .DOL_VERSION); - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetAuthor($outputLangs->convToOutputCharset($user->getFullName($outputLangs))); $pdf->SetKeyWords( - $outputlangs->convToOutputCharset($object->ref) . ' pdf_orque_projectdocument.modules.php' .$outputlangs->transnoentities('Project')); + $outputLangs->convToOutputCharset($object->ref) . ' pdf_orque_projectdocument.modules.php' .$outputLangs->transnoentities('Project')); if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { $pdf->SetCompression(false); } @@ -353,7 +348,7 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL $pdf->useTemplate($tplidx); } $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs); + $this->_pagehead($pdf, $object, 1, $outputLangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); @@ -366,9 +361,9 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL // Show public note $notetoshow = empty($object->note_public) ? '' : $object->note_public; if ($notetoshow) { - $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $substitutionarray = pdf_getSubstitutionArray($outputLangs, null, $object); + complete_substitutions_array($substitutionarray, $outputLangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputLangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); $tab_top -= 2; @@ -446,7 +441,7 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL $pdf->startTransaction(); // Label $pdf->SetXY($this->posxlabel, $curY); - $pdf->MultiCell($this->posxbudget - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); + $pdf->MultiCell($this->posxbudget - $this->posxlabel, 3, $outputLangs->convToOutputCharset($libelleline), 0, 'L'); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) { // There is a pagebreak $pdf->rollbackTransaction(true); @@ -456,7 +451,7 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL // Label $pdf->SetXY($this->posxlabel, $curY); $posybefore = $pdf->GetY(); - $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); + $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputLangs->convToOutputCharset($libelleline), 0, 'L'); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text @@ -466,7 +461,7 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputLangs); } $pdf->setPage($pageposafter + 1); } @@ -491,7 +486,7 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputLangs); } $pdf->setPage($pageposafter + 1); $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut @@ -504,7 +499,7 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL // Label $pdf->SetXY($this->posxlabel, $curY); $posybefore = $pdf->GetY(); - $pdf->MultiCell($this->posxbudget - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); + $pdf->MultiCell($this->posxbudget - $this->posxlabel, 3, $outputLangs->convToOutputCharset($libelleline), 0, 'L'); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); } @@ -533,7 +528,7 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL // Ref of task $pdf->SetXY($this->posxref, $curY); - $pdf->MultiCell($this->posxrisk - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L'); + $pdf->MultiCell($this->posxrisk - $this->posxref, 3, $outputLangs->convToOutputCharset($ref), 0, 'L'); // Risk $pdf->SetXY($this->posxrisk, $curY); $pdf->MultiCell($this->posxriskassessment - $this->posxrisk, 3, $riskref, 0, 'L'); @@ -585,16 +580,16 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputLangs, 0, 1); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputLangs, 1, 1); } - $this->_pagefoot($pdf, $object, $outputlangs, 1); + $this->_pagefoot($pdf, $object, $outputLangs, 1); $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputLangs); } if (!empty($tplidx)) { $pdf->useTemplate($tplidx); @@ -602,11 +597,11 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputLangs, 0, 1); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputLangs, 1, 1); } - $this->_pagefoot($pdf, $object, $outputlangs, 1); + $this->_pagefoot($pdf, $object, $outputLangs, 1); // New page $pdf->AddPage($this->orientation); if (!empty($tplidx)) { @@ -614,7 +609,7 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL } $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputLangs); } } } @@ -627,18 +622,18 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL // Total budget of task $pdf->SetXY($this->posxref, $curY); - $pdf->MultiCell($this->posxbudget - $this->posxlabel, 3, $outputlangs->convToOutputCharset($langs->transnoentities('TotalBudget')) . ' : ' . $outputlangs->convToOutputCharset($totalbudget), 0, 'L'); + $pdf->MultiCell($this->posxbudget - $this->posxlabel, 3, $outputLangs->convToOutputCharset($langs->transnoentities('TotalBudget')) . ' : ' . $outputLangs->convToOutputCharset($totalbudget), 0, 'L'); // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputLangs, 0, 0); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputLangs, 1, 0); } $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; // Footer of the page - $this->_pagefoot($pdf, $object, $outputlangs); + $this->_pagefoot($pdf, $object, $outputLangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); } @@ -649,7 +644,7 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputLangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -682,18 +677,18 @@ public function write_file( SaturneDocuments $objectDocument, Translate $outputL * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y - * @param Translate $outputlangs Langs object + * @param Translate $outputLangs Langs object * @param int $hidetop Hide top bar of array * @param int $hidebottom Hide bottom bar of array * @return void */ - protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputLangs, $hidetop = 0, $hidebottom = 0) { global $conf, $mysoc; $heightoftitleline = 10; - $default_font_size = pdf_getPDFFontSize($outputlangs); + $default_font_size = pdf_getPDFFontSize($outputLangs); $pdf->SetDrawColor(128, 128, 128); @@ -707,33 +702,33 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size); $pdf->SetXY($this->posxref, $tab_top + 1); - $pdf->MultiCell($this->posxrisk - $this->posxref, 3, $outputlangs->transnoentities('Tasks'), '', 'L'); + $pdf->MultiCell($this->posxrisk - $this->posxref, 3, $outputLangs->transnoentities('Tasks'), '', 'L'); $pdf->SetXY($this->posxrisk, $tab_top + 1); - $pdf->MultiCell($this->posxriskassessment - $this->posxrisk, 3, $outputlangs->transnoentities('Risk'), '', 'L'); + $pdf->MultiCell($this->posxriskassessment - $this->posxrisk, 3, $outputLangs->transnoentities('Risk'), '', 'L'); $pdf->SetXY($this->posxriskassessment, $tab_top + 1); - $pdf->MultiCell($this->posxlabel - $this->posxriskassessment, 3, $outputlangs->transnoentities('RiskAssessment'), '', 'L'); + $pdf->MultiCell($this->posxlabel - $this->posxriskassessment, 3, $outputLangs->transnoentities('RiskAssessment'), '', 'L'); $pdf->SetXY($this->posxlabel, $tab_top + 1); - $pdf->MultiCell($this->posxbudget - $this->posxlabel, 3, $outputlangs->transnoentities('Label'), 0, 'L'); + $pdf->MultiCell($this->posxbudget - $this->posxlabel, 3, $outputLangs->transnoentities('Label'), 0, 'L'); $pdf->SetXY($this->posxbudget, $tab_top + 1); - $pdf->MultiCell($this->posxworkload - $this->posxbudget, 3, $outputlangs->transnoentities('Budget'), 0, 'R'); + $pdf->MultiCell($this->posxworkload - $this->posxbudget, 3, $outputLangs->transnoentities('Budget'), 0, 'R'); $pdf->SetXY($this->posxworkload, $tab_top + 1); - $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities('PlannedWorkloadShort'), 0, 'R'); + $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputLangs->transnoentities('PlannedWorkloadShort'), 0, 'R'); $pdf->SetXY($this->posxprogress, $tab_top + 1); $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R'); // Date start $pdf->SetXY($this->posxdatestart, $tab_top + 1); - $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $outputlangs->trans('Start'), 0, 'C'); + $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $outputLangs->trans('Start'), 0, 'C'); // Date end $pdf->SetXY($this->posxdateend, $tab_top + 1); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $outputlangs->trans('End'), 0, 'C'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $outputLangs->trans('End'), 0, 'C'); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore @@ -743,16 +738,16 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ * @param TCPDF $pdf Object PDF * @param Project $object Object to show * @param int $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output + * @param Translate $outputLangs Object lang for output * @return void */ - protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + protected function _pagehead(&$pdf, $object, $showaddress, $outputLangs) { global $langs, $conf, $mysoc; - $default_font_size = pdf_getPDFFontSize($outputlangs); + $default_font_size = pdf_getPDFFontSize($outputLangs); - pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); + pdf_pagehead($pdf, $outputLangs, $this->page_hauteur); $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -775,30 +770,30 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell(100, 3, $langs->transnoentities('ErrorGoToModuleSetup'), 0, 'L'); } } else { - $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); + $pdf->MultiCell(100, 4, $outputLangs->transnoentities($this->emetteur->name), 0, 'L'); } $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities('Project') . ' ' .$outputlangs->convToOutputCharset($object->ref), '', 'R'); + $pdf->MultiCell(100, 4, $outputLangs->transnoentities('Project') . ' ' .$outputLangs->convToOutputCharset($object->ref), '', 'R'); $pdf->SetFont('', '', $default_font_size + 2); $posy += 6; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities('DateStart'). ' : ' .dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 4, $outputLangs->transnoentities('DateStart'). ' : ' .dol_print_date($object->date_start, 'day', false, $outputLangs, true), '', 'R'); if ($object->date_end) { $posy += 6; $pdf->SetXY($posx, $posy); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities('DateEnd'). ' : ' .dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 4, $outputLangs->transnoentities('DateEnd'). ' : ' .dol_print_date($object->date_end, 'day', false, $outputLangs, true), '', 'R'); } if (is_object($object->thirdparty)) { $posy += 6; $pdf->SetXY($posx, $posy); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities('ThirdParty'). ' : ' .$object->thirdparty->getFullName($outputlangs), '', 'R'); + $pdf->MultiCell(100, 4, $outputLangs->transnoentities('ThirdParty'). ' : ' .$object->thirdparty->getFullName($outputLangs), '', 'R'); } $pdf->SetTextColor(0, 0, 60); @@ -812,7 +807,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) var_dump($objects);exit; if ($objecttype == 'commande') { - $outputlangs->load('orders'); + $outputLangs->load('orders'); $num=count($objects); for ($i=0;$i<$num;$i++) { @@ -821,7 +816,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('','', $default_font_size - 1); $text=$objects[$i]->ref; if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')'; - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); + $pdf->MultiCell(100, 4, $outputLangs->transnoentities("RefOrder")." : ".$outputLangs->transnoentities($text), '', 'R'); } } } @@ -834,14 +829,14 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) * * @param TCPDF $pdf PDF * @param Project $object Object to show - * @param Translate $outputlangs Object lang for output + * @param Translate $outputLangs Object lang for output * @param int $hidefreetext 1=Hide free text * @return int */ - protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + protected function _pagefoot(&$pdf, $object, $outputLangs, $hidefreetext = 0) { global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputLangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } From 65aadecd336e31e4180bbe4f63b4be2349931a18 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Tue, 21 May 2024 23:45:57 +0200 Subject: [PATCH 08/25] #3900 [Risk] fix: remove class for prevent conflict JS with mediaGallery --- view/digiriskelement/digiriskelement_risk.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/digiriskelement/digiriskelement_risk.php b/view/digiriskelement/digiriskelement_risk.php index c15266e08..bc7ce75e9 100644 --- a/view/digiriskelement/digiriskelement_risk.php +++ b/view/digiriskelement/digiriskelement_risk.php @@ -298,7 +298,7 @@ $nophoto = DOL_URL_ROOT.'/public/theme/common/nophoto.png'; $importValue .= '
'; - $importValue .= ''; + $importValue .= ''; $importValue .= ''; $importValue .= ''; if (isset($lastEvaluation->photo) && dol_strlen($lastEvaluation->photo) > 0) { From bcd22bdb0ebdfd3b86ed902fccf466d52d55cfa8 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Wed, 22 May 2024 16:31:47 +0200 Subject: [PATCH 09/25] #2963 [Documents] fix: pdf orque task label should not overlap on budget --- .../pdf_orque_projectdocument.modules.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/projectdocument/pdf_orque_projectdocument.modules.php b/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/projectdocument/pdf_orque_projectdocument.modules.php index 28bc4ecf7..17c05d360 100644 --- a/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/projectdocument/pdf_orque_projectdocument.modules.php +++ b/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/projectdocument/pdf_orque_projectdocument.modules.php @@ -443,15 +443,15 @@ public function write_file(SaturneDocuments $objectDocument, Translate $outputLa $pdf->SetXY($this->posxlabel, $curY); $pdf->MultiCell($this->posxbudget - $this->posxlabel, 3, $outputLangs->convToOutputCharset($libelleline), 0, 'L'); $pageposafter = $pdf->getPage(); - if ($pageposafter > $pageposbefore) { // There is a pagebreak + if ($pageposafter > $pageposbefore) { // There is a pagebreak $pdf->rollbackTransaction(true); $pageposafter = $pageposbefore; - //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + // Label $pdf->SetXY($this->posxlabel, $curY); $posybefore = $pdf->GetY(); - $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputLangs->convToOutputCharset($libelleline), 0, 'L'); + $pdf->MultiCell($this->posxbudget - $this->posxlabel, 3, $outputLangs->convToOutputCharset($libelleline), 0, 'L'); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text @@ -504,12 +504,10 @@ public function write_file(SaturneDocuments $objectDocument, Translate $outputLa $posyafter = $pdf->GetY(); } } - //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); - } else // No pagebreak - { - $pdf->commitTransaction(); + } else { + // No pagebreak + $pdf->commitTransaction(); } - $posYAfterDescription = $pdf->GetY(); $nexY = $pdf->GetY(); $pageposafter = $pdf->getPage(); @@ -519,7 +517,6 @@ public function write_file(SaturneDocuments $objectDocument, Translate $outputLa // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; } From 1d6e6356c9504682afa4bd6ed4f67a773b523f24 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Thu, 23 May 2024 09:55:55 +0200 Subject: [PATCH 10/25] #3912 [Ticket] fix: action generate csv need getpost --- view/ticket/ticketstats.php | 1 + 1 file changed, 1 insertion(+) diff --git a/view/ticket/ticketstats.php b/view/ticket/ticketstats.php index d1d95eee3..041899ddf 100644 --- a/view/ticket/ticketstats.php +++ b/view/ticket/ticketstats.php @@ -50,6 +50,7 @@ saturne_load_langs(); // Get parameters +$action = GETPOST('action', 'aZ09'); $socid = GETPOST('socid', 'int'); $digiriskElements = GETPOST('digiriskElements', 'array'); $categories = GETPOST('categories', 'array'); From 1bdb5f43233d7f5b3710bc528beecbefb3459fe8 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Tue, 28 May 2024 12:24:19 +0200 Subject: [PATCH 11/25] #3918 [PublicTicket] fix: add manifest file for PWA --- class/actions_digiriskdolibarr.class.php | 10 ++ core/modules/modDigiriskDolibarr.class.php | 3 +- img/digiriskdolibarr_color.svg | 1 + img/digiriskdolibarr_color_192.png | Bin 0 -> 4779 bytes img/digiriskdolibarr_color_512.png | Bin 0 -> 16392 bytes lib/digiriskdolibarr.lib.php | 5 + manifest.json.php | 122 +++++++++++++++++++++ 7 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 img/digiriskdolibarr_color.svg create mode 100644 img/digiriskdolibarr_color_192.png create mode 100644 img/digiriskdolibarr_color_512.png create mode 100644 manifest.json.php diff --git a/class/actions_digiriskdolibarr.class.php b/class/actions_digiriskdolibarr.class.php index 82eedd5b1..1869cc987 100644 --- a/class/actions_digiriskdolibarr.class.php +++ b/class/actions_digiriskdolibarr.class.php @@ -132,6 +132,16 @@ public function addHtmlHeader(array $parameters): int $this->resprints = $out; } + if (strpos($_SERVER['PHP_SELF'], 'digiriskdolibarr') !== false) { + ?> + + resprints = ''; + } + return 0; // or return 1 to replace standard code } diff --git a/core/modules/modDigiriskDolibarr.class.php b/core/modules/modDigiriskDolibarr.class.php index a3f8c137b..7bab51654 100644 --- a/core/modules/modDigiriskDolibarr.class.php +++ b/core/modules/modDigiriskDolibarr.class.php @@ -439,7 +439,8 @@ public function __construct($db) 'accidentsignature', 'digiriskstandardagenda', 'category', - 'categoryindex' + 'categoryindex', + 'main' ], 'tabs' => [ 'mycompany_admin' diff --git a/img/digiriskdolibarr_color.svg b/img/digiriskdolibarr_color.svg new file mode 100644 index 000000000..fd1b217d8 --- /dev/null +++ b/img/digiriskdolibarr_color.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/img/digiriskdolibarr_color_192.png b/img/digiriskdolibarr_color_192.png new file mode 100644 index 0000000000000000000000000000000000000000..143600fe50a420d45f736f7887f35fbe56d5615f GIT binary patch literal 4779 zcmeHLeOOc189z6dBw#KC6V!yS1gR9Avd|<{gGdm{hYChSYkh1@5H*6dxW<-ZfrO;g z53nF;5y6H=hqGm6jCSZlxGX}ktQu|v7qeSlyWY6_Gi2OGoB|T z`JMN^AHVnGoRdSEtTg{Q!E*or{u${h+3=mDU%njpKl}5&T=?c!l>WrC0Qf}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(X}bxg{f>^2ZMCr=T#c z#L~xX77QN25Fq|wCf1Y8)Gx1n9J2@&w^@VGf7t7_4w)iSBOo%3N_`>hH+vfRlUeKl z*VNJVihSIr1{eKRLO1ZQ;q3nwtuGps>uUm&>CE zG*CjH&&Z3-ztTOGs)Vzedy5DQ(fSxl1G(BU(3hbX@E>erJe{I89ZU%e3e(b_G3GdY6*Qx!oJiHYggzD;b<%1n+y2f z27F!hi=M9w;gdJu!kxtFn9#0^+=;)iGj_$3hdvw5aTJDIO&7$xVIf{%%2^W?kE0N*NLdr~3_KD^{L(UcRI?s$3V z`$h1T1p4%cwRjP)-=v%iGPoc0$kCChiK+cHdi}kE^=w;(u_l3Z+g& z^Q4K!WD%AxndrSYxWlb-cMg~HU$OD1N|~Epexo&QD!VYZR^AEqg5v4J3H-W>301{Y z>E-@z+i;2cMJyhadkl(s+T$N0pL^nnJi;r&qk&Wc(Vq}YlwZ&x=2hs8-aeZBWNh7h zMK5>H*%t;IEBNDc_@khZMMJz2K4^bp{XaYB*5A>;;y9KFWqfsP?WdccI|1ayJ+}P5 e$CoTY)8KbG{NR5lm;DO=ci+8B7j-PO*#8GmoSIz# literal 0 HcmV?d00001 diff --git a/lib/digiriskdolibarr.lib.php b/lib/digiriskdolibarr.lib.php index 1e592c8bd..95c326285 100644 --- a/lib/digiriskdolibarr.lib.php +++ b/lib/digiriskdolibarr.lib.php @@ -73,6 +73,11 @@ function digiriskdolibarr_admin_prepare_head(): array $head[$h][2] = 'event'; $h++; + $head[$h][0] = dol_buildpath('/saturne/admin/pwa.php', 1). '?module_name=DigiriskDolibarr&start_url=' . dol_buildpath('/custom/digiriskdolibarr/public/create_ticket.php', 3); + $head[$h][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('PWA') : ''; + $head[$h][2] = 'pwa'; + $h++; + $head[$h][0] = dol_buildpath('/saturne/admin/documents.php?module_name=DigiriskDolibarr', 1); $head[$h][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('YourDocuments') : ''; $head[$h][2] = 'documents'; diff --git a/manifest.json.php b/manifest.json.php new file mode 100644 index 000000000..76c6c8174 --- /dev/null +++ b/manifest.json.php @@ -0,0 +1,122 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file manifest.json.php + * \ingroup digiriskdolibarr + * \brief File for The Web App + */ + +if (!defined('NOREQUIREUSER')) { + define('NOREQUIREUSER', 1); +} +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', 1); +} +if (!defined('NOREQUIRETRAN')) { + define('NOREQUIRETRAN', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', 1); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', 1); +} +if (!defined('NOSESSION')) { + define('NOSESSION', 1); +} +if (!defined('NOCSRFCHECK')) { // We accept to go on this page from external website + define('NOCSRFCHECK', 1); +} +if (!defined('NOIPCHECK')) { // Do not check IP defined into conf $dolibarr_main_restrict_ip + define('NOIPCHECK', 1); +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', 1); +} + +require_once __DIR__ . '/../../main.inc.php'; + +top_httphead('text/json'); + +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); + // For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server + header('Expires: ' . gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800) . ' GMT'); +} else { + header('Cache-Control: no-cache'); +} + +// Initialize technical objects +$manifest = new stdClass(); + +$manifest->short_name = 'DigiriskDolibarr'; +$manifest->name = 'DigiriskDolibarr'; +$manifest->icons = []; + +$img = new stdClass(); +$img->src = dol_buildpath('/custom/digiriskdolibarr/img/digiriskdolibarr_color.svg', 1); +$img->type = 'image/svg+xml'; +$img->sizes = '150x150'; +$manifest->icons[] = $img; + +$img = new stdClass(); +$img->src = dol_buildpath('/custom/digiriskdolibarr/img/digiriskdolibarr_color_192.png', 1); +$img->type = 'image/png'; +$img->sizes = '192x192'; +$manifest->icons[] = $img; + +$img = new stdClass(); +$img->src = dol_buildpath('/custom/digiriskdolibarr/img/digiriskdolibarr_color_512.png', 1); +$img->type = 'image/png'; +$img->sizes = '512x512'; +$manifest->icons[] = $img; + +$manifest->id = dol_buildpath('/custom/digiriskdolibarr/public/create_ticket.php', 1); +$manifest->start_url = dol_buildpath('/custom/digiriskdolibarr/public/create_ticket.php', 1); +$manifest->background_color = '#ffffff'; +$manifest->display = 'standalone'; +$manifest->display_override = ['window-controls-overlay']; +$manifest->scope = dol_buildpath('/custom/digiriskdolibarr/', 1); +$manifest->theme_color = '#ffffff'; +$manifest->description = 'Gérez les risques de votre entreprise et créez votre Document Unique en toute simplicité'; + +$img = new stdClass(); +$img->src = dol_buildpath('/custom/digiriskdolibarr/img/digiriskdolibarr_color_512.png', 1); +$img->type = 'image/png'; +$img->sizes = '512x512'; +$img->form_factor = 'narrow'; +$manifest->screenshots[] = $img; + +$img = new stdClass(); +$img->src = dol_buildpath('/custom/digiriskdolibarr/img/digiriskdolibarr_color_512.png', 1); +$img->type = 'image/png'; +$img->sizes = '512x512'; +$img->form_factor = 'wide'; +$manifest->screenshots[] = $img; + +print json_encode($manifest); From 1d7d7e7a89dd5ae214c8d508e5736dd40f642462 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Tue, 28 May 2024 17:00:01 +0200 Subject: [PATCH 12/25] #3923 [RiskAssessmentDocument] add: filter on GP/UT on tickets --- .../doc_riskassessmentdocument_odt.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/riskassessmentdocument/doc_riskassessmentdocument_odt.modules.php b/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/riskassessmentdocument/doc_riskassessmentdocument_odt.modules.php index 89609d157..c35c7e0ac 100644 --- a/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/riskassessmentdocument/doc_riskassessmentdocument_odt.modules.php +++ b/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/riskassessmentdocument/doc_riskassessmentdocument_odt.modules.php @@ -187,8 +187,8 @@ public function fillTagsLines(Odf $odfHandler, Translate $outputLangs, array $mo $objectDocument->fillRiskData($odfHandler, $objectDocument, $outputLangs, $tmpArray, $file, $risks, $conf->global->DIGIRISKDOLIBARR_SHOW_SHARED_RISKS); //Fill tickets data - $filter = array('t.fk_project' => $conf->global->DIGIRISKDOLIBARR_TICKET_PROJECT); - $tickets = saturne_fetch_all_object_type('Ticket', '', '', 0, 0, $filter); + $filter = ['customsql' => 't.fk_project = ' . $conf->global->DIGIRISKDOLIBARR_TICKET_PROJECT . ' AND eft.digiriskdolibarr_ticket_service > 0']; + $tickets = saturne_fetch_all_object_type('Ticket', '', '', 0, 0, $filter, 'AND', true); $listLines = $odfHandler->setSegment('tickets'); if (is_array($tickets) && !empty($tickets)) { foreach ($tickets as $line) { From e886782a2a7bc803bd15d144b10cebdb8f9ac396 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Wed, 29 May 2024 10:13:08 +0200 Subject: [PATCH 13/25] #3924 [Risk] fix: set massactionbutton even with filter --- .../risk/digiriskdolibarr_risklist_view.tpl.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/tpl/riskanalysis/risk/digiriskdolibarr_risklist_view.tpl.php b/core/tpl/riskanalysis/risk/digiriskdolibarr_risklist_view.tpl.php index 8944a0b4e..54eda6766 100644 --- a/core/tpl/riskanalysis/risk/digiriskdolibarr_risklist_view.tpl.php +++ b/core/tpl/riskanalysis/risk/digiriskdolibarr_risklist_view.tpl.php @@ -574,13 +574,15 @@ include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array(); -if ($permissiontodelete) $arrayofmassactions['predelete'] = '' . $langs->trans("Delete"); +$arrayofmassactions = []; +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = '' . $langs->trans("Delete"); +} + +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -if ($action != 'list') { - $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -} ?> - +?> + trans('AddRisk') . '" value="' . $object->id . '">'; From 7c8e8154d051fccf7d9904d3d06d464d8440e0c4 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Wed, 29 May 2024 14:45:16 +0200 Subject: [PATCH 14/25] #3917 [Tools] add: new tool to fix every risk with a corrupted category --- langs/fr_FR/digiriskdolibarr.lang | 4 ++ view/digirisktools.php | 84 ++++++++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 1 deletion(-) diff --git a/langs/fr_FR/digiriskdolibarr.lang b/langs/fr_FR/digiriskdolibarr.lang index 058754b6c..b66846adb 100644 --- a/langs/fr_FR/digiriskdolibarr.lang +++ b/langs/fr_FR/digiriskdolibarr.lang @@ -1444,6 +1444,10 @@ AdvancedImport = Import avancé AdvancedImportDescription = Permet d'importer chaque élément indépendamment (Arborescence, risques et signalisations) DataMigrationWordPressToDolibarr = Migration des données de WordPress vers Dolibarr DataMigrationDolibarrToDolibarr = Migration des données de Dolibarr vers Dolibarr +RepairRisks = Réparer les risques +NoRiskToRepair = Aucun risque à réparer +RiskSuccessfullyRepaired = Risques réparés avec succès +CorruptedCategoryOnRiskList = Liste des risques dont la catégorie est corrompue # # Other diff --git a/view/digirisktools.php b/view/digirisktools.php index 4c99dfdd1..29edd8401 100644 --- a/view/digirisktools.php +++ b/view/digirisktools.php @@ -783,6 +783,30 @@ } } +if ($action == 'repairCategory') { + if (is_array($_POST) && !empty($_POST)) { + $errors = []; + foreach($_POST as $key => $value) { + if (strstr($key, 'search_') && !empty($value) && $value >= 0 && $value <= 22) { + $riskId = trim($key, 'search_'); + $risk->fetch($riskId); + $result = $risk->setValueFrom('category', $value); + + if ($result <= 0) { + $errors[] = $risk->errors; + } + } + } + } + + if (!empty($errors)) { + setEventMessages($risk->error, $errors, 'errors'); + } else { + setEventMessages($langs->trans('RiskSuccessfullyRepaired'), []); + } + $action = ''; +} + /* * View */ @@ -938,7 +962,65 @@ print ''; print ''; print ''; - print ''; + print ''; + + print load_fiche_titre($langs->trans("CorruptedCategoryOnRiskList"), '', ''); + + print '
'; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $risks = saturne_fetch_all_object_type('Risk', '', '', 0, 0, ['customsql' => 't.category NOT BETWEEN 0 AND 22']); + + if (is_array($risks) && !empty($risks)) { + foreach ($risks as $key => $risk) { + $digiriskElement->fetch($risk->fk_element); + print ''; + print ''; + print ''; + print ''; + $button = ''; + } + } else { + print ''; + print ''; + $button = '
' . $langs->trans('RepairRisks') . '
'; + } + + print ''; + print '
' . $langs->trans('RiskCategory') . '' . $langs->trans('Risk') . '' . $langs->trans('Description') . '' . $langs->trans('DigiriskElement') . '
' + ?> + +
'; + print '
' . $risk->getNomUrl(1) . '
' . $risk->description . '
' . $digiriskElement->getNomUrl(1, '', 0, '', -1, 1) . '
' . $langs->trans('NoRiskToRepair') . '
'; + print $button; + print '
'; } // End of page From 09ba7308a0620205fd5bc52f20c84bac17d25db4 Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Wed, 29 May 2024 17:25:37 +0200 Subject: [PATCH 15/25] #3918 [PublicTicket] fix: directory to public_ticket --- lib/digiriskdolibarr.lib.php | 2 +- manifest.json.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/digiriskdolibarr.lib.php b/lib/digiriskdolibarr.lib.php index 95c326285..c500e5046 100644 --- a/lib/digiriskdolibarr.lib.php +++ b/lib/digiriskdolibarr.lib.php @@ -73,7 +73,7 @@ function digiriskdolibarr_admin_prepare_head(): array $head[$h][2] = 'event'; $h++; - $head[$h][0] = dol_buildpath('/saturne/admin/pwa.php', 1). '?module_name=DigiriskDolibarr&start_url=' . dol_buildpath('/custom/digiriskdolibarr/public/create_ticket.php', 3); + $head[$h][0] = dol_buildpath('/saturne/admin/pwa.php', 1). '?module_name=DigiriskDolibarr&start_url=' . dol_buildpath('/custom/digiriskdolibarr/public/ticket/create_ticket.php', 3); $head[$h][1] = $conf->browser->layout != 'phone' ? '' . $langs->trans('PWA') : ''; $head[$h][2] = 'pwa'; $h++; diff --git a/manifest.json.php b/manifest.json.php index 76c6c8174..2667d6ee6 100644 --- a/manifest.json.php +++ b/manifest.json.php @@ -96,8 +96,8 @@ $img->sizes = '512x512'; $manifest->icons[] = $img; -$manifest->id = dol_buildpath('/custom/digiriskdolibarr/public/create_ticket.php', 1); -$manifest->start_url = dol_buildpath('/custom/digiriskdolibarr/public/create_ticket.php', 1); +$manifest->id = dol_buildpath('/custom/digiriskdolibarr/public/ticket/create_ticket.php', 1); +$manifest->start_url = dol_buildpath('/custom/digiriskdolibarr/public/ticket/create_ticket.php', 1); $manifest->background_color = '#ffffff'; $manifest->display = 'standalone'; $manifest->display_override = ['window-controls-overlay']; From f4bb28cfe71842854ebc0916595909e40f5819ce Mon Sep 17 00:00:00 2001 From: evarisk-micka Date: Thu, 23 May 2024 12:34:43 +0200 Subject: [PATCH 16/25] #3920 [Risk] fix: digirisk element selector need a maxwidth --- class/actions_digiriskdolibarr.class.php | 2 +- class/digiriskelement.class.php | 2 +- .../risk/digiriskdolibarr_inheritedrisklist_view.tpl.php | 2 +- .../riskanalysis/risk/digiriskdolibarr_risklist_view.tpl.php | 4 ++-- .../risk/digiriskdolibarr_sharedrisklist_view.tpl.php | 2 +- .../digiriskdolibarr_inheritedrisksignlist_view.tpl.php | 2 +- .../risksign/digiriskdolibarr_sharedrisksignlist_view.tpl.php | 2 +- view/accident/accident_card.php | 4 ++-- view/digiriskelement/digiriskelement_card.php | 2 +- view/firepermit/firepermit_card.php | 4 ++-- view/preventionplan/preventionplan_card.php | 4 ++-- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/class/actions_digiriskdolibarr.class.php b/class/actions_digiriskdolibarr.class.php index 82eedd5b1..ae74b3a41 100644 --- a/class/actions_digiriskdolibarr.class.php +++ b/class/actions_digiriskdolibarr.class.php @@ -251,7 +251,7 @@ public function printCommonFooter($parameters) $object->fetch(GETPOST('id'),'',GETPOST('track_id')); require_once __DIR__ . '/digiriskelement.class.php'; $digiriskelement = new DigiriskElement($db); - $selectDigiriskElement = $digiriskelement->selectDigiriskElementList($object->array_options['options_digiriskdolibarr_ticket_service'], 'options_digiriskdolibarr_ticket_service', [], 1, 0, array(), 0, 0, 'minwidth100', 0, false, 1); + $selectDigiriskElement = $digiriskelement->selectDigiriskElementList($object->array_options['options_digiriskdolibarr_ticket_service'], 'options_digiriskdolibarr_ticket_service', [], 1, 0, array(), 0, 0, 'minwidth100 maxwidth300', 0, false, 1); ?>