<?php 
require 'db.php';
$data = json_decode(file_get_contents('php://input'), true);
if($data['uid'] == ''  or $data['d_rate'] == '' or  $data['p_rate'] == '' or $data['oid'] == '')
{
    $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Something Went Wrong!");
}
else
{
    $uid = strip_tags(mysqli_real_escape_string($con,$data['uid']));
    $d_msg = strip_tags(mysqli_real_escape_string($con,$data['d_msg']));
    $d_rate = strip_tags(mysqli_real_escape_string($con,$data['d_rate']));
    $p_msg = strip_tags(mysqli_real_escape_string($con,$data['p_msg']));
    $p_rate = strip_tags(mysqli_real_escape_string($con,$data['p_rate']));
    $oid = strip_tags(mysqli_real_escape_string($con,$data['oid']));
    $shop_id = strip_tags(mysqli_real_escape_string($con,$data['shop_id']));
    $shop_code = strip_tags(mysqli_real_escape_string($con,$data['shop_code']));

$sql = $con->query("insert into rate_order(`shop_id`,`shop_code`,`uid`,`msg`,`rate`,`oid`)values('$shop_id','$shop_code','$uid','$p_msg','$p_rate','$oid')");
$sql1 = $con->query("update orders set rate=1 where order_id='$oid' and uid='$uid'");

$query = $con->query("select * from orders where order_id='$oid'");
    if($row = $query->fetch_assoc())
    {
      $r_id = $row['rid'];
    }
    
$query1 = $con->query("select * from assist_settings where deli_code='$r_id'");
if($row1 = $query1->fetch_assoc())
{
    $rate = $row1['deli_reviews'];
    $rate1 = $rate + 1;
}

$ft = "insert into rate_rider(`uid`,`msg`,`rate`,`oid`)values('$uid','$d_msg','$d_rate','$oid')";
$sql2 = $con->query($ft);
$sql3 = $con->query("update assist_settings set deli_reviews='$rate1' where deli_code='$r_id'");

    $returnArr = array("ResponseCode"=>"200","Result"=>"true","ResponseMsg"=>"Thanks for Rating!");
}

echo json_encode($returnArr);
