Add door log changes, direction types, and manual reading event
This commit is contained in:
@@ -6,6 +6,7 @@ use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\DoorLog;
|
||||
use yii\db\Query;
|
||||
|
||||
/**
|
||||
* DoorLogSearch represents the model behind the search form about `common\models\DoorLog`.
|
||||
@@ -32,8 +33,10 @@ class DoorLogSearch extends DoorLog
|
||||
[[ 'direction', 'type'], 'integer'],
|
||||
[['created_at'], 'safe'],
|
||||
[['searchCardNumber','searchCustomerName','searchKeyName'], 'safe'],
|
||||
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
// [[ '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' ],
|
||||
|
||||
];
|
||||
}
|
||||
@@ -44,7 +47,7 @@ class DoorLogSearch extends DoorLog
|
||||
'searchCustomerName' => 'Vendég',
|
||||
'searchKeyName' => 'Kulcs szám',
|
||||
'type' => 'Típus',
|
||||
'direction' => 'Irány',
|
||||
'direction' => 'Esemény',
|
||||
'start' => 'Időszak kezdete',
|
||||
'end' => 'Időszak vége'
|
||||
];
|
||||
@@ -68,33 +71,61 @@ class DoorLogSearch extends DoorLog
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = DoorLog::find();
|
||||
$query = new Query();
|
||||
$query->select([
|
||||
'door_log.id_door_log as door_log_id',
|
||||
'card.number as card_number',
|
||||
'door_log.type as door_log_type',
|
||||
'key.number as key_number',
|
||||
'customer.name as customer_name',
|
||||
'customer.id_customer as customer_id_customer',
|
||||
'door_log.direction as door_log_direction',
|
||||
'door_log.created_at as door_log_created_at',
|
||||
'door_log.source_app as door_log_source_app'
|
||||
]);
|
||||
$query->from('door_log');
|
||||
$query->innerJoin('card','card.id_card = door_log.id_card');
|
||||
$query->leftJoin('key','key.id_key = door_log.id_key');
|
||||
$query->leftJoin('customer','customer.id_customer = door_log.id_customer');
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'sort' =>[
|
||||
'defaultOrder' =>[ 'door_log_created_at' => SORT_DESC ],
|
||||
'attributes' => [
|
||||
// 'age',
|
||||
'id_card' => [
|
||||
'card_number' => [
|
||||
'asc' => ['card.number' => SORT_ASC ],
|
||||
'desc' => ['card.number' => SORT_DESC],
|
||||
],
|
||||
'id_key' => [
|
||||
'key_number' => [
|
||||
'asc' => ['key.number' => SORT_ASC ],
|
||||
'desc' => ['key.number' => SORT_DESC],
|
||||
],
|
||||
'id_customer' => [
|
||||
'customer_name' => [
|
||||
'asc' => ['customer.name' => SORT_ASC ],
|
||||
'desc' => ['customer.name' => SORT_DESC],
|
||||
],
|
||||
'direction' => [
|
||||
'customer_id_customer' => [
|
||||
'asc' => ['customer.id_customer' => SORT_ASC ],
|
||||
'desc' => ['customer.id_customer' => SORT_DESC],
|
||||
],
|
||||
'door_log_direction' => [
|
||||
'asc' => ['door_log.direction' => SORT_ASC ],
|
||||
'desc' => ['door_log.direction' => SORT_DESC],
|
||||
],
|
||||
'created_at' => [
|
||||
'door_log_created_at' => [
|
||||
'asc' => ['door_log.created_at' => SORT_ASC ],
|
||||
'desc' => ['door_log.created_at' => SORT_DESC],
|
||||
],
|
||||
'door_log_source_app' => [
|
||||
'asc' => ['door_log.source_app' => SORT_ASC ],
|
||||
'desc' => ['door_log.source_app' => SORT_DESC],
|
||||
],
|
||||
'door_log_type' =>[
|
||||
'asc' => ['door_log.type' => SORT_ASC ],
|
||||
'desc' => ['door_log.type' => SORT_DESC],
|
||||
]
|
||||
],
|
||||
]
|
||||
]);
|
||||
@@ -103,7 +134,7 @@ class DoorLogSearch extends DoorLog
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
$query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
@@ -112,7 +143,9 @@ class DoorLogSearch extends DoorLog
|
||||
// 'id_card' => $this->id_card,
|
||||
// 'id_customer' => $this->id_customer,
|
||||
// 'id_key' => $this->id_key,
|
||||
'direction' => $this->direction,
|
||||
'direction' => $this->direction,
|
||||
'id_customer' => $this->id_customer
|
||||
|
||||
// 'type' => $this->type,
|
||||
// 'created_at' => $this->created_at,
|
||||
]);
|
||||
@@ -120,9 +153,6 @@ class DoorLogSearch extends DoorLog
|
||||
$query->andFilterWhere(['>=', 'door_log.created_at', $this->timestampStart]);
|
||||
$query->andFilterWhere(['<', 'door_log.created_at', $this->timestampEnd]);
|
||||
|
||||
$query->innerJoin('card','card.id_card = door_log.id_card');
|
||||
$query->leftJoin('key','key.id_key = door_log.id_key');
|
||||
$query->leftJoin('customer','customer.id_customer = door_log.id_customer');
|
||||
|
||||
if ( !empty($this->searchCardNumber)){
|
||||
$query->andWhere(['or',
|
||||
@@ -144,4 +174,11 @@ class DoorLogSearch extends DoorLog
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
public static function getAllDoorLog(){
|
||||
$result = DoorLog::getDirectionTypes();
|
||||
$result = $result + [ 0 => "Kézi olvasás" ];
|
||||
return $result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user