Skip to content

Commit

Permalink
fix: digiriskheader
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-theo committed Mar 15, 2021
1 parent cdb3003 commit 03e0e71
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 144 deletions.
28 changes: 2 additions & 26 deletions class/digiriskelement.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1090,32 +1090,8 @@ public function digiriskHeader($head = '', $title = '', $help_url = '', $target
$tmpcsstouse .= ' colorblind-'.strip_tags($conf->global->MAIN_OPTIMIZEFORCOLORBLIND);
}

print '<body id="mainbody" class="'.$tmpcsstouse.'">'."\n"; ?>

<?php //Top Menu ?>
<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { ?>
<div class="header">
<div class="topnav">
<div class="topnav-left">
<div class="inline-block valignmiddle">
<img src="img/digiriskdolibarr.png" width="32" height="32" alt="" class="inline-block">
<span class="hideonsmartphone"><?php echo $langs->trans("Digirisk"); ?></span>
</div>
</div>
<div class="topnav-right">
<div class="login_block_other">
<a onclick="window.location.href='<?php echo DOL_URL_ROOT; ?>';"><span class="fas fa-home"></span></a>
</div>
<div class="login_block_user">
<?php print top_menu_user(1, DOL_URL_ROOT.'/user/logout.php'); ?>
</div>
</div>
</div>
</div>
<?php } ?>


<?php //Body navigation digirisk
print '<body id="mainbody" class="'.$tmpcsstouse.'">'."\n";
llxHeader('');//Body navigation digirisk
$object = new DigiriskElement($this->db);
$objects = $object->fetchAll('', '', 0,0,array('entity' => $conf->entity));
$results = $this->recurse_tree(0,0,$objects); ?>
Expand Down
235 changes: 119 additions & 116 deletions digiriskelement_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@
dol_fiche_head($head, 'elementCard', $langs->trans("DigiriskElement"), -1, $object->picto);

$formconfirm = '';

// Confirmation to delete
if ($action == 'delete')
{
Expand Down Expand Up @@ -360,7 +359,6 @@
$morehtmlleft .= '<img class="photo maxwidth50" src="' . $path . 'logobdj.jpg' .'">';

$object->digirisk_banner_tab($object, 'ref', '', 0, 'ref', 'ref', $morehtmlref, '', 0, $morehtmlleft);

unset($object->fields['element_type']);
unset($object->fields['fk_parent']);
unset($object->fields['last_main_doc']);
Expand Down Expand Up @@ -412,169 +410,174 @@

dol_fiche_end();

/*
* Lines
*/
if ($object->id > 0) {

if (!empty($object->table_element_line))
{
// Show object lines
$result = $object->getLinesArray();

print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
/*
* Lines
*/

if (!empty($object->table_element_line))
{
// Show object lines
$result = $object->getLinesArray();

print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
<input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id.'">
';

if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
}
if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
}

print '<div class="div-table-responsive-no-min">';
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{
print '<table id="tablelines" class="noborder noshadow" width="100%">';
}
print '<div class="div-table-responsive-no-min">';
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{
print '<table id="tablelines" class="noborder noshadow" width="100%">';
}

if (!empty($object->lines))
{
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
}
if (!empty($object->lines))
{
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
}

// Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
{
if ($action != 'editline')
// Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
{
// Add products/services form
$object->formAddObjectLine(1, $mysoc, $soc);
if ($action != 'editline')
{
// Add products/services form
$object->formAddObjectLine(1, $mysoc, $soc);

$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
}
}

$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{
print '</table>';
}
}
print '</div>';

if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{
print '</table>';
print "</form>\n";
}
print '</div>';

print "</form>\n";
}
// Buttons for actions

// Buttons for actions
if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction" >'."\n";
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction" >'."\n";
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

if (empty($reshook))
{
// Modify
if ($permissiontoadd)
{
print '<a class="butAction" id="actionButtonEdit" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n";
}
else
if (empty($reshook))
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
}
// Modify
if ($permissiontoadd)
{
print '<a class="butAction" id="actionButtonEdit" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n";
}
else
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
}

// // Send
// if (empty($user->socid)) {
// print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
// }

// Delete (need delete permission, or if draft, just need create/modify permission)
if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd))
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
}
else
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
// Delete (need delete permission, or if draft, just need create/modify permission)
if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd))
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
}
else
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
}
}
print '</div>'."\n";
}
print '</div>'."\n";
}

// Select mail models is same action as presend
if (GETPOST('modelselected')) {
$action = 'presend';
}
// Select mail models is same action as presend
if (GETPOST('modelselected')) {
$action = 'presend';
}

// Document Generation -- Génération des documents
// Document Generation -- Génération des documents

if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft elementDocument">';
print '<a name="builddoc"></a>'; // ancre
if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft elementDocument">';
print '<a name="builddoc"></a>'; // ancre

