diff --git a/backend/controllers/ImportersPrefixController.php b/backend/controllers/ImportersPrefixController.php index dec3025..b3ecbf1 100644 --- a/backend/controllers/ImportersPrefixController.php +++ b/backend/controllers/ImportersPrefixController.php @@ -54,9 +54,10 @@ class ImportersPrefixController extends BaseController $model = new ImportersPrefix(); if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); + //return $this->redirect(['view', 'id' => $model->id]); + return $this->redirect('index'); } else { - return $this->render('create', [ + return $this->renderAjax('create', [ 'model' => $model, ]); } @@ -73,7 +74,8 @@ class ImportersPrefixController extends BaseController $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); + // return $this->redirect(['view', 'id' => $model->id]); + return $this->redirect('index'); } else { return $this->render('update', [ 'model' => $model, diff --git a/backend/controllers/ParserController.php b/backend/controllers/ParserController.php index f838024..bf306f7 100644 --- a/backend/controllers/ParserController.php +++ b/backend/controllers/ParserController.php @@ -111,7 +111,12 @@ class ParserController extends BaseController // === ручная загрузка =========== //запускаем парсинг - $data = $model->readFile(); + // доп. опции для парсера + $options = []; + if( ! $model->action ) // обработка с кастомным разделителем + $options['$delimiter'] = $model->delimiter; + + $data = $model->readFile( $options ); // сохраняем в кеш отпарсенные даные Yii::$app->getCache()->set('parser_data', json_encode($data)); // сохраняем в кеш модель - в ней настройки для дальнейшей обработки данных diff --git a/backend/models/ImportersPrefix.php b/backend/models/ImportersPrefix.php index ae0ca79..7436416 100644 --- a/backend/models/ImportersPrefix.php +++ b/backend/models/ImportersPrefix.php @@ -3,6 +3,7 @@ namespace backend\models; use Yii; +use backend\models\Importers; /** * This is the model class for table "w_importers_prefix". @@ -15,13 +16,6 @@ use Yii; */ class ImportersPrefix extends \backend\components\base\BaseActiveRecord { - /** - * @inheritdoc - */ - public static function tableName() - { - return 'w_importers_prefix'; - } /** * @inheritdoc @@ -38,6 +32,11 @@ class ImportersPrefix extends \backend\components\base\BaseActiveRecord ]; } + + public function getImporterName () + { + return Importers::findOne($this->importer_id)->name; + } /** * @inheritdoc */ @@ -45,10 +44,10 @@ class ImportersPrefix extends \backend\components\base\BaseActiveRecord { return [ 'id' => Yii::t('app', 'ID'), - 'importer_id' => Yii::t('app', 'Importer ID'), - 'brand' => Yii::t('app', 'Brand'), - 'prefix' => Yii::t('app', 'Prefix'), - 'timestamp' => Yii::t('app', 'Timestamp'), + 'importer_id' => Yii::t('app', 'Поставщик'), + 'brand' => Yii::t('app', 'Бренд'), + 'prefix' => Yii::t('app', 'Префикс'), + 'timestamp' => Yii::t('app', 'Дата создания'), ]; } } diff --git a/backend/views/check-price/index.php b/backend/views/check-price/index.php index 8fe6322..26fdb19 100644 --- a/backend/views/check-price/index.php +++ b/backend/views/check-price/index.php @@ -16,8 +16,7 @@ $this->title = 'Проверка прайсов'; $this->params['breadcrumbs'][] = $this->title; // зарегистрируем скрипт для обработки загрузки модального окна ParserAsset::register($this); -// убрал Pjax потому что он при выполнении блокирует скрипт вызова модального окна -//Pjax::begin(); +Pjax::begin(['id' => 'gridViewContent']); ?>
+ = Html::a(Yii::t('app', 'Добавление'), '#', ['class' => 'btn btn-success modalButton', 'value' => $url]) ?> +
+ render('_search', ['model' => $searchModel]); + Pjax::begin(['id' => 'gridViewContent']); + ?> = GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - - 'importer_id', - 'brand', - 'prefix', - 'timestamp', + [ + 'attribute' => 'importer_id', + 'label' => 'ПОСТАВЩИК', + 'value' => function ($data) { + return $data->importerName;} + ], + [ + 'attribute' => 'brand', + 'label' => 'БРЕНД', + ], + [ + 'attribute' => 'prefix', + 'label' => 'ПРЕФИКСЫ (ЧЕРЕЗ ,)', + ], + [ + 'attribute' => 'timestamp', + 'label' => 'ДАТА ДОБАВЛЕНИЯ', + ], ['class' => 'yii\grid\ActionColumn', 'template' => '{update},{delete}'], ], - ]); ?> + ]); + + + + // сюда будем всавлять контент модального окна + Modal::begin([ + 'id' => 'modal', + 'size' => 'modal-lg', + ]); + + echo ""; + Modal::end(); + Pjax::end(); + ?>