You are not logged in!!!"; } else { //********** BEGIN CONTENT **********// $userid = $_SESSION['user_id']; $nowarray = explode("-", date("Y-m-d-H-i")); $result = $sql->prepare("SELECT punches.id as punchid, users.id as user, punches.intime as intime, punches.outtime as outtime, punches.notes as notes FROM punches INNER JOIN users ON punches.userid = users.id WHERE users.id = $userid ORDER BY punches.id DESC LIMIT 1"); $result->execute(); $last = $result->fetchObject(); echo "

Advanced Punch

"; if(!isset($last->user)) { $status = "Out"; } else { if (!empty($last->outtime)) { $status = "Out"; $statustime = $last->outtime; } else { $status = "In"; $statustime = $last->intime; $punchid = $last->punchid; $notes = $last->notes; } } echo "

Use this form to enter a specific time on your punch. NOTE: changing the time from the current time will cause a flag on your log for the administrator to review, so we suggest you enter a reason why in the notes field (i.e. forgot punch, working from home, system down, etc).

"; echo "
"; echo "
"; echo "
"; echo "
"; echo ""; echo ""; echo "
"; echo "
"; echo ""; echo ""; echo "
"; echo "
"; echo ""; echo ""; echo "
"; echo "
"; echo ""; echo ""; echo "
"; echo "
"; echo ""; echo ""; echo "
"; echo "
"; echo ""; echo ""; echo "
"; echo "
"; echo "
"; if ($status=="In") { echo ""; echo ""; } else { echo ""; echo ""; } echo "
"; if (!empty($_POST)) { if (!empty($_POST['notes'])) { $p_notes = $_POST['notes']; } else { $p_notes = ""; } $p_punchtime = $_POST['year'] . "-" . $_POST['month'] . "-" . $_POST['day'] . " " . $_POST['hour'] . ":" . $_POST['minute'] . ":00"; if ($status=="In") { $query = "UPDATE punches SET outtime = :p_punchtime, notes = :p_notes WHERE id = :p_punchid"; $stmt = $sql->prepare($query); $stmt->execute(array( ':p_punchid' => $punchid, ':p_notes' => $p_notes, ':p_punchtime' => $p_punchtime )); } else { $query = "INSERT INTO punches (userid, notes, intime) VALUES (:p_userid, :p_notes, :p_punchtime)"; $stmt = $sql->prepare($query); $stmt->execute(array( ':p_userid' => $_SESSION['user_id'], ':p_notes' => $p_notes, ':p_punchtime' => $p_punchtime )); } header('Location: '.$_SERVER['PHP_SELF']); exit; } echo "
"; echo "
"; echo "

Punch History

"; echo "

Below is your full punch history, sorted newest to oldest.

"; $result = $sql->prepare("SELECT punches.id as punchid, users.id as user, punches.intime as intime, punches.outtime as outtime, punches.notes as notes, punches.modified as modified FROM punches INNER JOIN users ON punches.userid = users.id WHERE users.id = $userid ORDER BY punches.id DESC"); $result->execute(); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $intime = $row['intime']; $outtime = $row['outtime']; $date1 = new DateTime($intime); $date2 = new DateTime($outtime); $seconds = abs($date1->getTimestamp()-$date2->getTimestamp()); $flag = $row['modified']; if ($flag == "1") {$flg="YES";} else {$flg="";} $notes = $row['notes']; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo ''; echo '
Time InTime OutHoursFlagNotes
$intime$outtime" . number_format((float)(($seconds/60)/60), 2, '.', '') . "$flg$notes
'; //********** END CONTENT **********// } require_once($yaptc_inc . "footer.inc.php"); ?>