public function actionIndex() { $this->tituloManual = "Novo pedido"; $modelPizzaria = Pizzaria::model()->find(); $modelBanner = Banner::model()->ativos()->find(); if (!$this->validaSituacao()) { $this->render('indisponivel', array('modelPizzaria' => $modelPizzaria, 'modelBanner' => $modelBanner)); Yii::app()->end(); } $dataBebidas = new Produto(); $dataPratosLanche = new Produto(); $dataPromocao = new Promocao(); $modelSabor = array(); $modelTamanho = array(); $arrayTipoSabor = array(); $listCombinado = array(); switch ($modelPizzaria->tipo_restaurante) { case TipoRestaurante::_TIPO_PIZZARIA_: $modelSabor = Sabor::model()->ativos()->findAll(); $modelTamanho = Tamanho::getArrayTamanho(); $arrayTipoSabor = TipoSabor::getArrayTipoSabor(); break; default: $listCombinado = CHtml::listData(Combinado::model()->ativos()->findAll(), 'id', 'nome'); break; } $this->render('index', array('modelPedido' => new Pedido(), 'loginForm' => new LoginForm(), 'modelCliente' => new Cliente(), 'modelUsuario' => new Usuario(), 'dataBebidas' => $dataBebidas->ativos()->bebidas()->search(), 'dataPratosLanche' => $dataPratosLanche->ativos()->pratoLanche()->search(), 'dataPromocao' => $dataPromocao->ativas()->search(), 'modelSabor' => $modelSabor, 'modelTamanho' => $modelTamanho, 'arrayTipoSabor' => $arrayTipoSabor, 'modelPizzaria' => $modelPizzaria, 'arrayBairro' => CHtml::listData(EnderecoPermitido::model()->ativos()->findAll(array('group' => 'bairro', 'distinct' => true)), 'bairro', 'bairro'), 'arrayFormaPagamento' => CHtml::listData(FormaPagamento::model()->ativos()->findAll(), 'id', 'nome'), 'listCombinado' => $listCombinado, 'modelBanner' => $modelBanner)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return FormaPagamento the loaded model * @throws CHttpException */ public function loadModel($id) { $model = FormaPagamento::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Manages all models. */ public function actionIndex() { $this->tituloManual = "Lista de pedidos"; $model = new Pedido('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['Pedido'])) { $model->attributes = $_GET['Pedido']; } $this->render('index', array('model' => $model, 'arrayStatus' => Status::getArray(), 'arrayFormaPagamento' => CHtml::listData(FormaPagamento::model()->findAll(), 'id', 'nome'))); }
/** * Lists all models. */ public function actionIndex() { $this->tituloManual = "Lista de entregadores"; $modelPedido = new CActiveDataProvider('Pedido', array('criteria' => array('condition' => 'status = 3 AND excluido = 0'))); $entregador = ''; $entrega = ''; $modelEntregador = ''; if (isset($_GET['id'])) { $entrega = $_GET['id']; $modelEntrega = $this->loadModel($entrega); $modelEntregaPedido = new CActiveDataProvider('Pedido', array('criteria' => array('condition' => 'excluido = 0 AND entrega_id = ' . $_GET['id']))); $records = array_merge($modelPedido->data, $modelEntregaPedido->data); $modelEntregador = Entregador::model()->findByPk($modelEntrega['entregador_id']); $entregador = $modelEntregador->id; } else { $records = $modelPedido->data; } $modelPedidoAll = new CArrayDataProvider($records, array('sort' => array('attributes' => array('codigo', 'data_pedido', 'bairro', 'endereco', 'responsavel', 'forma_pagamento_id', 'preco_total', 'troco')), 'pagination' => array('pageSize' => 10))); $this->render('index', array('modelPedidoAll' => $modelPedidoAll, 'arrayFormaPagamento' => CHtml::listData(FormaPagamento::model()->ativos()->findAll(), 'id', 'nome'), 'arrayEntregadores' => CHtml::listData(Entregador::model()->findAll(), 'id', 'nome'), 'modelEntregador' => $modelEntregador, 'entregador' => $entregador, 'entrega' => $entrega)); }