Skip to content

Commit

Permalink
Visibilty of Check-in/out now includes check for admin only option
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmsworth committed Jun 16, 2022
1 parent 5523636 commit 0612ded
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
14 changes: 14 additions & 0 deletions Controls/Dashboard/UpcomingReservations.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public function BindNextWeek($reservations)
{
$this->Set('NextWeeksReservations', $reservations);
}

public function SetAllowCheckin($allowCheckin)
{
$this->Set('allowCheckin',$allowCheckin);
}

public function SetAllowCheckout($allowCheckout)
{
$this->Set('allowCheckout',$allowCheckout);
}

}

interface IUpcomingReservationsControl
Expand All @@ -67,6 +78,9 @@ public function SetTimezone($timezone);
public function SetTotal($total);
public function SetUserId($userId);

public function SetAllowCheckin($allowCheckin);
public function SetAllowCheckout($allowCheckout);

public function BindToday($reservations);
public function BindTomorrow($reservations);
public function BindThisWeek($reservations);
Expand Down
9 changes: 9 additions & 0 deletions Presenters/Dashboard/UpcomingReservationsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,19 @@ public function PageLoad()
}
}

$checkinAdminOnly = Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_CHECKIN_ADMIN_ONLY, new BooleanConverter());
$checkoutAdminOnly = Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_CHECKOUT_ADMIN_ONLY, new BooleanConverter());

$allowCheckin = $user->IsAdmin || !$checkinAdminOnly;
$allowCheckout = $user->IsAdmin || !$checkoutAdminOnly;

$this->control->SetTotal(count($consolidated));
$this->control->SetTimezone($timezone);
$this->control->SetUserId($user->UserId);

$this->control->SetAllowCheckin($allowCheckin);
$this->control->SetAllowCheckout($allowCheckout);

$this->control->BindToday($todays);
$this->control->BindTomorrow($tomorrows);
$this->control->BindThisWeek($thisWeeks);
Expand Down
8 changes: 4 additions & 4 deletions tpl/Dashboard/admin_upcoming_reservations.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@
{translate key="Today"} ({$TodaysReservations|default:array()|count})
</div>
{foreach from=$TodaysReservations item=reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation allowCheckin=$allowCheckin allowCheckout=$allowCheckout}
{/foreach}

<div class="timespan">
{translate key="Tomorrow"} ({$TomorrowsReservations|default:array()|count})
</div>
{foreach from=$TomorrowsReservations item=reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation allowCheckin=$allowCheckin allowCheckout=$allowCheckout}
{/foreach}

<div class="timespan">
{translate key="LaterThisWeek"} ({$ThisWeeksReservations|default:array()|count})
</div>
{foreach from=$ThisWeeksReservations item=reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation allowCheckin=$allowCheckin allowCheckout=$allowCheckout}
{/foreach}

<div class="timespan">
{translate key="NextWeek"} ({$NextWeeksReservations|default:array()|count})
</div>
{foreach from=$NextWeeksReservations item=reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation allowCheckin=$allowCheckin allowCheckout=$allowCheckout}
{/foreach}
</div>
{else}
Expand Down
4 changes: 2 additions & 2 deletions tpl/Dashboard/dashboard_reservation.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{assign var=checkin value=$reservation->IsCheckinEnabled() && $reservation->RequiresCheckin()}
{assign var=checkout value=$reservation->IsCheckinEnabled() && $reservation->RequiresCheckout()}
{assign var=checkin value=$reservation->IsCheckinEnabled() && $reservation->RequiresCheckin() && $allowCheckin}
{assign var=checkout value=$reservation->IsCheckinEnabled() && $reservation->RequiresCheckout() && allowCheckout}
{assign var=class value=""}
{if $reservation->RequiresApproval}{assign var=class value="pending"}{/if}
<div class="reservation row {$class}" id="{$reservation->ReferenceNumber}">
Expand Down
8 changes: 4 additions & 4 deletions tpl/Dashboard/upcoming_reservations.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@
{translate key="Today"} ({$TodaysReservations|default:array()|count})
</div>
{foreach from=$TodaysReservations item=reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation allowCheckin=$allowCheckin allowCheckout=$allowCheckout}
{/foreach}

<div class="timespan">
{translate key="Tomorrow"} ({$TomorrowsReservations|default:array()|count})
</div>
{foreach from=$TomorrowsReservations item=reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation allowCheckin=$allowCheckin allowCheckout=$allowCheckout}
{/foreach}

<div class="timespan">
{translate key="LaterThisWeek"} ({$ThisWeeksReservations|default:array()|count})
</div>
{foreach from=$ThisWeeksReservations item=reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation allowCheckin=$allowCheckin allowCheckout=$allowCheckout}
{/foreach}

<div class="timespan">
{translate key="NextWeek"} ({$NextWeeksReservations|default:array()|count})
</div>
{foreach from=$NextWeeksReservations item=reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation}
{include file='Dashboard/dashboard_reservation.tpl' reservation=$reservation allowCheckin=$allowCheckin allowCheckout=$allowCheckout}
{/foreach}
</div>
{else}
Expand Down

0 comments on commit 0612ded

Please sign in to comment.