Commit 3b7211a02fa8f629c84fc246e0a7e170595e69aa
1 parent
dd6fce49
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 | 11 | |
12 | 12 | class CustomCsvParser extends \yii\multiparser\CsvParser { |
13 | 13 | |
14 | - public $last_line = 10; | |
14 | + //public $last_line = 10; | |
15 | 15 | //public $hasHeaderRow = true; |
16 | 16 | // public $keys = ['first','second', 'third', 'forth', 'fifth']; |
17 | 17 | public function setupConverter() | ... | ... |
backend/controllers/ParserController.php
... | ... | @@ -178,14 +178,15 @@ class ParserController extends BaseController |
178 | 178 | // попытаемся вставить данные в БД с апдейтом по ключам |
179 | 179 | $details_model->save($data); |
180 | 180 | |
181 | - // 3. зафиксируем дату конца загрузки в файлах поставщика | |
181 | + // 3. зафиксируем дату начала и конца загрузки в файлах поставщика (для ручной загрузки начало приравниваем time_start и update_date) | |
182 | + $files_model->time_start = $update_date; | |
182 | 183 | $files_model->time_end = date('Y-m-d H:i:s'); |
183 | 184 | // CustomVarDamp::dumpAndDie($files_model); |
184 | 185 | $files_model->save(); |
185 | 186 | |
186 | 187 | // 4. зафиксируем дату загрузки в таблице поставщиков |
187 | 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 | 191 | if (!$imp_model->save()) { |
191 | 192 | CustomVarDamp::dumpAndDie( $imp_model->getErrors() ); |
... | ... | @@ -220,7 +221,8 @@ class ParserController extends BaseController |
220 | 221 | |
221 | 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 | 227 | $provider = new ActiveDataProvider([ |
226 | 228 | 'query' => $query, | ... | ... |
backend/models/Importer.php
... | ... | @@ -54,7 +54,7 @@ class Importer extends BaseActiveRecord |
54 | 54 | [['PARSER_FIELD_MULTIPLIER'], 'number'], |
55 | 55 | [['code', 'name', 'name_price', 'delivery', 'email'], 'string', 'max' => 254], |
56 | 56 | [['PARSER_FIELD_SIGN'], 'string', 'max' => 1], |
57 | - [['price_date_update'], 'string', 'max' => 15], | |
57 | + // [['price_date_update'], 'string', 'max' => 15], | |
58 | 58 | [['code'], 'unique'], |
59 | 59 | [['name'], 'unique'] |
60 | 60 | ]; | ... | ... |
backend/views/parser/checkPrice.php
... | ... | @@ -18,7 +18,13 @@ $this->params['breadcrumbs'][] = $this->title; |
18 | 18 | |
19 | 19 | <?= GridView::widget( ['dataProvider' => $dataProvider, |
20 | 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 | 30 | </div> |
25 | 31 | \ No newline at end of file | ... | ... |