Skip to content

Commit

Permalink
Fix "now" indicator in reservation calendar
Browse files Browse the repository at this point in the history
fixes #15929
  • Loading branch information
cedric-anne committed Apr 15, 2024
1 parent c6ee99a commit 59187df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/reservations.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var Reservations = function() {
this.currentv = null;
this.defaultDate = null;
this.can_reserve = true;
this.now = null;

var my = this;

Expand All @@ -60,13 +61,15 @@ var Reservations = function() {
if (config.can_reserve != undefined) {
my.can_reserve = config.can_reserve;
}
my.now = config.now || null;
};

my.displayPlanning = function() {
my.calendar = new FullCalendar.Calendar(document.getElementById(my.dom_id), {
schedulerLicenseKey: my.license_key,
timeZone: 'UTC',
nowIndicator: true,
now: my.now,// as we set the calendar as UTC, we need to reprecise the current datetime
theme: true,
editable: true,
defaultDate: my.defaultDate,
Expand Down
4 changes: 4 additions & 0 deletions src/Reservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ public static function showCalendar(int $ID = 0)
Session::haveRight("reservation", ReservationItem::RESERVEANITEM)
&& count(self::getReservableItemtypes()) > 0
) ? "true" : "false";
$now = date("Y-m-d H:i:s");
$js = <<<JAVASCRIPT
$(function() {
var reservation = new Reservations();
Expand All @@ -574,6 +575,7 @@ public static function showCalendar(int $ID = 0)
rand: $rand,
license_key: '$scheduler_key',
can_reserve: $can_reserve,
now: '$now',
});
reservation.displayPlanning();
});
Expand Down Expand Up @@ -1144,6 +1146,7 @@ public static function showForItem(CommonDBTM $item, $withtemplate = 0)
if (isset($_REQUEST['defaultDate'])) {
$defaultDate = $_REQUEST['defaultDate'];
}
$now = date("Y-m-d H:i:s");
$js = <<<JAVASCRIPT
$(function() {
var reservation = new Reservations();
Expand All @@ -1155,6 +1158,7 @@ public static function showForItem(CommonDBTM $item, $withtemplate = 0)
currentv: 'listFull',
defaultDate: '$defaultDate',
license_key: '$scheduler_key',
now: '$now',
});
reservation.displayPlanning();
});
Expand Down

0 comments on commit 59187df

Please sign in to comment.