<?php

/**
 * This is the model base class for the table "questionarios".
 * 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 "Questionarios".
 *
 * Columns in table "questionarios" available as properties of the model,
 * followed by relations of table "questionarios" available as properties of the model.
 *
 * @property integer $QUF_IDQUESTIONARIO
 * @property string $QUF_TITULO
 * @property string $QUF_REFERENCIA
 *
 * @property QuestionarioEtapas $QuestionarioEtapas
 * @property QuestionarioPerguntas $QuestionarioPerguntas
 */
class QuestionariosFluxo extends GxActiveRecord {

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

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

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

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

	public function rules() {
		return array(
			array('QUF_TITULO, QUF_REFERENCIA', 'required'),
			array('QUF_IDQUESTIONARIO', 'numerical', 'integerOnly'=>true),
            array('QUF_TITULO', 'length', 'max'=>255),
			array('QUF_REFERENCIA', 'length', 'max'=>45),
			array('QUF_TITULO, QUF_REFERENCIA', 'default', 'setOnEmpty' => true, 'value' => null),
			array('QUF_IDQUESTIONARIO, QUF_TITULO', 'safe', 'on'=>'search'),
			);
	}

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

			);
	}

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

	public function attributeLabels() {
		return array(
			'QUF_IDQUESTIONARIO' 	=> 'Código',
			'QUF_TITULO'            => 'Título',
			'QUF_REFERENCIA' 	    => 'Referência',
			);
	}

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

		$criteria->compare('QUF_IDQUESTIONARIO', $this->QUF_IDQUESTIONARIO);
		$criteria->compare('QUF_TITULO', $this->QUF_TITULO, true);
		$criteria->compare('QUF_REFERENCIA', $this->QUF_REFERENCIA);

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