コード例 #1
0
 /**
  * Deletes an existing Contasareceber 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 {
         if ($this->findModel($id)->delete()) {
             $transaction->commit();
         }
     } catch (\Exception $exception) {
         $transaction->rollBack();
         $mensagem = "Ocorreu uma falha inesperada ao tentar salvar ";
     }
     $searchModel = new ContasareceberSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'mensagem' => $mensagem]);
 }
コード例 #2
0
 public function actionPdfcontasareceber($id = null)
 {
     if ($id != null) {
         $searchContasAReceber = new ContasareceberSearch();
         $modelRelatorio = $this->findModel($id);
         $dadosContasAReceber = [$searchContasAReceber->searchDatasContasAReceberPorPeriodo($modelRelatorio->inicio_intervalo, $modelRelatorio->fim_intervalo), $searchContasAReceber->searchContasAReceberPorPeriodo($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('pdfcontasareceber', ['modelRelatorio' => $modelRelatorio, 'dadosContasAReceber' => $dadosContasAReceber]), 'options' => ['title' => 'Relatório de Contas a Receber'], '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]);
     }
 }