Commit 36b545ad8faa0d05e8ad1dd959c6698272a40273

Authored by Mihail
1 parent 3663f570

final upload form wihtout file extension validation

backend/components/parsers/CsvParser.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * Time: 17:00 6 * Time: 17:00
7 */ 7 */
8 8
9 -namespace backend\components; 9 +namespace backend\components\parsers;
10 10
11 11
12 use Yii; 12 use Yii;
backend/components/parsers/Encoder.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * Time: 13:36 6 * Time: 13:36
7 */ 7 */
8 8
9 -namespace backend\components; 9 +namespace backend\components\parsers;
10 10
11 // @todo add comments 11 // @todo add comments
12 class Encoder 12 class Encoder
backend/components/parsers/MailParser.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * Time: 10:53 6 * Time: 10:53
7 */ 7 */
8 8
9 -namespace backend\components; 9 +namespace backend\components\parsers;
10 10
11 11
12 class MailParser { 12 class MailParser {
backend/components/parsers/ParserHandler.php
1 <?php 1 <?php
2 -namespace backend\components; 2 +namespace backend\components\parsers;
3 3
4 use Yii; 4 use Yii;
5 5
backend/components/parsers/ValueFilter.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * Time: 12:50 6 * Time: 12:50
7 */ 7 */
8 8
9 -namespace backend\components; 9 +namespace backend\components\parsers;
10 10
11 // класс который содержит преобразователи значений (фильтры) используемые при парсинге 11 // класс который содержит преобразователи значений (фильтры) используемые при парсинге
12 class ValueFilter 12 class ValueFilter
backend/models/UploadFileParsingForm.php
@@ -3,7 +3,7 @@ namespace backend\models; @@ -3,7 +3,7 @@ namespace backend\models;
3 3
4 use yii\base\Model; 4 use yii\base\Model;
5 use yii\web\UploadedFile; 5 use yii\web\UploadedFile;
6 -use backend\components\ParserHandler; 6 +use backend\components\parsers\ParserHandler;
7 use Yii; 7 use Yii;
8 use common\components\debug\CustomVarDamp; 8 use common\components\debug\CustomVarDamp;
9 9
@@ -31,7 +31,7 @@ class UploadFileParsingForm extends Model @@ -31,7 +31,7 @@ class UploadFileParsingForm extends Model
31 ['importer', 'required', 'message' => 'Не указан поставщик!' ], 31 ['importer', 'required', 'message' => 'Не указан поставщик!' ],
32 ['file', 'required', 'message' => 'Не выбран файл!' ], 32 ['file', 'required', 'message' => 'Не выбран файл!' ],
33 //@todo - not working this file validator!!! - fixed 33 //@todo - not working this file validator!!! - fixed
34 - [['file'], 'file', 'extensions' => ['csv', 'xml'] ], //'extensions' => ['csv'], 34 + [['file'], 'file'],// 'extensions' => ['csv', 'xml'] ],
35 // 'wrongMimeType' => 'Указан неподдерживаемый тип файла. Можно выбирать csv, xml файлы.' ], 35 // 'wrongMimeType' => 'Указан неподдерживаемый тип файла. Можно выбирать csv, xml файлы.' ],
36 ['importer', 'integer','max' => 999999, 'min' => 0 ], 36 ['importer', 'integer','max' => 999999, 'min' => 0 ],
37 [['action','delete_prefix', 'delete_price'], 'boolean'], 37 [['action','delete_prefix', 'delete_price'], 'boolean'],
@@ -51,7 +51,6 @@ class UploadFileParsingForm extends Model @@ -51,7 +51,6 @@ class UploadFileParsingForm extends Model
51 } 51 }
52 52
53 public function readFile($filePath){ 53 public function readFile($filePath){
54 - CustomVarDamp::dumpAndDie( new ParserHandler( $filePath, $this ));  
55 $parser = new ParserHandler( $filePath, $this ); 54 $parser = new ParserHandler( $filePath, $this );
56 $data = $parser->run(); 55 $data = $parser->run();
57 56
backend/views/parser/index.php
@@ -7,7 +7,11 @@ use yii\helpers\ArrayHelper; @@ -7,7 +7,11 @@ use yii\helpers\ArrayHelper;
7 ?> 7 ?>
8 <div class="row"> 8 <div class="row">
9 <div class="col-lg-5"> 9 <div class="col-lg-5">
10 - <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data',],'action'=>['parser/results']]) ?> 10 + <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data',],'action'=>['parser/results']]);
  11 + if (!$model->action) {
  12 + $model->action = 1;
  13 + }
  14 + ?>
11 <h3>Загрузка прайсов поставщиков</h3> 15 <h3>Загрузка прайсов поставщиков</h3>
12 16
13 17