Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1128 [Dashboard] clean php8 warning #1129

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions class/saturnedashboard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function load_dashboard(?array $moreParams = []): array
*/
public function show_dashboard(?array $moreParams = [])
{
global $conf, $form, $langs, $moduleNameLowerCase, $user;
global $conf, $form, $langs, $moduleNameLowerCase;

$width = DolGraph::getDefaultGraphSizeForStats('width');
$height = DolGraph::getDefaultGraphSizeForStats('height');
Expand All @@ -115,7 +115,7 @@ public function show_dashboard(?array $moreParams = [])
print '<input type="hidden" name="action" value="view">';

$confName = dol_strtoupper($moduleNameLowerCase) . '_DASHBOARD_CONFIG';
$disableWidgetList = json_decode($user->conf->$confName);
$disableWidgetList = json_decode(getDolUserString($confName));
$disableWidgetList = $disableWidgetList->widgets ?? new stdClass();
$dashboardWidgetsArray = [];
if (is_array($dashboards['widgets']) && !empty($dashboards['widgets'])) {
Expand Down Expand Up @@ -179,7 +179,7 @@ public function show_dashboard(?array $moreParams = [])
}
}
$widget .= '</ul>';
if (is_array($dashboardWidget['moreParams']) && (!empty($dashboardWidget['moreParams']))) {
if (!empty($dashboardWidget['moreParams']) && is_array($dashboardWidget['moreParams'])) {
$widget .= '<div class="body__content">';
foreach ($dashboardWidget['moreParams'] as $dashboardWidgetMoreParamsKey => $dashboardWidgetMoreParams) {
switch ($dashboardWidgetMoreParamsKey) {
Expand Down Expand Up @@ -315,8 +315,8 @@ public function show_dashboard(?array $moreParams = [])
$graph->SetHeight($dashboardGraph['height'] ?? $height);
$graph->setShowLegend($dashboardGraph['showlegend'] ?? 2);
$graph->draw($fileName[$uniqueKey], $fileUrl[$uniqueKey]);
print '<div class="' . $dashboardGraph['moreCSS'] . '" id="graph-' . $dashboardGraph['name'] . '">';
print '<div' . (isset($dashboardGraph['moreCSS']) ? 'class="' . $dashboardGraph['moreCSS'] . '"' : '') . 'id="graph-' . $dashboardGraph['name'] . '">';

$downloadCSV = '<div class="flex flex-row justify-end">';
$downloadCSV .= '<input type="hidden" name="graph" value="' . dol_escape_htmltag(json_encode($dashboardGraph, JSON_UNESCAPED_UNICODE)) . '">';
$downloadCSV .= '<button class="wpeo-button no-load button-grey" id="export-csv" data-graph-name="' . dol_sanitizeFileName(dol_strtolower($dashboardGraph['title'])) . '">';
Expand All @@ -328,8 +328,12 @@ public function show_dashboard(?array $moreParams = [])
$downloadCSV .= '</button>';
}
$downloadCSV .= '</div>';
$dashboardGraph['morehtmlright'] .= $downloadCSV;

if (isset($dashboardGraph['morehtmlright'])) {
$dashboardGraph['morehtmlright'] .= $downloadCSV;
} else {
$dashboardGraph['morehtmlright'] = $downloadCSV;
}

print load_fiche_titre($dashboardGraph['title'], $dashboardGraph['morehtmlright'], $dashboardGraph['picto']);
print $graph->show();
print '</div>';
Expand Down Expand Up @@ -362,7 +366,7 @@ public function show_dashboard(?array $moreParams = [])
foreach ($dashboardList['data'] as $dashboardListDatasets) {
print '<tr class="oddeven">';
foreach ($dashboardListDatasets as $key => $dashboardGraphDataset) {
print '<td class="' . ($conf->browser->layout == 'classic' ? 'nowraponall tdoverflowmax200 ' : '') . (($key != 'Ref') ? 'center ' : '') . $dashboardGraphDataset['morecss'] . '"' . $dashboardGraphDataset['moreAttr'] . '>' . $dashboardGraphDataset['value'] . '</td>';
print '<td class="' . ($conf->browser->layout == 'classic' ? 'nowraponall tdoverflowmax200 ' : '') . (($key != 'Ref') ? 'center ' : '') . ($dashboardGraphDataset['morecss'] ?? '') . '"' . ($dashboardGraphDataset['moreAttr'] ?? '') . '>' . $dashboardGraphDataset['value'] . '</td>';
}
print '</tr>';
}
Expand Down
2 changes: 1 addition & 1 deletion class/saturneobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function fetchAll(string $sortorder = '', string $sortfield = '', int $li
foreach ($filter as $key => $value) {
if ($key == 't.rowid') {
$sqlwhere[] = $key . ' = ' . ((int) $value);
} elseif (in_array($this->fields[$key]['type'], ['date', 'datetime', 'timestamp'])) {
} elseif (isset($this->fields[$key]['type']) && in_array($this->fields[$key]['type'], ['date', 'datetime', 'timestamp'])) {
$sqlwhere[] = $key . " = '" . $this->db->idate($value) . "'";
} elseif ($key == 'customsql') {
$sqlwhere[] = $value;
Expand Down
4 changes: 2 additions & 2 deletions class/task/saturnetask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public function __construct($db)
*/
public function load_dashboard($projectId): array
{
global $user, $langs;
global $langs;

$confName = dol_strtoupper($this->module) . '_DASHBOARD_CONFIG';
$dashboardConfig = json_decode($user->conf->$confName);
$dashboardConfig = json_decode(getDolUserString($confName));
$array = ['graphs' => [], 'disabledGraphs' => []];

if (empty($dashboardConfig->graphs->TasksRepartition->hide)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/object.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function saturne_fetch_all_object_type(string $className = '', string $sortorder
foreach ($filter as $key => $value) {
if ($key == 't.rowid') {
$sqlwhere[] = $key . ' = ' . $value;
} elseif (in_array($object->fields[$key]['type'], ['date', 'datetime', 'timestamp'])) {
} elseif (isset($object->fields[$key]['type']) && in_array($object->fields[$key]['type'], ['date', 'datetime', 'timestamp'])) {
$sqlwhere[] = $key .' = \'' . $object->db->idate($value) . '\'';
} elseif ($key == 'customsql') {
$sqlwhere[] = $value;
Expand Down
2 changes: 1 addition & 1 deletion lib/saturne_functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function saturne_check_access($permission, object $object = null, bool $allowExt
}

if (isModEnabled('multicompany')) {
if ($object->id > 0) {
if (!is_null($object) && $object->id > 0) {
if ($object->entity != $conf->entity) {
setEventMessage($langs->trans('ChangeEntityRedirection'), 'warnings');
$urltogo = dol_buildpath('/custom/' . $moduleNameLowerCase . '/' . $moduleNameLowerCase . 'index.php?mainmenu=' . $moduleNameLowerCase, 1);
Expand Down