Skip to content
Snippets Groups Projects
Commit 6f8b895e authored by David Siegfried's avatar David Siegfried
Browse files

Biest #199

Closes #199

Merge request studip/studip!490
parent 3fa639da
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ class Resources_PrintController extends AuthenticatedController ...@@ -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(); throw new AccessDeniedException();
} }
...@@ -61,13 +61,13 @@ class Resources_PrintController extends AuthenticatedController ...@@ -61,13 +61,13 @@ class Resources_PrintController extends AuthenticatedController
$views = new ViewsWidget(); $views = new ViewsWidget();
if ($GLOBALS['user']->id && ($GLOBALS['user']->id != 'nobody')) { if ($GLOBALS['user']->id && ($GLOBALS['user']->id != 'nobody')) {
if ($this->resource->userHasPermission($current_user, 'user')) { if ($this->resource->userHasPermission($current_user)) {
$views->addLink( $views->addLink(
_('Standard Zeitfenster'), _('Standard Zeitfenster'),
URLHelper::getURL( $this->individual_booking_planURL(
'dispatch.php/resources/print/individual_booking_plan/' . $this->resource->id, $this->resource->id,
[ [
'defaultDate' => Request::get('defaultDate', date('Y-m-d')) 'defaultDate' => Request::get('defaultDate', date('Y-m-d', $this->timestamp))
] ]
), ),
null, null,
...@@ -76,11 +76,11 @@ class Resources_PrintController extends AuthenticatedController ...@@ -76,11 +76,11 @@ class Resources_PrintController extends AuthenticatedController
$views->addLink( $views->addLink(
_('Ganztägiges Zeitfenster'), _('Ganztägiges Zeitfenster'),
URLHelper::getURL( $this->individual_booking_planURL(
'dispatch.php/resources/print/individual_booking_plan/' . $this->resource->id, $this->resource->id,
[ [
'allday' => true, 'allday' => true,
'defaultDate' => Request::get('defaultDate', date('Y-m-d')) 'defaultDate' => Request::get('defaultDate', date('Y-m-d', $this->timestamp))
] ]
), ),
null, null,
......
...@@ -297,7 +297,7 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -297,7 +297,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
. $this->resource->id . $this->resource->id
), ),
Icon::create('add') Icon::create('add')
)->asDialog("size=auto"); )->asDialog('size=auto');
} }
if ($this->resource->userHasPermission($current_user)) { if ($this->resource->userHasPermission($current_user)) {
$actions->addLink( $actions->addLink(
...@@ -312,10 +312,14 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -312,10 +312,14 @@ class Resources_RoomPlanningController extends AuthenticatedController
'dispatch.php/resources/print/individual_booking_plan/' 'dispatch.php/resources/print/individual_booking_plan/'
. $this->resource->id, . $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( $actions->addLink(
...@@ -323,13 +327,14 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -323,13 +327,14 @@ class Resources_RoomPlanningController extends AuthenticatedController
URLHelper::getURL( URLHelper::getURL(
'dispatch.php/resources/export/resource_bookings/' . $this->resource->id, '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'), Icon::create('file-excel'),
[ [
'data-dialog' => 'size=auto', 'data-dialog' => 'size=auto',
'id' => 'export-resource-bookings-action' 'class' => 'resource-bookings-actions'
] ]
); );
} }
......
...@@ -670,39 +670,25 @@ STUDIP.ready(function () { ...@@ -670,39 +670,25 @@ STUDIP.ready(function () {
} }
function updateDateURL() { function updateDateURL() {
var changedmoment; let changedMoment;
$('*[data-resources-fullcalendar="1"]').each(function () { $('[data-resources-fullcalendar="1"]').each(function () {
changedmoment = $(this)[0].calendar.getDate(); changedMoment = $(this)[0].calendar.getDate();
}); });
if (changedmoment) { if (changedMoment) {
let changedDate = STUDIP.Fullcalendar.toRFC3339String(changedMoment).split('T')[0];
//Get the timestamp: //Get the timestamp:
var timestamp = changedmoment.getTime() / 1000; let 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 += '&timestamp=' + timestamp;
} else {
export_url += '?timestamp=' + timestamp;
}
}
jQuery(export_action).attr('href', export_url);
}
// Now change the URL of the window. $('a.resource-bookings-actions').each(function () {
var changeddate = STUDIP.Fullcalendar.toRFC3339String(changedmoment).split('T')[0]; 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); const url = new URL(window.location.href);
url.searchParams.set('defaultDate', changeddate); url.searchParams.set('defaultDate', changedDate);
// Update url in history // Update url in history
history.pushState({}, null, url.toString()); history.pushState({}, null, url.toString());
...@@ -715,10 +701,10 @@ STUDIP.ready(function () { ...@@ -715,10 +701,10 @@ STUDIP.ready(function () {
$('.booking-plan-allday_view').attr('href', url.toString()); $('.booking-plan-allday_view').attr('href', url.toString());
// Update sidebar value // 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: //Store the date in the sessionStorage:
sessionStorage.setItem('booking_plan_date', changeddate) sessionStorage.setItem('booking_plan_date', changedDate)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment