View : Search form
Model's Search functionlabel($model,'fromdate'); ?> widget('zii.widgets.jui.CJuiDatePicker',array( 'id'=>'HolidayHolidayrange_fromdate', 'name'=>'HolidayHolidayrange[fromdate]', 'value'=>$model->fromdate==''?'':date('d-m-Y',strtotime($model->fromdate)), 'options'=>array( 'dateFormat' => 'dd-mm-yy', 'showAnim'=>'slide', 'showButtonPanel'=>true, 'changeMonth'=>true, 'changeYear'=>true, 'yearRange'=>'1900:'.date('Y'), ), 'htmlOptions'=>array( 'style'=>'', 'placeHolder'=>'End Date' ), )); ?>label($model,'todate'); ?> widget('zii.widgets.jui.CJuiDatePicker',array( 'id'=>'HolidayHolidayrange_todate', 'name'=>'HolidayHolidayrange[todate]', 'value'=>$model->todate==''?'':date('d-m-Y',strtotime($model->todate)), 'options'=>array( 'dateFormat' => 'dd-mm-yy', 'showAnim'=>'slide', 'showButtonPanel'=>true, 'changeMonth'=>true, 'changeYear'=>true, 'yearRange'=>'1900:'.date('Y'), ), 'htmlOptions'=>array( 'style'=>'', 'placeHolder'=>'End Date' ), )); ?>
public function search()
{
....................
if(!empty($this->fromdate))
$criteria->addCondition('fromdate > "'.date("Y-m-d",strtotime($this->fromdate)).'" ');
if(!empty($this->todate))
$criteria->addCondition('todate < "'.date("Y-m-d",strtotime($this->todate)).'" ');
.......................
}