Skip to content

Commit

Permalink
Merge pull request Evarisk#3322 from evarisk-theo/fix_digiriskelement…
Browse files Browse the repository at this point in the history
…_data

fix digirisk element
  • Loading branch information
nicolas-eoxia authored Oct 9, 2023
2 parents 8625451 + bd2731e commit 79ded6f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 41 deletions.
7 changes: 2 additions & 5 deletions class/digiriskelement.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,21 +472,18 @@ public function getBannerTabContent(): array

$digiriskstandard = new DigiriskStandard($db);

dol_strlen($this->label) ? $morehtmlref = ' - ' . $this->label : '';

// ParentElement
$parent_element = new self($db);
$result = $parent_element->fetch($this->fk_parent);
if ($result > 0) {
$morehtmlref .= '<br>' . $langs->trans("Description") . ' : ' . $this->description;
$morehtmlref .= $langs->trans("Description") . ' : ' . $this->description;
$morehtmlref .= '<br>' . $langs->trans("ParentElement") . ' : ' . $parent_element->getNomUrl(1, 'blank', 1);
} else {
$digiriskstandard->fetch($conf->global->DIGIRISKDOLIBARR_ACTIVE_STANDARD);
$morehtmlref .= '<br>' . $langs->trans("Description") . ' : ' . $this->description;
$morehtmlref .= $langs->trans("Description") . ' : ' . $this->description;
$morehtmlref .= '<br>' . $langs->trans("ParentElement") . ' : ' . $digiriskstandard->getNomUrl(1, 'blank', 1);
}
$morehtmlref .= '<br>';
$linkback = '<a href="' . dol_buildpath('/digiriskdolibarr/view/digiriskelement/risk_list.php', 1) . '">' . $langs->trans("BackToList") . '</a>';
$this->fetch($this->id);
$this->fk_project = $conf->global->DIGIRISKDOLIBARR_DU_PROJECT;
$moreParams['project']['disable_edit'] = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,7 @@
print '<tr>';
print '<td class="titlefield">' . $form->editfieldkey($langs->trans("SitePlans"), 'SitePlans', '', $object, 0) . '</td>';
print '<td>';
$filearray = dol_dir_list($conf->digiriskdolibarr->multidir_output[$conf->entity] . '/riskassessmentdocument/', "files", 0, '', '(\.odt|\.zip)', 'date', 'asc', 1);
if (count($filearray)) : ?>
<?php
$file = array_shift($filearray);
$thumb_name = getThumbName($file['name']);
?>
<span class="">
<?php print '<img class="" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=digiriskdolibarr&entity=' . $conf->entity . '&file=' . urlencode('/riskassessmentdocument/thumbs/' . $thumb_name) . '" >'; ?>
</span>
<?php else : ?>
<?php $nophoto = DOL_URL_ROOT . '/public/theme/common/nophoto.png'; ?>
<span class="">
<img class="" alt="No photo" src="<?php echo $nophoto ?>">
</span>
<?php endif;
print saturne_show_medias_linked('digiriskdolibarr', $conf->digiriskdolibarr->multidir_output[$conf->entity] . '/riskassessmentdocument/siteplans', 'small', '', 0, 0, 0, 200, 200, 0, 0, 0, 'riskassessmentdocument/siteplans', null, '', 0, 0);
print '<input class="flat" type="file" name="userfile[]" id="SitePlans" />';
print '</td></tr>';
} else {
Expand Down Expand Up @@ -141,22 +127,8 @@
print '<tr>';
print '<td class="titlefield">' . $langs->trans("SitePlans") . '</td>';
print '<td>';
$filearray = dol_dir_list($conf->digiriskdolibarr->multidir_output[$conf->entity] . '/riskassessmentdocument/', "files", 0, '', '(\.odt|\.zip)', 'date', 'asc', 1);
if (count($filearray)) : ?>
<?php
$file = array_shift($filearray);
$thumb_name = getThumbName($file['name']);
?>
<span class="">
<?php print '<img class="" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=digiriskdolibarr&entity=' . $conf->entity . '&file=' . urlencode('/riskassessmentdocument/thumbs/' . $thumb_name) . '" >'; ?>
</span>
<?php else : ?>
<?php $nophoto = DOL_URL_ROOT . '/public/theme/common/nophoto.png'; ?>
<span class="">
<img class="" alt="No photo" src="<?php echo $nophoto ?>">
</span>
<?php endif; ?>
<?php print '</td></tr>';
print saturne_show_medias_linked('digiriskdolibarr', $conf->digiriskdolibarr->multidir_output[$conf->entity] . '/riskassessmentdocument/siteplans', 'small', '', 0, 0, 0, 200, 200, 0, 0, 0, 'riskassessmentdocument/siteplans', null, '', 0, 0);
print '</td></tr>';
}

?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,18 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
$digiriskelement->fetch($object->fk_parent);
$actioncomm->note_private .= $langs->trans('ParentElement') . ' : ' . $digiriskelement->ref . ' - ' . $digiriskelement->label . '<br/>';
}
$object->fetch($object->id);

$actioncomm->elementtype = 'digiriskelement@digiriskdolibarr';
$actioncomm->elementid = $object->id;

$actioncomm->label = $langs->transnoentities('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element)), $object->ref);
$actioncomm->note_private .= $langs->trans('Standard') . ' : ' . $digiriskstandard->ref . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM . '<br/>';
$actioncomm->label = $langs->transnoentities('ObjectCreateTrigger', $langs->transnoentities(ucfirst($object->element_type)), $object->ref);
$actioncomm->note_private .= $langs->trans('Standard') . ' : ' . $digiriskstandard->ref . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM . '<br/>';
$actioncomm->note_private .= $langs->trans('Ref') . ' : ' . $object->ref . '<br/>';
$actioncomm->note_private .= $langs->trans('Label') . ' : ' . $object->label . '<br/>';
$actioncomm->note_private .= $langs->trans('Entity') . ' : ' . $conf->entity . '<br>';
$actioncomm->note_private .= $langs->trans('TechnicalID') . ' : ' . $object->id . '<br>';
$actioncomm->note_private .= $langs->trans('Description') . ' : ' . (!empty($object->description) ? $object->description : 'N/A') . '<br>';
$actioncomm->note_private .= $langs->trans('Photo') . ' : ' . (!empty($object->photo) ? $object->photo : 'N/A') . '<br>';
$actioncomm->note_private .= $langs->trans('ElementType') . ' : ' . $langs->trans($object->element_type) . '<br>';
($object->ranks != 0 ? $actioncomm->note_private .= $langs->trans('Order') . ' : ' . $object->ranks . '<br>' : '');
Expand Down
2 changes: 1 addition & 1 deletion js/digiriskdolibarr.min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@
}

if ( ! $error) {
$filedir = $upload_dir . '/riskassessmentdocument/';
if ( ! empty($filedir)) {
$filedir = $upload_dir . '/riskassessmentdocument/siteplans/';
array_map('unlink', array_filter((array) glob($filedir . '*')));
if ( ! empty($filedir)) {
$result = digirisk_dol_add_file_process($filedir, 0, 1, 'userfile', '', null, '', 1, $object);
}
}
Expand Down

0 comments on commit 79ded6f

Please sign in to comment.