<?php
/**
 * IMPORTANT NOTE
 * The code of this system is closed and a private proprietary of Flex Solutions.
 * A written authorization/license from Flex Solutions is required before using or modifying this code.
 * Email: sales@flexsolution.biz, Phone: +962795342585, Website: http://www.flexsolutions.biz
 */
 

/**
 * This is the model class for table "v_user".
 *
 * The followings are the available columns in table 'v_user':
 * @property integer $id
 * @property string $username
 * @property string $password
 * @property string $email
 * @property integer $location
 * @property string $status
 * @property integer $created_by
 * @property string $created_date
 * @property integer $last_edited_by
 * @property string $last_edited_date
 * @property string $role
 */
class VUser extends LsmsActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return VUser the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'v_user';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			// The following rule is used by search().
			array('id, username, password, email, location, status, created_by, created_date, last_edited_by, last_edited_date, role', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
                    'username' => yii::t('default', 'Username'),
                    'password' => yii::t('default', 'Password'),
                    'email' => yii::t('default', 'Email'),
                    'location' => yii::t('default', 'Location'),
                    'status' => yii::t('default', 'Status'),
                    'role' => yii::t('default', 'Role'),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('location',$this->location, true);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('role',$this->role,true);
                $pageSize = $this->yiiparam('pageSize');

		return new CActiveDataProvider($this, array(
                    'pagination' => array('pageSize' => $pageSize,),
                    'criteria' => $criteria,
                ));
	}


        public function getPrimaryKey()
	{
		return $this->id;
	}
}