<?php

/**
 * This is the model class for table "{{mas_inv_bin}}".
 *
 * @property integer $id
 * @property string $bin_name
 * @property integer $rack_id
 * @property string $isActive
 * @property string $is_base_bin
 * @property integer $created_by
 * @property integer $updated_by
 * @property string $created_datetime
 * @property string $updated_datetime
 */
class MasInvBin extends CActiveRecord
{
    public function tableName()
    {
        return '{{mas_inv_bin}}';
    }

    public function rules()
    {
        return array(
            array('rack_id, created_by, updated_by', 'numerical', 'integerOnly' => true),
            array('bin_name', 'length', 'max' => 255),
            array('isActive, is_base_bin', 'length', 'max' => 1),
            array('created_datetime, updated_datetime', 'safe'),
            array('id, bin_name, rack_id, isActive, is_base_bin, created_by, updated_by, created_datetime, updated_datetime', 'safe', 'on' => 'search'),
        );
    }

    public function relations()
    {
        return array(
            // Relation to MasInvRack so we can get rack_name
            'rack' => array(self::BELONGS_TO, 'MasInvRack', 'rack_id'),
        );
    }

    public function attributeLabels()
    {
        return array(
            'id'               => 'ID',
            'bin_name'         => 'Bin Name',
            'rack_id'          => 'Rack',
            'isActive'         => 'Is Active',
            'is_base_bin'      => 'Is Base Bin',
            'created_by'       => 'Created By',
            'updated_by'       => 'Updated By',
            'created_datetime' => 'Created Datetime',
            'updated_datetime' => 'Updated Datetime',
        );
    }

    public function search()
    {
        $criteria = new CDbCriteria;

        $criteria->compare('id',               $this->id);
        $criteria->compare('bin_name',         $this->bin_name,    true);
        $criteria->compare('rack_id',          $this->rack_id);
        $criteria->compare('isActive',         $this->isActive,    true);
        $criteria->compare('is_base_bin',      $this->is_base_bin, 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,
        ));
    }

    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }
}