diff --git a/common/manager/MobileDeviceManager.php b/common/manager/MobileDeviceManager.php index edd67f9..0550d3a 100644 --- a/common/manager/MobileDeviceManager.php +++ b/common/manager/MobileDeviceManager.php @@ -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); } } diff --git a/common/models/Log.php b/common/models/Log.php index 1f4d21c..278376f 100644 --- a/common/models/Log.php +++ b/common/models/Log.php @@ -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; diff --git a/common/models/MobileDevice.php b/common/models/MobileDevice.php index dba6373..f454959 100644 --- a/common/models/MobileDevice.php +++ b/common/models/MobileDevice.php @@ -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; + } } diff --git a/console/migrations/m220218_192423_alter_table_mobile_device_add_column_device_name.php b/console/migrations/m220218_192423_alter_table_mobile_device_add_column_device_name.php new file mode 100644 index 0000000..25c3829 --- /dev/null +++ b/console/migrations/m220218_192423_alter_table_mobile_device_add_column_device_name.php @@ -0,0 +1,43 @@ +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; + } + */ +} diff --git a/frontend/components/ReceptionCustomerWidget.php b/frontend/components/ReceptionCustomerWidget.php index 96255e2..cda0162 100644 --- a/frontend/components/ReceptionCustomerWidget.php +++ b/frontend/components/ReceptionCustomerWidget.php @@ -1,6 +1,7 @@ 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 + ]); } -} \ No newline at end of file +} diff --git a/frontend/controllers/MobileDeviceController.php b/frontend/controllers/MobileDeviceController.php new file mode 100644 index 0000000..6972ac8 --- /dev/null +++ b/frontend/controllers/MobileDeviceController.php @@ -0,0 +1,108 @@ + [ + '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.'); + } + } + +} diff --git a/frontend/models/MobileDeviceSearch.php b/frontend/models/MobileDeviceSearch.php new file mode 100644 index 0000000..728c826 --- /dev/null +++ b/frontend/models/MobileDeviceSearch.php @@ -0,0 +1,89 @@ +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; + } + +} diff --git a/frontend/models/MobileStatusForm.php b/frontend/models/MobileStatusForm.php new file mode 100644 index 0000000..522f30b --- /dev/null +++ b/frontend/models/MobileStatusForm.php @@ -0,0 +1,96 @@ +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; + } + } + +} diff --git a/frontend/views/common/_customer_tab.php b/frontend/views/common/_customer_tab.php index 5ea6c5f..d86533e 100644 --- a/frontend/views/common/_customer_tab.php +++ b/frontend/views/common/_customer_tab.php @@ -1,57 +1,85 @@ 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]], ]; - - - ?> + +
- +
+ + + + +
+
- -

+ +

Vendég: customer->name ?>

Kártyaszám: number ?>

- + diff --git a/frontend/views/common/_reception_customer.php b/frontend/views/common/_reception_customer.php index 29262a3..6083835 100644 --- a/frontend/views/common/_reception_customer.php +++ b/frontend/views/common/_reception_customer.php @@ -13,57 +13,69 @@ use yii\helpers\Url; 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) ? '' : ( + "
$model->card->number])."'>" + .$model->keysText + .Html::hiddenInput("KeyToggleForm[key]", $model->keysText) + .Html::submitButton("Visszaad", [ 'style' => 'float: right;', 'class' => 'btn btn-primary btn-xs']) + ."
") + , + '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' + ], + ]; + + ?>
$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) ? '' : ( - "
$model->card->number])."'>" - .$model->keysText - .Html::hiddenInput("KeyToggleForm[key]", $model->keysText) - .Html::submitButton("Visszaad", [ 'style' => 'float: right;', 'class' => 'btn btn-primary btn-xs']) - ."
") - , - '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 + ]) ?> +
+ $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']); + }?> +
\ No newline at end of file +?> diff --git a/frontend/views/mobile-device/index.php b/frontend/views/mobile-device/index.php new file mode 100644 index 0000000..d426740 --- /dev/null +++ b/frontend/views/mobile-device/index.php @@ -0,0 +1,86 @@ +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; + } + ], + ], +]); ?> diff --git a/frontend/web/css/site.css b/frontend/web/css/site.css index fe8d94b..4004131 100644 --- a/frontend/web/css/site.css +++ b/frontend/web/css/site.css @@ -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); +} diff --git a/mobileapi/models/LoginForm.php b/mobileapi/models/LoginForm.php index f730cba..4ca9ed4 100644 --- a/mobileapi/models/LoginForm.php +++ b/mobileapi/models/LoginForm.php @@ -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