Selaa lähdekoodia

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

refactoring
Guillaume Bourgeois 1 vuosi sitten
vanhempi
commit
7e1aca7092
3 muutettua tiedostoa jossa 17 lisäystä ja 3 poistoa
  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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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…
Peruuta
Tallenna