Skip to content

Commit

Permalink
Initial work on admin-only check in/out functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmsworth committed Jun 14, 2022
1 parent c88da9c commit ab9a79b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Domain/ReservationView.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,21 @@ public function IsCheckinEnabled()
public function IsCheckinAvailable()
{
$checkinMinutes = Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_CHECKIN_MINUTES, new IntConverter());
$checkinAdminOnly = Configuration::Instance()->GetSecionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_CHECKIN_ADMIN_ONLY, new BooleanConverter());

if ($this->CheckinDate->ToString() == '' && Date::Now()->AddMinutes($checkinMinutes)->GreaterThanOrEqual($this->StartDate)) {
return $this->IsCheckinEnabled();
if (!($checkinAdminOnly) || $currentUser->IsAdmin) {
if ($this->CheckinDate->ToString() == '' && Date::Now()->AddMinutes($checkinMinutes)->GreaterThanOrEqual($this->StartDate)) {
return $this->IsCheckinEnabled();
}
}

return false;
}

public function IsCheckoutAvailable()
{
//$checkoutAdminOnly = Configuration::Instance()->GetSecionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_CHECKOUT_ADMIN_ONLY, new BooleanConverter());

if ($this->StartDate->LessThan(Date::Now()) &&
$this->CheckoutDate->ToString() == '' &&
$this->CheckinDate->ToString() != '') {
Expand Down
2 changes: 2 additions & 0 deletions config/config.devel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
$conf['settings']['reservation']['default.end.reminder'] = ''; // the default end reservation reminder. format is ## interval. for example, 10 minutes, 2 hours, 6 days.
$conf['settings']['reservation']['title.required'] = 'false';
$conf['settings']['reservation']['description.required'] = 'false';
$conf['settings']['reservation']['checkin.admin.only'] = 'true';

/**
* Email notification configuration
*/
Expand Down
1 change: 1 addition & 0 deletions lib/Config/ConfigKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class ConfigKeys
public const RESERVATION_END_REMINDER = 'default.end.reminder';
public const RESERVATION_TITLE_REQUIRED = 'title.required';
public const RESERVATION_DESCRIPTION_REQUIRED = 'description.required';
public const RESERVATION_CHECKIN_ADMIN_ONLY = 'checkin.admin.only';

public const IMAGE_UPLOAD_DIRECTORY = 'image.upload.directory';
public const IMAGE_UPLOAD_URL = 'image.upload.url';
Expand Down

0 comments on commit ab9a79b

Please sign in to comment.