|
- <?php
-
-
-
- namespace backend\controllers;
-
- use Yii;
-
- class InvoiceController extends DocumentController
- {
-
-
- public function actionIndex()
- {
- $searchModel = new InvoiceSearch() ;
- $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
-
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
- }
-
- public function actionAjaxDeleteDeliveryNote($idInvoice, $idDeliveryNote)
- {
- \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
-
- $invoice = Invoice::searchOne(['id' => $idInvoice]);
-
- if($invoice && $invoice->isStatusDraft()) {
- Order::updateAll([
- 'id_invoice' => null
- ], [
- 'id_delivery_note' => $idDeliveryNote
- ]);
-
- return [
- 'alert' => [
- 'type' => 'success',
- 'message' => 'Bon de livraison supprimé de la facture.'
- ]
- ];
- }
- else {
- return [
- 'alert' => [
- 'type' => 'error',
- 'message' => 'Une erreur est survenue lors de la suppression du bon de livraison.'
- ]
- ];
- }
- }
-
- public function actionAjaxAddDeliveryNote($idInvoice, $idDeliveryNote)
- {
- \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
-
- $invoice = Invoice::searchOne(['id' => $idInvoice]);
- $deliveryNote = DeliveryNote::searchOne(['id' => $idDeliveryNote]);
-
- if($invoice && $invoice->isStatusDraft() && $deliveryNote) {
- Order::updateAll([
- 'id_invoice' => $idInvoice
- ], [
- 'id_delivery_note' => $idDeliveryNote
- ]);
-
- return [
- 'alert' => [
- 'type' => 'success',
- 'message' => 'Bon de livraison ajouté à la facture.'
- ]
- ];
- }
- else {
- return [
- 'alert' => [
- 'type' => 'error',
- 'message' => 'Une erreur est survenue lors de l\'ajout du bon de livraison.'
- ]
- ];
- }
- }
-
- }
|