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

@@ -6,21 +6,34 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Collection;
use common\components\Helper;
/**
* CollectionSearch represents the model behind the search form about `common\models\Collection`.
*/
class CollectionSearch extends Collection
{
public $accounts;
public $accountMap;
public $users;
public $timestampStart;
public $timestampEnd;
public $totals;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_collection', 'id_user', 'created_by', 'id_account', 'money', 'type'], 'integer'],
[['start', 'end', 'created_at', 'updated_at'], 'safe'],
];
return [
[[ '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','id_user'],'integer']
];
}
/**
@@ -56,18 +69,17 @@ class CollectionSearch extends Collection
}
$query->andFilterWhere([
'id_collection' => $this->id_collection,
'id_user' => $this->id_user,
'created_by' => $this->created_by,
'id_account' => $this->id_account,
'money' => $this->money,
'start' => $this->start,
'end' => $this->end,
'type' => $this->type,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
Helper::inInterval($query, 'collection.end', $this->timestampStart, $this->timestampEnd);
return $dataProvider;
}
public function searchTotal(){
$this->totals = Collection::mkReceptionTotal($this->timestampStart, $this->timestampEnd , Yii::$app->user->id, [Collection::TYPE_RECEPTION], $this->id_account, $this->accounts, $this->accountMap);
}
}