Skip to content

Commit

Permalink
Merge pull request #236 from Capping-CPCA/235-edit-attendance
Browse files Browse the repository at this point in the history
235 edit attendance
  • Loading branch information
michellecrawley committed Apr 5, 2018
2 parents b6c2a99 + db94840 commit 62ed7c6
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 129 deletions.
1 change: 0 additions & 1 deletion public/js/livesearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function setMethod(method){
if(methods != null){
return this;
}
console.log("The method was not set correctly");
return false;
}

Expand Down
1 change: 0 additions & 1 deletion public/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

$( ".dynamic-search" ).keypress(function() {
userSearch=$(".dynamic-search").val();
console.log(userSearch);
$(".list-group-item:not(:contains("+userSearch+"))").hide();
$(".list-group-item:contains("+userSearch+")").show();
});
Expand Down
7 changes: 3 additions & 4 deletions views/attendance/attendance_edit_class_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

//previous inputs
$attendanceInfo = $_SESSION['attendance-info'];

$_SESSION['old-info'] = $attendanceInfo;
$selected_class = $attendanceInfo['classes'];
$selected_curr = $attendanceInfo['curr'];
$selected_date = $attendanceInfo['date-input'];
Expand All @@ -41,7 +41,7 @@
$selected_facilitator = $attendanceInfo['facilitator'];
$selected_topic_id = $attendanceInfo['topic-id'];
$selected_curr_id = $attendanceInfo['curr-id'];

unset($_SESSION['attendance-info']);
//only update class info if coming from attendance sheet (if duplicate classOffering can come from confirmed page)
if($_SERVER['REQUEST_METHOD'] == 'POST'){
updateSessionClassInformation();
Expand Down Expand Up @@ -141,9 +141,8 @@ classesElement.appendChild(classNode);
*/
function createTime(hour, minute, amORpm){
var option = document.createElement('OPTION');

//set current set time as the time selected
if((hour + ":" + minute + " " + amORpm) === "<?php echo $selected_time; ?>" ){
if((hour + ":" + minute + " " + amORpm) === "<?=$selected_time?>" ){
option.setAttribute('selected','selected');
}
option.innerHTML = (hour + ":" + minute + " " + amORpm).toString();
Expand Down
58 changes: 37 additions & 21 deletions views/attendance/attendance_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@

/* Begin set class details */
// Attendance has already started being recorded and we are not coming from edit class information page
if (isset($_SESSION['attendance-info']) && !isset($_POST['fromEditClassInfo'])) {
if (isset($_SESSION['attendance-info'])) {
$attendanceInfo = $_SESSION['attendance-info'];

$selected_class = $attendanceInfo['classes'];
$selected_curr = $attendanceInfo['curr'];
$selected_date = $attendanceInfo['date-input'];
Expand Down Expand Up @@ -242,21 +241,38 @@
//no session information set, populate class attendance recommendations
//else grab information from the db and format it into the associative array format
else {
//how many weeks ago do we want in our participant recommendations
$threeWeeksAgo = date_subtraction('22 days');

//participant recommendations for attendance form
$fullQuery = "SELECT * FROM classattendancedetails " .
"WHERE curriculumid = $1 " .
"AND sitename = $2 " .
"AND facilitatorid = $3 " .
"AND date >= $4 " .
"ORDER BY date DESC;";

//query the view
$get_participants = $db->query($fullQuery,
[$selected_curr_id, $selected_site, $selected_facilitator, $threeWeeksAgo]);

if (isset($_SESSION['old-info'])) {
$oldInfo = $_SESSION['old-info'];

// Make timestamp into correct format
$timestamp = makeTimestamp($oldInfo['date-input'], $oldInfo['time-input']);
$classDate = new DateTime($timestamp);
$dateTime = $classDate->format('Y-m-d H:i:s');

$fullQuery = "SELECT * FROM classattendancedetails " .
"WHERE curriculumid = $1 " .
"AND sitename = $2 " .
"AND date = $3";

//query the view
$get_participants = $db->query($fullQuery,
[$oldInfo['curr-id'], $oldInfo['site'], $dateTime]);
} else {
//how many weeks ago do we want in our participant recommendations
$threeWeeksAgo = date_subtraction('22 days');

//participant recommendations for attendance form
$fullQuery = "SELECT * FROM classattendancedetails " .
"WHERE curriculumid = $1 " .
"AND sitename = $2 " .
"AND facilitatorid = $3 " .
"AND date >= $4 " .
"ORDER BY date DESC;";

//query the view
$get_participants = $db->query($fullQuery,
[$selected_curr_id, $selected_site, $selected_facilitator, $threeWeeksAgo]);
}
$addedPIDs = array();

//look through the records to see if this person was added before
Expand All @@ -282,9 +298,9 @@
"zip" => $row['zipcode'],
"numChildren" => $row['numchildren'],
"race" => null,
"comments" => null,
"comments" => isset($row['comments']) ? $row['comments'] : null,
"present" => false,
"isNew" => false, //isNew field from DB
"isNew" => isset($row['isnew']) ? $row['isnew'] : false, //isNew field from DB
//people who haven't completed the intake forms and just filled out info in the "no intake form" section
"firstClass" => false,
"sex" => $row['sex']
Expand Down Expand Up @@ -321,7 +337,7 @@
<h6 class="text-center text-secondary" style="font-weight: 200;"><?= "Class Time: $display_time - $display_date" ?></h6>
<div class="flex-row">
<div class="d-flex justify-content-center">
<button type="button" class="btn btn-link" style="text-align: center;" onclick="editClassDetails()">Edit Class Details</button>
<button type="button" class="btn btn-link" style="text-align: center;" onclick="oldInfoDetails()">Edit Class Details</button>
</div>
</div>
<br />
Expand Down Expand Up @@ -622,7 +638,7 @@ function editPerson(buttonNumber){
/**
* set the form action to direct to edit class info
*/
function editClassDetails(){
function oldInfoDetails(){
setFormAction('edit-class-info');
document.getElementById(pageFormName).submit();
}
Expand Down

0 comments on commit 62ed7c6

Please sign in to comment.