<?php

/**
 * This is the model class for table "{{mas_inv_rack}}".
 *
 * The followings are the available columns in table '{{mas_inv_rack}}':
 * @property integer $id
 * @property string $rack_name
 * @property integer $total_bins
 * @property string $isActive
 * @property string $is_base_rack
 * @property integer $created_by
 * @property integer $updated_by
 * @property string $created_datetime
 * @property string $updated_datetime
 */
class MasInvRack extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{mas_inv_rack}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		return array(
			array('rack_name, total_bins, created_by, updated_by, created_datetime, updated_datetime', 'required'),
			array('total_bins, created_by, updated_by', 'numerical', 'integerOnly'=>true),
			array('rack_name', 'length', 'max'=>255),
			array('isActive, is_base_rack', 'length', 'max'=>1),
			array('id, rack_name, total_bins, isActive, is_base_rack', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		return array();
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id'               => 'ID',
			'rack_name'        => 'Rack Name',
			'total_bins'       => 'Total Bins',
			'isActive'         => 'Is Active',
			'is_base_rack'     => 'Is Base Rack',
			'created_by'       => 'Created By',
			'updated_by'       => 'Updated By',
			'created_datetime' => 'Created Datetime',
			'updated_datetime' => 'Updated Datetime',
		);
	}

	/**
	 * 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);
		$criteria->compare('rack_name',        $this->rack_name,        true);
		$criteria->compare('total_bins',       $this->total_bins);
		$criteria->compare('isActive',         $this->isActive,         true);
		$criteria->compare('is_base_rack',     $this->is_base_rack,     true);
		$criteria->compare('created_by',       $this->created_by);
		$criteria->compare('updated_by',       $this->updated_by);
		$criteria->compare('created_datetime', $this->created_datetime, true);
		$criteria->compare('updated_datetime', $this->updated_datetime, true);

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

	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return MasInvRack the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}