瀏覽代碼

[backend] Suppression documents : amélioration script suppression

refactoring
Guillaume Bourgeois 4 年之前
父節點
當前提交
7a17960c9e
共有 1 個文件被更改,包括 23 次插入5 次删除
  1. +23
    -5
      backend/controllers/DocumentController.php

+ 23
- 5
backend/controllers/DocumentController.php 查看文件

@@ -154,11 +154,29 @@ class DocumentController extends BackendController

$model->delete();

Order::updateAll([
'order.id_delivery_note' => null
], [
'order.id_delivery_note' => $id
]);
if($this->getClass() == 'DeliveryNote') {
Order::updateAll([
'order.id_delivery_note' => null
], [
'order.id_delivery_note' => $id
]);
}

if($this->getClass() == 'Quotation') {
Order::updateAll([
'order.id_quotation' => null
], [
'order.id_quotation' => $id
]);
}

if($this->getClass() == 'Invoice') {
Order::updateAll([
'order.id_invoice' => null
], [
'order.id_invoice' => $id
]);
}

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

Loading…
取消
儲存