diff --git a/backend/assets/CartAsset.php b/backend/assets/CartAsset.php
new file mode 100644
index 0000000..dbf2846
--- /dev/null
+++ b/backend/assets/CartAsset.php
@@ -0,0 +1,26 @@
+render('view', [
- 'model' => $this->findModel($id),
+ $provider = new ActiveDataProvider([
+ 'query' => Cart::find()->where(['bill_id' => $id]),
+ 'sort' => false,
+
+ ]);
+
+ return $this->renderAjax('view', [
+ 'id' => $id,
+ 'provider' => $provider,
]);
}
@@ -53,7 +62,7 @@ class CartController extends BaseController
*/
protected function findModel($id)
{
- if (($model = CartBillsView::findById($id)) !== null) {
+ if (($model = Cart::findOne(['bill_id' => $id])) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
diff --git a/backend/views/cart/index.php b/backend/views/cart/index.php
index 9d2ef9a..85a4470 100755
--- a/backend/views/cart/index.php
+++ b/backend/views/cart/index.php
@@ -3,6 +3,8 @@
use yii\helpers\Html;
use yii\grid\GridView;
use kartik\date\DatePicker;
+use \yii\widgets\Pjax;
+use \yii\bootstrap\Modal;
/* @var $this yii\web\View */
/* @var $searchModel common\models\CartBillsSearch */
@@ -11,7 +13,13 @@ use kartik\date\DatePicker;
$this->title = Yii::t('app', 'Заказы');
$this->params['breadcrumbs'][] = $this->title;
+$safe_bill_img0 = '/storage/checkbox0.gif';
+$safe_bill_img1 = '/storage/checkbox1.gif';
+
+\backend\assets\CartAsset::register($this);
+Pjax::begin(['id' => 'gridViewContent']);
?>
+
= Html::encode($this->title) ?>
@@ -23,13 +31,32 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
-
+ ['content' => function ($model) {
+ $url = \yii\helpers\Url::to(['view', 'id' => $model->id]);
+ return Html::a('
', '#', [
+ 'class' => 'cartModalViewButton',
+ 'value' => $url,
+ ]);
+ },
+ ],
'id',
'account_id',
['label' =>'Информация',
- 'value' =>function ($data) {
- $info = $data->scode . ' /n';
- $info .= $data->name;
+ 'format' => 'raw',
+ 'value' =>function( $model ) use ($safe_bill_img0, $safe_bill_img1) {
+ $info = '
Код 1С:' . ' ' . $model->scode . '
';
+ $info .= '
Имя:' . ' ' .$model->name . '
';
+ $info .= '
Тел.:' . ' ' .$model->phone . '
';
+ $info .= '
Email:' . ' ' .$model->email . '
';
+ $info .= '
Доставка:' . ' ' .$model->delivery . '
';
+ $info .= '
Комментарий:' . ' ' .$model->message . '
';
+ $info .= '
Страховка:';
+ if ($model->safe_bill == '1') {
+ $info .= "

";
+ }
+ else {
+ $info .= "

";
+ }
return $info;
},
],
@@ -60,4 +87,16 @@ $this->params['breadcrumbs'][] = $this->title;
],
]); ?>
+ '
Прайс
',
+ 'id' => 'modal',
+ 'size' => 'modal-lg',
+ ]);
+
+ echo "
";
+ Modal::end();
+ Pjax::end();
+ ?>
diff --git a/backend/views/cart/view.php b/backend/views/cart/view.php
index dbefc32..58940ad 100755
--- a/backend/views/cart/view.php
+++ b/backend/views/cart/view.php
@@ -1,47 +1,31 @@
title = $model->id;
-$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Cart Bills'), 'url' => ['index']];
-$this->params['breadcrumbs'][] = $this->title;
+$this->title = "Заказ № " . $id;
?>
= Html::encode($this->title) ?>
-
- = Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
- = Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
- 'method' => 'post',
- ],
- ]) ?>
-
-
- = DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'id',
- 'account_id',
- 'manager_id',
- 'office_id',
- 'status',
- 'f1',
- 'f2',
- 'f3',
- 'message:ntext',
- 'safe_bill',
- 'delivery',
- 'delivery_price',
- 'timestamp',
+ = GridView::widget([
+ 'dataProvider' => $provider,
+ 'layout' =>'{items}',
+ 'columns'=>[
+ 'article',
+ 'brand',
+ 'importer',
+ 'descr',
+ 'count',
+ 'price',
+ 'aggregate',
+ 'status_name',
],
- ]) ?>
+
+ ]); ?>
diff --git a/backend/web/css/AdminLTE.css b/backend/web/css/AdminLTE.css
index 93e60d9..fcc9471 100755
--- a/backend/web/css/AdminLTE.css
+++ b/backend/web/css/AdminLTE.css
@@ -2554,6 +2554,7 @@ a:focus {
}
.table-bordered {
border: 1px solid #f4f4f4;
+
}
.table-bordered > thead > tr > th,
.table-bordered > tbody > tr > th,
diff --git a/backend/web/js/cart.js b/backend/web/js/cart.js
new file mode 100644
index 0000000..bbe80b1
--- /dev/null
+++ b/backend/web/js/cart.js
@@ -0,0 +1,14 @@
+$(function(){
+
+ // cart\view.php
+ // для каждой строки обрабатываем клик по ссылке
+ $('.cartModalViewButton').click(function (){
+ // находим контейнер с модальным контентом и подгружаем в него по аджаксу результат
+ $('#modal').modal('show')
+ .find('.modalContent')
+ .load($(this).attr('value')); // в 'value' - у нас указан путь с гет параметрами к конроллеру
+ $.pjax.reload({container:'#gridViewContent'});
+ });
+
+});
+
diff --git a/common/models/Cart.php b/common/models/Cart.php
index 7563991..83cada0 100755
--- a/common/models/Cart.php
+++ b/common/models/Cart.php
@@ -2,6 +2,7 @@
namespace common\models;
+use backend\models\Importers;
use Yii;
/**
@@ -44,6 +45,18 @@ class Cart extends \backend\components\base\BaseActiveRecord
];
}
+ public function getImporter ()
+ {
+ return Importers::findOne(['id' => $this->import_id])->name;
+ }
+ public function getStatus_name ()
+ {
+ return DicStatuses::findOne(['id' => $this->status])->name;
+ }
+ public function getAggregate ()
+ {
+ return (float)$this->price * (float)$this->count;
+ }
/**
* @inheritdoc
*/
@@ -52,15 +65,18 @@ class Cart extends \backend\components\base\BaseActiveRecord
return [
'bill_id' => Yii::t('app', 'Bill ID'),
'account_id' => Yii::t('app', 'Account ID'),
- 'count' => Yii::t('app', 'Count'),
- 'price' => Yii::t('app', 'Price'),
+ 'count' => Yii::t('app', 'Кол-во'),
+ 'price' => Yii::t('app', 'Цена'),
'price_purchase' => Yii::t('app', 'Price Purchase'),
- 'status' => Yii::t('app', 'Status'),
- 'article' => Yii::t('app', 'Article'),
- 'brand' => Yii::t('app', 'Brand'),
- 'descr' => Yii::t('app', 'Descr'),
+ 'status' => Yii::t('app', 'id status'),
+ 'status_name' => Yii::t('app', 'Статус'),
+ 'article' => Yii::t('app', 'Артикул'),
+ 'brand' => Yii::t('app', 'Бренд'),
+ 'descr' => Yii::t('app', 'Описание'),
'import_id' => Yii::t('app', 'Import ID'),
+ 'importer' => Yii::t('app', 'Поставщик'),
'timestamp' => Yii::t('app', 'Timestamp'),
+ 'aggregate' => Yii::t('app', 'Сумма'),
];
}
}
diff --git a/common/models/CartBillsSearch.php b/common/models/CartBillsSearch.php
index 2fbca4d..5e32224 100644
--- a/common/models/CartBillsSearch.php
+++ b/common/models/CartBillsSearch.php
@@ -52,9 +52,15 @@ class CartBillsSearch extends CartBillsView
$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;
+
+ }
+
+ if ( !$params || !$params['CartBillsSearch'] ) {
+ // если не переданы параметры - показываем первые 100 записей
+ $query->limit = 100;
+
}
$query->andFilterWhere([
@@ -63,22 +69,15 @@ class CartBillsSearch extends CartBillsView
'status_id' => $this->status,
]);
- if($this->dt !== null || $this->date_to !== null){
- $date_from = mktime(0,0,0,(int)substr($this->dt,4,2),(int)substr($this->dt,1,2),(int)substr($this->dt,7,4));
- $date_to = mktime(23,59,59,(int)substr($this->date_to,4,2),(int)substr($this->date_to,1,2),(int)substr($this->date_to,7,4));
+ if( !empty( $this->dt ) || !empty( $this->date_to ) ){
+ $date_from = \Yii::$app->converter->convertTo( 'timestamp', $this->dt );
+ $date_to = \Yii::$app->converter->convertTo( 'timestamp', $this->date_to, ['begin_of_the_day' => false] );
$query->andFilterWhere([
'between', 'dt', $date_from, $date_to
]);
- }
-
-
-// $query->andFilterWhere(['like', 'f1', $this->f1])
-// ->andFilterWhere(['like', 'f2', $this->f2])
-// ->andFilterWhere(['like', 'f3', $this->f3])
-// ->andFilterWhere(['like', 'message', $this->message])
-// ->andFilterWhere(['like', 'delivery', $this->delivery]);
+ }
return $dataProvider;
}
diff --git a/tests/runtime/cache/co/converter.bin b/tests/runtime/cache/co/converter.bin
deleted file mode 100644
index c7f1c25..0000000
--- a/tests/runtime/cache/co/converter.bin
+++ /dev/null
@@ -1 +0,0 @@
-a:2:{i:0;a:3:{s:5:"class";s:42:" common\components\parsers\CustomConverter";s:13:"configuration";a:2:{s:5:"brand";a:2:{i:0;s:5:"BRAND";i:1;s:11:"CROSS_BRAND";}s:7:"crosses";a:0:{}}s:6:"hasKey";i:1;}i:1;N;}
\ No newline at end of file
diff --git a/tests/runtime/cache/pa/parser.bin b/tests/runtime/cache/pa/parser.bin
new file mode 100644
index 0000000..3f56985
--- /dev/null
+++ b/tests/runtime/cache/pa/parser.bin
@@ -0,0 +1 @@
+a:2:{i:0;a:7:{s:5:"class";s:41:"common\components\parsers\CustomCsvParser";s:22:"auto_detect_first_line";b:1;s:19:"min_column_quantity";i:4;s:14:"converter_conf";a:3:{s:5:"class";s:42:" common\components\parsers\CustomConverter";s:6:"hasKey";i:1;s:13:"configuration";a:2:{s:5:"brand";a:2:{i:0;s:5:"BRAND";i:1;s:11:"CROSS_BRAND";}s:7:"crosses";a:0:{}}}s:12:"basic_column";a:5:{s:0:"";s:10:"Пусто";s:7:"ARTICLE";s:14:"Артикул";s:13:"CROSS_ARTICLE";s:25:"Кросс артикул";s:5:"BRAND";s:10:"Бренд";s:11:"CROSS_BRAND";s:21:"Кросс бренд";}s:4:"file";i:0;s:9:"file_path";s:57:"C:\xampp\htdocs\ital\tests\_data\parser\crosses\test1.csv";}i:1;N;}
\ No newline at end of file
diff --git a/tests/unit/CrossesParsingTest.php b/tests/unit/CrossesParsingTest.php
index 9bd6bef..92d637e 100755
--- a/tests/unit/CrossesParsingTest.php
+++ b/tests/unit/CrossesParsingTest.php
@@ -19,18 +19,6 @@ class CrossesParsingTest extends \Codeception\TestCase\Test
{
$this->options[ 'mode' ] = 'crosses';
- $this->options[ 'crosses' ] = [
- 'class' => 'common\components\parsers\CustomCsvParser',
- 'auto_detect_first_line' => true,
- 'min_column_quantity' => 4,
- 'keys' =>['ARTICLE', 'CROSS_ARTICLE', 'BRAND', 'CROSS_BRAND'],
- 'converter_conf' => [
- 'class' => ' common\components\parsers\CustomConverter',
- 'configuration' => [
- "brand" => ['BRAND', 'CROSS_BRAND'],
- "crosses" => [],
- ]]
- ];
$this->file_path = Yii::getAlias('@data_parser') . '\crosses\test1.csv';
--
libgit2 0.21.4