Filter CGridView per ID

Hi all,

I want to filter the records according to the current users, how can I do this?

this is my views/JobOrder/admin.php code:




<?php

	$itemFilter = array('0'=>'Waiting', '1'=>'Done');

	

	$this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'job-order-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'jo_cusname',

		'jo_details',

		'jo_date',

		'jo_amount',

		array(

            'name' => 'jo_status',

			'value'=>'$data->jo_status ? \'Done\':\'Waiting\'',

			'filter' => $itemFilter,

        ),

		array

		(

			'header'=>'Action',

			'class'=>'CButtonColumn',

			'template'=>'{view}{update}',

			'buttons'=>array

			(

			),

		),

	),

)); 

?>

this is my table structure:




table name job_order

jo_id 	

jo_cusname 	

jo_cusid 	

jo_details 	

jo_files 	

jo_date 	

jo_status

jo_cusid is equal to the current user’s id

tnx…

The filtering is done in $model->search()… you just need to add there the condition you need…

HOw?




  public function search() {

    $criteria=new CDbCriteria;

    $criteria->compare('id',$this->id);

    return new CActiveDataProvider($this, array(

      'criteria'=>$criteria,

    ));



How will i make

dynamic and get the value of the current user’s ID?


	public function search()

	{


                ...

  

		$criteria=new CDbCriteria;


		$UID = 3;

		$criteria->compare('jo_cusid',$UID);


		...

	}