<?php

/**
 * This is the model class for table "sidcai_certificado".
 *
 * The followings are the available columns in table 'sidcai_certificado':
 * @property integer $cert_codigo_pk
 * @property integer $decl_codigo_fk
 * @property integer $firm_codigo_fk
 * @property string $cert_fecha_emitida
 * @property string $cert_codigo_unico
 * @property boolean $cert_habilitado
 * @property integer $cert_erro_fk
 * @property integer $audit_usua
 * @property integer $apor_codigo_fk
 *
 * The followings are the available model relations:
 * @property SidcaiDeclaracioncti $declCodigoFk
 * @property SidcaiCertificadoError $certErroFk
 */
class SidcaiCertificado extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'sidcai_certificado';
	}

	/**
	 * @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('decl_codigo_fk, firm_codigo_fk, cert_fecha_emitida, cert_codigo_unico, apor_codigo_fk', 'required'),
			array('decl_codigo_fk, firm_codigo_fk, cert_erro_fk, audit_usua, apor_codigo_fk', 'numerical', 'integerOnly'=>true),
			array('cert_codigo_unico', 'length', 'max'=>70),
			array('cert_habilitado', 'safe'),
		);
	}

	/**
	 * @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(
			'declCodigoFk' => array(self::BELONGS_TO, 'SidcaiDeclaracioncti', 'decl_codigo_fk'),
			'certErroFk' => array(self::BELONGS_TO, 'SidcaiCertificadoError', 'cert_erro_fk'),
			'aporCodigoFk' => array(self::BELONGS_TO, 'SidcaiAportante', 'apor_codiog_fk'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'cert_codigo_pk' => 'Código',
			'decl_codigo_fk' => 'Declaración',
			'firm_codigo_fk' => 'Firma',
			'cert_fecha_emitida' => 'Fecha Emitida',
			'cert_codigo_unico' => 'Código Unico',
			'cert_habilitado' => 'Habilitado',
			'cert_erro_fk' => 'Error',
			'audit_usua' => 'Auditor',
			'apor_codigo_fk' => 'Empresa'
		);
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return SidcaiCertificado the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
