diff --git a/app/controllers/resources/print.php b/app/controllers/resources/print.php index 05a6df3958de653e7f0549b6ea52f04534cec35e..066a3249f946eaaa478e47e2ad18f106e535abb1 100644 --- a/app/controllers/resources/print.php +++ b/app/controllers/resources/print.php @@ -48,7 +48,7 @@ class Resources_PrintController extends AuthenticatedController ) ); - if (!$this->resource->userHasPermission($current_user, 'user')) { + if (!$this->resource->userHasPermission($current_user)) { throw new AccessDeniedException(); } @@ -61,13 +61,13 @@ class Resources_PrintController extends AuthenticatedController $views = new ViewsWidget(); if ($GLOBALS['user']->id && ($GLOBALS['user']->id != 'nobody')) { - if ($this->resource->userHasPermission($current_user, 'user')) { + if ($this->resource->userHasPermission($current_user)) { $views->addLink( _('Standard Zeitfenster'), - URLHelper::getURL( - 'dispatch.php/resources/print/individual_booking_plan/' . $this->resource->id, + $this->individual_booking_planURL( + $this->resource->id, [ - 'defaultDate' => Request::get('defaultDate', date('Y-m-d')) + 'defaultDate' => Request::get('defaultDate', date('Y-m-d', $this->timestamp)) ] ), null, @@ -76,11 +76,11 @@ class Resources_PrintController extends AuthenticatedController $views->addLink( _('Ganztägiges Zeitfenster'), - URLHelper::getURL( - 'dispatch.php/resources/print/individual_booking_plan/' . $this->resource->id, + $this->individual_booking_planURL( + $this->resource->id, [ 'allday' => true, - 'defaultDate' => Request::get('defaultDate', date('Y-m-d')) + 'defaultDate' => Request::get('defaultDate', date('Y-m-d', $this->timestamp)) ] ), null, diff --git a/app/controllers/resources/room_planning.php b/app/controllers/resources/room_planning.php index e4c2b97e023567b6f14d3784344ed2f9d5cff217..23056bc5ab4953722ef64d70d09f84530be13c0b 100644 --- a/app/controllers/resources/room_planning.php +++ b/app/controllers/resources/room_planning.php @@ -297,7 +297,7 @@ class Resources_RoomPlanningController extends AuthenticatedController . $this->resource->id ), Icon::create('add') - )->asDialog("size=auto"); + )->asDialog('size=auto'); } if ($this->resource->userHasPermission($current_user)) { $actions->addLink( @@ -312,10 +312,14 @@ class Resources_RoomPlanningController extends AuthenticatedController 'dispatch.php/resources/print/individual_booking_plan/' . $this->resource->id, [ - 'timestamp' => $week_timestamp + 'timestamp' => $week_timestamp, + 'defaultDate' => date('Y-m-d', $week_timestamp) ] ), - Icon::create('print') + Icon::create('print'), + [ + 'class' => 'resource-bookings-actions' + ] ); } $actions->addLink( @@ -323,13 +327,14 @@ class Resources_RoomPlanningController extends AuthenticatedController URLHelper::getURL( 'dispatch.php/resources/export/resource_bookings/' . $this->resource->id, [ - 'timestamp' => $week_timestamp + 'timestamp' => $week_timestamp, + 'defaultDate' => date('Y-m-d', $week_timestamp) ] ), Icon::create('file-excel'), [ 'data-dialog' => 'size=auto', - 'id' => 'export-resource-bookings-action' + 'class' => 'resource-bookings-actions' ] ); } diff --git a/resources/assets/javascripts/bootstrap/resources.js b/resources/assets/javascripts/bootstrap/resources.js index bda46dc6513284d58ef92f5b901e581319ca926a..bc0b460a1d9d9e3169752c842ee7db2c24b09c64 100644 --- a/resources/assets/javascripts/bootstrap/resources.js +++ b/resources/assets/javascripts/bootstrap/resources.js @@ -670,39 +670,25 @@ STUDIP.ready(function () { } function updateDateURL() { - var changedmoment; - $('*[data-resources-fullcalendar="1"]').each(function () { - changedmoment = $(this)[0].calendar.getDate(); + let changedMoment; + $('[data-resources-fullcalendar="1"]').each(function () { + changedMoment = $(this)[0].calendar.getDate(); }); - if (changedmoment) { + if (changedMoment) { + let changedDate = STUDIP.Fullcalendar.toRFC3339String(changedMoment).split('T')[0]; //Get the timestamp: - var timestamp = changedmoment.getTime() / 1000; - - //Set the URL parameter for the "export bookings" action - //in the sidebar: - var export_action = jQuery('#export-resource-bookings-action'); - if (export_action.length > 0) { - var export_url = jQuery(export_action).attr('href'); - if (export_url.search(/[?&]timestamp=/) >= 0) { - export_url = export_url.replace( - /timestamp=[0-9]{0,10}/, - 'timestamp=' + timestamp - ); - } else { - if (export_url.search(/\?/) >= 0) { - export_url += '×tamp=' + timestamp; - } else { - export_url += '?timestamp=' + timestamp; - } - } - jQuery(export_action).attr('href', export_url); - } + let timeStamp = changedMoment.getTime() / 1000; - // Now change the URL of the window. - var changeddate = STUDIP.Fullcalendar.toRFC3339String(changedmoment).split('T')[0]; + $('a.resource-bookings-actions').each(function () { + const url = new URL(this.href); + url.searchParams.set('timestamp', timeStamp) + url.searchParams.set('defaultDate', changedDate) + this.href = url.toString(); + }); + // Now change the URL of the window. const url = new URL(window.location.href); - url.searchParams.set('defaultDate', changeddate); + url.searchParams.set('defaultDate', changedDate); // Update url in history history.pushState({}, null, url.toString()); @@ -715,10 +701,10 @@ STUDIP.ready(function () { $('.booking-plan-allday_view').attr('href', url.toString()); // Update sidebar value - $('#booking-plan-jmpdate').val(changedmoment.toLocaleDateString('de-DE')); + $('#booking-plan-jmpdate').val(changedMoment.toLocaleDateString('de-DE')); //Store the date in the sessionStorage: - sessionStorage.setItem('booking_plan_date', changeddate) + sessionStorage.setItem('booking_plan_date', changedDate) } }