Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct the "Hours to be worked" #95

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions db/update.d/23_room_location.php

This file was deleted.

5 changes: 1 addition & 4 deletions includes/model/Room_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ function Room_delete($room_id) {
* @param boolean $public
* Is the room visible for angels?
*/
function Room_create($name, $from_frab, $public, $location, $lat, $long) {
function Room_create($name, $from_frab, $public) {
$result = sql_query("
INSERT INTO `Room` SET
`Name`='" . sql_escape($name) . "',
`location`='" . sql_escape($location) . "',
`lat`='" . sql_escape($lat) . "',
`long`='" . sql_escape($long) . "',
`FromPentabarf`='" . ($from_frab ? 'Y' : 'N') . "',
`show`='" . ($public ? 'Y' : 'N') . "',
`Number`=0");
Expand Down
58 changes: 2 additions & 56 deletions includes/pages/admin_rooms.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ function admin_rooms()
if (isset($_REQUEST['show'])) {
$msg = "";
$name = "";
$location = "";
$lat = "";
$long = "";
$from_pentabarf = "";
$public = 'Y';
$number = "";
Expand All @@ -46,9 +43,6 @@ function admin_rooms()
if (count($room) > 0) {
$id = $_REQUEST['id'];
$name = $room[0]['Name'];
$location = $room[0]['location'];
$lat = $room[0]['lat'];
$long = $room[0]['long'];
$from_pentabarf = $room[0]['FromPentabarf'];
$public = $room[0]['show'];
$needed_angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($id) . "'");
Expand All @@ -69,21 +63,6 @@ function admin_rooms()
$msg .= error(_("Please enter a name."), true);
}

if (isset($_REQUEST['location']) && strlen(strip_request_item('location')) > 0) {
$location = strip_request_item('location');
} else {
$ok = false;
$msg .= error(_("Please enter a location."));
}

if (isset($_REQUEST['lat']) && isset($_REQUEST['long'])) {
$lat = $_REQUEST['lat'];
$long = $_REQUEST['long'];
} else {
$ok = false;
$msg .= error(_("Please enter a location - no lat long values found."));
}

$from_pentabarf = isset($_REQUEST['from_pentabarf']) ? 'Y' : '';
$public = isset($_REQUEST['public']) ? 'Y' : '';

Expand All @@ -105,20 +84,17 @@ function admin_rooms()
if (isset($id)) {
sql_query(
sprintf(
"UPDATE `Room` SET `Name`='%s', `FromPentabarf`='%s', `show`='%s', `Number`='%s', `location` = '%s', `lat` = '%s', `long` = '%s' WHERE `RID`='%s' LIMIT 1",
"UPDATE `Room` SET `Name`='%s', `FromPentabarf`='%s', `show`='%s', `Number`='%s' WHERE `RID`='%s' LIMIT 1",
sql_escape($name),
sql_escape($from_pentabarf),
sql_escape($public),
sql_escape($number),
sql_escape($location),
sql_escape($lat),
sql_escape($long),
sql_escape($id)
)
);
engelsystem_log("Location updated: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
} else {
$id = Room_create($name, $from_pentabarf, $public, $location, $lat, $long);
$id = Room_create($name, $from_pentabarf, $public);
if ($id === false)
engelsystem_error("Unable to create location.");
engelsystem_log("Location created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
Expand Down Expand Up @@ -157,9 +133,6 @@ function admin_rooms()

$form_elements = [];
$form_elements[] = form_text('name', _("Name"), $name);
$form_elements[] = form_text('location', _("Location"), $location);
$form_elements[] = form_text('lat', _("Latitude"), $lat, false, true);
$form_elements[] = form_text('long', _("Longitude"), $long, false, true);
if ($enable_frab_import) {
$form_elements[] = form_checkbox('from_pentabarf', _("Frab import"), $from_pentabarf);
}
Expand All @@ -182,33 +155,6 @@ function admin_rooms()
join($angeltypes_count_form)
))
)),
script("
jQuery(function ($) {
var input = $(\"input[id='form_location']\");
var inputElement = document.getElementById(input.attr('id'));
var searchBox = new google.maps.places.SearchBox(inputElement);
searchBox.addListener('places_changed', function() {
var places = searchBox.getPlaces();
if (places.length == 0) {
return;
}

var place = places.pop();
var lat = place.geometry.location.lat();
var long = place.geometry.location.lng();

$(\"input[id='form_lat']\").val(lat);
$(\"input[id='form_long']\").val(long);
});

// suppress form submit on enter
input.keypress(function (event) {
if (event.keyCode === 13) {
return false;
}
});
});
")
)),
form_submit('submit', _("Save"))
))
Expand Down
44 changes: 40 additions & 4 deletions includes/pages/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,16 @@ function getListUpcomingShifts($shifts, $withinSeconds)
*
* @return array
*/
function getUpcomingShifts($shifts, $withinSeconds)
function getUpcomingShifts($shifts, $withinSeconds = false)
{
return array_filter($shifts, function ($shift) use ($withinSeconds) {
$currentTime = time();

if (!$withinSeconds) {
// just use all upcoming
return $shift['start'] > $currentTime || $shift['end'] > $currentTime;
}

return $shift['start'] > $currentTime && $shift['start'] <= ($currentTime + $withinSeconds);
});
}
Expand Down Expand Up @@ -320,18 +325,49 @@ function getCurrentlyWorkingAngels()
*/
function countHoursToBeWorked($shifts)
{
$upcomingShifts = getUpcomingShifts($shifts);
$ids = array();
foreach ($upcomingShifts as $shift) {
$ids[] = $shift['SID'];
}
if (count($ids) === 0) {
return 0;
}

$shiftWithNeededAngels = sql_select(
sprintf(
"SELECT
s.SID,
s.start,
s.end,
SUM(nat.count) as countAngels
FROM Shifts s
INNER JOIN NeededAngelTypes nat
ON s.SID = nat.shift_id
WHERE s.SID IN ('%s')
GROUP BY s.SID;",
implode("', '", $ids)
)
);

if (!$shiftWithNeededAngels) {
return 0;
}

$seconds = 0;
$currentTime = time();

foreach ($shifts as $shift) {
foreach ($shiftWithNeededAngels as $shift) {
$diff = 0;
if ($shift['start'] >= $currentTime) {
// has not started yet
$diff = $shift['end'] - $shift['start'];
$seconds += $diff > 0 ? $diff : 0;
} elseif ($shift['end'] >= $currentTime && $shift['start'] <= $currentTime) {
// shift has started, so just use the time until the end
$seconds += $shift['end'] - $currentTime;
$diff = $shift['end'] - $currentTime;
}

$seconds += $diff > 0 ? $diff*$shift['countAngels'] : 0;
}

return round($seconds/60/60, 0);
Expand Down
12 changes: 3 additions & 9 deletions public/css/theme0.css
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ th {
}
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../assets/bootstrap/fonts/glyphicons-halflings-regular.eot');
src: url('../assets/bootstrap/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.woff') format('woff'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
.glyphicon {
position: relative;
Expand Down Expand Up @@ -6889,8 +6889,7 @@ a#shifts td.collides:focus {
.forecast {
margin-bottom: 30px;
}
.blocks,
.google {
.blocks {
margin-bottom: 30px;
}
.job-list,
Expand Down Expand Up @@ -7014,15 +7013,10 @@ a#shifts td.collides:focus {
font-size: 70px;
text-align: center;
}

.news-list,
.job-list li {
margin-bottom: 10px;
}
.google-container {
width: 100%;
height: 300px;
}
/* makes table elements in User-Edit-Form behave like bootstrap elements
(quick-fix! html should get refactored) */
form.admin-user-form td {
Expand Down
13 changes: 3 additions & 10 deletions public/css/theme1.css
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ th {
}
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../assets/bootstrap/fonts/glyphicons-halflings-regular.eot');
src: url('../assets/bootstrap/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.woff') format('woff'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
.glyphicon {
position: relative;
Expand Down Expand Up @@ -6912,8 +6912,7 @@ a#shifts td.collides:focus {
.forecast {
margin-bottom: 30px;
}
.blocks,
.google {
.blocks {
margin-bottom: 30px;
}
.job-list,
Expand Down Expand Up @@ -7037,16 +7036,10 @@ a#shifts td.collides:focus {
font-size: 70px;
text-align: center;
}

.news-list,
.job-list li {
margin-bottom: 10px;
}

.google-container {
width: 100%;
height: 300px;
}
/* makes table elements in User-Edit-Form behave like bootstrap elements
(quick-fix! html should get refactored) */
form.admin-user-form td {
Expand Down
13 changes: 3 additions & 10 deletions public/css/theme2.css
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ th {
}
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../assets/bootstrap/fonts/glyphicons-halflings-regular.eot');
src: url('../assets/bootstrap/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.woff') format('woff'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../assets/bootstrap/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
.glyphicon {
position: relative;
Expand Down Expand Up @@ -6889,8 +6889,7 @@ a#shifts td.collides:focus {
.forecast {
margin-bottom: 30px;
}
.blocks,
.google {
.blocks {
margin-bottom: 30px;
}
.job-list,
Expand Down Expand Up @@ -7014,16 +7013,10 @@ a#shifts td.collides:focus {
font-size: 70px;
text-align: center;
}

.news-list,
.job-list li {
margin-bottom: 10px;
}

.google-container {
width: 100%;
height: 300px;
}
/* makes table elements in User-Edit-Form behave like bootstrap elements
(quick-fix! html should get refactored) */
form.admin-user-form td {
Expand Down
Loading