<?php

$response = array();

// include db connect class
require_once __DIR__ . '/db_config.php';

    
// check for required fields
if (isset($_POST['assign_id']) && isset($_POST['datetime']) && isset($_POST['latitude']) && isset($_POST['longtitude']))  {
     
$assign_id= $_POST['assign_id'];
$datetime= $_POST['datetime'];
$latitude= $_POST['latitude'];
$longitude= $_POST['longtitude'];
  
 $con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());
  
  $query="UPDATE task_assign SET a_status='accepted',a_accepted_reject_datetime='$datetime',ar_latitude='$latitude',ar_longitude='$longitude' WHERE assign_id='$assign_id'";
  

    if (mysqli_query($con,$query)) {
        $response["s"] = 1;
        $response["m"] = "Task successfully accepted.";
    } else {
        $response["s"] = 0;
        $response["m"] = "Oops! An error occurred.";
    }
    mysqli_close($con);
} 
    echo json_encode($response);

?>