<?php
$Permissoes = User::getUser(true);

if ($Permissoes->FUN_TBL_PROSPECTOS == 1) {
	
	class ContratosItensController extends GxController {
	
	
		var $help = 'Esta é a ajuda';
	
			public function actionView($id) {
			$this->render('view', array(
				'model' => $this->loadModel($id, 'ContratosItens'),
			));
		}
	
		public function actionCreate() {
			$model = new ContratosItens;
	
	
			if (isset($_POST['ContratosItens'])) {
				$model->setAttributes($_POST['ContratosItens']);
	
				if ($model->save()) {
					if (Yii::app()->getRequest()->getIsAjaxRequest())
						Yii::app()->end();
					else
						$this->redirect(array('view', 'id' => $model->CTI_ID));
				}
			}
	
			$this->render('create', array( 'model' => $model));
		}
	
		public function actionUpdate($id) {
			$model = $this->loadModel($id, 'ContratosItens');
	
	
			if (isset($_POST['ContratosItens'])) {
				$model->setAttributes($_POST['ContratosItens']);
	
				if ($model->save()) {
					$this->redirect(array('view', 'id' => $model->CTI_ID));
				}
			}
	
			$this->render('update', array(
					'model' => $model,
					));
		}
	
		public function actionDelete($id) {
			if (Yii::app()->getRequest()->getIsPostRequest()) {
				$this->loadModel($id, 'ContratosItens')->delete();
	
				if (!Yii::app()->getRequest()->getIsAjaxRequest())
					$this->redirect(array('admin'));
			} else
				throw new CHttpException(400, 'Sua solicitação é inválida.');
		}
	
		public function actionIndex() {
			$dataProvider = new CActiveDataProvider('ContratosItens');
			$this->render('index', array(
				'dataProvider' => $dataProvider,
			));
		}
	
		public function actionAdmin() {
			$model = new ContratosItens('search');
			$model->unsetAttributes();
	
			if (isset($_GET['ContratosItens']))
				$model->setAttributes($_GET['ContratosItens']);
	
			$this->render('admin', array(
				'model' => $model,
			));
		}
	
	}
	
}