I am a yiibie. I have top 5 ngo's on my view page(top 5 ngo's for each month) and also the top 5 ngo's at the end of the year on the same page. Now i want to show the bootstrap progress bar in front of every ngo. For example if January is the month and it is showing me top 5 ngo's of that month,I want to show a progress bar in front of all those 5 ngo's and I want it for every month. And same thing for the end of the year. Like the 1st ngo progress bar will be 100%, 2nd ngo will have less then 100% and so on. Please help me in doing this, thank you. This is my code for my controller which has the view file function
public function actionNgostats()
{
$this->layout='main';
$myCurrYear = date("Y");
$userYear=UserRateReviewNgo::model()->findAll(array(
'condition' => 'YEAR(date_created)=:year',
'params' => array(':year'=>$myCurrYear),
'select'=>'DISTINCT rate,ngo_id',
'order'=>'rate DESC',
'limit' => 5
));
$this->render('ngostats', array("userYear"=>$userYear));
}
and this is my view file(ngostats)
<div>
<?php
for($month = 1 ; $month <=date('m') ; $month++)
{
$user=UserRateReviewNgo::model()->findAll(array(
'condition' => 'YEAR(date_created)=:year and MONTH(date_created)=:month',
'params' => array(':year'=>2015, ':month'=>$month),
'select'=>'DISTINCT rate,ngo_id',
'order'=>'rate DESC',
'limit' => 5
));
foreach($user as $show) {
$model = Ngo::model()->findByAttributes(array('id'=>$show->ngo_id,));
if (isset($model)) {
?>
<div><h4><?php echo $model->ngo_name?></h4></div>
<div class="progress">
<div class="progress-bar progress-bar-striped active" role="progressbar"
aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%">
40%
</div>
</div>
<?php
}}}
?>
</div>
<h3>This is for the year's top 5 Ngo's</h3>
<div>
<?php // the for the year
foreach($userYear as $show) {
$model = Ngo::model()->findByAttributes(array('id'=>$show->ngo_id,));
if (isset($model)) {
?>
<div><h4><?php echo $model->ngo_name?></h4></div>
<div class="progress">
<div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar"
aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%">
40% Complete (success)
</div>
</div>
<?php
}
}
?>
</div>
See Question&Answers more detail:os