Commit 0716cf79dd7b705128d0e899a2abbdd6f3a56ac4
1 parent
51e6872d
fixed testing issues Details, Crosses ex...
Showing
24 changed files
with
282 additions
and
125 deletions
Show diff stats
1 | +<?php | |
2 | +namespace backend\components; | |
3 | +use common\models\Fields; | |
4 | +use yii\base\Widget; | |
5 | + | |
6 | + | |
7 | +class FieldEditor extends Widget | |
8 | +{ | |
9 | + public $item_id; | |
10 | + public $model; | |
11 | + public $template; | |
12 | + | |
13 | + public function init(){ | |
14 | + | |
15 | + parent::init(); | |
16 | + | |
17 | + } | |
18 | + | |
19 | + | |
20 | + public function run() | |
21 | + { | |
22 | + if($this->item_id && $this->model){ | |
23 | + $widgetData = $this->findModel(); | |
24 | + } else { | |
25 | + $widgetData= [new Fields()]; | |
26 | + } | |
27 | + | |
28 | + | |
29 | + return $this->render($this->template.'_field',['model'=>$widgetData]); | |
30 | + } | |
31 | + | |
32 | + protected function findModel() | |
33 | + { | |
34 | + if (($model = Fields::find()->where(['table_id'=>$this->item_id, 'table_name'=>$this->model, 'field_type'=>$this->template])->all()) !== null) { | |
35 | + | |
36 | + return $model; | |
37 | + | |
38 | + } else { | |
39 | + return [new Fields()]; | |
40 | + } | |
41 | + } | |
42 | +} | |
0 | 43 | \ No newline at end of file | ... | ... |
backend/components/FieldEditor/views/phone_field.php
0 → 100644
1 | +<?php | |
2 | +use yii\helpers\Html; | |
3 | +?> | |
4 | +<div class="fields_result"> | |
5 | +<?php $i=0; foreach ($model as $field):?> | |
6 | + <?= Html::beginTag('div',['class'=>'form-group'])?> | |
7 | + <input type="text" class="form-control" value="<?= $field->value ?>" name="Fields[phone][<?=$i++?>][value]" /> | |
8 | + <span data-id="<?= $field->id ?>" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span> | |
9 | + <?= Html::endTag('div')?> | |
10 | +<?php endforeach; ?> | |
11 | +</div> | |
12 | +<p class="btn btn-success add_field">Добавить поле</p> | |
13 | + | |
14 | + | |
15 | +<script> | |
16 | + $( document ).ready(function(){ | |
17 | + var start_i = <?=$i?>; | |
18 | + $('.add_field').click(function(){ | |
19 | + var block = $('.fields_result'); | |
20 | + var sub_block = '<div class="form-group">'+ | |
21 | + '<input type="text" class="form-control" value="" name="Fields[phone]['+ start_i++ +'][value]">'+ | |
22 | + '<span data-id="none" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>'+ | |
23 | + '<div>'; | |
24 | + block.append(sub_block); | |
25 | + | |
26 | + }); | |
27 | + }); | |
28 | +</script> | |
0 | 29 | \ No newline at end of file | ... | ... |
backend/components/FieldEditor/views/price_field.php
0 → 100644
1 | +<?php | |
2 | +use yii\helpers\Html; | |
3 | +?> | |
4 | +<div class="price_fields_result"> | |
5 | + <?php $i=0; foreach ($model as $field):?> | |
6 | + <?= Html::beginTag('div',['class'=>'form-group'])?> | |
7 | + <input type="text" placeholder="Описание" class="form-control" value="<?= $field->field_name ?>" name="Fields[price][<?=$i?>][description]" /> | |
8 | + <input type="text" placeholder="Цена" class="form-control" value="<?= $field->value ?>" name="Fields[price][<?=$i++?>][value]" /> | |
9 | + <span data-id="<?= $field->id ?>" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span> | |
10 | + <?= Html::endTag('div')?> | |
11 | + <?php endforeach; ?> | |
12 | +</div> | |
13 | +<p class="btn btn-success add_price_field">Добавить поле</p> | |
14 | + | |
15 | + | |
16 | +<script> | |
17 | + $( document ).ready(function(){ | |
18 | + var start_i = <?=$i?>; | |
19 | + $('.add_price_field').click(function(){ | |
20 | + var block = $('.price_fields_result'); | |
21 | + var sub_block = '<div class="form-group">'+ | |
22 | + '<input type="text" placeholder="Описание" class="form-control" value="" name="Fields[price]['+ start_i +'][description]">'+ | |
23 | + '<input type="text" placeholder="Цена" class="form-control" value="" name="Fields[price]['+ start_i++ +'][value]">'+ | |
24 | + '<span data-id="none" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>'+ | |
25 | + '<div>'; | |
26 | + block.append(sub_block); | |
27 | + | |
28 | + }); | |
29 | + }); | |
30 | +</script> | |
0 | 31 | \ No newline at end of file | ... | ... |
backend/components/FieldEditor/views/video_field.php
0 → 100644
1 | +<?php | |
2 | +use yii\helpers\Html; | |
3 | +?> | |
4 | +<div class="fields_video_result"> | |
5 | + <?php $i=0; foreach ($model as $field):?> | |
6 | + <?= Html::beginTag('div',['class'=>'form-group'])?> | |
7 | + <input type="text" class="form-control" value="<?= $field->value ?>" name="Fields[video][<?=$i++?>][value]" /> | |
8 | + <span data-id="<?= $field->id ?>" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span> | |
9 | + <?= Html::endTag('div')?> | |
10 | + <?php endforeach; ?> | |
11 | +</div> | |
12 | +<p class="btn btn-success add_video_field">Добавить поле</p> | |
13 | + | |
14 | + | |
15 | +<script> | |
16 | + $( document ).ready(function(){ | |
17 | + var start_i = <?=$i?>; | |
18 | + $('.add_video_field').click(function(){ | |
19 | + var block = $('.fields_video_result'); | |
20 | + var sub_block = '<div class="form-group">'+ | |
21 | + '<input type="text" class="form-control" value="" name="Fields[video]['+ start_i++ +'][value]">'+ | |
22 | + '<span data-id="none" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>'+ | |
23 | + '<div>'; | |
24 | + block.append(sub_block); | |
25 | + | |
26 | + }); | |
27 | + }); | |
28 | +</script> | |
0 | 29 | \ No newline at end of file | ... | ... |
backend/components/base/BaseActiveRecord.php
... | ... | @@ -13,9 +13,12 @@ use yii\base\ErrorException; |
13 | 13 | |
14 | 14 | class BaseActiveRecord extends \yii\db\ActiveRecord { |
15 | 15 | |
16 | - public function throwStringErrorException(){ | |
16 | + public function throwStringErrorException($row = 0){ | |
17 | 17 | |
18 | 18 | $errors_str = ''; |
19 | + if ($row != 0) { | |
20 | + $errors_str = "Ошибка в строке {$row} "; | |
21 | + } | |
19 | 22 | foreach ($this->getErrors() as $error) { |
20 | 23 | $errors_str .= implode( array_values($error) ); |
21 | 24 | } | ... | ... |
backend/controllers/BrandsController.php
... | ... | @@ -14,6 +14,8 @@ use yii\filters\VerbFilter; |
14 | 14 | */ |
15 | 15 | class BrandsController extends Controller |
16 | 16 | { |
17 | + public $layout = "/column"; | |
18 | + | |
17 | 19 | public function behaviors() |
18 | 20 | { |
19 | 21 | return [ |
... | ... | @@ -63,7 +65,8 @@ class BrandsController extends Controller |
63 | 65 | $model = new Brands(); |
64 | 66 | |
65 | 67 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
66 | - return $this->redirect(['view', 'id' => $model->BRAND]); | |
68 | + //return $this->redirect(['view', 'id' => $model->BRAND]); | |
69 | + return $this->redirect(['index']); | |
67 | 70 | } else { |
68 | 71 | return $this->render('create', [ |
69 | 72 | 'model' => $model, |
... | ... | @@ -82,7 +85,8 @@ class BrandsController extends Controller |
82 | 85 | $model = $this->findModel($id); |
83 | 86 | |
84 | 87 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
85 | - return $this->redirect(['view', 'id' => $model->BRAND]); | |
88 | + //return $this->redirect(['view', 'id' => $model->BRAND]); | |
89 | + return $this->redirect(['index']); | |
86 | 90 | } else { |
87 | 91 | return $this->render('update', [ |
88 | 92 | 'model' => $model, | ... | ... |
backend/controllers/BrandsReplaceController.php
... | ... | @@ -66,7 +66,8 @@ class BrandsReplaceController extends Controller |
66 | 66 | $model = new BrandsReplace(); |
67 | 67 | |
68 | 68 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
69 | - return $this->redirect(['view', 'from_brand' => $model->from_brand, 'to_brand' => $model->to_brand]); | |
69 | + //return $this->redirect(['view', 'from_brand' => $model->from_brand, 'to_brand' => $model->to_brand]); | |
70 | + return $this->redirect(['index']); | |
70 | 71 | } else { |
71 | 72 | return $this->render('create', [ |
72 | 73 | 'model' => $model, |
... | ... | @@ -86,7 +87,8 @@ class BrandsReplaceController extends Controller |
86 | 87 | $model = $this->findModel($from_brand, $to_brand); |
87 | 88 | |
88 | 89 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
89 | - return $this->redirect(['view', 'from_brand' => $model->from_brand, 'to_brand' => $model->to_brand]); | |
90 | + //return $this->redirect(['view', 'from_brand' => $model->from_brand, 'to_brand' => $model->to_brand]); | |
91 | + return $this->redirect(['index']); | |
90 | 92 | } else { |
91 | 93 | return $this->render('update', [ |
92 | 94 | 'model' => $model, | ... | ... |
backend/controllers/CurrencyController.php
... | ... | @@ -64,7 +64,8 @@ class CurrencyController extends Controller |
64 | 64 | $model = new Currency(); |
65 | 65 | |
66 | 66 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
67 | - return $this->redirect(['view', 'id' => $model->id]); | |
67 | + // return $this->redirect(['view', 'id' => $model->id]); | |
68 | + return $this->redirect(['index']); | |
68 | 69 | } else { |
69 | 70 | return $this->render('create', [ |
70 | 71 | 'model' => $model, |
... | ... | @@ -83,7 +84,8 @@ class CurrencyController extends Controller |
83 | 84 | $model = $this->findModel($id); |
84 | 85 | |
85 | 86 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
86 | - return $this->redirect(['view', 'id' => $model->id]); | |
87 | + //return $this->redirect(['view', 'id' => $model->id]); | |
88 | + return $this->redirect(['index']); | |
87 | 89 | } else { |
88 | 90 | return $this->render('update', [ |
89 | 91 | 'model' => $model, | ... | ... |
backend/controllers/DetailsController.php
backend/controllers/ManufacturersController.php
... | ... | @@ -65,7 +65,8 @@ class ManufacturersController extends Controller |
65 | 65 | $model = new Manufacturers(); |
66 | 66 | |
67 | 67 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
68 | - return $this->redirect(['view', 'id' => $model->MFA_ID]); | |
68 | + // return $this->redirect(['view', 'id' => $model->MFA_ID]); | |
69 | + return $this->redirect(['index']); | |
69 | 70 | } else { |
70 | 71 | return $this->render('create', [ |
71 | 72 | 'model' => $model, |
... | ... | @@ -84,7 +85,8 @@ class ManufacturersController extends Controller |
84 | 85 | $model = $this->findModel($id); |
85 | 86 | |
86 | 87 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
87 | - return $this->redirect(['view', 'id' => $model->MFA_ID]); | |
88 | + // return $this->redirect(['view', 'id' => $model->MFA_ID]); | |
89 | + return $this->redirect(['index']); | |
88 | 90 | } else { |
89 | 91 | return $this->render('update', [ |
90 | 92 | 'model' => $model, | ... | ... |
backend/controllers/MarginsController.php
... | ... | @@ -65,7 +65,8 @@ class MarginsController extends Controller |
65 | 65 | $model = new Margins(); |
66 | 66 | |
67 | 67 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
68 | - return $this->redirect(['view', 'id' => $model->id]); | |
68 | + // return $this->redirect(['view', 'id' => $model->id]); | |
69 | + return $this->redirect(['index']); | |
69 | 70 | } else { |
70 | 71 | return $this->render('create', [ |
71 | 72 | 'model' => $model, |
... | ... | @@ -84,7 +85,8 @@ class MarginsController extends Controller |
84 | 85 | $model = $this->findModel($id); |
85 | 86 | |
86 | 87 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
87 | - return $this->redirect(['view', 'id' => $model->id]); | |
88 | + //return $this->redirect(['view', 'id' => $model->id]); | |
89 | + return $this->redirect(['index']); | |
88 | 90 | } else { |
89 | 91 | return $this->render('update', [ |
90 | 92 | 'model' => $model, | ... | ... |
backend/views/brands/index.php
... | ... | @@ -7,7 +7,7 @@ use yii\grid\GridView; |
7 | 7 | /* @var $searchModel common\models\BrandsSearch */ |
8 | 8 | /* @var $dataProvider yii\data\ActiveDataProvider */ |
9 | 9 | |
10 | -$this->title = 'Brands'; | |
10 | +$this->title = 'Бренды'; | |
11 | 11 | $this->params['breadcrumbs'][] = $this->title; |
12 | 12 | ?> |
13 | 13 | <div class="brands-index"> |
... | ... | @@ -16,7 +16,7 @@ $this->params['breadcrumbs'][] = $this->title; |
16 | 16 | <?php // echo $this->render('_search', ['model' => $searchModel]); ?> |
17 | 17 | |
18 | 18 | <p> |
19 | - <?= Html::a('Create Brands', ['create'], ['class' => 'btn btn-success']) ?> | |
19 | + <?= Html::a('Создать', ['create'], ['class' => 'btn btn-success']) ?> | |
20 | 20 | </p> |
21 | 21 | |
22 | 22 | <?= GridView::widget([ | ... | ... |
backend/views/details-crosses/index.php
... | ... | @@ -7,7 +7,7 @@ use yii\grid\GridView; |
7 | 7 | /* @var $searchModel common\models\DetailsCrossesSearch */ |
8 | 8 | /* @var $dataProvider yii\data\ActiveDataProvider */ |
9 | 9 | |
10 | -$this->title = 'Details Crosses'; | |
10 | +$this->title = 'Кроссы'; | |
11 | 11 | $this->params['breadcrumbs'][] = $this->title; |
12 | 12 | ?> |
13 | 13 | <div class="details-crosses-index"> |
... | ... | @@ -16,7 +16,7 @@ $this->params['breadcrumbs'][] = $this->title; |
16 | 16 | <?php // echo $this->render('_search', ['model' => $searchModel]); ?> |
17 | 17 | |
18 | 18 | <p> |
19 | - <?= Html::a('Create Details Crosses', ['create'], ['class' => 'btn btn-success']) ?> | |
19 | + <?= Html::a('Создать', ['create'], ['class' => 'btn btn-success']) ?> | |
20 | 20 | </p> |
21 | 21 | |
22 | 22 | <?= GridView::widget([ |
... | ... | @@ -24,13 +24,11 @@ $this->params['breadcrumbs'][] = $this->title; |
24 | 24 | 'filterModel' => $searchModel, |
25 | 25 | 'columns' => [ |
26 | 26 | ['class' => 'yii\grid\SerialColumn'], |
27 | - | |
28 | - 'ID', | |
29 | 27 | 'ARTICLE', |
30 | 28 | 'BRAND', |
31 | - 'CROSS_BRAND', | |
32 | 29 | 'CROSS_ARTICLE', |
33 | - // 'timestamp', | |
30 | + 'CROSS_BRAND', | |
31 | + 'timestamp', | |
34 | 32 | |
35 | 33 | ['class' => 'yii\grid\ActionColumn'], |
36 | 34 | ], | ... | ... |
backend/views/details/index.php
... | ... | @@ -7,7 +7,7 @@ use yii\grid\GridView; |
7 | 7 | /* @var $searchModel common\models\DetailsSearch */ |
8 | 8 | /* @var $dataProvider yii\data\ActiveDataProvider */ |
9 | 9 | |
10 | -$this->title = 'Details'; | |
10 | +$this->title = 'Список запчастей'; | |
11 | 11 | $this->params['breadcrumbs'][] = $this->title; |
12 | 12 | ?> |
13 | 13 | <div class="details-index"> |
... | ... | @@ -16,7 +16,7 @@ $this->params['breadcrumbs'][] = $this->title; |
16 | 16 | <?php // echo $this->render('_search', ['model' => $searchModel]); ?> |
17 | 17 | |
18 | 18 | <p> |
19 | - <?= Html::a('Create Details', ['create'], ['class' => 'btn btn-success']) ?> | |
19 | + <?= Html::a('Создать', ['create'], ['class' => 'btn btn-success']) ?> | |
20 | 20 | </p> |
21 | 21 | |
22 | 22 | <?= GridView::widget([ |
... | ... | @@ -25,17 +25,14 @@ $this->params['breadcrumbs'][] = $this->title; |
25 | 25 | 'layout'=>"{pager}\n{items}", |
26 | 26 | 'columns' => [ |
27 | 27 | ['class' => 'yii\grid\SerialColumn'], |
28 | - | |
29 | - 'ID', | |
30 | - 'IMPORT_ID', | |
31 | - 'BRAND', | |
32 | 28 | 'ARTICLE', |
33 | - 'FULL_ARTICLE', | |
34 | - // 'PRICE', | |
35 | - // 'DESCR', | |
36 | - // 'BOX', | |
37 | - // 'ADD_BOX', | |
38 | - // 'GROUP', | |
29 | + 'BRAND', | |
30 | + 'IMPORT_ID', | |
31 | + 'DESCR', | |
32 | + 'BOX', | |
33 | + 'ADD_BOX', | |
34 | + 'PRICE', | |
35 | + 'GROUP', | |
39 | 36 | // 'timestamp', |
40 | 37 | |
41 | 38 | ['class' => 'yii\grid\ActionColumn'], | ... | ... |
backend/views/layouts/column.php
... | ... | @@ -314,8 +314,8 @@ $this->beginContent('@app/views/layouts/main.php'); |
314 | 314 | ['label' => 'Карточки товаров', 'url' => ['#']], |
315 | 315 | ['label' => 'Товары поставщиков', 'url' => ['details/index']], |
316 | 316 | ['label' => 'Кроссы', 'url' => ['details-crosses/index']], |
317 | - ['label' => 'Бренды', 'url' => ['currency/index']], | |
318 | - ['label' => 'Марки авто', 'url' => ['currency/index']], | |
317 | + ['label' => 'Бренды', 'url' => ['brands/index']], | |
318 | + ['label' => 'Марки авто', 'url' => ['manufacturers/index']], | |
319 | 319 | ['label' => 'Статусы заказов', 'url' => ['currency/index']], |
320 | 320 | ['label' => 'Типы доставок', 'url' => ['currency/index']], |
321 | 321 | ['label' => 'Категории товаров', 'url' => ['currency/index']], | ... | ... |
backend/views/manufacturers/_search.php
... | ... | @@ -17,23 +17,11 @@ use yii\widgets\ActiveForm; |
17 | 17 | |
18 | 18 | <?= $form->field($model, 'MFA_ID') ?> |
19 | 19 | |
20 | - <?= $form->field($model, 'MFA_PC_MFC') ?> | |
21 | - | |
22 | - <?= $form->field($model, 'MFA_CV_MFC') ?> | |
23 | - | |
24 | - <?= $form->field($model, 'MFA_AXL_MFC') ?> | |
25 | - | |
26 | - <?= $form->field($model, 'MFA_ENG_MFC') ?> | |
27 | - | |
28 | - <?php // echo $form->field($model, 'MFA_ENG_TYP') ?> | |
29 | - | |
30 | - <?php // echo $form->field($model, 'MFA_MFC_CODE') ?> | |
31 | - | |
32 | - <?php // echo $form->field($model, 'MFA_BRAND') ?> | |
20 | + <?php echo $form->field($model, 'MFA_BRAND') ?> | |
33 | 21 | |
34 | 22 | <?php // echo $form->field($model, 'MFA_MF_NR') ?> |
35 | 23 | |
36 | - <?php // echo $form->field($model, 'MY_SORT') ?> | |
24 | + <?php echo $form->field($model, 'MY_SORT') ?> | |
37 | 25 | |
38 | 26 | <?php // echo $form->field($model, 'MY_ACTIVE') ?> |
39 | 27 | |
... | ... | @@ -53,7 +41,7 @@ use yii\widgets\ActiveForm; |
53 | 41 | |
54 | 42 | <?php // echo $form->field($model, 'h1') ?> |
55 | 43 | |
56 | - <?php // echo $form->field($model, 'original_url') ?> | |
44 | + <?php echo $form->field($model, 'original_url') ?> | |
57 | 45 | |
58 | 46 | <div class="form-group"> |
59 | 47 | <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?> | ... | ... |
backend/views/manufacturers/index.php
... | ... | @@ -7,7 +7,7 @@ use yii\grid\GridView; |
7 | 7 | /* @var $searchModel common\models\ManufacturersSearch */ |
8 | 8 | /* @var $dataProvider yii\data\ActiveDataProvider */ |
9 | 9 | |
10 | -$this->title = 'Manufacturers'; | |
10 | +$this->title = 'Марки авто'; | |
11 | 11 | $this->params['breadcrumbs'][] = $this->title; |
12 | 12 | ?> |
13 | 13 | <div class="manufacturers-index"> |
... | ... | @@ -16,7 +16,7 @@ $this->params['breadcrumbs'][] = $this->title; |
16 | 16 | <?php // echo $this->render('_search', ['model' => $searchModel]); ?> |
17 | 17 | |
18 | 18 | <p> |
19 | - <?= Html::a('Create Manufacturers', ['create'], ['class' => 'btn btn-success']) ?> | |
19 | + <?= Html::a('Создать', ['create'], ['class' => 'btn btn-success']) ?> | |
20 | 20 | </p> |
21 | 21 | |
22 | 22 | <?= GridView::widget([ |
... | ... | @@ -26,16 +26,13 @@ $this->params['breadcrumbs'][] = $this->title; |
26 | 26 | ['class' => 'yii\grid\SerialColumn'], |
27 | 27 | |
28 | 28 | 'MFA_ID', |
29 | - 'MFA_PC_MFC', | |
30 | - 'MFA_CV_MFC', | |
31 | - 'MFA_AXL_MFC', | |
32 | - 'MFA_ENG_MFC', | |
29 | + | |
33 | 30 | // 'MFA_ENG_TYP', |
34 | 31 | // 'MFA_MFC_CODE', |
35 | - // 'MFA_BRAND', | |
32 | + 'MFA_BRAND', | |
36 | 33 | // 'MFA_MF_NR', |
37 | - // 'MY_SORT', | |
38 | - // 'MY_ACTIVE', | |
34 | + 'MY_SORT', | |
35 | + 'MY_ACTIVE', | |
39 | 36 | // 'MY_IMG', |
40 | 37 | // 'MY_DEFAULT', |
41 | 38 | // 'name', |
... | ... | @@ -44,7 +41,7 @@ $this->params['breadcrumbs'][] = $this->title; |
44 | 41 | // 'kwords', |
45 | 42 | // 'descr', |
46 | 43 | // 'h1', |
47 | - // 'original_url:url', | |
44 | + 'original_url:url', | |
48 | 45 | |
49 | 46 | ['class' => 'yii\grid\ActionColumn'], |
50 | 47 | ], | ... | ... |
common/components/PriceWriter.php
... | ... | @@ -61,18 +61,24 @@ class PriceWriter |
61 | 61 | if ($this->mode == 0) { |
62 | 62 | // преобразуем числовые значения |
63 | 63 | foreach ($this->data as &$row) { |
64 | + if(isset( $row['PRICE'] )) | |
65 | + $row['PRICE'] = \Yii::$app->converter->convertTo('float',$row['PRICE']); | |
64 | 66 | |
65 | - $row['PRICE'] = \Yii::$app->converter->convertTo('float',$row['PRICE']); | |
66 | - $row['BOX'] = \Yii::$app->converter->convertTo('integer',$row['BOX']); | |
67 | + if(isset( $row['BOX'] )) | |
68 | + $row['BOX'] = \Yii::$app->converter->convertTo('integer',$row['BOX']); | |
67 | 69 | // присвоим полный артикул |
68 | 70 | |
69 | - $row['FULL_ARTICLE'] = $row['ARTICLE']; | |
70 | - if ((int)$this->configuration['delete_prefix']) { | |
71 | - $row = \Yii::$app->converter->convertTo( 'Article', $row, ['importer_id' => $this->configuration['importer_id']] ); | |
72 | - } else { | |
73 | - $row['ARTICLE'] = \Yii::$app->converter->convertTo( 'Article', $row['ARTICLE'] ); | |
74 | - } | |
71 | + if( isset( $row['ARTICLE'] ) ) { | |
72 | + | |
73 | + $row['FULL_ARTICLE'] = $row['ARTICLE']; | |
75 | 74 | |
75 | + if ((int)$this->configuration['delete_prefix']) { | |
76 | + $row = \Yii::$app->converter->convertTo('Article', $row, ['importer_id' => $this->configuration['importer_id']]); | |
77 | + } else { | |
78 | + if (isset($row['ARTICLE'])) | |
79 | + $row['ARTICLE'] = \Yii::$app->converter->convertTo('Article', $row['ARTICLE']); | |
80 | + } | |
81 | + } | |
76 | 82 | |
77 | 83 | if (isset($row['ADD_BOX'])) |
78 | 84 | $row['ADD_BOX'] = \Yii::$app->converter->convertTo( 'integer', $row['ADD_BOX'] ); |
... | ... | @@ -80,8 +86,7 @@ class PriceWriter |
80 | 86 | // проверим все ли обязательные колонки были указаны пользователем |
81 | 87 | $details_model->load(['Details' => $row]); |
82 | 88 | if (!$details_model->validate()) |
83 | - //@todo предоставить более детальную информацию об ошибке | |
84 | - throw new \ErrorException('Ошибка записи товаров'); | |
89 | + $details_model->throwStringErrorException( key($this->data) ); | |
85 | 90 | |
86 | 91 | } |
87 | 92 | } |
... | ... | @@ -89,16 +94,17 @@ class PriceWriter |
89 | 94 | // дополним данные значением импортера и даты обновления цены |
90 | 95 | $this->data = CustomArrayHelper::addColumns( $this->data, ['IMPORT_ID' => $this->configuration['importer_id'], 'timestamp' => $update_date] ); |
91 | 96 | try { |
92 | - //@todo add transaction | |
93 | 97 | |
94 | 98 | if ( isset($this->configuration['delete_price']) && (int)$this->configuration['delete_price'] ) { |
95 | 99 | $details_model->delete_price = true; |
96 | 100 | } |
101 | + $transaction = \Yii::$app->db->beginTransaction(); | |
97 | 102 | //2. попытаемся вставить данные в БД с апдейтом по ключам |
98 | 103 | $details_model->ManualInsert($this->data, $this->configuration['importer_id']); |
99 | 104 | |
100 | 105 | // 3. зафиксируем дату конца загрузки в файлах поставщика |
101 | 106 | if (!$files_model->save()) { |
107 | + $transaction->rollBack(); | |
102 | 108 | throw new \ErrorException(implode(', ', $files_model->getErrors())); |
103 | 109 | } |
104 | 110 | |
... | ... | @@ -107,9 +113,13 @@ class PriceWriter |
107 | 113 | $imp_model->price_date_update = $update_date; |
108 | 114 | |
109 | 115 | if (!$imp_model->save()) { |
116 | + $transaction->rollBack(); | |
110 | 117 | throw new \ErrorException(implode(', ', $imp_model->getErrors())); |
111 | 118 | } |
119 | + $transaction->commit(); | |
120 | + | |
112 | 121 | } catch (ErrorException $e) { |
122 | + $transaction->rollBack(); | |
113 | 123 | throw new \ErrorException($e->getMessage()); |
114 | 124 | } |
115 | 125 | ... | ... |
common/models/Details.php
... | ... | @@ -52,15 +52,15 @@ class Details extends \yii\db\ActiveRecord |
52 | 52 | { |
53 | 53 | return [ |
54 | 54 | 'ID' => 'ID', |
55 | - 'IMPORT_ID' => 'Import ID', | |
56 | - 'BRAND' => 'Brand', | |
57 | - 'ARTICLE' => 'Article', | |
58 | - 'FULL_ARTICLE' => 'Full Article', | |
59 | - 'PRICE' => 'Price', | |
60 | - 'DESCR' => 'Descr', | |
61 | - 'BOX' => 'Box', | |
62 | - 'ADD_BOX' => 'Add Box', | |
63 | - 'GROUP' => 'Group', | |
55 | + 'IMPORT_ID' => 'ПОСТАВЩИК', | |
56 | + 'BRAND' => 'БРЕНД', | |
57 | + 'ARTICLE' => 'АРТИКУЛ', | |
58 | + 'FULL_ARTICLE' => 'ПОЛНЫЙ АРТИКУЛ', | |
59 | + 'PRICE' => 'ЦЕНА', | |
60 | + 'DESCR' => 'ОПИСАНИЕ', | |
61 | + 'BOX' => 'НАЛИЧИЕ', | |
62 | + 'ADD_BOX' => 'В ПУТИ', | |
63 | + 'GROUP' => 'ГРУППА RG', | |
64 | 64 | 'timestamp' => 'Timestamp', |
65 | 65 | ]; |
66 | 66 | } | ... | ... |
common/models/DetailsCrosses.php
... | ... | @@ -43,11 +43,11 @@ class DetailsCrosses extends \yii\db\ActiveRecord |
43 | 43 | { |
44 | 44 | return [ |
45 | 45 | 'ID' => 'ID', |
46 | - 'ARTICLE' => 'Article', | |
47 | - 'BRAND' => 'Brand', | |
48 | - 'CROSS_BRAND' => 'Cross Brand', | |
49 | - 'CROSS_ARTICLE' => 'Cross Article', | |
50 | - 'timestamp' => 'Timestamp', | |
46 | + 'ARTICLE' => 'АРТИКУЛ', | |
47 | + 'BRAND' => 'БРЕНД', | |
48 | + 'CROSS_ARTICLE' => 'КРОСС БРЕНД', | |
49 | + 'CROSS_BRAND' => 'КРОСС АРТИКУЛ', | |
50 | + 'timestamp' => 'ВРЕМЯ ДОБАВЛЕНИЯ', | |
51 | 51 | ]; |
52 | 52 | } |
53 | 53 | } | ... | ... |
common/models/DetailsCrossesSearch.php
... | ... | @@ -18,8 +18,7 @@ class DetailsCrossesSearch extends DetailsCrosses |
18 | 18 | public function rules() |
19 | 19 | { |
20 | 20 | return [ |
21 | - [['ID'], 'integer'], | |
22 | - [['ARTICLE', 'BRAND', 'CROSS_BRAND', 'CROSS_ARTICLE', 'timestamp'], 'safe'], | |
21 | + [['ARTICLE', 'BRAND', 'CROSS_BRAND', 'CROSS_ARTICLE'], 'safe'], | |
23 | 22 | ]; |
24 | 23 | } |
25 | 24 | |
... | ... | @@ -43,27 +42,41 @@ class DetailsCrossesSearch extends DetailsCrosses |
43 | 42 | { |
44 | 43 | $query = DetailsCrosses::find(); |
45 | 44 | |
46 | - $dataProvider = new ActiveDataProvider([ | |
47 | - 'query' => $query, | |
48 | - ]); | |
45 | + $pagination = [ | |
46 | + 'pageSize' => 20, | |
47 | + ]; | |
49 | 48 | |
49 | + // удалим пустые параметры | |
50 | + if ( is_array( $params['DetailsCrossesSearch'] )) { | |
51 | + $params['DetailsCrossesSearch'] = array_filter( $params['DetailsCrossesSearch'], function($val){ | |
52 | + return $val !=""; | |
53 | + }); | |
54 | + } | |
50 | 55 | $this->load($params); |
51 | 56 | |
52 | - if (!$this->validate()) { | |
53 | - // uncomment the following line if you do not want to return any records when validation fails | |
54 | - // $query->where('0=1'); | |
55 | - return $dataProvider; | |
57 | + if ( !$this->validate() ) { | |
58 | + $query->where('0=1'); | |
59 | + } | |
60 | + | |
61 | + if ( !$params || !$params['DetailsCrossesSearch'] ) { | |
62 | + // если не переданы параметры - показываем первые 100 записей | |
63 | + $pagination = false; | |
64 | + $query->limit = 100; | |
65 | + | |
56 | 66 | } |
57 | 67 | |
58 | 68 | $query->andFilterWhere([ |
59 | - 'ID' => $this->ID, | |
60 | - 'timestamp' => $this->timestamp, | |
69 | + 'ARTICLE' => $this->ARTICLE, | |
70 | + 'BRAND' => $this->BRAND, | |
71 | + 'CROSS_BRAND' => $this->CROSS_BRAND, | |
72 | + 'CROSS_ARTICLE' => $this->CROSS_ARTICLE, | |
61 | 73 | ]); |
62 | 74 | |
63 | - $query->andFilterWhere(['like', 'ARTICLE', $this->ARTICLE]) | |
64 | - ->andFilterWhere(['like', 'BRAND', $this->BRAND]) | |
65 | - ->andFilterWhere(['like', 'CROSS_BRAND', $this->CROSS_BRAND]) | |
66 | - ->andFilterWhere(['like', 'CROSS_ARTICLE', $this->CROSS_ARTICLE]); | |
75 | + | |
76 | + $dataProvider = new ActiveDataProvider([ | |
77 | + 'query' => $query, | |
78 | + 'pagination' => $pagination, | |
79 | + ]); | |
67 | 80 | |
68 | 81 | return $dataProvider; |
69 | 82 | } | ... | ... |
common/models/DetailsSearch.php
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | |
3 | 3 | namespace common\models; |
4 | 4 | |
5 | +use common\components\CustomVarDamp; | |
5 | 6 | use Yii; |
6 | 7 | use yii\base\Model; |
7 | 8 | use yii\data\ActiveDataProvider; |
... | ... | @@ -18,9 +19,8 @@ class DetailsSearch extends Details |
18 | 19 | public function rules() |
19 | 20 | { |
20 | 21 | return [ |
21 | - [['ID', 'IMPORT_ID', 'BOX', 'ADD_BOX'], 'integer'], | |
22 | - [['BRAND', 'ARTICLE', 'FULL_ARTICLE', 'DESCR', 'GROUP', 'timestamp'], 'safe'], | |
23 | - [['PRICE'], 'number'], | |
22 | + [['IMPORT_ID'], 'integer'], | |
23 | + [['BRAND', 'ARTICLE'], 'safe'], | |
24 | 24 | ]; |
25 | 25 | } |
26 | 26 | |
... | ... | @@ -44,32 +44,41 @@ class DetailsSearch extends Details |
44 | 44 | { |
45 | 45 | $query = Details::find(); |
46 | 46 | |
47 | - $dataProvider = new ActiveDataProvider([ | |
48 | - 'query' => $query, | |
49 | - ]); | |
47 | + $pagination = [ | |
48 | + 'pageSize' => 20, | |
49 | + ]; | |
50 | + | |
51 | + // удалим пустые параметры | |
52 | + if ( isset( $params['DetailsSearch'] ) && is_array( $params['DetailsSearch'] )) { | |
53 | + $params['DetailsSearch'] = array_filter( $params['DetailsSearch'], function($val){ | |
54 | + return $val !=""; | |
55 | + }); | |
56 | + } | |
50 | 57 | |
51 | 58 | $this->load($params); |
52 | 59 | |
53 | - if (!$this->validate()) { | |
54 | - // uncomment the following line if you do not want to return any records when validation fails | |
55 | - // $query->where('0=1'); | |
56 | - return $dataProvider; | |
60 | + if ( !$this->validate() ) { | |
61 | + $query->where('0=1'); | |
62 | + } | |
63 | + | |
64 | + if ( !$params || !$params['DetailsSearch'] ) { | |
65 | + // если не переданы параметры - показываем первые 100 записей | |
66 | + $pagination = false; | |
67 | + $query->limit = 100; | |
68 | + | |
57 | 69 | } |
58 | 70 | |
59 | 71 | $query->andFilterWhere([ |
60 | - 'ID' => $this->ID, | |
61 | 72 | 'IMPORT_ID' => $this->IMPORT_ID, |
62 | - 'PRICE' => $this->PRICE, | |
63 | - 'BOX' => $this->BOX, | |
64 | - 'ADD_BOX' => $this->ADD_BOX, | |
65 | - 'timestamp' => $this->timestamp, | |
73 | + 'ARTICLE' => $this->ARTICLE, | |
74 | + 'BRAND' => $this->BRAND, | |
66 | 75 | ]); |
67 | 76 | |
68 | - $query->andFilterWhere(['like', 'BRAND', $this->BRAND]) | |
69 | - ->andFilterWhere(['like', 'ARTICLE', $this->ARTICLE]) | |
70 | - ->andFilterWhere(['like', 'FULL_ARTICLE', $this->FULL_ARTICLE]) | |
71 | - ->andFilterWhere(['like', 'DESCR', $this->DESCR]) | |
72 | - ->andFilterWhere(['like', 'GROUP', $this->GROUP]); | |
77 | + | |
78 | + $dataProvider = new ActiveDataProvider([ | |
79 | + 'query' => $query, | |
80 | + 'pagination' => $pagination, | |
81 | + ]); | |
73 | 82 | |
74 | 83 | return $dataProvider; |
75 | 84 | } | ... | ... |
common/models/Manufacturers.php
... | ... | @@ -60,17 +60,17 @@ class Manufacturers extends \yii\db\ActiveRecord |
60 | 60 | public function attributeLabels() |
61 | 61 | { |
62 | 62 | return [ |
63 | - 'MFA_ID' => 'Mfa ID', | |
63 | + 'MFA_ID' => 'ID', | |
64 | 64 | 'MFA_PC_MFC' => 'Mfa Pc Mfc', |
65 | 65 | 'MFA_CV_MFC' => 'Mfa Cv Mfc', |
66 | 66 | 'MFA_AXL_MFC' => 'Mfa Axl Mfc', |
67 | 67 | 'MFA_ENG_MFC' => 'Mfa Eng Mfc', |
68 | 68 | 'MFA_ENG_TYP' => 'Mfa Eng Typ', |
69 | 69 | 'MFA_MFC_CODE' => 'Mfa Mfc Code', |
70 | - 'MFA_BRAND' => 'Mfa Brand', | |
70 | + 'MFA_BRAND' => 'Название', | |
71 | 71 | 'MFA_MF_NR' => 'Mfa Mf Nr', |
72 | - 'MY_SORT' => 'My Sort', | |
73 | - 'MY_ACTIVE' => 'My Active', | |
72 | + 'MY_SORT' => 'Сортировка', | |
73 | + 'MY_ACTIVE' => 'Выводить', | |
74 | 74 | 'MY_IMG' => 'My Img', |
75 | 75 | 'MY_DEFAULT' => 'My Default', |
76 | 76 | 'name' => 'Name', |
... | ... | @@ -79,7 +79,7 @@ class Manufacturers extends \yii\db\ActiveRecord |
79 | 79 | 'kwords' => 'Kwords', |
80 | 80 | 'descr' => 'Descr', |
81 | 81 | 'h1' => 'H1', |
82 | - 'original_url' => 'Original Url', | |
82 | + 'original_url' => 'Ссылка на оригинальный каталог', | |
83 | 83 | ]; |
84 | 84 | } |
85 | 85 | } | ... | ... |
common/models/ManufacturersSearch.php
... | ... | @@ -18,7 +18,7 @@ class ManufacturersSearch extends Manufacturers |
18 | 18 | public function rules() |
19 | 19 | { |
20 | 20 | return [ |
21 | - [['MFA_ID', 'MFA_PC_MFC', 'MFA_CV_MFC', 'MFA_AXL_MFC', 'MFA_ENG_MFC', 'MFA_ENG_TYP', 'MFA_MF_NR', 'MY_SORT', 'MY_ACTIVE', 'MY_DEFAULT'], 'integer'], | |
21 | + [['MFA_ID', 'MFA_PC_MFC', 'MFA_CV_MFC', 'MFA_AXL_MFC', 'MFA_ENG_MFC', 'MFA_ENG_TYP', 'MFA_MF_NR', 'MY_SORT', 'MY_DEFAULT'], 'integer'], | |
22 | 22 | [['MFA_MFC_CODE', 'MFA_BRAND', 'MY_IMG', 'name', 'content', 'title', 'kwords', 'descr', 'h1', 'original_url'], 'safe'], |
23 | 23 | ]; |
24 | 24 | } |
... | ... | @@ -64,7 +64,7 @@ class ManufacturersSearch extends Manufacturers |
64 | 64 | 'MFA_ENG_TYP' => $this->MFA_ENG_TYP, |
65 | 65 | 'MFA_MF_NR' => $this->MFA_MF_NR, |
66 | 66 | 'MY_SORT' => $this->MY_SORT, |
67 | - 'MY_ACTIVE' => $this->MY_ACTIVE, | |
67 | + 'MY_ACTIVE' => isset( $this->MY_ACTIVE ) ? $this->MY_ACTIVE : 1, | |
68 | 68 | 'MY_DEFAULT' => $this->MY_DEFAULT, |
69 | 69 | ]); |
70 | 70 | ... | ... |