diff --git a/backend/assets/CheckPriceAsset.php b/backend/assets/CheckPriceAsset.php
new file mode 100644
index 0000000..876f02d
--- /dev/null
+++ b/backend/assets/CheckPriceAsset.php
@@ -0,0 +1,26 @@
+request->isAjax){
- CustomVarDamp::dumpAndDie(1);
+ CustomVarDamp::dumpAndDie('Ajax!!!');
}
//$query = (new Query())->select('*')->from('{{%importer_files}}')->where(['not', ['time_end' => null]])->orderBy(['upload_time' => SORT_DESC]);
@@ -81,18 +81,18 @@ class CheckPriceController extends BaseController
}
- public function actionView ($id)
+ public function actionView ($id, $date_update)
{
- // @todo переписать запрос - нужно условие на равенство даты, а также вьюшка должна быть модальным окном вызываемой по аджаксу
- $query = Details::find()->where(['IMPORT_ID' => $id])->orderBy(['timestamp' => SORT_DESC]);
+
+ $query = Details::find()->where(['IMPORT_ID' => $id, 'timestamp' => $date_update])->limit(20);
$provider = new ActiveDataProvider([
'query' => $query,
- 'pagination' => [
- 'pageSize' => 16,
- ],
+ 'pagination' => false,
+ 'sort' => false,
]);
- return $this->render('view',
+
+ return $this->renderAjax('view',
['dataProvider' => $provider]);
}
diff --git a/backend/controllers/Check_priceController.php b/backend/controllers/Check_priceController.php
deleted file mode 100644
index 4ebd29b..0000000
--- a/backend/controllers/Check_priceController.php
+++ /dev/null
@@ -1,108 +0,0 @@
- [
- 'class' => AccessControl::className(),
- 'rules' => [
- [
- 'actions' => ['index', 'view'],
- 'allow' => true,
- 'roles' => ['@'],
- ],
- ],
- ],
-// 'verbs' => [
-// 'class' => VerbFilter::className(),
-// 'actions' => [
-// 'logout' => ['post'],
-// ],
-// ],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function actions()
- {
- return [
- 'error' => [
- 'class' => 'yii\web\ErrorAction',
- ],
- ];
- }
-
-
- public function actionIndex()
- {
-
- if(Yii::$app->request->isAjax){
- CustomVarDamp::dumpAndDie(1);
- }
-
- //$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,
- 'pagination' => [
- 'pageSize' => 10,
- ],
- ]);
- return $this->render('index',
- [
- 'dataProvider' => $provider,
- ]);
- }
-
-
- public function actionView ($id)
- {
-
-
-
-
- $query = Details::find()->where(['IMPORT_ID' => $id])->orderBy(['timestamp' => SORT_DESC]);
-
- $provider = new ActiveDataProvider([
- 'query' => $query,
- 'pagination' => [
- 'pageSize' => 16,
- ],
- ]);
- return $this->render('view',
- ['dataProvider' => $provider]);
- }
-}
diff --git a/backend/views/check-price/index.php b/backend/views/check-price/index.php
index e34f765..4070d96 100644
--- a/backend/views/check-price/index.php
+++ b/backend/views/check-price/index.php
@@ -4,6 +4,9 @@ use yii\grid\GridView;
use yii\grid\SerialColumn;
use yii\grid\ActionColumn;
use yii\widgets\Pjax;
+use yii\bootstrap\Modal;
+use yii\helpers\Url;
+use backend\assets\CheckPriceAsset;
/* @var $this yii\web\View */
@@ -12,47 +15,68 @@ use yii\widgets\Pjax;
$this->title = 'Проверка прайсов';
$this->params['breadcrumbs'][] = $this->title;
+// зарегистрируем скрипт для обработки загрузки модального окна
+CheckPriceAsset::register($this);
?>
= Html::encode($this->title) ?>
- = GridView::widget( ['dataProvider' => $dataProvider,
- 'columns' => [['class' => SerialColumn::className()],
- [
- 'class' => ActionColumn::className(),
- 'template'=>'{view}',
- 'contentOptions' => function ($model, $key, $index, $column){
- return ['data' => ['id' => $model->id, 'date' => $model->price_date_update]];
- }
+ = GridView::widget(['dataProvider' => $dataProvider,
+ 'columns' => [
+ ['class' => SerialColumn::className()],
+
+ ['content' => function ($model) {
+ $url = Url::to(['view', 'id' => $model->id, 'date_update' => $model->price_date_update]);
+ return Html::a('
Просмотреть ', '#', [
+ 'title' => Yii::t('yii', 'Просмотреть прайс'),
+ 'class' => 'modalButton',
+ 'value' => $url,
+ ]);
+ },
],
+
[
- 'label' =>'Поставщик',
+ 'label' => 'Поставщик',
'value' => function ($data) {
- return '№ ' .$data->id . ' ' . $data->name;
+ return '№ ' . $data->id . ' ' . $data->name;
},
],
- ['label' =>'Дата обновления',
- 'attribute' => 'price_date_update' ],
- ['label' => 'Кол-во дней',
- 'value' => function ($data) {
- $date1 = new DateTime("now");
- $date2 = new DateTime( $data->price_date_update );
- $quo_days = $date2->diff($date1)->format('%R%a');
- // уберем первый символ - там знак "+"
- $quo_days = substr( $quo_days, 1, strlen($quo_days) );
- $quo_days = (int) $quo_days;
-
- if($quo_days > 15)
- $quo_days = '>15';
-
- return $quo_days;
- }
- ],
- ]] );?>
+ ['label' => 'Дата обновления',
+ 'attribute' => 'price_date_update'],
+
+ ['label' => 'Кол-во дней',
+ 'value' => function ($data) {
+ $date1 = new DateTime("now");
+ $date2 = new DateTime($data->price_date_update);
+ $quo_days = $date2->diff($date1)->format('%R%a');
+ // уберем первый символ - там знак "+"
+ $quo_days = substr($quo_days, 1, strlen($quo_days));
+ $quo_days = (int)$quo_days;
+
+ if ($quo_days > 15)
+ $quo_days = '>15';
+
+ return $quo_days;
+ }
+ ],
+ ]
+ ]); ?>
+
+ '
Прайс
',
+ 'id' => 'modal',
+ 'size' => 'modal-lg',
+ ]);
+
+ echo "
";
+ Modal::end();
+ ?>
\ No newline at end of file
diff --git a/backend/views/check_price/index.php b/backend/views/check_price/index.php
deleted file mode 100644
index e34f765..0000000
--- a/backend/views/check_price/index.php
+++ /dev/null
@@ -1,58 +0,0 @@
-title = 'Проверка прайсов';
-$this->params['breadcrumbs'][] = $this->title;
-?>
-
-
-
= Html::encode($this->title) ?>
-
-
- = GridView::widget( ['dataProvider' => $dataProvider,
- 'columns' => [['class' => SerialColumn::className()],
- [
- 'class' => ActionColumn::className(),
- 'template'=>'{view}',
- 'contentOptions' => function ($model, $key, $index, $column){
- return ['data' => ['id' => $model->id, 'date' => $model->price_date_update]];
- }
- ],
- [
- 'label' =>'Поставщик',
- 'value' => function ($data) {
- return '№ ' .$data->id . ' ' . $data->name;
- },
- ],
- ['label' =>'Дата обновления',
- 'attribute' => 'price_date_update' ],
- ['label' => 'Кол-во дней',
- 'value' => function ($data) {
- $date1 = new DateTime("now");
- $date2 = new DateTime( $data->price_date_update );
- $quo_days = $date2->diff($date1)->format('%R%a');
- // уберем первый символ - там знак "+"
- $quo_days = substr( $quo_days, 1, strlen($quo_days) );
- $quo_days = (int) $quo_days;
-
- if($quo_days > 15)
- $quo_days = '>15';
-
- return $quo_days;
- }
- ],
- ]] );?>
-
-
-
-
-
\ No newline at end of file
diff --git a/backend/views/check_price/view.php b/backend/views/check_price/view.php
deleted file mode 100644
index f6d9ff0..0000000
--- a/backend/views/check_price/view.php
+++ /dev/null
@@ -1,32 +0,0 @@
-title = 'Проверка прайсов';
-$this->params['breadcrumbs'][] = $this->title;
-
-?>
-
-
-
= Html::encode($this->title) ?>
-
- = GridView::widget( ['dataProvider' => $dataProvider,
-
- ] );
-
-
- ?>
-
-
-
-
-
\ No newline at end of file
diff --git a/backend/views/parser/server-files.php b/backend/views/parser/server-files.php
index e82bc0a..486f6bc 100644
--- a/backend/views/parser/server-files.php
+++ b/backend/views/parser/server-files.php
@@ -38,7 +38,7 @@ Pjax::begin();
'title' => Yii::t('yii', 'Удалить файл'),
'data-confirm' => 'Вы уверены что хотите удалить этот файл?',
'data-method' => 'post',
- 'data-pjax' => '1',
+ 'data-pjax' => '0',
]);
},
],
diff --git a/backend/web/js/check-price.js b/backend/web/js/check-price.js
new file mode 100644
index 0000000..ec4fc62
--- /dev/null
+++ b/backend/web/js/check-price.js
@@ -0,0 +1,9 @@
+$(function(){
+
+ // get the click of the create button
+ $('.modalButton').click(function (){
+ $('#modal').modal('show')
+ .find('#modalContent')
+ .load($(this).attr('value'));
+ });
+});
--
libgit2 0.21.4