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 Sabor the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Sabor::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function actionSaveAll()
 {
     $this->tituloManual = "Gerenciador de preços de sabores de pizza";
     $return = true;
     $modelItem = Sabor::model()->naoExcluido()->ordenarPorDescricao()->findAll();
     // Alterar 2
     if (isset($_POST['TamanhoSabor']) && !empty($_POST['TamanhoSabor']['sabor_id'])) {
         $arrayItem = $_POST['TamanhoSabor']['sabor_id'];
         // Alterar 3
         foreach ($_POST['TamanhoSabor']['preco'] as $key_preco => $preco) {
             // Alterar 2
             if (empty($preco)) {
                 continue;
             }
             foreach ($arrayItem as $item) {
                 // Alterar 2
                 $tamanho_id = $_POST['TamanhoSabor']['tamanho_id'][$key_preco];
                 // Alterar 2
                 $model = TamanhoSabor::model()->findByAttributes(array('sabor_id' => $item, 'tamanho_id' => $tamanho_id));
                 // Alterar 3
                 if (empty($model)) {
                     $model = new TamanhoSabor();
                 }
                 $model->sabor_id = $item;
                 // Alterar 2
                 $model->tamanho_id = $tamanho_id;
                 $model->preco = $preco;
                 if (!$model->save()) {
                     $return = false;
                 }
             }
         }
     }
     $this->render('save_all', array('return' => $return, 'arrayTamanho' => CHtml::listData(Tamanho::model()->naoExcluido()->findAll(), 'id', 'descricao'), 'modelItens' => $modelItem, 'arrayItens' => CHtml::listData($modelItem, 'id', 'descricao')));
 }
 public function adicionarSabor(Sabor $sabor)
 {
     $this->sabores[] = $sabor;
     $this->valor += $sabor->getValor();
     return $this;
 }
 public function actionIndex()
 {
     $this->tituloManual = "Cardápios";
     $this->render('index', array('modelSabor' => Sabor::model()->naoExcluido()->ordenarPorSalgada()->findAll(), 'listTamanho' => CHtml::listData(Tamanho::model()->naoExcluido()->findAll(), 'id', 'descricao'), 'listAdicional' => CHtml::listData(Adicional::model()->naoExcluido()->findAll(), 'id', 'descricao'), 'listMassa' => Produto::getArrayListMassaCardapio(), 'listBebidas' => Produto::getArrayListBebidasCardapio()));
 }