<?php

require_once __DIR__ . '/db_config.php';

$r = array();
$r["subcat"]= array();
$r["cat"]= array();
$r["facility"] = array();

if (isset($_POST["mail"]) ) {
 
$cname=$_POST["cname"];
$email=$_POST["mail"];
date_default_timezone_set('Asia/Calcutta');
$date=date('Y-m-d');
//$email="demonew3@gmail.com";

$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());

$type=array();
mysqli_query($con,'SET CHARACTER SET utf8');

$facilityQuery="SELECT Id,atmid,customername,atmaddress,atmlandmark,atmpincode,state,country,latitude,longitude,location,
atmphonenumber,managername,customermode,facilitytype 
FROM atmdetails 
WHERE companyname='$cname' AND deleted='no'";
    
$result=mysqli_query($con,$facilityQuery);
if(!empty($result) && mysqli_num_rows($result) > 0){
    while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
        array_push($r["facility"], $row);
    }
}

 
 $catQuery="SELECT id,category 
 FROM dynamicquestionscategory 
 WHERE companyname='$cname' AND deleted='no'";
    $result=mysqli_query($con,$catQuery);
    if(!empty($result) && mysqli_num_rows($result) > 0){
        while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
            array_push($r["cat"], $row);
        }
    }

$subcatQuery="SELECT id,category,subcategory 
   FROM dynamicquestionssubcategory 
   WHERE companyname='$cname' AND deleted='no'";
   
$result=mysqli_query($con,$subcatQuery);
    if(!empty($result) && mysqli_num_rows($result) > 0){
        while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
            array_push($r["subcat"], $row);
        }
}

}   
echo json_encode($r);


?>