소스 검색

[Backend] Documents : pouvoir regénérer PDF #798

refactoring
Guillaume Bourgeois 1 년 전
부모
커밋
7e1aca7092
3개의 변경된 파일17개의 추가작업 그리고 3개의 파일을 삭제
  1. +8
    -0
      backend/controllers/DocumentController.php
  2. +7
    -1
      backend/views/document/_form.php
  3. +2
    -2
      common/models/Document.php

+ 8
- 0
backend/controllers/DocumentController.php 파일 보기

@@ -316,6 +316,14 @@ class DocumentController extends BackendController
return $document->downloadPdf();
}

public function actionRegenerate($id)
{
$document = $this->findModel($id);
$document->downloadPdf(true);
Yii::$app->getSession()->setFlash('success', 'Le document PDF a bien été regénéré.');
return $this->redirect([$this->getControllerUrl() . '/update', 'id' => $id]);
}

public function actionSend($id, $backUpdateForm = false)
{
$document = $this->findModel($id);

+ 7
- 1
backend/views/document/_form.php 파일 보기

@@ -208,7 +208,13 @@ use common\models\Producer;
<span class="info-box-icon bg-blue"><i class="fa fa-download"></i></span>
<div class="info-box-content">
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/download', 'id' => $model->id]) ?>"
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-download-alt"></span> Télécharger (PDF)</a>
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-download-alt"></span> Télécharger</a>

<?php if($model->isStatusValid()): ?>
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/regenerate', 'id' => $model->id]) ?>"
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer</a>
<?php endif; ?>

<?php if ($model->getClass() == 'Invoice' && Producer::getConfig('option_export_evoliz')): ?>
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/export-csv-evoliz', 'id' => $model->id]) ?>"
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-save-file"></span> Export Evoliz

+ 2
- 2
common/models/Document.php 파일 보기

@@ -283,11 +283,11 @@ class Document extends ActiveRecordCommon
}
}

public function downloadPdf()
public function downloadPdf($regenerate = false)
{
$filenameComplete = $this->getFilenameComplete();

if (!file_exists($filenameComplete) || $this->isStatusDraft()) {
if (!file_exists($filenameComplete) || $this->isStatusDraft() || $regenerate) {
$this->generatePdf(Pdf::DEST_FILE);
}


Loading…
취소
저장