#366 Feature: Time Interval Buttons (on Shifts page), closes #366

main
Igor Scheller 7 years ago
parent 599f2fd264
commit 0b45d2a88f

@ -242,7 +242,14 @@ function view_user_shifts()
page_link_to('shifts_json_export', ['key' => $user['api_key']]),
page_link_to('user_myshifts', ['reset' => 1])
) . '</p>',
'filter' => _('Filter')
'filter' => _('Filter'),
'set_yesterday' => _('Yesterday'),
'set_today' => _('Today'),
'set_tomorrow' => _('Tomorrow'),
'set_last_8h' => _('last 8h'),
'set_last_4h' => _('last 4h'),
'set_next_4h' => _('next 4h'),
'set_next_8h' => _('next 8h'),
])
])
]);

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Engelsystem 2.0\n"
"POT-Creation-Date: 2017-11-24 11:59+0100\n"
"PO-Revision-Date: 2017-11-24 12:00+0100\n"
"PO-Revision-Date: 2017-11-29 13:20+0100\n"
"Last-Translator: msquare <msquare@notrademark.de>\n"
"Language-Team: \n"
"Language: de_DE\n"
@ -1837,6 +1837,34 @@ msgstr ""
msgid "Filter"
msgstr "Filter"
#: engelsystem/includes/pages/user_shifts.php:246
msgid "Yesterday"
msgstr "Gestern"
#: engelsystem/includes/pages/user_shifts.php:247
msgid "Today"
msgstr "Heute"
#: engelsystem/includes/pages/user_shifts.php:248
msgid "Tomorrow"
msgstr "Morgen"
#: engelsystem/includes/pages/user_shifts.php:249
msgid "last 8h"
msgstr "letzte 8h"
#: engelsystem/includes/pages/user_shifts.php:250
msgid "last 4h"
msgstr "letzte 4h"
#: engelsystem/includes/pages/user_shifts.php:251
msgid "next 4h"
msgstr "nächste 4h"
#: engelsystem/includes/pages/user_shifts.php:252
msgid "next 8h"
msgstr "nächste 8h"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:278
#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:49
msgid "All"

@ -17,6 +17,63 @@ function checkAll(id, checked) {
}
}
/**
* @param {moment} date
*/
function formatDay(date) {
return date.format('YYYY-MM-DD')
}
/**
* @param {moment} date
*/
function formatTime(date) {
return date.format('HH:mm')
}
/**
* @param {moment} from
* @param {moment} to
*/
function setInput(from, to) {
var from_day = $('#start_day'), from_time = $('#start_time'), to_day = $('#end_day'), to_time = $('#end_time');
from_day.val(formatDay(from));
from_time.val(formatTime(from));
to_day.val(formatDay(to));
to_time.val(formatTime(to));
}
function setDay(days) {
days = days || 0;
var from = moment();
from.hours(0).minutes(0).seconds(0);
from.add(days, 'd');
var to = from.clone();
to.hours(23).minutes(59);
setInput(from, to)
}
function setHours(hours) {
hours = hours || 1;
var from = moment();
var to = from.clone();
to.add(hours, 'h');
if (to < from) {
setInput(to, from);
return;
}
setInput(from, to);
}
$(function () {
/**
* Disable every submit button after clicking (to prevent double-clicking)

@ -41,6 +41,19 @@
</div>
</div>
</div>
<div class="form-group" style="margin-top: .5em">
<div class="btn-group">
<a href="javascript:setDay(-1)" class="btn btn-default ">%set_yesterday%</a>
<a href="javascript:setDay()" class="btn btn-default ">%set_today%</a>
<a href="javascript:setDay(1)" class="btn btn-default ">%set_tomorrow%</a>
</div>
<div class="btn-group">
<a href="javascript:setHours(-8)" class="btn btn-default ">%set_last_8h%</a>
<a href="javascript:setHours(-4)" class="btn btn-default ">%set_last_4h%</a>
<a href="javascript:setHours(4)" class="btn btn-default ">%set_next_4h%</a>
<a href="javascript:setHours(8)" class="btn btn-default ">%set_next_8h%</a>
</div>
</div>
</div>
<div class="col-md-2">%room_select%</div>
<div class="col-md-2">%type_select%</div>

Loading…
Cancel
Save