<?php

/**
 * This is the model base class for the table "contratos_documentos_fiscais".
 * 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 "ClientesDocumentosFiscais".
 *
 * Columns in table "contratos_documentos_fiscais" available as properties of the model,
 * followed by relations of table "contratos_documentos_fiscais" available as properties of the model.
 *
 * @property integer $CDF_ID
 * @property integer $CDF_IDCONTRATO
 * @property integer $CDF_IDDOCUMENTO
 *
 * @property DocumentosFiscais $DocumentoFiscal
 * @property Clientes $Cliente
 */
class ContratosDocumentosFiscais extends GxActiveRecord {

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

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

    public static function label($n = 1) {
        return Yii::t('app', 'Contrato X Documento Fiscal|Contratos X Documentos Fiscais', $n);
    }

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

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

    public function rules() {
        return array(
            array('CDF_IDCONTRATO, CDF_IDDOCUMENTO', 'required'),
            array('CDF_IDCONTRATO, CDF_IDDOCUMENTO', 'numerical', 'integerOnly' => true),
            array('CDF_ID, CDF_IDCONTRATO, CDF_IDDOCUMENTO', 'safe', 'on' => 'search'),
        );
    }

    public function relations() {
        return array(
            'DocumentoFiscal'   => array(self::BELONGS_TO, 'DocumentosFiscais', 'CDF_IDDOCUMENTO'),
            'Contrato'           => array(self::BELONGS_TO, 'Contratos', 'CDF_IDCONTRATO'),
        );
    }

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

    public function attributeLabels() {
        return array(
            'CDF_ID'            => 'Código',
            'CDF_IDCONTRATO'     => 'Contrato',
            'CDF_IDDOCUMENTO'   => 'Documento Fiscal',
            'Modulo'            => 'Contrato',
            'DocumentoFiscal'   => 'Documento Fiscal',
        );
    }

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

        $criteria->compare('CDF_ID', $this->CDF_ID);
        $criteria->compare('CDF_IDCONTRATO', $this->CDF_IDCONTRATO);
        $criteria->compare('CDF_IDDOCUMENTO', $this->CDF_IDDOCUMENTO);

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

}
