From 1ee959a11f134e138b8ec29b5e121e8344a9e420 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 8 Feb 2020 17:46:41 +0100 Subject: [PATCH] Generic graph --- htdocs/core/customreports.php | 18 +++++++++++++----- htdocs/langs/en_US/other.lang | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 80d88f72203..31db8fe5447 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -17,7 +17,7 @@ /** * \file htdocs/core/customreports.php - * \ingroup sellyoursaas + * \ingroup core * \brief Page to make custom reports */ @@ -72,6 +72,7 @@ $picto = ''; $head = array(); $object = null; $ObjectClassName = ''; +// Objects available by default $arrayoftype = array( 'thirdparty' => array('label' => 'ThirdParties', 'ObjectClassName' => 'Societe', 'enabled' => $conf->societe->enabled, 'ClassPath' => DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"), 'contact' => array('label' => 'Contacts', 'ObjectClassName' => 'Contact', 'enabled' => $conf->societe->enabled, 'ClassPath' => DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"), @@ -158,8 +159,15 @@ $form=new Form($db); llxHeader('', $langs->transnoentitiesnoconv('CustomReports'), ''); -//print_fiche_titre($langs->trans("DoliCloudArea")); - +// Check parameters +if ($mode == 'graph' && $search_graph == 'bars' && count($search_measures) > 3) { + setEventMessages($langs->trans("GraphInBarsAreLimitedTo3Measures"), null, 'warnings'); + $search_graph = 'lines'; +} +if ($mode == 'graph' && count($search_xaxis) > 1) { + setEventMessages($langs->trans("OnlyOneFieldForXAxisIsPossible"), null, 'warnings'); + $search_xaxis = array(0 => $search_xaxis[0]); +} //$head = commande_prepare_head(null); @@ -307,9 +315,9 @@ if ($mode == 'grid') { if ($mode == 'graph') { print '
'; - $arrayofgraphs = array('bars', 'line'); // also 'pies' + $arrayofgraphs = array('bars' => 'Bars', 'lines' => 'Lines'); // also 'pies' print '
'.$langs->trans("Graph").'
'; - print $form->selectarray('search_graph', $arrayofgraphs, $search_graph, 0, 0, 'minwidth100', 1); + print $form->selectarray('search_graph', $arrayofgraphs, $search_graph, 0, 0, 0, 'minwidth100', 1); print '
'; } print '
'; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 46424590f31..8530c9fbede 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -30,6 +30,8 @@ PreviousYearOfInvoice=Previous year of invoice date NextYearOfInvoice=Following year of invoice date DateNextInvoiceBeforeGen=Date of next invoice (before generation) DateNextInvoiceAfterGen=Date of next invoice (after generation) +GraphInBarsAreLimitedTo3Measures=Grapics are limited to 3 measures in 'Bars' mode. The mode 'Lines' was automatically selected instead. +OnlyOneFieldForXAxisIsPossible=Only 1 field is currently possible as X-Axis. Only the first selected field has been selected. Notify_ORDER_VALIDATE=Sales order validated Notify_ORDER_SENTBYMAIL=Sales order sent by mail