Merge pull request #15999 from frederic34/boxdolibarrstat

fix unknown variable
This commit is contained in:
Laurent Destailleur 2021-01-18 15:18:07 +01:00 committed by GitHub
commit 3ff720f8d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr> * Copyright (C) 2015-2021 Frederic France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -62,7 +62,9 @@ class box_dolibarr_state_board extends ModeleBoxes
$this->db = $db; $this->db = $db;
// disable box for such cases // disable box for such cases
if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$this->enabled = 0; // disabled by this option
}
$this->hidden = !($user->rights->societe->lire && empty($user->socid)); $this->hidden = !($user->rights->societe->lire && empty($user->socid));
} }
@ -81,8 +83,7 @@ class box_dolibarr_state_board extends ModeleBoxes
$this->max = $max; $this->max = $max;
$this->info_box_head = array('text' => $langs->trans("DolibarrStateBoard")); $this->info_box_head = array('text' => $langs->trans("DolibarrStateBoard"));
if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) {
{
$hookmanager = new HookManager($this->db); $hookmanager = new HookManager($this->db);
$hookmanager->initHooks(array('index')); $hookmanager->initHooks(array('index'));
$boxstatItems = array(); $boxstatItems = array();
@ -242,18 +243,15 @@ class box_dolibarr_state_board extends ModeleBoxes
); );
$boardloaded = array(); $boardloaded = array();
foreach ($keys as $val) foreach ($keys as $val) {
{ if ($conditions[$val]) {
if ($conditions[$val])
{
$boxstatItem = ''; $boxstatItem = '';
$class = $classes[$val]; $class = $classes[$val];
// Search in cache if load_state_board is already realized // Search in cache if load_state_board is already realized
$classkeyforcache = $class; $classkeyforcache = $class;
if ($classkeyforcache == 'ProductService') $classkeyforcache = 'Product'; // ProductService use same load_state_board than Product if ($classkeyforcache == 'ProductService') $classkeyforcache = 'Product'; // ProductService use same load_state_board than Product
if (!isset($boardloaded[$classkeyforcache]) || !is_object($boardloaded[$classkeyforcache])) if (!isset($boardloaded[$classkeyforcache]) || !is_object($boardloaded[$classkeyforcache])) {
{
include_once $includes[$val]; // Loading a class cost around 1Mb include_once $includes[$val]; // Loading a class cost around 1Mb
$board = new $class($this->db); $board = new $class($this->db);
@ -277,12 +275,10 @@ class box_dolibarr_state_board extends ModeleBoxes
} }
} }
if (!empty($boxstatFromHook) || !empty($boxstatItems)) if (!empty($boxstatFromHook) || !empty($boxstatItems)) {
{
$boxstat .= $boxstatFromHook; $boxstat .= $boxstatFromHook;
if (is_array($boxstatItems) && count($boxstatItems) > 0) if (is_array($boxstatItems) && count($boxstatItems) > 0) {
{
$boxstat .= implode('', $boxstatItems); $boxstat .= implode('', $boxstatItems);
} }
@ -302,12 +298,6 @@ class box_dolibarr_state_board extends ModeleBoxes
'td' => '', 'td' => '',
'textnoformat' => $boxstat 'textnoformat' => $boxstat
); );
} else {
$this->info_box_contents[0][0] = array(
'td' => 'class="nohover center"',
'maxlength' => 500,
'text' => ($this->db->error() . ' sql=' . $sql)
);
} }
} else { } else {
$this->info_box_contents[0][0] = array( $this->info_box_contents[0][0] = array(