implement mobile devices in reception

This commit is contained in:
Roland Schneider 2022-02-19 14:51:58 +01:00
parent 9fb0485066
commit 34fca82e7d
13 changed files with 834 additions and 185 deletions

View File

@ -62,7 +62,7 @@ class MobileDeviceManager extends BaseObject
}
public function create($cardNumber, $deviceIdentifier)
public function create($cardNumber, $deviceIdentifier, $deviceName)
{
$card = Card::find()->andWhere(
['number' => $cardNumber]
@ -72,6 +72,12 @@ class MobileDeviceManager extends BaseObject
throw new NotFoundHttpException();
}
// do not allow registering cards without customer
$customer = Customer::find()->andWhere(['id_customer_card' => $card->id_card])->one();
if ( $customer == null ){
throw new NotFoundHttpException();
}
$device = MobileDevice::find()
->andWhere(
[
@ -84,10 +90,12 @@ class MobileDeviceManager extends BaseObject
throw new BadRequestHttpException("Device already exists, can't create");
}
$device = new MobileDevice();
$device->device_identifier = $deviceIdentifier;
$device->id_card = $card->id_card;
$device->status = MobileDevice::STATUS_INACTIVE;
$device->device_name = $deviceName;
$device->save(false);
return $device;
@ -100,13 +108,13 @@ class MobileDeviceManager extends BaseObject
* @throws BadRequestHttpException
* @throws NotFoundHttpException
*/
public function loginOrCreate($cardNumber, $deviceIdentifier)
public function loginOrCreate($cardNumber, $deviceIdentifier, $deviceName)
{
try {
return $this->login($cardNumber, $deviceIdentifier);
} catch (\Exception $e) {
return $this->create($cardNumber, $deviceIdentifier);
return $this->create($cardNumber, $deviceIdentifier, $deviceName);
}
}

View File

@ -33,67 +33,71 @@ use yii\helpers\Console;
*/
class Log extends BaseFitnessActiveRecord
{
public static $TYPE_INFO = 10;
public static $TYPE_ERR = 20;
public static $TYPE_TICKET_USAGE_FIRST = 30;
public static $TYPE_TICKET_USAGE_MULTIPLE = 40;
public static $TYPE_LOGIN = 50;
public static $TYPE_DEFAULT_ACCOUNT= 60;
public static $TYPE_CREATE_CUSTOMER= 70;
public static $TYPE_PROCUREMENT_UPDATE = 80;
public static $TYPE_TICKET_COUNT_MOVE_OUT = 90;
public static $TYPE_WASTE = 100;
public static $TYPE_NEWSLETTER_SUBSCRIBE = 110;
public static $TYPE_NEWSLETTER_UNSUBSCRIBE = 120;
public static $TYPE_NEWSLETTER_SENT = 130;
public static $TYPE_TICKET_EXPIRE_SENT = 140;
public static $TYPE_NEWSLETTER_SEND_START = 150;
public static $TYPE_NEWSLETTER_SEND_END = 160;
public static $TYPE_KEY_ASSIGN = 170;
public static $TYPE_KEY_UNASSIGN = 180;
public static $TYPE_TOWEL_IN = 190;
public static $TYPE_TOWEL_OUT = 200;
public static $TYPE_CRUD = 210;
public static $TYPE_TICKET_UPDATED_BY_ADMIN = 220;
public static $TYPE_INFO = 10;
public static $TYPE_ERR = 20;
public static $TYPE_TICKET_USAGE_FIRST = 30;
public static $TYPE_TICKET_USAGE_MULTIPLE = 40;
public static $TYPE_LOGIN = 50;
public static $TYPE_DEFAULT_ACCOUNT = 60;
public static $TYPE_CREATE_CUSTOMER = 70;
public static $TYPE_PROCUREMENT_UPDATE = 80;
public static $TYPE_TICKET_COUNT_MOVE_OUT = 90;
public static $TYPE_WASTE = 100;
public static $TYPE_NEWSLETTER_SUBSCRIBE = 110;
public static $TYPE_NEWSLETTER_UNSUBSCRIBE = 120;
public static $TYPE_NEWSLETTER_SENT = 130;
public static $TYPE_TICKET_EXPIRE_SENT = 140;
public static $TYPE_NEWSLETTER_SEND_START = 150;
public static $TYPE_NEWSLETTER_SEND_END = 160;
public static $TYPE_KEY_ASSIGN = 170;
public static $TYPE_KEY_UNASSIGN = 180;
public static $TYPE_TOWEL_IN = 190;
public static $TYPE_TOWEL_OUT = 200;
public static $TYPE_CRUD = 210;
public static $TYPE_TICKET_UPDATED_BY_ADMIN = 220;
public static $TYPE_MOBILE_DEVICE_STATUS = 230;
public static function getTypes(){
return [
Log::$TYPE_INFO => "Info",
Log::$TYPE_ERR => "Hiba",
Log::$TYPE_TICKET_USAGE_FIRST => "Bérlet használat",
Log::$TYPE_TICKET_USAGE_MULTIPLE => "Többszöri bérlet használat",
Log::$TYPE_LOGIN => "Bejelentkezés",
Log::$TYPE_DEFAULT_ACCOUNT=> "Alapértelmezett kassza",
Log::$TYPE_CREATE_CUSTOMER=> "Új vendég",
Log::$TYPE_PROCUREMENT_UPDATE => "Beszerzés módosítás",
Log::$TYPE_TICKET_COUNT_MOVE_OUT => "Ki mozgás",
Log::$TYPE_WASTE => "Selejt",
Log::$TYPE_NEWSLETTER_SUBSCRIBE => "Feliratkozás hirlevélre",
Log::$TYPE_NEWSLETTER_UNSUBSCRIBE => "Leiratkozás hírlevélről",
Log::$TYPE_NEWSLETTER_SENT => "Hirlevél elküldve",
Log::$TYPE_TICKET_EXPIRE_SENT => "Bérlet lejáart figyelmeztetés elküldve",
Log::$TYPE_NEWSLETTER_SEND_START => "Hirlevél küldés start",
Log::$TYPE_NEWSLETTER_SEND_END => "Hirlevél küldés vége",
Log::$TYPE_KEY_ASSIGN => "Kulcs kiadás",
Log::$TYPE_KEY_UNASSIGN => "Kulcs visszaadás",
Log::$TYPE_TOWEL_IN => "Törölköző ki",
Log::$TYPE_TOWEL_OUT => "Törölköző vissza",
Log::$TYPE_CRUD => "CRUD",
Log::$TYPE_TICKET_UPDATED_BY_ADMIN => "Bérlet módosítás"
public static function getTypes()
{
return [
Log::$TYPE_INFO => "Info",
Log::$TYPE_ERR => "Hiba",
Log::$TYPE_TICKET_USAGE_FIRST => "Bérlet használat",
Log::$TYPE_TICKET_USAGE_MULTIPLE => "Többszöri bérlet használat",
Log::$TYPE_LOGIN => "Bejelentkezés",
Log::$TYPE_DEFAULT_ACCOUNT => "Alapértelmezett kassza",
Log::$TYPE_CREATE_CUSTOMER => "Új vendég",
Log::$TYPE_PROCUREMENT_UPDATE => "Beszerzés módosítás",
Log::$TYPE_TICKET_COUNT_MOVE_OUT => "Ki mozgás",
Log::$TYPE_WASTE => "Selejt",
Log::$TYPE_NEWSLETTER_SUBSCRIBE => "Feliratkozás hirlevélre",
Log::$TYPE_NEWSLETTER_UNSUBSCRIBE => "Leiratkozás hírlevélről",
Log::$TYPE_NEWSLETTER_SENT => "Hirlevél elküldve",
Log::$TYPE_TICKET_EXPIRE_SENT => "Bérlet lejáart figyelmeztetés elküldve",
Log::$TYPE_NEWSLETTER_SEND_START => "Hirlevél küldés start",
Log::$TYPE_NEWSLETTER_SEND_END => "Hirlevél küldés vége",
Log::$TYPE_KEY_ASSIGN => "Kulcs kiadás",
Log::$TYPE_KEY_UNASSIGN => "Kulcs visszaadás",
Log::$TYPE_TOWEL_IN => "Törölköző ki",
Log::$TYPE_TOWEL_OUT => "Törölköző vissza",
Log::$TYPE_CRUD => "CRUD",
Log::$TYPE_TICKET_UPDATED_BY_ADMIN => "Bérlet módosítás",
Log::$TYPE_MOBILE_DEVICE_STATUS => "Mobil eszköz státusz"
];
}
public function getTypeName(){
$types = Log::getTypes();
return Helper::getArrayValue($types,$this->type,null);
}
/**
public function getTypeName()
{
$types = Log::getTypes();
return Helper::getArrayValue($types, $this->type, null);
}
/**
* @inheritdoc
*/
public static function tableName()
@ -134,79 +138,89 @@ class Log extends BaseFitnessActiveRecord
'id_door_log' => Yii::t('common/log', 'Kapu log'),
'created_at' => Yii::t('common/log', 'Dátum idő'),
'updated_at' => Yii::t('common/log', 'Módosítás'),
'start' => 'Időszak kezdete',
'end' => 'Időszak vége'
'start' => 'Időszak kezdete',
'end' => 'Időszak vége'
];
}
public static function info($message ){
self::log(['type' =>self::$TYPE_INFO, 'message' => $message]);
public static function info($message)
{
self::log(['type' => self::$TYPE_INFO, 'message' => $message]);
}
/**
* example
* Log::log([
'type' =>Log::$TYPE_LOGIN,
'message' => $message
]);
* 'type' =>Log::$TYPE_LOGIN,
* 'message' => $message
* ]);
* @param array $config
*/
public static function log( $config ){
$model = new Log($config);
$model->app = \Yii::$app->name;
$model->url = Url::canonical();
$model->id_user = \Yii::$app->user->id;
$model->save(false);
public static function log($config)
{
$model = new Log($config);
$model->app = \Yii::$app->name;
$model->url = Url::canonical();
$model->id_user = \Yii::$app->user->id;
$model->save(false);
}
/**
* create a log from the console app
* */
public static function logC( $config ){
$model = new Log($config);
$model->app = "Fitness rendszer";
$model->url = "console";
$model->id_user = 1;
$model->save(false);
public static function logC($config)
{
$model = new Log($config);
$model->app = "Fitness rendszer";
$model->url = "console";
$model->id_user = 1;
$model->save(false);
}
public function getUser(){
return $this->hasOne( User::className(), ["id" =>"id_user" ] );
public function getUser()
{
return $this->hasOne(User::className(), ["id" => "id_user"]);
}
public function getTicket(){
return $this->hasOne( Ticket::className(), ["id_ticket" =>"id_ticket" ] );
public function getTicket()
{
return $this->hasOne(Ticket::className(), ["id_ticket" => "id_ticket"]);
}
public function getCustomer(){
return $this->hasOne( Customer::className(), ["id_customer" =>"id_customer" ] );
public function getCustomer()
{
return $this->hasOne(Customer::className(), ["id_customer" => "id_customer"]);
}
public function getMoneyMovement(){
return $this->hasOne( MoneyMovement::className(), ["id_money_movement" =>"id_money_movement" ] );
public function getMoneyMovement()
{
return $this->hasOne(MoneyMovement::className(), ["id_money_movement" => "id_money_movement"]);
}
public function getUserName(){
public function getUserName()
{
$user = $this->user;
if ( isset($user)){
if (isset($user)) {
return $user->username;
}
return null;
}
public function getCustomerName(){
public function getCustomerName()
{
$customer = $this->customer;
if ( isset($customer)){
if (isset($customer)) {
return $customer->name;
}
return null;
}
public function getTicketName(){
public function getTicketName()
{
$ticket = $this->ticket;
if ( isset($ticket)){
if (isset($ticket)) {
return $ticket->ticketTypeName;
}
return null;

View File

@ -13,6 +13,7 @@ use yii\helpers\ArrayHelper;
* @property integer $id_card
* @property string $status
* @property string $device_identifier
* @property string $device_name
* @property string $activated_at
* @property string $created_at
* @property string $updated_at
@ -22,7 +23,8 @@ class MobileDevice extends \yii\db\ActiveRecord
const STATUS_ACTIVE = 'active';
const STATUS_INACTIVE = 'inactive';
const STATUS_DELETED = 'deleted';
const STATUS_DELETED_MANUAL = 'deleted_manual';
const STATUS_DELETED_SYSTEM = 'deleted_system';
/**
* @inheritdoc
@ -38,11 +40,11 @@ class MobileDevice extends \yii\db\ActiveRecord
public function rules()
{
return [
[['id_card'], 'integer'],
[['activated_at', 'created_at', 'updated_at'], 'safe'],
[['created_at', 'updated_at'], 'required'],
[['status'], 'string', 'max' => 20],
[['device_identifier'], 'string', 'max' => 255]
// [['id_card'], 'integer'],
// [['activated_at', 'created_at', 'updated_at'], 'safe'],
// [['created_at', 'updated_at'], 'required'],
// [['status'], 'string', 'max' => 20],
// [['device_identifier'], 'string', 'max' => 255]
];
}
@ -56,6 +58,7 @@ class MobileDevice extends \yii\db\ActiveRecord
'id_card' => Yii::t('common/mobiledevice', 'Id Card'),
'status' => Yii::t('common/mobiledevice', 'Status'),
'device_identifier' => Yii::t('common/mobiledevice', 'Device Identifier'),
'device_name' => Yii::t('common/mobiledevice', 'Device Name'),
'activated_at' => Yii::t('common/mobiledevice', 'Activated At'),
'created_at' => Yii::t('common/mobiledevice', 'Created At'),
'updated_at' => Yii::t('common/mobiledevice', 'Updated At'),
@ -72,4 +75,24 @@ class MobileDevice extends \yii\db\ActiveRecord
],
parent::behaviors());
}
public static function toStatusHumanReadable($status){
$result = "";
switch ($status){
case self::STATUS_ACTIVE:
$result ='Aktív';
break;
case self::STATUS_DELETED_MANUAL:
$result ='Törölve (m)';
break;
case self::STATUS_DELETED_SYSTEM:
$result ='Törölve (r)';
break;
case self::STATUS_INACTIVE:
$result ='Inaktív';
break;
}
return $result;
}
}

View File

@ -0,0 +1,43 @@
<?php
use yii\db\Migration;
/**
* Class m220218_192423_alter_table_mobile_device_add_column_device_name
*/
class m220218_192423_alter_table_mobile_device_add_column_device_name extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('mobile_device', 'device_name', $this->string() );
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
echo "m220218_192423_alter_table_mobile_device_add_column_device_name cannot be reverted.\n";
return false;
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m220218_192423_alter_table_mobile_device_add_column_device_name cannot be reverted.\n";
return false;
}
*/
}

View File

@ -1,6 +1,7 @@
<?php
namespace frontend\components;
use common\models\MobileDevice;
use yii\base\Widget;
/**
* This is the model class for table "customer".
@ -15,8 +16,13 @@ class ReceptionCustomerWidget extends Widget{
public $model;
public function run(){
echo $this->render($this->viewFile,[ 'model' => $this->model ]);
$showLinkDevices = MobileDevice::find()
->andWhere(['status' => MobileDevice::STATUS_INACTIVE])
->count() > 0;
echo $this->render($this->viewFile,[ 'model' => $this->model,
'showLinkDevices' => $showLinkDevices
]);
}
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace frontend\controllers;
use common\models\Card;
use common\models\MobileDevice;
use frontend\models\MobileDeviceSearch;
use frontend\models\MobileStatusForm;
use Yii;
use common\models\City;
use backend\models\CitySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use yii\db\Query;
use yii\helpers\Json;
/**
* CityController implements the CRUD actions for City model.
*/
class MobileDeviceController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all City models.
* @return mixed
*/
public function actionIndex($id_card)
{
$card = $this->findModel($id_card);
$searchModel = new MobileDeviceSearch();
$searchModel->id_card = $card->id_card;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'card' => $card
]);
}
public function actionStatus($id_device, $status)
{
$device = $this->findDevice($id_device);
\Yii::info(print_r($device,true));
if ( $device == null ){
throw new NotFoundHttpException();
}
if (\Yii::$app->request->isPost) {
$form = new MobileStatusForm();
$form->status = $status;
$form->id_device = $id_device;
if ($form->validate()) {
$form->save();
return $this->redirect(['mobile-device/index', 'id_card' => $device->id_card]);
}
}
return $this->render( 'mobile-device/index',[ 'id_card' => $device->id_card]);
}
/**
* Finds the Card model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Card the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Card::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* @param $id
* @return MobileDevice|null
* @throws NotFoundHttpException
*/
protected function findDevice($id)
{
if (($model = MobileDevice::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace frontend\models;
use common\components\Helper;
use common\models\MobileDevice;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\db\Query;
/**
* EventSearch represents the model behind the search form about `common\models\Event`.
*/
class MobileDeviceSearch extends MobileDevice
{
/**
* @inheritdoc
*/
public function rules()
{
return [
];
}
/**
* @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([
'card.id_card as card_id',
'card.number as card_number',
'mobile_device.id as device_id',
'mobile_device.device_name as device_name',
'mobile_device.status as device_status',
'mobile_device.created_at as device_created_at',
]);
$query->from("mobile_device");
$query->innerJoin('customer', 'customer.id_customer_card = mobile_device.id_card');
$query->innerJoin('card', 'card.id_card = mobile_device.id_card');
$query->andWhere(['card.id_card' => $this->id_card]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'defaultOrder' => [
'device_created_at' => SORT_DESC
],
'attributes' => Helper::mkYiiSortItems([
['device_created_at'],
['device_status'],
]),
]
]);
$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([
// 'event.id' => $this->id,
// ]);
return $dataProvider;
}
}

View File

@ -0,0 +1,96 @@
<?php
namespace frontend\models;
use common\components\Helper;
use common\models\Card;
use common\models\Customer;
use common\models\Log;
use common\models\MobileDevice;
use Yii;
use yii\base\Model;
use yii\web\BadRequestHttpException;
use yii\web\NotFoundHttpException;
/**
* ContactForm is the model behind the contact form.
*/
class MobileStatusForm extends Model
{
public $id_device;
public $status;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_device', 'status'], 'required'],
];
}
public function save()
{
$tx = null;
try {
$tx = \Yii::$app->db->beginTransaction();
$device = MobileDevice::findOne(['id' => $this->id_device]);
if ($device === null) {
throw new NotFoundHttpException();
}
$card = Card::findOne(['id_card' => $device->id_card]);
if ($card === null) {
throw new NotFoundHttpException();
}
\Yii::info("MobileStatusForm: changing status from $device->status to $this->status");
$origStatus = $device->status;
$device->status = $this->status;
if ( $this->status === MobileDevice::STATUS_ACTIVE ){
// only one card can be active at the same time
MobileDevice::updateAll([
'activated_at' => null,
'status' => MobileDevice::STATUS_DELETED_SYSTEM
],
[
'id_card' => $device->id_card
]
);
}
if ($this->status === MobileDevice::STATUS_ACTIVE) {
if (!isset($device->activated_at)) {
$device->activated_at = Helper::getDateTimeString();
}
} else {
$device->activated_at = null;
}
$device->save(false);
$customer = Customer::find()->andWhere(['id_customer_card' => $device->id_card])->one();
Log::log([
'type' => Log::$TYPE_MOBILE_DEVICE_STATUS,
'message' => "Eszkösz $device->id; Kártya: $card->number; előző státusz: $origStatus; új státusz: $this->status",
'id_customer' => $customer->id_customer
]);
$tx->commit();
}catch ( \Exception $e){
\Yii::error("Failed to save status for device $this->id_device :".$e->getMessage());
if ( $tx != null ){
$tx->rollBack();
}
throw $e;
}
}
}

View File

@ -1,57 +1,85 @@
<?php
use yii\helpers\Url;
?>
<?php
$route = Yii::$app->controller->id .'/'. Yii::$app->controller->action->id;
$route = Yii::$app->controller->id . '/' . Yii::$app->controller->action->id;
/** @noinspection PhpUnhandledExceptionInspection */
$todayDateTime = Yii::$app->formatter->asDatetime(strtotime('today UTC'));
$items = [
[ 'Recepció', ['customer/reception', 'number' => $card->number ]],
[ 'Termék eladás', ['product/sale', 'number' => $card->number ]],
[ 'Adatlap', ['customer/update', 'number' => $card->number ]],
[ 'Befizetések', ['ticket/index', 'number' => $card->number] ],
[ 'Kulcsok', ['key/index', 'id_card' => $card->id_card] ],
[ 'Szerződések', ['contract/index', 'id_card' => $card->id_card ]],
[ 'Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card ]],
[ 'Kártya', ['card/info', 'id_card' => $card->id_card ]],
[ 'Törölköző Bérlés', ['log/towel', 'id_card' => $card->id_card , 'LogSearch[start]' => $todayDateTime ]],
[ 'Ujjlenyomat', ['fingerprint/index', 'FingerprintSearch[id_card]' => $card->id_card ]],
[ 'Jelszó küldése', ['customer/password-change', 'id_card' => $card->id_card ]],
['Recepció', ['customer/reception', 'number' => $card->number]],
['Termék eladás', ['product/sale', 'number' => $card->number]],
['Adatlap', ['customer/update', 'number' => $card->number]],
['Befizetések', ['ticket/index', 'number' => $card->number]],
['Kulcsok', ['key/index', 'id_card' => $card->id_card]],
['Szerződések', ['contract/index', 'id_card' => $card->id_card]],
['Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card]],
['Kártya', ['card/info', 'id_card' => $card->id_card]],
['Törölköző Bérlés', ['log/towel', 'id_card' => $card->id_card, 'LogSearch[start]' => $todayDateTime]],
['Ujjlenyomat', ['fingerprint/index', 'FingerprintSearch[id_card]' => $card->id_card]],
['Jelszó küldése', ['customer/password-change', 'id_card' => $card->id_card]],
['Mobil Eszközök', ['mobile-device/index', 'id_card' => $card->id_card]],
];
?>
<style>
.fitness-nav {
}
.fitness-nav-item.active a, .fitness-nav-item a:hover {
background: #0b93d5;
}
.fitness-nav-item > a {
padding: 8px 16px;
display: block;
margin-bottom: 8px;
background: #204d74;
color: #ffffff;
border-radius: 4px;
text-align: center;
}
.fitness-nav-container{
background: #e2e2e2;
padding: 8px 8px 0 8px;
border-radius: 4px;
}
</style>
<div class="fitness-nav-container">
<ul class="nav nav-tabs">
<?php foreach ($items as $item){?>
<?php
if ( empty($title)){
if ( $item[1][0] == $route) {
$title = $item[0];
}
}
?>
<li role="presentation" class="<?php echo $item[1][0] == $route ? 'active' : '' ?>"><a href="<?php echo Url::toRoute($item[1])?>"><?php echo $item[0] ?></a></li>
<?php }?>
</ul>
<div class="row fitness-nav">
<?php foreach ($items as $item) { ?>
<?php
if (empty($title)) {
if ($item[1][0] == $route) {
$title = $item[0];
}
}
?>
<div role="presentation"
class="col-lg-2 fitness-nav-item <?php echo $item[1][0] == $route ? 'active' : '' ?>"><a
href="<?php echo Url::toRoute($item[1]) ?>"><?php echo $item[0] ?></a></div>
<?php } ?>
</div>
</div>
<?php if ( !empty($title)) {?>
<h1><?php echo $title?></h1>
<?php if (!empty($title)) { ?>
<h1><?php echo $title ?></h1>
<p>Vendég: <?php echo $card->customer->name ?></p>
<p>Kártyaszám: <?php echo $card->number ?></p>
<?php }?>
<?php } ?>

View File

@ -13,57 +13,69 @@ use yii\helpers\Url;
<?php
if ( $model->isCardWithCustomer() ){
$attributes = [
[
'label' => 'Kártyaszám',
'value' => $model->card->number
],
[
'label' => 'Vendég',
'value' => $model->customer->name
],
[
'label' => 'E-Mail',
'value' => $model->customer->email
],
[
'label' => 'Telefon',
'value' => $model->customer->phone
],
[
'label' => 'Kiadott törölközők',
'value' => $model->customer->towel_count
],
[
'label' => 'Kulcsok',
'value' =>
empty($model->keysText) ? '' : (
"<form method='POST' action='". Url::toRoute(['key/toggle', "number" => $model->card->number])."'>"
.$model->keysText
.Html::hiddenInput("KeyToggleForm[key]", $model->keysText)
.Html::submitButton("Visszaad", [ 'style' => 'float: right;', 'class' => 'btn btn-primary btn-xs'])
."</form>")
,
'format' => 'raw'
],
[
'label' => 'Fénykép',
'value' => $model->customer->image1 ? Html::img( Url::base( ) . Image::thumb( $model->customer->image1->path,160,120 )) : 'Nincs kép',
'format' => 'raw'
],
];
?>
<div class="row">
<div class="col-md-12">
<?php
echo DetailView::widget([
'model' => $model,
'attributes' =>[
[
'label' => 'Kártyaszám',
'value' => $model->card->number
],
[
'label' => 'Vendég',
'value' => $model->customer->name
],
[
'label' => 'E-Mail',
'value' => $model->customer->email
],
[
'label' => 'Telefon',
'value' => $model->customer->phone
],
[
'label' => 'Kiadott törölközők',
'value' => $model->customer->towel_count
],
[
'label' => 'Kulcsok',
'value' =>
empty($model->keysText) ? '' : (
"<form method='POST' action='". Url::toRoute(['key/toggle', "number" => $model->card->number])."'>"
.$model->keysText
.Html::hiddenInput("KeyToggleForm[key]", $model->keysText)
.Html::submitButton("Visszaad", [ 'style' => 'float: right;', 'class' => 'btn btn-primary btn-xs'])
."</form>")
,
'format' => 'raw'
],
[
'label' => 'Fénykép',
'value' => $model->customer->image1 ? Html::img( Url::base( ) . Image::thumb( $model->customer->image1->path,160,120 )) : 'Nincs kép',
'format' => 'raw'
],
]
'attributes' => $attributes
])
?>
<div>
<?php
echo Html::a('Menü',['customer/update', 'number' => $model->card->number],['class' => 'btn btn-success me-3']);
if ( isset($showLinkDevices) && $showLinkDevices === true ) {
echo Html::a('Eszköz aktiválása', ['mobile-device/index', 'id_card' => $model->card->id_card], ['class' => 'btn btn-success']);
}?>
</div>
</div>
</div>
<?php
}
?>
?>

View File

@ -0,0 +1,86 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use common\models\MobileDevice;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\CollectionSearch */
/* @var $card \common\models\Card */
/* @var $dataProvider \frontend\controllers\MobileDeviceController */
$this->title = "Vendég - mobil eszközök";
$this->params['breadcrumbs'][] = "Vendég";
$this->params['breadcrumbs'][] = "Mobil eszközök";
echo \frontend\components\CustomerTabWidget::widget(['card' => $card]);
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'card_number',
'label' => 'Kártyaszám',
],
[
'attribute' => 'device_name',
'label' => 'Eszköz neve',
],
[
'attribute' => 'device_created_at',
'label' => 'Létrehozva',
'format' => 'datetime'
],
[
'attribute' => 'device_status',
'label' => 'Státusz',
'value' => function ($model, $key, $index, $column) {
return MobileDevice::toStatusHumanReadable($model['device_status']);
}
],
['class' => 'yii\grid\ActionColumn',
'header' => 'Műveletek',
'template' => '{activate} {delete}',
'buttons' => [
'activate' => function ($url, $model, $key) {
$status = $model['device_status'];
if ($status == MobileDevice::STATUS_ACTIVE) {
return null;
}
$options = [
'title' => 'Az aktuális eszköz aktiválása',
'data-confirm' => "Biztosan aktiválni szerenté ezt az eszközt?",
'data-method' => 'post',
'class' => 'btn btn-xs btn-success'
];
return Html::a('Aktivál', $url, $options);
},
'delete' => function ($url, $model, $key) {
$status = $model['device_status'];
if ($status !== MobileDevice::STATUS_ACTIVE) {
return null;
}
$options = [
'title' => 'Az aktuális eszköz törlése',
'data-confirm' => "Biztosan törölni szerenté ezt az eszközt?",
'data-method' => 'post',
'class' => 'btn btn-xs btn-danger'
];
return Html::a('Töröl', $url, $options);
},
],
'urlCreator' => function ($action, $model, $key, $index) {
$status = MobileDevice::STATUS_DELETED_MANUAL;
if ($action === 'activate') {
$status = MobileDevice::STATUS_ACTIVE;
}
$url = Url::to(['mobile-device/status', 'id_device' => $model['device_id'], 'status' => $status]);
return $url;
}
],
],
]); ?>

View File

@ -96,3 +96,138 @@ a.desc:after {
background-color: #dc500b;
border-color: #faebcc;
}
:root{
--spacer-1: 0.25rem;
--spacer-2: 0.5rem;
--spacer-3: 1rem;
--spacer-4: 1.5rem;
--spacer-5: 3rem;
}
.px-1{
padding-left: var(--spacer-1);
padding-right: var(--spacer-1);
}
.px-2{
padding-left: var(--spacer-2);
padding-right: var(--spacer-2);
}
.px-3{
padding-left: var(--spacer-3);
padding-right: var(--spacer-3);
}
.px-4{
padding-left: var(--spacer-4);
padding-right: var(--spacer-4);
}
.py-1{
padding-top: var(--spacer-1);
padding-bottom: var(--spacer-1);
}
.py-2{
padding-top: var(--spacer-2);
padding-bottom: var(--spacer-2);
}
.py-3{
padding-top: var(--spacer-3);
padding-bottom: var(--spacer-3);
}
.py-4{
padding-top: var(--spacer-4);
padding-bottom: var(--spacer-4);
}
.ps-1{
padding-left: var(--spacer-1);
}
.ps-2{
padding-left: var(--spacer-2);
}
.ps-3{
padding-left: var(--spacer-3);
}
.ps-4{
padding-left: var(--spacer-4);
}
.pe-1{
padding-right: var(--spacer-1);
}
.pe-2{
padding-right: var(--spacer-2);
}
.pe-3{
padding-right: var(--spacer-3);
}
.pe-4{
padding-right: var(--spacer-4);
}
/**
margins
*/
.mx-1{
margin-left: var(--spacer-1);
margin-right: var(--spacer-1);
}
.mx-2{
margin-left: var(--spacer-2);
margin-right: var(--spacer-2);
}
.mx-3{
margin-left: var(--spacer-3);
margin-right: var(--spacer-3);
}
.mx-4{
margin-left: var(--spacer-4);
margin-right: var(--spacer-4);
}
.my-1{
margin-top: var(--spacer-1);
margin-bottom: var(--spacer-1);
}
.my-2{
margin-top: var(--spacer-2);
margin-bottom: var(--spacer-2);
}
.my-3{
margin-top: var(--spacer-3);
margin-bottom: var(--spacer-3);
}
.my-4{
margin-top: var(--spacer-4);
margin-bottom: var(--spacer-4);
}
.ms-1{
margin-left: var(--spacer-1);
}
.ms-2{
margin-left: var(--spacer-2);
}
.ms-3{
margin-left: var(--spacer-3);
}
.ms-4{
margin-left: var(--spacer-4);
}
.me-1{
margin-right: var(--spacer-1);
}
.me-2{
margin-right: var(--spacer-2);
}
.me-3{
margin-right: var(--spacer-3);
}
.me-4{
margin-right: var(--spacer-4);
}

View File

@ -18,8 +18,9 @@ use yii\web\NotFoundHttpException;
class LoginForm extends Model
{
// cardnumber
public $username;
public $password;
public $cardNumber;
public $deviceId;
public $deviceName;
public $customer;
@ -30,9 +31,9 @@ class LoginForm extends Model
{
return [
// username and password are both required
[['username', 'password'], 'required'],
// password is validated by validatePassword()
['password', 'validatePassword'],
[['cardNumber', 'deviceId','deviceName'], 'required'],
// cardNumber is validated by validatePassword()
['cardNumber', 'validateCardNumber'],
];
}
@ -52,7 +53,7 @@ class LoginForm extends Model
* @param array $params the additional name-value pairs given in the rule
* @throws \yii\base\InvalidConfigException
*/
public function validatePassword($attribute, $params)
public function validateCardNumber($attribute, $params)
{
if ($this->hasErrors()) {
/** @var \common\models\Customer $user */
@ -72,7 +73,7 @@ class LoginForm extends Model
if ($this->customer === null) {
$mobileDeviceManager = new MobileDeviceManager();
$mobileDevice = $mobileDeviceManager->loginOrCreate($this->username, $this->password);
$mobileDevice = $mobileDeviceManager->loginOrCreate($this->cardNumber, $this->deviceId, $this->deviceName);
/** @var Customer */
$this->customer = Customer::find()->andWhere([
'id_customer_card' => $mobileDevice->id_card