From d42cbf1fdf2df96f5ab3155d0450d3296ddd67a1 Mon Sep 17 00:00:00 2001 From: komal mane Date: Thu, 19 Sep 2019 10:46:00 +0530 Subject: [PATCH 1/7] Task #150780 --- tjreports/administrator/models/tjreport.php | 1 + tjreports/site/models/reports.php | 38 ++++++++++++++++--- tjreports/site/views/reports/tmpl/default.php | 9 ++++- tjreports/site/views/reports/view.base.php | 1 + 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/tjreports/administrator/models/tjreport.php b/tjreports/administrator/models/tjreport.php index 768706b..be8295d 100644 --- a/tjreports/administrator/models/tjreport.php +++ b/tjreports/administrator/models/tjreport.php @@ -177,6 +177,7 @@ public function getReportPluginData($pluginId, $pluginName = null) $params['filter_order'] = $plgModel->getState('list.ordering'); $params['filter_order_Dir'] = $plgModel->getState('list.direction'); $params['limit'] = $plgModel->getState('list.limit'); + $params['sendEmail'] = $plgModel->sendEmail; $params['colToshow'] = $plgModel->getState('colToshow'); $params['colToshow'] = array_combine($params['colToshow'], array_fill(0, count($params['colToshow']), true)); $params['showHideColumns'] = $plgModel->showhideCols; diff --git a/tjreports/site/models/reports.php b/tjreports/site/models/reports.php index c74b626..97f08a1 100755 --- a/tjreports/site/models/reports.php +++ b/tjreports/site/models/reports.php @@ -37,6 +37,9 @@ class TjreportsModelReports extends JModelList // Columns array contain columns data public $columns = array(); + // Columns array contain columns data + public $sendEmail = array(); + // Columns that a user can select to display public $showhideCols = array(); @@ -344,6 +347,12 @@ private function initData() unset($this->showhideCols[$key]); } + if ((isset($column['sendEmail']) && $column['sendEmail'] === true) + || (strpos($key, '::') !== false && !isset($column['sendEmail']))) + { + array_push($this->sendEmail, $key); + } + if ((isset($column['disable_sorting']) && $column['disable_sorting']) || (strpos($key, '::') !== false && !isset($column['disable_sorting']))) { @@ -362,10 +371,12 @@ private function initData() } } + $this->sendEmail = array_values($this->sendEmail); $this->showhideCols = array_values($this->showhideCols); $this->sortableColumns = array_values($this->sortableColumns); $this->sortableWoQuery = array_values($this->sortableWoQuery); $this->defaultColToShow = array_values($this->defaultColToShow); + } /** @@ -1065,15 +1076,15 @@ private function filterReportColumns($queryId, &$selColToshow) } $query = $this->_db->getQuery(true); - $showhideCols = $paramColToshow = array(); + $showhideCols = $paramColToshow = $sendEmail = array(); // Process plugin params - $parentId = $this->processSavedReportColumns($queryId, $showhideCols, $paramColToshow, $selColToshow); + $parentId = $this->processSavedReportColumns($queryId, $showhideCols, $paramColToshow, $selColToshow, $sendEmail); // Process if user has saved query is for a plugin if (!empty($parentId)) { - $this->processSavedReportColumns($parentId, $showhideCols, $paramColToshow, $selColToshow); + $this->processSavedReportColumns($parentId, $showhideCols, $paramColToshow, $selColToshow, $sendEmail); } // If plugin has save any column assign that otherwise default plugin param will be applied @@ -1095,6 +1106,11 @@ private function filterReportColumns($queryId, &$selColToshow) { $this->showhideCols = $showhideCols; } + + if (!empty($sendEmail)) + { + $this->sendEmail = $sendEmail; + } } /** @@ -1109,7 +1125,7 @@ private function filterReportColumns($queryId, &$selColToshow) * * @since 3.0 */ - private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow, &$selColToshow) + private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow, &$selColToshow, &$sendEmail) { $query = $this->_db->getQuery(true); $query->select(array('param', 'parent')) @@ -1135,6 +1151,18 @@ private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow } } + if (isset($param['sendEmail'])) + { + if (empty($sendEmail)) + { + $sendEmail = (array) $param['sendEmail']; + } + else + { + $sendEmail = array_intersect($sendEmail, (array) $param['sendEmail']); + } + } + if (isset($param['colToshow'])) { foreach ((array) $param['colToshow'] as $cols => $show) @@ -1228,7 +1256,7 @@ public function getReportParams($reportId) JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables'); $reportTable = JTable::getInstance('Tjreport', 'TjreportsTable', array('dbo', $db)); $reportTable->load($reportId); - + return new JRegistry($reportTable->param); } diff --git a/tjreports/site/views/reports/tmpl/default.php b/tjreports/site/views/reports/tmpl/default.php index 8ae974f..734370f 100644 --- a/tjreports/site/views/reports/tmpl/default.php +++ b/tjreports/site/views/reports/tmpl/default.php @@ -289,7 +289,7 @@ for($i = $headerLevel; $i > 0 ; $i--) { - echo ''; + echo ''; foreach($this->colToshow as $index=>$detail) { @@ -431,7 +431,12 @@ } else { - echo ''. $item[$key] .''; + $isSendEmailClass = ''; + if (in_array($key, $this->sendEmail)) + { + $isSendEmailClass = 'td-sendemail'; + } + echo ''. $item[$key] .''; } } diff --git a/tjreports/site/views/reports/view.base.php b/tjreports/site/views/reports/view.base.php index 06c348f..fda835a 100644 --- a/tjreports/site/views/reports/view.base.php +++ b/tjreports/site/views/reports/view.base.php @@ -162,6 +162,7 @@ public function processData($type = 'html') $this->columns = $this->model->columns; $this->showHideColumns = $this->model->showhideCols; $this->sortable = $this->model->sortableColumns; + $this->sendEmail = $this->model->sendEmail; $this->srButton = $this->model->showSearchResetButton; $this->colToshow = $this->model->getState('colToshow'); From c8708a119336b1f834162ba7301f1dceab93de3a Mon Sep 17 00:00:00 2001 From: komal mane Date: Mon, 23 Sep 2019 14:46:36 +0530 Subject: [PATCH 2/7] Task #150780 feat: Add sendemail config colum level. --- tjreports/site/assets/js/tjrContentUI.js | 9 +++++++++ tjreports/site/models/reports.php | 14 +++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tjreports/site/assets/js/tjrContentUI.js b/tjreports/site/assets/js/tjrContentUI.js index 2797b01..67214bf 100755 --- a/tjreports/site/assets/js/tjrContentUI.js +++ b/tjreports/site/assets/js/tjrContentUI.js @@ -28,6 +28,7 @@ jQuery.extend(tjrContentUI.report, { } jQuery(".hasPopover").popover('destroy') var promise = tjrContentService.postData(this.url, this.$form.serialize());//, {'datatype':'html'} + promise.fail( function(response) { console.log('Something went wrong.'); @@ -45,6 +46,14 @@ jQuery.extend(tjrContentUI.report, { var responseHTML = jQuery(response['html']).find(containerSel).html(); jQuery(containerSel).html(responseHTML); + // If sendEmail plug is enable then call the below funcation. To show checkboxes + var isSendEmail = jQuery('body').find('.td-sendemail').length; + if (isSendEmail) + { + tjutilitysendemail.addColumn('report-table'); + } + // END + // Reinitialze some js like for calandar, tooltip, chosen jQuery(".hasPopover").popover({"html": true,"trigger": "hover focus","container": "body"}); diff --git a/tjreports/site/models/reports.php b/tjreports/site/models/reports.php index 97f08a1..7a267e3 100755 --- a/tjreports/site/models/reports.php +++ b/tjreports/site/models/reports.php @@ -37,8 +37,8 @@ class TjreportsModelReports extends JModelList // Columns array contain columns data public $columns = array(); - // Columns array contain columns data - public $sendEmail = array(); + // Columns array contain email columns + private $emailColumn = ''; // Columns that a user can select to display public $showhideCols = array(); @@ -94,6 +94,9 @@ public function __construct($config = array()) $this->setCustomFieldsColumns(); } + // Get email column + $this->emailColumn = array_search(1, array_map(function ($ar) {return $ar['emailColumn'];}, $this->columns)); + $this->initData(); parent::__construct($config); @@ -347,12 +350,6 @@ private function initData() unset($this->showhideCols[$key]); } - if ((isset($column['sendEmail']) && $column['sendEmail'] === true) - || (strpos($key, '::') !== false && !isset($column['sendEmail']))) - { - array_push($this->sendEmail, $key); - } - if ((isset($column['disable_sorting']) && $column['disable_sorting']) || (strpos($key, '::') !== false && !isset($column['disable_sorting']))) { @@ -371,7 +368,6 @@ private function initData() } } - $this->sendEmail = array_values($this->sendEmail); $this->showhideCols = array_values($this->showhideCols); $this->sortableColumns = array_values($this->sortableColumns); $this->sortableWoQuery = array_values($this->sortableWoQuery); From de6f4711e55681ed07400da392bd85d43d343ec4 Mon Sep 17 00:00:00 2001 From: komal mane Date: Mon, 23 Sep 2019 15:11:39 +0530 Subject: [PATCH 3/7] Task #150780 feat: Add sendemail config colum level. --- tjreports/administrator/models/tjreport.php | 2 +- tjreports/site/models/reports.php | 36 +++++++++++-------- tjreports/site/views/reports/tmpl/default.php | 6 ++-- tjreports/site/views/reports/view.base.php | 2 +- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/tjreports/administrator/models/tjreport.php b/tjreports/administrator/models/tjreport.php index be8295d..ece6446 100644 --- a/tjreports/administrator/models/tjreport.php +++ b/tjreports/administrator/models/tjreport.php @@ -177,7 +177,7 @@ public function getReportPluginData($pluginId, $pluginName = null) $params['filter_order'] = $plgModel->getState('list.ordering'); $params['filter_order_Dir'] = $plgModel->getState('list.direction'); $params['limit'] = $plgModel->getState('list.limit'); - $params['sendEmail'] = $plgModel->sendEmail; + $params['emailColumn'] = $plgModel->getState('emailColumn'); $params['colToshow'] = $plgModel->getState('colToshow'); $params['colToshow'] = array_combine($params['colToshow'], array_fill(0, count($params['colToshow']), true)); $params['showHideColumns'] = $plgModel->showhideCols; diff --git a/tjreports/site/models/reports.php b/tjreports/site/models/reports.php index 7a267e3..8479c9c 100755 --- a/tjreports/site/models/reports.php +++ b/tjreports/site/models/reports.php @@ -532,6 +532,11 @@ protected function populateState($ordering = '', $direction = 'ASC') $value = $input->get('limitstart', 0, 'uint'); $this->setState('list.start', $value); + if ($this->emailColumn) + { + $this->setState('emailColumn', $this->emailColumn); + } + // Ordering $this->default_order = $input->get('filter_order', $this->default_order, 'STRING'); @@ -1072,15 +1077,15 @@ private function filterReportColumns($queryId, &$selColToshow) } $query = $this->_db->getQuery(true); - $showhideCols = $paramColToshow = $sendEmail = array(); + $showhideCols = $paramColToshow = $emailColumn = array(); // Process plugin params - $parentId = $this->processSavedReportColumns($queryId, $showhideCols, $paramColToshow, $selColToshow, $sendEmail); + $parentId = $this->processSavedReportColumns($queryId, $showhideCols, $paramColToshow, $selColToshow, $emailColumn); // Process if user has saved query is for a plugin if (!empty($parentId)) { - $this->processSavedReportColumns($parentId, $showhideCols, $paramColToshow, $selColToshow, $sendEmail); + $this->processSavedReportColumns($parentId, $showhideCols, $paramColToshow, $selColToshow, $emailColumn); } // If plugin has save any column assign that otherwise default plugin param will be applied @@ -1103,25 +1108,26 @@ private function filterReportColumns($queryId, &$selColToshow) $this->showhideCols = $showhideCols; } - if (!empty($sendEmail)) + if (!empty($emailColumn)) { - $this->sendEmail = $sendEmail; + $this->emailColumn = $emailColumn; } } /** * Method to Process parent Report columns * - * @param INT $queryId Query Id - * @param ARRAY &$showhideCols Show Hide columns - * @param ARRAY &$colToshow Columns to show - * @param ARRAY &$selColToshow Selected Cols + * @param INT $queryId Query Id + * @param ARRAY &$showhideCols Show Hide columns + * @param ARRAY &$colToshow Columns to show + * @param ARRAY &$selColToshow Selected Cols + * @param STRING &$emailColumn emailColumn * * @return Void * * @since 3.0 */ - private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow, &$selColToshow, &$sendEmail) + private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow, &$selColToshow, &$emailColumn) { $query = $this->_db->getQuery(true); $query->select(array('param', 'parent')) @@ -1147,15 +1153,15 @@ private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow } } - if (isset($param['sendEmail'])) + if (isset($param['emailColumn'])) { - if (empty($sendEmail)) + if (empty($emailColumn)) { - $sendEmail = (array) $param['sendEmail']; + $emailColumn = (array) $param['emailColumn']; } else { - $sendEmail = array_intersect($sendEmail, (array) $param['sendEmail']); + $emailColumn = array_intersect($emailColumn, (array) $param['emailColumn']); } } @@ -1240,7 +1246,7 @@ public function getReportLink($reportToLink, $filters) /** * Method to get id of the report having default set as 1 * - * @param STRING $pluginName Plugin Name + * @param STRING $reportId Report id * * @return Integer * diff --git a/tjreports/site/views/reports/tmpl/default.php b/tjreports/site/views/reports/tmpl/default.php index 734370f..580ca38 100644 --- a/tjreports/site/views/reports/tmpl/default.php +++ b/tjreports/site/views/reports/tmpl/default.php @@ -12,6 +12,8 @@ JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); +$emailColmClass = 'td-sendemail'; + $app = JFactory::getApplication(); $headerLevel = $this->headerLevel; $this->listOrder = $this->state->get('list.ordering'); @@ -432,9 +434,9 @@ else { $isSendEmailClass = ''; - if (in_array($key, $this->sendEmail)) + if (in_array($key, $this->emailColumn)) { - $isSendEmailClass = 'td-sendemail'; + $isSendEmailClass = $emailColmClass; } echo ''. $item[$key] .''; } diff --git a/tjreports/site/views/reports/view.base.php b/tjreports/site/views/reports/view.base.php index fda835a..d8809a9 100644 --- a/tjreports/site/views/reports/view.base.php +++ b/tjreports/site/views/reports/view.base.php @@ -162,7 +162,7 @@ public function processData($type = 'html') $this->columns = $this->model->columns; $this->showHideColumns = $this->model->showhideCols; $this->sortable = $this->model->sortableColumns; - $this->sendEmail = $this->model->sendEmail; + $this->emailColumn = $this->model->getState('emailColumn'); $this->srButton = $this->model->showSearchResetButton; $this->colToshow = $this->model->getState('colToshow'); From c8718dbb23101ed31efc9ce199912b896f978da0 Mon Sep 17 00:00:00 2001 From: komal mane Date: Mon, 23 Sep 2019 17:19:53 +0530 Subject: [PATCH 4/7] Task #150780 feat: Add sendemail config colum level. --- tjreports/site/assets/js/tjrContentUI.js | 15 ++++++++++----- tjreports/site/views/reports/tmpl/default.php | 8 ++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tjreports/site/assets/js/tjrContentUI.js b/tjreports/site/assets/js/tjrContentUI.js index 67214bf..e75a371 100755 --- a/tjreports/site/assets/js/tjrContentUI.js +++ b/tjreports/site/assets/js/tjrContentUI.js @@ -12,6 +12,7 @@ tjrContentUI.root_url = (typeof root_url == 'undefined') ? '' : root_url; tjrContentUI.base_url = (typeof root_url == 'undefined') ? '' : root_url; tjrContentUI.report = tjrContentUI.report ? tjrContentUI.report : {}; + jQuery.extend(tjrContentUI.report, { searchToggle: true, $form: null, @@ -46,13 +47,17 @@ jQuery.extend(tjrContentUI.report, { var responseHTML = jQuery(response['html']).find(containerSel).html(); jQuery(containerSel).html(responseHTML); - // If sendEmail plug is enable then call the below funcation. To show checkboxes - var isSendEmail = jQuery('body').find('.td-sendemail').length; - if (isSendEmail) + // If plg_system_sendemail enable + if (typeof tjutilitysendemail != 'undefined') { - tjutilitysendemail.addColumn('report-table'); + // If sendEmail plug is enable then call the below funcation. To show checkboxes + var isSendEmail = jQuery('body').find('.td-sendemail').length; + if (isSendEmail) + { + tjutilitysendemail.addColumn('report-table'); + } + // END } - // END // Reinitialze some js like for calandar, tooltip, chosen jQuery(".hasPopover").popover({"html": true,"trigger": "hover focus","container": "body"}); diff --git a/tjreports/site/views/reports/tmpl/default.php b/tjreports/site/views/reports/tmpl/default.php index 580ca38..50adb48 100644 --- a/tjreports/site/views/reports/tmpl/default.php +++ b/tjreports/site/views/reports/tmpl/default.php @@ -433,12 +433,8 @@ } else { - $isSendEmailClass = ''; - if (in_array($key, $this->emailColumn)) - { - $isSendEmailClass = $emailColmClass; - } - echo ''. $item[$key] .''; + $isSendEmailClass = (in_array($key, $this->emailColumn)) ? $emailColmClass : ''; + echo "{$item[$key]}"; } } From 436b2d87f9b2d96b022a514510a5c5eff0fac26b Mon Sep 17 00:00:00 2001 From: komal mane Date: Mon, 23 Sep 2019 17:31:11 +0530 Subject: [PATCH 5/7] Task #150780 feat: Add sendemail config colum level. --- tjreports/site/models/reports.php | 21 ++++--------------- tjreports/site/views/reports/tmpl/default.php | 2 +- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/tjreports/site/models/reports.php b/tjreports/site/models/reports.php index 8479c9c..5614ff4 100755 --- a/tjreports/site/models/reports.php +++ b/tjreports/site/models/reports.php @@ -1077,15 +1077,15 @@ private function filterReportColumns($queryId, &$selColToshow) } $query = $this->_db->getQuery(true); - $showhideCols = $paramColToshow = $emailColumn = array(); + $showhideCols = $paramColToshow = array(); // Process plugin params - $parentId = $this->processSavedReportColumns($queryId, $showhideCols, $paramColToshow, $selColToshow, $emailColumn); + $parentId = $this->processSavedReportColumns($queryId, $showhideCols, $paramColToshow, $selColToshow); // Process if user has saved query is for a plugin if (!empty($parentId)) { - $this->processSavedReportColumns($parentId, $showhideCols, $paramColToshow, $selColToshow, $emailColumn); + $this->processSavedReportColumns($parentId, $showhideCols, $paramColToshow, $selColToshow); } // If plugin has save any column assign that otherwise default plugin param will be applied @@ -1121,13 +1121,12 @@ private function filterReportColumns($queryId, &$selColToshow) * @param ARRAY &$showhideCols Show Hide columns * @param ARRAY &$colToshow Columns to show * @param ARRAY &$selColToshow Selected Cols - * @param STRING &$emailColumn emailColumn * * @return Void * * @since 3.0 */ - private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow, &$selColToshow, &$emailColumn) + private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow, &$selColToshow) { $query = $this->_db->getQuery(true); $query->select(array('param', 'parent')) @@ -1153,18 +1152,6 @@ private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow } } - if (isset($param['emailColumn'])) - { - if (empty($emailColumn)) - { - $emailColumn = (array) $param['emailColumn']; - } - else - { - $emailColumn = array_intersect($emailColumn, (array) $param['emailColumn']); - } - } - if (isset($param['colToshow'])) { foreach ((array) $param['colToshow'] as $cols => $show) diff --git a/tjreports/site/views/reports/tmpl/default.php b/tjreports/site/views/reports/tmpl/default.php index 50adb48..b63d2b3 100644 --- a/tjreports/site/views/reports/tmpl/default.php +++ b/tjreports/site/views/reports/tmpl/default.php @@ -433,7 +433,7 @@ } else { - $isSendEmailClass = (in_array($key, $this->emailColumn)) ? $emailColmClass : ''; + $isSendEmailClass = ($key == $this->emailColumn) ? $emailColmClass : ''; echo "{$item[$key]}"; } } From e8cbf896db077ed6a33ca01d832308bc90a42107 Mon Sep 17 00:00:00 2001 From: Ashwin Date Date: Mon, 23 Sep 2019 17:43:38 +0530 Subject: [PATCH 6/7] Update tjrContentUI.js --- tjreports/site/assets/js/tjrContentUI.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tjreports/site/assets/js/tjrContentUI.js b/tjreports/site/assets/js/tjrContentUI.js index e75a371..4334811 100755 --- a/tjreports/site/assets/js/tjrContentUI.js +++ b/tjreports/site/assets/js/tjrContentUI.js @@ -50,13 +50,11 @@ jQuery.extend(tjrContentUI.report, { // If plg_system_sendemail enable if (typeof tjutilitysendemail != 'undefined') { - // If sendEmail plug is enable then call the below funcation. To show checkboxes - var isSendEmail = jQuery('body').find('.td-sendemail').length; - if (isSendEmail) + // If sendEmail plug is enabled then try to add a column of checkboxes + if (jQuery('body').find('.td-sendemail').length) { tjutilitysendemail.addColumn('report-table'); } - // END } // Reinitialze some js like for calandar, tooltip, chosen From 8a9c4456395074fe1be9012cf0ba067a89734fd4 Mon Sep 17 00:00:00 2001 From: Ashwin Date Date: Mon, 23 Sep 2019 17:45:22 +0530 Subject: [PATCH 7/7] Update tjrContentUI.js --- tjreports/site/assets/js/tjrContentUI.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tjreports/site/assets/js/tjrContentUI.js b/tjreports/site/assets/js/tjrContentUI.js index 4334811..5c16ad2 100755 --- a/tjreports/site/assets/js/tjrContentUI.js +++ b/tjreports/site/assets/js/tjrContentUI.js @@ -47,14 +47,13 @@ jQuery.extend(tjrContentUI.report, { var responseHTML = jQuery(response['html']).find(containerSel).html(); jQuery(containerSel).html(responseHTML); - // If plg_system_sendemail enable - if (typeof tjutilitysendemail != 'undefined') + // If sendEmail plug is enabled then try to add a column of checkboxes + if ( + typeof tjutilitysendemail != 'undefined' && + jQuery('body').find('.td-sendemail').length > 0 + ) { - // If sendEmail plug is enabled then try to add a column of checkboxes - if (jQuery('body').find('.td-sendemail').length) - { - tjutilitysendemail.addColumn('report-table'); - } + tjutilitysendemail.addColumn('report-table'); } // Reinitialze some js like for calandar, tooltip, chosen