|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
-
-
-
- namespace backend\controllers;
-
- use common\helpers\Ajax;
- use domain\Document\Invoice\InvoiceSearch;
-
- 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)
- {
- $orderModule = $this->getOrderModule();
- $invoiceModule = $this-> getInvoiceModule();
- $deliveryNoteModule = $this->getDeliveryNoteModule();
- $invoice = $invoiceModule->findOneInvoiceById($idInvoice);
- $deliveryNote = $deliveryNoteModule->findOneDeliveryNoteById($idDeliveryNote);
-
- if ($invoice && $invoiceModule->isStatusDraft($invoice) && $deliveryNote) {
- $orderModule->unassignAllOrdersInvoiceByDeliveryNote($deliveryNote);
- return Ajax::responseSuccess('Bon de livraison supprimé de la facture.');
- } else {
- return Ajax::responseError('Une erreur est survenue lors de la suppression du bon de livraison.');
- }
- }
-
- public function actionAjaxAddDeliveryNote($idInvoice, $idDeliveryNote)
- {
- $orderModule = $this->getOrderModule();
- $invoiceModule = $this-> getInvoiceModule();
- $deliveryNoteModule = $this->getDeliveryNoteModule();
-
- $invoice = $invoiceModule->findOneInvoiceById($idInvoice);
- $deliveryNote = $deliveryNoteModule->findOneDeliveryNoteById($idDeliveryNote);
-
- if ($invoice && $invoiceModule->isStatusDraft($invoice) && $deliveryNote) {
- $orderModule->assignAllOrdersInvoiceByDeliveryNote($invoice, $deliveryNote);
- return Ajax::responseSuccess("Bon de livraison ajouté à la facture.");
- } else {
- return Ajax::responseError("Une erreur est survenue lors de l'ajout du bon de livraison.");
- }
- }
- }
|