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
)
);
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,
......
......@@ -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'
]
);
}
......
......@@ -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 += '&timestamp=' + 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)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment