<?php

$Permissoes = User::getUser(true);

if ($Permissoes->FUN_TBL_SERVICOS == 1) {

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