add editable account on reception/customer-cart, add towel handling
This commit is contained in:
130
frontend/models/LogSearch.php
Normal file
130
frontend/models/LogSearch.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Log;
|
||||
use yii\db\Expression;
|
||||
use yii\db\Query;
|
||||
use common\components\Helper;
|
||||
|
||||
/**
|
||||
* LogSearch represents the model behind the search form about `common\models\Log`.
|
||||
*/
|
||||
class LogSearch extends Log
|
||||
{
|
||||
|
||||
public $start;
|
||||
public $end;
|
||||
public $timestampStart;
|
||||
public $timestampEnd;
|
||||
|
||||
public $card;
|
||||
public $customer;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
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' ],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = new Query();
|
||||
$query->select([
|
||||
'log.id_log as log_id_log',
|
||||
'log.created_at as log_created_at',
|
||||
'log.message as log_message',
|
||||
'user.username as user_username',
|
||||
'customer.name as customer_name',
|
||||
new Expression("case when log.type = " .Log::$TYPE_TOWEL_IN ." then 'Visszaad' ".
|
||||
" when log.type = ". Log::$TYPE_TOWEL_OUT . " then 'Bérel' ".
|
||||
" else '-' end as log_type")
|
||||
|
||||
]);
|
||||
$query->from("log");
|
||||
$query->leftJoin("user"," user.id = log.id_user");
|
||||
$query->leftJoin("customer"," customer.id_customer = log.id_customer");
|
||||
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'sort' =>[
|
||||
'defaultOrder' => [ 'log_created_at' => SORT_DESC],
|
||||
'attributes' => Helper::mkYiiSortItems([
|
||||
['log_id_log'],
|
||||
['log_created_at'],
|
||||
['log_message'],
|
||||
['log_app'],
|
||||
['log_app'],
|
||||
['user_username'],
|
||||
['customer_name'],
|
||||
['log_type'],
|
||||
|
||||
])
|
||||
|
||||
]
|
||||
]);
|
||||
|
||||
$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->andFilterWhere(['>=', 'log.created_at', $this->timestampStart]);
|
||||
$query->andFilterWhere(['<', 'log.created_at', $this->timestampEnd]);
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id_log' => $this->id_log,
|
||||
'type' => $this->type,
|
||||
'id_user' => $this->id_user,
|
||||
'id_transfer' => $this->id_transfer,
|
||||
'id_money_movement' => $this->id_money_movement,
|
||||
'id_ticket' => $this->id_ticket,
|
||||
'id_sale' => $this->id_sale,
|
||||
'id_customer' => $this->id_customer,
|
||||
'id_account' => $this->id_account,
|
||||
'id_account_state' => $this->id_account_state,
|
||||
'id_key' => $this->id_key,
|
||||
'id_product' => $this->id_product,
|
||||
'id_door_log' => $this->id_door_log,
|
||||
'created_at' => $this->created_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'message', $this->message])
|
||||
->andFilterWhere(['like', 'url', $this->url])
|
||||
->andFilterWhere(['like', 'app', $this->app]);
|
||||
|
||||
|
||||
$query->andWhere(['in', 'log.type',[Log::$TYPE_TOWEL_IN,Log::$TYPE_TOWEL_OUT]]);
|
||||
$query->andWhere([ '=', 'customer.id_customer' , $this->customer->id_customer]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user