Skip to content

Commit

Permalink
New feature : Allow export to use statistics filter
Browse files Browse the repository at this point in the history
Dev: lost in 2.00 to 2.05 feature ?
  • Loading branch information
Shnoulle committed Jul 27, 2015
1 parent 2d5c02a commit 6d5038d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
7 changes: 4 additions & 3 deletions application/controllers/admin/export.php
Expand Up @@ -303,13 +303,14 @@ public function exportresults()
}

if (Yii::app()->request->getPost('response_id'))
{
$sFilter="{{survey_{$iSurveyID}}}.id=".(int)Yii::app()->request->getPost('response_id');
elseif(App()->request->getQuery('statfilter') && is_array(Yii::app()->session['statistics_selects_'.$iSurveyID]))
{
$sFilter=Yii::app()->session['statistics_selects_'.$iSurveyID];
}
else
{
$sFilter='';
}

viewHelper::disableHtmlLogging();
$resultsService->exportSurvey($iSurveyID, $explang, $sExportType, $options, $sFilter);

Expand Down
8 changes: 6 additions & 2 deletions application/helpers/admin/export/SurveyDao.php
Expand Up @@ -92,7 +92,7 @@ public function loadSurveyById($id, $lang = null)
* @param Survey $survey
* @param int $iMinimum
* @param int $iMaximum
* @param string $sFilter An optional filter for the results
* @param string|array $sFilter An optional filter for the results, i string or arry of string
* @param string $completionState all, complete or incomplete
*/
public function loadSurveyResults(SurveyObj $survey, $iMinimum, $iMaximum, $sFilter='', $completionState = 'all' )
Expand Down Expand Up @@ -131,8 +131,12 @@ public function loadSurveyResults(SurveyObj $survey, $iMinimum, $iMaximum, $sFil
$selection = '{{survey_' . $survey->id . '}}.id >= :min AND {{survey_' . $survey->id . '}}.id <= :max';
$oRecordSet->where($selection, $aParams);

if ($sFilter!='') {
if(is_string($sFilter))
$oRecordSet->andWhere($sFilter);
elseif(is_array($sFilter))
{
foreach($sFilter as $filter)
$oRecordSet->andWhere($filter);
}

switch ($completionState)
Expand Down
1 change: 1 addition & 0 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -3086,6 +3086,7 @@ public function generate_statistics($surveyid, $allfields, $q2show='all', $usegr
//add a buttons to browse results
$sOutputHTML .= "<tr><td clospan='2' style='text-align:center'>";
$sOutputHTML .= CHtml::link(gT("Browse"),array("admin/responses","sa"=>'browse','surveyid'=>$surveyid,'statfilter'=>1),array('class'=>'button btn-link'));
$sOutputHTML .= CHtml::link(gT("Export"),array("admin/export","sa"=>'exportresults','surveyid'=>$surveyid,'statfilter'=>1),array('class'=>'button btn-link'));
$sOutputHTML .= "</td></tr>";

}
Expand Down
11 changes: 8 additions & 3 deletions application/views/admin/export/exportresults_view.php
Expand Up @@ -4,13 +4,18 @@
var sMsgColumnCount = '<?php eT("%s of %s columns selected",'js'); ?>';
</script>
<div class='header ui-widget-header'><?php eT("Export results");?>
<?php if (isset($_POST['sql'])) {echo" - ".gT("Filtered from statistics script");}
if ($SingleResponse) {
<?php
if (App()->request->getQuery('statfilter'))
echo" - ".gT("Filtered from statistics script");
elseif ($SingleResponse) {
echo " - ".sprintf(gT("Single response: ID %s"),$SingleResponse);}
?>
</div>
<div class='wrap2columns'>
<?php echo CHtml::form(array('admin/export/sa/exportresults/surveyid/'.$surveyid), 'post', array('id'=>'resultexport'));?>
<?php echo CHtml::form(array("admin/export","sa"=>'exportresults','surveyid'=>$surveyid,'statfilter'=>App()->request->getQuery('statfilter')), 'post', array('id'=>'resultexport'));


?>
<div class='left'>
<fieldset><legend><?php eT("Format");?></legend>
<ul>
Expand Down

0 comments on commit 6d5038d

Please sign in to comment.