<?php

require 'db.php';

$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
if(isset($postdata) && !empty($postdata))
{
    $value = mysqli_real_escape_string($con, trim($request->value));
    if($value == "1")
    {
        $sql = "SELECT * FROM setting";
        $result = mysqli_query($con,$sql);
        if($rows = mysqli_fetch_assoc($result))
        {
        	$privacy_policy = $rows['privacy_policy'];
        	$about_app = $rows['about_us'];
        	$contact_us = $rows['contact_us'];
        	$min_cart_value = $rows['o_min'];
        	$max_dis = $rows['max_km'];
        	$tax = $rows['tax'];
        	$currency = $rows['currency'];
        	$terms = $rows['terms'];
        }
        
        $rows = array('privacy_policy'=>$privacy_policy,'about_app'=>$about_app,'contact_us'=>$contact_us,'terms'=>$terms);
        echo json_encode($rows);
    }
    else if($value == '2')
    {
        $sql = "SELECT * FROM setting";
        $result = mysqli_query($con,$sql);
        if($rows = mysqli_fetch_assoc($result))
        {
        	$app_name = $rows['app_name'];
        	$currency = $rows['currency'];
        	$location = $rows['location'];
        	$min_cart_value = $rows['o_min'];
        	$free_value = $rows['free_deli_value'];
        	$max_dis = $rows['max_km'];
        	$tax = $rows['tax'];
        	$start_time = $rows['start_time'];
        	$end_time = $rows['end_time'];
        	$shopmessage = $rows['shop_message'];
        }
        $rows = array('app_name'=>$app_name,'currency'=>$currency,'location'=>$location,'min_cart_value'=>$min_cart_value,'max_distance'=>$max_dis,'tax'=>$tax,'start_time'=>$start_time,'end_time'=>$end_time,'shop_message'=>$shopmessage,'free_deli_value'=>$free_value);
        echo json_encode($rows);
    }
}


?>