diff --git a/backend/controllers/DetailsDescriptionController.php b/backend/controllers/DetailsDescriptionController.php index ecc6ad6..2a271f1 100644 --- a/backend/controllers/DetailsDescriptionController.php +++ b/backend/controllers/DetailsDescriptionController.php @@ -85,6 +85,24 @@ class DetailsDescriptionController extends BaseController } + public function actionDeleteCriteria() + { + + $params = Yii::$app->request->get(); + $criteria_model = $this->findCriteriaModel( $params ); + + if ( $criteria_model->delete() ) { + + return $this->redirect(['view', 'name' => $params['name'], 'brand' => $params['brand']]); + + } else { + + throw new HttpException('Не удалось удалить характеристики из базы данных'); + + } + + } + /** * Finds the DetailsDescription model based on its primary key value. @@ -103,5 +121,19 @@ class DetailsDescriptionController extends BaseController } } + protected function findCriteriaModel( $params ) + { + if ( isset($params['name']) + && isset($params['brand']) + && isset($params['key']) + && ($model = DetailsCriteria::findOne(['name' => $params['name'], 'brand' => $params['brand'], 'key' => $params['key']])) !== null ) { + + return $model; + + } else { + throw new NotFoundHttpException('Запрашиваемая характеристика не существует.'); + } + } + } diff --git a/backend/views/check-price/index.php b/backend/views/check-price/index.php index 376d420..33fadb1 100755 --- a/backend/views/check-price/index.php +++ b/backend/views/check-price/index.php @@ -86,14 +86,6 @@ Pjax::begin(['id' => 'gridViewContent']); }, ], ], -// ['content' => function ($model) { -// $url = Url::to(['delete', 'id' => $model->id, 'update_date' => $model->price_date_update]); -// return Html::a(' ', $url, [ -// 'class' => 'deletePriceButton', -// 'value' => $url, -// ]); -// }, -// ], ] ]); ?> diff --git a/backend/views/details-description/view.php b/backend/views/details-description/view.php index f09270d..19c3c37 100644 --- a/backend/views/details-description/view.php +++ b/backend/views/details-description/view.php @@ -2,8 +2,9 @@ use yii\helpers\Html; use yii\widgets\DetailView; -use yii\widgets\ActiveForm; +use yii\bootstrap\ActiveForm; use yii\grid\GridView; +use yii\widgets\Pjax; /* @var $this yii\web\View */ @@ -23,47 +24,75 @@ $this->params['breadcrumbs'][] = $this->title; 'attributes' => [ 'name', 'brand', - 'tecdoc_id', - 'tecdoc_article', +// 'tecdoc_id', +// 'tecdoc_article', 'description', - 'tecdoc_description', - 'supplier_description', - 'article', - 'image', +// 'tecdoc_description', +// 'supplier_description', +// 'article', +// 'image', 'tecdoc_image', - 'category_id', + // 'category_id', ], ]) ?> $dataProvider, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - 'key', - 'value', - ['class' => 'yii\grid\ActionColumn', - 'template' => '{delete}'], - ], - ]); ?> + 'dataProvider' => $dataProvider, + 'showHeader' => false, + 'showOnEmpty' => false, + 'columns' => [ + 'key', + 'value', + ['class' => \yii\grid\ActionColumn::className(), + 'template'=>'{delete}', + 'buttons' => [ + 'delete' => function ($url, $model, $key) { + $url = \yii\helpers\Url::to(['details-description/delete-criteria', 'name' => $model->name, 'brand' => $model->brand, 'key' => $model->key]); + return Html::a('', $url, [ + 'title' => Yii::t('yii', 'Удалить характеристики'), + 'data-confirm' => 'Вы уверены что хотите удалить эти характеристики?', + 'data-method' => 'post', + 'data-pjax' => '1', + ]); + }, + ], + ], + ], + ]); + Pjax::end(); + } + + ?>