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

if ($Permissoes->FUN_TBL_PROSPECTOS == 1) {
	
	class EnderecosController extends GxController {
	
	
		var $help = 'Esta é a ajuda';
	
			public function actionView($id) {
			$this->render('view', array(
				'model' => $this->loadModel($id, 'Enderecos'),
			));
		}
	
		public function actionCreate($CLI_IDCLIENTE) {
			$model = new Enderecos;
	
	
			if (isset($_POST['Enderecos'])) {
				$model->setAttributes($_POST['Enderecos']);
	
				if ($model->save()) {
					if (Yii::app()->getRequest()->getIsAjaxRequest())
						Yii::app()->end();
					else
						$this->redirect(array('clientes/view', 'id' => $model->END_IDCLIENTE, 'page' => 'endereco-cobranca'));
				}
			}
	
			$this->render('create', array( 'model' => $model, 'CLI_IDCLIENTE' => $CLI_IDCLIENTE));
		}
	
		public function actionUpdate($id) {
			$model = $this->loadModel($id, 'Enderecos');
	
	
			if (isset($_POST['Enderecos'])) {
				$model->setAttributes($_POST['Enderecos']);
	
				if ($model->save()) {
					$this->redirect(array('view', 'id' => $model->END_IDENDERECO));
				}
			}
	
			$this->render('update', array(
					'model' => $model,
					));
		}
	
		public function actionDelete($id) {
			if (Yii::app()->getRequest()->getIsPostRequest()) {
				$this->loadModel($id, 'Enderecos')->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('Enderecos');
			$this->render('index', array(
				'dataProvider' => $dataProvider,
			));
		}
	
		public function actionAdmin() {
			$model = new Enderecos('search');
			$model->unsetAttributes();
	
			if (isset($_GET['Enderecos']))
				$model->setAttributes($_GET['Enderecos']);
	
			$this->render('admin', array(
				'model' => $model,
			));
		}
	
	}
	
}