Skip to content
This repository has been archived by the owner on Oct 16, 2018. It is now read-only.

Commit

Permalink
add a report list for equipment group display which shows reservation…
Browse files Browse the repository at this point in the history
…s broken down by eq item; manager reservation legen item is an active control that toggles visibility of management reservations in list view
  • Loading branch information
cwarren committed Nov 30, 2015
1 parent 2b6e42a commit c9c1581
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 41 deletions.
9 changes: 7 additions & 2 deletions css/WMS_bootstrap_PATCH.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ Purpose: CSS that's not an extension / modification of the bootstrap framework
}

.rendered-object > .render-hover-info {
position: fixed;
position: relative;
border: 1px solid #000000;
background-color: #ddd;
max-width: 300px;
margin: 0;
padding: 8px;
visibility: hidden;
float: right;
}

.rendered-object:hover > .render-hover-info {
Expand All @@ -108,7 +109,7 @@ input[type="checkbox"].comm_pref-checkbox {
padding-bottom: 5px;
}

#reservationSchedules > li {
#reservationSchedules > li .item-listing ul {
padding-bottom: 7px;
}

Expand Down Expand Up @@ -157,6 +158,10 @@ ul.subgroup-ul {
line-height: 36px;
}

.mgt-reservation-legend-item-strikethrough {
text-decoration: line-through;
}

/*-------------------------
transient alert*/
.transient_alert
Expand Down
138 changes: 99 additions & 39 deletions equipment_group_schedules_of_reservations.frag.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,34 @@
<span id = "reservations_view">
<a href="#" class="show_reservation_list btn btn-medium btn-primary">List View</a>
<a href="#" class="show_reservation_calendar btn btn-medium btn-primary">Monthly Calendar View</a>
<a href="#" class="show_reservation_report btn btn-medium btn-primary">Report</a>
</span>

<div id="calendar-legend">
<b>legend:</b> <span class="legend-box time-slot-in-use-mgt">manager reservation</span> <span class="legend-box time-slot-in-use">user reservation</span>
<b>legend:</b> <span id="mgt-reservation-legend-item" class="legend-box time-slot-in-use-mgt">manager reservation</span> <span class="legend-box time-slot-in-use">user reservation</span>
</div>
</legend>

<br clear="all" />
<ul id="reservationSchedules" class="schedule unstyled hide">
<?php
$schedule_transpose = [];

