<?php 

require 'db.php';
// $data = json_decode(file_get_contents('php://input'), true);
 
// $uid = $data['uid'];
// if($uid == '')
// {
// 	$returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Something Went wrong  try again !");
// }

$sels = $con->query("select * from subcategory");
while($rows = $sels->fetch_assoc())
{
        $p['id'] = $rows['id'];
		$p['subcatname'] = $rows['name'];
		$p['subcatimg'] = $rows['img'];
		$p['cattime'] = $rows['cattime'];
    	if($p['cattime'] == "Default")
    	{
    	    $sel = $con->query("select start_time,end_time from setting where id='1'");
            if($row = $sel->fetch_assoc())
            {
                $p['catstarttime'] = $row['start_time'];
                $p['catstoptime'] = $row['end_time'];
            }
    	}
    	else
    	{
    	    $p['catstarttime'] = $rows['catstarttime'];
    	    $p['catstoptime'] = $rows['catstoptime'];
    	}
		$p['catstatus'] = $rows['catstatus'];
		$cat =  $con->query("select catname from category where id=".$rows['cat_id']."");
		if($row = $cat->fetch_assoc())
		$p['catname'] = $row['catname'];

		$cp[] = $p;
}

echo json_encode($cp);
?>