You are not logged in!!!"; } else { //********** BEGIN CONTENT **********// $userid = $_SESSION['user_id']; $timenow = date('Y-m-d H:i'); // This is to get the current user status - in or out - and the notes and times associated for use in the form $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(); // Let's build the page - this is the header with current status echo "
You do not appear to have any punches on record.
"; $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 "You have been Punched $status since " . date('g:i a \o\n M jS, Y', strtotime($statustime)) . ".
"; } 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 "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 'Time In | '; echo 'Time Out | '; echo 'Hours | '; echo 'Flag | '; echo 'Notes | '; echo '
---|---|---|---|---|
$intime | "; echo "$outtime | "; echo "" . number_format((float)(($seconds/60)/60), 2, '.', '') . " | "; echo "$flg | "; echo "$notes | "; echo "