add frontend collection

This commit is contained in:
2015-11-04 12:33:45 +01:00
parent ed9c1e77cd
commit 48a00e4bdc
17 changed files with 370 additions and 194 deletions

View File

@@ -24,13 +24,15 @@ class TransferSearch extends Transfer
public $timestampStart;
public $timestampEnd;
public $totalsCreatedAt = ['total' => 0, 'accounts' =>[] ];
public $totalsCreatedAtNotPaid= ['total' => 0, 'accounts' =>[]];
public $totalsCreatedAtPaid= ['total' => 0, 'accounts' =>[]];
public $totalsPaidAt= ['total' => 0, 'accounts' =>[]];
public $totalsPaidAtNotCreatedAt= ['total' => 0, 'accounts' =>[]];
// public $totalsCreatedAt = ['total' => 0, 'accounts' =>[] ];
// public $totalsCreatedAtNotPaid= ['total' => 0, 'accounts' =>[]];
// public $totalsCreatedAtPaid= ['total' => 0, 'accounts' =>[]];
// public $totalsPaidAt= ['total' => 0, 'accounts' =>[]];
// public $totalsPaidAtNotCreatedAt= ['total' => 0, 'accounts' =>[]];
public $totals;
public $accounts;
public $types;
@@ -41,19 +43,12 @@ class TransferSearch extends Transfer
public function rules()
{
return [
// [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
// [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[[ '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' ],
[ [ 'id_account' ] , 'integer'],
['types', 'each', 'rule' => ['integer']],
// [ [ 'types' ], function ($attribute, $params) {
// if (!is_array($this->$attribute)) {
// $this->addError($attribute, 'Invalid array');
// }
// }],
];
}
@@ -103,9 +98,9 @@ class TransferSearch extends Transfer
'money' => 0
];
if ( $this->hasErrors() ){
return;
}
// if ( $this->hasErrors() ){
// return;
// }
@@ -113,13 +108,13 @@ class TransferSearch extends Transfer
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
$idUser = Yii::$app->user->id;
$totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
$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'];
// $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'];
}