Commit 54aa20c312045aa7ca44b71d895264df6f372ad6
1 parent
56f74596
change query for check price view and action
Showing
4 changed files
with
15 additions
and
7 deletions
Show diff stats
backend/components/parsers/CustomCsvParser.php
@@ -11,7 +11,7 @@ namespace backend\components\parsers; | @@ -11,7 +11,7 @@ namespace backend\components\parsers; | ||
11 | 11 | ||
12 | class CustomCsvParser extends \yii\multiparser\CsvParser { | 12 | class CustomCsvParser extends \yii\multiparser\CsvParser { |
13 | 13 | ||
14 | - public $last_line = 10; | 14 | + //public $last_line = 10; |
15 | //public $hasHeaderRow = true; | 15 | //public $hasHeaderRow = true; |
16 | // public $keys = ['first','second', 'third', 'forth', 'fifth']; | 16 | // public $keys = ['first','second', 'third', 'forth', 'fifth']; |
17 | public function setupConverter() | 17 | public function setupConverter() |
backend/controllers/ParserController.php
@@ -178,14 +178,15 @@ class ParserController extends BaseController | @@ -178,14 +178,15 @@ class ParserController extends BaseController | ||
178 | // попытаемся вставить данные в БД с апдейтом по ключам | 178 | // попытаемся вставить данные в БД с апдейтом по ключам |
179 | $details_model->save($data); | 179 | $details_model->save($data); |
180 | 180 | ||
181 | - // 3. зафиксируем дату конца загрузки в файлах поставщика | 181 | + // 3. зафиксируем дату начала и конца загрузки в файлах поставщика (для ручной загрузки начало приравниваем time_start и update_date) |
182 | + $files_model->time_start = $update_date; | ||
182 | $files_model->time_end = date('Y-m-d H:i:s'); | 183 | $files_model->time_end = date('Y-m-d H:i:s'); |
183 | // CustomVarDamp::dumpAndDie($files_model); | 184 | // CustomVarDamp::dumpAndDie($files_model); |
184 | $files_model->save(); | 185 | $files_model->save(); |
185 | 186 | ||
186 | // 4. зафиксируем дату загрузки в таблице поставщиков | 187 | // 4. зафиксируем дату загрузки в таблице поставщиков |
187 | $imp_model = Importer::findOne( $configuration['importer_id'] ); | 188 | $imp_model = Importer::findOne( $configuration['importer_id'] ); |
188 | - $imp_model->price_date_update = ''.strtotime($update_date); | 189 | + $imp_model->price_date_update = $update_date; |
189 | 190 | ||
190 | if (!$imp_model->save()) { | 191 | if (!$imp_model->save()) { |
191 | CustomVarDamp::dumpAndDie( $imp_model->getErrors() ); | 192 | CustomVarDamp::dumpAndDie( $imp_model->getErrors() ); |
@@ -220,7 +221,8 @@ class ParserController extends BaseController | @@ -220,7 +221,8 @@ class ParserController extends BaseController | ||
220 | 221 | ||
221 | public function actionCheck_price () | 222 | public function actionCheck_price () |
222 | { | 223 | { |
223 | - $query = (new Query())->select('*')->from('{{%importer_files}}')->where(['not', ['time_end' => null]])->orderBy(['upload_time' => SORT_DESC]); | 224 | + //$query = (new Query())->select('*')->from('{{%importer_files}}')->where(['not', ['time_end' => null]])->orderBy(['upload_time' => SORT_DESC]); |
225 | + $query = Importer::find()->where(['active' => true])->orderBy(['price_date_update' => SORT_DESC]); | ||
224 | 226 | ||
225 | $provider = new ActiveDataProvider([ | 227 | $provider = new ActiveDataProvider([ |
226 | 'query' => $query, | 228 | 'query' => $query, |
backend/models/Importer.php
@@ -54,7 +54,7 @@ class Importer extends BaseActiveRecord | @@ -54,7 +54,7 @@ class Importer extends BaseActiveRecord | ||
54 | [['PARSER_FIELD_MULTIPLIER'], 'number'], | 54 | [['PARSER_FIELD_MULTIPLIER'], 'number'], |
55 | [['code', 'name', 'name_price', 'delivery', 'email'], 'string', 'max' => 254], | 55 | [['code', 'name', 'name_price', 'delivery', 'email'], 'string', 'max' => 254], |
56 | [['PARSER_FIELD_SIGN'], 'string', 'max' => 1], | 56 | [['PARSER_FIELD_SIGN'], 'string', 'max' => 1], |
57 | - [['price_date_update'], 'string', 'max' => 15], | 57 | + // [['price_date_update'], 'string', 'max' => 15], |
58 | [['code'], 'unique'], | 58 | [['code'], 'unique'], |
59 | [['name'], 'unique'] | 59 | [['name'], 'unique'] |
60 | ]; | 60 | ]; |
backend/views/parser/checkPrice.php
@@ -18,7 +18,13 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -18,7 +18,13 @@ $this->params['breadcrumbs'][] = $this->title; | ||
18 | 18 | ||
19 | <?= GridView::widget( ['dataProvider' => $dataProvider, | 19 | <?= GridView::widget( ['dataProvider' => $dataProvider, |
20 | 'columns' => [['class' => SerialColumn::className()], | 20 | 'columns' => [['class' => SerialColumn::className()], |
21 | - 'importer_id', | ||
22 | - 'upload_time' ]] );?> | 21 | + [ |
22 | + 'label' =>'Поставщик', | ||
23 | + 'value' => function ($data) { | ||
24 | + return '№ ' . $data->id . $data->name; | ||
25 | + }, | ||
26 | + ], | ||
27 | + ['label' =>'Дата обновления', | ||
28 | + 'attribute' => 'price_date_update' ]]] );?> | ||
23 | 29 | ||
24 | </div> | 30 | </div> |
25 | \ No newline at end of file | 31 | \ No newline at end of file |