diff --git a/admin/dolimeetdocuments.php b/admin/dolimeetdocuments.php index de29ed8..afb8c71 100644 --- a/admin/dolimeetdocuments.php +++ b/admin/dolimeetdocuments.php @@ -205,6 +205,39 @@ $head = dolimeet_admin_prepare_head(); print dol_get_fiche_head($head, 'dolimeetdocuments', $title, -1, 'dolimeet_color@dolimeet'); +print load_fiche_titre($langs->trans('DocumentsData'), '', ''); + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +// Automatic PDF generation +print ''; +print ''; +print ''; + +// Manual PDF generation +print ''; +print ''; +print ''; + +print '
' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Status") . '
'; +print $langs->trans("AutomaticPdfGeneration"); +print ''; +print $langs->trans('AutomaticPdfGenerationDescription'); +print ''; +print ajax_constantonoff('DOLIMEET_AUTOMATIC_PDF_GENERATION'); +print '
'; +print $langs->trans("ManualPdfGeneration"); +print ''; +print $langs->trans('ManualPdfGenerationDescription'); +print ''; +print ajax_constantonoff('DOLIMEET_MANUAL_PDF_GENERATION'); +print '
'; + foreach ($types as $type => $documentType) { $filelist = []; if (preg_match('/_/', $documentType)) { diff --git a/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/doc_attendancesheetdocument_odt.modules.php b/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/doc_attendancesheetdocument_odt.modules.php index 7f98880..a4aa830 100644 --- a/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/doc_attendancesheetdocument_odt.modules.php +++ b/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/doc_attendancesheetdocument_odt.modules.php @@ -435,26 +435,33 @@ public function write_file(SessionDocument $objectDocument, Translate $outputlan $parameters = ['odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray]; $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $fileInfos = pathinfo($filename); + $pdfName = $fileInfos['filename'] . '.pdf'; + // Write new file - if (!empty($conf->global->MAIN_ODT_AS_PDF)) { - try { - $odfHandler->exportAsAttachedPDF($file); - } catch (Exception $e) { - $this->error = $e->getMessage(); - dol_syslog($e->getMessage()); - return -1; - } - } else { - try { - $odfHandler->saveToDisk($file); - } catch (Exception $e) { - $this->error = $e->getMessage(); - dol_syslog($e->getMessage()); - return -1; - } - } + if (!empty($conf->global->MAIN_ODT_AS_PDF) && $conf->global->DOLIMEET_AUTOMATIC_PDF_GENERATION > 0) { + try { + $odfHandler->exportAsAttachedPDF($file); - $parameters = ['odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray]; + global $moduleNameLowerCase; + $documentUrl = DOL_URL_ROOT . '/document.php'; + setEventMessages($langs->trans('FileGenerated') . ' - ' . 'ref . '/' . $pdfName) . '&entity='. $conf->entity .'"' . '>' . $pdfName . '', []); + } catch (Exception $e) { + $this->error = $e->getMessage(); + dol_syslog($e->getMessage()); + setEventMessages($langs->transnoentities('FileCouldNotBeGeneratedInPDF') . '
' . $langs->transnoentities('CheckDocumentationToEnablePDFGeneration'), [], 'errors'); + } + } else { + try { + $odfHandler->saveToDisk($file); + } catch (Exception $e) { + $this->error = $e->getMessage(); + dol_syslog($e->getMessage()); + return -1; + } + } + + $parameters = ['odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray]; $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (!empty($conf->global->MAIN_UMASK)) { diff --git a/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/doc_completioncertificatedocument_odt.modules.php b/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/doc_completioncertificatedocument_odt.modules.php index 307984a..4e36f5b 100644 --- a/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/doc_completioncertificatedocument_odt.modules.php +++ b/core/modules/dolimeet/dolimeetdocuments/trainingsessiondocument/doc_completioncertificatedocument_odt.modules.php @@ -383,14 +383,21 @@ public function write_file(SessionDocument $objectDocument, Translate $outputlan $parameters = ['odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray]; $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $fileInfos = pathinfo($filename); + $pdfName = $fileInfos['filename'] . '.pdf'; + // Write new file - if (empty($conf->global->MAIN_ODT_AS_PDF)) { + if (!empty($conf->global->MAIN_ODT_AS_PDF) && $conf->global->DOLIMEET_AUTOMATIC_PDF_GENERATION > 0) { try { $odfHandler->exportAsAttachedPDF($file); + + global $moduleNameLowerCase; + $documentUrl = DOL_URL_ROOT . '/document.php'; + setEventMessages($langs->trans('FileGenerated') . ' - ' . 'ref . '/' . $pdfName) . '&entity='. $conf->entity .'"' . '>' . $pdfName . '', []); } catch (Exception $e) { $this->error = $e->getMessage(); dol_syslog($e->getMessage()); - return -1; + setEventMessages($langs->transnoentities('FileCouldNotBeGeneratedInPDF') . '
' . $langs->transnoentities('CheckDocumentationToEnablePDFGeneration'), [], 'errors'); } } else { try { diff --git a/core/modules/modDoliMeet.class.php b/core/modules/modDoliMeet.class.php index 3bada63..29ebea5 100644 --- a/core/modules/modDoliMeet.class.php +++ b/core/modules/modDoliMeet.class.php @@ -191,7 +191,12 @@ public function __construct($db) // CONST MODULE $i++ => ['DOLIMEET_VERSION','chaine', $this->version, '', 0, 'current'], - $i => ['DOLIMEET_DB_VERSION', 'chaine', $this->version, '', 0, 'current'] + $i++ => ['DOLIMEET_DB_VERSION', 'chaine', $this->version, '', 0, 'current'], + $i++ => ['DOLIMEET_AUTOMATIC_PDF_GENERATION', 'integer', 0, '', 0, 'current'], + $i++ => ['DOLIMEET_MANUAL_PDF_GENERATION', 'integer', 0, '', 0, 'current'], + + // CONST GENERAL CONST + $i => ['MAIN_ODT_AS_PDF', 'chaine', 'libreoffice', '', 0, 'current'] ]; // Some keys to add into the overwriting translation tables