From 4477b7f19fbc8deced8e454dd6f40698b1b8444c Mon Sep 17 00:00:00 2001 From: ttpllt46 <“praneet_s@tekditechnologies.com”> Date: Tue, 22 Jun 2021 19:45:15 +0530 Subject: [PATCH 1/8] Issue #172665 feat: Support set of filters in TjReports --- tjreports/site/assets/js/tjrContentUI.js | 24 +- tjreports/site/models/reports.php | 30 +- .../views/reports/tmpl/default_filters.php | 383 ++++++++++++++---- tjreports/site/views/reports/view.base.php | 23 +- 4 files changed, 356 insertions(+), 104 deletions(-) mode change 100644 => 100755 tjreports/site/views/reports/tmpl/default_filters.php diff --git a/tjreports/site/assets/js/tjrContentUI.js b/tjreports/site/assets/js/tjrContentUI.js index 6fcc4a5..baccdfa 100755 --- a/tjreports/site/assets/js/tjrContentUI.js +++ b/tjreports/site/assets/js/tjrContentUI.js @@ -12,13 +12,13 @@ tjrContentUI.root_url = (typeof root_url == 'undefined') ? '' : root_url; tjrContentUI.base_url = (typeof root_url == 'undefined') ? '' : root_url; tjrContentUI.report = tjrContentUI.report ? tjrContentUI.report : {}; - +addMorefilterCnt = 1; jQuery.extend(tjrContentUI.report, { searchToggle: true, $form: null, url: 'index.php?option=com_tjreports&view=reports&format=json', querySaveUrl: 'index.php?option=com_tjreports&format=json', - submitTJRData: function(task) { + submitTJRData: function(task, addMorefilter, removeFilter = '') { // Set the view layout on the basis of task task = (typeof task == 'undefined' ) ? 'default' : task; @@ -47,6 +47,25 @@ jQuery.extend(tjrContentUI.report, { this.searchToggle = jQuery('div#topFilters').is(':visible'); tjrContentUI.utility.loadingLayer('show'); this.$form = jQuery('#adminForm'); + + if (addMorefilterCnt >= 1) + { + if (parseInt(addMorefilter) === 1) + { + addMorefilterCnt++; + } + else if (Number.isInteger(removeFilter)) + { + addMorefilterCnt--; + } + + jQuery('#tjReportaddMorefilter').remove(); + this.$form.append(''); + + jQuery('#tjReportremoveFilter').remove(); + this.$form.append(''); + } + var doProcess = this.validate(); if (!doProcess) { return false; @@ -138,6 +157,7 @@ jQuery.extend(tjrContentUI.report, { .val('') .removeAttr('checked') .removeAttr('selected'); + addMorefilterCnt = 1; tjrContentUI.report.submitTJRData(task); }, validate: function() { diff --git a/tjreports/site/models/reports.php b/tjreports/site/models/reports.php index 2cd5968..bcbd3fc 100755 --- a/tjreports/site/models/reports.php +++ b/tjreports/site/models/reports.php @@ -117,6 +117,9 @@ class TjreportsModelReports extends ListModel */ public $supportedFieldTypesForSummaryReport = array ('radio', 'checkbox', 'rating'); + + public $allowToCreateResultSets = false; + /** * Constructor. * @@ -730,11 +733,34 @@ protected function getListQuery() { if ($dispFilter['type'] == 'custom') { - $query->where(sprintf($dispFilter['searchin'], $db->quote($filters[$key]))); + if ($dispFilter['search_type'] == 'select' && $dispFilter['multiple'] && is_array($filters[$key])) + { + $filters[$key] = array_map(array($db, 'quote'), $filters[$key]); + + // Create safe string of array. + $filters[$key] = implode(',', $filters[$key]); + $query->where(sprintf($dispFilter['searchin'], $filters[$key])); + } + else + { + $query->where(sprintf($dispFilter['searchin'], $db->quote($filters[$key]))); + } } else { - $query->where($db->quoteName($columnName) . '=' . $db->quote($filters[$key])); + if ($dispFilter['search_type'] == 'select' && $dispFilter['multiple'] && is_array($filters[$key])) + { + $filters[$key] = array_map(array($db, 'quote'), $filters[$key]); + + // Create safe string of array. + $filters[$key] = implode(',', $filters[$key]); + + $query->where($db->quoteName($columnName) . ' IN (' . $filters[$key] . ')'); + } + else + { + $query->where($db->quoteName($columnName) . '=' . $db->quote($filters[$key])); + } } } else diff --git a/tjreports/site/views/reports/tmpl/default_filters.php b/tjreports/site/views/reports/tmpl/default_filters.php old mode 100644 new mode 100755 index bb41736..edf7d65 --- a/tjreports/site/views/reports/tmpl/default_filters.php +++ b/tjreports/site/views/reports/tmpl/default_filters.php @@ -19,123 +19,258 @@ $classForShowHide = 'col-filter-header'; } -foreach($displayFilters as $searchKey => $filter) +if ($this->addMorefilter && $this->allowToCreateResultSets) { - $searchType = $filter['search_type']; - $searchValue = isset($filters[$searchKey]) ? $filters[$searchKey] : ''; - $filterHtml = ''; - $filterHide = $searchValue === '' ? 'filter-hide' : 'filter-show'; + $removeFilter = ''; - if ($searchType == 'text') + if (isset($this->removeFilter) && $this->removeFilter != '' && $this->removeFilter != 0) { - $filterHtml = '
- - - - -
'; - - if(isset($this->colKey)) - { - $filterHtml .= JHtml::_('grid.sort', '', $this->colKey, $this->listDirn, $this->listOrder); - } - } - elseif($searchType == 'select' && isset($filter['select_options'])) - { - $svalue = isset($filter['select_value']) ? $filter['select_value'] : "value"; - $stext = isset($filter['select_text']) ? $filter['select_text'] : "text"; + $removeFilter = (int) $this->removeFilter; - $filterHtml = '
'; + unset($filters['options-' . $removeFilter]); - $filterHtml .= JHtml::_('select.genericlist', $filter['select_options'], 'filters[' . $searchKey . ']', - 'class="filter-input ' . $filterHide . '" size="1" onchange="tjrContentUI.report.submitTJRData();"', - $svalue, $stext, $searchValue); + $filterInc = 0; + $tempFilter = array(); - if ($this->filterLevel == 1) + foreach ($filters as $f_key => $f_value) { - $filterHtml .= '
'; - } - else - { - $filterHtml .= ' - - '; + $tempFilter['options-' . $filterInc] = $f_value; + $filterInc++; } - if(isset($this->colKey)) - { - $filterHtml .= JHtml::_('grid.sort', '', $this->colKey, $this->listDirn, $this->listOrder); - } + $filters = $tempFilter; } - elseif($searchType == 'date.range' || $searchType == 'calendar') + + for ((int) $i = 0; $i < $this->addMorefilter; $i++) { - $j = ($searchType == 'date.range') ? 2 : 1; + if ($i >= 1) + { + echo '
'; + } + ?> +
- for ($i=1; $i<=$j; $i++) + $filter) { - $altfieldKey = ''; + $searchType = $filter['search_type']; + $searchValue = isset($filters['options-' . $i][$searchKey]) ? $filters['options-' . $i][$searchKey] : ''; + $filterHtml = ''; + $filterHide = $searchValue === '' ? 'filter-hide' : 'filter-show'; - if ($searchType == 'date.range') + if ($searchType == 'text') { - $fieldKey = ($i == 1) ? ($searchKey . '_from') : ($searchKey . '_to'); - $altfieldKey = ($i == 1) ? ($searchKey . '_to') : ($searchKey . '_from'); + $filterHtml = '
+ + + + +
'; + + if(isset($this->colKey)) + { + $filterHtml .= JHtml::_('grid.sort', '', $this->colKey, $this->listDirn, $this->listOrder); + } } - else + elseif($searchType == 'select' && isset($filter['select_options'])) { - $fieldKey = $searchKey; - } + $svalue = isset($filter['select_value']) ? $filter['select_value'] : "value"; + $stext = isset($filter['select_text']) ? $filter['select_text'] : "text"; + $multiple = isset($filter['multiple']) && $filter['multiple'] ? "multiple='true'" : ""; + $arrayFilter = isset($filter['multiple']) && $filter['multiple'] ? "[]" : ""; + $class = isset($filter['class']) ? $filter['class'] : ""; - $searchValue = isset($filters[$fieldKey]) ? $filters[$fieldKey] : ''; - $dateFormat = isset($filters['dateFormat']) ? $filters['dateFormat'] : '%Y-%m-%d'; + $filterHtml = '
'; - if ($j == 2) - { - $altSearchValue = isset($filters[$altfieldKey]) ? $filters[$altfieldKey] : ''; - $filterHide = ($searchValue === '' && $altSearchValue === '') ? 'filter-hide' : 'filter-show'; + $filterHtml .= JHtml::_('select.genericlist', $filter['select_options'], 'filters[options-' . $i . '][' . $searchKey . ']' . $arrayFilter, + 'class="filter-input ' . $filterHide . ' ' . $class . ' " size="1" onchange="tjrContentUI.report.submitTJRData();"' . $multiple, + $svalue, $stext, $searchValue); + + if ($this->filterLevel == 1) + { + $filterHtml .= '
'; + } + else + { + $filterHtml .= ' + +
'; + } + + if(isset($this->colKey)) + { + $filterHtml .= JHtml::_('grid.sort', '', $this->colKey, $this->listDirn, $this->listOrder); + } } - else + elseif($searchType == 'date.range' || $searchType == 'calendar') { - $filterHide = $searchValue === '' ? 'filter-hide' : 'filter-show'; - } + $j = ($searchType == 'date.range') ? 2 : 1; + + for ($i=1; $i<=$j; $i++) + { + $altfieldKey = ''; + + if ($searchType == 'date.range') + { + $fieldKey = ($i == 1) ? ($searchKey . '_from') : ($searchKey . '_to'); + $altfieldKey = ($i == 1) ? ($searchKey . '_to') : ($searchKey . '_from'); + } + else + { + $fieldKey = $searchKey; + } + + $searchValue = isset($filters['options-' . $i][$fieldKey]) ? $filters['options-' . $i][$fieldKey] : ''; + $dateFormat = isset($filters['dateFormat']) ? $filters['dateFormat'] : '%Y-%m-%d'; + + if ($j == 2) + { + $altSearchValue = isset($filters[$altfieldKey]) ? $filters[$altfieldKey] : ''; + $filterHide = ($searchValue === '' && $altSearchValue === '') ? 'filter-hide' : 'filter-show'; + } + else + { + $filterHide = $searchValue === '' ? 'filter-hide' : 'filter-show'; + } + + $attrib = array('class' => 'tjrsmall-input dash-calendar validate-ymd-date ' . $filterHide); + + if (isset($filter[$fieldKey]['attrib'])) + { + $fieldAttr = array_merge($filter[$fieldKey]['attrib'], $attrib); + } + elseif (isset($filter['attrib'])) + { + $fieldAttr = array_merge($filter['attrib'], $attrib); + } + else + { + $fieldAttr = $attrib; + } - $attrib = array('class' => 'tjrsmall-input dash-calendar validate-ymd-date ' . $filterHide); + $filterHtml .= ''; + } + elseif ($this->filterLevel != 1 && $i != 1 || $searchType == 'calendar' ) + { + $filterHtml .= ' + + '; + } + + if(isset($this->colKey)) + { + $filterHtml .= JHtml::_('grid.sort', '', $this->colKey, $this->listDirn, $this->listOrder); + } + } + } + elseif($searchType == 'html') { - $fieldAttr = array_merge($filter[$fieldKey]['attrib'], $attrib); + $filterHtml = $filter['html']; } - elseif (isset($filter['attrib'])) + ?> + + + filterLevel == 1) + { + ?> +
+ + + + +
+ + + $filter) + { + $searchType = $filter['search_type']; + $searchValue = isset($filters[$searchKey]) ? $filters[$searchKey] : ''; + $filterHtml = ''; + $filterHide = $searchValue === '' ? 'filter-hide' : 'filter-show'; + + if ($searchType == 'text') + { + $filterHtml = '
+ + + + +
'; + + if(isset($this->colKey)) { - $fieldAttr = $attrib; + $filterHtml .= JHtml::_('grid.sort', '', $this->colKey, $this->listDirn, $this->listOrder); } + } + elseif($searchType == 'select' && isset($filter['select_options'])) + { + $svalue = isset($filter['select_value']) ? $filter['select_value'] : "value"; + $stext = isset($filter['select_text']) ? $filter['select_text'] : "text"; + $multiple = isset($filter['multiple']) && $filter['multiple'] ? "multiple='true'" : ""; + $arrayFilter = isset($filter['multiple']) && $filter['multiple'] ? "[]" : ""; + $class = isset($filter['class']) ? $filter['class'] : ""; + + $filterHtml = '
'; - $filterHtml .= ''; } - elseif ($this->filterLevel != 1 && $i != 1 || $searchType == 'calendar' ) + else { - $filterHtml .= ' - -
'; + $filterHtml .= ' + + '; } if(isset($this->colKey)) @@ -143,14 +278,82 @@ class="input input-mini filter-input ' . $filterHide . '" ' . $filterHtml .= JHtml::_('grid.sort', '', $this->colKey, $this->listDirn, $this->listOrder); } } + elseif($searchType == 'date.range' || $searchType == 'calendar') + { + $j = ($searchType == 'date.range') ? 2 : 1; + + for ($i=1; $i<=$j; $i++) + { + $altfieldKey = ''; + + if ($searchType == 'date.range') + { + $fieldKey = ($i == 1) ? ($searchKey . '_from') : ($searchKey . '_to'); + $altfieldKey = ($i == 1) ? ($searchKey . '_to') : ($searchKey . '_from'); + } + else + { + $fieldKey = $searchKey; + } + + $searchValue = isset($filters[$fieldKey]) ? $filters[$fieldKey] : ''; + $dateFormat = isset($filters['dateFormat']) ? $filters['dateFormat'] : '%Y-%m-%d'; + + if ($j == 2) + { + $altSearchValue = isset($filters[$altfieldKey]) ? $filters[$altfieldKey] : ''; + $filterHide = ($searchValue === '' && $altSearchValue === '') ? 'filter-hide' : 'filter-show'; + } + else + { + $filterHide = $searchValue === '' ? 'filter-hide' : 'filter-show'; + } + + $attrib = array('class' => 'tjrsmall-input dash-calendar validate-ymd-date ' . $filterHide); + + if (isset($filter[$fieldKey]['attrib'])) + { + $fieldAttr = array_merge($filter[$fieldKey]['attrib'], $attrib); + } + elseif (isset($filter['attrib'])) + { + $fieldAttr = array_merge($filter['attrib'], $attrib); + } + else + { + $fieldAttr = $attrib; + } + + $filterHtml .= ''; + } + elseif ($this->filterLevel != 1 && $i != 1 || $searchType == 'calendar' ) + { + $filterHtml .= ' + + '; + } + + if(isset($this->colKey)) + { + $filterHtml .= JHtml::_('grid.sort', '', $this->colKey, $this->listDirn, $this->listOrder); + } + } + } + elseif($searchType == 'html') + { + $filterHtml = $filter['html']; + } + ?> + + - - showHideColumns = array_intersect($this->model->showhideCols, array_merge($this->defaultColToshow, $this->defaultColToHide)); } - $this->sortable = $this->model->sortableColumns; - $this->emailColumn = $this->model->getState('emailColumn'); - $this->srButton = $this->model->showSearchResetButton; - $this->colToshow = $this->model->getState('colToshow'); - $this->filterValues = $this->model->getState('filters'); - $this->userFilters = $this->model->displayFilters(); - $this->messages = $this->model->getTJRMessages(); - $this->showSummaryReport = $this->model->getState('showSummaryReport'); - $this->enableReportPlugins = $this->model->getenableReportPlugins($this->client); - $this->isExport = $user->authorise('core.export', 'com_tjreports.tjreport.' . $this->reportId); + $this->sortable = $this->model->sortableColumns; + $this->emailColumn = $this->model->getState('emailColumn'); + $this->srButton = $this->model->showSearchResetButton; + $this->colToshow = $this->model->getState('colToshow'); + $this->filterValues = $this->model->getState('filters'); + $this->userFilters = $this->model->displayFilters(); + $this->messages = $this->model->getTJRMessages(); + $this->showSummaryReport = $this->model->getState('showSummaryReport'); + $this->enableReportPlugins = $this->model->getenableReportPlugins($this->client); + $this->isExport = $user->authorise('core.export', 'com_tjreports.tjreport.' . $this->reportId); + $this->allowToCreateResultSets = $this->model->allowToCreateResultSets; + $this->addMorefilter = $input->get('addMorefilter', 1, 'INT'); + $this->removeFilter = $input->get('removeFilter', '', 'STRING'); return true; } From 1af597e946c23d04a251a1c587138a33f3d195eb Mon Sep 17 00:00:00 2001 From: Komal Mane Date: Thu, 24 Jun 2021 12:34:53 +0530 Subject: [PATCH 2/8] Task #172689 fix: Allow js to override (#215) --- tjreports/site/views/reports/view.html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tjreports/site/views/reports/view.html.php b/tjreports/site/views/reports/view.html.php index 9037021..3afd01a 100755 --- a/tjreports/site/views/reports/view.html.php +++ b/tjreports/site/views/reports/view.html.php @@ -159,8 +159,8 @@ protected function addDocumentHeaderData() HTMLHelper::stylesheet(Uri::root() . '/media/techjoomla_strapper/bs3/css/bootstrap.min.css'); } - HTMLHelper::_('script', 'components/com_tjreports/assets/js/tjrContentService.min.js'); - HTMLHelper::_('script', 'components/com_tjreports/assets/js/tjrContentUI.min.js'); + HTMLHelper::_('script', 'components/com_tjreports/assets/js/tjrContentService.min.js', array("relative" => true)); + HTMLHelper::_('script', 'components/com_tjreports/assets/js/tjrContentUI.min.js', array("relative" => true)); HTMLHelper::_('stylesheet', 'components/com_tjreports/assets/css/tjreports.min.css'); $document->addScriptDeclaration('tjrContentUI.base_url = "' . Uri::base() . '"'); From 5aa33fa90aef81dddb86a00e4cc34f8775337037 Mon Sep 17 00:00:00 2001 From: ttpllt46 <“praneet_s@tekditechnologies.com”> Date: Thu, 24 Jun 2021 17:07:48 +0530 Subject: [PATCH 3/8] Issue #172665 feat: Support set of filters in TjReports --- tjreports/site/views/reports/view.csv.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tjreports/site/views/reports/view.csv.php b/tjreports/site/views/reports/view.csv.php index ee81654..8311f32 100644 --- a/tjreports/site/views/reports/view.csv.php +++ b/tjreports/site/views/reports/view.csv.php @@ -104,6 +104,11 @@ private function getItems() JModelLegacy::addIncludePath(JPATH_SITE . '/plugins/tjreports/' . $pluginName); $model = JModelLegacy::getInstance($pluginName, 'TjreportsModel'); + if ($model->allowToCreateResultSets) + { + $model->addMorefilter = $input->get('addMorefilter', 1, 'INT'); + } + $model->loadLanguage($pluginName); $input->set('limit', $this->limit); From cf89f69061caa37d69b84d082eb612e5dc30f7e6 Mon Sep 17 00:00:00 2001 From: ttpllt46 <“praneet_s@tekditechnologies.com”> Date: Thu, 24 Jun 2021 17:48:41 +0530 Subject: [PATCH 4/8] Issue #172665 feat: Support set of filters in TjReports --- tjreports/site/views/reports/view.base.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tjreports/site/views/reports/view.base.php b/tjreports/site/views/reports/view.base.php index 7761e13..94f0cce 100644 --- a/tjreports/site/views/reports/view.base.php +++ b/tjreports/site/views/reports/view.base.php @@ -144,6 +144,11 @@ public function processData($type = 'html') $param = json_decode($queryData->param, true); $postFilters = $this->model->getValidRequestVars(); + if ($this->model->allowToCreateResultSets) + { + $input->set('addMorefilter', count($param['filters'])); + } + foreach ($postFilters as $postFilter => $filterType) { if (isset($param[$postFilter])) From 834f4da341181f2bd9229ef94b67cc9e3592014c Mon Sep 17 00:00:00 2001 From: ttpllt46 <“praneet_s@tekditechnologies.com”> Date: Mon, 28 Jun 2021 12:52:46 +0530 Subject: [PATCH 5/8] Issue #172665 feat: Support set of filters in TjReports --- tjreports/site/assets/js/tjrContentUI.js | 10 +++++++++ tjreports/site/assets/js/tjrContentUI.min.js | 2 +- tjreports/site/models/reports.php | 9 +++++++- .../views/reports/tmpl/default_filters.php | 21 ++++++++++--------- tjreports/site/views/reports/view.base.php | 16 ++++++++++++-- tjreports/site/views/reports/view.csv.php | 2 ++ 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/tjreports/site/assets/js/tjrContentUI.js b/tjreports/site/assets/js/tjrContentUI.js index baccdfa..b3afee0 100755 --- a/tjreports/site/assets/js/tjrContentUI.js +++ b/tjreports/site/assets/js/tjrContentUI.js @@ -482,6 +482,16 @@ jQuery.extend(tjrContentUI.utility, { eraseJSCookie:function(name) { tjrContentUI.utility.setJSCookie(name,"",-1); }, + initiateChznPlaceholders:function(placeHolders) + { + jQuery(document).ready(function () { + for (let i = 0; i < parseInt(addMorefilterCnt); i++) { + for (let x in placeHolders) { + jQuery('#filtersoptions_' + i + x + '_chzn').find('li.search-field input.default').val(placeHolders[x]); + } + } + }); + } }); tjrContentUI.tjreport = tjrContentUI.tjreport ? tjrContentUI.tjreport : {}; jQuery.extend(tjrContentUI.tjreport, { diff --git a/tjreports/site/assets/js/tjrContentUI.min.js b/tjreports/site/assets/js/tjrContentUI.min.js index b5dabfb..ee2c258 100644 --- a/tjreports/site/assets/js/tjrContentUI.min.js +++ b/tjreports/site/assets/js/tjrContentUI.min.js @@ -1 +1 @@ -if(void 0===tjrContentUI)var tjrContentUI={};tjrContentUI.root_url="undefined"==typeof root_url?"":root_url,tjrContentUI.base_url="undefined"==typeof root_url?"":root_url,tjrContentUI.report=tjrContentUI.report?tjrContentUI.report:{},jQuery.extend(tjrContentUI.report,{searchToggle:!0,$form:null,url:"index.php?option=com_tjreports&view=reports&format=json",querySaveUrl:"index.php?option=com_tjreports&format=json",submitTJRData:function(e){var t="default";if("summary"==(e=void 0===e?"default":e)?(t="summary",jQuery("#summaryReportLabel").addClass("btn-danger"),jQuery("#detailsReportLabel").removeClass("btn-success"),jQuery("#reportPagination").hide(),jQuery("#pagination").hide()):(jQuery("#detailsReportLabel").removeClass("btn-success"),jQuery("#summaryReportLabel").removeClass("btn-danger"),jQuery("#reportPagination").show(),jQuery("#pagination").show()),jQuery("#reports-container .hasTooltip").tooltip("destroy"),this.searchToggle=jQuery("div#topFilters").is(":visible"),tjrContentUI.utility.loadingLayer("show"),this.$form=jQuery("#adminForm"),!this.validate())return!1;jQuery(".hasPopover").popover("destroy"),tjrContentService.postData(this.url+"&tpl="+t,this.$form.serialize()).fail(function(e){console.log("Something went wrong."),tjrContentUI.utility.loadingLayer("hide"),403==e.status&&alert(Joomla.JText._("JERROR_ALERTNOAUTHOR"))}).done(function(r){if(tjrContentUI.utility.loadingLayer("hide"),"summary"==t)jQuery("#report-containing-div").html(r.html);else{var o=jQuery(r.html).find("#j-main-container").html();jQuery("#j-main-container").html(o),"undefined"!=typeof tjutilitysendemail&&jQuery("body").find(".td-sendemail").length>0&&tjutilitysendemail.addColumn("report-table"),jQuery(".hasPopover").popover({html:!0,trigger:"hover focus",container:"body"}),"showHide"==e&&tjrContentUI.report.getColNames();var n=jQuery("#j-main-container .field-calendar");for(i=0;i").html(e);return t.find("script").remove(),e=t.html()},displayMessage:function(e,t,r){this.parent.validation.messages={},this.parent.validation.addMessage(e,t),this.displayMessages()},displayMessages:function(e){Joomla.removeMessages(),Joomla.renderMessages(this.parent.validation.messages),e&&jQuery("body").animate({scrollTop:jQuery("#system-message-container").offset().top},500)},setJSCookie:function(e,t,r){var o="";if(r){var n=new Date;n.setTime(n.getTime()+24*r*60*60*1e3),o="; expires="+n.toUTCString()}document.cookie=e+"="+t+o+"; path=/"},getJSCookie:function(e){for(var t=e+"=",r=document.cookie.split(";"),o=0;o=1&&(1===parseInt(t)?addMorefilterCnt++:Number.isInteger(r)&&addMorefilterCnt--,jQuery("#tjReportaddMorefilter").remove(),this.$form.append('").html(e);return t.find("script").remove(),e=t.html()},displayMessage:function(e,t,r){this.parent.validation.messages={},this.parent.validation.addMessage(e,t),this.displayMessages()},displayMessages:function(e){Joomla.removeMessages(),Joomla.renderMessages(this.parent.validation.messages),e&&jQuery("body").animate({scrollTop:jQuery("#system-message-container").offset().top},500)},setJSCookie:function(e,t,r){var o="";if(r){var n=new Date;n.setTime(n.getTime()+24*r*60*60*1e3),o="; expires="+n.toUTCString()}document.cookie=e+"="+t+o+"; path=/"},getJSCookie:function(e){for(var t=e+"=",r=document.cookie.split(";"),o=0;oallowToCreateResultSets is true if ($this->addMorefilter && $this->allowToCreateResultSets) { $removeFilter = ''; @@ -41,9 +42,9 @@ $filters = $tempFilter; } - for ((int) $i = 0; $i < $this->addMorefilter; $i++) + for ((int) $filterCnt = 0; $filterCnt < $this->addMorefilter; $filterCnt++) { - if ($i >= 1) + if ($filterCnt >= 1) { echo '
'; } @@ -54,14 +55,14 @@ foreach ($displayFilters as $searchKey => $filter) { $searchType = $filter['search_type']; - $searchValue = isset($filters['options-' . $i][$searchKey]) ? $filters['options-' . $i][$searchKey] : ''; + $searchValue = isset($filters['options-' . $filterCnt][$searchKey]) ? $filters['options-' . $filterCnt][$searchKey] : ''; $filterHtml = ''; $filterHide = $searchValue === '' ? 'filter-hide' : 'filter-show'; if ($searchType == 'text') { $filterHtml = '
- filterLevel == 1) { @@ -199,10 +200,10 @@ class="input input-mini filter-input ' . $filterHide . '" ' . - param, true); $postFilters = $this->model->getValidRequestVars(); + // Check if multiple result sets are allowed in the Report if ($this->model->allowToCreateResultSets) { + if (count($param['filters']) >= 1) + { + // Initiate the number of filter sets count + Factory::getDocument()->addScriptDeclaration('addMorefilterCnt = ' . count($param['filters'])); + } + + // Post the count of filter set to set the filters in the saved report $input->set('addMorefilter', count($param['filters'])); } @@ -228,9 +236,13 @@ public function processData($type = 'html') $this->showSummaryReport = $this->model->getState('showSummaryReport'); $this->enableReportPlugins = $this->model->getenableReportPlugins($this->client); $this->isExport = $user->authorise('core.export', 'com_tjreports.tjreport.' . $this->reportId); + + // This will be used to create multiple result sets $this->allowToCreateResultSets = $this->model->allowToCreateResultSets; - $this->addMorefilter = $input->get('addMorefilter', 1, 'INT'); - $this->removeFilter = $input->get('removeFilter', '', 'STRING'); + + // These two are used to generate filters sets similar to addMore in subforms + $this->addMorefilter = $input->get('addMorefilter', 1, 'INT'); + $this->removeFilter = $input->get('removeFilter', '', 'STRING'); return true; } diff --git a/tjreports/site/views/reports/view.csv.php b/tjreports/site/views/reports/view.csv.php index 8311f32..1d1c40c 100644 --- a/tjreports/site/views/reports/view.csv.php +++ b/tjreports/site/views/reports/view.csv.php @@ -104,8 +104,10 @@ private function getItems() JModelLegacy::addIncludePath(JPATH_SITE . '/plugins/tjreports/' . $pluginName); $model = JModelLegacy::getInstance($pluginName, 'TjreportsModel'); + // Check if multiple filters set are enabled in the report if ($model->allowToCreateResultSets) { + // Set the number of filter sets count in order to get correct CSV report $model->addMorefilter = $input->get('addMorefilter', 1, 'INT'); } From 104fc69d7f4bca7438bc2f6b4cfd0d2c76e33f9a Mon Sep 17 00:00:00 2001 From: ttpllt46 <“praneet_s@tekditechnologies.com”> Date: Mon, 28 Jun 2021 13:44:57 +0530 Subject: [PATCH 6/8] Issue #172665 feat: Cosmetic changes --- tjreports/site/assets/css/tjreports.css | 1 + tjreports/site/assets/css/tjreports.min.css | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tjreports/site/assets/css/tjreports.css b/tjreports/site/assets/css/tjreports.css index 6427662..b19af0e 100755 --- a/tjreports/site/assets/css/tjreports.css +++ b/tjreports/site/assets/css/tjreports.css @@ -60,6 +60,7 @@ div#topFilters div.filter-search { display: inline-block; float: left; margin-right: 5px; + padding: 2px; } div#topFilters { diff --git a/tjreports/site/assets/css/tjreports.min.css b/tjreports/site/assets/css/tjreports.min.css index a3a0ece..aa51a9d 100644 --- a/tjreports/site/assets/css/tjreports.min.css +++ b/tjreports/site/assets/css/tjreports.min.css @@ -1 +1 @@ -.other-filters{padding:0 14px}.hasPopover{display:block!important}a[disabled]{pointer-events:none}.show-hide-cols{position:relative}.ColVis_collection{list-style:none;min-width:150px;padding:8px 8px 4px 8px;margin:0;border:1px solid #ccc;border:1px solid rgba(0,0,0,.4);background-color:#f9f9f9;overflow:hidden;display:block;opacity:1;position:absolute;z-index:1}table#report-table .chzn-container{width:150px!important}ul#ul-columns-name li input{margin-top:0}ul#ul-columns-name li:hover label{background-color:#f0f0f0}ul#ul-columns-name li label{margin-bottom:0;padding-top:2px;padding-bottom:2px;cursor:pointer}div#report-containing-div{min-height:450px}div#reports-container .form-inline-header .controls{padding-right:5px}div#topFilters div.filter-search{display:inline-block;float:left;margin-right:5px}div#topFilters{margin-top:10px;float:left;width:100%}.ColVis_collection{display:none}#topFilters{display:none}#queryName{display:none}.header_title{display:inline-block}th.center:nth-child(odd){background-color:#d9edf7;border-left:1px solid #ddd}th.center:nth-child(even){background-color:#fcf8e3;border-left:1px solid #ddd}td.subdetails.lesson.attempts_done:nth-child(odd),th.subdetails.lesson.attempts_done:nth-child(odd){border-left:1px solid #ddd}table.tjrport-table{border-bottom:1px solid #ddd}#reportPagination .pagination.pagination-toolbar.clearfix{margin:0}#t3-content #report-table thead input{height:100%;max-width:120px}#t3-content #queryName{height:32px;font-size:14px}.report-top-bar{margin-top:10px}#t3-content .form-group{margin-bottom:15px}#reports-container h2{font-weight:500}#t3-mainbody #reports-container .field-calendar .tjrsmall-input{display:inline-block;height:32px!important;max-width:165px;font-size:14px}.report-tbl{min-height:450px!important;overflow-x:auto}#t3-mainbody #report-containing-div .table-responsive{margin-top:20px}#t3-content #reports-container .btn{padding:4px 12px;text-transform:none;font-size:14px}#t3-mainbody #report-table .custom-group{display:table;border-collapse:separate;margin-bottom:0}#content div.row{margin-left:0;margin-right:0}#t3-mainbody #report-table .custom-group-btn{vertical-align:baseline}.t3-content .btn-custom{color:#fff;background-color:#337ab7;border-color:#2e6da4}.t3-content .btn-custom:hover{color:#fff;background-color:#286090;border-color:#204d74}.t3-content .btn-custom:active{color:#fff;background-color:#286090;border-color:#204d74}.t3-content .btn-custom:focus{color:#fff;background-color:#286090;border-color:#204d74}.t3-content .btn-custom.active.focus,.t3-content .btn-custom.active:focus,.t3-content .btn-custom.active:hover,.t3-content .btn-custom:active.focus,.t3-content .btn-custom:active:focus,.t3-content .btn-custom:active:hover{color:#fff;background-color:#204d74;border-color:#122b40}#t3-content.chzn-container-single .chzn-single{height:32px;border-radius:0;background:no-repeat;padding-left:15px}#t3-content #report-table .chzn-container-single .chzn-single span,b{margin-top:3px}#t3-content .filter-search .chzn-container-single .chzn-single{height:32px;border-radius:0;background:no-repeat;padding-left:15px}#t3-content .filter-search .chzn-container-single .chzn-single b,#t3-content .filter-search .chzn-container-single .chzn-single span{margin-top:3px}#reports-container .ordering-select .input-group-btn,#t3-content #report-table .input-group-btn{width:0}.ordering-select a.chzn-single,.view-reports select{height:35px!important}#reports-container .input-append .field-calendar{font-size:14px}#reports-container .input-group .field-calendar .input-append,.view-reports .j-toggle-main input[type=text]{margin-bottom:0}#reports-container .filter-search .input-group-btn{border:1px solid #ccc;border-radius:0}.table-responsive.report-tbl .js-calendar{margin-top:0!important}.view-reports .chzn-container .chzn-single,.view-reports a.btn,.view-reports button,.view-reports button.btn,.view-reports input[type=button],.view-reports input[type=text],.view-reports select{height:35px;padding-top:6px!important;padding-bottom:6px!important;border-radius:0!important;box-shadow:none;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;line-height:18px!important}.view-reports #toolbar [class^=icon-]{height:28px;padding-top:5px!important}.view-reports #toolbar .export{padding-top:0!important;padding-bottom:0!important}@media screen and (max-width:767px){.table-responsive{width:100%;margin-bottom:15px;overflow-y:hidden;-ms-overflow-style:-ms-autohiding-scrollbar;border:1px solid #ddd}.show-hide-cols{margin-bottom:20px}#show-hide-cols-btn{width:100%}#queryName{margin-bottom:10px!important}.btn-csv{margin-bottom:20px}#t3-content #report-table .input-append input,#t3-content #report-table .input-append select{margin-bottom:0!important;width:auto}}@media screen and (max-width:768px){#t3-content #show-filter{margin-bottom:20px}#filterscourse_id,.ordering-select #filtersreport_filter{margin-bottom:20px}}@media (max-width:1024px) and (min-width:768px){.t3-content .row-fluid [class*=span]{margin-left:0}}.m-0{margin:0!important}.equal-height-col{display:flex;flex-wrap:wrap;margin-top:20px}.equal-height-col>.equal-items{display:flex;flex-direction:column}.tj-card{border:1px solid #f0f0f0;height:100%;-webkit-box-shadow:0 1px 4px 0 rgba(0,0,0,.3);-moz-box-shadow:0 1px 4px 0 rgba(0,0,0,.3);box-shadow:0 1px 4px 0 rgba(0,0,0,.3);border-radius:5px}.tj-card-title{border-bottom:1px solid #f0f0f0;margin:0!important;padding:15px;font-size:15px;font-weight:700}.tj-card-body{margin:15px 0}.chartItems{margin-bottom:30px}.summaryReport{margin-top:0!important} +.other-filters{padding:0 14px}.hasPopover{display:block!important}a[disabled]{pointer-events:none}.show-hide-cols{position:relative}.ColVis_collection{list-style:none;min-width:150px;padding:8px 8px 4px 8px;margin:0;border:1px solid #ccc;border:1px solid rgba(0,0,0,.4);background-color:#f9f9f9;overflow:hidden;display:block;opacity:1;position:absolute;z-index:1}table#report-table .chzn-container{width:150px!important}ul#ul-columns-name li input{margin-top:0}ul#ul-columns-name li:hover label{background-color:#f0f0f0}ul#ul-columns-name li label{margin-bottom:0;padding-top:2px;padding-bottom:2px;cursor:pointer}div#report-containing-div{min-height:450px}div#reports-container .form-inline-header .controls{padding-right:5px}div#topFilters div.filter-search{display:inline-block;float:left;margin-right:5px;padding:2px}div#topFilters{margin-top:10px;float:left;width:100%}.ColVis_collection{display:none}#topFilters{display:none}#queryName{display:none}.header_title{display:inline-block}th.center:nth-child(odd){background-color:#d9edf7;border-left:1px solid #ddd}th.center:nth-child(even){background-color:#fcf8e3;border-left:1px solid #ddd}td.subdetails.lesson.attempts_done:nth-child(odd),th.subdetails.lesson.attempts_done:nth-child(odd){border-left:1px solid #ddd}table.tjrport-table{border-bottom:1px solid #ddd}#reportPagination .pagination.pagination-toolbar.clearfix{margin:0}#t3-content #report-table thead input{height:100%;max-width:120px}#t3-content #queryName{height:32px;font-size:14px}.report-top-bar{margin-top:10px}#t3-content .form-group{margin-bottom:15px}#reports-container h2{font-weight:500}#t3-mainbody #reports-container .field-calendar .tjrsmall-input{display:inline-block;height:32px!important;max-width:165px;font-size:14px}.report-tbl{min-height:450px!important;overflow-x:auto}#t3-mainbody #report-containing-div .table-responsive{margin-top:20px}#t3-content #reports-container .btn{padding:4px 12px;text-transform:none;font-size:14px}#t3-mainbody #report-table .custom-group{display:table;border-collapse:separate;margin-bottom:0}#content div.row{margin-left:0;margin-right:0}#t3-mainbody #report-table .custom-group-btn{vertical-align:baseline}.t3-content .btn-custom{color:#fff;background-color:#337ab7;border-color:#2e6da4}.t3-content .btn-custom:hover{color:#fff;background-color:#286090;border-color:#204d74}.t3-content .btn-custom:active{color:#fff;background-color:#286090;border-color:#204d74}.t3-content .btn-custom:focus{color:#fff;background-color:#286090;border-color:#204d74}.t3-content .btn-custom.active.focus,.t3-content .btn-custom.active:focus,.t3-content .btn-custom.active:hover,.t3-content .btn-custom:active.focus,.t3-content .btn-custom:active:focus,.t3-content .btn-custom:active:hover{color:#fff;background-color:#204d74;border-color:#122b40}#t3-content.chzn-container-single .chzn-single{height:32px;border-radius:0;background:no-repeat;padding-left:15px}#t3-content #report-table .chzn-container-single .chzn-single span,b{margin-top:3px}#t3-content .filter-search .chzn-container-single .chzn-single{height:32px;border-radius:0;background:no-repeat;padding-left:15px}#t3-content .filter-search .chzn-container-single .chzn-single b,#t3-content .filter-search .chzn-container-single .chzn-single span{margin-top:3px}#reports-container .ordering-select .input-group-btn,#t3-content #report-table .input-group-btn{width:0}.ordering-select a.chzn-single,.view-reports select{height:35px!important}#reports-container .input-append .field-calendar{font-size:14px}#reports-container .input-group .field-calendar .input-append,.view-reports .j-toggle-main input[type=text]{margin-bottom:0}#reports-container .filter-search .input-group-btn{border:1px solid #ccc;border-radius:0}.table-responsive.report-tbl .js-calendar{margin-top:0!important}.view-reports .chzn-container .chzn-single,.view-reports a.btn,.view-reports button,.view-reports button.btn,.view-reports input[type=button],.view-reports input[type=text],.view-reports select{height:35px;padding-top:6px!important;padding-bottom:6px!important;border-radius:0!important;box-shadow:none;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;line-height:18px!important}.view-reports #toolbar [class^=icon-]{height:28px;padding-top:5px!important}.view-reports #toolbar .export{padding-top:0!important;padding-bottom:0!important}@media screen and (max-width:767px){.table-responsive{width:100%;margin-bottom:15px;overflow-y:hidden;-ms-overflow-style:-ms-autohiding-scrollbar;border:1px solid #ddd}.show-hide-cols{margin-bottom:20px}#show-hide-cols-btn{width:100%}#queryName{margin-bottom:10px!important}.btn-csv{margin-bottom:20px}#t3-content #report-table .input-append input,#t3-content #report-table .input-append select{margin-bottom:0!important;width:auto}}@media screen and (max-width:768px){#t3-content #show-filter{margin-bottom:20px}#filterscourse_id,.ordering-select #filtersreport_filter{margin-bottom:20px}}@media (max-width:1024px) and (min-width:768px){.t3-content .row-fluid [class*=span]{margin-left:0}}.m-0{margin:0!important}.equal-height-col{display:flex;flex-wrap:wrap;margin-top:20px}.equal-height-col>.equal-items{display:flex;flex-direction:column}.tj-card{border:1px solid #f0f0f0;height:100%;-webkit-box-shadow:0 1px 4px 0 rgba(0,0,0,.3);-moz-box-shadow:0 1px 4px 0 rgba(0,0,0,.3);box-shadow:0 1px 4px 0 rgba(0,0,0,.3);border-radius:5px}.tj-card-title{border-bottom:1px solid #f0f0f0;margin:0!important;padding:15px;font-size:15px;font-weight:700}.tj-card-body{margin:15px 0}.chartItems{margin-bottom:30px}.summaryReport{margin-top:0!important} \ No newline at end of file From d7b1bcfb05e5ffbd29e6e5353720ea94df4d02ff Mon Sep 17 00:00:00 2001 From: ttpllt46 <“praneet_s@tekditechnologies.com”> Date: Mon, 28 Jun 2021 14:17:56 +0530 Subject: [PATCH 7/8] Issue #172665 feat: Cosmetic changes --- tjreports/site/views/reports/view.base.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tjreports/site/views/reports/view.base.php b/tjreports/site/views/reports/view.base.php index ccd3bac..0fdf1f6 100644 --- a/tjreports/site/views/reports/view.base.php +++ b/tjreports/site/views/reports/view.base.php @@ -150,7 +150,9 @@ public function processData($type = 'html') if (count($param['filters']) >= 1) { // Initiate the number of filter sets count - Factory::getDocument()->addScriptDeclaration('addMorefilterCnt = ' . count($param['filters'])); + Factory::getDocument()->addScriptDeclaration(' + addMorefilterCnt = ' . count($param['filters']) + ); } // Post the count of filter set to set the filters in the saved report @@ -159,6 +161,16 @@ public function processData($type = 'html') foreach ($postFilters as $postFilter => $filterType) { + if ($postFilter == 'filters' && isset($param[$postFilter]) && !empty($param['filters'])) + { + Factory::getDocument()->addScriptDeclaration(' + jQuery(document).ready(function (){ + tjrContentUI.report.showFilter(); + }); + ' + ); + } + if (isset($param[$postFilter])) { $input->set($postFilter, $param[$postFilter]); From ec8fbe699234f8ec119f4834039569003387c71b Mon Sep 17 00:00:00 2001 From: ttpllt46 <“praneet_s@tekditechnologies.com”> Date: Mon, 28 Jun 2021 14:19:44 +0530 Subject: [PATCH 8/8] Issue #172665 feat: Cosmetic changes --- tjreports/site/views/reports/view.base.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tjreports/site/views/reports/view.base.php b/tjreports/site/views/reports/view.base.php index 0fdf1f6..a513403 100644 --- a/tjreports/site/views/reports/view.base.php +++ b/tjreports/site/views/reports/view.base.php @@ -161,6 +161,7 @@ public function processData($type = 'html') foreach ($postFilters as $postFilter => $filterType) { + // If filters are set in saved queries, then by default keep the Search Tools open if ($postFilter == 'filters' && isset($param[$postFilter]) && !empty($param['filters'])) { Factory::getDocument()->addScriptDeclaration('