<?php

/**
 * This is the model base class for the table "questionario_perguntas_etapas".
 * 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 "QuestionarioPerguntasEtapas".
 *
 * Columns in table "questionario_perguntas_etapas" available as properties of the model,
 * followed by relations of table "questionario_perguntas_etapas" available as properties of the model.
 *
 * @property integer $QFE_IDQFE
 * @property integer $QFE_IDQUESTIONARIO
 * @property integer $QFE_IDETAPA
 *
 * @property Questionarios $Questionarios
 * @property Etapas $Etapas
 */
class QuestionariosFluxoEtapas extends GxActiveRecord {

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

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

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

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

	public function rules() {
		return array(
			array('QFE_IDQFE, QFE_IDQUESTIONARIO, QFE_IDETAPA', 'numerical', 'integerOnly'=>true),
			array('QFE_IDQUESTIONARIO, QFE_IDETAPA', 'default', 'setOnEmpty' => true, 'value' => null),
			array('QFE_IDQFE, QFE_IDQUESTIONARIO, QFE_IDETAPA', 'safe', 'on'=>'search'),
			);
	}

	public function relations() {
		return array(
            'QuestionariosFluxo' => array(self::BELONGS_TO,
                                     'QuestionariosFluxo',
                                     'QFE_IDQUESTIONARIO',
                                     'joinType'=>'LEFT JOIN'),

            'QuestionarioEtapas' => array(self::BELONGS_TO,
                                          'QuestionarioEtapas',
                                          'QFE_IDETAPA',
                                          'joinType'=>'LEFT JOIN'),

            'QuestionarioPerguntasRespostas' => array(self::BELONGS_TO,
                                                      'QuestionarioPerguntasRespostas',
                                                      'QFE_IDQFE',
                                                      'joinType'=>'LEFT JOIN'),
			);
	}

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

	public function attributeLabels() {
		return array(
			'QFE_IDQFE' 	     => 'Código',
            'QFE_IDQUESTIONARIO' => 'Questionario',
            'QFE_IDETAPA'        => 'Etapa',
			);
	}

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

		$criteria->compare('QFE_IDQFE', $this->QFE_IDQFE);
        $criteria->compare('QFE_IDQUESTIONARIO', $this->QFE_IDQUESTIONARIO, true);
        $criteria->compare('QFE_IDETAPA', $this->QFE_IDETAPA, true);

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