<?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 "badge_history".
 *
 * The followings are the available columns in table 'badge_history':
 * @property integer $id
 * @property integer $badge_id
 * @property integer $person_id
 * @property string $activation_start_date
 * @property string $activation_end_date
 * @property integer $max_served_meals
 */
class BadgeHistory extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return BadgeHistory 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 'badge_history';
	}

	/**
	 * @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(
			array('badge_id, person_id, activation_start_date, activation_end_date, max_served_meals', 'required'),
			array('badge_id, person_id, max_served_meals', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, badge_id, person_id, activation_start_date, activation_end_date, max_served_meals', '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(
			'id' => 'ID',
			'badge_id' => 'Badge',
			'person_id' => 'Person',
			'activation_start_date' => 'Activation Start Date',
			'activation_end_date' => 'Activation End Date',
			'max_served_meals' => 'Max Served Meals',
		);
	}

	/**
	 * 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()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('badge_id',$this->badge_id);
		$criteria->compare('person_id',$this->person_id);
		$criteria->compare('activation_start_date',$this->activation_start_date,true);
		$criteria->compare('activation_end_date',$this->activation_end_date,true);
		$criteria->compare('max_served_meals',$this->max_served_meals);

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

       

}