Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions tjreports/site/controllers/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,24 @@ public function csvexport()

foreach ($data['colToshow'] as $eachColumn)
{
$calHeading = strtoupper($eachColumn);
// Remove double Quotes from the data
$eachColumn = str_replace('"', '', $eachColumn);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 3 different variables? eachColumn eachColumn2 final_eachColumn ?
only one should do.


// Remove single Quotes from the data
$eachColumn = str_replace("'", '', $eachColumn);

// Remove tabs and newlines from the data
$eachColumn2 = preg_replace('/(\r\n|\r|\n)+/', " ", $eachColumn);

// Remove extra spaces from the data
$final_eachColumn = preg_replace('/\s+/', " ", $eachColumn2);

// Add data in the Quotes and asign it in the csv array
// $csvData_arr1[] = '"' . $final_eachColumn . '"';
$calHeading = strtoupper($final_eachColumn);
$plgReport = strtoupper($reportName);
$calHeading = 'PLG_TJREPORTS_' . $plgReport . '_' . $calHeading;
$csvData_arr[] = JText::_($calHeading);
$csvData_arr[] = '"' . JText::_($calHeading) . '"';
}

$csvData .= implode(',', $csvData_arr);
Expand All @@ -194,7 +208,20 @@ public function csvexport()
{
if (in_array($index, $data['colToshow']))
{
$csvData_arr1[] = $finalValue;
// Remove double Quotes from the data
$finalValue = str_replace('"', '', $finalValue);

// Remove single Quotes from the data
$finalValue = str_replace("'", '', $finalValue);

// Remove tabs and newlines from the data
$finalValue2 = preg_replace('/(\r\n|\r|\n)+/', " ", $finalValue);

// Remove extra spaces from the data
$final_text_value = preg_replace('/\s+/', " ", $finalValue2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, use only single variable


// Add data in the Quotes and asign it in the csv array
$csvData_arr1[] = '"' . $final_text_value . '"';
}
}

Expand Down
43 changes: 40 additions & 3 deletions tjreports/site/models/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ public function getData($filters = array(), $colNames = array(), $rowsTofetch =

if (empty($colNames))
{
$colNames = $this->getColNames();
// Get all column name for default report
$configcolNames = (array) $this->getconfigColNames();

$colNames = (array) ($configcolNames['colToshow']);
}

$this->setAllUserPreference($reportName, $sortCol, $sortOrder, $colNames, $filters);
Expand Down Expand Up @@ -199,9 +202,10 @@ public function getColNames()

$colNames = array_intersect($plugcolNames[0], $confirgcols);

if (!empty($colNames))
// Change By komal to show default field
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove your name, add issue id in comment

if (!empty($plugcolNames[0]))
{
return $colNames;
return $plugcolNames[0];
}

return false;
Expand Down Expand Up @@ -336,6 +340,39 @@ public function getQueryData($queryId)
return $queryData;
}

/**
* By komal to show default field
* Get all Default fields names
*
* @return object
*
* @since 1.0
*/
public function getDefaultReport()
{
$input = JFactory::getApplication()->input;
$reportName = $input->get('reportToBuild', '', 'STRING');

if (empty($reportName))
{
$mainframe = JFactory::getApplication();
$reportName = $mainframe->getUserState('com_tjreports' . '.reportName', '');
}

$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__tj_reports', 'tjr'));
$query->where($db->quoteName('tjr.plugin') . ' = ' . $db->quote($reportName));
$query->where($db->quoteName('tjr.default') . ' = ' . 1);
$query->where($db->quoteName('tjr.userid') . ' = ' . 0);
$query->where($db->quoteName('tjr.parent') . ' = ' . 0);
$db->setQuery($query);
$queryData = $db->loadObject();

return $queryData;
}

/**
* Get all plugins names
*
Expand Down
9 changes: 9 additions & 0 deletions tjreports/site/views/reports/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ public function display($tpl = null)
$param = json_decode($QueryData->param);
$this->colToshow = $param->colToshow;
}
// Added By komal to show default field
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove name, add issue id in comment if needed at all

else
{
$model = $this->getModel();
$colToSelect = array('colToshow');
$QueryData = $model->getDefaultReport();
$param = json_decode($QueryData->param);
$this->colToshow = $param->colToshow;
}

$input = JFactory::getApplication()->input;

Expand Down