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

if ($Permissoes->FUN_TBL_NOTICIAS == 1) {
	
	class NoticiasController extends GxController {
	
	
		var $help = 'Cadastro das notícias apresentadas na tela principal do CRM acesso gerencial pelo menu Cadastros ->Notícias. ';
	
			public function actionView($id) {
			$this->render('view', array(
				'model' => $this->loadModel($id, 'Noticias'),
			));
		}
	
		public function actionCreate() {
			$model = new Noticias;
			if (isset($_POST['Noticias'])) {
				$model->setAttributes($_POST['Noticias']);
				
				if ($model->save()) {
					if (Yii::app()->getRequest()->getIsAjaxRequest())
						Yii::app()->end();
					else
						$this->redirect(array('view', 'id' => $model->NTS_IDNOTICIA));
				}
			}
	
			$this->render('create', array( 'model' => $model));
		}
	
		public function actionUpdate($id) {
			$model = $this->loadModel($id, 'Noticias');
	
	
			if (isset($_POST['Noticias'])) {
				$model->setAttributes($_POST['Noticias']);
	
				if ($model->save()) {
					$this->redirect(array('view', 'id' => $model->NTS_IDNOTICIA));
				}
			}
	
			$this->render('update', array(
					'model' => $model,
					));
		}
	
		public function actionDelete($id) {
			if (Yii::app()->getRequest()->getIsPostRequest()) {
				$this->loadModel($id, 'Noticias')->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 Noticias('search');
			$model->unsetAttributes();
	
			if (isset($_GET['Noticias']))
				$model->setAttributes($_GET['Noticias']);
	
			$this->render('admin', array(
				'model' => $model,
			));
		}
	
	}
	
}