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; $invoiceManager = $this->getInvoiceManager(); $invoice = $invoiceManager->findOneInvoiceById($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; $invoiceManager = $this->getInvoiceManager(); $deliveryNoteManager = $this->getDeliveryNoteManager(); $invoice = $invoiceManager->findOneInvoiceById($idInvoice); $deliveryNote = $deliveryNoteManager->findOneDeliveryNoteById($idDeliveryNote); if ($invoice && $invoiceManager->isStatusDraft($invoice) && $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.' ] ]; } } }