add collections to backend
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user