Commit 942bad48ab0b784cd99f500ca7a08852e4c728cd
1 parent
5beedbd0
adapt project to original DB (migrations and AR)
Showing
21 changed files
with
96 additions
and
469 deletions
Show diff stats
backend/controllers/CheckPriceController.php
... | ... | @@ -8,8 +8,8 @@ use yii\filters\AccessControl; |
8 | 8 | use backend\components\base\BaseController; |
9 | 9 | use yii\filters\VerbFilter; |
10 | 10 | use backend\models\Details; |
11 | -use backend\models\ImporterFiles; | |
12 | -use backend\models\Importer; | |
11 | +use backend\models\ImportersFiles; | |
12 | +use backend\models\Importers; | |
13 | 13 | use yii\base\ErrorException; |
14 | 14 | |
15 | 15 | use common\components\CustomVarDamp; |
... | ... | @@ -66,7 +66,7 @@ class CheckPriceController extends BaseController |
66 | 66 | } |
67 | 67 | |
68 | 68 | //$query = (new Query())->select('*')->from('{{%importer_files}}')->where(['not', ['time_end' => null]])->orderBy(['upload_time' => SORT_DESC]); |
69 | - $query = Importer::find()->where(['active' => true])->orderBy(['price_date_update' => SORT_DESC]); | |
69 | + $query = Importers::find()->where(['active' => true])->orderBy(['price_date_update' => SORT_DESC]); | |
70 | 70 | |
71 | 71 | $provider = new ActiveDataProvider([ |
72 | 72 | 'query' => $query, | ... | ... |
backend/controllers/ParserController.php
... | ... | @@ -12,8 +12,8 @@ use yii\data\ArrayDataProvider; |
12 | 12 | use yii\multiparser\DynamicFormHelper; |
13 | 13 | use backend\components\parsers\CustomParserConfigurator; |
14 | 14 | use backend\models\Details; |
15 | -use backend\models\ImporterFiles; | |
16 | -use backend\models\Importer; | |
15 | +use backend\models\ImportersFiles; | |
16 | +use backend\models\Importers; | |
17 | 17 | use yii\base\ErrorException; |
18 | 18 | use yii\db\Query; |
19 | 19 | |
... | ... | @@ -88,9 +88,9 @@ class ParserController extends BaseController |
88 | 88 | // первый проход - валидируем, сохраняем файл, ложим в кеш (для ручной загрузки) отпарсенные данные и параметры модели (потом при записи в базу данных они пригодятся) |
89 | 89 | if ($model->validate()) { |
90 | 90 | // запишем дату загрузки файла в таблицу файлов поставщика (ImportersFiles) |
91 | - $files_model = new ImporterFiles(); | |
91 | + $files_model = new ImportersFiles(); | |
92 | 92 | // id поставщика получим из конфигурации |
93 | - $files_model->load(['ImporterFiles' => $model->toArray()]); | |
93 | + $files_model->load(['ImportersFiles' => $model->toArray()]); | |
94 | 94 | try { |
95 | 95 | $files_model->save(); |
96 | 96 | } catch (ErrorException $e) { |
... | ... | @@ -194,9 +194,9 @@ class ParserController extends BaseController |
194 | 194 | |
195 | 195 | // 1. запишем дату старта в таблицу файлов поставщика (ImportersFiles) |
196 | 196 | // id загруженного файла получим из конфигурации |
197 | - $files_model = ImporterFiles::findOne( $configuration->record_id ); | |
197 | + $files_model = ImportersFiles::findOne( $configuration->record_id ); | |
198 | 198 | |
199 | - //$files_model->load(['ImporterFiles' => $configuration->toArray()]); | |
199 | + //$files_model->load(['ImportersFiles' => $configuration->toArray()]); | |
200 | 200 | $update_date = date('Y-m-d H:i:s'); |
201 | 201 | $files_model->time_start = $update_date; |
202 | 202 | // запишем дату начала загрузки |
... | ... | @@ -227,7 +227,7 @@ class ParserController extends BaseController |
227 | 227 | } |
228 | 228 | |
229 | 229 | // 4. зафиксируем дату загрузки в таблице поставщиков |
230 | - $imp_model = Importer::findOne($configuration['importer_id']); | |
230 | + $imp_model = Importers::findOne($configuration['importer_id']); | |
231 | 231 | $imp_model->price_date_update = $update_date; |
232 | 232 | |
233 | 233 | if (!$imp_model->save()) { |
... | ... | @@ -260,7 +260,7 @@ class ParserController extends BaseController |
260 | 260 | |
261 | 261 | public function actionAutoUpload() |
262 | 262 | { |
263 | - $query = Importer::find()->where(['active' => true])->orderBy(['price_date_update' => SORT_DESC]); | |
263 | + $query = Importers::find()->where(['active' => true])->orderBy(['price_date_update' => SORT_DESC]); | |
264 | 264 | |
265 | 265 | $provider = new ActiveDataProvider([ |
266 | 266 | 'query' => $query, |
... | ... | @@ -282,7 +282,7 @@ class ParserController extends BaseController |
282 | 282 | $arr_id_files[] = (int) $file_id; |
283 | 283 | } |
284 | 284 | Yii::$app->cache->set( 'files_to_delete',json_encode( $arr_id_files ) ); |
285 | - $query = ImporterFiles::find()->where(['in', 'id', $arr_id_files])->orderBy(['upload_time' => SORT_DESC]); | |
285 | + $query = ImportersFiles::find()->where(['in', 'id', $arr_id_files])->orderBy(['upload_time' => SORT_DESC]); | |
286 | 286 | |
287 | 287 | $provider = new ActiveDataProvider([ |
288 | 288 | 'query' => $query, |
... | ... | @@ -299,7 +299,7 @@ class ParserController extends BaseController |
299 | 299 | { |
300 | 300 | if ( Yii::$app->request->isAjax ) { |
301 | 301 | |
302 | - $files_model = new ImporterFiles(); | |
302 | + $files_model = new ImportersFiles(); | |
303 | 303 | if ( isset(Yii::$app->request->post()['id'] )) { |
304 | 304 | $id = Yii::$app->request->post()['id']; |
305 | 305 | try { | ... | ... |
backend/models/Details_old.php deleted
1 | -<?php | |
2 | -/** | |
3 | - * Created by PhpStorm. | |
4 | - * User: Cibermag | |
5 | - * Date: 15.09.2015 | |
6 | - * Time: 16:49 | |
7 | - */ | |
8 | - | |
9 | -namespace backend\models; | |
10 | - | |
11 | -use yii\base\Model; | |
12 | -use Yii; | |
13 | - | |
14 | -class Details_old extends Model{ | |
15 | - const KEY_COLUMN = ['IMPORT_ID','BRAND','ARTICLE']; | |
16 | - const BATCH = 500; | |
17 | - | |
18 | - private $mode; | |
19 | - | |
20 | - // обязательные поля модели | |
21 | - public $BRAND; | |
22 | - public $ARTICLE; | |
23 | - public $PRICE; | |
24 | - public $BOX; | |
25 | - | |
26 | - function __construct($mode) | |
27 | - { | |
28 | - $this->mode = $mode; | |
29 | - } | |
30 | - | |
31 | - public function rules() | |
32 | - { | |
33 | - return [ | |
34 | - [['BRAND','ARTICLE', 'PRICE', 'BOX'], 'required' ], | |
35 | - ]; | |
36 | - } | |
37 | - | |
38 | - public function formName() | |
39 | - { | |
40 | - return 'Details'; | |
41 | - } | |
42 | - | |
43 | - | |
44 | - public static function tableName() | |
45 | - { | |
46 | - return '{{%details}}'; | |
47 | - } | |
48 | - | |
49 | -// //@todo вероятно этой функции не место здесь | |
50 | -// public function prepareData ( $data, $configuration ) | |
51 | -// { | |
52 | -// if ( isset($configuration['importer_id']) && $configuration['importer_id']) { | |
53 | -// $data = \Yii::$app->multiparser->addColumn( $data, 'IMPORT_ID', $configuration['importer_id'] ); | |
54 | -// } | |
55 | -// // \common\components\CustomVarDamp::dumpAndDie($data); | |
56 | -// return $data; | |
57 | -// } | |
58 | - | |
59 | - /** | |
60 | - * @param $data - двумерный массив данных для записи в таблицу details | |
61 | - * @throws \yii\db\Exception | |
62 | - * вставляет записи с апдейтом при дубляже ключей | |
63 | - */ | |
64 | - public function save ($data) | |
65 | - { | |
66 | - $table_name = self::tableName(); | |
67 | - $keys_arr = array_keys( $data[0] ); | |
68 | - // найдем те поля которые не являются ключами. Их нужно будет при дубляже апдейтить | |
69 | - $fields_arr_to_update = array_diff( $keys_arr, $this::KEY_COLUMN ); | |
70 | - | |
71 | - $query_update = ' on duplicate key update '; | |
72 | - foreach ($fields_arr_to_update as $field) { | |
73 | - $query_update .= "{$field} = values({$field}),"; | |
74 | - } | |
75 | - // удалим последнюю запятую | |
76 | - $query_update = substr($query_update, 0, strlen($query_update) - 1); | |
77 | - | |
78 | - // запросы будем выполнять пакетами | |
79 | - // размер пакета установлен в константе | |
80 | - // разобъем массив на пакеты и будем их проходить | |
81 | - $data = array_chunk($data, $this::BATCH ); | |
82 | - foreach( $data as $current_batch_array ){ | |
83 | - | |
84 | - //воспользуемся пакетной вставкой от фреймворка, плюс сразу с экранированием и защитой от инъекций | |
85 | - $query_insert = Yii::$app->db->createCommand()->batchInsert($table_name, $keys_arr, $current_batch_array)->sql; | |
86 | - // добавим фрагмент с апдейтом при дубляже | |
87 | - $query = "{$query_insert} {$query_update}"; | |
88 | - // \common\components\CustomVarDamp::dumpAndDie($query); | |
89 | - $res = Yii::$app->db->createCommand($query)->execute(); | |
90 | - | |
91 | - } | |
92 | - | |
93 | - } | |
94 | -} | |
95 | - | |
96 | -// | |
97 | - | |
98 | -//$q = " INSERT INTO {$table_name} ({$keys_string}) VALUES ("; | |
99 | - | |
100 | -//$q .= " on duplicate key update `FULL_ARTICLE` = values (`FULL_ARTICLE`), | |
101 | -// `PRICE` = values (`PRICE`), | |
102 | -// `DESCR` = values(`DESCR`), | |
103 | -// `BOX` = values(`BOX`), | |
104 | -// `ADD_BOX` = values(`ADD_BOX`), | |
105 | -// `GROUP` = values(`GROUP`);"; | |
106 | - | |
107 | -// INSERT INTO table (a,b,c) VALUES (1,2,3),(4,5,6) | |
108 | -// ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b); | |
109 | - | |
110 | - | |
111 | - | |
112 | -//INSERT INTO `books` (`UserId`, `BookId`, `Count`) VALUES (13, 1001, 3) | |
113 | -//ON DUPLICATE KEY UPDATE `Count` = `Count` + VALUES(`Count`); | |
114 | - | |
115 | -//$values_string = ''; | |
116 | -//$keys_arr = array_keys( $data[0] ); | |
117 | -//$keys_string = implode( ',', $keys_arr); | |
118 | -//$table_name = self::tableName(); | |
119 | -//$current_batch = 0; | |
120 | -//for ($i = $current_batch; $i < $this::BATCH AND $i < count($data); $i++) { | |
121 | -// $values_string .= '(' . implode( ',', $data[$i]) . '),'; | |
122 | -//} | |
123 | -// for ($current_batch = $this::BATCH; $current_batch<count($data); $current_batch + $this::BATCH ) | |
124 | -//// удалим последнюю запятую | |
125 | -//$values_string = substr($values_string, 0, strlen($values_string) - 1) . ' '; | |
126 | -////\common\components\CustomVarDamp::dumpAndDie($values_string); | |
127 | -//// $query = "INSERT INTO {$table_name}({$keys_string}) VALUES {$values_string}"; | |
128 | -//// on duplicate key update `PRICE` = values (`PRICE`),`DESCR` = values(`DESCR`),`BOX` = values(`BOX`)"; | |
129 | -//$query_insert = Yii::$app->db->createCommand()->batchInsert($table_name, $keys_arr, $data)->sql; | |
130 | -//$query = "{$query_insert} on duplicate key update `PRICE` = values (`PRICE`),`DESCR` = values(`DESCR`),`BOX` = values(`BOX`)"; | |
131 | -//$res = Yii::$app->db->createCommand($query)->execute(); | |
132 | - | |
133 | - | |
134 | - | |
135 | -// Yii::$app->db->createCommand()->batchInsert($table_name, $keys_arr, $data)->sql execute(); | |
136 | 0 | \ No newline at end of file |
backend/models/Importer.php renamed to backend/models/Importers.php
... | ... | @@ -31,19 +31,9 @@ use backend\components\base\BaseActiveRecord; |
31 | 31 | * @property double $PARSER_FIELD_MULTIPLIER |
32 | 32 | * @property string $price_date_update |
33 | 33 | */ |
34 | -class Importer extends BaseActiveRecord | |
34 | +class Importers extends BaseActiveRecord | |
35 | 35 | { |
36 | - /** | |
37 | - * @inheritdoc | |
38 | - */ | |
39 | - public static function tableName() | |
40 | - { | |
41 | - return '{{%importer}}'; | |
42 | - } | |
43 | 36 | |
44 | - /** | |
45 | - * @inheritdoc | |
46 | - */ | |
47 | 37 | public function rules() |
48 | 38 | { |
49 | 39 | return [ | ... | ... |
backend/models/ImporterFiles.php renamed to backend/models/ImportersFiles.php
... | ... | @@ -14,19 +14,11 @@ use Yii; |
14 | 14 | * @property string $time_start |
15 | 15 | * @property string $time_end |
16 | 16 | */ |
17 | -class ImporterFiles extends \yii\db\ActiveRecord | |
17 | +class ImportersFiles extends \yii\db\ActiveRecord | |
18 | 18 | { |
19 | 19 | /** |
20 | 20 | * @inheritdoc |
21 | 21 | */ |
22 | - public static function tableName() | |
23 | - { | |
24 | - return '{{%importer_files}}'; | |
25 | - } | |
26 | - | |
27 | - /** | |
28 | - * @inheritdoc | |
29 | - */ | |
30 | 22 | public function rules() |
31 | 23 | { |
32 | 24 | return [ |
... | ... | @@ -38,7 +30,7 @@ class ImporterFiles extends \yii\db\ActiveRecord |
38 | 30 | |
39 | 31 | public function getImporter () |
40 | 32 | { |
41 | - return $this->hasOne(Importer::className(), ['id' => 'importer_id'])->one()->name; | |
33 | + return $this->hasOne(Importers::className(), ['id' => 'importer_id'])->one()->name; | |
42 | 34 | } |
43 | 35 | |
44 | 36 | /** |
... | ... | @@ -48,10 +40,10 @@ class ImporterFiles extends \yii\db\ActiveRecord |
48 | 40 | { |
49 | 41 | return [ |
50 | 42 | 'id' => Yii::t('app', 'ID'), |
51 | - 'importer_id' => Yii::t('app', 'Importer ID'), | |
43 | + 'importer_id' => Yii::t('app', 'Importers ID'), | |
52 | 44 | 'upload_time' => Yii::t('app', 'Upload Time'), |
53 | 45 | 'time_start' => Yii::t('app', 'Time Start'), |
54 | 46 | 'time_end' => Yii::t('app', 'Time End'), |
55 | 47 | ]; |
56 | 48 | } |
57 | 49 | -} |
50 | +} | |
58 | 51 | \ No newline at end of file | ... | ... |
backend/views/parser/index.php
1 | 1 | <?php |
2 | 2 | use yii\widgets\ActiveForm; |
3 | 3 | use yii\helpers\Html; |
4 | -use backend\models\Importer; | |
4 | +use backend\models\Importers; | |
5 | 5 | use yii\helpers\ArrayHelper; |
6 | 6 | if ( $model->mode ) { |
7 | 7 | // авто загрузка |
... | ... | @@ -27,7 +27,7 @@ if ( $model->mode ) { |
27 | 27 | <h3>Загрузка прайсов поставщиков</h3> |
28 | 28 | |
29 | 29 | |
30 | - <?= $form->field($model, 'importer_id')->dropDownList(ArrayHelper::map( Importer::find()->all(), 'id','name' )); ?> | |
30 | + <?= $form->field($model, 'importer_id')->dropDownList(ArrayHelper::map( Importers::find()->all(), 'id','name' )); ?> | |
31 | 31 | |
32 | 32 | <?php if ( !$mode ) { |
33 | 33 | echo $form->field($model, 'delete_price')->checkbox(['label' => 'Загрузить с удалением старого прайса']); | ... | ... |
common/models/User.php
console/migrations/m150818_125718_create_user_180815.php deleted
1 | -<?php | |
2 | - | |
3 | - | |
4 | -use yii\db\Schema; | |
5 | -use yii\db\Migration; | |
6 | - | |
7 | - | |
8 | -class m150818_125718_create_user_180815 extends Migration | |
9 | -{ | |
10 | - public function up() | |
11 | - { | |
12 | - | |
13 | - | |
14 | - $user_array = [ | |
15 | - 'username' => 'admin', | |
16 | - 'auth_key' => 'admin', | |
17 | - 'password_hash' => Yii::$app->security->generatePasswordHash('admin'), | |
18 | - 'password_reset_token' => 'admin', | |
19 | - 'email'=> 'admin@test.com', | |
20 | - 'status' => '10', | |
21 | - 'created_at'=>'000000', | |
22 | - 'updated_at' => '000000' | |
23 | - ]; | |
24 | - $this->insert('{{%user}}', $user_array); | |
25 | - } | |
26 | - | |
27 | - | |
28 | - | |
29 | - public function down() | |
30 | - { | |
31 | - $this->dropTable('{{%user}}'); | |
32 | - } | |
33 | - | |
34 | - /* | |
35 | - // Use safeUp/safeDown to run migration code within a transaction | |
36 | - public function safeUp() | |
37 | - { | |
38 | - } | |
39 | - | |
40 | - public function safeDown() | |
41 | - { | |
42 | - } | |
43 | - */ | |
44 | -} |
console/migrations/m150831_130250_addImporters.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\db\Schema; | |
4 | -use yii\db\Migration; | |
5 | - | |
6 | -class m150831_130250_addImporters extends Migration | |
7 | -{ | |
8 | - public function up() | |
9 | - { | |
10 | - $tableOptions = null; | |
11 | - if ($this->db->driverName === 'mysql') { | |
12 | - $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; | |
13 | - } | |
14 | - | |
15 | - $this->createTable('{{%importer}}', [ | |
16 | - 'id' => $this->primaryKey(6)->notNull() . ' AUTO_INCREMENT', | |
17 | - 'code' =>'varchar(254) NOT NULL', | |
18 | - 'name' => 'varchar(254) NOT NULL', | |
19 | - 'name_price' => 'varchar(254) NOT NULL', | |
20 | - 'currency_id' => 'int(3) unsigned NOT NULL', | |
21 | - 'delivery' => 'varchar(254) NOT NULL', | |
22 | - 'email' => 'varchar(254) NOT NULL', | |
23 | - 'info' => 'text NOT NULL', | |
24 | - 'active' => 'tinyint(1) unsigned NOT NULL DEFAULT 1', | |
25 | - 'PARSER_IS_ACTIVE' => 'tinyint(1) unsigned NOT NULL DEFAULT 0', | |
26 | - 'PARSER_COLUMN_COUNT' => 'int(6) unsigned DEFAULT NULL', | |
27 | - 'PARSER_FIELD_BRAND' => 'int(3) unsigned DEFAULT NULL', | |
28 | - 'PARSER_FIELD_ARTICLE' => 'int(3) unsigned DEFAULT NULL', | |
29 | - 'PARSER_FIELD_ARTICLE_PREFIX' => 'tinyint(1) unsigned NOT NULL DEFAULT 0', | |
30 | - 'PARSER_FIELD_PRICE' => 'int(3) unsigned DEFAULT NULL', | |
31 | - 'PARSER_FIELD_DESCR' =>'int(3) unsigned DEFAULT NULL', | |
32 | - 'PARSER_FIELD_BOX' => 'int(3) unsigned DEFAULT NULL', | |
33 | - 'PARSER_FIELD_ADD_BOX' => 'int(3) unsigned DEFAULT NULL', | |
34 | - 'PARSER_FIELD_GROUP_RG' => 'int(3) unsigned DEFAULT NULL', | |
35 | - 'PARSER_FIELD_SIGN' => 'varchar(1) NOT NULL', | |
36 | - 'PARSER_FIELD_MULTIPLIER' => 'float(8,2) unsigned DEFAULT NULL', | |
37 | - 'price_date_update' => 'varchar(15) NOT NULL' | |
38 | - | |
39 | - ], $tableOptions); | |
40 | - | |
41 | - $this->createIndex('code', '{{%importer}}', 'code', true); | |
42 | - $this->createIndex('name', '{{%importer}}', 'name', true); | |
43 | - $this->createIndex('active', '{{%importer}}', 'active', false); | |
44 | - } | |
45 | - | |
46 | - public function down() | |
47 | - { | |
48 | - $this->dropTable('{{%importer}}'); | |
49 | - | |
50 | - } | |
51 | - | |
52 | - /* | |
53 | - // Use safeUp/safeDown to run migration code within a transaction | |
54 | - public function safeUp() | |
55 | - { | |
56 | - } | |
57 | - | |
58 | - public function safeDown() | |
59 | - { | |
60 | - } | |
61 | - */ | |
62 | -} |
console/migrations/m150901_135806_addImportersFiles.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\db\Schema; | |
4 | -use yii\db\Migration; | |
5 | - | |
6 | -class m150901_135806_addImportersFiles extends Migration | |
7 | -{ | |
8 | - public function up() | |
9 | - { | |
10 | - $tableOptions = null; | |
11 | - if ($this->db->driverName === 'mysql') { | |
12 | - $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; | |
13 | - } | |
14 | - | |
15 | - $this->createTable('{{%importer_files}}', [ | |
16 | - 'id' => $this->primaryKey(10)->notNull() . ' AUTO_INCREMENT', | |
17 | - 'importer_id' => 'int(6) unsigned NOT NULL', | |
18 | - 'upload_time' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP', | |
19 | - 'time_start' => 'timestamp NULL DEFAULT NULL', | |
20 | - 'time_end' => 'timestamp NULL DEFAULT NULL', | |
21 | - ], $tableOptions); | |
22 | - | |
23 | - | |
24 | - $this->createIndex('importer_id', '{{%importer_files}}', 'importer_id, time_start', false); | |
25 | - } | |
26 | - | |
27 | - public function down() | |
28 | - { | |
29 | - $this->dropTable('{{%importer_files}}'); | |
30 | - } | |
31 | - | |
32 | - /* | |
33 | - // Use safeUp/safeDown to run migration code within a transaction | |
34 | - public function safeUp() | |
35 | - { | |
36 | - } | |
37 | - | |
38 | - public function safeDown() | |
39 | - { | |
40 | - } | |
41 | - */ | |
42 | -} |
console/migrations/m150901_141850_addImportersPrefix.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\db\Schema; | |
4 | -use yii\db\Migration; | |
5 | - | |
6 | -class m150901_141850_addImportersPrefix extends Migration | |
7 | -{ | |
8 | - public function up() | |
9 | - { | |
10 | - $tableOptions = null; | |
11 | - if ($this->db->driverName === 'mysql') { | |
12 | - $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; | |
13 | - } | |
14 | - | |
15 | - $this->createTable('{{%importer_prefix}}', [ | |
16 | - 'id' => $this->primaryKey(10)->notNull() . ' AUTO_INCREMENT', | |
17 | - 'importer_id' => 'int(6) unsigned NOT NULL', | |
18 | - 'brand' => 'varchar(100) NOT NULL', | |
19 | - 'prefix' => 'varchar(50) NOT NULL', | |
20 | - 'timestamp' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP', | |
21 | - ], $tableOptions); | |
22 | - | |
23 | - $this->createIndex('importer_id', '{{%importer_prefix}}', 'importer_id, brand, prefix', true); | |
24 | - } | |
25 | - | |
26 | - public function down() | |
27 | - { | |
28 | - $this->dropTable('{{%importer_prefix}}'); | |
29 | - } | |
30 | - | |
31 | - /* | |
32 | - // Use safeUp/safeDown to run migration code within a transaction | |
33 | - public function safeUp() | |
34 | - { | |
35 | - } | |
36 | - | |
37 | - public function safeDown() | |
38 | - { | |
39 | - } | |
40 | - */ | |
41 | -} |
console/migrations/m150915_125129_addDetails.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\db\Schema; | |
4 | -use yii\db\Migration; | |
5 | - | |
6 | -class m150915_125129_addDetails extends Migration | |
7 | -{ | |
8 | - public function up() | |
9 | - { | |
10 | - $this->execute('CREATE TABLE `details` ( | |
11 | - `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
12 | - `IMPORT_ID` int(6) unsigned NOT NULL, | |
13 | - `BRAND` varchar(100) NOT NULL, | |
14 | - `ARTICLE` varchar(100) NOT NULL, | |
15 | - `FULL_ARTICLE` varchar(150) NOT NULL, | |
16 | - `PRICE` float(15,2) unsigned NOT NULL, | |
17 | - `DESCR` varchar(200) NOT NULL, | |
18 | - `BOX` int(6) unsigned NOT NULL, | |
19 | - `ADD_BOX` int(6) unsigned NOT NULL DEFAULT 0, | |
20 | - `GROUP` varchar(200) NOT NULL DEFAULT \'\', | |
21 | - `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
22 | - PRIMARY KEY (`ARTICLE`,`BRAND`,`IMPORT_ID`), | |
23 | - UNIQUE KEY `ID_delete` (`ID`), | |
24 | - KEY `timestamp` (`timestamp`), | |
25 | - KEY `ARTICLE` (`ARTICLE`,`BRAND`,`BOX`), | |
26 | - KEY `BRAND` (`BRAND`,`ARTICLE`), | |
27 | - KEY `ARTICLE_2` (`ARTICLE`,`BRAND`,`ADD_BOX`), | |
28 | - KEY `IMPORT_ID` (`IMPORT_ID`,`ARTICLE`), | |
29 | - KEY `IMPORT_ID_2` (`IMPORT_ID`,`timestamp`) | |
30 | - ) ENGINE=InnoDB DEFAULT CHARSET=utf8'); | |
31 | - | |
32 | - } | |
33 | - | |
34 | - public function down() | |
35 | - { | |
36 | - $this->dropTable('{{%details}}'); | |
37 | - | |
38 | - } | |
39 | - | |
40 | -} |
console/migrations/m150922_094313_change_key_ImportFiles.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\db\Schema; | |
4 | -use yii\db\Migration; | |
5 | - | |
6 | -class m150922_094313_change_key_ImportFiles extends Migration | |
7 | -{ | |
8 | - //@todo вероятно что эта миграция ненужна - посмотреть ближе к концу проекта на ключи которые используются - остальные удалить. | |
9 | - public function up() | |
10 | - { | |
11 | - $this->dropIndex('importer_id', '{{%importer_files}}'); | |
12 | - $this->createIndex('importer_id', '{{%importer_files}}', 'importer_id, upload_time', false); | |
13 | - } | |
14 | - | |
15 | - public function down() | |
16 | - { | |
17 | - $this->dropIndex('importer_id', '{{%importer_files}}'); | |
18 | - $this->createIndex('importer_id', '{{%importer_files}}', 'importer_id, time_start', false); | |
19 | - } | |
20 | - | |
21 | - | |
22 | -} |
console/migrations/m150922_144040_change_Importer_dataPrice.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\db\Schema; | |
4 | -use yii\db\Migration; | |
5 | - | |
6 | -class m150922_144040_change_Importer_dataPrice extends Migration | |
7 | -{ | |
8 | - public function up() | |
9 | - { | |
10 | - $this->alterColumn('{{%importer}}','price_date_update','TIMESTAMP' ); | |
11 | - $this->createIndex('price_date', '{{%importer}}', 'price_date_update', false); | |
12 | - } | |
13 | - | |
14 | - public function down() | |
15 | - { | |
16 | - $this->alterColumn('{{%importer}}','price_date','varchar(15)' ); | |
17 | - $this->dropIndex('price_date', '{{%importer}}'); | |
18 | - } | |
19 | - | |
20 | - | |
21 | -} |
console/migrations/m150925_111922_add_foreign_key_ImportFiles.php
... | ... | @@ -2,17 +2,29 @@ |
2 | 2 | |
3 | 3 | use yii\db\Schema; |
4 | 4 | use yii\db\Migration; |
5 | +use backend\models\ImportersFiles; | |
5 | 6 | |
6 | 7 | class m150925_111922_add_foreign_key_ImportFiles extends Migration |
7 | 8 | { |
8 | - public function up() | |
9 | + public function safeUp() | |
9 | 10 | { |
10 | - $this->addForeignKey('importer_fk', '{{%importer_files}}', 'importer_id', '{{%importer}}', 'id'); | |
11 | + // сначала отберем записи которых нет уже в поставщиках | |
12 | + $id_arr = (new \yii\db\Query()) | |
13 | + ->select(['{{%importers_files}}.id']) | |
14 | + ->from('{{%importers_files}}') | |
15 | + ->leftJoin('{{%importers}}', 'importer_id = {{%importers}}.id') | |
16 | + ->where(['name' => null]) | |
17 | + ->all(); | |
18 | + $id_arr = array_column($id_arr,'id'); | |
19 | + // удалим их | |
20 | + $this->delete('{{%importers_files}}',['id' => $id_arr]); | |
21 | + | |
22 | + $this->addForeignKey('importer_fk', '{{%importers_files}}', 'importer_id', '{{%importers}}', 'id'); | |
11 | 23 | } |
12 | 24 | |
13 | 25 | public function down() |
14 | 26 | { |
15 | - $this->dropForeignKey('importer_fk', '{{%importer_files}}'); | |
27 | + $this->dropForeignKey('importer_fk', '{{%importers_files}}'); | |
16 | 28 | } |
17 | 29 | |
18 | 30 | } | ... | ... |
console/migrations/m130524_201442_init.php renamed to console/migrations/m150929_110456_addTempTableUser.php
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | use yii\db\Schema; |
4 | 4 | use yii\db\Migration; |
5 | 5 | |
6 | -class m130524_201442_init extends Migration | |
6 | +class m150929_110456_addTempTableUser extends Migration | |
7 | 7 | { |
8 | 8 | public function up() |
9 | 9 | { |
... | ... | @@ -13,7 +13,7 @@ class m130524_201442_init extends Migration |
13 | 13 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
14 | 14 | } |
15 | 15 | |
16 | - $this->createTable('{{%user}}', [ | |
16 | + $this->createTable('user', [ | |
17 | 17 | 'id' => $this->primaryKey(), |
18 | 18 | 'username' => $this->string()->notNull()->unique(), |
19 | 19 | 'auth_key' => $this->string(32)->notNull(), |
... | ... | @@ -25,10 +25,22 @@ class m130524_201442_init extends Migration |
25 | 25 | 'created_at' => $this->integer()->notNull(), |
26 | 26 | 'updated_at' => $this->integer()->notNull(), |
27 | 27 | ], $tableOptions); |
28 | + | |
29 | + $user_array = [ | |
30 | + 'username' => 'admin', | |
31 | + 'auth_key' => 'admin', | |
32 | + 'password_hash' => Yii::$app->security->generatePasswordHash('admin'), | |
33 | + 'password_reset_token' => 'admin', | |
34 | + 'email'=> 'admin@test.com', | |
35 | + 'status' => '10', | |
36 | + 'created_at'=>'000000', | |
37 | + 'updated_at' => '000000' | |
38 | + ]; | |
39 | + $this->insert('user', $user_array); | |
28 | 40 | } |
29 | 41 | |
30 | 42 | public function down() |
31 | 43 | { |
32 | - $this->dropTable('{{%user}}'); | |
44 | + $this->dropTable('user'); | |
33 | 45 | } |
34 | 46 | } | ... | ... |
console/migrations/m150929_113358_change_Importer_dataPrice.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Schema; | |
4 | +use yii\db\Migration; | |
5 | + | |
6 | +class m150929_113358_change_Importer_dataPrice extends Migration | |
7 | +{ | |
8 | + public function safeUp() | |
9 | + { | |
10 | + // увеличим размерность строки, так как при преобразовании из таймстампа в дату может не хватить символов | |
11 | + $this->alterColumn('{{%importers}}','price_date_update','VARCHAR(80)' ); | |
12 | + // конвертем в дату | |
13 | + $this->update('{{%importers}}',['price_date_update'=> new yii\db\Expression('FROM_UNIXTIME(price_date_update)')]); | |
14 | + // а из даты в таймстамп | |
15 | + $this->alterColumn('{{%importers}}','price_date_update','TIMESTAMP NOT NULL' ); | |
16 | + $this->createIndex('price_date', '{{%importers}}', 'price_date_update', false); | |
17 | + | |
18 | + } | |
19 | + | |
20 | + | |
21 | + public function safedown() | |
22 | + { | |
23 | + $this->alterColumn('{{%importers}}','price_date','varchar(15)' ); | |
24 | + $this->dropIndex('price_date', '{{%importers}}'); | |
25 | + } | |
26 | + | |
27 | +} | ... | ... |
framework/lang/da.yml
... | ... | @@ -23,7 +23,7 @@ da: |
23 | 23 | PLEASESAVE: 'Gem siden: Denne side kunne ikke blive opdateret, fordi den endnu ikke er gemt.' |
24 | 24 | ModelAdmin: |
25 | 25 | DELETE: Slet |
26 | - IMPORT: 'Importer fra CSV' | |
26 | + IMPORT: 'Importers fra CSV' | |
27 | 27 | NOCSVFILE: 'Tryk på Gennemse for at vælge en CSVfil til importering' |
28 | 28 | NOIMPORT: 'Intet at importere' |
29 | 29 | SecurityAdmin: | ... | ... |
framework/lang/fr.yml
... | ... | @@ -234,7 +234,7 @@ fr: |
234 | 234 | has_many_Permissions: Autorisations |
235 | 235 | many_many_Members: Membres |
236 | 236 | GroupImportForm: |
237 | - Help1: '<p>Importer un ou plusieurs groupe(s) au format <em>CSV</em> (comma-separated values). <small><a href="#" class="toggle-advanced">Montrer l''usage avancé</a></small></p>' | |
237 | + Help1: '<p>Importers un ou plusieurs groupe(s) au format <em>CSV</em> (comma-separated values). <small><a href="#" class="toggle-advanced">Montrer l''usage avancé</a></small></p>' | |
238 | 238 | Help2: "<div class=\"advanced\">\n<h4>Utilisation avancée</h4>\n<ul>\n<li>Colonnes autorisées : <em>%s</em></li>\n<li>Les utilisateurs existants sont retrouvés avec leur <em>Code</em> unique et les registres sont mis à jour avec les nouvelles valeurs du fichier importé.</li>\n<li>Des hiérarchies de groupes peuvent être créées à l’aide de la colonne <em>ParentCode</em>.</li>\n<li>Les autorisations sont assignées par la colonne <em>PermissionCode</em>. Les autorisations actuelles ne sont pas modifiées.</li>\n</ul>\n</div>" |
239 | 239 | ResultCreated: '{count} groupes créés' |
240 | 240 | ResultDeleted: '%d groupes supprimés' |
... | ... | @@ -388,7 +388,7 @@ fr: |
388 | 388 | TWODIGITYEAR: 'L’année sur deux chiffres' |
389 | 389 | Toggle: 'Afficher l’aide de mise en forme' |
390 | 390 | MemberImportForm: |
391 | - Help1: '<p>Importer les membres au format<em>CSV format</em> (comma-separated values). <small><a href="#" class="toggle-advanced">Afficher l''usage avancé.</a></small></p>' | |
391 | + Help1: '<p>Importers les membres au format<em>CSV format</em> (comma-separated values). <small><a href="#" class="toggle-advanced">Afficher l''usage avancé.</a></small></p>' | |
392 | 392 | Help2: "<div class=\"advanced\">\n<h4>Utilisation avancée</h4>\n<ul>\n<li>Colonnes autorisées : <em>%s</em></li>\n<li>Les utilisateurs existants sont retrouvés avec leur <em>Code</em> unique et les registres sont mis à jour avec les nouvelles valeurs du fichier importé.</li>\n<li>Des groupes peuvent être assignés à l’aide de la colonne <em>Groups</em>. Les groupes sont identifiés par leur <em>Code</em>, plusieurs groupes peuvent être indiqués en les séparant par des virgules. L’appartenance actuelle aux groupes n’est pas modifiée.</li>\n</ul>\n</div>" |
393 | 393 | ResultCreated: '{count} membres créés' |
394 | 394 | ResultDeleted: '%d membres supprimés' |
... | ... | @@ -403,7 +403,7 @@ fr: |
403 | 403 | DELETE: Supprime |
404 | 404 | DELETEDRECORDS: '{count} enregistrements supprimés.' |
405 | 405 | EMPTYBEFOREIMPORT: 'Remplacer les données' |
406 | - IMPORT: 'Importer de CSV' | |
406 | + IMPORT: 'Importers de CSV' | |
407 | 407 | IMPORTEDRECORDS: '{count} enregistrements importés.' |
408 | 408 | NOCSVFILE: 'Veuillez choisir un fichier CSV à importer' |
409 | 409 | NOIMPORT: 'Rien à importer' |
... | ... | @@ -417,9 +417,9 @@ fr: |
417 | 417 | IMPORTSPECTITLE: 'Spécification de %s' |
418 | 418 | ModelAdmin_Tools_ss: |
419 | 419 | FILTER: Filtrer |
420 | - IMPORT: Importer | |
420 | + IMPORT: Importers | |
421 | 421 | ModelSidebar_ss: |
422 | - IMPORT_TAB_HEADER: Importer | |
422 | + IMPORT_TAB_HEADER: Importers | |
423 | 423 | SEARCHLISTINGS: Rechercher |
424 | 424 | MoneyField: |
425 | 425 | FIELDLABELAMOUNT: Quantité |
... | ... | @@ -481,8 +481,8 @@ fr: |
481 | 481 | EDITPERMISSIONS: 'Gérer les autorisations des groupes' |
482 | 482 | EDITPERMISSIONS_HELP: 'Possibilité d''éditer les autorisations et les adresses IP pour un groupe. Nécessite l’autorisation « Accès à la section “Securité” ».' |
483 | 483 | GROUPNAME: 'Nom du group' |
484 | - IMPORTGROUPS: 'Importer des groupes' | |
485 | - IMPORTUSERS: 'Importer des utilisateurs' | |
484 | + IMPORTGROUPS: 'Importers des groupes' | |
485 | + IMPORTUSERS: 'Importers des utilisateurs' | |
486 | 486 | MEMBERS: Membres |
487 | 487 | MENUTITLE: Sécurité |
488 | 488 | MemberListCaution: 'Attention : en supprimant des membres de cette liste vous les enlèverez de tous les groupes ainsi que de la base de données' |
... | ... | @@ -493,7 +493,7 @@ fr: |
493 | 493 | TABROLES: Rôles |
494 | 494 | Users: Utilisateurs |
495 | 495 | SecurityAdmin_MemberImportForm: |
496 | - BtnImport: 'Importer' | |
496 | + BtnImport: 'Importers' | |
497 | 497 | FileFieldLabel: 'Fichier CSV <small>(extension autorisée : *.csv)</small>' |
498 | 498 | SilverStripeNavigator: |
499 | 499 | Auto: Auto | ... | ... |
framework/lang/nb.yml
... | ... | @@ -236,7 +236,7 @@ nb: |
236 | 236 | has_many_Permissions: Tillatelser |
237 | 237 | many_many_Members: Medlemmer |
238 | 238 | GroupImportForm: |
239 | - Help1: '<p>Importer en eller flere grupper i <em>CSV</em>-format (kommaseparerte verdier). <small><a href="#" class="toggle-advanced">Vis avanserte alternativer</a></small></p>' | |
239 | + Help1: '<p>Importers en eller flere grupper i <em>CSV</em>-format (kommaseparerte verdier). <small><a href="#" class="toggle-advanced">Vis avanserte alternativer</a></small></p>' | |
240 | 240 | Help2: "<div class=\"advanced\">\n<h4>Avanserte alternativer</h4>\n<ul>\n<li>Tillatte kolonner: <em>%s</em></li>\n<li>Eksisterende grupper matches mot deres <em>Code</em>-verdi og oppdateres med nye verdier fra den importerte filen.</li>\n<li>Gruppehierarkier kan bli opprettet ved å benytte en <em>ParentCode</em>-kolonne.</li>\n<li>Tillatelseskoder kan bli angitt med <em>PermissionCode</em>-kolonnen. Eksisterende tillatelselskoder blir ikke fjernet.</li>\n</ul>\n</div>" |
241 | 241 | ResultCreated: 'Opprettet {count} grupper' |
242 | 242 | ResultDeleted: 'Slettet %d grupper' |
... | ... | @@ -390,7 +390,7 @@ nb: |
390 | 390 | TWODIGITYEAR: 'Tosifret årstall' |
391 | 391 | Toggle: 'Vis formateringshjelp' |
392 | 392 | MemberImportForm: |
393 | - Help1: '<p>Importer brukere i <em>CSV-format</em> (verdier adskilt med komma). <small><a href="#" class="toggle-advanced">Vis avanserte alternativer</a></small></p>' | |
393 | + Help1: '<p>Importers brukere i <em>CSV-format</em> (verdier adskilt med komma). <small><a href="#" class="toggle-advanced">Vis avanserte alternativer</a></small></p>' | |
394 | 394 | Help2: "<div class=\"advanced\">\n<h4>Avanserte alternativer</h4>\n<ul>\n<li>Tillatte kolonner: <em>%s</em></li>\n<li>Eksisterende brukere blir matchet mot deres unike <em>Code</em> og oppdatert med nye verdier fra den importerte filen.</li>\n<li>Grupper kan angis med <em>Groups</em>-kolonnen. Grupper er identifisert ved deres <em>Code</em>. Grupper kan adskilles med komma. Eksisterende gruppemedlemskap blir ikke fjernet.</li>\n</ul>\n</div>" |
395 | 395 | ResultCreated: 'Opprettet {count} medlemmer' |
396 | 396 | ResultDeleted: 'Slettet %d medlemmer' |
... | ... | @@ -405,7 +405,7 @@ nb: |
405 | 405 | DELETE: Slett |
406 | 406 | DELETEDRECORDS: 'Slettet {count} oppføringer.' |
407 | 407 | EMPTYBEFOREIMPORT: 'Erstatt data' |
408 | - IMPORT: 'Importer fra CSV' | |
408 | + IMPORT: 'Importers fra CSV' | |
409 | 409 | IMPORTEDRECORDS: 'Importerte {count} oppføringer.' |
410 | 410 | NOCSVFILE: 'Vennligst finn en CSV-fil å importere' |
411 | 411 | NOIMPORT: 'Ingenting å importere' |
... | ... | @@ -419,9 +419,9 @@ nb: |
419 | 419 | IMPORTSPECTITLE: 'Spesifikasjon for %s' |
420 | 420 | ModelAdmin_Tools_ss: |
421 | 421 | FILTER: Filtrer |
422 | - IMPORT: Importer | |
422 | + IMPORT: Importers | |
423 | 423 | ModelSidebar_ss: |
424 | - IMPORT_TAB_HEADER: Importer | |
424 | + IMPORT_TAB_HEADER: Importers | |
425 | 425 | SEARCHLISTINGS: Søk |
426 | 426 | MoneyField: |
427 | 427 | FIELDLABELAMOUNT: Mengde |
... | ... | @@ -485,8 +485,8 @@ nb: |
485 | 485 | EDITPERMISSIONS: 'Administrer tillatelser for grupper' |
486 | 486 | EDITPERMISSIONS_HELP: 'Mulighet for å endre tillatelser og IP-adresser for en gruppe. Brukere må ha adgang til sikkerhetsseksjon.' |
487 | 487 | GROUPNAME: 'Gruppenavn' |
488 | - IMPORTGROUPS: 'Importer grupper' | |
489 | - IMPORTUSERS: 'Importer brukere' | |
488 | + IMPORTGROUPS: 'Importers grupper' | |
489 | + IMPORTUSERS: 'Importers brukere' | |
490 | 490 | MEMBERS: Medlemmer |
491 | 491 | MENUTITLE: Sikkerhet |
492 | 492 | MemberListCaution: 'Advarsel: Hvis du fjerner medlemmer fra denne listen vil det samtidig fjerne dem fra alle grupper og databasen' |
... | ... | @@ -497,7 +497,7 @@ nb: |
497 | 497 | TABROLES: Roller |
498 | 498 | Users: Brukere |
499 | 499 | SecurityAdmin_MemberImportForm: |
500 | - BtnImport: 'Importer fra CSV' | |
500 | + BtnImport: 'Importers fra CSV' | |
501 | 501 | FileFieldLabel: 'CSV-fil <small>(Tillatt filtype: *.csv)</small>' |
502 | 502 | SilverStripeNavigator: |
503 | 503 | Auto: Automatisk | ... | ... |