<?php

require 'db.php';

$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
if(isset($postdata) && !empty($postdata))
{
    $min_order = mysqli_real_escape_string($con, trim($request->form_value->min_order_value));
    $free_deli = mysqli_real_escape_string($con, trim($request->form_value->free_deli_value));
    $tax = mysqli_real_escape_string($con, trim($request->form_value->tax_value));
    $starttime = mysqli_real_escape_string($con, trim($request->form_value->start_time));
    $endtime = mysqli_real_escape_string($con, trim($request->form_value->end_time));
    $shopmessage = mysqli_real_escape_string($con, trim($request->form_value->shop_message));
    $shop_id = mysqli_real_escape_string($con, trim($request->shop_id));
    $shop_code = mysqli_real_escape_string($con, trim($request->shop_code));
    
    include 'token_check.php';

    if($token_check)
    {
        $sql = "UPDATE shop_settings set min_order_value = '$min_order',free_deli_value = '$free_deli',tax_value = '$tax',shop_message = '$shopmessage',start_time = '$starttime', end_time = '$endtime' 
        where shop_id='$shop_id' and shop_code='$shop_code'";
        $result = mysqli_query($con,$sql);
        if($result)
        {
            $rows = array('status'=>true,'message' => 'Settings Updated');
            echo json_encode($rows);
        }
    }
    else
    {
        $rows = array('status'=>"",'message' => 'Data Error');
        echo json_encode($rows);
    }

}

?>

