diff --git a/tjreports/site/controllers/reports.php b/tjreports/site/controllers/reports.php index 83a1d33..5b1eb61 100644 --- a/tjreports/site/controllers/reports.php +++ b/tjreports/site/controllers/reports.php @@ -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); + + // 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); @@ -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); + + // Add data in the Quotes and asign it in the csv array + $csvData_arr1[] = '"' . $final_text_value . '"'; } } diff --git a/tjreports/site/models/reports.php b/tjreports/site/models/reports.php index 99c88ab..935e90b 100755 --- a/tjreports/site/models/reports.php +++ b/tjreports/site/models/reports.php @@ -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); @@ -199,9 +202,10 @@ public function getColNames() $colNames = array_intersect($plugcolNames[0], $confirgcols); - if (!empty($colNames)) + // Change By komal to show default field + if (!empty($plugcolNames[0])) { - return $colNames; + return $plugcolNames[0]; } return false; @@ -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 * diff --git a/tjreports/site/views/reports/view.html.php b/tjreports/site/views/reports/view.html.php index 7a6b4fb..faec027 100755 --- a/tjreports/site/views/reports/view.html.php +++ b/tjreports/site/views/reports/view.html.php @@ -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 + else + { + $model = $this->getModel(); + $colToSelect = array('colToshow'); + $QueryData = $model->getDefaultReport(); + $param = json_decode($QueryData->param); + $this->colToshow = $param->colToshow; + } $input = JFactory::getApplication()->input;