From 3b7211a02fa8f629c84fc246e0a7e170595e69aa Mon Sep 17 00:00:00 2001 From: Mihail Date: Tue, 22 Sep 2015 18:22:47 +0300 Subject: [PATCH] change query for check price view and action --- backend/components/parsers/CustomCsvParser.php | 2 +- backend/controllers/ParserController.php | 8 +++++--- backend/models/Importer.php | 2 +- backend/views/parser/checkPrice.php | 10 ++++++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/backend/components/parsers/CustomCsvParser.php b/backend/components/parsers/CustomCsvParser.php index dd28725..407b20a 100644 --- a/backend/components/parsers/CustomCsvParser.php +++ b/backend/components/parsers/CustomCsvParser.php @@ -11,7 +11,7 @@ namespace backend\components\parsers; class CustomCsvParser extends \yii\multiparser\CsvParser { - public $last_line = 10; + //public $last_line = 10; //public $hasHeaderRow = true; // public $keys = ['first','second', 'third', 'forth', 'fifth']; public function setupConverter() diff --git a/backend/controllers/ParserController.php b/backend/controllers/ParserController.php index 631c16e..5b058cb 100644 --- a/backend/controllers/ParserController.php +++ b/backend/controllers/ParserController.php @@ -178,14 +178,15 @@ class ParserController extends BaseController // попытаемся вставить данные в БД с апдейтом по ключам $details_model->save($data); - // 3. зафиксируем дату конца загрузки в файлах поставщика + // 3. зафиксируем дату начала и конца загрузки в файлах поставщика (для ручной загрузки начало приравниваем time_start и update_date) + $files_model->time_start = $update_date; $files_model->time_end = date('Y-m-d H:i:s'); // CustomVarDamp::dumpAndDie($files_model); $files_model->save(); // 4. зафиксируем дату загрузки в таблице поставщиков $imp_model = Importer::findOne( $configuration['importer_id'] ); - $imp_model->price_date_update = ''.strtotime($update_date); + $imp_model->price_date_update = $update_date; if (!$imp_model->save()) { CustomVarDamp::dumpAndDie( $imp_model->getErrors() ); @@ -220,7 +221,8 @@ class ParserController extends BaseController public function actionCheck_price () { - $query = (new Query())->select('*')->from('{{%importer_files}}')->where(['not', ['time_end' => null]])->orderBy(['upload_time' => SORT_DESC]); + //$query = (new Query())->select('*')->from('{{%importer_files}}')->where(['not', ['time_end' => null]])->orderBy(['upload_time' => SORT_DESC]); + $query = Importer::find()->where(['active' => true])->orderBy(['price_date_update' => SORT_DESC]); $provider = new ActiveDataProvider([ 'query' => $query, diff --git a/backend/models/Importer.php b/backend/models/Importer.php index 8a51373..8c06694 100644 --- a/backend/models/Importer.php +++ b/backend/models/Importer.php @@ -54,7 +54,7 @@ class Importer extends BaseActiveRecord [['PARSER_FIELD_MULTIPLIER'], 'number'], [['code', 'name', 'name_price', 'delivery', 'email'], 'string', 'max' => 254], [['PARSER_FIELD_SIGN'], 'string', 'max' => 1], - [['price_date_update'], 'string', 'max' => 15], + // [['price_date_update'], 'string', 'max' => 15], [['code'], 'unique'], [['name'], 'unique'] ]; diff --git a/backend/views/parser/checkPrice.php b/backend/views/parser/checkPrice.php index 46069d8..719ee82 100644 --- a/backend/views/parser/checkPrice.php +++ b/backend/views/parser/checkPrice.php @@ -18,7 +18,13 @@ $this->params['breadcrumbs'][] = $this->title; $dataProvider, 'columns' => [['class' => SerialColumn::className()], - 'importer_id', - 'upload_time' ]] );?> + [ + 'label' =>'Поставщик', + 'value' => function ($data) { + return '№ ' . $data->id . $data->name; + }, + ], + ['label' =>'Дата обновления', + 'attribute' => 'price_date_update' ]]] );?> \ No newline at end of file -- libgit2 0.21.4