implement mobile devices in reception
This commit is contained in:
parent
9fb0485066
commit
34fca82e7d
@ -62,7 +62,7 @@ class MobileDeviceManager extends BaseObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($cardNumber, $deviceIdentifier)
|
public function create($cardNumber, $deviceIdentifier, $deviceName)
|
||||||
{
|
{
|
||||||
$card = Card::find()->andWhere(
|
$card = Card::find()->andWhere(
|
||||||
['number' => $cardNumber]
|
['number' => $cardNumber]
|
||||||
@ -72,6 +72,12 @@ class MobileDeviceManager extends BaseObject
|
|||||||
throw new NotFoundHttpException();
|
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()
|
$device = MobileDevice::find()
|
||||||
->andWhere(
|
->andWhere(
|
||||||
[
|
[
|
||||||
@ -84,10 +90,12 @@ class MobileDeviceManager extends BaseObject
|
|||||||
throw new BadRequestHttpException("Device already exists, can't create");
|
throw new BadRequestHttpException("Device already exists, can't create");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$device = new MobileDevice();
|
$device = new MobileDevice();
|
||||||
$device->device_identifier = $deviceIdentifier;
|
$device->device_identifier = $deviceIdentifier;
|
||||||
$device->id_card = $card->id_card;
|
$device->id_card = $card->id_card;
|
||||||
$device->status = MobileDevice::STATUS_INACTIVE;
|
$device->status = MobileDevice::STATUS_INACTIVE;
|
||||||
|
$device->device_name = $deviceName;
|
||||||
$device->save(false);
|
$device->save(false);
|
||||||
|
|
||||||
return $device;
|
return $device;
|
||||||
@ -100,13 +108,13 @@ class MobileDeviceManager extends BaseObject
|
|||||||
* @throws BadRequestHttpException
|
* @throws BadRequestHttpException
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function loginOrCreate($cardNumber, $deviceIdentifier)
|
public function loginOrCreate($cardNumber, $deviceIdentifier, $deviceName)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
return $this->login($cardNumber, $deviceIdentifier);
|
return $this->login($cardNumber, $deviceIdentifier);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->create($cardNumber, $deviceIdentifier);
|
return $this->create($cardNumber, $deviceIdentifier, $deviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,66 +34,70 @@ use yii\helpers\Console;
|
|||||||
class Log extends BaseFitnessActiveRecord
|
class Log extends BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
|
|
||||||
public static $TYPE_INFO = 10;
|
public static $TYPE_INFO = 10;
|
||||||
public static $TYPE_ERR = 20;
|
public static $TYPE_ERR = 20;
|
||||||
public static $TYPE_TICKET_USAGE_FIRST = 30;
|
public static $TYPE_TICKET_USAGE_FIRST = 30;
|
||||||
public static $TYPE_TICKET_USAGE_MULTIPLE = 40;
|
public static $TYPE_TICKET_USAGE_MULTIPLE = 40;
|
||||||
public static $TYPE_LOGIN = 50;
|
public static $TYPE_LOGIN = 50;
|
||||||
public static $TYPE_DEFAULT_ACCOUNT= 60;
|
public static $TYPE_DEFAULT_ACCOUNT = 60;
|
||||||
public static $TYPE_CREATE_CUSTOMER= 70;
|
public static $TYPE_CREATE_CUSTOMER = 70;
|
||||||
public static $TYPE_PROCUREMENT_UPDATE = 80;
|
public static $TYPE_PROCUREMENT_UPDATE = 80;
|
||||||
public static $TYPE_TICKET_COUNT_MOVE_OUT = 90;
|
public static $TYPE_TICKET_COUNT_MOVE_OUT = 90;
|
||||||
public static $TYPE_WASTE = 100;
|
public static $TYPE_WASTE = 100;
|
||||||
public static $TYPE_NEWSLETTER_SUBSCRIBE = 110;
|
public static $TYPE_NEWSLETTER_SUBSCRIBE = 110;
|
||||||
public static $TYPE_NEWSLETTER_UNSUBSCRIBE = 120;
|
public static $TYPE_NEWSLETTER_UNSUBSCRIBE = 120;
|
||||||
public static $TYPE_NEWSLETTER_SENT = 130;
|
public static $TYPE_NEWSLETTER_SENT = 130;
|
||||||
public static $TYPE_TICKET_EXPIRE_SENT = 140;
|
public static $TYPE_TICKET_EXPIRE_SENT = 140;
|
||||||
public static $TYPE_NEWSLETTER_SEND_START = 150;
|
public static $TYPE_NEWSLETTER_SEND_START = 150;
|
||||||
public static $TYPE_NEWSLETTER_SEND_END = 160;
|
public static $TYPE_NEWSLETTER_SEND_END = 160;
|
||||||
public static $TYPE_KEY_ASSIGN = 170;
|
public static $TYPE_KEY_ASSIGN = 170;
|
||||||
public static $TYPE_KEY_UNASSIGN = 180;
|
public static $TYPE_KEY_UNASSIGN = 180;
|
||||||
public static $TYPE_TOWEL_IN = 190;
|
public static $TYPE_TOWEL_IN = 190;
|
||||||
public static $TYPE_TOWEL_OUT = 200;
|
public static $TYPE_TOWEL_OUT = 200;
|
||||||
public static $TYPE_CRUD = 210;
|
public static $TYPE_CRUD = 210;
|
||||||
public static $TYPE_TICKET_UPDATED_BY_ADMIN = 220;
|
public static $TYPE_TICKET_UPDATED_BY_ADMIN = 220;
|
||||||
|
public static $TYPE_MOBILE_DEVICE_STATUS = 230;
|
||||||
|
|
||||||
|
|
||||||
public static function getTypes(){
|
public static function getTypes()
|
||||||
return [
|
{
|
||||||
|
return [
|
||||||
|
|
||||||
Log::$TYPE_INFO => "Info",
|
Log::$TYPE_INFO => "Info",
|
||||||
Log::$TYPE_ERR => "Hiba",
|
Log::$TYPE_ERR => "Hiba",
|
||||||
Log::$TYPE_TICKET_USAGE_FIRST => "Bérlet használat",
|
Log::$TYPE_TICKET_USAGE_FIRST => "Bérlet használat",
|
||||||
Log::$TYPE_TICKET_USAGE_MULTIPLE => "Többszöri bérlet használat",
|
Log::$TYPE_TICKET_USAGE_MULTIPLE => "Többszöri bérlet használat",
|
||||||
Log::$TYPE_LOGIN => "Bejelentkezés",
|
Log::$TYPE_LOGIN => "Bejelentkezés",
|
||||||
Log::$TYPE_DEFAULT_ACCOUNT=> "Alapértelmezett kassza",
|
Log::$TYPE_DEFAULT_ACCOUNT => "Alapértelmezett kassza",
|
||||||
Log::$TYPE_CREATE_CUSTOMER=> "Új vendég",
|
Log::$TYPE_CREATE_CUSTOMER => "Új vendég",
|
||||||
Log::$TYPE_PROCUREMENT_UPDATE => "Beszerzés módosítás",
|
Log::$TYPE_PROCUREMENT_UPDATE => "Beszerzés módosítás",
|
||||||
Log::$TYPE_TICKET_COUNT_MOVE_OUT => "Ki mozgás",
|
Log::$TYPE_TICKET_COUNT_MOVE_OUT => "Ki mozgás",
|
||||||
Log::$TYPE_WASTE => "Selejt",
|
Log::$TYPE_WASTE => "Selejt",
|
||||||
Log::$TYPE_NEWSLETTER_SUBSCRIBE => "Feliratkozás hirlevélre",
|
Log::$TYPE_NEWSLETTER_SUBSCRIBE => "Feliratkozás hirlevélre",
|
||||||
Log::$TYPE_NEWSLETTER_UNSUBSCRIBE => "Leiratkozás hírlevélről",
|
Log::$TYPE_NEWSLETTER_UNSUBSCRIBE => "Leiratkozás hírlevélről",
|
||||||
Log::$TYPE_NEWSLETTER_SENT => "Hirlevél elküldve",
|
Log::$TYPE_NEWSLETTER_SENT => "Hirlevél elküldve",
|
||||||
Log::$TYPE_TICKET_EXPIRE_SENT => "Bérlet lejáart figyelmeztetés 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_START => "Hirlevél küldés start",
|
||||||
Log::$TYPE_NEWSLETTER_SEND_END => "Hirlevél küldés vége",
|
Log::$TYPE_NEWSLETTER_SEND_END => "Hirlevél küldés vége",
|
||||||
Log::$TYPE_KEY_ASSIGN => "Kulcs kiadás",
|
Log::$TYPE_KEY_ASSIGN => "Kulcs kiadás",
|
||||||
Log::$TYPE_KEY_UNASSIGN => "Kulcs visszaadás",
|
Log::$TYPE_KEY_UNASSIGN => "Kulcs visszaadás",
|
||||||
Log::$TYPE_TOWEL_IN => "Törölköző ki",
|
Log::$TYPE_TOWEL_IN => "Törölköző ki",
|
||||||
Log::$TYPE_TOWEL_OUT => "Törölköző vissza",
|
Log::$TYPE_TOWEL_OUT => "Törölköző vissza",
|
||||||
Log::$TYPE_CRUD => "CRUD",
|
Log::$TYPE_CRUD => "CRUD",
|
||||||
Log::$TYPE_TICKET_UPDATED_BY_ADMIN => "Bérlet módosítás"
|
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
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public static function tableName()
|
public static function tableName()
|
||||||
@ -134,79 +138,89 @@ class Log extends BaseFitnessActiveRecord
|
|||||||
'id_door_log' => Yii::t('common/log', 'Kapu log'),
|
'id_door_log' => Yii::t('common/log', 'Kapu log'),
|
||||||
'created_at' => Yii::t('common/log', 'Dátum idő'),
|
'created_at' => Yii::t('common/log', 'Dátum idő'),
|
||||||
'updated_at' => Yii::t('common/log', 'Módosítás'),
|
'updated_at' => Yii::t('common/log', 'Módosítás'),
|
||||||
'start' => 'Időszak kezdete',
|
'start' => 'Időszak kezdete',
|
||||||
'end' => 'Időszak vége'
|
'end' => 'Időszak vége'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function info($message ){
|
public static function info($message)
|
||||||
self::log(['type' =>self::$TYPE_INFO, 'message' => $message]);
|
{
|
||||||
|
self::log(['type' => self::$TYPE_INFO, 'message' => $message]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* example
|
* example
|
||||||
* Log::log([
|
* Log::log([
|
||||||
'type' =>Log::$TYPE_LOGIN,
|
* 'type' =>Log::$TYPE_LOGIN,
|
||||||
'message' => $message
|
* 'message' => $message
|
||||||
]);
|
* ]);
|
||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
public static function log( $config ){
|
public static function log($config)
|
||||||
$model = new Log($config);
|
{
|
||||||
$model->app = \Yii::$app->name;
|
$model = new Log($config);
|
||||||
$model->url = Url::canonical();
|
$model->app = \Yii::$app->name;
|
||||||
$model->id_user = \Yii::$app->user->id;
|
$model->url = Url::canonical();
|
||||||
$model->save(false);
|
$model->id_user = \Yii::$app->user->id;
|
||||||
|
$model->save(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a log from the console app
|
* create a log from the console app
|
||||||
* */
|
* */
|
||||||
public static function logC( $config ){
|
public static function logC($config)
|
||||||
$model = new Log($config);
|
{
|
||||||
$model->app = "Fitness rendszer";
|
$model = new Log($config);
|
||||||
$model->url = "console";
|
$model->app = "Fitness rendszer";
|
||||||
$model->id_user = 1;
|
$model->url = "console";
|
||||||
$model->save(false);
|
$model->id_user = 1;
|
||||||
|
$model->save(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser(){
|
public function getUser()
|
||||||
return $this->hasOne( User::className(), ["id" =>"id_user" ] );
|
{
|
||||||
|
return $this->hasOne(User::className(), ["id" => "id_user"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTicket(){
|
public function getTicket()
|
||||||
return $this->hasOne( Ticket::className(), ["id_ticket" =>"id_ticket" ] );
|
{
|
||||||
|
return $this->hasOne(Ticket::className(), ["id_ticket" => "id_ticket"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCustomer(){
|
public function getCustomer()
|
||||||
return $this->hasOne( Customer::className(), ["id_customer" =>"id_customer" ] );
|
{
|
||||||
|
return $this->hasOne(Customer::className(), ["id_customer" => "id_customer"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMoneyMovement(){
|
public function getMoneyMovement()
|
||||||
return $this->hasOne( MoneyMovement::className(), ["id_money_movement" =>"id_money_movement" ] );
|
{
|
||||||
|
return $this->hasOne(MoneyMovement::className(), ["id_money_movement" => "id_money_movement"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getUserName(){
|
public function getUserName()
|
||||||
|
{
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
if ( isset($user)){
|
if (isset($user)) {
|
||||||
return $user->username;
|
return $user->username;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCustomerName(){
|
public function getCustomerName()
|
||||||
|
{
|
||||||
$customer = $this->customer;
|
$customer = $this->customer;
|
||||||
if ( isset($customer)){
|
if (isset($customer)) {
|
||||||
return $customer->name;
|
return $customer->name;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTicketName(){
|
public function getTicketName()
|
||||||
|
{
|
||||||
$ticket = $this->ticket;
|
$ticket = $this->ticket;
|
||||||
if ( isset($ticket)){
|
if (isset($ticket)) {
|
||||||
return $ticket->ticketTypeName;
|
return $ticket->ticketTypeName;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -13,6 +13,7 @@ use yii\helpers\ArrayHelper;
|
|||||||
* @property integer $id_card
|
* @property integer $id_card
|
||||||
* @property string $status
|
* @property string $status
|
||||||
* @property string $device_identifier
|
* @property string $device_identifier
|
||||||
|
* @property string $device_name
|
||||||
* @property string $activated_at
|
* @property string $activated_at
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
@ -22,7 +23,8 @@ class MobileDevice extends \yii\db\ActiveRecord
|
|||||||
|
|
||||||
const STATUS_ACTIVE = 'active';
|
const STATUS_ACTIVE = 'active';
|
||||||
const STATUS_INACTIVE = 'inactive';
|
const STATUS_INACTIVE = 'inactive';
|
||||||
const STATUS_DELETED = 'deleted';
|
const STATUS_DELETED_MANUAL = 'deleted_manual';
|
||||||
|
const STATUS_DELETED_SYSTEM = 'deleted_system';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
@ -38,11 +40,11 @@ class MobileDevice extends \yii\db\ActiveRecord
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['id_card'], 'integer'],
|
// [['id_card'], 'integer'],
|
||||||
[['activated_at', 'created_at', 'updated_at'], 'safe'],
|
// [['activated_at', 'created_at', 'updated_at'], 'safe'],
|
||||||
[['created_at', 'updated_at'], 'required'],
|
// [['created_at', 'updated_at'], 'required'],
|
||||||
[['status'], 'string', 'max' => 20],
|
// [['status'], 'string', 'max' => 20],
|
||||||
[['device_identifier'], 'string', 'max' => 255]
|
// [['device_identifier'], 'string', 'max' => 255]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +58,7 @@ class MobileDevice extends \yii\db\ActiveRecord
|
|||||||
'id_card' => Yii::t('common/mobiledevice', 'Id Card'),
|
'id_card' => Yii::t('common/mobiledevice', 'Id Card'),
|
||||||
'status' => Yii::t('common/mobiledevice', 'Status'),
|
'status' => Yii::t('common/mobiledevice', 'Status'),
|
||||||
'device_identifier' => Yii::t('common/mobiledevice', 'Device Identifier'),
|
'device_identifier' => Yii::t('common/mobiledevice', 'Device Identifier'),
|
||||||
|
'device_name' => Yii::t('common/mobiledevice', 'Device Name'),
|
||||||
'activated_at' => Yii::t('common/mobiledevice', 'Activated At'),
|
'activated_at' => Yii::t('common/mobiledevice', 'Activated At'),
|
||||||
'created_at' => Yii::t('common/mobiledevice', 'Created At'),
|
'created_at' => Yii::t('common/mobiledevice', 'Created At'),
|
||||||
'updated_at' => Yii::t('common/mobiledevice', 'Updated At'),
|
'updated_at' => Yii::t('common/mobiledevice', 'Updated At'),
|
||||||
@ -72,4 +75,24 @@ class MobileDevice extends \yii\db\ActiveRecord
|
|||||||
],
|
],
|
||||||
parent::behaviors());
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace frontend\components;
|
namespace frontend\components;
|
||||||
|
|
||||||
|
use common\models\MobileDevice;
|
||||||
use yii\base\Widget;
|
use yii\base\Widget;
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "customer".
|
* This is the model class for table "customer".
|
||||||
@ -15,7 +16,12 @@ class ReceptionCustomerWidget extends Widget{
|
|||||||
public $model;
|
public $model;
|
||||||
|
|
||||||
public function run(){
|
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
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
108
frontend/controllers/MobileDeviceController.php
Normal file
108
frontend/controllers/MobileDeviceController.php
Normal 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.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
89
frontend/models/MobileDeviceSearch.php
Normal file
89
frontend/models/MobileDeviceSearch.php
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
96
frontend/models/MobileStatusForm.php
Normal file
96
frontend/models/MobileStatusForm.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,57 +1,85 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use yii\helpers\Url;
|
use yii\helpers\Url;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
$route = Yii::$app->controller->id .'/'. Yii::$app->controller->action->id;
|
$route = Yii::$app->controller->id . '/' . Yii::$app->controller->action->id;
|
||||||
|
|
||||||
/** @noinspection PhpUnhandledExceptionInspection */
|
/** @noinspection PhpUnhandledExceptionInspection */
|
||||||
$todayDateTime = Yii::$app->formatter->asDatetime(strtotime('today UTC'));
|
$todayDateTime = Yii::$app->formatter->asDatetime(strtotime('today UTC'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$items = [
|
$items = [
|
||||||
[ 'Recepció', ['customer/reception', 'number' => $card->number ]],
|
['Recepció', ['customer/reception', 'number' => $card->number]],
|
||||||
[ 'Termék eladás', ['product/sale', 'number' => $card->number ]],
|
['Termék eladás', ['product/sale', 'number' => $card->number]],
|
||||||
[ 'Adatlap', ['customer/update', 'number' => $card->number ]],
|
['Adatlap', ['customer/update', 'number' => $card->number]],
|
||||||
[ 'Befizetések', ['ticket/index', 'number' => $card->number] ],
|
['Befizetések', ['ticket/index', 'number' => $card->number]],
|
||||||
[ 'Kulcsok', ['key/index', 'id_card' => $card->id_card] ],
|
['Kulcsok', ['key/index', 'id_card' => $card->id_card]],
|
||||||
[ 'Szerződések', ['contract/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 ]],
|
['Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card]],
|
||||||
[ 'Kártya', ['card/info', '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 ]],
|
['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 ]],
|
['Ujjlenyomat', ['fingerprint/index', 'FingerprintSearch[id_card]' => $card->id_card]],
|
||||||
[ 'Jelszó küldése', ['customer/password-change', '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">
|
<div class="row fitness-nav">
|
||||||
<?php foreach ($items as $item){?>
|
<?php foreach ($items as $item) { ?>
|
||||||
<?php
|
<?php
|
||||||
if ( empty($title)){
|
if (empty($title)) {
|
||||||
if ( $item[1][0] == $route) {
|
if ($item[1][0] == $route) {
|
||||||
$title = $item[0];
|
$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>
|
<div role="presentation"
|
||||||
<?php }?>
|
class="col-lg-2 fitness-nav-item <?php echo $item[1][0] == $route ? 'active' : '' ?>"><a
|
||||||
</ul>
|
href="<?php echo Url::toRoute($item[1]) ?>"><?php echo $item[0] ?></a></div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php if ( !empty($title)) {?>
|
<?php if (!empty($title)) { ?>
|
||||||
<h1><?php echo $title?></h1>
|
<h1><?php echo $title ?></h1>
|
||||||
<p>Vendég: <?php echo $card->customer->name ?></p>
|
<p>Vendég: <?php echo $card->customer->name ?></p>
|
||||||
<p>Kártyaszám: <?php echo $card->number ?></p>
|
<p>Kártyaszám: <?php echo $card->number ?></p>
|
||||||
<?php }?>
|
<?php } ?>
|
||||||
|
|||||||
@ -13,55 +13,67 @@ use yii\helpers\Url;
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ( $model->isCardWithCustomer() ){
|
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="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<?php
|
<?php
|
||||||
echo DetailView::widget([
|
echo DetailView::widget([
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
'attributes' =>[
|
'attributes' => $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>
|
||||||
|
<?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>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
86
frontend/views/mobile-device/index.php
Normal file
86
frontend/views/mobile-device/index.php
Normal 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;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
@ -96,3 +96,138 @@ a.desc:after {
|
|||||||
background-color: #dc500b;
|
background-color: #dc500b;
|
||||||
border-color: #faebcc;
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@ -18,8 +18,9 @@ use yii\web\NotFoundHttpException;
|
|||||||
class LoginForm extends Model
|
class LoginForm extends Model
|
||||||
{
|
{
|
||||||
// cardnumber
|
// cardnumber
|
||||||
public $username;
|
public $cardNumber;
|
||||||
public $password;
|
public $deviceId;
|
||||||
|
public $deviceName;
|
||||||
|
|
||||||
public $customer;
|
public $customer;
|
||||||
|
|
||||||
@ -30,9 +31,9 @@ class LoginForm extends Model
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// username and password are both required
|
// username and password are both required
|
||||||
[['username', 'password'], 'required'],
|
[['cardNumber', 'deviceId','deviceName'], 'required'],
|
||||||
// password is validated by validatePassword()
|
// cardNumber is validated by validatePassword()
|
||||||
['password', 'validatePassword'],
|
['cardNumber', 'validateCardNumber'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ class LoginForm extends Model
|
|||||||
* @param array $params the additional name-value pairs given in the rule
|
* @param array $params the additional name-value pairs given in the rule
|
||||||
* @throws \yii\base\InvalidConfigException
|
* @throws \yii\base\InvalidConfigException
|
||||||
*/
|
*/
|
||||||
public function validatePassword($attribute, $params)
|
public function validateCardNumber($attribute, $params)
|
||||||
{
|
{
|
||||||
if ($this->hasErrors()) {
|
if ($this->hasErrors()) {
|
||||||
/** @var \common\models\Customer $user */
|
/** @var \common\models\Customer $user */
|
||||||
@ -72,7 +73,7 @@ class LoginForm extends Model
|
|||||||
|
|
||||||
if ($this->customer === null) {
|
if ($this->customer === null) {
|
||||||
$mobileDeviceManager = new MobileDeviceManager();
|
$mobileDeviceManager = new MobileDeviceManager();
|
||||||
$mobileDevice = $mobileDeviceManager->loginOrCreate($this->username, $this->password);
|
$mobileDevice = $mobileDeviceManager->loginOrCreate($this->cardNumber, $this->deviceId, $this->deviceName);
|
||||||
/** @var Customer */
|
/** @var Customer */
|
||||||
$this->customer = Customer::find()->andWhere([
|
$this->customer = Customer::find()->andWhere([
|
||||||
'id_customer_card' => $mobileDevice->id_card
|
'id_customer_card' => $mobileDevice->id_card
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user