$show_del_control = ($USER->flag_is_system_admin || $is_group_manager);
if (count($Requested_EqGroup->schedules) > 0) {
$allCount = count($Requested_EqGroup->schedules);
$thisMonthCount = 0;
foreach ($Requested_EqGroup->schedules as $sched) {

$li = Db_Linked::listItemTag('list-of-schedule-' . $sched->schedule_id);

// add metadata about schedule type
$li = substr($li,0,-1); // remove trailing '>'
if ($sched->type == 'manager') {
$li .= ' class="list-items-mgr">';
} else {
$li .= ' class="list-items-user">';
}

//If want to show the delete button
if ($show_del_control) {
Expand All @@ -31,9 +42,15 @@
$month = substr($sched->start_on_date, 5, 2);
$thisSched = $sched->schedule_id;

// NOTE: this structure currently has a lot of unnecessary code duplication (or, in some cases, insufficient duplication - the first section has stuff that really should be repeated in the second section). However, time crunch means that's not getting refactored right now.

//Default: only list the reservations in the current year and month
if ($year == util_getCurrentYearNum() && $month == util_getCurrentMonthNum()) {
$li .= "<span id=\"item\" class=\"item-listing\" data-sched=\"$thisSched\" data-year=\"$year\" data-month=\"$month\">";
} else {
$li .= "<span id=\"item\" class=\"item-listing hide\" data-sched=\"$thisSched\" data-year=\"$year\" data-month=\"$month\">";
$thisMonthCount++;
}

if ($sched->type == 'manager') {
$li .= '<strong><span class="text-warning">(MANAGEMENT)</span></strong> ';
Expand All @@ -47,6 +64,7 @@
}

//if this reservation is by the signed in user then schedule is reserved "by you" else show username of the reserver
$user_label = 'you';
if ($sched->user_id == $USER->user_id) {
$li .= '<strong><a href="schedule.php?schedule=' . $sched->schedule_id . '&returnToEqGroup=1"> ' . $output . '</a></strong> by you<br/>';
} else {
Expand All @@ -56,63 +74,85 @@
if (!$sched->user->matchesDb) {
$del_user = User::getOneFromDb(['user_id' => $sched->user_id, 'flag_delete' => true], $DB);
if (!$del_user->matchesDb) {
$li .= '<i>could not determine the user</i> ';
$user_label = '<i>could not determine the user</i> ';
$li .= $user_label;
} else {
$li .= '<i>user removed from system: ' . $del_user->fname . ' ' . $del_user->lname . '</i> ';
$user_label = '<i>user removed from system: ' . $del_user->fname . ' ' . $del_user->lname . '</i> ';
$li .= $user_label;
}
} else {
// $li .= $sched->user->fname . ' ' . $sched->user->lname . '(TODO: add link/hover stuff)<br/>';
//Allows hover
$li .= $sched->user->renderRich();
$user_label = $sched->user->renderRich();
$li .= $user_label;
}
}
$li .= "<ul class=\"unstyled\">\n";

//Print out the corresponding reservations
foreach ($sched->reservations as $r) {
if ($r->eq_item->name) {
$li .= '<li>' . $r->eq_item->eq_subgroup->name . ': ' . $r->eq_item->name . "</li>\n";
$item_label = $r->eq_item->eq_subgroup->name . ': ' . $r->eq_item->name;
$li .= '<li>' . $item_label . "</li>\n";
if (! array_key_exists($item_label,$schedule_transpose)) {
$schedule_transpose[$item_label] = [];
}
array_push($schedule_transpose[$item_label],"$output - $user_label");
}
}
$li .= "</ul></li></span>\n";
echo $li;
}else{
$li .= "<span id=\"item\" class=\"item-listing hide\" data-sched=\"$thisSched\" data-year=\"$year\" data-month=\"$month\">";
if ($sched->type == 'manager') {
$li .= '<strong><span class="text-warning">(MANAGEMENT)</span></strong> ';
}
if ($sched->user_id == $USER->user_id) {
$li .= '<strong><a href="schedule.php?schedule=' . $sched->schedule_id . '&returnToEqGroup=1"> ' . $sched->toString() . '</a></strong> by you<br/>';
} else {
$sched->loadUser();
$li .= '<strong>' . $sched->toString() . '</strong> by ';

if (!$sched->user->matchesDb) {
$del_user = User::getOneFromDb(['user_id' => $sched->user_id, 'flag_delete' => true], $DB);
if (!$del_user->matchesDb) {
$li .= '<i>could not determine the user</i> ';
} else {
$li .= '<i>user removed from system: ' . $del_user->fname . ' ' . $del_user->lname . '</i> ';
}
} else {
// $li .= $sched->user->fname . ' ' . $sched->user->lname . '(TODO: add link/hover stuff)<br/>';
$li .= $sched->user->renderRich();
}
}
$li .= "<ul class=\"unstyled\">\n";
foreach ($sched->reservations as $r) {
// util_prePrintR($sched);
if ($r->eq_item->name) {
$li .= '<li>' . $r->eq_item->eq_subgroup->name . ': ' . $r->eq_item->name . "</li>\n";
}
}
$li .= "</ul></li></span>\n";
echo $li;

$thisMonthCount++;
}
# }else{
# $li .= "<span id=\"item\" class=\"item-listing hide\" data-sched=\"$thisSched\" data-year=\"$year\" data-month=\"$month\">";
# if ($sched->type == 'manager') {
# $li .= '<strong><span class="text-warning">(MANAGEMENT)</span></strong> ';
# }

# //shorten the shown reservation if it is a repeated schedule
# if ($sched->frequency_type == 'monthly' || $sched->frequency_type == 'weekly') {
# $output = $sched->summary;
# } else {
# $output = $sched->toString();
# }

# if ($sched->user_id == $USER->user_id) {
# $li .= '<strong><a href="schedule.php?schedule=' . $sched->schedule_id . '&returnToEqGroup=1"> ' . $output . '</a></strong> by you<br/>';
# } else {
# $sched->loadUser();
# $li .= '<strong>' . $output . '</strong> by ';

# if (!$sched->user->matchesDb) {
# $del_user = User::getOneFromDb(['user_id' => $sched->user_id, 'flag_delete' => true], $DB);
# if (!$del_user->matchesDb) {
# $li .= '<i>could not determine the user</i> ';
# } else {
# $li .= '<i>user removed from system: ' . $del_user->fname . ' ' . $del_user->lname . '</i> ';
# }
# } else {
# // $li .= $sched->user->fname . ' ' . $sched->user->lname . '(TODO: add link/hover stuff)<br/>';
# $li .= $sched->user->renderRich();
# }
# }
# $li .= "<ul class=\"unstyled\">\n";
# foreach ($sched->reservations as $r) {
# // util_prePrintR($sched);
# if ($r->eq_item->name) {
# $li .= '<li>' . $r->eq_item->eq_subgroup->name . ': ' . $r->eq_item->name . "</li>\n";
# }
# }
# $li .= "</ul></li></span>\n";
# echo $li;

# $thisMonthCount++;
# }
}

echo "<!--";
util_prePrintR($schedule_transpose);
echo "-->";


if ($thisMonthCount == $allCount) {
echo "<li class=\"no-reserv-month\">Nothing reserved for this month</li><br>";
}
Expand All @@ -139,6 +179,26 @@
?>
</ul>

<ul id="reservations-report" class="report hide">
<?php
if (count($schedule_transpose) < 1) {
echo " <li>No reservations for any equipment in this group</li>\n";
} else {
ksort($schedule_transpose);
foreach ($schedule_transpose as $item_label => $res_ar) {
echo " <li>$item_label";
echo " <ul>\n";
$recent_first_res = array_reverse($res_ar);
foreach ($recent_first_res as $res_elt) {
echo " <li>$res_elt</li>\n";
}
echo " </ul>\n";
echo " </li>\n";
}
}
?>
</ul>

<!--calendar for displaying schedule-->
<div>
<div id="monthly_calendar_view" class="calendar">
Expand Down
36 changes: 36 additions & 0 deletions js/equipment_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ $(document).ready(function () {
}
}

$(document).on("click", "#mgt-reservation-legend-item", function(){
$("#mgt-reservation-legend-item").toggleClass("mgt-reservation-legend-item-strikethrough");
if ($("#mgt-reservation-legend-item").hasClass("mgt-reservation-legend-item-strikethrough")) {
$(".list-items-mgr").addClass("hide");
} else {
$(".list-items-mgr").removeClass("hide");
}
});

//****** related to showing reservations list
$(document).on("click", "#show-reservations-buttons .show-this-month", function(){
var show_which = $('.show-this-month').attr('data-show-month');
Expand Down Expand Up @@ -1365,6 +1374,23 @@ var durationsJSON = '{
//**********************************
// Calendar related

$(document).on("click", "#reservations_view .show_reservation_report", function () {
//Successfully gets the calendar day
if($('.report').hasClass("hide")){
if($('.calendar').hasClass('hide')){
$('.calendar_day').addClass('hide');
}else{
$('.calendar').addClass("hide");
}
if($('.schedule').hasClass('hide')){
$('.calendar_day').addClass('hide');
}else{
$('.schedule').addClass("hide");
}
$('.report').removeClass("hide");
}
});

$(document).on("click", "#reservations_view .show_reservation_list", function () {
//Successfully gets the calendar day
if($('.schedule').hasClass("hide")){
Expand All @@ -1373,6 +1399,11 @@ var durationsJSON = '{
}else{
$('.calendar').addClass("hide");
}
if($('.report').hasClass('hide')){
$('.calendar_day').addClass('hide');
}else{
$('.report').addClass("hide");
}
$('.schedule').removeClass("hide");
}
});
Expand All @@ -1384,6 +1415,11 @@ var durationsJSON = '{
}else{
$('.schedule').addClass("hide");
}
if($('.report').hasClass('hide')){
$('.calendar_day').addClass('hide');
}else{
$('.report').addClass("hide");
}
$('.calendar').removeClass("hide");
}
});
Expand Down

0 comments on commit c9c1581

Please sign in to comment.