Commit 9b0a69f37f373cb1bc19d26e26f05501b2769a2a
1 parent
6ccb6e69
add details criteria form - create and delete
Showing
6 changed files
with
91 additions
and
35 deletions
Show diff stats
backend/controllers/DetailsDescriptionController.php
| @@ -85,6 +85,24 @@ class DetailsDescriptionController extends BaseController | @@ -85,6 +85,24 @@ class DetailsDescriptionController extends BaseController | ||
| 85 | 85 | ||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | + public function actionDeleteCriteria() | ||
| 89 | + { | ||
| 90 | + | ||
| 91 | + $params = Yii::$app->request->get(); | ||
| 92 | + $criteria_model = $this->findCriteriaModel( $params ); | ||
| 93 | + | ||
| 94 | + if ( $criteria_model->delete() ) { | ||
| 95 | + | ||
| 96 | + return $this->redirect(['view', 'name' => $params['name'], 'brand' => $params['brand']]); | ||
| 97 | + | ||
| 98 | + } else { | ||
| 99 | + | ||
| 100 | + throw new HttpException('Не удалось удалить характеристики из базы данных'); | ||
| 101 | + | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + } | ||
| 105 | + | ||
| 88 | 106 | ||
| 89 | /** | 107 | /** |
| 90 | * Finds the DetailsDescription model based on its primary key value. | 108 | * Finds the DetailsDescription model based on its primary key value. |
| @@ -103,5 +121,19 @@ class DetailsDescriptionController extends BaseController | @@ -103,5 +121,19 @@ class DetailsDescriptionController extends BaseController | ||
| 103 | } | 121 | } |
| 104 | } | 122 | } |
| 105 | 123 | ||
| 124 | + protected function findCriteriaModel( $params ) | ||
| 125 | + { | ||
| 126 | + if ( isset($params['name']) | ||
| 127 | + && isset($params['brand']) | ||
| 128 | + && isset($params['key']) | ||
| 129 | + && ($model = DetailsCriteria::findOne(['name' => $params['name'], 'brand' => $params['brand'], 'key' => $params['key']])) !== null ) { | ||
| 130 | + | ||
| 131 | + return $model; | ||
| 132 | + | ||
| 133 | + } else { | ||
| 134 | + throw new NotFoundHttpException('Запрашиваемая характеристика не существует.'); | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + | ||
| 106 | 138 | ||
| 107 | } | 139 | } |
backend/views/check-price/index.php
| @@ -86,14 +86,6 @@ Pjax::begin(['id' => 'gridViewContent']); | @@ -86,14 +86,6 @@ Pjax::begin(['id' => 'gridViewContent']); | ||
| 86 | }, | 86 | }, |
| 87 | ], | 87 | ], |
| 88 | ], | 88 | ], |
| 89 | -// ['content' => function ($model) { | ||
| 90 | -// $url = Url::to(['delete', 'id' => $model->id, 'update_date' => $model->price_date_update]); | ||
| 91 | -// return Html::a('<span class="glyphicon glyphicon-trash"> </span>', $url, [ | ||
| 92 | -// 'class' => 'deletePriceButton', | ||
| 93 | -// 'value' => $url, | ||
| 94 | -// ]); | ||
| 95 | -// }, | ||
| 96 | -// ], | ||
| 97 | ] | 89 | ] |
| 98 | ]); ?> | 90 | ]); ?> |
| 99 | 91 |
backend/views/details-description/view.php
| @@ -2,8 +2,9 @@ | @@ -2,8 +2,9 @@ | ||
| 2 | 2 | ||
| 3 | use yii\helpers\Html; | 3 | use yii\helpers\Html; |
| 4 | use yii\widgets\DetailView; | 4 | use yii\widgets\DetailView; |
| 5 | -use yii\widgets\ActiveForm; | 5 | +use yii\bootstrap\ActiveForm; |
| 6 | use yii\grid\GridView; | 6 | use yii\grid\GridView; |
| 7 | +use yii\widgets\Pjax; | ||
| 7 | 8 | ||
| 8 | 9 | ||
| 9 | /* @var $this yii\web\View */ | 10 | /* @var $this yii\web\View */ |
| @@ -23,47 +24,75 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -23,47 +24,75 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 23 | 'attributes' => [ | 24 | 'attributes' => [ |
| 24 | 'name', | 25 | 'name', |
| 25 | 'brand', | 26 | 'brand', |
| 26 | - 'tecdoc_id', | ||
| 27 | - 'tecdoc_article', | 27 | +// 'tecdoc_id', |
| 28 | +// 'tecdoc_article', | ||
| 28 | 'description', | 29 | 'description', |
| 29 | - 'tecdoc_description', | ||
| 30 | - 'supplier_description', | ||
| 31 | - 'article', | ||
| 32 | - 'image', | 30 | +// 'tecdoc_description', |
| 31 | +// 'supplier_description', | ||
| 32 | +// 'article', | ||
| 33 | +// 'image', | ||
| 33 | 'tecdoc_image', | 34 | 'tecdoc_image', |
| 34 | - 'category_id', | 35 | + // 'category_id', |
| 35 | ], | 36 | ], |
| 36 | ]) ?> | 37 | ]) ?> |
| 37 | 38 | ||
| 38 | <?php | 39 | <?php |
| 39 | - if($count) | 40 | + echo Html::tag('hr'); |
| 41 | + echo Html::tag('h4','Xарактеристики товара'); | ||
| 42 | + if($count){ | ||
| 43 | + Pjax::begin(); | ||
| 40 | echo GridView::widget([ | 44 | echo GridView::widget([ |
| 41 | - 'dataProvider' => $dataProvider, | ||
| 42 | - 'columns' => [ | ||
| 43 | - ['class' => 'yii\grid\SerialColumn'], | ||
| 44 | - 'key', | ||
| 45 | - 'value', | ||
| 46 | - ['class' => 'yii\grid\ActionColumn', | ||
| 47 | - 'template' => '{delete}'], | ||
| 48 | - ], | ||
| 49 | - ]); ?> | 45 | + 'dataProvider' => $dataProvider, |
| 46 | + 'showHeader' => false, | ||
| 47 | + 'showOnEmpty' => false, | ||
| 48 | + 'columns' => [ | ||
| 49 | + 'key', | ||
| 50 | + 'value', | ||
| 51 | + ['class' => \yii\grid\ActionColumn::className(), | ||
| 52 | + 'template'=>'{delete}', | ||
| 53 | + 'buttons' => [ | ||
| 54 | + 'delete' => function ($url, $model, $key) { | ||
| 55 | + $url = \yii\helpers\Url::to(['details-description/delete-criteria', 'name' => $model->name, 'brand' => $model->brand, 'key' => $model->key]); | ||
| 56 | + return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | ||
| 57 | + 'title' => Yii::t('yii', 'Удалить характеристики'), | ||
| 58 | + 'data-confirm' => 'Вы уверены что хотите удалить эти характеристики?', | ||
| 59 | + 'data-method' => 'post', | ||
| 60 | + 'data-pjax' => '1', | ||
| 61 | + ]); | ||
| 62 | + }, | ||
| 63 | + ], | ||
| 64 | + ], | ||
| 65 | + ], | ||
| 66 | + ]); | ||
| 67 | + Pjax::end(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + ?> | ||
| 50 | 71 | ||
| 51 | <div class="details-criteria-form"> | 72 | <div class="details-criteria-form"> |
| 52 | 73 | ||
| 53 | <?php $form = ActiveForm::begin(['action' =>['details-description/create-criteria'],]); ?> | 74 | <?php $form = ActiveForm::begin(['action' =>['details-description/create-criteria'],]); ?> |
| 54 | 75 | ||
| 55 | - <?= $form->field( $criteria_model, 'key' )->textInput(['maxlength' => true]) ?> | 76 | + <?= $form->field( $criteria_model, 'key', [ |
| 77 | + 'horizontalCssClasses' => [ | ||
| 78 | + 'input' => 'col-sm-1', | ||
| 79 | + ]] )->textInput() ?> | ||
| 56 | 80 | ||
| 57 | - <?= $form->field( $criteria_model, 'value' )->textInput(['maxlength' => true]) ?> | 81 | + <?= $form->field( $criteria_model, 'value', [ |
| 82 | + 'horizontalCssClasses' => [ | ||
| 83 | + 'input' => 'col-sm-1', | ||
| 84 | + ]] )->textInput() ?> | ||
| 58 | 85 | ||
| 59 | <?= $form->field( $criteria_model, 'name' )->hiddenInput(['value' => $model->name])->label(false)?> | 86 | <?= $form->field( $criteria_model, 'name' )->hiddenInput(['value' => $model->name])->label(false)?> |
| 60 | <?= $form->field( $criteria_model, 'brand' )->hiddenInput(['value' => $model->brand])->label(false) ?> | 87 | <?= $form->field( $criteria_model, 'brand' )->hiddenInput(['value' => $model->brand])->label(false) ?> |
| 61 | 88 | ||
| 62 | 89 | ||
| 63 | <div class="form-group"> | 90 | <div class="form-group"> |
| 64 | - <?= Html::submitButton(Yii::t('app', 'Добавить'), ['class' => 'btn btn-success']) ?> | 91 | + <?= Html::submitButton(Yii::t('app', 'Добавить характеристику'), ['class' => 'btn btn-success']) ?> |
| 65 | </div> | 92 | </div> |
| 66 | 93 | ||
| 67 | <?php ActiveForm::end(); ?> | 94 | <?php ActiveForm::end(); ?> |
| 68 | </div> | 95 | </div> |
| 96 | + <hr> | ||
| 97 | + | ||
| 69 | </div> | 98 | </div> |
backend/views/layouts/column.php
| @@ -286,6 +286,7 @@ $this->beginContent('@app/views/layouts/main.php'); | @@ -286,6 +286,7 @@ $this->beginContent('@app/views/layouts/main.php'); | ||
| 286 | ['label' => "Загрузка файлов", 'url' => ['#'], 'items' => [ | 286 | ['label' => "Загрузка файлов", 'url' => ['#'], 'items' => [ |
| 287 | ['label' => 'Кросс файлы', 'url' => ['crossing-upload/index']], | 287 | ['label' => 'Кросс файлы', 'url' => ['crossing-upload/index']], |
| 288 | ['label' => 'Группы RG', 'url' => ['rg-grup/index']], | 288 | ['label' => 'Группы RG', 'url' => ['rg-grup/index']], |
| 289 | + ['label' => "Прайс файлы", 'url' => ['#'], 'items' => [ | ||
| 289 | ['label' => 'Файлы на сервере', 'url' => ['parser/server-files']], | 290 | ['label' => 'Файлы на сервере', 'url' => ['parser/server-files']], |
| 290 | ['label' => 'Загрузить файл на сервер', 'url' => ['parser/index', 'mode' => 1]], | 291 | ['label' => 'Загрузить файл на сервер', 'url' => ['parser/index', 'mode' => 1]], |
| 291 | ['label' => 'Ручная загрузка', 'url' => ['parser/index']], | 292 | ['label' => 'Ручная загрузка', 'url' => ['parser/index']], |
| @@ -293,6 +294,8 @@ $this->beginContent('@app/views/layouts/main.php'); | @@ -293,6 +294,8 @@ $this->beginContent('@app/views/layouts/main.php'); | ||
| 293 | ['label' => 'Управление префиксами', 'url' => ['importers-prefix/index']], | 294 | ['label' => 'Управление префиксами', 'url' => ['importers-prefix/index']], |
| 294 | ], | 295 | ], |
| 295 | ], | 296 | ], |
| 297 | + ], | ||
| 298 | + ], | ||
| 296 | ['label' => 'Управление ролями', 'url' => ['#'], 'items' => [ | 299 | ['label' => 'Управление ролями', 'url' => ['#'], 'items' => [ |
| 297 | ['label' => 'Покупатели', 'url' => ['accounts/index']], | 300 | ['label' => 'Покупатели', 'url' => ['accounts/index']], |
| 298 | ['label' => 'Поставщики', 'url' => ['importers/index']], | 301 | ['label' => 'Поставщики', 'url' => ['importers/index']], |
common/models/DetailsCriteria.php
| @@ -48,8 +48,8 @@ class DetailsCriteria extends \backend\components\base\BaseActiveRecord | @@ -48,8 +48,8 @@ class DetailsCriteria extends \backend\components\base\BaseActiveRecord | ||
| 48 | return [ | 48 | return [ |
| 49 | 'name' => Yii::t('app', 'Name'), | 49 | 'name' => Yii::t('app', 'Name'), |
| 50 | 'brand' => Yii::t('app', 'Brand'), | 50 | 'brand' => Yii::t('app', 'Brand'), |
| 51 | - 'key' => Yii::t('app', 'Key'), | ||
| 52 | - 'value' => Yii::t('app', 'Value'), | 51 | + 'key' => Yii::t('app', 'Ключ'), |
| 52 | + 'value' => Yii::t('app', 'Характеристика'), | ||
| 53 | 'if_tecdoc' => Yii::t('app', 'If Tecdoc'), | 53 | 'if_tecdoc' => Yii::t('app', 'If Tecdoc'), |
| 54 | 'filter_id' => Yii::t('app', 'Filter ID'), | 54 | 'filter_id' => Yii::t('app', 'Filter ID'), |
| 55 | 'timestamp' => Yii::t('app', 'Timestamp'), | 55 | 'timestamp' => Yii::t('app', 'Timestamp'), |
common/models/DetailsDescription.php
| @@ -59,12 +59,12 @@ class DetailsDescription extends \backend\components\base\BaseActiveRecord | @@ -59,12 +59,12 @@ class DetailsDescription extends \backend\components\base\BaseActiveRecord | ||
| 59 | 'brand' => Yii::t('app', 'Бренд'), | 59 | 'brand' => Yii::t('app', 'Бренд'), |
| 60 | 'tecdoc_id' => Yii::t('app', 'Tecdoc ID'), | 60 | 'tecdoc_id' => Yii::t('app', 'Tecdoc ID'), |
| 61 | 'tecdoc_article' => Yii::t('app', 'Артикул Текдока'), | 61 | 'tecdoc_article' => Yii::t('app', 'Артикул Текдока'), |
| 62 | - 'description' => Yii::t('app', 'Description'), | 62 | + 'description' => Yii::t('app', 'Главное наименование'), |
| 63 | 'tecdoc_description' => Yii::t('app', 'Tecdoc Description'), | 63 | 'tecdoc_description' => Yii::t('app', 'Tecdoc Description'), |
| 64 | - 'supplier_description' => Yii::t('app', 'Supplier Description'), | 64 | + 'supplier_description' => Yii::t('app', 'Наименование поставщика'), |
| 65 | 'article' => Yii::t('app', 'Article'), | 65 | 'article' => Yii::t('app', 'Article'), |
| 66 | - 'image' => Yii::t('app', 'Image'), | ||
| 67 | - 'tecdoc_image' => Yii::t('app', 'Tecdoc Image'), | 66 | + 'image' => Yii::t('app', 'Картинка сайта'), |
| 67 | + 'tecdoc_image' => Yii::t('app', 'Картинка Текдока'), | ||
| 68 | 'category_id' => Yii::t('app', 'Category ID'), | 68 | 'category_id' => Yii::t('app', 'Category ID'), |
| 69 | 'timestamp' => Yii::t('app', 'Timestamp'), | 69 | 'timestamp' => Yii::t('app', 'Timestamp'), |
| 70 | ]; | 70 | ]; |