Skip to content

Commit

Permalink
Merge pull request #233 from Capping-CPCA/232-report-card
Browse files Browse the repository at this point in the history
Report Card Functionality
  • Loading branch information
blackjack26 committed Mar 20, 2018
2 parents fdf6418 + ef3fec6 commit 43696a5
Show file tree
Hide file tree
Showing 12 changed files with 655 additions and 8 deletions.
5 changes: 5 additions & 0 deletions page_permissions.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
/participant-search/* = ALLOW User
/ps-view-participant/* = ALLOW User
/ps-edit-participant/* = ALLOW Administrator
/report-card/* = ALLOW User
/report-card/edit/* = ALLOW User
/report-card/delete/* = ALLOW Administrator
/report-card-new-entry/* = ALLOW User

; classes
/classes = ALLOW User
Expand Down Expand Up @@ -76,6 +80,7 @@
; attendance
/attendance = ALLOW User
/new-class = ALLOW User
/new-class/* = ALLOW User
/attendance-form = ALLOW User
/attendance-form-confirmation = ALLOW User
/attendance-history = ALLOW User
Expand Down
72 changes: 72 additions & 0 deletions public/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ span.language-span {

/* End Nav Bar */

/* Badge */

.badge-cpca {
background-color: #5C629C;
color: rgba(255,255,255,0.8);
transition: all 0.2s;
cursor: default;
}

/* Button */

.outline-cpca {
Expand Down Expand Up @@ -181,6 +190,32 @@ span.language-span {
box-shadow: none!important;
}

/* Is New toggle */
#is-new.active, #is-not-new.active {
outline: none!important;
background-color: #5C629C!important;
color: rgba(255,255,255,0.8)!important;
transition: all 0.2s!important;
}

#is-new.active:not(:disabled):hover, #is-not-new.active:not(:disabled):hover {
cursor: pointer!important;
background-color: #898EBB!important;
}
#is-new.active:active, .cpca:focus, #is-not-new.active:active {
outline: none!important;
box-shadow: none!important;
}

#is-new.focus, #is-not-new.active:active {
background-color: #5C629C;
color: rgba(255,255,255,0.8);
transition: all 0.2s;
outline: none!important;
box-shadow: none!important;
}


/* End Button
/* Footer */
Expand Down Expand Up @@ -381,6 +416,7 @@ select.form-control {
flex: 1;
min-width: 280px;
padding: 10px;
padding: 10px;
transition: background-color 0.2s;
text-decoration: none;
}
Expand Down Expand Up @@ -645,6 +681,42 @@ label[for=password] {
}
}

div.flex-column.no-report-card {
margin: 15px!important;
}

#report-card-heading > #add-report-card-entry {
margin-top: 1px;
float: right;
}

#report-card-heading > #add-report-card-entry:hover,.delete-entry:hover, .edit-entry:hover {
cursor: pointer;
color: rgba(0,0,0,0.65);
}

#report-card-heading {
margin-top: 6px;
}

.list-group-item.report-card-item {
border-left: 1px solid rgba(0, 0, 0, 0.125)!important;
}

.list-group-item.report-card-item:hover {
background-color: #dfdfdf;
cursor: pointer;
}

.list-group-item.more-details {
border: none!important;
padding: 0 1em 0.5em!important;
}

.delete-entry, .edit-entry {
float: right;
}

/* Help */
#help-section {
overflow-y: auto;
Expand Down
2 changes: 2 additions & 0 deletions routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
$router->add('/participant-search', 'agency-requests/agency_requests_results.php', 'Search Results');
$router->add('/ps-view-participant', 'agency-requests/view_participant.php', 'View Participant');
$router->add('/ps-edit-participant', 'agency-requests/edit_participant.php', 'Edit Participant');
$router->add('/report-card', 'agency-requests/report_card.php', 'Participant Attendance');
$router->add('/report-card-new-entry', 'agency-requests/report_card_new_entry.php', 'Participant Details');

