From 4044fc300ab1d8991d7ca5dfbb476628863d738f Mon Sep 17 00:00:00 2001 From: Mihail Date: Tue, 17 Nov 2015 14:09:24 +0200 Subject: [PATCH] add details criteria form - create and delete --- backend/controllers/DetailsDescriptionController.php | 32 ++++++++++++++++++++++++++++++++ backend/views/check-price/index.php | 8 -------- backend/views/details-description/view.php | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++--------------------- backend/views/layouts/column.php | 3 +++ common/models/DetailsCriteria.php | 4 ++-- common/models/DetailsDescription.php | 8 ++++---- 6 files changed, 91 insertions(+), 35 deletions(-) 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(); + } + + ?>
['details-description/create-criteria'],]); ?> - field( $criteria_model, 'key' )->textInput(['maxlength' => true]) ?> + field( $criteria_model, 'key', [ + 'horizontalCssClasses' => [ + 'input' => 'col-sm-1', + ]] )->textInput() ?> - field( $criteria_model, 'value' )->textInput(['maxlength' => true]) ?> + field( $criteria_model, 'value', [ + 'horizontalCssClasses' => [ + 'input' => 'col-sm-1', + ]] )->textInput() ?> field( $criteria_model, 'name' )->hiddenInput(['value' => $model->name])->label(false)?> field( $criteria_model, 'brand' )->hiddenInput(['value' => $model->brand])->label(false) ?>
- 'btn btn-success']) ?> + 'btn btn-success']) ?>
+
+ diff --git a/backend/views/layouts/column.php b/backend/views/layouts/column.php index 8b48818..bf69e6e 100755 --- a/backend/views/layouts/column.php +++ b/backend/views/layouts/column.php @@ -286,6 +286,7 @@ $this->beginContent('@app/views/layouts/main.php'); ['label' => "Загрузка файлов", 'url' => ['#'], 'items' => [ ['label' => 'Кросс файлы', 'url' => ['crossing-upload/index']], ['label' => 'Группы RG', 'url' => ['rg-grup/index']], + ['label' => "Прайс файлы", 'url' => ['#'], 'items' => [ ['label' => 'Файлы на сервере', 'url' => ['parser/server-files']], ['label' => 'Загрузить файл на сервер', 'url' => ['parser/index', 'mode' => 1]], ['label' => 'Ручная загрузка', 'url' => ['parser/index']], @@ -293,6 +294,8 @@ $this->beginContent('@app/views/layouts/main.php'); ['label' => 'Управление префиксами', 'url' => ['importers-prefix/index']], ], ], + ], + ], ['label' => 'Управление ролями', 'url' => ['#'], 'items' => [ ['label' => 'Покупатели', 'url' => ['accounts/index']], ['label' => 'Поставщики', 'url' => ['importers/index']], diff --git a/common/models/DetailsCriteria.php b/common/models/DetailsCriteria.php index 3eed639..5bca13c 100644 --- a/common/models/DetailsCriteria.php +++ b/common/models/DetailsCriteria.php @@ -48,8 +48,8 @@ class DetailsCriteria extends \backend\components\base\BaseActiveRecord return [ 'name' => Yii::t('app', 'Name'), 'brand' => Yii::t('app', 'Brand'), - 'key' => Yii::t('app', 'Key'), - 'value' => Yii::t('app', 'Value'), + 'key' => Yii::t('app', 'Ключ'), + 'value' => Yii::t('app', 'Характеристика'), 'if_tecdoc' => Yii::t('app', 'If Tecdoc'), 'filter_id' => Yii::t('app', 'Filter ID'), 'timestamp' => Yii::t('app', 'Timestamp'), diff --git a/common/models/DetailsDescription.php b/common/models/DetailsDescription.php index b74ae67..ea86985 100644 --- a/common/models/DetailsDescription.php +++ b/common/models/DetailsDescription.php @@ -59,12 +59,12 @@ class DetailsDescription extends \backend\components\base\BaseActiveRecord 'brand' => Yii::t('app', 'Бренд'), 'tecdoc_id' => Yii::t('app', 'Tecdoc ID'), 'tecdoc_article' => Yii::t('app', 'Артикул Текдока'), - 'description' => Yii::t('app', 'Description'), + 'description' => Yii::t('app', 'Главное наименование'), 'tecdoc_description' => Yii::t('app', 'Tecdoc Description'), - 'supplier_description' => Yii::t('app', 'Supplier Description'), + 'supplier_description' => Yii::t('app', 'Наименование поставщика'), 'article' => Yii::t('app', 'Article'), - 'image' => Yii::t('app', 'Image'), - 'tecdoc_image' => Yii::t('app', 'Tecdoc Image'), + 'image' => Yii::t('app', 'Картинка сайта'), + 'tecdoc_image' => Yii::t('app', 'Картинка Текдока'), 'category_id' => Yii::t('app', 'Category ID'), 'timestamp' => Yii::t('app', 'Timestamp'), ]; -- libgit2 0.21.4