Merge pull request #24579 from frederic34/fiscalyear
tooltip ajax for Fiscalyear
This commit is contained in:
commit
7c0611f34d
@ -97,7 +97,7 @@ $help_url = "EN:Module_Double_Entry_Accounting";
|
||||
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity";
|
||||
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut as status, f.entity";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
|
||||
$sql .= " WHERE f.entity = ".$conf->entity;
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
@ -137,7 +137,7 @@ if ($result) {
|
||||
print '<td>'.$langs->trans("DateEnd").'</td>';
|
||||
print '<td class="center">'.$langs->trans("NumberOfAccountancyEntries").'</td>';
|
||||
print '<td class="center">'.$langs->trans("NumberOfAccountancyMovements").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Statut").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Status").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
if ($num) {
|
||||
@ -145,6 +145,9 @@ if ($result) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$fiscalyearstatic->id = $obj->rowid;
|
||||
$fiscalyearstatic->date_start = $obj->date_start;
|
||||
$fiscalyearstatic->date_end = $obj->date_end;
|
||||
$fiscalyearstatic->status = $obj->status;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
@ -155,7 +158,7 @@ if ($result) {
|
||||
print '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>';
|
||||
print '<td class="center">'.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).'</td>';
|
||||
print '<td class="center">'.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).'</td>';
|
||||
print '<td class="right">'.$fiscalyearstatic->LibStatut($obj->statut, 5).'</td>';
|
||||
print '<td class="right">'.$fiscalyearstatic->LibStatut($obj->status, 5).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -92,7 +92,17 @@ class Fiscalyear extends CommonObject
|
||||
*/
|
||||
public $datec;
|
||||
|
||||
public $statut; // 0=open, 1=closed
|
||||
/**
|
||||
* @var int status 0=open, 1=closed
|
||||
* @deprecated
|
||||
* @see $status
|
||||
*/
|
||||
public $statut;
|
||||
|
||||
/**
|
||||
* @var int status 0=open, 1=closed
|
||||
*/
|
||||
public $status;
|
||||
|
||||
/**
|
||||
* @var int Entity
|
||||
@ -102,6 +112,9 @@ class Fiscalyear extends CommonObject
|
||||
public $statuts = array();
|
||||
public $statuts_short = array();
|
||||
|
||||
const STATUS_OPEN = 0;
|
||||
const STATUS_CLOSED = 1;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -220,7 +233,7 @@ class Fiscalyear extends CommonObject
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
$sql = "SELECT rowid, label, date_start, date_end, statut";
|
||||
$sql = "SELECT rowid, label, date_start, date_end, statut as status";
|
||||
$sql .= " FROM ".$this->db->prefix()."accounting_fiscalyear";
|
||||
$sql .= " WHERE rowid = ".((int) $id);
|
||||
|
||||
@ -234,7 +247,8 @@ class Fiscalyear extends CommonObject
|
||||
$this->date_start = $this->db->jdate($obj->date_start);
|
||||
$this->date_end = $this->db->jdate($obj->date_end);
|
||||
$this->label = $obj->label;
|
||||
$this->statut = $obj->statut;
|
||||
$this->statut = $obj->status;
|
||||
$this->status = $obj->status;
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
@ -267,6 +281,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->status)) {
|
||||
$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 +329,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 +362,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 +383,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;
|
||||
@ -359,7 +401,7 @@ class Fiscalyear extends CommonObject
|
||||
*/
|
||||
public function getLibStatut($mode = 0)
|
||||
{
|
||||
return $this->LibStatut($this->statut, $mode);
|
||||
return $this->LibStatut($this->status, $mode);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
|
||||
@ -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