Skip to content

Commit

Permalink
Dev: fix "from" information and data for showing last 50 in browse re…
Browse files Browse the repository at this point in the history
…sponse

Dev: only if start is not set or is 0
  • Loading branch information
Shnoulle committed Apr 6, 2013
1 parent c9a7f46 commit 64396cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions application/controllers/admin/responses.php
Expand Up @@ -507,6 +507,8 @@ function browse($iSurveyID)

$start = Yii::app()->request->getParam('start', 0);
$limit = Yii::app()->request->getParam('limit', 50);
$order = Yii::app()->request->getParam('order', 'asc');

if(!$limit){$limit=50;}
$oCriteria = new CDbCriteria;
//Create the query
Expand All @@ -530,7 +532,6 @@ function browse($iSurveyID)
{
$limit = $dtcount;
}

//NOW LETS SHOW THE DATA
if (Yii::app()->request->getPost('sql') && stripcslashes(Yii::app()->request->getPost('sql')) !== "" && Yii::app()->request->getPost('sql') != "NULL")
$oCriteria->addCondition(stripcslashes(Yii::app()->request->getPost('sql')));
Expand All @@ -539,14 +540,19 @@ function browse($iSurveyID)
$oCriteria->addCondition('t.token = ' . Yii::app()->db->quoteValue($tokenRequest));
}

$oCriteria->order = 'id ' . (Yii::app()->request->getParam('order') == 'desc' ? 'desc' : 'asc');
$oCriteria->order = 'id ' . ($order == 'desc' ? 'desc' : 'asc');
$oCriteria->offset = $start;
$oCriteria->limit = $limit;

$dtresult = Survey_dynamic::model($iSurveyID)->findAllAsArray($oCriteria);

$dtcount2 = count($dtresult);
$cells = $fncount + 1;
// Fix start if order is desc, only if actual start is 0
if($order == 'desc' && $start==0)
{
$start=$dtcount-count($dtresult);
}

//CONTROL MENUBAR
$last = $start - $limit;
Expand Down
8 changes: 4 additions & 4 deletions application/views/admin/responses/browseallheader_view.php
Expand Up @@ -11,15 +11,15 @@
<div class='menubar-left'>
<?php if (!isset($_POST['sql']))
{ ?>
<a href='<?php echo $this->createUrl("admin/responses/sa/browse/surveyid/$surveyid/start/0/limit/$limit"); ?>'>
<a href='<?php echo $this->createUrl("admin/responses/sa/browse/surveyid/$surveyid", array('start' =>0,'limit'=>$limit)); ?>'>
<img src='<?php echo $sImageURL; ?>databegin.png' alt='<?php $clang->eT("Show start..."); ?>' /></a>
<a href='<?php echo $this->createUrl("admin/responses/sa/browse/surveyid/$surveyid/start/$last/limit/$limit"); ?>'>
<a href='<?php echo $this->createUrl("admin/responses/sa/browse/surveyid/$surveyid", array('start' =>$last,'limit'=>$limit)); ?>'>
<img src='<?php echo $sImageURL; ?>databack.png' alt='<?php $clang->eT("Show previous.."); ?>' /></a>
<img src='<?php echo $sImageURL; ?>blank.gif' width='13' height='20' alt='' />

<a href='<?php echo $this->createUrl("admin/responses/sa/browse/surveyid/$surveyid/start/$next/limit/$limit"); ?>'>
<a href='<?php echo $this->createUrl("admin/responses/sa/browse/surveyid/$surveyid", array('start' =>$next,'limit'=>$limit)); ?>'>
<img src='<?php echo $sImageURL; ?>dataforward.png' alt='<?php $clang->eT("Show next.."); ?>' /></a>
<a href='<?php echo $this->createUrl("admin/responses/sa/browse/surveyid/$surveyid/start/$end/limit/$limit"); ?>'>
<a href='<?php echo $this->createUrl("admin/responses/sa/browse/surveyid/$surveyid", array('start' =>$end,'limit'=>$limit)); ?>'>
<img src='<?php echo $sImageURL; ?>dataend.png' alt='<?php $clang->eT("Show last.."); ?>' /></a>
<img src='<?php echo $sImageURL; ?>separator.gif' class='separator' alt='' />
<?php
Expand Down

0 comments on commit 64396cf

Please sign in to comment.