<?php

/**
 * This is the model base class for the table "contratos_servicos".
 * 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 "ContratosServicos".
 *
 * Columns in table "contratos_servicos" available as properties of the model,
 * followed by relations of table "contratos_servicos" available as properties of the model.
 *
 * @property integer $COS_ID
 * @property integer $COS_IDCONTRATO
 * @property integer $COS_IDSERVICO
 *
 * @property Servicos $Servico
 * @property Contratos $Contrato
 */
class ContratosServicos extends GxActiveRecord {

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

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

	public static function label($n = 1) {
		return Yii::t('app', 'Serviço|Serviços', $n);
	}

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

	public function rules() {
		return array(
			array('COS_IDCONTRATO, COS_IDSERVICO', 'required'),
			array('COS_IDCONTRATO, COS_IDSERVICO', 'numerical', 'integerOnly'=>true),
			array('COS_ID, COS_IDCONTRATO, COS_IDSERVICO', 'safe', 'on'=>'search'),
		);
	}

	public function relations() {
		return array(
			'Servico' => array(self::BELONGS_TO, 'Servicos', 'COS_IDSERVICO'),
			'Contrato' => array(self::BELONGS_TO, 'Contratos', 'COS_IDCONTRATO'),
		);
	}

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

	public function attributeLabels() {
		return array(
			'COS_ID' => 'Código',
			'COS_IDCONTRATO' => 'Contrato',
			'COS_IDSERVICO' => 'Serviço',
			'Contrato' => 'Contrato',
			'Servico' => 'Serviço',
		);
	}

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

		$criteria->compare('COS_ID', $this->COS_ID);
		$criteria->compare('COS_IDCONTRATO', $this->COS_IDCONTRATO);
		$criteria->compare('COS_IDSERVICO', $this->COS_IDSERVICO);

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

}
