<?php

require 'db.php';

$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
if(isset($postdata) && !empty($postdata))
{
$orderid = mysqli_real_escape_string($con, trim($request->value));
date_default_timezone_set('Asia/Kolkata');
$t=time();
$nw_date = date("d-m-Y",$t);
$nw_time = date('h:i:s',$t);

$sql = "Update orders set status = 'completed',rid = '0',r_status='delivered',d_date='$nw_date',d_time = '$nw_time' where id = '$orderid'";
$result = mysqli_query($con,$sql);
if($result)
{
    $rows = array('status'=>true,'message' => 'Order Completed');
    echo json_encode($rows); 
}
else
{
    $rows = array('status'=>false,'message' => 'Order is Missing');
    echo json_encode($rows); 
}
}
else
{
    $rows = array('status'=>false,'message' => 'Error');
    echo json_encode($rows); 
}

?>