From f5e08febc10e4100a242ca49354b5ccd962425fa Mon Sep 17 00:00:00 2001 From: marina Date: Mon, 26 Aug 2024 15:18:01 +0300 Subject: [PATCH] =?utf8?q?ERP-85=20=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7?= =?utf8?q?=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BE=D0=B1=D0=BC=D0=B5=D0=BD?= =?utf8?q?=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D1=81=201=D0=A1=20?= =?utf8?q?=D0=91=D1=83=D1=85=D0=B3=D0=B0=D0=BB=D1=82=D0=B5=D1=80=D0=B8?= =?utf8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/ApiController.php | 18 ++++++++++++++++++ erp24/views/api/store-guid-buh.php | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/erp24/controllers/ApiController.php b/erp24/controllers/ApiController.php index ab8d0481..66b4c62d 100644 --- a/erp24/controllers/ApiController.php +++ b/erp24/controllers/ApiController.php @@ -2,6 +2,7 @@ namespace app\controllers; +use yii\db\StaleObjectException; use yii_app\records\AdminGroup; use yii_app\records\StoreGuidBuh; use kartik\select2\Select2; @@ -455,4 +456,21 @@ class ApiController extends Controller 'model' => $model ]); } + + /** + * @throws \Throwable + * @throws StaleObjectException + */ + public function actionDeleteStoreGuidBuh($id) + { + try { + if ($model = StoreGuidBuh::findOne($id)) { + $model->delete(); + } + }catch (\Exception $e) { + throw new \Exception($e); + } + + $this->redirect(Yii::$app->request->referrer); + } } \ No newline at end of file diff --git a/erp24/views/api/store-guid-buh.php b/erp24/views/api/store-guid-buh.php index 56b6038b..333c639b 100644 --- a/erp24/views/api/store-guid-buh.php +++ b/erp24/views/api/store-guid-buh.php @@ -1,8 +1,10 @@ params['breadcrumbs'][] = $this->title; return date('d-m-Y H:i:s', strtotime($model->updated_at)); } ], + [ + 'class' => 'yii\grid\ActionColumn', + 'template' => '{delete}', + 'buttons' => [ + 'delete' => function ($url, $model, $key) { + return Html::a( + '', + Url::to(['delete-store-guid-buh', 'id' => $model->id]), + [ + 'title' => 'Удалить', + 'data' => [ + 'confirm' => 'Вы уверены, что хотите удалить этот элемент?', + 'method' => 'post', + ], + ] + ); + }, + ], + ], ], ]); ?> -- 2.39.5