From 05f02421989625665e0ec87f0d870f304519c879 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Feb 2020 10:38:09 +0100 Subject: [PATCH] NEW The info_admin() can show text after click on other text --- htdocs/core/class/html.formfile.class.php | 4 +- htdocs/core/customreports.php | 131 ++++++++++++---------- htdocs/core/lib/functions.lib.php | 39 +++++-- htdocs/exports/export.php | 10 +- htdocs/langs/en_US/other.lang | 2 + 5 files changed, 111 insertions(+), 75 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 7a3b48e1c40..9d27bc0421a 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -325,7 +325,7 @@ class FormFile * @param int $notused Not used * @param integer $noform Do not output html form tags * @param string $param More param on http links - * @param string $title Title to show on top of form + * @param string $title Title to show on top of form. Example: '' (Default to "Documents") or 'none' * @param string $buttonlabel Label on submit button * @param string $codelang Default language code to use on lang combo box if multilang is enabled * @param string $morepicto Add more HTML content into cell with picto @@ -408,7 +408,7 @@ class FormFile } $titletoshow = $langs->trans("Documents"); - if (!empty($title)) $titletoshow = $title; + if (!empty($title)) $titletoshow = ($title == 'none' ? '' : $title); // Show table if ($genallowed) diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 575bbb759d3..4478f6f2ce6 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -13,6 +13,10 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * + * This tool can be included into a list page with + * define('USE_CUSTOME_REPORT_AS_INCLUDE', 1); + * include DOL_DOCUMENT_ROOT.'/core/customreports.php'; */ /** @@ -21,50 +25,48 @@ * \brief Page to make custom reports */ -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; -require_once DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"; -require_once DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php"; -require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; +if (! defined('USE_CUSTOME_REPORT_AS_INCLUDE')) +{ + require '../main.inc.php'; + require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php"; + require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; + + // Get parameters + $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) + + $mode = GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'graph'; + $objecttype = GETPOST('objecttype', 'aZ09'); + $tabfamily = GETPOST('tabfamily', 'aZ09'); + + if (empty($objecttype)) $objecttype = 'thirdparty'; + + $search_filters = GETPOST('search_filters', 'array'); + $search_measures = GETPOST('search_measures', 'array'); + $search_xaxis = GETPOST('search_xaxis', 'array'); + $search_yaxis = GETPOST('search_yaxis', 'array'); + $search_graph = GETPOST('search_graph', 'none'); + + // Load variable for pagination + $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; + $sortfield = GETPOST('sortfield', 'alpha'); + $sortorder = GETPOST('sortorder', 'alpha'); + $page = GETPOST('page', 'int'); + 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; + + $diroutputmassaction = $conf->user->dir_temp.'/'.$user->id.'/customreport'; +} // Load traductions files requiredby by page -$langs->loadLangs(array("companies", "bills", "other", "exports")); - -// Get parameters -$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) - -$mode = GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'graph'; -$objecttype = GETPOST('objecttype', 'aZ09'); -$tabfamily = GETPOST('tabfamily', 'aZ09'); - -if (empty($objecttype)) $objecttype = 'thirdparty'; - -$search_filters = GETPOST('search_filters', 'array'); -$search_measures = GETPOST('search_measures', 'array'); -$search_xaxis = GETPOST('search_xaxis', 'array'); -$search_yaxis = GETPOST('search_yaxis', 'array'); -$search_graph = GETPOST('search_graph', 'none'); - -// Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'alpha'); -$sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); -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; - -// Protection if external user -if ($user->societe_id > 0) -{ - //accessforbidden(); -} +$langs->loadLangs(array("companies", "other", "exports")); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->user->dir_temp.'/'.$user->id.'/customreport'; $hookmanager->initHooks(array('customreport')); // Note that conf->hooks_modules contains array $title = ''; @@ -105,6 +107,9 @@ elseif (is_array($hookmanager->resArray)) { $arrayoftype[$key] = $val; } } + if (! empty($hookmanager->resArray['modenotusedforlist'])) { // Show objecttype selection even if objecttype is set + $modenotusedforlist = $hookmanager->resArray['modenotusedforlist']; + } } if ($objecttype) { @@ -157,22 +162,27 @@ $search_component_params=array(''); $form=new Form($db); -llxHeader('', $langs->transnoentitiesnoconv('CustomReports'), ''); +if (! defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { + llxHeader('', $langs->transnoentitiesnoconv('CustomReports'), ''); + + dol_fiche_head($head, 'customreports', $title, -1, $picto); +} // Check parameters -if ($mode == 'graph' && $search_graph == 'bars' && count($search_measures) > 3) { - setEventMessages($langs->trans("GraphInBarsAreLimitedTo3Measures"), null, 'warnings'); - $search_graph = 'lines'; +if ($action == 'viewgraph') { + if (! count($search_measures)) { + setEventMessages($langs->trans("AtLeastOneMeasureIsRequired"), null, 'warnings'); + } elseif ($mode == 'graph' && count($search_xaxis) > 1) { + setEventMessages($langs->trans("OnlyOneFieldForXAxisIsPossible"), null, 'warnings'); + $search_xaxis = array(0 => $search_xaxis[0]); + } + if (! count($search_xaxis)) { + setEventMessages($langs->trans("AtLeastOneXAxisIsRequired"), null, 'warnings'); + } elseif ($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); -dol_fiche_head($head, 'customreports', $title, -1, $picto); - $tmparray=dol_getdate(dol_now()); $endyear=$tmparray['year']; @@ -188,6 +198,7 @@ $arrayofyaxis = array(); print '
'; print ''; +print ''; print ''; print '
'; @@ -195,7 +206,13 @@ print '
'; // Select object print '
'; print '
'.$langs->trans("StatisticsOn").'
'; -print $form->selectarray('objecttype', $arrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', '', 1); +$newarrayoftype = array(); +foreach($arrayoftype as $key => $val) { + if (dol_eval($val['enabled'], 1)) { + $newarrayoftype[$key] = $arrayoftype[$key]; + } +} +print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', '', 1); if (empty($conf->use_javascript_ajax)) print ''; else { print ''; + + $result = $tmpresult.$result; + } } - return ($nodiv ? '' : '
').' '.$text.($nodiv ? '' : '
'); + return $result; } diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index f910001a5e0..81e96c24479 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -147,6 +147,7 @@ $htmlother = new FormOther($db); $formfile = new FormFile($db); $sqlusedforexport = ''; +$head = array(); $upload_dir = $conf->export->dir_temp.'/'.$user->id; //$usefilters=($conf->global->MAIN_FEATURES_LEVEL > 1); @@ -1266,22 +1267,17 @@ if ($step == 5 && $datatoexport) print '
'; - print ''; - if ($sqlusedforexport && $user->admin) { - print ''; + print info_admin($langs->trans("SQLUsedForExport").':
'.$sqlusedforexport, 0, 0, 1, '', 'TechnicalInformation'); } - print '
'; - print info_admin($langs->trans("SQLUsedForExport").':
'.$sqlusedforexport); - print '
'; if (!is_dir($conf->export->dir_temp)) dol_mkdir($conf->export->dir_temp); // Show existing generated documents // NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste - print $formfile->showdocuments('export', '', $upload_dir, $_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport, $liste, 1, (!empty($_POST['model']) ? $_POST['model'] : 'csv'), 1, 1, 0, 0, 0, '', ' ', '', '', ''); + print $formfile->showdocuments('export', '', $upload_dir, $_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport, $liste, 1, (!empty($_POST['model']) ? $_POST['model'] : 'csv'), 1, 1, 0, 0, 0, '', 'none', '', '', ''); } llxFooter(); diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 8530c9fbede..59950289236 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -32,6 +32,8 @@ 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. +AtLeastOneMeasureIsRequired=At least 1 field for measure is required +AtLeastOneXAxisIsRequired=At least 1 field for X-Axis is required Notify_ORDER_VALIDATE=Sales order validated Notify_ORDER_SENTBYMAIL=Sales order sent by mail