Skip to content

Commit

Permalink
Dev: added "export responses" mass action rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Oct 6, 2017
1 parent f7ee0c8 commit 7e9dee3
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
19 changes: 19 additions & 0 deletions application/controllers/admin/responses.php
Expand Up @@ -1001,6 +1001,25 @@ private function _zipFiles($iSurveyID, $responseIds, $zipfilename)
$this->getController()->redirect(array("admin/responses","sa"=>"browse","surveyid"=>$iSurveyID));
}



/**
* Responsible for setting the session variables for attribute map page redirect
* @todo Use user session?
* @todo Used?
*/
public function setSession($unset=false, $sid=null)
{
if (!$unset){
unset(Yii::app()->session['responsesid']);
Yii::app()->session['responsesid'] = Yii::app()->request->getPost('itemsid');
}else{
unset(Yii::app()->session['responsesid']);
$this->getController()->redirect(array("admin/export","sa"=>"exportresults","surveyid"=>$sid));
}

}

/**
* Renders template(s) wrapped in header and footer
*
Expand Down
40 changes: 40 additions & 0 deletions application/views/admin/export/exportresults_view.php
Expand Up @@ -51,6 +51,7 @@
</div>
</div>

<?php if (empty(Yii::app()->session['responsesid'])): // If called from massive action, it will be filled the selected answers ?>
<!-- Range -->
<div class="panel panel-primary" id="panel-2" <?php if ($SingleResponse) { echo 'style="display:none"';} ?> >
<div class="panel-heading">
Expand Down Expand Up @@ -97,6 +98,45 @@ class="form-control"
</div>
</div>
</div>
<?php else: ?>

<div class="panel panel-primary" id="panel-2" <?php if ($SingleResponse) { echo 'style="display:none"';} ?> >
<div class="panel-heading">
<h4 class="panel-title">
<?php eT("Selection");?>
</h4>
</div>
<div class="panel-body">
<div class="form-group">
<?php
$sResponsesId = '';
$aResponsesId = json_decode(Yii::app()->session['responsesid']);
foreach($aResponsesId as $aResponseId){
$sResponsesId .= $aResponseId.', ';
}
?>
<!-- From -->
<label for='export_ids' class="col-sm-2 control-label">
<?php eT("Selected answers"); ?>
</label>

<div class="col-sm-6">
<input type="text" readonly value="<?php echo $sResponsesId; ?>" class="form-control" name="responses_id" id="responses_id" />
</div>
<div class="col-sm-2">
<a class="btn btn-default" href="<?php echo Yii::app()->getController()->createUrl("admin/responses/sa/setSession/", array('unset'=>'true', 'sid'=>$surveyid)); ?>" role="button"><?php eT("Reset");?></a>
</div>
<input
type="hidden"
value='<?php echo json_encode($aResponsesId); ?>'
name="export_ids"
id="export_ids"
/>

</div>
</div>
</div>
<?php endif;?>

<!-- General -->
<div class="panel panel-primary" id="panel-3">
Expand Down
3 changes: 2 additions & 1 deletion application/views/admin/responses/listResponses_view.php
Expand Up @@ -220,8 +220,9 @@
?>
</div>

<!-- To update rows per page via ajax -->
<!-- To update rows per page via ajax setSession-->
<script type="text/javascript">
var postUrl = "<?php echo Yii::app()->getController()->createUrl("admin/responses/", array("sa" => "setSession")); ?>"; // For massive export
jQuery(function($) {
jQuery(document).on("change", '#pageSize', function(){
$.fn.yiiGridView.update('responses-grid',{ data:{ pageSize: $(this).val() }});
Expand Down
18 changes: 18 additions & 0 deletions application/views/admin/responses/massive_actions/_selector.php
Expand Up @@ -65,6 +65,24 @@
'actionType' => 'window-location-href'
);


// Export responses
$buttons[] = array(
// li element
'type' => 'action',
'action' => 'export',
'url' => App()->createUrl('admin/export/sa/exportresults/surveyid/'.$_GET['surveyid']),
'iconClasses' => 'glyphicon glyphicon-download-alt',
'text' => gT('Export'),

'aLinkSpecificDatas' => array(
'input-name' => 'tokenids',
),

// modal
'actionType' => 'fill-session-and-redirect',
);

}

$this->widget('ext.admin.grid.MassiveActionsWidget.MassiveActionsWidget', array(
Expand Down

0 comments on commit 7e9dee3

Please sign in to comment.