Example #1
0
 /**
  * Lists all Pedido models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new PedidoSearch();
     if (Yii::$app->user->identity != null && Yii::$app->user->identity->username == "admin") {
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     } else {
         $dataProvider = $searchModel->search2(Yii::$app->request->queryParams);
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Example #2
0
 /**
  * Lists all Pedido models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new PedidoSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 /**
  * Deletes an existing Pedido model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     //Guarda a mensagem
     $mensagem = "";
     $transaction = \Yii::$app->db->beginTransaction();
     try {
         $itenspedido = Itempedido::find()->where(['idPedido' => $id])->all();
         foreach ($itenspedido as $p) {
             Insumo::atualizaQtdNoEstoqueDelete($p->idProduto, $p->quantidade);
         }
         if ($this->findModel($id)->delete()) {
             $transaction->commit();
         }
     } catch (\Exception $exception) {
         $transaction->rollBack();
         $mensagem = "Ocorreu uma falha inesperada ao tentar salvar ";
     }
     $searchModel = new PedidoSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'mensagem' => $mensagem]);
 }
 public function actionPdfpedido($id = null)
 {
     if ($id != null) {
         $searchPedido = new PedidoSearch();
         $modelRelatorio = $this->findModel($id);
         $dadosPedido = $searchPedido->searchCountPedidosContasAReceberPorPeriodo($modelRelatorio->inicio_intervalo, $modelRelatorio->fim_intervalo);
         //         Setando a data para o fuso do Brasil
         date_default_timezone_set('America/Sao_Paulo');
         $pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'content' => $this->renderPartial('pdfpedido', ['modelRelatorio' => $modelRelatorio, 'dadosPedido' => $dadosPedido]), 'options' => ['title' => 'Relatório de Pedidos Feitos'], 'methods' => ['SetHeader' => ['Gerado pelo Componente "Krajee Pdf" ||Gerado em: ' . date('d/m/Y h:m:s')], 'SetFooter' => ['|Página {PAGENO}|']]]);
         return $pdf->render();
     } else {
         $searchModel = new RelatorioSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
     }
 }