diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php
index 0c26d78..d33943c 100644
--- a/backend/components/AdminMenuStructure.php
+++ b/backend/components/AdminMenuStructure.php
@@ -130,12 +130,12 @@ class AdminMenuStructure{
// Kap lug megbízások
/////////////////////////////
$items = [];
- $items[] = ['label' => 'Mozgások', 'url' => ['/door-log/index' , 'DoorLogSearch[start]' =>$today,'DoorLogSearch[end]' => $tomorrow ] ];
+ $items[] = ['label' => 'Kártya események', 'url' => ['/door-log/index' , 'DoorLogSearch[start]' =>$todayDatetime,'DoorLogSearch[end]' => $tomorrowDatetime ] ];
// $items[] = ['label' => 'Részletek aktiválása', 'url' => ['/ugiro/parts' ] ];
// $items[] = ['label' => 'Bevétel', 'url' => ['/transfer/summary' , 'TransferSummarySearch[start]' =>$today,'TransferSummarySearch[end]' => $tomorrow ] ];
// $items[] = ['label' => 'Napi bevételek', 'url' => ['/transfer/list', 'TransferListSearch[start]' =>$todayDatetime,'TransferListSearch[end]' => $tomorrowDatetime ] ];
// $items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
- $this->menuItems[] = ['label' => 'Forgóvilla', 'url' => $this->emptyUrl,
+ $this->menuItems[] = ['label' => 'Események', 'url' => $this->emptyUrl,
'items' => $items
];
diff --git a/backend/models/DoorLogSearch.php b/backend/models/DoorLogSearch.php
index 6bad50b..99f15aa 100644
--- a/backend/models/DoorLogSearch.php
+++ b/backend/models/DoorLogSearch.php
@@ -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;
+
+ }
}
diff --git a/backend/views/door-log/_search.php b/backend/views/door-log/_search.php
index 5313484..2795ff4 100644
--- a/backend/views/door-log/_search.php
+++ b/backend/views/door-log/_search.php
@@ -3,6 +3,8 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\widgets\DatePicker;
+use backend\models\DoorLogSearch;
+use kartik\widgets\DateTimePicker;
/* @var $this yii\web\View */
/* @var $model backend\models\DoorLogSearch */
@@ -26,11 +28,13 @@ use kartik\widgets\DatePicker;
- = $form->field($model, 'searchKeyName') ?>
+
+ = $form->field($model, 'id_customer')->label("Vendég azon.") ?>
- = $form->field($model, 'direction')->dropDownList(['' => 'Mind' ] + []) ?>
+ = $form->field($model, 'searchKeyName') ?>
+
@@ -39,26 +43,31 @@ use kartik\widgets\DatePicker;
field($model, 'created_at') ?>
+
+ = $form->field($model, 'direction')->dropDownList(['' => 'Mind' ] + DoorLogSearch::getAllDoorLog() ) ?>
+
- = $form->field($model, 'start')->widget(DatePicker::classname(), [
+
+ = $form->field($model, 'start')->widget(DateTimePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
- 'format' => 'yyyy.mm.dd'
+ 'format' => 'yyyy.mm.dd hh:ii'
]
- ]) ?>
+ ]) ?>
+
- = $form->field($model, 'end') ->widget(DatePicker::classname(), [
+ = $form->field($model, 'end') ->widget(DateTimePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
- 'format' => 'yyyy.mm.dd'
+ 'format' => 'yyyy.mm.dd hh:ii'
]
- ]) ?>
+ ]) ?>
- = Html::submitButton(Yii::t('common/door_log', 'Search'), ['class' => 'btn btn-primary']) ?>
+ = Html::submitButton(Yii::t('common/door_log', 'Keresés'), ['class' => 'btn btn-primary']) ?>
diff --git a/backend/views/door-log/index.php b/backend/views/door-log/index.php
index a1b0f01..d60e3e7 100644
--- a/backend/views/door-log/index.php
+++ b/backend/views/door-log/index.php
@@ -2,12 +2,15 @@
use yii\helpers\Html;
use yii\grid\GridView;
+use common\components\Helper;
+use common\models\DoorLog;
+use common\models\Card;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\DoorLogSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
-$this->title = Yii::t('common/door_log', 'Mozgások');
+$this->title = Yii::t('common/door_log', 'Kártya események');
$this->params['breadcrumbs'][] = $this->title;
?>
@@ -19,26 +22,52 @@ $this->params['breadcrumbs'][] = $this->title;
= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
- ['class' => 'yii\grid\SerialColumn'],
- [
- 'attribute' => 'id_card',
- 'value' => 'cardNumber'
+ [
+ 'attribute' => 'door_log_created_at',
+ 'label' => "Időpont",
+ 'value' => 'door_log_created_at',
+ 'format' => 'datetime'
],
[
- 'attribute' => 'id_key',
- 'value' => 'keyNumber'
+ 'attribute' => 'card_number',
+ 'label' => 'Kártya szám'
],
[
- 'attribute' => 'id_customer',
- 'value' => 'customerName'
+ 'attribute' => 'door_log_type',
+ 'label' => 'Kártya típus',
+ 'value' => function ($model, $key, $index, $column){
+ return Helper::getArrayValue(Card::types(), $model['door_log_type'], "-");
+ }
],
[
- 'attribute' => 'direction',
- 'value' => 'directionName'
+ 'attribute' => 'key_number',
+ 'label' => 'Kulcs'
],
+ [
+ 'attribute' => 'customer_id_customer',
+ 'label' => 'Vendég azon.'
+ ],
+ [
+ 'attribute' => 'customer_name',
+ 'label' => 'Vendég'
+ ],
+ [
+ 'attribute' => 'door_log_direction',
+ 'label' => 'Esemény',
+ 'value' => function ($model, $key, $index, $column){
+ return Helper::getArrayValue(DoorLog::getDirectionTypes(), $model['door_log_direction'],"-" );
+ }
+ ],
+ [
+ 'attribute' => 'door_log_source_app',
+ 'label' => 'Forrás alkalmazás',
+ 'value' => function ($model, $key, $index, $column){
+ return DoorLog::getSourceAppName($model['door_log_source_app']);
+ }
+ ],
+ /*
// 'type',
- 'created_at:datetime',
-
+ */
],
]); ?>
diff --git a/common/models/DoorLog.php b/common/models/DoorLog.php
index d17a128..3456c64 100644
--- a/common/models/DoorLog.php
+++ b/common/models/DoorLog.php
@@ -3,6 +3,7 @@
namespace common\models;
use Yii;
+use common\components\Helper;
/**
* This is the model class for table "door_log".
@@ -14,9 +15,13 @@ use Yii;
* @property integer $direction
* @property integer $type
* @property string $created_at
+ * @property string $source_app
*/
class DoorLog extends \yii\db\ActiveRecord
{
+
+ public static $SOURCE_APP_FORGO_VILLA = "forgo_villa";
+ public static $SOURCE_APP_FITNESS_ADMIN = "fitness_admin";
/**
* @inheritdoc
*/
@@ -47,9 +52,10 @@ class DoorLog extends \yii\db\ActiveRecord
'id_card' => Yii::t('common/door_log', 'Bérlet kártya'),
'id_customer' => Yii::t('common/door_log', 'Vendég'),
'id_key' => Yii::t('common/door_log', 'Kulcs'),
- 'direction' => Yii::t('common/door_log', 'Irány'),
+ 'direction' => Yii::t('common/door_log', 'Esemény'),
'type' => Yii::t('common/door_log', 'Típus'),
'created_at' => Yii::t('common/door_log', 'Időpont'),
+ 'source_app' => Yii::t('common/door_log', 'Eszköz'),
];
}
@@ -88,9 +94,49 @@ class DoorLog extends \yii\db\ActiveRecord
}
public function getDirectionName(){
$result = "";
- if (isset($this->direction)){
- $result = $this->direction;
+ if ( $this->source_app == 'forgo_villa'){
+ if (isset($this->direction)){
+ $result = Helper::getArrayValue(self::getDirectionTypes() , $this->direction, "-");
+ }
+ }else{
+ $result = "Kézi olvasás";
}
return $result;
}
+
+
+ public static function getSourceAppName($source_app){
+ $result = "";
+ switch ($source_app){
+ case self::$SOURCE_APP_FITNESS_ADMIN :
+ $result = "Recepciós alkalmazás";
+ break;
+ case self::$SOURCE_APP_FORGO_VILLA:
+ $result = "Forgó villa";
+ break;
+ }
+ return $result;
+ }
+
+ public static function getDirectionTypes( ){
+ return [
+ 0 => "Kézi olvasás",
+
+ 1 => "KI olvastatás mozgás nélkül",
+
+ 3 => "BE olvastatás mozgás nélkül",
+
+ 5 => "KI mozgás",
+
+ 7 => "BE mozgás",
+
+ 9 => "KI olvastatás, van érvényes öltöző kulcs (nem enged)",
+
+ 11 => "BE olvastatás, nincs érvényes öltöző kulcs (nem enged)",
+
+ 17 => "Bérlet érvényességi időn kívüli KI olvastatás (nem enged)",
+
+ 19 => "Bérlet érvényességi időn kívüli BE olvastatás (nem enged)",
+ ];
+ }
}
diff --git a/console/migrations/m160215_182850_alter__table__door_log_add_column__source_app.php b/console/migrations/m160215_182850_alter__table__door_log_add_column__source_app.php
new file mode 100644
index 0000000..ca0de88
--- /dev/null
+++ b/console/migrations/m160215_182850_alter__table__door_log_add_column__source_app.php
@@ -0,0 +1,30 @@
+addColumn("door_log", "source_app", "varchar(20) default 'forgo_villa' ");
+ }
+
+ public function down()
+ {
+ echo "m160215_182850_alter__table__door_log_add_column__source_app cannot be reverted.\n";
+
+ return false;
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}
diff --git a/frontend/controllers/CustomerController.php b/frontend/controllers/CustomerController.php
index 36f35a1..6b61d50 100644
--- a/frontend/controllers/CustomerController.php
+++ b/frontend/controllers/CustomerController.php
@@ -54,7 +54,7 @@ class CustomerController extends Controller
$model->number = $number;
$model->readCard();
-
+ $model->mkDoorLog();
if ( $model->isFreeCard() ){
return $this->redirect([ 'create', 'number' => $model->card->number ]);
diff --git a/frontend/models/ReceptionForm.php b/frontend/models/ReceptionForm.php
index b6f7c68..e97eb4c 100644
--- a/frontend/models/ReceptionForm.php
+++ b/frontend/models/ReceptionForm.php
@@ -14,6 +14,8 @@ use common\models\Key;
use common\models\CardKeyAssignment;
use common\models\Contract;
use yii\db\Expression;
+use common\components\Helper;
+use common\models\DoorLog;
/**
* ContactForm is the model behind the contact form.
@@ -52,7 +54,7 @@ class ReceptionForm extends Model
public function readCard(){
- $this->number = str_replace("ö", "0", $this->number);
+ $this->number = Helper::fixAsciiChars( $this->number );
$query = Card::find();
$query->leftJoin("card_key_assignment", 'card.id_card = card_key_assignment.id_card');
@@ -89,6 +91,32 @@ class ReceptionForm extends Model
}
+ public function mkDoorLog(){
+
+ if ( !isset($this->card)){
+ return;
+ }
+
+ $dlog = new DoorLog();
+ $dlog->id_card = $this->card->id_card;
+
+ if ( isset($this->customer)){
+ $dlog->id_customer = $this->customer->id_customer;
+ }
+
+ $key = $this->getFirstKey();
+
+ if ( isset($key)){
+ $dlog->id_key = $key->id_key;
+ }
+ $dlog->direction = 0;
+ $dlog->type = $this->card->type;
+ $dlog->source_app = DoorLog::$SOURCE_APP_FITNESS_ADMIN;
+
+ $dlog->created_at = date('Y-m-d H:i:s');
+ $dlog->save(false);
+ }
+
public function readAssignedKeys(){
$query = Key::find();
$query->join( 'INNER JOIN', CardKeyAssignment::tableName() , Key::tableName().".id_key = " . CardKeyAssignment::tableName() . ".id_key");
@@ -97,6 +125,14 @@ class ReceptionForm extends Model
}
+ public function getFirstKey(){
+ $result = null;
+ if ( isset($this->keys) && is_array($this->keys) && count($this->keys) > 0 ){
+ $esut = $this->keys[0];
+ }
+ return $result;
+ }
+
public function readLastCassaState(){
$a = Account::readDefault();
if ( isset($a)){