<?php
require_once 'classes/ConDB.php';

require_once 'classes/getErrorMsg.php';

header('Content-type: application/json');
if (isset($_REQUEST['time_log_submit'])) {
    $db = new ConDB();
    
    $request = $db-> _cleanInputs($_REQUEST);
    // $request = $_REQUEST;
    
    
    extract($request);
   
    if ($device_id == '' || $emp_no == '' || $lock_cor == '' || $lock_type == '' || $cur_date == '' || $file_name == '') {
        $msg = new getErrorMsg('7');
        $json = array('statusMessage' => $msg->errMsg, 'statusNumber' => $msg->errNo);
        echo json_encode($json);
        return false;
    }

	 $reg_time_qry = "insert into time_log_table(device_id,emp_no,log_type,coordinates,log_date_time, filename) values('".$device_id."','".$emp_no."','".$lock_type."','" . $lock_cor."','".$cur_date."','".$file_name."')";

	$resutl= mysql_query($reg_time_qry, $db->conn);
	$inserted_id = mysql_insert_id();
	if (mysql_affected_rows() > 0) {

		$msg = new getErrorMsg('0');
		$json = array('DeviceId' => $inserted_id, 'statusMessage' => $msg->errMsg, 'statusNumber' => $msg->errNo);
		echo json_encode($json);

		return false;
	} else {
//            echo $reg_user_qry;
		$msg = new getErrorMsg('9');
		$json = array('statusMessage' => $msg->errMsg, 'statusNumber' => $msg->errNo);
		echo json_encode($json);
//                echo $reg_user_qry;
		return false;
	}

}
?>