add collections to backend

This commit is contained in:
2015-11-04 15:39:02 +01:00
parent 48a00e4bdc
commit 4303409fe2
22 changed files with 212 additions and 266 deletions

View File

@@ -2,12 +2,22 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use frontend\components\HtmlHelper;
use kartik\widgets\DateTimePicker;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model backend\models\CollectionSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
$accountOptions = ['' =>Yii::t('frontend/collection','All')]+ HtmlHelper::mkAccountOptions($model->accounts);
$userOptions = ['' =>Yii::t('frontend/collection','All')]+ ArrayHelper::map($model->users,'id','username');
?>
<div class="collection-search">
<?php $form = ActiveForm::begin([
@@ -15,29 +25,35 @@ use yii\widgets\ActiveForm;
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_collection') ?>
<?= $form->field($model, 'id_user') ?>
<?= $form->field($model, 'created_by') ?>
<?= $form->field($model, 'id_account') ?>
<?= $form->field($model, 'money') ?>
<?php // echo $form->field($model, 'start') ?>
<?php // echo $form->field($model, 'end') ?>
<?php // echo $form->field($model, 'type') ?>
<?php // echo $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'id_account')->dropDownList( $accountOptions ) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'id_user')->dropDownList( $userOptions ) ?>
</div>
<div class="col-md-3">
<?= $form->field($model, 'start')->widget(DateTimePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd hh:ii'
]
]) ?>
</div>
<div class="col-md-3">
<?= $form->field($model, 'end') ->widget(DateTimePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd hh:ii'
]
]) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('backend/collection', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('backend/collection', 'Reset'), ['class' => 'btn btn-default']) ?>
<?= Html::submitButton(Yii::t('frontend/collection', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>

View File

@@ -15,27 +15,37 @@ $this->params['breadcrumbs'][] = $this->title;
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('backend/collection', 'Create Collection'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id_collection',
'id_user',
'created_by',
'id_account',
'money',
// 'start',
// 'end',
// 'type',
// 'created_at',
// 'updated_at',
[
'attribute' => 'id_user',
'value' => 'userName',
],
[
'attribute' => 'id_account',
'value' => 'accountName',
],
'money:integer',
[
'attribute' => 'start',
'value' => function($model){
return Yii::$app->formatter->asDatetime($model->start,'yyyy-MM-dd HH:mm:ss');
}
],
[
'attribute' => 'end',
'value' => function($model){
return Yii::$app->formatter->asDatetime($model->end,'yyyy-MM-dd HH:mm:ss');
}
],
'created_at:datetime',
['class' => 'yii\grid\ActionColumn'],
['class' => 'yii\grid\ActionColumn',
'template' => '{view}'
],
],
]); ?>

View File

@@ -2,6 +2,7 @@
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\components\AccountStatisticWidget;
/* @var $this yii\web\View */
/* @var $model common\models\Collection */
@@ -14,31 +15,30 @@ $this->params['breadcrumbs'][] = $this->title;
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('backend/collection', 'Update'), ['update', 'id' => $model->id_collection], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('backend/collection', 'Delete'), ['delete', 'id' => $model->id_collection], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('backend/collection', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id_collection',
'id_user',
'created_by',
'id_account',
'money',
'start',
'end',
'type',
'created_at',
'updated_at',
[
'attribute' =>'id_user',
'value' => $model->userName
],
[
'attribute' =>'id_account',
'value' => $model->accountName
],
'money:integer',
'start:datetime',
'end:datetime',
'created_at:datetime',
],
]) ?>
<?php
echo AccountStatisticWidget::widget([
'totals' => $totals
]);
?>
</div>

View File

@@ -26,7 +26,7 @@ use kartik\widgets\DatePicker;
<?= $form->field($model, 'id_account')->dropDownList( ['' => Yii::t('common/transfer', 'All')] +HtmlHelper::mkAccountOptions($accounts) ) ?>
</div>
<div class='col-md-4'>
<?= $form->field($model, 'type')->dropDownList( ['' => Yii::t('common/transfer', 'All')] + Transfer::types() ) ?>
<?php echo $form->field($model, 'types')->checkboxList( Transfer::types()) ?>
</div>
<div class='col-md-4'>
<?= $form->field($model, 'id_user')->dropDownList( ['' => Yii::t('common/transfer', 'All')] +ArrayHelper::map($users,'id' , 'username') ) ?>

View File

@@ -6,6 +6,7 @@ use yii\widgets\DetailView;
use yii\base\Widget;
use yii\base\Object;
use yii\data\ArrayDataProvider;
use common\components\AccountStatisticWidget;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\TransferSearch */
@@ -28,42 +29,15 @@ $this->params['breadcrumbs'][] = $this->title;
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel, 'accounts' => $accounts,'users' => $users,]); ?>
<?php
echo AccountStatisticWidget::widget([
'totals' => $searchModel->totals
]);
?>
<h2>Összesen</h2>
<?php
echo DetailView::widget([
'model' => $searchModel->fullTotal,
'attributes' => [
[
'value' => $searchModel->fullTotal['money'],
'label' => $searchModel->fullTotal['label'],
],
]
])
?>
<h2>Kasszák összesen</h2>
<?php
echo GridView::widget([
'dataProvider' => new ArrayDataProvider([
'allModels' => $searchModel->accountTotals,
'sort' => false,
'pagination' => false,
]) ,
'columns' => [
[
'label' => Yii::t('common/transfer','Account'),
'value' => 'label'
],
[
'label' => Yii::t('common/transfer','Money total'),
'value' => 'money'
],
]
]
);
?>
<h2>Pénzmozgások</h2>
<h2>Tranzakciók</h2>
<?= GridView::widget([
'tableOptions' => ['class' => 'table table-striped table-bordered table-transfer'],
'dataProvider' => $dataProvider,