/**
  * 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 Adicional the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Adicional::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 adicionais extra";
     $return = true;
     $modelItem = Adicional::model()->naoExcluido()->findAll();
     // Alterar 2
     if (isset($_POST['TamanhoAdicional']) && !empty($_POST['TamanhoAdicional']['adicional_id'])) {
         // Alterar 1
         $arrayItem = $_POST['TamanhoAdicional']['adicional_id'];
         // Alterar 3
         foreach ($_POST['TamanhoAdicional']['preco'] as $key_preco => $preco) {
             // Alterar 2
             if (empty($preco)) {
                 continue;
             }
             foreach ($arrayItem as $item) {
                 // Alterar 2
                 $tamanho_id = $_POST['TamanhoAdicional']['tamanho_id'][$key_preco];
                 // Alterar 2
                 $model = TamanhoAdicional::model()->findByAttributes(array('adicional_id' => $item, 'tamanho_id' => $tamanho_id));
                 // Alterar 3
                 if (empty($model)) {
                     $model = new TamanhoAdicional();
                 }
                 $model->adicional_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 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()));
 }