<?php

/**
 * This is the model base class for the table "acessos".
 * DO NOT MODIFY THIS FILE! It is automatically generated by giix.
 * If any changes are necessary, you must set or override the required
 * property or method in class "Acessos".
 *
 * Columns in table "acessos" available as properties of the model,
 * followed by relations of table "acessos" available as properties of the model.
 *
 * @property integer $ACE_IDACESSO
 * @property integer $ACE_IDFUNCIONARIO
 * @property string $ACE_ENDERECOIP
 * @property string $ACE_DATA
 *
 * @property Funcionarios $Funcionario
 */
class Acessos extends GxActiveRecord {

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

    public function tableName() {
        return 'acessos';
    }

    public static function label($n = 1) {
        return Yii::t('app', 'Acesso|Acessos', $n);
    }

    public static function representingColumn() {
        return 'ACE_ENDERECOIP';
    }

    public function behaviors() {
        return array('datetimeI18NBehavior' => array('class' => 'ext.DateTimeI18NBehavior'));
    }

    public function rules() {
        return array(
            array('ACE_IDFUNCIONARIO, ACE_ENDERECOIP, ACE_DATA', 'required'),
            array('ACE_IDFUNCIONARIO', 'numerical', 'integerOnly' => true),
            array('ACE_ENDERECOIP', 'length', 'max' => 25),
            array('ACE_IDACESSO, ACE_IDFUNCIONARIO, ACE_ENDERECOIP, ACE_DATA', 'safe', 'on' => 'search'),
        );
    }

    public function relations() {
        return array(
            'Funcionario' => array(self::BELONGS_TO, 'Funcionarios', 'ACE_IDFUNCIONARIO'),
        );
    }

    public function pivotModels() {
        return array(
        );
    }

    public function attributeLabels() {
        return array(
            'ACE_IDACESSO' => 'Código',
            'ACE_IDFUNCIONARIO' => 'Funcionário',
            'ACE_ENDERECOIP' => 'Endereço IP',
            'ACE_DATA' => 'Data',
            'Funcionario' => 'Funcionário',
        );
    }

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

        $criteria->compare('ACE_IDACESSO', $this->ACE_IDACESSO);
        $criteria->compare('ACE_IDFUNCIONARIO', $this->ACE_IDFUNCIONARIO);
        $criteria->compare('ACE_ENDERECOIP', $this->ACE_ENDERECOIP, true);
        $criteria->compare('ACE_DATA', $this->ACE_DATA, true);

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

}
