dolibarr/htdocs/core/customreports.php

1374 lines
57 KiB
PHP
Raw Permalink Normal View History

2020-02-07 09:58:17 +00:00
<?php
/* Copyright (C) 2020-2024 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
2020-02-07 09:58:17 +00:00
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2022-09-07 18:21:01 +00:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2020-02-07 09:58:17 +00:00
*/
/**
2024-02-26 17:06:35 +00:00
* \file htdocs/core/customreports.php
* \ingroup core
* \brief Page to make custom reports. Page can also be used alone or as a tab among other tabs of an object
*
* To include this tool into another PHP page:
2025-07-29 09:04:32 +00:00
*
2024-02-26 17:06:35 +00:00
* define('USE_CUSTOM_REPORT_AS_INCLUDE', 1);
2024-03-17 18:23:25 +00:00
* define('MAIN_DO_NOT_USE_JQUERY_MULTISELECT', 1);
2025-07-29 09:04:32 +00:00
* define('MAIN_CUSTOM_REPORT_KEEP_GRAPH_ONLY', 1); // TODO Use a variable
2024-03-17 18:23:25 +00:00
* $SHOWLEGEND = 0;
2026-03-26 01:16:35 +00:00
* $search_xaxis = array('t.columnx');
* $search_yaxis = array('t.columny'); // for grid ???
* $search_measures = array('t.count');
* $search_groupby = array('t.column2');
2024-03-17 18:23:25 +00:00
* $customreportkey='abc';
2024-02-26 17:06:35 +00:00
* include DOL_DOCUMENT_ROOT.'/core/customreports.php';
2020-02-07 09:58:17 +00:00
*/
2024-02-18 13:27:15 +00:00
2025-01-14 21:05:08 +00:00
/**
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 22:53:20 +00:00
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
2025-02-22 12:57:07 +00:00
*
2025-07-29 09:04:32 +00:00
* @var ?int[] $toselect Items selected on page, only used to see if not empty here
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 22:53:20 +00:00
*/
'
@phan-var-force ?int[] $toselect
';
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 22:53:20 +00:00
2025-01-05 14:50:20 +00:00
// Initialise values
$tabfamily = null;
2025-01-05 17:12:36 +00:00
$objecttype = null;
2025-01-05 14:50:20 +00:00
2021-04-02 11:31:03 +00:00
if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) {
require '../main.inc.php';
// Get parameters
2023-12-04 11:07:53 +00:00
$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
2024-02-26 19:39:46 +00:00
$mode = GETPOST('mode', 'alpha');
$objecttype = (string) GETPOST('objecttype', 'aZ09arobase');
$tabfamily = GETPOST('tabfamily', 'aZ09');
2026-03-25 14:28:41 +00:00
$search_measures = GETPOST('search_measures', 'array:alphanohtml');
2020-03-06 16:13:51 +00:00
2021-02-23 21:03:23 +00:00
if (GETPOST('search_xaxis', 'alpha') && GETPOST('search_xaxis', 'alpha') != '-1') {
$search_xaxis = array(GETPOST('search_xaxis', 'alpha'));
} else {
$search_xaxis = array();
2021-02-23 21:03:23 +00:00
}
if (GETPOST('search_groupby', 'alpha') && GETPOST('search_groupby', 'alpha') != '-1') {
$search_groupby = array(GETPOST('search_groupby', 'alpha'));
} else {
$search_groupby = array();
2021-02-23 21:03:23 +00:00
}
'@phan-var-force string[] $search_groupby';
2026-03-25 14:28:41 +00:00
$search_yaxis = GETPOST('search_yaxis', 'array:alphanohtml');
2025-01-05 17:12:36 +00:00
$search_graph = (string) GETPOST('search_graph', 'restricthtml');
2026-03-26 00:53:08 +00:00
/**
* Sanitize key
*
* @param string $value Value
* @return string Sanitized value
*/
function sanititzekey($value)
{
return preg_replace('/[^a-z0-9\._\-]+/', '', $value);
}
$sanitized_search_measures = array_map('sanititzekey', $search_measures);
$sanitized_search_xaxis = array_map('sanititzekey', $search_xaxis);
$sanitized_search_yaxis = array_map('sanititzekey', $search_yaxis);
$sanitized_search_groupby = array_map('sanititzekey', $search_groupby);
2026-03-25 14:28:41 +00:00
// Load variable for pagination
2024-03-16 10:41:00 +00:00
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
2020-09-18 15:13:01 +00:00
$sortfield = GETPOST('sortfield', 'aZ09comma');
2020-09-17 12:31:25 +00:00
$sortorder = GETPOST('sortorder', 'aZ09comma');
2024-03-01 00:52:40 +00:00
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
2021-02-23 21:03:23 +00:00
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
2024-02-26 17:06:35 +00:00
$object = null;
} else {
2025-02-22 12:57:07 +00:00
// When included into a main page
/**
* @var ?int $SHOWLEGEND Show legend or not
* @var string $customreportkey Custom report key
* @var ?string $customsql Custom SQL
* @var ?string[] $sanitized_search_groupby Array with the third dimension
* @var int $page
* @var string $sortfield
* @var string $sortorder
*/
'
@phan-var-force int<0,1> $SHOWLEGEND
@phan-var-force string $customreportkey
@phan-var-force ?string $customsql
@phan-var-force ?string[] $sanitized_search_groupby Array with the third dimension
@phan-var-force int $page
@phan-var-force string $sortfield
@phan-var-force string $sortorder
';
// $sanitized_search_measures, $sanitized_search_xaxis or $sanitized_search_yaxis may have been defined by the parent.
2024-02-26 17:06:35 +00:00
2024-02-26 18:08:00 +00:00
if (empty($user) || empty($user->id)) {
print 'Page is called as an include but $user and its permission loaded with loadRights() are not defined. We stop here.';
2025-09-12 00:29:23 +00:00
exit(1);
2024-02-26 18:08:00 +00:00
}
2024-02-26 17:06:35 +00:00
if (empty($object)) {
print 'Page is called as an include but $object is not defined. We stop here.';
2025-09-12 00:29:23 +00:00
exit(1);
2024-02-26 17:06:35 +00:00
}
2020-02-07 09:58:17 +00:00
}
// In customreport context, we force the protection to avoid forging of criteria including bind SQL injection
global $dolibarr_allow_unsecured_select_in_extrafields_filter;
$dolibarr_allow_unsecured_select_in_extrafields_filter = 0;
2024-02-26 19:39:46 +00:00
if (empty($mode)) {
$mode = 'graph';
}
if (!isset($sanitized_search_measures)) {
$sanitized_search_measures = array(0 => 't.count');
2024-02-26 19:11:55 +00:00
}
if (!isset($sanitized_search_xaxis)) {
2025-01-05 17:12:36 +00:00
// Ensure value is set and not null.
$sanitized_search_xaxis = array();
2025-01-05 17:12:36 +00:00
}
if (!isset($sanitized_search_yaxis)) {
2026-03-26 01:16:35 +00:00
// Ensure value is set and not null.
$sanitized_search_yaxis = array();
2026-03-26 01:16:35 +00:00
}
if (!isset($sanitized_search_groupby)) {
2026-03-26 01:16:35 +00:00
// Ensure value is set and not null.
$sanitized_search_groupby = array();
2026-03-26 01:16:35 +00:00
}
2025-01-05 17:12:36 +00:00
if (!isset($search_graph)) {
// Ensure value is set and not null
$search_graph = '';
}
2024-02-26 18:08:00 +00:00
if (!empty($object)) {
$objecttype = $object->element.($object->module ? '@'.$object->module : '');
}
2025-07-10 15:50:34 +00:00
if ((!is_string($objecttype) || empty($objecttype)) && isModEnabled('societe')) {
2024-02-26 18:08:00 +00:00
$objecttype = 'thirdparty';
}
2025-01-05 17:12:36 +00:00
'@phan-var-force string $objecttype'; // Help phan that suggests $objecttype can be null
2024-02-26 18:08:00 +00:00
2024-02-26 17:06:35 +00:00
require_once DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php";
require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php";
2020-03-06 16:13:51 +00:00
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
require_once DOL_DOCUMENT_ROOT."/core/lib/company.lib.php";
2024-02-26 17:06:35 +00:00
require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
2024-02-29 12:36:21 +00:00
require_once DOL_DOCUMENT_ROOT."/core/lib/customreports.lib.php";
2020-03-06 16:13:51 +00:00
require_once DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php";
require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php";
require_once DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php";
// Load traductions files requiredby by page
2020-03-08 19:10:31 +00:00
$langs->loadLangs(array("companies", "other", "exports", "sendings"));
2020-02-07 09:58:17 +00:00
$extrafields = new ExtraFields($db);
$hookmanager->initHooks(array('customreport')); // Note that conf->hooks_modules contains array
$title = '';
$picto = '';
$errormessage = null;
$keyforlabeloffield = null;
2020-02-07 09:58:17 +00:00
$head = array();
$ObjectClassName = '';
2020-02-08 16:46:41 +00:00
// Objects available by default
2020-02-07 09:58:17 +00:00
$arrayoftype = array(
'thirdparty' => array('label' => 'ThirdParties', 'picto' => 'company', 'ObjectClassName' => 'Societe', 'enabled' => isModEnabled('societe'), 'ClassPath' => "/societe/class/societe.class.php", 'langs' => 'companies'),
2024-02-27 15:43:04 +00:00
'contact' => array('label' => 'Contacts', 'picto' => 'contact', 'ObjectClassName' => 'Contact', 'enabled' => isModEnabled('societe'), 'ClassPath' => "/contact/class/contact.class.php"),
'proposal' => array('label' => 'Proposals', 'picto' => 'proposal', 'ObjectClassName' => 'Propal', 'enabled' => isModEnabled('propal'), 'ClassPath' => "/comm/propal/class/propal.class.php", 'langs' => 'propal'),
'proposaldet' => array('label' => 'ProposalLines', 'picto' => 'proposal', 'ObjectClassName' => 'PropaleLigne', 'enabled' => isModEnabled('propal'), 'ClassPath' => "/comm/propal/class/propaleligne.class.php", 'langs' => 'propal'),
'order' => array('label' => 'Orders', 'picto' => 'order', 'ObjectClassName' => 'Commande', 'enabled' => isModEnabled('order'), 'ClassPath' => "/commande/class/commande.class.php", 'langs' => 'orders'),
'orderdet' => array('label' => 'SaleOrderLines', 'picto' => 'order', 'ObjectClassName' => 'OrderLine', 'enabled' => isModEnabled('order'), 'ClassPath' => "/commande/class/orderline.class.php", 'langs' => 'orders'),
'invoice' => array('label' => 'Invoices', 'picto' => 'bill', 'ObjectClassName' => 'Facture', 'enabled' => isModEnabled('invoice'), 'ClassPath' => "/compta/facture/class/facture.class.php", 'langs' => 'bills'),
'invoice_template' => array('label' => 'PredefinedInvoices', 'picto' => 'bill', 'ObjectClassName' => 'FactureRec', 'enabled' => isModEnabled('invoice'), 'ClassPath' => "/compta/facture/class/facture-rec.class.php", 'langs' => 'bills'),
'contract' => array('label' => 'Contracts', 'picto' => 'contract', 'ObjectClassName' => 'Contrat', 'enabled' => isModEnabled('contract'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs' => 'contracts'),
'contractdet' => array('label' => 'ContractLines', 'picto' => 'contract', 'ObjectClassName' => 'ContratLigne', 'enabled' => isModEnabled('contract'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs' => 'contracts'),
2024-02-27 15:43:04 +00:00
'bom' => array('label' => 'BOM', 'picto' => 'bom', 'ObjectClassName' => 'Bom', 'enabled' => isModEnabled('bom')),
'mrp' => array('label' => 'MO', 'picto' => 'mrp', 'ObjectClassName' => 'Mo', 'enabled' => isModEnabled('mrp'), 'ClassPath' => "/mrp/class/mo.class.php"),
'ticket' => array('label' => 'Ticket', 'picto' => 'ticket', 'ObjectClassName' => 'Ticket', 'enabled' => isModEnabled('ticket')),
2025-07-23 14:31:09 +00:00
'member' => array('langs' => 'members', 'label' => 'Adherent', 'picto' => 'member', 'ObjectClassName' => 'Adherent', 'enabled' => isModEnabled('member'), 'ClassPath' => "/adherents/class/adherent.class.php"),
'cotisation' => array('langs' => 'members', 'label' => 'Subscriptions', 'picto' => 'member', 'ObjectClassName' => 'Subscription', 'enabled' => isModEnabled('member'), 'ClassPath' => "/adherents/class/subscription.class.php"),
2020-02-07 09:58:17 +00:00
);
2024-02-25 22:49:20 +00:00
2020-02-28 23:11:19 +00:00
// Complete $arrayoftype by external modules
2024-02-27 15:43:04 +00:00
$parameters = array('objecttype' => $objecttype, 'tabfamily' => $tabfamily);
2025-01-05 17:12:36 +00:00
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable
2020-02-07 09:58:17 +00:00
$reshook = $hookmanager->executeHooks('loadDataForCustomReports', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2021-02-23 21:03:23 +00:00
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} elseif (is_array($hookmanager->resArray)) {
if (!empty($hookmanager->resArray['title'])) { // Add entries for tabs
2020-02-07 09:58:17 +00:00
$title = $hookmanager->resArray['title'];
}
if (!empty($hookmanager->resArray['picto'])) { // Add entries for tabs
2020-02-07 09:58:17 +00:00
$picto = $hookmanager->resArray['picto'];
}
if (!empty($hookmanager->resArray['head'])) { // Add entries for tabs
2020-02-07 09:58:17 +00:00
$head = array_merge($head, $hookmanager->resArray['head']);
}
if (!empty($hookmanager->resArray['arrayoftype'])) { // Add entries from hook
foreach ($hookmanager->resArray['arrayoftype'] as $key => $val) {
$arrayoftype[$key] = $val;
}
2020-02-07 09:58:17 +00:00
}
}
2024-02-17 03:07:34 +00:00
// Load the main $object for statistics
2020-02-07 09:58:17 +00:00
if ($objecttype) {
try {
if (!empty($arrayoftype[$objecttype]['ClassPath'])) {
2024-02-16 23:10:41 +00:00
$fileforclass = $arrayoftype[$objecttype]['ClassPath'];
} else {
2024-02-16 23:10:41 +00:00
$fileforclass = "/".$objecttype."/class/".$objecttype.".class.php";
}
2025-01-05 17:12:36 +00:00
$ObjectClassName = null;
2025-01-05 17:12:36 +00:00
if ($fileforclass !== null) {
dol_include_once($fileforclass);
2025-07-21 16:15:43 +00:00
2025-01-05 17:12:36 +00:00
$ObjectClassName = $arrayoftype[$objecttype]['ObjectClassName'];
}
2024-02-26 18:08:00 +00:00
if (!empty($ObjectClassName)) {
if (class_exists($ObjectClassName)) {
$object = new $ObjectClassName($db);
} else {
print 'Failed to load class for type '.$objecttype.'. Class file found but Class object named '.$ObjectClassName.' not found.';
}
} else {
2024-02-26 18:08:00 +00:00
print 'Failed to load class for type '.$objecttype.'. Class file name is unknown.';
}
} catch (Exception $e) {
print 'Failed to load class for type '.$objecttype.'. Class path not found.';
}
2020-02-07 09:58:17 +00:00
}
2024-03-18 21:53:46 +00:00
'@phan-var-force CommonObject $object';
2020-02-07 10:53:09 +00:00
// Security check
2026-03-07 19:07:24 +00:00
//$socid = 0;
2021-02-23 21:03:23 +00:00
if ($user->socid > 0) { // Protection if external user
2020-02-07 10:53:09 +00:00
//$socid = $user->socid;
accessforbidden('Access forbidden to external users');
2020-02-07 10:53:09 +00:00
}
2020-02-07 09:58:17 +00:00
// Fetch optionals attributes and labels
2023-05-23 22:19:27 +00:00
$extrafields->fetch_name_optionals_label('all'); // We load all extrafields definitions for all objects
2020-02-07 09:58:17 +00:00
//$extrafields->fetch_name_optionals_label($object->table_element_line);
if (!empty($object->table_element)) {
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
} else {
$search_array_options = array();
}
2020-02-07 09:58:17 +00:00
$search_component_params = array('');
2024-02-16 00:19:53 +00:00
$search_component_params_hidden = trim(GETPOST('search_component_params_hidden', 'alphanohtml'));
$search_component_params_input = trim(GETPOST('search_component_params_input', 'alphanohtml'));
//var_dump($search_component_params_hidden);
//var_dump($search_component_params_input);
2020-02-07 09:58:17 +00:00
2024-02-17 03:07:34 +00:00
// If string is not an universal filter string, we try to convert it into universal filter syntax string
$errorstr = '';
2024-02-18 12:39:25 +00:00
forgeSQLFromUniversalSearchCriteria($search_component_params_input, $errorstr); // Try conversion UFS->SQL
2024-02-17 03:07:34 +00:00
//var_dump($errorstr);
if ($errorstr) {
$value = $search_component_params_input;
$value = preg_replace('/([a-z\.]+)\s*([!<>=]+|in|notin|like|notlike)\s*/', '\1:\2:', $value); // Clean string 'x < 10' into 'x:<:10' so we can then explode on space to get all AND tests to do
$value = preg_replace('/\s*\|\s*/', '|', $value);
//var_dump($value);
$crits = explode(' ', trim($value)); // the string after the name of the field. Explode on each AND
$res = '';
$i1 = 0; // count the nb of and criteria added (all fields / criteria)
foreach ($crits as $crit) { // Loop on each AND criteria
$crit = trim($crit);
$i2 = 0; // count the nb of valid criteria added for this first criteria
$newres = '';
$tmpcrits = explode('|', $crit);
$i3 = 0; // count the nb of valid criteria added for this current field
foreach ($tmpcrits as $tmpcrit) {
if ($tmpcrit !== '0' && empty($tmpcrit)) {
continue;
}
$tmpcrit = trim($tmpcrit);
//var_dump($tmpcrit);
$errorstr = '';
$parenthesislevel = 0;
$rescheckfilter = dolCheckFilters($tmpcrit, $errorstr, $parenthesislevel);
if ($rescheckfilter) {
while ($parenthesislevel > 0) {
$tmpcrit = preg_replace('/^\(/', '', preg_replace('/\)$/', '', $tmpcrit));
$parenthesislevel--;
}
}
$field = preg_replace('/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:).*$/', '', $tmpcrit); // the name of the field
$tmpcrit = preg_replace('/^.*(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/', '\1', $tmpcrit); // the condition after the name of the field
//var_dump($field); var_dump($tmpcrit); var_dump($i3);
$newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
$operator = '=';
$newcrit = preg_replace('/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/', '', $tmpcrit);
//var_dump($newcrit);
$reg = array();
preg_match('/:([!<>=\s]+|in|notin|like|notlike):/', $tmpcrit, $reg);
if (!empty($reg[1])) {
$operator = $reg[1];
}
if ($newcrit != '') {
if (!preg_match('/^\'[^\']*\'$/', $newcrit)) {
$numnewcrit = price2num($newcrit);
$newres .= '('.$field.':'.$operator.':'.((float) $numnewcrit).')';
} else {
$newres .= '('.$field.':'.$operator.":".((string) $newcrit).')';
}
$i3++; // a criteria was added to string
}
}
$i2++; // a criteria for 1 more field was added to string
if ($newres) {
$res = $res.($res ? ' AND ' : '').($i2 > 1 ? '(' : '').$newres.($i2 > 1 ? ')' : '');
}
$i1++;
}
$res = "(".$res.")";
//var_dump($res);exit;
$search_component_params_input = $res;
}
2024-02-16 00:19:53 +00:00
$arrayofandtagshidden = dolForgeExplodeAnd($search_component_params_hidden);
$arrayofandtagsinput = dolForgeExplodeAnd($search_component_params_input);
$search_component_params_hidden = implode(' AND ', array_merge($arrayofandtagshidden, $arrayofandtagsinput));
//var_dump($search_component_params_hidden);
2022-02-15 10:03:48 +00:00
$MAXUNIQUEVALFORGROUP = 20;
$MAXMEASURESINBARGRAPH = 20;
2024-02-29 12:03:04 +00:00
$SHOWLEGEND = (isset($SHOWLEGEND) ? $SHOWLEGEND : 1);
2020-03-06 16:13:51 +00:00
$YYYY = substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1);
$MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1);
$DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1);
$HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1);
$MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1);
$SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
2025-01-14 21:05:08 +00:00
$arrayoffilterfields = array();
2022-02-21 18:09:26 +00:00
$arrayofmesures = array();
$arrayofxaxis = array();
$arrayofgroupby = array();
$arrayofyaxis = array();
$arrayofvaluesforgroupby = array();
2026-03-07 19:07:24 +00:00
$features = '';
if (!empty($object->element)) {
$features = $object->element;
} else {
$features = '';
}
2022-02-15 10:03:48 +00:00
if (!empty($object->element_for_permission)) {
$features = $object->element_for_permission;
2024-02-16 23:10:41 +00:00
} else {
Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests (#30544) * Remove PhanPluginDuplicateExpressionAssignmentOperation from baseline * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * fixup! Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-08-07 00:53:45 +00:00
$features .= (empty($object->module) ? '' : '@'.$object->module);
2022-02-15 10:03:48 +00:00
}
2026-03-07 19:07:24 +00:00
// $arrayoftype contains several features
// Test on permission can be done on a given selected feature only
// Security check (do not stop here, get only result to show message later)
$resultcheck = restrictedArea($user, $features, 0, '', '', 'fk_soc', 'rowid', 0, 1);
2022-01-03 03:47:17 +00:00
2020-02-07 09:58:17 +00:00
/*
* Actions
*/
2022-01-03 03:47:17 +00:00
// None
2020-02-07 09:58:17 +00:00
/*
* View
*/
$form = new Form($db);
2020-03-06 16:13:51 +00:00
$formother = new FormOther($db);
2020-02-07 09:58:17 +00:00
2021-04-02 11:31:03 +00:00
if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) {
llxHeader('', $langs->transnoentitiesnoconv('CustomReports'), '');
2020-02-07 09:58:17 +00:00
2024-02-25 22:49:20 +00:00
if (empty($head)) {
print dol_get_fiche_head($head, 'customreports', $title, -2, $picto);
} else {
print dol_get_fiche_head($head, 'customreports', $title, -1, $picto);
}
2020-02-08 16:46:41 +00:00
}
2020-02-07 09:58:17 +00:00
2025-07-10 14:34:06 +00:00
// Define $newarrayoftype that is array of object available for report
$newarrayoftype = array();
foreach ($arrayoftype as $key => $val) {
2025-01-05 17:12:36 +00:00
if (dol_eval((string) $val['enabled'], 1, 1, '1')) {
$newarrayoftype[$key] = $arrayoftype[$key];
}
2022-07-16 00:23:30 +00:00
if (!empty($val['langs'])) {
$langs->load($val['langs']);
}
}
2025-01-14 21:05:08 +00:00
$count = 0;
2025-01-05 17:12:36 +00:00
$label = '';
if (array_key_exists($objecttype, $newarrayoftype)) {
$label = $langs->trans($newarrayoftype[$objecttype]['label']);
}
$arrayoffilterfields = fillArrayOfFilterFields($object, 't', $label, $arrayoffilterfields, 0, $count);
2025-01-14 21:05:08 +00:00
$arrayoffilterfields = dol_sort_array($arrayoffilterfields, 'position', 'asc', 0, 0, 1);
$count = 0;
2025-01-05 17:12:36 +00:00
$arrayofmesures = fillArrayOfMeasures($object, 't', $label, $arrayofmesures, 0, $count);
2022-03-22 12:23:16 +00:00
$arrayofmesures = dol_sort_array($arrayofmesures, 'position', 'asc', 0, 0, 1);
$count = 0;
2025-01-05 14:50:20 +00:00
$arrayofxaxis = fillArrayOfXAxis($object, 't', $label, $arrayofxaxis, 0, $count);
$arrayofxaxis = dol_sort_array($arrayofxaxis, 'position', 'asc', 0, 0, 1);
$count = 0;
2025-01-05 14:50:20 +00:00
$arrayofgroupby = fillArrayOfGroupBy($object, 't', $label, $arrayofgroupby, 0, $count);
$arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1);
// Check parameters
if ($action == 'viewgraph') {
if (!count($sanitized_search_measures)) {
setEventMessages($langs->trans("AtLeastOneMeasureIsRequired"), null, 'warnings');
} elseif ($mode == 'graph' && is_array($sanitized_search_xaxis) && count($sanitized_search_xaxis) > 1) {
setEventMessages($langs->trans("OnlyOneFieldForXAxisIsPossible"), null, 'warnings');
$sanitized_search_xaxis = array(0 => $sanitized_search_xaxis[0]);
}
if (count($sanitized_search_groupby) >= 2) {
setEventMessages($langs->trans("ErrorOnlyOneFieldForGroupByIsPossible"), null, 'warnings');
$sanitized_search_groupby = array(0 => $sanitized_search_groupby[0]);
}
if (!count($sanitized_search_xaxis)) {
setEventMessages($langs->trans("AtLeastOneXAxisIsRequired"), null, 'warnings');
} elseif ($mode == 'graph' && $search_graph == 'bars' && count($sanitized_search_measures) > $MAXMEASURESINBARGRAPH) {
$langs->load("errors");
setEventMessages($langs->trans("GraphInBarsAreLimitedToNMeasures", $MAXMEASURESINBARGRAPH), null, 'warnings');
$search_graph = 'lines';
}
}
2020-02-07 09:58:17 +00:00
2020-03-12 10:09:18 +00:00
// Get all possible values of fields when a 'group by' is set, and save this into $arrayofvaluesforgroupby
2020-04-12 23:10:35 +00:00
// $arrayofvaluesforgroupby will be used to forge lael of each grouped series
if (count($sanitized_search_groupby)) {
$fieldtocount = '';
foreach ($sanitized_search_groupby as $gkey => $sanitized_gval) {
$gvalwithoutprefix = preg_replace('/^[a-z]+\./i', '', $sanitized_gval);
$gvalsanitized = preg_replace('/[^a-z0-9\._\-]+/i', '', $sanitized_gval);
$sanitizedfieldtocount = '';
if (preg_match('/\-year$/', $gvalsanitized)) {
$tmpval = preg_replace('/\-year$/', '', $gvalsanitized);
$sanitizedfieldtocount .= 'DATE_FORMAT('.$tmpval.", '%Y')";
} elseif (preg_match('/\-month$/', $gvalsanitized)) {
$tmpval = preg_replace('/\-month$/', '', $gvalsanitized);
$sanitizedfieldtocount .= 'DATE_FORMAT('.$tmpval.", '%Y-%m')";
} elseif (preg_match('/\-day$/', $gvalsanitized)) {
$tmpval = preg_replace('/\-day$/', '', $gvalsanitized);
$sanitizedfieldtocount .= 'DATE_FORMAT('.$tmpval.", '%Y-%m-%d')";
} else {
$sanitizedfieldtocount = $gvalsanitized;
}
$fieldtocount = $sanitizedfieldtocount;
$sql = "SELECT DISTINCT ".$sanitizedfieldtocount." as val"; // $fieldtocount has been sanitized by previous lines as we can't use db->sanitize()
2022-03-22 12:23:16 +00:00
2023-05-24 01:18:00 +00:00
if (strpos($fieldtocount, 'te') === 0) {
$tabletouse = $object->table_element;
$tablealiastouse = 'te';
if (!empty($arrayofgroupby[$sanitized_gval])) {
$tmpval = explode('.', $sanitized_gval);
$tabletouse = $arrayofgroupby[$sanitized_gval]['table'];
2023-05-24 01:18:00 +00:00
$tablealiastouse = $tmpval[0];
}
//var_dump($tablealiastouse);exit;
//$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te";
$sql .= " FROM ".MAIN_DB_PREFIX.$tabletouse."_extrafields as ".$tablealiastouse;
} else {
2022-03-22 12:23:16 +00:00
$tabletouse = $object->table_element;
$tablealiastouse = 't';
if (!empty($arrayofgroupby[$sanitized_gval])) {
$tmpval = explode('.', $sanitized_gval);
$tabletouse = $arrayofgroupby[$sanitized_gval]['table'];
2022-03-22 12:23:16 +00:00
$tablealiastouse = $tmpval[0];
}
2022-03-22 12:37:33 +00:00
$sql .= " FROM ".MAIN_DB_PREFIX.$tabletouse." as ".$tablealiastouse;
}
2022-01-03 03:47:17 +00:00
// Add a where here keeping only the criteria on $tabletouse
2024-02-16 01:11:04 +00:00
/* TODO
if ($search_component_params_hidden) {
2022-01-03 03:47:17 +00:00
$errormessage = '';
2024-02-16 01:11:04 +00:00
$sql .= forgeSQLFromUniversalSearchCriteria($search_component_params_hidden, $errormessage);
}
*/
2022-03-22 12:37:33 +00:00
$sql .= " LIMIT ".((int) ($MAXUNIQUEVALFORGROUP + 1));
//print $sql;
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
}
while ($obj = $db->fetch_object($resql)) {
if (is_null($obj->val)) {
$keytouse = '__NULL__';
$valuetranslated = $langs->transnoentitiesnoconv("NotDefined");
2020-05-21 13:05:19 +00:00
} elseif ($obj->val === '') {
$keytouse = '';
$valuetranslated = $langs->transnoentitiesnoconv("Empty");
2020-05-21 13:05:19 +00:00
} else {
$keytouse = (string) $obj->val;
$valuetranslated = $obj->val;
}
2020-04-12 23:10:35 +00:00
$regs = array();
if (isset($object->fields[$gvalwithoutprefix])) {
if (!empty($object->fields[$gvalwithoutprefix]['arrayofkeyval'])) {
$valuetranslated = $object->fields[$gvalwithoutprefix]['arrayofkeyval'][$obj->val];
if (is_null($valuetranslated)) {
$valuetranslated = $langs->transnoentitiesnoconv("UndefinedKey");
}
$valuetranslated = $langs->trans($valuetranslated);
} elseif (preg_match('/integer:([^:]+):([^:]+)$/', $object->fields[$gvalwithoutprefix]['type'], $regs)) {
$classname = $regs[1];
$classpath = $regs[2];
dol_include_once($classpath);
if (class_exists($classname)) {
$tmpobject = new $classname($db);
'@phan-var-force CommonObject $tmpobject';
$tmpobject->fetch($obj->val);
foreach ($tmpobject->fields as $fieldkey => $field) {
if ($field['showoncombobox']) {
$valuetranslated = $tmpobject->$fieldkey;
//if ($valuetranslated == '-') $valuetranslated = $langs->transnoentitiesnoconv("Unknown")
break;
}
2020-04-12 23:10:35 +00:00
}
//$valuetranslated = $tmpobject->ref.'eee';
2020-04-12 23:10:35 +00:00
}
}
}
$arrayofvaluesforgroupby['g_'.$gkey][$keytouse] = $valuetranslated;
}
2022-03-22 12:23:16 +00:00
// Add also the possible NULL value if field is a parent field that is not a strict join
$tmpfield = explode('.', $sanitized_gval);
if ($tmpfield[0] != 't' || (isset($object->fields[$tmpfield[1]]) && is_array($object->fields[$tmpfield[1]]) && empty($object->fields[$tmpfield[1]]['notnull']))) {
dol_syslog("The group by field ".$sanitized_gval." may be null (because field is null or it is a left join), so we add __NULL__ entry in list of possible values");
//var_dump($sanitized_gval); var_dump($object->fields);
2022-03-22 12:23:16 +00:00
$arrayofvaluesforgroupby['g_'.$gkey]['__NULL__'] = $langs->transnoentitiesnoconv("NotDefined");
}
2024-02-22 01:36:21 +00:00
if (is_array($arrayofvaluesforgroupby['g_'.$gkey])) {
asort($arrayofvaluesforgroupby['g_'.$gkey]);
}
2022-03-22 12:23:16 +00:00
// Add a protection/error to refuse the request if number of differentr values for the group by is higher than $MAXUNIQUEVALFORGROUP
2024-02-22 01:36:21 +00:00
if (is_array($arrayofvaluesforgroupby['g_'.$gkey]) && count($arrayofvaluesforgroupby['g_'.$gkey]) > $MAXUNIQUEVALFORGROUP) {
$langs->load("errors");
2023-05-24 01:18:00 +00:00
if (strpos($fieldtocount, 'te') === 0) { // This is a field of an extrafield
//if (!empty($extrafields->attributes[$object->table_element]['langfile'][$gvalwithoutprefix])) {
// $langs->load($extrafields->attributes[$object->table_element]['langfile'][$gvalwithoutprefix]);
//}
$keyforlabeloffield = $extrafields->attributes[$object->table_element]['label'][$gvalwithoutprefix];
2022-08-23 00:31:38 +00:00
$labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
} elseif (strpos($fieldtocount, 't__') === 0) { // This is a field of a foreign key
$reg = array();
if (preg_match('/^(.*)\.(.*)/', $gvalwithoutprefix, $reg)) {
2023-05-24 01:18:00 +00:00
/*
2022-08-23 00:31:38 +00:00
$gvalwithoutprefix = preg_replace('/\..*$/', '', $gvalwithoutprefix);
2023-05-24 01:18:00 +00:00
$gvalwithoutprefix = preg_replace('/^t__/', '', $gvalwithoutprefix);
2022-08-23 00:31:38 +00:00
$keyforlabeloffield = $object->fields[$gvalwithoutprefix]['label'];
$labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield).'-'.$reg[2];
2023-05-24 01:18:00 +00:00
*/
$labeloffield = $arrayofgroupby[$fieldtocount]['labelnohtml'];
2022-08-23 00:31:38 +00:00
} else {
2025-01-05 14:50:20 +00:00
$labeloffield = 'FK_ISSUE'; // $langs->transnoentitiesnoconv($keyforlabeloffield);
2022-08-23 00:31:38 +00:00
}
} else { // This is a common field
$reg = array();
if (preg_match('/^(.*)\-(year|month|day)/', $gvalwithoutprefix, $reg)) {
$gvalwithoutprefix = preg_replace('/\-(year|month|day)/', '', $gvalwithoutprefix);
$keyforlabeloffield = $object->fields[$gvalwithoutprefix]['label'];
$labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield).'-'.$reg[2];
} else {
$keyforlabeloffield = $object->fields[$gvalwithoutprefix]['label'];
$labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
}
}
2024-11-04 13:59:22 +00:00
//var_dump($labeloffield);
2025-01-05 17:12:36 +00:00
setEventMessages($langs->transnoentitiesnoconv("ErrorTooManyDifferentValueForSelectedGroupBy", (string) $MAXUNIQUEVALFORGROUP, (string) $labeloffield), null, 'warnings');
$sanitized_search_groupby = array();
}
$db->free($resql);
}
}
//var_dump($arrayofvaluesforgroupby);exit;
2026-03-07 19:07:24 +00:00
if (!$resultcheck) {
print '<div class="error">';
print $langs->trans("NotEnoughPermissions");
print '</div>';
}
2025-07-29 09:04:32 +00:00
//$tmparray = dol_getdate(dol_now());
//$endyear = $tmparray['year'];
//$endmonth = $tmparray['mon'];
//$datelastday = dol_get_last_day($endyear, $endmonth, 1);
//$startyear = $endyear - 2;
2020-02-07 09:58:17 +00:00
$param = '';
2024-02-26 19:39:46 +00:00
if (!defined('MAIN_CUSTOM_REPORT_KEEP_GRAPH_ONLY')) {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" autocomplete="off">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="viewgraph">';
2025-01-05 14:50:20 +00:00
print '<input type="hidden" name="tabfamily" value="'.(string) $tabfamily.'">';
2022-01-03 03:47:17 +00:00
2024-02-26 19:39:46 +00:00
$viewmode = '';
2022-01-03 03:47:17 +00:00
2024-02-26 19:39:46 +00:00
$viewmode .= '<div class="divadvancedsearchfield">';
$arrayofgraphs = array('bars' => 'Bars', 'lines' => 'Lines'); // also 'pies'
$viewmode .= '<div class="inline-block opacitymedium"><span class="fas fa-chart-area paddingright" title="'.$langs->trans("Graph").'"></span>'.$langs->trans("Graph").'</div> ';
$viewmode .= $form->selectarray('search_graph', $arrayofgraphs, $search_graph, 0, 0, 0, '', 1, 0, 0, '', 'graphtype width100');
$viewmode .= '</div>';
2022-01-03 03:47:17 +00:00
2024-02-26 19:39:46 +00:00
$num = 0;
$massactionbutton = '';
$nav = '';
$newcardbutton = '';
$limit = 0;
2022-01-03 03:47:17 +00:00
2024-02-26 19:39:46 +00:00
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.'<span class="marginleftonly"></span>'.$newcardbutton, '', $limit, 1, 0, 1, $viewmode);
2022-01-03 03:47:17 +00:00
2024-02-26 19:39:46 +00:00
foreach ($newarrayoftype as $tmpkey => $tmpval) {
2025-11-24 17:58:50 +00:00
$newarrayoftype[$tmpkey]['data-html'] = img_picto('', $tmpval['picto'], 'class="pictofixedwidth"').$langs->trans($tmpval['label']);
$newarrayoftype[$tmpkey]['label'] = $langs->trans($tmpval['label']);
2024-02-26 19:39:46 +00:00
}
2020-02-07 09:58:17 +00:00
2024-11-04 13:59:22 +00:00
print '<div class="liste_titre liste_titre_bydiv liste_titre_bydiv_inlineblock liste_titre_bydiv_nothingafter centpercent">';
2020-02-07 09:58:17 +00:00
2024-02-26 19:39:46 +00:00
// Select object
print '<div class="divadvancedsearchfield center floatnone">';
print '<div class="inline-block"><span class="opacitymedium">'.$langs->trans("StatisticsOn").'</span></div> ';
2025-07-10 14:34:06 +00:00
2025-07-21 16:15:43 +00:00
print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', 'minwidth250', 1, '', 0, 1);
2024-02-26 19:39:46 +00:00
if (empty($conf->use_javascript_ajax)) {
print '<input type="submit" class="button buttongen button-save nomargintop" name="changeobjecttype" value="'.$langs->trans("Refresh").'">';
} else {
print '<!-- js code to reload page with good object type -->
<script nonce="'.getNonce().'" type="text/javascript">
jQuery(document).ready(function() {
jQuery("#objecttype").change(function() {
console.log("Reload for "+jQuery("#objecttype").val());
2024-02-27 15:43:04 +00:00
location.href = "'.$_SERVER["PHP_SELF"].'?objecttype="+jQuery("#objecttype").val()+"'.($tabfamily ? '&tabfamily='.urlencode($tabfamily) : '').(GETPOSTINT('show_search_component_params_hidden') ? '&show_search_component_params_hidden='.((int) GETPOSTINT('show_search_component_params_hidden')) : '').'";
2024-02-26 19:39:46 +00:00
});
});
</script>';
}
print '</div><div class="clearboth"></div>';
2020-02-07 09:58:17 +00:00
2025-07-10 14:34:06 +00:00
if (!empty($newarrayoftype)) {
// Filter (you can use param &show_search_component_params_hidden=1 for debug)
if (!empty($object)) {
print '<div class="divadvancedsearchfield">';
print $form->searchComponent(array($object->element => $object->fields), $search_component_params, array(), $search_component_params_hidden, $arrayoffilterfields);
print '</div>';
}
// YAxis (add measures into array)
$count = 0;
//var_dump($arrayofmesures);
print '<div class="divadvancedsearchfield clearboth">';
print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span><span class="fas fa-caret-left caretleftaxis" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span></div>';
$simplearrayofmesures = array();
foreach ($arrayofmesures as $key => $val) {
$simplearrayofmesures[$key] = $arrayofmesures[$key]['label'];
}
print $form->multiselectarray('search_measures', $simplearrayofmesures, $sanitized_search_measures, 0, 0, 'minwidth300 widthcentpercentminusx', 1, 0, '', '', $langs->transnoentitiesnoconv("Measures")); // Fill the array $arrayofmeasures with possible fields
2025-07-10 14:34:06 +00:00
print '</div>';
// XAxis
$count = 0;
2024-04-09 23:38:36 +00:00
print '<div class="divadvancedsearchfield">';
2025-07-10 14:34:06 +00:00
print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span><span class="fas fa-caret-down caretdownaxis" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span></div>';
//var_dump($arrayofxaxis);
print $formother->selectXAxisField($object, $sanitized_search_xaxis, $arrayofxaxis, $langs->trans("XAxis"), 'minwidth300 maxwidth400 widthcentpercentminusx'); // Fill the array $arrayofxaxis with possible fields
2024-02-26 19:39:46 +00:00
print '</div>';
2025-07-10 14:34:06 +00:00
// Group by
$count = 0;
print '<div class="divadvancedsearchfield">';
print '<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("GroupBy")).'"></span></div>';
print $formother->selectGroupByField($object, $sanitized_search_groupby, $arrayofgroupby, 'minwidth250 maxwidth300 widthcentpercentminusx', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields
2025-07-10 14:34:06 +00:00
print '</div>';
2024-02-26 19:39:46 +00:00
}
if ($mode == 'grid') {
// YAxis
print '<div class="divadvancedsearchfield">';
foreach ($object->fields as $key => $val) {
2025-11-06 12:15:03 +00:00
if (empty($val['measure']) && (!isset($val['enabled']) || dol_eval((string) $val['enabled'], 1, 1, '1'))) {
2024-02-26 19:39:46 +00:00
if (in_array($key, array('id', 'rowid', 'entity', 'last_main_doc', 'extraparams'))) {
continue;
}
if (preg_match('/^fk_/', $key)) {
continue;
}
if (in_array($val['type'], array('html', 'text'))) {
continue;
}
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
$arrayofyaxis['t.'.$key.'-year'] = array(
'label' => $langs->trans($val['label']).' ('.$YYYY.')',
'position' => $val['position'],
'table' => $object->table_element
);
$arrayofyaxis['t.'.$key.'-month'] = array(
'label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')',
'position' => $val['position'],
'table' => $object->table_element
);
$arrayofyaxis['t.'.$key.'-day'] = array(
'label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')',
'position' => $val['position'],
'table' => $object->table_element
);
} else {
$arrayofyaxis['t.'.$key] = array(
'label' => $val['label'],
'position' => (int) $val['position'],
'table' => $object->table_element
);
}
}
}
2024-02-26 19:39:46 +00:00
// Add measure from extrafields
if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
fix ignored phpstan (most of expects string, int given) (#30649) * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan fix ignored phpstan fix ignored phpstan fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan fix ignored phpstan fix ignored phpstan fix ignored phpstan fix ignored phpstan fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * fix ignored phpstan * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * more ignore * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan
2024-09-05 14:05:37 +00:00
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval((string) $extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
2024-02-26 19:39:46 +00:00
$arrayofyaxis['te.'.$key] = array(
'label' => $extrafields->attributes[$object->table_element]['label'][$key],
'position' => (int) $extrafields->attributes[$object->table_element]['pos'][$key],
'table' => $object->table_element
);
}
}
}
2024-02-26 19:39:46 +00:00
$arrayofyaxis = dol_sort_array($arrayofyaxis, 'position');
$arrayofyaxislabel = array();
foreach ($arrayofyaxis as $key => $val) {
$arrayofyaxislabel[$key] = $val['label'];
}
print '<div class="inline-block opacitymedium"><span class="fas fa-ruler-vertical paddingright" title="'.$langs->trans("YAxis").'"></span>'.$langs->trans("YAxis").'</div> ';
print $form->multiselectarray('search_yaxis', $arrayofyaxislabel, $sanitized_search_yaxis != null ? $sanitized_search_yaxis : array(), 0, 0, 'minwidth100', 1);
2024-02-26 19:39:46 +00:00
print '</div>';
}
2024-02-26 19:39:46 +00:00
2025-07-10 14:34:06 +00:00
if (!empty($newarrayoftype)) {
print '<div class="divadvancedsearchfield">';
print '<input type="submit" class="button buttongen button-save nomargintop" value="'.$langs->trans("Refresh").'">';
print '</div>';
}
2020-02-07 09:58:17 +00:00
2024-02-26 19:39:46 +00:00
print '</div>';
print '</form>';
2020-02-07 09:58:17 +00:00
}
2022-01-03 03:47:17 +00:00
2020-02-07 09:58:17 +00:00
// Generate the SQL request
$sql = '';
if (!empty($sanitized_search_measures) && !empty($sanitized_search_xaxis)) {
2023-05-25 10:25:06 +00:00
$errormessage = '';
$fieldid = 'rowid';
2022-03-22 12:23:16 +00:00
$sql = "SELECT ";
foreach ($sanitized_search_xaxis as $sql_key => $sql_val) {
if (preg_match('/\-year$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-year$/', '', $sql_val);
$sql .= "DATE_FORMAT(".$sql_tmpval.", '%Y') as x_".$sql_key.', ';
} elseif (preg_match('/\-month$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-month$/', '', $sql_val);
$sql .= "DATE_FORMAT(".$sql_tmpval.", '%Y-%m') as x_".$sql_key.', ';
} elseif (preg_match('/\-day$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-day$/', '', $sql_val);
$sql .= "DATE_FORMAT(".$sql_tmpval.", '%Y-%m-%d') as x_".$sql_key.', ';
2021-02-23 21:03:23 +00:00
} else {
$sql .= $sql_val." as x_".$sql_key.", ";
2021-02-23 21:03:23 +00:00
}
}
if (!empty($sanitized_search_groupby)) {
foreach ($sanitized_search_groupby as $sql_key => $sql_val) {
if (preg_match('/\-year$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-year$/', '', $sql_val);
$sql .= "DATE_FORMAT(".$sql_tmpval.", '%Y') as g_".$sql_key.', ';
} elseif (preg_match('/\-month$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-month$/', '', $sql_val);
$sql .= "DATE_FORMAT(".$sql_tmpval.", '%Y-%m') as g_".$sql_key.', ';
} elseif (preg_match('/\-day$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-day$/', '', $sql_val);
$sql .= "DATE_FORMAT(".$sql_tmpval.", '%Y-%m-%d') as g_".$sql_key.', ';
2024-03-17 12:10:17 +00:00
} else {
$sql .= $sql_val." as g_".$sql_key.", ";
2024-03-17 12:10:17 +00:00
}
2021-02-23 21:03:23 +00:00
}
}
foreach ($sanitized_search_measures as $sql_key => $sql_val) {
if ($sql_val == 't.count') {
$sql .= "COUNT(t.".$fieldid.") as y_".$sql_key.', ';
} elseif (preg_match('/\-sum$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-sum$/', '', $sql_val);
$sql .= "SUM(".$db->ifsql($sql_tmpval.' IS NULL', '0', $sql_tmpval).") as y_".$sql_key.", ";
} elseif (preg_match('/\-average$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-average$/', '', $sql_val);
$sql .= "AVG(".$db->ifsql($sql_tmpval.' IS NULL', '0', $sql_tmpval).") as y_".$sql_key.", ";
} elseif (preg_match('/\-min$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-min$/', '', $sql_val);
$sql .= "MIN(".$db->ifsql($sql_tmpval.' IS NULL', '0', $sql_tmpval).") as y_".$sql_key.", ";
} elseif (preg_match('/\-max$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-max$/', '', $sql_val);
$sql .= "MAX(".$db->ifsql($sql_tmpval.' IS NULL', '0', $sql_tmpval).") as y_".$sql_key.", ";
} elseif (preg_match('/\-stddevpop$/', $sql_val)) {
$sql_tmpval = preg_replace('/\-stddevpop$/', '', $sql_val);
$sql .= "STDDEV_POP(".$db->ifsql($sql_tmpval.' IS NULL', '0', $sql_tmpval).") as y_".$sql_key.", ";
}
}
$sql = preg_replace('/,\s*$/', '', $sql);
2022-03-22 12:23:16 +00:00
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
// Add measure from extrafields
if ($object->isextrafieldmanaged) {
2021-08-27 22:55:51 +00:00
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te ON te.fk_object = t.".$fieldid;
}
2023-05-24 01:18:00 +00:00
// Add table for link on multientity
2022-03-22 12:23:16 +00:00
if ($object->ismultientitymanaged) { // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
if ($object->ismultientitymanaged == 1) {
2022-03-22 12:23:16 +00:00
// No table to add here
} else {
$tmparray = explode('@', $object->ismultientitymanaged);
$sql .= " INNER JOIN ".MAIN_DB_PREFIX.$db->sanitize($tmparray[1])." as parenttableforentity ON t.".$db->sanitize($tmparray[0])." = parenttableforentity.rowid";
2022-03-22 12:23:16 +00:00
$sql .= " AND parenttableforentity.entity IN (".getEntity($tmparray[1]).")";
}
}
2022-03-21 21:02:34 +00:00
2023-05-24 01:18:00 +00:00
// Init the list of tables added. We include by default always the main table.
2022-03-21 21:02:34 +00:00
$listoftablesalreadyadded = array($object->table_element => $object->table_element);
2022-03-22 12:23:16 +00:00
// Add LEFT JOIN for all parent tables mentioned into the Xaxis
//var_dump($arrayofxaxis); var_dump($sanitized_search_xaxis);
foreach ($sanitized_search_xaxis as $key => $val) {
2022-03-21 21:02:34 +00:00
if (!empty($arrayofxaxis[$val])) {
$tmpval = explode('.', $val);
2023-05-24 01:18:00 +00:00
//var_dump($arrayofgroupby);
$tmpforloop = dolExplodeIntoArray($arrayofxaxis[$val]['tablefromt'], ',');
foreach ($tmpforloop as $tmptable => $tmptablealias) {
if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added
$tmpforexplode = explode('__', $tmptablealias);
$endpart = end($tmpforexplode);
$parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable." as ".$db->sanitize($tmptablealias)." ON ".$db->sanitize($parenttableandfield)." = ".$db->sanitize($tmptablealias).".rowid";
$listoftablesalreadyadded[$tmptable] = $tmptable;
if (preg_match('/^te/', $tmpval[0]) && preg_replace('/^t_/', 'te_', $tmptablealias) == $tmpval[0]) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable."_extrafields as ".$db->sanitize($tmpval[0])." ON ".$db->sanitize($tmpval[0]).".fk_object = ".$db->sanitize($tmptablealias).".rowid";
$listoftablesalreadyadded[$tmptable] = $tmptable;
}
}
2022-03-21 21:02:34 +00:00
}
} else {
2023-05-25 10:25:06 +00:00
$errormessage = 'Found a key into search_xaxis not found into arrayofxaxis';
2022-03-21 21:02:34 +00:00
}
}
// Add LEFT JOIN for all parent tables mentioned into the Group by
//var_dump($arrayofgroupby); var_dump($sanitized_search_groupby);
foreach ($sanitized_search_groupby as $key => $val) {
2022-03-22 12:23:16 +00:00
if (!empty($arrayofgroupby[$val])) {
$tmpval = explode('.', $val);
2023-05-24 01:18:00 +00:00
//var_dump($arrayofgroupby[$val]); var_dump($tmpval);
$tmpforloop = dolExplodeIntoArray($arrayofgroupby[$val]['tablefromt'], ',');
foreach ($tmpforloop as $tmptable => $tmptablealias) {
if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added
$tmpforexplode = explode('__', $tmptablealias);
$endpart = end($tmpforexplode);
$parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable." as ".$db->sanitize($tmptablealias)." ON ".$db->sanitize($parenttableandfield)." = ".$db->sanitize($tmptablealias).".rowid";
$listoftablesalreadyadded[$tmptable] = $tmptable;
if (preg_match('/^te/', $tmpval[0]) && preg_replace('/^t_/', 'te_', $tmptablealias) == $tmpval[0]) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable."_extrafields as ".$db->sanitize($tmpval[0])." ON ".$db->sanitize($tmpval[0]).".fk_object = ".$db->sanitize($tmptablealias).".rowid";
$listoftablesalreadyadded[$tmptable] = $tmptable;
}
}
2022-03-22 12:23:16 +00:00
}
} else {
2023-05-25 10:25:06 +00:00
$errormessage = 'Found a key into search_groupby not found into arrayofgroupby';
2022-03-22 12:23:16 +00:00
}
}
// Add LEFT JOIN for all parent tables mentioned into the Yaxis
//var_dump($arrayofgroupby); var_dump($sanitized_search_groupby);
foreach ($sanitized_search_measures as $key => $val) {
2022-03-22 12:23:16 +00:00
if (!empty($arrayofmesures[$val])) {
$tmpval = explode('.', $val);
2023-05-24 01:18:00 +00:00
//var_dump($arrayofgroupby);
$tmpforloop = dolExplodeIntoArray($arrayofmesures[$val]['tablefromt'], ',');
foreach ($tmpforloop as $tmptable => $tmptablealias) {
if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added
$tmpforexplode = explode('__', $tmptablealias);
$endpart = end($tmpforexplode);
$parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable." as ".$db->sanitize($tmptablealias)." ON ".$db->sanitize($parenttableandfield)." = ".$db->sanitize($tmptablealias).".rowid";
$listoftablesalreadyadded[$tmptable] = $tmptable;
if (preg_match('/^te/', $tmpval[0]) && preg_replace('/^t_/', 'te_', $tmptablealias) == $tmpval[0]) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable."_extrafields as ".$db->sanitize($tmpval[0])." ON ".$db->sanitize($tmpval[0]).".fk_object = ".$db->sanitize($tmptablealias).".rowid";
$listoftablesalreadyadded[$tmptable] = $tmptable;
}
}
2022-03-22 12:23:16 +00:00
}
} else {
2023-05-25 10:25:06 +00:00
$errormessage = 'Found a key into search_measures not found into arrayofmesures';
2022-03-21 21:02:34 +00:00
}
}
// Add LEFT JOIN for all tables mentioned into filter
if (!empty($search_component_params_hidden)) {
// Get all fields used into the filter
2025-07-29 09:04:32 +00:00
$matches = array();
preg_match_all('/\b(t[\w]*_[\w]*)\.(\w+(-\w+)?)/', $search_component_params_hidden, $matches);
$fieldsUsedInFilter = array_unique($matches[0]);
// Remove fields used before to avoid double join
$fieldsToRemove = array_merge($sanitized_search_measures, $sanitized_search_groupby, $sanitized_search_xaxis);
$fieldsUsedInFilter = array_diff($fieldsUsedInFilter, $fieldsToRemove);
foreach ($fieldsUsedInFilter as $key => $val) {
if (!empty($arrayoffilterfields[$val])) {
$tmpval = explode('.', $val);
$tmpforloop = dolExplodeIntoArray($arrayoffilterfields[$val]['tablefromt'], ',');
foreach ($tmpforloop as $tmptable => $tmptablealias) {
if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added
$tmpforexplode = explode('__', $tmptablealias);
$endpart = end($tmpforexplode);
$parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable." as ".$db->sanitize($tmptablealias)." ON ".$db->sanitize($parenttableandfield)." = ".$db->sanitize($tmptablealias).".rowid";
$listoftablesalreadyadded[$tmptable] = $tmptable;
if (preg_match('/^te/', $tmpval[0]) && preg_replace('/^t_/', 'te_', $tmptablealias) == $tmpval[0]) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$tmptable."_extrafields as ".$db->sanitize($tmpval[0])." ON ".$db->sanitize($tmpval[0]).".fk_object = ".$db->sanitize($tmptablealias).".rowid";
$listoftablesalreadyadded[$tmptable] = $tmptable;
}
}
}
} else {
$errormessage = 'Found a key into search_filterfields not found into arrayoffilterfields';
}
}
}
2022-03-22 12:23:16 +00:00
$sql .= " WHERE 1 = 1";
if ($object->ismultientitymanaged == 1) { // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
$sql .= " AND t.entity IN (".getEntity($object->element).")";
}
2022-01-03 03:47:17 +00:00
// Add the where here
if ($search_component_params_hidden) {
$sql .= forgeSQLFromUniversalSearchCriteria($search_component_params_hidden, $errormessage, 0, 0, 1);
// Replace date values by $db->idate(dol_mktime(...)) @phan-suppress-next-line SqlInjection
$sql = preg_replace_callback(
"/(\w+)\.(\w+)\s*(=|!=|<>|<|>|<=|>=)\s*'(\d{4})-(\d{2})-(\d{2})'/",
/**
* @param array<int, string> $matches
* @return string SQL filter condition
*/
static function (array $matches): string {
global $db;
'@phan-var-force DoliDB $db';
$column = $matches[1] . '.' . $matches[2];
$operator = $matches[3];
$year = (int) $matches[4];
$month = (int) $matches[5];
$day = (int) $matches[6];
$startOfDay = $db->idate(dol_mktime(0, 0, 0, $month, $day, $year));
$endOfDay = $db->idate(dol_mktime(23, 59, 59, $month, $day, $year));
switch ($operator) {
case "=":
return "($column >= '$startOfDay' AND $column <= '$endOfDay')";
case "!=":
case "<>":
return "NOT ($column >= '$startOfDay' AND $column <= '$endOfDay')";
case "<":
return "$column < '$startOfDay'";
case ">":
return "$column > '$endOfDay'";
case "<=":
return "$column <= '$endOfDay'";
case ">=":
return "$column >= '$startOfDay'";
default:
return "";
}
},
$sql
);
}
2022-03-22 12:23:16 +00:00
$sql .= " GROUP BY ";
foreach ($sanitized_search_xaxis as $key => $sanitized_val) {
if (preg_match('/\-year$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-year$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y'), ";
} elseif (preg_match('/\-month$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-month$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y-%m'), ";
} elseif (preg_match('/\-day$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-day$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y-%m-%d'), ";
2021-02-23 21:03:23 +00:00
} else {
$sql .= $sanitized_val.", ";
2021-02-23 21:03:23 +00:00
}
}
if (!empty($sanitized_search_groupby)) {
foreach ($sanitized_search_groupby as $key => $sanitized_val) {
if (preg_match('/\-year$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-year$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y'), ";
} elseif (preg_match('/\-month$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-month$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y-%m'), ";
} elseif (preg_match('/\-day$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-day$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y-%m-%d'), ";
2024-03-17 12:10:17 +00:00
} else {
$sql .= $sanitized_val.', ';
2024-03-17 12:10:17 +00:00
}
2021-02-23 21:03:23 +00:00
}
}
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= ' ORDER BY ';
foreach ($sanitized_search_xaxis as $key => $sanitized_val) {
if (preg_match('/\-year$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-year$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y'), ";
} elseif (preg_match('/\-month$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-month$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y-%m'), ";
} elseif (preg_match('/\-day$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-day$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y-%m-%d'), ";
2021-02-23 21:03:23 +00:00
} else {
$sql .= $sanitized_val.', ';
2021-02-23 21:03:23 +00:00
}
}
if (!empty($sanitized_search_groupby)) {
foreach ($sanitized_search_groupby as $key => $sanitized_val) {
if (preg_match('/\-year$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-year$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y'), ";
} elseif (preg_match('/\-month$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-month$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y-%m'), ";
} elseif (preg_match('/\-day$/', $sanitized_val)) {
$sanitized_tmpval = preg_replace('/\-day$/', '', $sanitized_val);
$sql .= "DATE_FORMAT(".$sanitized_tmpval.", '%Y-%m-%d'), ";
2024-03-17 12:10:17 +00:00
} else {
$sql .= $sanitized_val.', ';
2024-03-17 12:10:17 +00:00
}
2021-02-23 21:03:23 +00:00
}
}
$sql = preg_replace('/,\s*$/', '', $sql);
2024-03-17 18:23:25 +00:00
// Can overwrite the SQL with a custom SQL string (when used as an include)
if (!empty($customsql)) {
$sql = $customsql;
}
2020-02-07 09:58:17 +00:00
}
//print $sql;
2020-02-07 09:58:17 +00:00
2023-05-25 10:25:06 +00:00
if ($errormessage) {
2024-02-17 03:07:34 +00:00
print '<div class="warning">';
2023-05-25 10:25:06 +00:00
print dol_escape_htmltag($errormessage);
2024-02-17 03:07:34 +00:00
//print '<br>'.dol_escape_htmltag('SQL is '.$sql);
print '</div>';
2023-05-25 10:25:06 +00:00
$sql = '';
}
$legend = array();
foreach ($sanitized_search_measures as $key => $val) {
2022-03-22 12:23:16 +00:00
$legend[] = $langs->trans($arrayofmesures[$val]['label']);
2020-02-07 09:58:17 +00:00
}
$useagroupby = count($sanitized_search_groupby);
2020-03-08 18:25:00 +00:00
//var_dump($useagroupby);
//var_dump($arrayofvaluesforgroupby);
2020-02-07 09:58:17 +00:00
// Execute the SQL request
$totalnbofrecord = 0;
$data = array();
if ($sql) {
$resql = $db->query($sql);
if (!$resql) {
2024-02-17 03:07:34 +00:00
print '<div class="warning">';
print dol_escape_htmltag($db->lasterror());
//print '<br>'.dol_escape_htmltag('SQL is '.$sql);
print '</div>';
} else {
$ifetch = 0;
$xi = 0;
$oldlabeltouse = '';
while ($obj = $db->fetch_object($resql)) {
$ifetch++;
if ($useagroupby) {
$xval = $sanitized_search_xaxis[0];
2024-02-17 03:07:34 +00:00
$fieldforxkey = 'x_0';
$xlabel = $obj->$fieldforxkey;
$xvalwithoutprefix = preg_replace('/^[a-z]+\./', '', $xval);
// Define $xlabel
if (!empty($object->fields[$xvalwithoutprefix]['arrayofkeyval'])) {
$xlabel = $object->fields[$xvalwithoutprefix]['arrayofkeyval'][$obj->$fieldforxkey];
}
$labeltouse = (($xlabel || $xlabel == '0') ? dol_trunc($xlabel, 20, 'middle') : ($xlabel === '' ? $langs->transnoentitiesnoconv("Empty") : $langs->transnoentitiesnoconv("NotDefined")));
2020-03-06 19:06:56 +00:00
2024-02-25 22:58:37 +00:00
if ($oldlabeltouse !== '' && ($labeltouse != $oldlabeltouse)) {
2024-02-17 03:07:34 +00:00
$xi++; // Increase $xi
}
//var_dump($labeltouse.' '.$oldlabeltouse.' '.$xi);
$oldlabeltouse = $labeltouse;
/* Example of value for $arrayofvaluesforgroupby
* array (size=1)
* 'g_0' =>
* array (size=6)
* 0 => string '0' (length=1)
* '' => string 'Empty' (length=5)
* '__NULL__' => string 'Not defined' (length=11)
* 'done' => string 'done' (length=4)
* 'processing' => string 'processing' (length=10)
* 'undeployed' => string 'undeployed' (length=10)
*/
foreach ($sanitized_search_measures as $key => $val) {
2024-02-17 03:07:34 +00:00
$gi = 0;
foreach ($sanitized_search_groupby as $gkey => $gval) {
2024-02-17 03:07:34 +00:00
//var_dump('*** Fetch #'.$ifetch.' for labeltouse='.$labeltouse.' measure number '.$key.' and group g_'.$gi);
//var_dump($arrayofvaluesforgroupby);
foreach ($arrayofvaluesforgroupby['g_'.$gi] as $gvaluepossiblekey => $gvaluepossiblelabel) {
$ykeysuffix = $gvaluepossiblelabel;
$gvalwithoutprefix = preg_replace('/^[a-z]+\./', '', $gval);
$fieldfory = 'y_'.$key;
$fieldforg = 'g_'.$gi;
$fieldforybis = 'y_'.$key.'_'.$ykeysuffix;
//var_dump('gvaluepossiblekey='.$gvaluepossiblekey.' gvaluepossiblelabel='.$gvaluepossiblelabel.' ykeysuffix='.$ykeysuffix.' gval='.$gval.' gvalwithoutsuffix='.$gvalwithoutprefix);
//var_dump('fieldforg='.$fieldforg.' obj->$fieldforg='.$obj->$fieldforg.' fieldfory='.$fieldfory.' obj->$fieldfory='.$obj->$fieldfory.' fieldforybis='.$fieldforybis);
if (!array_key_exists($xi, $data)) {
2024-02-17 03:07:34 +00:00
$data[$xi] = array();
}
2024-02-17 03:07:34 +00:00
if (!array_key_exists('label', $data[$xi])) {
$data[$xi] = array();
$data[$xi]['label'] = $labeltouse;
}
2024-02-17 03:07:34 +00:00
$objfieldforg = $obj->$fieldforg;
if (is_null($objfieldforg)) {
$objfieldforg = '__NULL__';
}
2024-02-17 03:07:34 +00:00
if ($gvaluepossiblekey == '0') { // $gvaluepossiblekey can have type int or string. So we create a special if, used when value is '0'
//var_dump($objfieldforg.' == \'0\' -> '.($objfieldforg == '0'));
if ($objfieldforg == '0') {
// The record we fetch is for this group
$data[$xi][$fieldforybis] = $obj->$fieldfory;
} elseif (!isset($data[$xi][$fieldforybis])) {
// The record we fetch is not for this group
$data[$xi][$fieldforybis] = '0';
}
} else {
//var_dump((string) $objfieldforg.' === '.(string) $gvaluepossiblekey.' -> '.((string) $objfieldforg === (string) $gvaluepossiblekey));
if ((string) $objfieldforg === (string) $gvaluepossiblekey) {
// The record we fetch is for this group
$data[$xi][$fieldforybis] = $obj->$fieldfory;
} elseif (!isset($data[$xi][$fieldforybis])) {
// The record we fetch is not for this group
$data[$xi][$fieldforybis] = '0';
}
}
}
2024-02-17 03:07:34 +00:00
//var_dump($data[$xi]);
$gi++;
}
}
2024-02-17 03:07:34 +00:00
} else { // No group by
$xval = $sanitized_search_xaxis[0];
2024-02-17 03:07:34 +00:00
$fieldforxkey = 'x_0';
$xlabel = $obj->$fieldforxkey;
$xvalwithoutprefix = preg_replace('/^[a-z]+\./', '', $xval);
// Define $xlabel
if (!empty($object->fields[$xvalwithoutprefix]['arrayofkeyval'])) {
$xlabel = $object->fields[$xvalwithoutprefix]['arrayofkeyval'][$obj->$fieldforxkey];
}
2024-02-17 03:07:34 +00:00
$labeltouse = (($xlabel || $xlabel == '0') ? dol_trunc($xlabel, 20, 'middle') : ($xlabel === '' ? $langs->transnoentitiesnoconv("Empty") : $langs->transnoentitiesnoconv("NotDefined")));
$xarrayforallseries = array('label' => $labeltouse);
foreach ($sanitized_search_measures as $key => $val) {
2024-02-17 03:07:34 +00:00
$fieldfory = 'y_'.$key;
$xarrayforallseries[$fieldfory] = $obj->$fieldfory;
}
$data[$xi] = $xarrayforallseries;
$xi++;
}
}
2024-02-17 03:07:34 +00:00
$totalnbofrecord = count($data);
}
2020-02-07 09:58:17 +00:00
}
//var_dump($data);
2024-02-16 17:18:17 +00:00
print '<!-- Section to show the result -->'."\n";
print '<div class="customreportsoutput'.($totalnbofrecord ? '' : ' customreportsoutputnotdata').'">';
2020-02-07 09:58:17 +00:00
2025-07-10 14:34:06 +00:00
if (empty($newarrayoftype)) {
$langs->load("admin");
2025-08-20 15:57:08 +00:00
print info_admin($langs->trans("NoSupportedModulesHaveBeenActivated").' '.$langs->trans("YouCanEnableModulesFrom"), 0, 0, 'info');
2025-07-10 14:34:06 +00:00
}
2020-02-07 09:58:17 +00:00
if ($mode == 'grid') {
2020-02-07 11:51:08 +00:00
// TODO
2020-02-07 09:58:17 +00:00
}
if ($mode == 'graph') {
$WIDTH = '80%';
$HEIGHT = (empty($_SESSION['dol_screenheight']) ? 400 : $_SESSION['dol_screenheight'] - 500);
// Show graph
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
2021-02-23 21:03:23 +00:00
if (!$mesg) {
//var_dump($legend);
//var_dump($data);
$px1->SetData($data);
unset($data);
$arrayoftypes = array();
foreach ($sanitized_search_measures as $key => $val) {
$arrayoftypes[] = $search_graph;
}
$px1->SetLegend($legend);
2024-02-29 12:03:04 +00:00
$px1->setShowLegend($SHOWLEGEND);
2025-01-05 17:12:36 +00:00
$px1->SetMinValue((int) $px1->GetFloorMinValue());
$px1->SetMaxValue($px1->GetCeilMaxValue());
$px1->SetWidth($WIDTH);
$px1->SetHeight($HEIGHT);
$px1->SetYLabel($langs->trans("Y"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
$px1->SetCssPrefix("cssboxes");
$px1->SetType($arrayoftypes);
$px1->mode = 'depth';
$px1->SetTitle('');
$dir = $conf->user->dir_temp;
dol_mkdir($dir);
// $customreportkey may be defined when using customreports.php as an include
if (!empty($object->element)) {
$filenamekey = $dir.'/customreport_'.$object->element.(empty($customreportkey) ? '' : $customreportkey).'.png';
$fileurlkey = DOL_URL_ROOT.'/viewimage.php?modulepart=user&file=customreport_'.$object->element.(empty($customreportkey) ? '' : $customreportkey).'.png';
}
if (isset($filenamekey) && isset($fileurlkey)) {
$px1->draw($filenamekey, $fileurlkey);
}
$texttoshow = $langs->trans("NoRecordFound");
if (!GETPOSTISSET('search_measures') || !GETPOSTISSET('search_xaxis')) {
$texttoshow = $langs->trans("SelectYourGraphOptionsFirst");
}
print $px1->show($totalnbofrecord ? 0 : $texttoshow);
}
2020-02-07 09:58:17 +00:00
}
2024-11-04 13:59:22 +00:00
print '</div>';
2024-02-26 19:39:46 +00:00
if ($sql && !defined('MAIN_CUSTOM_REPORT_KEEP_GRAPH_ONLY')) {
// Show admin info
print '<br>'.info_admin($langs->trans("SQLUsedForExport").':<br> '.$sql, 0, 0, '1', '', 'TechnicalInformation');
2020-02-07 09:58:17 +00:00
}
2021-04-02 11:31:03 +00:00
if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) {
2020-10-27 17:19:31 +00:00
print dol_get_fiche_end();
2020-02-07 09:58:17 +00:00
2024-02-26 17:06:35 +00:00
llxFooter();
// End of page
2024-02-29 10:52:53 +00:00
$db->close();
2024-02-26 17:06:35 +00:00
}