From 2d10c44d9ae520cce69211168e6b04aaa880f4fd Mon Sep 17 00:00:00 2001 From: Mihail Date: Fri, 2 Oct 2015 12:03:43 +0300 Subject: [PATCH] temp commit - work with console controller and log settings --- backend/controllers/ParserController.php | 2 +- common/models/User.php | 2 +- common/models/WAccounts.php | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/models/WAccountsSearch.php | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/models/WDicCities.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ console/config/main.php | 8 +++++++- console/controllers/ParserController.php | 18 ++++++++++++------ 7 files changed, 293 insertions(+), 9 deletions(-) create mode 100644 common/models/WAccounts.php create mode 100644 common/models/WAccountsSearch.php create mode 100644 common/models/WDicCities.php diff --git a/backend/controllers/ParserController.php b/backend/controllers/ParserController.php index 5b3fbf5..3af9d94 100644 --- a/backend/controllers/ParserController.php +++ b/backend/controllers/ParserController.php @@ -299,7 +299,7 @@ class ParserController extends BaseController } } else { // Yii::$app->log-> - // не дошли до конца по этому остаки вернем в кеш + // не дошли до конца по этому остатки вернем в кеш Yii::$app->cache->set( 'files_to_parse',json_encode( $arr_id_files ) ); } } diff --git a/common/models/User.php b/common/models/User.php index a23707a..ce78fcd 100644 --- a/common/models/User.php +++ b/common/models/User.php @@ -31,7 +31,7 @@ class User extends ActiveRecord implements IdentityInterface */ public static function tableName() { - return 'user'; + return '{{%user}}'; } /** diff --git a/common/models/WAccounts.php b/common/models/WAccounts.php new file mode 100644 index 0000000..7f601cf --- /dev/null +++ b/common/models/WAccounts.php @@ -0,0 +1,121 @@ + 150], + [['pass'], 'string', 'max' => 30], + [['phones', 'phones2', 'phones3'], 'string', 'max' => 50], + [['address', 'firm_inn', 'firm_bank'], 'string', 'max' => 254], + [['last_loginin'], 'string', 'max' => 15], + [['snumb', 'firm_ur_adr', 'firm_fiz_adr', 'firm_code_eg', 'firm_rs', 'firm_mfo', 'company'], 'string', 'max' => 255], + [['email'], 'unique'] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('app', 'ID'), + 'if_manager' => Yii::t('app', 'If Manager'), + 'email' => Yii::t('app', 'Email'), + 'pass' => Yii::t('app', 'Pass'), + 'margin_id' => Yii::t('app', 'Margin ID'), + 'name' => Yii::t('app', 'Name'), + 'phones' => Yii::t('app', 'Phones'), + 'country' => Yii::t('app', 'Country'), + 'city' => Yii::t('app', 'City'), + 'address' => Yii::t('app', 'Address'), + 'comment' => Yii::t('app', 'Comment'), + 'rating' => Yii::t('app', 'Rating'), + 'dt' => Yii::t('app', 'Dt'), + 'is_active' => Yii::t('app', 'Is Active'), + 'is_firm' => Yii::t('app', 'Is Firm'), + 'last_loginin' => Yii::t('app', 'Last Loginin'), + 'firm_inn' => Yii::t('app', 'Firm Inn'), + 'firm_bank' => Yii::t('app', 'Firm Bank'), + 'balance' => Yii::t('app', 'Balance'), + 'office_id' => Yii::t('app', 'Office ID'), + 'is_scribe' => Yii::t('app', 'Is Scribe'), + 'set_manager_id' => Yii::t('app', 'Set Manager ID'), + 'phones2' => Yii::t('app', 'Phones2'), + 'phones3' => Yii::t('app', 'Phones3'), + 'car' => Yii::t('app', 'Car'), + 'mod' => Yii::t('app', 'Mod'), + 'snumb' => Yii::t('app', 'Snumb'), + 'deliveries' => Yii::t('app', 'Deliveries'), + 'scode' => Yii::t('app', 'Scode'), + 'firm_ur_adr' => Yii::t('app', 'Firm Ur Adr'), + 'firm_fiz_adr' => Yii::t('app', 'Firm Fiz Adr'), + 'firm_code_eg' => Yii::t('app', 'Firm Code Eg'), + 'firm_rs' => Yii::t('app', 'Firm Rs'), + 'firm_mfo' => Yii::t('app', 'Firm Mfo'), + 'firm_site' => Yii::t('app', 'Firm Site'), + 'company' => Yii::t('app', 'Company'), + ]; + } +} diff --git a/common/models/WAccountsSearch.php b/common/models/WAccountsSearch.php new file mode 100644 index 0000000..b02eaeb --- /dev/null +++ b/common/models/WAccountsSearch.php @@ -0,0 +1,101 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'id' => $this->id, + 'if_manager' => $this->if_manager, + 'margin_id' => $this->margin_id, + 'country' => $this->country, + 'city' => $this->city, + 'rating' => $this->rating, + 'dt' => $this->dt, + 'is_active' => $this->is_active, + 'is_firm' => $this->is_firm, + 'balance' => $this->balance, + 'office_id' => $this->office_id, + 'is_scribe' => $this->is_scribe, + 'set_manager_id' => $this->set_manager_id, + 'car' => $this->car, + 'mod' => $this->mod, + 'deliveries' => $this->deliveries, + 'scode' => $this->scode, + ]); + + $query->andFilterWhere(['like', 'email', $this->email]) + ->andFilterWhere(['like', 'pass', $this->pass]) + ->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'phones', $this->phones]) + ->andFilterWhere(['like', 'address', $this->address]) + ->andFilterWhere(['like', 'comment', $this->comment]) + ->andFilterWhere(['like', 'last_loginin', $this->last_loginin]) + ->andFilterWhere(['like', 'firm_inn', $this->firm_inn]) + ->andFilterWhere(['like', 'firm_bank', $this->firm_bank]) + ->andFilterWhere(['like', 'phones2', $this->phones2]) + ->andFilterWhere(['like', 'phones3', $this->phones3]) + ->andFilterWhere(['like', 'snumb', $this->snumb]) + ->andFilterWhere(['like', 'firm_ur_adr', $this->firm_ur_adr]) + ->andFilterWhere(['like', 'firm_fiz_adr', $this->firm_fiz_adr]) + ->andFilterWhere(['like', 'firm_code_eg', $this->firm_code_eg]) + ->andFilterWhere(['like', 'firm_rs', $this->firm_rs]) + ->andFilterWhere(['like', 'firm_mfo', $this->firm_mfo]) + ->andFilterWhere(['like', 'firm_site', $this->firm_site]) + ->andFilterWhere(['like', 'company', $this->company]); + + return $dataProvider; + } +} diff --git a/common/models/WDicCities.php b/common/models/WDicCities.php new file mode 100644 index 0000000..0305efc --- /dev/null +++ b/common/models/WDicCities.php @@ -0,0 +1,50 @@ + 254], + [['parent', 'name'], 'unique', 'targetAttribute' => ['parent', 'name'], 'message' => 'The combination of Name and Parent has already been taken.'] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('app', 'ID'), + 'name' => Yii::t('app', 'Name'), + 'is_active' => Yii::t('app', 'Is Active'), + 'parent' => Yii::t('app', 'Parent'), + ]; + } +} diff --git a/console/config/main.php b/console/config/main.php index 2c7d7d4..7a67404 100644 --- a/console/config/main.php +++ b/console/config/main.php @@ -18,8 +18,14 @@ return [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], - ], + [ + 'class' => 'yii\log\FileTarget', + 'logFile' => 'C:\xampp\htdocs\ital\console\runtime\logs\parser.log', + 'levels' => ['info', 'error'], + // 'categories' => ['parser'], + ], ], ], 'params' => $params, +] ]; diff --git a/console/controllers/ParserController.php b/console/controllers/ParserController.php index 109a588..43d8f61 100644 --- a/console/controllers/ParserController.php +++ b/console/controllers/ParserController.php @@ -1,10 +1,6 @@