From 3b2f19b90946300f8b0ffcde759b71ce8718e303 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Mon, 28 Dec 2015 21:03:52 +0100 Subject: [PATCH] add rfid_key to card and key --- backend/models/CardSearch.php | 3 +- backend/models/KeySearch.php | 4 ++- backend/views/card/_form.php | 1 + backend/views/card/_search.php | 3 ++ backend/views/card/index.php | 4 +++ backend/views/card/view.php | 1 + backend/views/key/_form.php | 1 + backend/views/key/_search.php | 12 ++++---- backend/views/key/index.php | 7 ++++- backend/views/key/view.php | 1 + common/messages/hu/common/card.php | 3 +- common/messages/hu/common/key.php | 2 ++ common/models/Card.php | 2 ++ common/models/Key.php | 11 +++++++ ...ter__table__customer__add__column__key.php | 2 +- ..._table__key__add__column__rfid__number.php | 30 +++++++++++++++++++ ...table__card__add__column__rfid__number.php | 30 +++++++++++++++++++ frontend/models/ReceptionForm.php | 2 +- 18 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 console/migrations/m151228_162443_alter__table__key__add__column__rfid__number.php create mode 100644 console/migrations/m151228_172909_alter__table__card__add__column__rfid__number.php diff --git a/backend/models/CardSearch.php b/backend/models/CardSearch.php index 3ae466e..5ddcbbd 100644 --- a/backend/models/CardSearch.php +++ b/backend/models/CardSearch.php @@ -23,7 +23,7 @@ class CardSearch extends Card { return [ [['id_card', 'status', 'type'], 'integer'], - [[ 'searchCustomerName', 'number', 'created_at', 'updated_at'], 'safe'], + [[ 'searchCustomerName', 'number','rfid_key', 'created_at', 'updated_at'], 'safe'], ]; } @@ -72,6 +72,7 @@ class CardSearch extends Card ]); $query->andFilterWhere(['like', 'card.number', $this->number]); + $query->andFilterWhere(['like', 'card.rfid_key', $this->rfid_key]); $query->andFilterWhere(['like', 'customer.name', $this->searchCustomerName]); return $dataProvider; diff --git a/backend/models/KeySearch.php b/backend/models/KeySearch.php index a35af44..9a004d9 100644 --- a/backend/models/KeySearch.php +++ b/backend/models/KeySearch.php @@ -20,7 +20,8 @@ class KeySearch extends Key return [ /*[['id_key', 'status', 'type'], 'integer'], [['number', 'created_at', 'updated_at'], 'safe'],*/ - [['number'], 'safe'] + [['number'], 'safe'], + [['rfid_key'], 'safe'] ]; } @@ -59,6 +60,7 @@ class KeySearch extends Key $query->andFilterWhere([ 'id_key' => $this->id_key, 'number' => $this->number, + 'rfid_key' => $this->rfid_key, 'status' => $this->status, 'type' => $this->type, 'created_at' => $this->created_at, diff --git a/backend/views/card/_form.php b/backend/views/card/_form.php index dfa41b0..3cd9972 100644 --- a/backend/views/card/_form.php +++ b/backend/views/card/_form.php @@ -14,6 +14,7 @@ use common\models\Card; field($model, 'number')->textInput(['maxlength' => true]) ?> + field($model, 'rfid_key')->textInput(['maxlength' => true]) ?> field($model, 'status')->dropDownList(Card::statuses()) ?> diff --git a/backend/views/card/_search.php b/backend/views/card/_search.php index cf109b4..36ab2e0 100644 --- a/backend/views/card/_search.php +++ b/backend/views/card/_search.php @@ -46,6 +46,9 @@ $statusOptions = mkOptions(Card::statuses());
field($model, 'searchCustomerName')->textInput() ?>
+
+ field($model, 'rfid_key')->textInput() ?> +
diff --git a/backend/views/card/index.php b/backend/views/card/index.php index 94d6086..32802f2 100644 --- a/backend/views/card/index.php +++ b/backend/views/card/index.php @@ -28,6 +28,10 @@ $this->params['breadcrumbs'][] = $this->title; 'attribute' => 'number', 'value' => 'number' ], + [ + 'attribute' => 'rfid_key', + 'value' => 'rfid_key' + ], [ 'attribute' => 'status', 'value' => 'statusHuman' diff --git a/backend/views/card/view.php b/backend/views/card/view.php index 4ab4efd..a6977f2 100644 --- a/backend/views/card/view.php +++ b/backend/views/card/view.php @@ -22,6 +22,7 @@ $this->params['breadcrumbs'][] = $this->title; 'model' => $model, 'attributes' => [ 'number', + 'rfid_key', ['attribute' => 'status', 'value' => $model->statusHuman], ['attribute' => 'type', 'value' => $model->typeHuman], 'created_at:datetime', diff --git a/backend/views/key/_form.php b/backend/views/key/_form.php index bd62298..48c046c 100644 --- a/backend/views/key/_form.php +++ b/backend/views/key/_form.php @@ -14,6 +14,7 @@ use common\models\Key; field($model, 'number')->textInput(['maxlength' => true]) ?> + field($model, 'rfid_key')->textInput(['maxlength' => true]) ?> field($model, 'status')->dropDownList( Key::statuses() ) /*->textInput()*/ ?> diff --git a/backend/views/key/_search.php b/backend/views/key/_search.php index a69436c..509bab5 100644 --- a/backend/views/key/_search.php +++ b/backend/views/key/_search.php @@ -11,8 +11,6 @@ use common\models\Key; diff --git a/backend/views/key/index.php b/backend/views/key/index.php index 53f9430..f44ccd1 100644 --- a/backend/views/key/index.php +++ b/backend/views/key/index.php @@ -30,6 +30,7 @@ $this->params['breadcrumbs'][] = $this->title; // ['class' => 'yii\grid\SerialColumn'], // 'id_key', 'number', + 'rfid_key', [ 'attribute' => 'status', 'value' => function ($model, $key, $index, $column){ @@ -39,7 +40,11 @@ $this->params['breadcrumbs'][] = $this->title; } ], //'status', - 'type', + [ + 'attribute' =>'type', + 'value' =>'humanType' + + ], 'created_at', // 'updated_at', diff --git a/backend/views/key/view.php b/backend/views/key/view.php index 48f5760..6488b8a 100644 --- a/backend/views/key/view.php +++ b/backend/views/key/view.php @@ -30,6 +30,7 @@ $this->params['breadcrumbs'][] = $this->title; 'attributes' => [ 'id_key', 'number', + 'rfid_key', 'status', 'type', 'created_at', diff --git a/common/messages/hu/common/card.php b/common/messages/hu/common/card.php index e4dfa5a..02fca45 100644 --- a/common/messages/hu/common/card.php +++ b/common/messages/hu/common/card.php @@ -37,5 +37,6 @@ return [ 'Update' => 'Módosítás', 'Update {modelClass}: ' => '{modelClass} módosítása:', 'Updated At' => 'Módosítás ideje', - 'OLD' => 'Régi Rendszer' + 'OLD' => 'Régi Rendszer', + 'RFID key' => 'RFID szám' ]; diff --git a/common/messages/hu/common/key.php b/common/messages/hu/common/key.php index 4ca4bc0..bf3a8d2 100644 --- a/common/messages/hu/common/key.php +++ b/common/messages/hu/common/key.php @@ -6,6 +6,8 @@ return [ 'Status' => 'Státusz', 'Search' => 'Keresés', 'Type' => 'Típus', + 'Key' => 'Kulcs', 'Created At' => 'Létrehozva', + 'RFID key' => 'RFID szám', ]; ?> diff --git a/common/models/Card.php b/common/models/Card.php index 28e8af6..09e1af7 100644 --- a/common/models/Card.php +++ b/common/models/Card.php @@ -42,6 +42,7 @@ class Card extends \common\models\BaseFitnessActiveRecord [['number', 'type','status'], 'required'], [['status', 'type'], 'integer'], [['number'], 'string', 'max' => 20], + [['rfid_key'], 'string', 'max' => 25], [['number'], 'unique' ] ]; } @@ -54,6 +55,7 @@ class Card extends \common\models\BaseFitnessActiveRecord return [ 'id_card' => Yii::t('common/card', 'Id Card'), 'number' => Yii::t('common/card', 'Number'), + 'rfid_key' => Yii::t('common/card', 'RFID key'), 'status' => Yii::t('common/card', 'Status'), 'type' => Yii::t('common/card', 'Type'), 'created_at' => Yii::t('common/card', 'Created At'), diff --git a/common/models/Key.php b/common/models/Key.php index f4e8b77..b9a3feb 100644 --- a/common/models/Key.php +++ b/common/models/Key.php @@ -39,6 +39,7 @@ class Key extends \yii\db\ActiveRecord //[['created_at', 'updated_at'], 'required'],//kötelezőek //[['created_at', 'updated_at'], 'safe'], //bármi lehet [['number'], 'string', 'max' => 255], + [['rfid_key'], 'string', 'max' => 25], [['number' ], 'unique'], ]; } @@ -61,6 +62,7 @@ class Key extends \yii\db\ActiveRecord return [ 'id_key' => Yii::t('common/key', 'Id Key'), 'number' => Yii::t('common/key', 'Number'), + 'rfid_key' => Yii::t('common/key', 'RFID key'), 'status' => Yii::t('common/key', 'Status'), 'type' => Yii::t('common/key', 'Type'), 'created_at' => Yii::t('common/key', 'Created At'), @@ -80,5 +82,14 @@ class Key extends \yii\db\ActiveRecord self::TYPE_NORMAL => Yii::t('common/key', 'Key'), ]; } + + public function getHumanType(){ + $result = ""; + $types = self::types(); + if ( array_key_exists($this->type, $types) ){ + $result = $types[$this->type]; + } + return $result; + } } diff --git a/console/migrations/m151208_212339_alter__table__customer__add__column__key.php b/console/migrations/m151208_212339_alter__table__customer__add__column__key.php index 2a4cca8..7091c04 100644 --- a/console/migrations/m151208_212339_alter__table__customer__add__column__key.php +++ b/console/migrations/m151208_212339_alter__table__customer__add__column__key.php @@ -7,7 +7,7 @@ class m151208_212339_alter__table__customer__add__column__key extends Migration { public function up() { - $this->addColumn("customer", "id_key", "int"); + $this->addColumn("key", "id_key", "int"); } public function down() diff --git a/console/migrations/m151228_162443_alter__table__key__add__column__rfid__number.php b/console/migrations/m151228_162443_alter__table__key__add__column__rfid__number.php new file mode 100644 index 0000000..0c469ef --- /dev/null +++ b/console/migrations/m151228_162443_alter__table__key__add__column__rfid__number.php @@ -0,0 +1,30 @@ +addColumn("key", "rfid_key", "varchar(25)"); + } + + public function down() + { + echo "m151228_162443_alter__table__key__add__column__rfid__number 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/console/migrations/m151228_172909_alter__table__card__add__column__rfid__number.php b/console/migrations/m151228_172909_alter__table__card__add__column__rfid__number.php new file mode 100644 index 0000000..ba28cd7 --- /dev/null +++ b/console/migrations/m151228_172909_alter__table__card__add__column__rfid__number.php @@ -0,0 +1,30 @@ +addColumn("card", "rfid_key", "varchar(25)"); + } + + public function down() + { + echo "m151228_172909_alter__table__card__add__column__rfid__number 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/models/ReceptionForm.php b/frontend/models/ReceptionForm.php index 83be5df..618d275 100644 --- a/frontend/models/ReceptionForm.php +++ b/frontend/models/ReceptionForm.php @@ -42,7 +42,7 @@ class ReceptionForm extends Model public function readCard(){ - $this->card = Card::findOne(['number' => $this->number]); + $this->card = Card::find()->andWhere(['or',[ 'in','number' , [$this->number]],['in','rfid_key' ,[ $this->number]]])->one(); if ( $this->card != null ){ $this->customer = $this->card->customer; $this->readValidTickets();