/* Check to see if they're already clocked in */ $cquery = "SELECT STATUS FROM `tbl_employee_clock_time` WHERE "; $cquery .= sprintf("ID_EMPLOYEE = %s AND ENTITY_ID = %s ", mysql_real_escape_string($msgid), mysql_real_escape_string($entity)); $cquery .= " AND ID IN (SELECT MAX(ID) FROM `tbl_employee_clock_time` "; $cquery .= sprintf("WHERE ID_EMPLOYEE = %s AND ENTITY_ID = %s )", mysql_real_escape_string($msgid), mysql_real_escape_string($entity)); $cresults = mysql_query($cquery); $crow = mysql_fetch_row($cresults); echo '
'; echo $msgid .'
'; echo $entity .'
'; echo $cquery .'
'; echo substr($crow[0], 0, 2) .'
'; echo strtoupper($type) .'
'; echo '
'; echo '

'; /* Check to see if the last record matches the current on $type */ if (strtoupper($type) === "IN") { if (substr($crow[0], 0, 2) === "IN") { echo 'You are either already clocked in, or you forgot to clock out from the previous day. Please contact a supervisor.'; echo '

Return

'; exit(); } else { echo ''; } } if (strtoupper($type) === "OUT") { if (substr($crow[0], 0, 3) === "OUT") { echo 'You are either already clocked out, or you forgot to clock in today. Please contact a supervisor.'; echo '

Return

'; exit(); } }