I have one more piece I need to add to my code for the next version to be ready.
At the moment, you can mark attendance and absence records using this code:
Attendance:
<?php
include('nav/head.php');
$msg = "";
// Prepare SQL Statement
$stmt = $pdo->prepare("INSERT INTO attendance (member_id, member_email,
member_phone, present, attend_state) VALUES (:member_id, :member_email,
:member_phone, :present, :attend_state)");
$stmt->bindParam(':member_id', $member_id);
$stmt->bindParam(':member_email', $member_email);
$stmt->bindParam(':member_phone', $member_phone);
$stmt->bindParam(':present', $present);
$stmt->bindParam(':attend_state', $attend_state);
// insert a row and add new record
if(isset($_POST['btn_save'])) {
try {
$id = $_POST["member_id"];
$ary = explode("-", $id);
$member_id = $ary[0];
$member_email = $_POST["member_email"];
$member_phone = $_POST["member_phone"];
$present = $_POST["present"];
$attend_state = $_POST["attend_state"];
$stmt->execute();
header('Location: record_attn.php');
exit();
} catch(PDOException $e) {
$msg = "This delegate has already been marked present";
}
}
// insert a row and exit attendance screen
if(isset($_POST['btn_close'])) {
try {
$id = $_POST["member_id"];
$ary = explode("-", $id);
$member_id = $ary[0];
$member_email = $_POST["member_email"];
$member_phone = $_POST["member_phone"];
$present = $_POST["present"];
$attend_state = $_POST['attend_state'];
$stmt->execute();
header('Location: index.php');
exit();
} catch (PDOException $e) {
$msg = "This delegate has already been marked present";
}
}
// return to home screen
if(isset($_POST['btn_cancel'])) {
header('Location: index.php');
}
// Populate Address Field
?>
Absence:
<?php
include('nav/head.php');
if($role_id != '1') {
header('Location: error.php');
exit();
}
$msg = "";
// Prepare SQL Statement
$stmt = $pdo->prepare("INSERT INTO absence (member_id, member_email,
member_phone, absence_desc) VALUES (:member_id, :member_email,
:member_phone, :absence_desc)");
$stmt->bindParam(':member_id', $member_id);
$stmt->bindParam(':member_email', $member_email);
$stmt->bindParam(':member_phone', $member_phone);
$stmt->bindParam(':absence_desc', $absence_desc);
// insert a row and add new record
if(isset($_POST['btn_save'])) {
try {
$id = $_POST["member_id"];
$ary = explode("-", $id);
$member_id = $ary[0];
$member_email = $_POST['member_email'];
$member_phone = $_POST['member_phone'];
$absence_desc = $_POST["absence_desc"];
$stmt->execute();
header('Location: record_abs.php');
exit();
} catch (PDOException $e) {
$msg = "This delegate has already filed an excused absence";
}
}
// insert a row and exit attendance screen
if(isset($_POST['btn_close'])) {
try {
$id = $_POST["member_id"];
$ary = explode("-", $id);
$member_id = $ary[0];
$member_email = $_POST['member_email'];
$member_phone = $_POST['member_phone'];
$absence_desc = $_POST["absence_desc"];
$stmt->execute();
header('Location: index.php');
exit();
} catch (PDOException $e) {
$msg = "This delegate has already filed an excused absence";
}
}
?>
I need to create a feature in this code where if I put someone in as absent and then they show up, that person should be converted to the attendance list. The absent record should be deleted and a new attendance record should be made.
If the person is marked present and then I try to enter an absent record for them, a warning should appear indicating the person is already in the attendance list.
The in-person takes precedence over the absentee request. Whatās the best way to do it?