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

@@ -1,23 +0,0 @@
<?php
namespace frontend\components;
use yii\base\Widget;
class AccountStatisticWidget extends Widget{
public $totals;
public $viewFile = '//common/_account_statistic';
public function init(){
parent::init();
}
public function run(){
echo $this->render($this->viewFile,[ 'model' => $this ]);
}
}

View File

@@ -44,6 +44,7 @@ class CollectionController extends Controller
$searchModel->accounts = Account::read();
$searchModel->accountMap = Account::toAccaountMap($searchModel->accounts);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$searchModel->searchTotal();
@@ -62,7 +63,7 @@ class CollectionController extends Controller
{
$model = $this->findModel($id);
$accounts = Account::read();
$accounts = Account::read();
$accountMap = Account::toAccaountMap($accounts);
$totals = Transfer::mkTotals($model->start, $model->end, $model->id_user, null, $model->id_account, $accounts, $accountMap);

View File

@@ -14,6 +14,7 @@ class CollectionSearch extends Collection
{
public $accounts;
public $accountMap;
public $users;
public $timestampStart;
public $timestampEnd;

View File

@@ -68,13 +68,16 @@ class TransferSearch extends Transfer
'query' => $query,
]);
$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;
$query->where('0=1');
}
$query->andWhere(['id_user' => Yii::$app->user->id ] );
$query->andFilterWhere([
'id_account' => $this->id_account,
@@ -98,11 +101,6 @@ class TransferSearch extends Transfer
'money' => 0
];
// if ( $this->hasErrors() ){
// return;
// }
$accounts = Account::find()->orderBy("name asc")->all();
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
@@ -110,11 +108,6 @@ class TransferSearch extends Transfer
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
// $this->totalsCreatedAt = $totals['created_at'];
// $this->totalsPaidAt = $totals['paid_at'];
// $this->totalsCreatedAtPaid = $totals['created_at_paid'];
// $this->totalsCreatedAtNotPaid = $totals['created_at_not_paid'];
// $this->totalsPaidAtNotCreatedAt = $totals['paid_at_not_created_at'];
}

View File

@@ -2,8 +2,8 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\widgets\DateTimePicker;
use frontend\components\HtmlHelper;
use kartik\widgets\DateTimePicker;
/* @var $this yii\web\View */
/* @var $model frontend\models\CollectionSearch */

View File

@@ -2,7 +2,7 @@
use yii\helpers\Html;
use frontend\components\TransferTotalWidget;
use frontend\components\AccountStatisticWidget;
use common\components\AccountStatisticWidget;
/* @var $this yii\web\View */

View File

@@ -2,7 +2,7 @@
use yii\helpers\Html;
use yii\widgets\DetailView;
use frontend\components\AccountStatisticWidget;
use common\components\AccountStatisticWidget;
/* @var $this yii\web\View */
/* @var $model common\models\Collection */

View File

@@ -1,64 +0,0 @@
<?php
use common\components\AccountTotalWidget;
?>
<div class='row'>
<div class='col-md-4'>
<?php
echo AccountTotalWidget::widget([
'statistic' => $model->totals['created_at'],
'panelHeading' => 'Kiadva',
]);
?>
</div>
<div class='col-md-4'>
<?php
echo AccountTotalWidget::widget([
'statistic' => $model->totals['created_at_paid'],
'panelHeading' => 'Kiadva/fizetve',
]);
?>
</div>
<div class='col-md-4'>
<?php
echo AccountTotalWidget::widget([
'statistic' => $model->totals['created_at_not_paid'],
'panelHeading' => 'Kiadva/nem fizetve (Hitel)',
'panelType' => 'panel-danger'
]);
?>
</div>
</div>
<div class='row'>
<div class='col-md-4'>
</div>
<div class='col-md-4'>
<?php
echo AccountTotalWidget::widget([
'statistic' => $model->totals['paid_at_not_created_at'],
'panelHeading' => 'Adósság (Hitel)/Fizetve' ,
]);
?>
</div>
<div class='col-md-4'>
</div>
</div>
<div class='row'>
<div class='col-md-4'>
</div>
<div class='col-md-4'>
<?php
echo AccountTotalWidget::widget([
'statistic' => $model->totals['paid_at'],
'panelHeading' => 'Fizetve' ,
'panelType' => 'panel-success'
]);
?>
</div>
<div class='col-md-4'>
</div>
</div>

View File

@@ -1,7 +1,6 @@
<?php
use frontend\components\TransferTotalWidget;
use frontend\components\AccountStatisticWidget;
use common\components\AccountStatisticWidget;
?>
<?php

View File

@@ -48,7 +48,6 @@ use kartik\widgets\DateTimePicker;
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
</div>
<div class="col-md-4">
<?php //echo $form->field($model, 'type')->dropDownList( ['' =>'Mind']+ Transfer::types()) ?>
<?php echo $form->field($model, 'types')->checkboxList( Transfer::types()) ?>
</div>
</div>