Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class PainelClienteController extends Controller
- {
- public $layout='//layouts/column1';
- /**
- * @return array action filters
- */
- public function filters()
- {
- return array(
- 'accessControl', // perform access control for CRUD operations
- );
- }
- /**
- * Specifies the access control rules.
- * This method is used by the 'accessControl' filter.
- * @return array access control rules
- */
- public function accessRules()
- {
- return array(
- array('allow', // allow all users to perform 'index' and 'view' actions
- 'actions'=>array('index','view'),
- 'users'=>array('*'),
- ),
- array('allow', // allow authenticated user to perform 'create' and 'update' actions
- 'actions'=>array('create','update'),
- 'users'=>array('@'),
- ),
- array('allow', // allow admin user to perform 'admin' and 'delete' actions
- 'actions'=>array('admin','delete'),
- 'users'=>array('admin'),
- ),
- array('deny', // deny all users
- 'users'=>array('*'),
- ),
- );
- }
- /**
- * This is the default 'index' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionIndex()
- {
- $painelSelecionadoCliente = $this->selecionaPainelCliente();
- $campos = new SpfRespostas;
- $this->render('painelcliente', array('painelSelecionadoCliente' => $painelSelecionadoCliente,
- 'campos'=> $campos));
- }
- public function selecionaPainelCliente()
- {
- if(Yii::app()->request->isPostRequest)
- {
- $criteria = new CDbCriteria( array(
- //'select'=>'rpc_painel_fk',
- 'with' => array('rpcPainelFk'),
- 'condition'=>'rpc_cliente_fk = :idUsuario AND
- rpc_painel_fk = :idPainel ',
- 'params'=>array(':idUsuario' => (int)Yii::app()->user->id,
- ':idPainel' => (int)$_POST['painel_id']),
- ));
- $painelSelecionado = SpfRelPaineisClientes::model()->findAll( $criteria );
- return $painelSelecionado;
- }
- else
- throw new CHttpException(404,'Requisição inválida.');
- }
- public function buscaTendenciaPainel($painel)
- {
- if(Yii::app()->request->isPostRequest)
- {
- $criteria = new CDbCriteria( array(
- 'with' => array('rptTendenciaFk'),
- 'condition'=>'rpt_painel_fk = :idPainel',
- 'params'=>array(':idPainel' => $painel),
- ));
- $tendenciaPainel = SpfRelPaineisTendencias::model()->findAll( $criteria );
- return $tendenciaPainel;
- }
- else
- throw new CHttpException(404,'Requisição inválida.');
- }
- public function buscaValoresEscalaPainel($escala)
- {
- if(Yii::app()->request->isPostRequest)
- {
- $criteria = new CDbCriteria( array(
- //'with' => array('rptTendenciaFk'),
- 'condition'=>'eva_escala_fk = :idEscala',
- 'params'=>array(':idEscala' => $escala),
- ));
- $valoresEscalasPainel = SpfEscalasValores::model()->findAll( $criteria );
- return $valoresEscalasPainel;
- }
- else
- throw new CHttpException(404,'Requisição inválida.');
- }
- public function actionAdiciona()
- {
- $painelSelecionado = Yii::app()->user->SessionPainelSelecionado;
- $idUsuario = Yii::app()->user->id;
- $model=new SpfRespostas;
- // recupera os itens para atualização em lote
- // assumindo que cada item é instância de um Item
- if(isset($_POST['res_resposta']))
- {
- $valid=true;
- foreach($items as $i=>$item)
- {
- if(isset($_POST['res_resposta'][$i]))
- $item->attributes=$_POST['res_resposta'][$i];
- $valid=$valid && $item->validate();
- }
- if($valid): // todos os itens são validos
- // ...faça algo aqui
- endif;
- }
- Yii::app()->user->setFlash('pesquisa','<span style="color: green; font-size: 20px">Sua pesquisa foi registrada com sucesso.<br /> Você está ajudando a sempre melhorarmos nossos serviços.</span>');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment