Skip to content

Commit

Permalink
Merge pull request #147 from komalm/development
Browse files Browse the repository at this point in the history
Task #150780 feat: Add sendemail config colum level.
  • Loading branch information
coolbung authored Sep 23, 2019
2 parents cfcf123 + 8a9c445 commit 6d78322
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
1 change: 1 addition & 0 deletions tjreports/administrator/models/tjreport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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['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;
Expand Down
11 changes: 11 additions & 0 deletions tjreports/site/assets/js/tjrContentUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,6 +29,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.');
Expand All @@ -45,6 +47,15 @@ jQuery.extend(tjrContentUI.report, {
var responseHTML = jQuery(response['html']).find(containerSel).html();
jQuery(containerSel).html(responseHTML);

// If sendEmail plug is enabled then try to add a column of checkboxes
if (
typeof tjutilitysendemail != 'undefined' &&
jQuery('body').find('.td-sendemail').length > 0
)
{
tjutilitysendemail.addColumn('report-table');
}

// Reinitialze some js like for calandar, tooltip, chosen
jQuery(".hasPopover").popover({"html": true,"trigger": "hover focus","container": "body"});

Expand Down
31 changes: 24 additions & 7 deletions tjreports/site/models/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class TjreportsModelReports extends JModelList
// Columns array contain columns data
public $columns = array();

// Columns array contain email columns
private $emailColumn = '';

// Columns that a user can select to display
public $showhideCols = array();

Expand Down Expand Up @@ -91,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);
Expand Down Expand Up @@ -366,6 +372,7 @@ private function initData()
$this->sortableColumns = array_values($this->sortableColumns);
$this->sortableWoQuery = array_values($this->sortableWoQuery);
$this->defaultColToShow = array_values($this->defaultColToShow);

}

/**
Expand Down Expand Up @@ -525,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');

Expand Down Expand Up @@ -1073,7 +1085,7 @@ private function filterReportColumns($queryId, &$selColToshow)
// 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);
}

// If plugin has save any column assign that otherwise default plugin param will be applied
Expand All @@ -1095,15 +1107,20 @@ private function filterReportColumns($queryId, &$selColToshow)
{
$this->showhideCols = $showhideCols;
}

if (!empty($emailColumn))
{
$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
*
* @return Void
*
Expand Down Expand Up @@ -1216,7 +1233,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
*
Expand All @@ -1228,7 +1245,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);
}

Expand Down
7 changes: 5 additions & 2 deletions tjreports/site/views/reports/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -289,7 +291,7 @@

for($i = $headerLevel; $i > 0 ; $i--)
{
echo '<tr>';
echo '<tr class="report-row">';

foreach($this->colToshow as $index=>$detail)
{
Expand Down Expand Up @@ -431,7 +433,8 @@
}
else
{
echo '<td class="' . $key . '">'. $item[$key] .'</td>';
$isSendEmailClass = ($key == $this->emailColumn) ? $emailColmClass : '';
echo "<td class=\"{$key} {$isSendEmailClass} \">{$item[$key]}</td>";
}
}

Expand Down
1 change: 1 addition & 0 deletions tjreports/site/views/reports/view.base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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->emailColumn = $this->model->getState('emailColumn');
$this->srButton = $this->model->showSearchResetButton;

$this->colToshow = $this->model->getState('colToshow');
Expand Down

0 comments on commit 6d78322

Please sign in to comment.