search(\Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); } public function actionAjaxDeleteDeliveryNote($idInvoice, $idDeliveryNote) { $orderManager = $this->getOrderManager(); $invoiceManager = $this->getInvoiceManager(); $deliveryNoteManager = $this->getDeliveryNoteManager(); $invoice = $invoiceManager->findOneInvoiceById($idInvoice); $deliveryNote = $deliveryNoteManager->findOneDeliveryNoteById($idDeliveryNote); if ($invoice && $invoiceManager->isStatusDraft($invoice) && $deliveryNote) { $orderManager->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) { $orderManager = $this->getOrderManager(); $invoiceManager = $this->getInvoiceManager(); $deliveryNoteManager = $this->getDeliveryNoteManager(); $invoice = $invoiceManager->findOneInvoiceById($idInvoice); $deliveryNote = $deliveryNoteManager->findOneDeliveryNoteById($idDeliveryNote); if ($invoice && $invoiceManager->isStatusDraft($invoice) && $deliveryNote) { $orderManager->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."); } } public function actionAjaxAddOrder($idInvoice, $idOrder) { $invoiceManager = $this->getInvoiceManager(); $orderManager = $this->getOrderManager(); $invoice = $invoiceManager->findOneInvoiceById($idInvoice); $order = $orderManager->findOneOrderById($idOrder); if ($invoice && $invoiceManager->isStatusDraft($invoice) && $order) { $orderManager->updateOrderInvoice($order, $invoice); return Ajax::responseSuccess("Commande ajoutée à la facture."); } else { return Ajax::responseError("Une erreur est survenue lors de l'ajout de la commande."); } } public function actionAjaxDeleteOrder($idInvoice, $idOrder) { $invoiceManager = $this->getInvoiceManager(); $orderManager = $this->getOrderManager(); $invoice = $invoiceManager->findOneInvoiceById($idInvoice); $order = $orderManager->findOneOrderById($idOrder); if ($invoice && $invoiceManager->isStatusDraft($invoice)) { $orderManager->updateOrderInvoice($order, null); return Ajax::responseSuccess('Commande supprimée de la facture.'); } else { return Ajax::responseError('Une erreur est survenue lors de la suppression de la commande.'); } } public function actionAjaxIgnoreOrderWhenInvoicing($idInvoice, $idOrder) { $invoiceManager = $this->getInvoiceManager(); $orderManager = $this->getOrderManager(); $invoice = $invoiceManager->findOneInvoiceById($idInvoice); $order = $orderManager->findOneOrderById($idOrder); if ($invoice && $invoiceManager->isStatusDraft($invoice) && $order) { $orderManager->updateOrderIgnoreWhenInvoicing($order, true); return Ajax::responseSuccess("La commande sera maintenant ignorée au moment de la facturation."); } else { return Ajax::responseError("Une erreur est survenue."); } } }