<?php

$Permissoes = User::getUser(true);

if ($Permissoes->FUN_TBL_RDM == 1 or $Permissoes->FUN_IDSETOR == 5) {

    class RdmAcaoController extends GxController {

        var $help = 'Esta é a ajuda';

        public function actionView($id) {
            $this->render('view', array(
                'model' => $this->loadModel($id, 'RdmAcao'),
            ));
        }

        public function actionCreate() {
            $model = new RdmAcao;


            if (isset($_POST['RdmAcao'])) {
                $model->setAttributes($_POST['RdmAcao']);

                if ($model->save()) {
                    if (Yii::app()->getRequest()->getIsAjaxRequest())
                        Yii::app()->end();
                    else
                        $this->redirect(array('view', 'id' => $model->RDA_IDACAO));
                }
            }

            $this->render('create', array('model' => $model));
        }

        public function actionUpdate($id) {
            $model = $this->loadModel($id, 'RdmAcao');


            if (isset($_POST['RdmAcao'])) {
                $model->setAttributes($_POST['RdmAcao']);

                if ($model->save()) {
                    $this->redirect(array('view', 'id' => $model->RDA_IDACAO));
                }
            }

            $this->render('update', array(
                'model' => $model,
            ));
        }

        public function actionDelete($id) {
            if (Yii::app()->getRequest()->getIsPostRequest()) {
                $this->loadModel($id, 'RdmAcao')->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 RdmAcao('search');
            $model->unsetAttributes();

            if (isset($_GET['RdmAcao']))
                $model->setAttributes($_GET['RdmAcao']);

            $this->render('admin', array(
                'model' => $model,
            ));
        }

    }

}