tooltip ajax for fiscalyear
This commit is contained in:
parent
56a0b16abc
commit
4eca22afc8
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2020 OScss-Shop <support@oscss-shop.fr>
|
||||
*
|
||||
* Copyright (C) 2023 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -267,6 +267,35 @@ class Fiscalyear extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getTooltipContentArray
|
||||
*
|
||||
* @param array $params ex option, infologin
|
||||
* @since v18
|
||||
* @return array
|
||||
*/
|
||||
public function getTooltipContentArray($params)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$langs->load('compta');
|
||||
|
||||
$datas = [];
|
||||
$datas['picto'] = img_picto('', $this->picto).' <b><u>'.$langs->trans("FiscalPeriod").'</u></b>';
|
||||
if (isset($this->statut)) {
|
||||
$datas['picto'] .= ' '.$this->getLibStatut(5);
|
||||
}
|
||||
$datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||
if (isset($this->date_start)) {
|
||||
$datas['date_start'] .= '<br><b>'.$langs->trans('DateStart').':</b> '.dol_print_date($this->date_start, 'day');
|
||||
}
|
||||
if (isset($this->date_start)) {
|
||||
$datas['date_end'] .= '<br><b>'.$langs->trans('DateEnd').':</b> '.dol_print_date($this->date_end, 'day');;
|
||||
}
|
||||
|
||||
return $datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable link of object (with eventually picto)
|
||||
*
|
||||
@ -286,14 +315,27 @@ class Fiscalyear extends CommonObject
|
||||
if (!empty($conf->dol_no_mouse_hover)) {
|
||||
$notooltip = 1; // Force disable tooltips
|
||||
}
|
||||
|
||||
$result = '';
|
||||
|
||||
$url = DOL_URL_ROOT.'/accountancy/admin/fiscalyear_card.php?id='.$this->id;
|
||||
|
||||
if (empty($user->rights->accounting->fiscalyear->write)) {
|
||||
$option = '';
|
||||
if (!$user->hasRight('accounting', 'fiscalyear', 'write')) {
|
||||
$option = 'nolink';
|
||||
}
|
||||
$result = '';
|
||||
$params = [
|
||||
'id' => $this->id,
|
||||
'objecttype' => $this->element,
|
||||
'option', $option,
|
||||
'nofetch' => 1,
|
||||
];
|
||||
$classfortooltip = 'classfortooltip';
|
||||
$dataparams = '';
|
||||
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
|
||||
$classfortooltip = 'classforajaxtooltip';
|
||||
$dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
|
||||
$label = 'ToComplete';
|
||||
} else {
|
||||
$label = implode($this->getTooltipContentArray($params));
|
||||
}
|
||||
$url = DOL_URL_ROOT.'/accountancy/admin/fiscalyear_card.php?id='.$this->id;
|
||||
|
||||
if ($option !== 'nolink') {
|
||||
// Add param to save lastsearch_values or not
|
||||
@ -306,28 +348,14 @@ class Fiscalyear extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if ($short) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
$label = '';
|
||||
|
||||
if ($user->rights->accounting->fiscalyear->write) {
|
||||
$label = '<u>'.$langs->trans("FiscalPeriod").'</u>';
|
||||
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id;
|
||||
if (isset($this->statut)) {
|
||||
$label .= '<br><b>'.$langs->trans("Status").":</b> ".$this->getLibStatut(5);
|
||||
}
|
||||
}
|
||||
|
||||
$linkclose = '';
|
||||
if (empty($notooltip) && $user->rights->accounting->fiscalyear->write) {
|
||||
if (empty($notooltip) && $user->hasRight('accounting', 'fiscalyear', 'write')) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("FiscalYear");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip"';
|
||||
$linkclose .= $dataparams.' class="'.$classfortooltip.'"';
|
||||
}
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
@ -341,7 +369,7 @@ class Fiscalyear extends CommonObject
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $this->ref;
|
||||
|
||||
@ -11414,6 +11414,10 @@ function getElementProperties($element_type)
|
||||
$classname = 'Websitepage';
|
||||
$module = 'website';
|
||||
$subelement = 'websitepage';
|
||||
} elseif ($element_type == 'fiscalyear') {
|
||||
$classpath = 'core/class';
|
||||
$module = 'accounting';
|
||||
$subelement = 'fiscalyear';
|
||||
}
|
||||
|
||||
if (empty($classfile)) {
|
||||
|
||||
@ -509,6 +509,11 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
|
||||
if ($subfeature == 'user' && $user->id == $objectid) {
|
||||
continue; // A user can always read its own card
|
||||
}
|
||||
if ($subfeature == 'fiscalyear' && $user->hasRight('accounting', 'fiscalyear', 'write')) {
|
||||
// only one right for fiscalyear
|
||||
$tmpreadok = 1;
|
||||
continue;
|
||||
}
|
||||
if (!empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) {
|
||||
$tmpreadok = 0;
|
||||
} elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user