# Manage Curricula & Classes
$router->add('/curricula', 'curricula/curricula.php', 'Curricula');
Expand Down
4 changes: 2 additions & 2 deletions views/account/account_archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
<div class="page-wrapper">
<form class="card warning-card" method="post" action="<?= $_SERVER['REQUEST_URI'] ?>">
<h4 class="card-header card-title">
<?= ucwords($firstname . ' ' . $middleinit . ' ' . $lastname); ?>
<?= ucwords($firstname . " " . ($middleinit ?: "") . " " . $lastname); ?>
</h4>
<div class="card-body">
You are about to delete user "<?= ucwords($firstname . ' ' . $middleinit . ' ' . $lastname); ?>". Are you sure
You are about to delete user "<?= ucwords($firstname . " " . ($middleinit ?: "") . " " . $lastname); ?>". Are you sure
you want to delete this user?
</div>
<div class="card-footer text-right">
Expand Down
145 changes: 145 additions & 0 deletions views/agency-requests/report_card.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?php
/**
* PEP Capping 2017 Algozzine's Class
*
* Displays a participant's attendance record.
*
* This page displays details about the classes a
* participant has taken and allows the user add a new
* record or edit and delete an existing one.
*
* @author Michelle Crawley
* @copyright 2017 Marist College
* @version 0.7.1
* @since 0.1
*/
include ('../models/Notification.php');
include($_SERVER['DOCUMENT_ROOT'].'/../views/attendance/attendance_utilities.php');
global $db, $view, $route, $params;

// Select page to display
if (!empty($params) && $params[0] == 'edit') {
$view->display('agency-requests/report_card_edit_entry.php');
} else if (!empty($params) && $params[0] == 'delete') {
$view->display('agency-requests/report_card_delete_entry.php');
} else {
include('header.php');

// Get people id from params
$peopleid = rawurldecode(implode('/', $params));
$result = $db->query("SELECT * FROM people WHERE peopleid = $1", [$peopleid]);
$person = pg_fetch_assoc($result);
extract($person);

// Get participant's attendance record
$result = $db->query("SELECT * FROM participantclassattendance, participants WHERE participants.participantid = $1 AND participants.participantid = participantclassattendance.participantid ORDER BY date ASC;", [$peopleid]);
?>
<div class="w-100" style="height: fit-content;">
<?php
// Displays a notification if modification was successful
if (isset($_SESSION['notification'])) {
$note = $_SESSION['notification'];
$notification = new Notification($note['title'], $note['msg'], $note['type']);
$notification->display();
unset($_SESSION['notification']);
}
?>
<button class="cpca btn" onclick="window.location.href='/ps-view-participant/<?=$peopleid?>'"><i class="fa fa-arrow-left"></i> Back</button>
<div class="card" style="max-width: 700px; width: 100%; margin: 0 auto;">
<div class="card-header">
<h4 id="report-card-heading"><?= ucwords($firstname . " " . ($middleinit ?: "") . " " . $lastname) . "'s Report Card" ?>
<div id="add-report-card-entry" onclick="document.location.href='/new-class/<?= $peopleid ?>'">
<i class="fa fa-plus"></i>
</div>
</h4>
</div>
<?php if (pg_num_rows($result) > 0) {
// Keep track if number of attendance entries
$recordNumber = 1;
while ($attendance = pg_fetch_assoc($result)) {
extract($attendance);

// Get class offering details
$res = $db->query("SELECT * FROM classoffering WHERE date = $1 AND siteName = $2 ", [$date, $sitename]);
extract(pg_fetch_assoc($res));

// Get class name
$res = $db->query("SELECT topicname FROM classes WHERE classid = $1", [$classid]);
$className = pg_fetch_assoc($res);

// Get curriculum name
$res = $db->query("SELECT curriculumname FROM curricula WHERE curriculumid = $1", [$curriculumid]);
$curriculumName = pg_fetch_assoc($res);

// Store important details in a json array to be passed to the edit/delete pages
$entryInfo = array($attendance, $className['topicname'], $curriculumName['curriculumname']);
$entryInfo = json_encode($entryInfo);
?>
<ul class="list-group list-group-flush">
<li class="list-group-item report-card-item" data-toggle="modal"
data-target="#modal-<?= $recordNumber ?>">
<span style="float: left; margin: 15px 15px 5px 0px;"
class="badge badge-cpca"><?= $recordNumber ?></span>
<b class="class-details"><?= $curriculumName['curriculumname'] . ": " . $className['topicname'] ?></b>
<br>
<?= preg_replace('/(?<!\ )[A-Z]/', ' $0', $sitename) ?><span
style="float: right;"><i><?= formatSQLDateShort($date) ?></i></span>
</li>
</ul>
<div class="modal fade" id="modal-<?= $recordNumber ?>">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header" style="padding: 10px 25px 5px 25px;">
<h5 class="modal-title">More Details</h5>
<div class="float-right" style="padding-top: 15px; display: inline-flex;">
<form method="post" action="/report-card/edit/<?=$peopleid?>">
<button type="submit" class="btn btn-outline-secondary btn-sm edit" style="margin: 0 5px 0 0;">Edit</button>
<input type="hidden" name="entry-info" value='<?=$entryInfo?>'/>
</form>
<form method="post" action="/report-card/delete/<?=$peopleid?>">
<button type="submit" class="btn btn-outline-danger btn-sm" >Delete</button>
<input type="hidden" name="entry-info" value='<?=$entryInfo?>'/>
</form>
</div>
</div>
<div class="modal-body">
<ul class="list-group list-group-flush more-details-list">
<li class="list-group-item more-details"><b>Site
Name: </b><?= preg_replace('/(?<!\ )[A-Z]/', ' $0', $sitename); ?></li>
<li class="list-group-item more-details">
<b>Curriculum: </b><?= preg_replace('/(?<!\ )[A-Z]/', ' $0', $curriculumName['curriculumname']); ?>
</li>
<li class="list-group-item more-details">
<b>Class: </b><?= preg_replace('/(?<!\ )[A-Z]/', ' $0', $className['topicname']); ?>
</li>
<li class="list-group-item more-details">
<b>Date: </b><?= formatSQLDate($date) ?></li>
<li class="list-group-item more-details"><b>Number of
Children: </b><?= $numchildren ?></li>
<li class="list-group-item more-details"><b>New
Participant: </b><?= $isnew == "f" ? "No" : "Yes" ?></li>
<li class="list-group-item more-details"><b>Zip Code: </b><?= $zipcode ?></li>
<li class="list-group-item more-details"><b>Comments: </b><?= $comments ?></li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php $recordNumber++;
}
} else { ?>
<div class="w-100 d-flex flex-column justify-content-center text-center no-report-card">
<h3 class="display-3 text-secondary" style="font-size: 20px;"><i
class="fa fa-exclamation-circle"></i></h3>
<h3 class="display-3 text-secondary" style="font-size: 20px;">User has not attended any
classes.</h3>
</div>
<?php } ?>
</div>
</div>
<?php
include('footer.php');
} ?>
77 changes: 77 additions & 0 deletions views/agency-requests/report_card_delete_entry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* PEP Capping 2017 Algozzine's Class
*
* Prompts the user to delete an existing
* attendance entry.
*
* This page displays a prompt to either remove the selected
* attendance record or to cancel and go back. If the user removes the
* record then it is removed from the database. This function is for
* admins only.
*
* @author Michelle Crawley
* @copyright 2017 Marist College
* @version 0.3.3
* @since 0.1
*/
global $db, $params;

