diff --git a/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/digiriskelementdocument/modules_digiriskelementdocument.php b/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/digiriskelementdocument/modules_digiriskelementdocument.php index 5577f3650..f56fabef8 100644 --- a/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/digiriskelementdocument/modules_digiriskelementdocument.php +++ b/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/digiriskelementdocument/modules_digiriskelementdocument.php @@ -32,8 +32,9 @@ require_once __DIR__ . '/../../../../../class/riskanalysis/risk.class.php'; require_once __DIR__ . '/../../../../../class/evaluator.class.php'; require_once __DIR__ . '/../../../../../class/accident.class.php'; +require_once __DIR__ . '/../../../../../class/digiriskresources.class.php'; -// Load saturne libraries +// Load Saturne libraries require_once __DIR__ . '/../../../../../../saturne/core/modules/saturne/modules_saturne.php'; /** @@ -306,6 +307,32 @@ public function write_file(SaturneDocuments $objectDocument, Translate $outputLa $tmpArray['photo'] = DOL_DOCUMENT_ROOT . $noPhoto; } + $resources = new DigiriskResources($this->db); + $userTmp = new User($this->db); + + // Get QRCode to public interface + if (isModEnabled('multicompany')) { + $qrCodePath = DOL_DATA_ROOT . '/digiriskdolibarr/multicompany/ticketqrcode/'; + } else { + $qrCodePath = $conf->digiriskdolibarr->multidir_output[$conf->entity ?: 1] . '/ticketqrcode/'; + } + $QRCodeList = dol_dir_list($qrCodePath); + if (is_array($QRCodeList) && !empty($QRCodeList)) { + $QRCode = array_shift($QRCodeList); + $QRCodeImagePath = $QRCode['fullname']; + } else { + $QRCodeImagePath = DOL_DOCUMENT_ROOT . '/public/theme/common/nophoto.png'; + } + + $allLinks = $resources->fetchDigiriskResources(); + $responsibleResources = $allLinks['Responsible']; + $userTmp->fetch($responsibleResources->id[0]); + + // @todo The keyword "signature" is needed because we want the image to be cropped to fit in the table + $tmpArray['helpUrl'] = DOL_MAIN_URL_ROOT . '/custom/digiriskdolibarr/public/ticket/create_ticket.php'; + $tmpArray['signatureQRCodeTicket'] = $QRCodeImagePath; + $tmpArray['securityResponsible'] = (!empty($userTmp) ? dol_strtoupper($userTmp->lastname) . ' ' . ucfirst($userTmp->firstname) : ''); + if (isset($moreParam['tmparray']) && is_array($moreParam['tmparray'])) { $moreParam['tmparray'] = array_merge($moreParam['tmparray'], $tmpArray); } else { diff --git a/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/workunitdocument/doc_workunitdocument_odt.modules.php b/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/workunitdocument/doc_workunitdocument_odt.modules.php index 7b9adcc40..cb8da90f8 100644 --- a/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/workunitdocument/doc_workunitdocument_odt.modules.php +++ b/core/modules/digiriskdolibarr/digiriskdolibarrdocuments/workunitdocument/doc_workunitdocument_odt.modules.php @@ -28,7 +28,6 @@ // Load DigiriskDolibarr libraries require_once __DIR__ . '/../digiriskelementdocument/modules_digiriskelementdocument.php'; -require_once __DIR__ . '/../../../../../class/digiriskresources.class.php'; /** * Class to build documents using ODF templates generator @@ -65,52 +64,4 @@ public function info(Translate $langs): string { return parent::info($langs); } - - /** - * Function to build a document on disk - * - * @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 $conf; - - $resources = new DigiriskResources($this->db); - $userTmp = new User($this->db); - - // Get QRCode to public interface - if (isModEnabled('multicompany')) { - $qrCodePath = DOL_DATA_ROOT . '/digiriskdolibarr/multicompany/ticketqrcode/'; - } else { - $qrCodePath = $conf->digiriskdolibarr->multidir_output[$conf->entity ?: 1] . '/ticketqrcode/'; - } - $QRCodeList = dol_dir_list($qrCodePath); - if (is_array($QRCodeList) && !empty($QRCodeList)) { - $QRCode = array_shift($QRCodeList); - $QRCodeImagePath = $QRCode['fullname']; - } else { - $QRCodeImagePath = DOL_DOCUMENT_ROOT . '/public/theme/common/nophoto.png'; - } - - $allLinks = $resources->fetchDigiriskResources(); - $responsibleResources = $allLinks['Responsible']; - $userTmp->fetch($responsibleResources->id[0]); - - // @todo The keyword "signature" is needed because we want the image to be cropped to fit in the table - $tmpArray['helpUrl'] = DOL_MAIN_URL_ROOT . '/custom/digiriskdolibarr/public/ticket/create_ticket.php'; - $tmpArray['signatureQRCodeTicket'] = $QRCodeImagePath; - $tmpArray['securityResponsible'] = (!empty($userTmp) ? dol_strtoupper($userTmp->lastname) . ' ' . ucfirst($userTmp->firstname) : ''); - - $moreParam['tmparray'] = $tmpArray; - - return parent::write_file($objectDocument, $outputLangs, $srcTemplatePath, $hideDetails, $hideDesc, $hideRef, $moreParam); - } } diff --git a/documents/doctemplates/groupmentdocument/template_groupmentdocument.odt b/documents/doctemplates/groupmentdocument/template_groupmentdocument.odt index 058715624..27050b709 100644 Binary files a/documents/doctemplates/groupmentdocument/template_groupmentdocument.odt and b/documents/doctemplates/groupmentdocument/template_groupmentdocument.odt differ diff --git a/documents/doctemplates/workunitdocument/template_workunitdocument.odt b/documents/doctemplates/workunitdocument/template_workunitdocument.odt index 469955099..22039a1b6 100644 Binary files a/documents/doctemplates/workunitdocument/template_workunitdocument.odt and b/documents/doctemplates/workunitdocument/template_workunitdocument.odt differ