<?php

/**
 * This is the model class for table "sidcai_nombre_plantilla_pdf".
 *
 * The followings are the available columns in table 'sidcai_nombre_plantilla_pdf':
 * @property integer $plan_codigo_pk
 * @property string $plan_nombre
 *
 * The followings are the available model relations:
 * @property SidcaiPlantillaPdf[] $sidcaiPlantillaPdfs
 */
class SidcaiNombrePlantillaPdf extends CActiveRecord{
	/**
	 * @return string the associated database table name
	 */
	public function tableName(){
		return 'sidcai_nombre_plantilla_pdf';
	}

	/**
	 * @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('plan_nombre', 'required'),
			array('plan_nombre', 'length', 'max'=>45),
		);
	}

	/**
	 * @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(
			'sidcaiPlantillaPdfs' => array(self::HAS_MANY, 'SidcaiPlantillaPdf', 'nombre_plantilla_fk'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels(){
		return array(
			'plan_codigo_pk' => 'Plan Codigo Pk',
			'plan_nombre' => 'Plan Nombre',
		);
	}

	/**
	 * 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 SidcaiNombrePlantillaPdf the static model class
	 */
	public static function model($className=__CLASS__){
		return parent::model($className);
	}

	// Obtiene todos los nombres de las plantillas pdf.
	public static function getNombres(){
		$nombre = SidcaiNombrePlantillaPdf::model()->findAll();

		return CHtml::listData($nombre, 'plan_codigo_pk', 'plan_nombre');
	}
}
