getConnection(); $emp = new employee($db); // get posted data $data = json_decode(file_get_contents("php://input")); // make sure data is not empty if( //!empty($data->ts_brid) && !empty($data->ts_empid) && !empty($data->ts_scantime) && !empty($data->ts_scanloc) && !empty($data->ts_type) ){ // set product property values //$emp->ts_brid = $data->ts_brid; $emp->ts_empid = $data->ts_empid; $emp->ts_scantime = $data->ts_scantime; $emp->ts_scanloc = $data->ts_scanloc; $emp->ts_type = $data->ts_type; $stmt = $emp->emp_Valid(); $num = $stmt->rowCount(); $stmtoff = $emp->emp_OffCode(); $numoff = $stmtoff->rowCount(); if($numoff<=0){ // set response code - 503 service unavailable http_response_code(503); echo json_encode(array("message" => "Failed Submission - Employee code does not exist.".$num)); exit; }else{ while ($row = $stmtoff->fetch(PDO::FETCH_ASSOC)){ $emp->ts_brid = $row['empbranchcode']; } } if($num<=0){ // set response code - 503 service unavailable http_response_code(503); echo json_encode(array("message" => "Failed Submission - Employee code does not exist.".$num)); exit; } // Update the attendance if($emp->at_update()){ // set response code - 201 updated http_response_code(201); // tell the user echo json_encode(array("message" => "Successfully Submited")); } // if unable to update the attendance, tell the user else{ // set response code - 503 service unavailable http_response_code(503); // tell the user echo json_encode(array("message" => "Failed Submission.")); } } // tell the user data is incomplete else{ // set response code - 400 bad request http_response_code(400); // tell the user echo json_encode(array("message" => "Unable to Submit. Data is incomplete.")); } ?>