$includedocgeneration = 1;
// Documents
if ($includedocgeneration) {
$includedocgeneration = 1;
// Documents
if ($includedocgeneration) {

$objref = dol_sanitizeFileName($object->ref);
$objref = dol_sanitizeFileName($object->ref);

$relativepath = $objref . '/' . $objref . '.pdf';
$dir_files = $object->element_type . '/' . $objref;
$filedir = $conf->digiriskdolibarr->dir_output.'/'.$dir_files;
$relativepath = $objref . '/' . $objref . '.pdf';
$dir_files = $object->element_type . '/' . $objref;
$filedir = $conf->digiriskdolibarr->dir_output.'/'.$dir_files;

$urlsource = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
$genallowed = $user->rights->digiriskdolibarr->digiriskelement->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->digiriskdolibarr->digiriskelement->create; // If you can create/edit, you can remove a file on card
$urlsource = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
$genallowed = $user->rights->digiriskdolibarr->digiriskelement->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->digiriskdolibarr->digiriskelement->create; // If you can create/edit, you can remove a file on card

if ( $object->element_type == 'groupment' ) {
$modulepart = 'digiriskdolibarr:Groupment';
} else {
$modulepart = 'digiriskdolibarr:WorkUnit';
}
if ( $object->element_type == 'groupment' ) {
$modulepart = 'digiriskdolibarr:Groupment';
} else {
$modulepart = 'digiriskdolibarr:WorkUnit';
}

print $formfile->showdocuments($modulepart,$dir_files, $filedir, $urlsource, $genallowed, $delallowed, $conf->global->DIGIRISKDOLIBARR_GROUPMENT_DEFAULT_MODEL, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang, '');
print $formfile->showdocuments($modulepart,$dir_files, $filedir, $urlsource, $genallowed, $delallowed, $conf->global->DIGIRISKDOLIBARR_GROUPMENT_DEFAULT_MODEL, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang, '');

}
}

// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('digiriskelement'));
//$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('digiriskelement'));
//$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);

print '</div><div class="fichehalfright"><div class="ficheaddleft">';
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

$MAXEVENT = 10;
$MAXEVENT = 10;

$morehtmlright = '<a href="'.dol_buildpath('/digiriskdolibarr/digiriskelement_agenda.php', 1).'?id='.$object->id.'">';
$morehtmlright .= $langs->trans("SeeAll");
$morehtmlright .= '</a>';
$morehtmlright = '<a href="'.dol_buildpath('/digiriskdolibarr/digiriskelement_agenda.php', 1).'?id='.$object->id.'">';
$morehtmlright .= $langs->trans("SeeAll");
$morehtmlright .= '</a>';

// List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, $object->element_type.'@digiriskdolibarr', (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright);
// List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, $object->element_type.'@digiriskdolibarr', (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright);

print '</div></div></div>';
}
print '</div></div></div>';
}

//Select mail models is same action as presend
if (GETPOST('modelselected')) $action = 'presend';
//Select mail models is same action as presend
if (GETPOST('modelselected')) $action = 'presend';

// Presend form
// Presend form

//force generate document when 'send by mail' button is clicked
$object->modelpdf = 'digiriskelement_A4_odt';
//force generate document when 'send by mail' button is clicked
$object->modelpdf = 'digiriskelement_A4_odt';

//get title and content
$modelmail = 'Digirisk_DigiriskElement';
$defaulttopic = $langs->trans('SendDigiriskElement') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$diroutput = $conf->digiriskdolibarr->dir_output . '/digiriskelement';
$trackid = 'digiriskelement'.$object->id;
//get title and content
$modelmail = 'Digirisk_DigiriskElement';
$defaulttopic = $langs->trans('SendDigiriskElement') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$diroutput = $conf->digiriskdolibarr->dir_output . '/digiriskelement';
$trackid = 'digiriskelement'.$object->id;

include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
print '</div>';
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
print '</div>';

}

}

Expand Down
2 changes: 1 addition & 1 deletion digiriskelement_listingrisksaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
}

// Document Generation -- Génération des documents
print '<h2>' . $langs->trans('ListingRisksAction') . '</h2>';
print '<h2>' . $langs->trans('ListingRisksAction') . ($object->id ? ' ' . $object->ref : ' ' . 'global') . '</h2>';

if ($action != 'presend')
{
Expand Down
2 changes: 1 addition & 1 deletion digiriskelement_listingrisksphoto.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
}

// Document Generation -- Génération des documents
print '<h2>' . $langs->trans('ListingRisksPhoto') . '</h2>';
print '<h2>' . $langs->trans('ListingRisksPhoto') . ($object->id ? ' ' . $object->ref : ' ' . 'global') . '</h2>';

if ($action != 'presend')
{
Expand Down

0 comments on commit 03e0e71

Please sign in to comment.