Exemplo n.º 1
0
 public function actionCreateCreditNote($code, $targetBlank = false)
 {
     /**
      * @var $model Registration
      * @var $invoice Invoice
      */
     $model = $this->findModelByCode($code);
     if ($model->status === $model::STATUS_CONFIRM) {
         $invoice = Invoice::getByRegistrationId($model->id);
         $pdfHelper = new PdfHelper();
         $invoice->newAmount = Yii::$app->request->post('Invoice')['newAmount'];
         $invoice->subject = Yii::$app->request->post('Invoice')['subject'];
         $invoice->finalText = Yii::$app->request->post('Invoice')['finalText'];
         $content = $this->renderPartial('credit_note_pdf', ['model' => $model, 'invoice' => $invoice]);
         if ($targetBlank) {
             $pdfHelper->renderPDF($content, $model, $invoice);
         } else {
             $pdfHelper->generatePDF($content, $model, $invoice);
         }
     }
 }