ソースを参照

Refactoring getControllerUrlPath()

refactoring
コミット
d5d27ccdf1
5個のファイルの変更26行の追加16行の削除
  1. +12
    -5
      backend/controllers/DocumentController.php
  2. +2
    -2
      backend/views/document/_form.php
  3. +6
    -1
      backend/views/invoice/index.php
  4. +6
    -1
      backend/views/quotation/index.php
  5. +0
    -7
      common/models/Document.php

+ 12
- 5
backend/controllers/DocumentController.php ファイルの表示

@@ -86,7 +86,7 @@ class DocumentController extends BackendController
$this->processInvoiceViaDeliveryNotes($model) ;

Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('create', $model));
return $this->redirect(['/' . $model->getControllerUrlPath() . '/update', 'id' => $model->id]);
return $this->redirect(['/' . $this->getControllerUrl() . '/update', 'id' => $model->id]);
} else {
Yii::$app->getSession()->setFlash('error', 'Un problème est survenu lors de la création du document.');
}
@@ -161,7 +161,7 @@ class DocumentController extends BackendController
]);

Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('delete', $model));
$this->redirect([$model->getControllerUrlPath().'/index']);
$this->redirect([$this->getControllerUrl().'/index']);
}

public function actionDownload($id)
@@ -179,7 +179,7 @@ class DocumentController extends BackendController
else {
Yii::$app->getSession()->setFlash('danger', $this->getFlashMessage('send', $document));
}
$this->redirect([$document->getControllerUrlPath().'/index']);
$this->redirect([$this->getControllerUrl().'/index']);
}

public function actionAjaxUserInfos($typeAction, $idUser, $classDocument, $idDocument = false)
@@ -262,12 +262,12 @@ class DocumentController extends BackendController
$document->changeStatus(Document::STATUS_VALID);
$document->save();
Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('validate', $document));
return $this->redirect(['delivery-note/index']);
return $this->redirect([$this->getControllerUrl().'/index']);
}
}

Yii::$app->getSession()->setFlash('danger', 'Une erreur est survenue lors de la validation du document.');
return $this->redirect(['delivery-note/index']);
return $this->redirect([$this->getControllerUrl().'/index']);
}

public function actionAjaxValidateDocument($idDocument, $classDocument)
@@ -522,6 +522,13 @@ class DocumentController extends BackendController
return $title;
}

public function getControllerUrl()
{
$path = strtolower($this->getClass());
$path = str_replace('deliverynote', 'delivery-note', $path);
return $path;
}

/**
* Recherche un Document en fonction de son ID.
*

+ 2
- 2
backend/views/document/_form.php ファイルの表示

@@ -142,13 +142,13 @@ use common\models\Producer;
<div id="" class="info-box">
<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([$model->getControllerUrlPath().'/download', 'id' => $model->id]) ?>" class="btn btn-default">Télécharger (PDF)</a>
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl().'/download', 'id' => $model->id]) ?>" class="btn btn-default"><span class="glyphicon glyphicon-download-alt"></span> Télécharger (PDF)</a>
</div>
</div>
<div id="" class="info-box">
<span class="info-box-icon bg-red"><i class="fa fa-flash"></i></span>
<div class="info-box-content">
<a v-if="document.status == 'draft'" class="btn btn-default" @click="validateDocument">Valider le document</a>
<a v-if="document.status == 'draft'" class="btn btn-default" @click="validateDocument"><span class="glyphicon glyphicon-ok"></span> Valider le document</a>
</div>
</div>
</div>

+ 6
- 1
backend/views/invoice/index.php ファイルの表示

@@ -99,10 +99,15 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete} {send} {download}',
'template' => '{validate} {update} {delete} {send} {download}',
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'validate' => function ($url, $model) {
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [
'title' => Yii::t('app', 'Valider'), 'class' => 'btn btn-default'
]) : '');
},
'send' => function($url, $model) {
return (!$model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [
'title' => Yii::t('app', 'Envoyer'), 'class' => 'btn btn-default'

+ 6
- 1
backend/views/quotation/index.php ファイルの表示

@@ -85,10 +85,15 @@ $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plu
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete} {send} {download}',
'template' => '{validate} {update} {delete} {send} {download}',
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'validate' => function ($url, $model) {
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [
'title' => Yii::t('app', 'Valider'), 'class' => 'btn btn-default'
]) : '');
},
'send' => function($url, $model) {
return (!$model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [
'title' => Yii::t('app', 'Envoyer'), 'class' => 'btn btn-default'

+ 0
- 7
common/models/Document.php ファイルの表示

@@ -179,13 +179,6 @@ class Document extends ActiveRecordCommon
return '';
}

public function getControllerUrlPath()
{
$path = strtolower($this->getClass());
$path = str_replace('deliverynote', 'delivery-note', $path);
return $path;
}

public function isValidClass($typeDocument)
{
return in_array($typeDocument, ['Invoice', 'DeliveryNote', 'Quotation']);

読み込み中…
キャンセル
保存