implement mobile devices in reception
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user