Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3942 [PreventionPlan] add: associated fire permits documents #3966

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
41 changes: 40 additions & 1 deletion view/preventionplan/preventionplan_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
require_once __DIR__ . '/../../class/digiriskelement.class.php';
require_once __DIR__ . '/../../class/digiriskresources.class.php';
require_once __DIR__ . '/../../class/preventionplan.class.php';
require_once __DIR__ . '/../../class/firepermit.class.php';
require_once __DIR__ . '/../../class/riskanalysis/risk.class.php';
require_once __DIR__ . '/../../class/digiriskdolibarrdocuments/preventionplandocument.class.php';
require_once __DIR__ . '/../../class/digiriskdolibarrdocuments/firepermitdocument.class.php';
require_once __DIR__ . '/../../lib/digiriskdolibarr_function.lib.php';
require_once __DIR__ . '/../../lib/digiriskdolibarr_preventionplan.lib.php';

Expand Down Expand Up @@ -1443,6 +1445,7 @@ class="attachment-thumbail size-thumbnail photo photowithmargin" alt="">
print '</table>';
print '</div>';
}

// Document Generation -- Génération des documents
if ($permissiontoadd) {
print '<div class=""><div class="preventionplanDocument fichehalfleft">';
Expand All @@ -1460,6 +1463,7 @@ class="attachment-thumbail size-thumbnail photo photowithmargin" alt="">
$genallowed = 1;
}

// TODO: Ne fonctionne pas
evarisk-micka marked this conversation as resolved.
Show resolved Hide resolved
$filelist = dol_dir_list($filedir, 'files');
if (!empty($filelist) && is_array($filelist)) {
foreach ($filelist as $file) {
Expand All @@ -1472,7 +1476,42 @@ class="attachment-thumbail size-thumbnail photo photowithmargin" alt="">
print saturne_show_documents($modulepart, $dirFiles, $filedir, $urlsource, $genallowed, 0, $defaultmodel, 1, 0, 0, 0, 0, $title, 0, 0, empty($soc->default_lang) ? '' : $soc->default_lang, $object, 0, 'remove_file', (($object->status > $object::STATUS_VALIDATED) ? 1 : 0), $langs->trans('ObjectMustBeLockedToGenerate', ucfirst($langs->transnoentities('The' . ucfirst($object->element)))));
}

if ($permissiontoadd) {
$firepermits = saturne_fetch_all_object_type('FirePermit', '', '', 0, 0, ['customsql' => 'fk_preventionplan = ' . $id]);

if (!empty($firepermits) && is_array($firepermits)) {
$firepermitdocument = new FirePermitDocument($db);
foreach ($firepermits as $firepermit) {
$objref = dol_sanitizeFileName($firepermit->ref);
evarisk-micka marked this conversation as resolved.
Show resolved Hide resolved
$dirFiles = $firepermitdocument->element . '/' . $objref;
echo '<pre>'; print_r( $dirFiles ); echo '</pre>';
evarisk-micka marked this conversation as resolved.
Show resolved Hide resolved

$filedir = $upload_dir . '/' . $dirFiles;
$dirFilesArray[] = $dirFiles;
$filedirArray[] = $filedir;
evarisk-micka marked this conversation as resolved.
Show resolved Hide resolved

$modulepart = 'digiriskdolibarr:FirePermitDocument';
$defaultmodel = $conf->global->DIGIRISKDOLIBARR_FIREPERMITDOCUMENT_DEFAULT_MODEL;
evarisk-micka marked this conversation as resolved.
Show resolved Hide resolved
$title = $langs->trans('FirePermitDocument');

if ($permissiontoadd || $permissiontoread) {
$genallowed = 1;
}
evarisk-micka marked this conversation as resolved.
Show resolved Hide resolved

$filelist = array_merge($filelist, dol_dir_list($filedir, 'files'));
if (!empty($filelist) && is_array($filelist)) {
foreach ($filelist as $file) {
if (preg_match('/sign/', $file['name'])) {
$filesigned = 1;
}
}
}
}
$urlsource = $_SERVER["PHP_SELF"] . '?id=' . $object->id;

print saturne_show_documents($modulepart, $dirFilesArray, $filedirArray, $urlsource, $genallowed, 0, $defaultmodel, 1, 0, 0, 0, 0, $title, 0, 0, empty($soc->default_lang) ? '' : $soc->default_lang, $object, 0, 'remove_file', (($object->status > $object::STATUS_VALIDATED) ? 1 : 0), $langs->trans('ObjectMustBeLockedToGenerate', ucfirst($langs->transnoentities('The' . ucfirst($object->element)))));
evarisk-micka marked this conversation as resolved.
Show resolved Hide resolved
}

if ($permissiontoadd) {
print '</div><div class="fichehalfright">';
} else {
print '</div><div class="">';
Expand Down