Skip to content

Commit

Permalink
Evarisk#3942 [PreventionPlan] add: associated fire permits documents
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-francois committed Jun 10, 2024
1 parent f56410c commit e56bad1
Showing 1 changed file with 40 additions and 1 deletion.
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
$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);
$dirFiles = $firepermitdocument->element . '/' . $objref;
echo '<pre>'; print_r( $dirFiles ); echo '</pre>';

$filedir = $upload_dir . '/' . $dirFiles;
$dirFilesArray[] = $dirFiles;
$filedirArray[] = $filedir;

$modulepart = 'digiriskdolibarr:FirePermitDocument';
$defaultmodel = $conf->global->DIGIRISKDOLIBARR_FIREPERMITDOCUMENT_DEFAULT_MODEL;
$title = $langs->trans('FirePermitDocument');

if ($permissiontoadd || $permissiontoread) {
$genallowed = 1;
}

$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)))));
}

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

0 comments on commit e56bad1

Please sign in to comment.