Hello Friends.
In my app I have one alert page. That page will intimate that who are all having birthday for next 30 days. So i need to show only those rows display in my Cgridview. how can I do this???
Hello Friends.
In my app I have one alert page. That page will intimate that who are all having birthday for next 30 days. So i need to show only those rows display in my Cgridview. how can I do this???
Try this code
<?php
public function search_next_30_days()
{
$criteria=new CDbCriteria;
$next_30_days= date('Y-m-d', strtotime("+30 days"));
$today= date('Y-m-d');
..............
//$criteria->compare('emp_birthday',$this->emp_birthday,true);
$criteria->addBetweenCondition("t.emp_birthday",$today,$next_30_days,"AND");
..............
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
?>
Is this in my controller rite.
Thank you bala… and how can i use this in the filters in gridview
No you have to add this code in your model and call this function in gridview.
Just use ‘search_next_30_days’ function instead of ‘search’.
See the gridview code
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'emptermination-grid',
'dataProvider'=>$model->search_next_30_days(),
'filter'=>$model,
'columns'=>array(
'id',
'employee_id',
'emp_name',
'emp_birthday',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
In my model
public function search_next_30_days()
{
$criteria=new CDbCriteria;
$next_30_days= date('Y-m-d', strtotime("-30 days"));
$today= date('Y-m-d');
//$criteria->compare('emp_birthday',$this->emp_birthday,true);
$criteria->addBetweenCondition("maturitydate",$today,$next_30_days,"AND");
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
In my Gridview:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'alert-fd-grid',
'dataProvider'=>$model->search_next_30_days(),
'filter'=>$model,
'columns'=>array(
'add_id',
'code',
'catg_id',
'head_id',
'shead_id',
'fdnumber',
'fdname',
'startdate',
'noofyears',
'maturitydate',
'amount',
'bank',
'branch',
'rateofinterest',
'interestamount',
'interest_bank',
'interest_branch',
'annual',
array(
'class'=>'CButtonColumn',
),
),
));
It shows no result found… How can get sure its working or not
Enable the log in ‘config/main.php’ file and find the sql query to run in database.
Now its work bala…Thank you.