// Get entry information from previous page
if (array_key_exists('entry-info', $_POST)) {
$entryInfo = json_decode($_POST['entry-info'], true);
$_SESSION['entry-info'] = $entryInfo;
// Otherwise get entry information from session variable
} else {
$entryInfo = $_SESSION['entry-info'];
unset($_SESSION['entry-info']);
}
$topicName = $entryInfo[1];
$curriculumName = $entryInfo[2];
extract($entryInfo[0]);

// Get people id from params
$peopleid = $params[1];
$result = $db->query("SELECT * FROM people WHERE peopleid = $1", [$peopleid]);
$person = pg_fetch_assoc($result);
extract($person);

// Archive data
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['delete'])) {
$deleteRes = $db->query("DELETE FROM participantclassattendance " .
"WHERE participantid = $1 AND sitename = $2 AND date = $3", [$peopleid, $sitename, $date]);

// If the delete is successful display a notification on the report-card page
$note['title'] = ($deleteRes ? 'Success!' : 'Error!');
$note['msg'] = ($deleteRes ? 'The entry has been deleted.' : 'The entry wasn\'t deleted.');
$note['type'] = ($deleteRes ? 'success' : 'danger');
$_SESSION['notification'] = $note;
header('Location: /report-card/' . $peopleid);
die();
}
include('header.php');
?>

<div class="page-wrapper">
<form class="card warning-card" method="post" action="<?= $_SERVER['REQUEST_URI'] ?>">
<h4 class="card-header card-title">
Attendance Entry for <?= ucwords($firstname . " " . ($middleinit ?: "") . " " . $lastname); ?>
</h4>
<div class="card-body">
You are about to delete an attendance entry for "<?= ucwords($firstname . " " . ($middleinit ?: "") . " " . $lastname); ?>" with the following details: <br>
<div class="text-center" style="padding:10px;"><b>Class:</b> <?=$topicName?> <br>
<b>Curriculum:</b> <?=$curriculumName?> <br>
<b>Site:</b> <?=$sitename?> <br>
<b>Date:</b> <?=formatSQLDate($date)?> <br>
</div>
Are you sure you want to delete this entry?
</div>
<div class="card-footer text-right">
<button type="button" class="btn btn-light" onclick="goBack()">Cancel</button>
<button type="submit" name="delete" class="btn btn-danger">Delete</button>
</div>
</form>
</div>

<?php
include ('footer.php'); ?>

0 comments on commit 43696a5

Please sign in to comment.