add totals to frontend collection/index
This commit is contained in:
parent
cee5d60d9d
commit
9751e7756e
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
|
use common\components\AccountTotalWidget;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $searchModel backend\models\CollectionSearch */
|
/* @var $searchModel backend\models\CollectionSearch */
|
||||||
@ -15,6 +16,16 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4 ">
|
||||||
|
<?php
|
||||||
|
echo AccountTotalWidget::widget([
|
||||||
|
'statistic' => $searchModel->totals
|
||||||
|
])?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<?= GridView::widget([
|
<?= GridView::widget([
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
|
|||||||
@ -29,7 +29,8 @@ class CollectionSearch extends Collection
|
|||||||
return [
|
return [
|
||||||
[[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
[[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||||
[[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
[[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||||
];
|
[['id_account'],'integer']
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,12 +59,15 @@ class CollectionSearch extends Collection
|
|||||||
|
|
||||||
$this->load($params);
|
$this->load($params);
|
||||||
|
|
||||||
|
$this->id_user = Yii::$app->user->id;
|
||||||
|
|
||||||
if (!$this->validate()) {
|
if (!$this->validate()) {
|
||||||
// uncomment the following line if you do not want to return any records when validation fails
|
// uncomment the following line if you do not want to return any records when validation fails
|
||||||
// $query->where('0=1');
|
// $query->where('0=1');
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'id_account' => $this->id_account,
|
'id_account' => $this->id_account,
|
||||||
]);
|
]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user