<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');
$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

if ($_REQUEST["tenant"]) {
    $tenant = $_REQUEST["tenant"];
//
//    $getdata = mysqli_query($conn, "SELECT a.`block`, a.`floortype`, a.`floorno`, a.`room`, b.name as blockname,a.gstperc,a.tenanttype FROM `tenant` a, block b
//                                   WHERE a.block = b.code AND accode = '$tenant'")or die(mysqli_error($conn));

    $getdata = mysqli_query($conn, "SELECT flatno,tenanttype as rentfor,rent,othertax,total,repairtax,proptax,gstperc FROM `accmast` WHERE accode = '$tenant' ")or die(mysqli_error($conn));
    $row2 = mysqli_fetch_array($getdata);

    $getdata2 = mysqli_query($conn, "SELECT name,block,wing,floor,area,unit,mobile,flatno FROM `accmast` WHERE flatno = '$row2[flatno]' and grpcode = '010'")or die(mysqli_error($conn));
    $row = mysqli_fetch_array($getdata2);
    
    

  
//    $data = array();
    $data = array('success' => true,
        'flatno' => $row['flatno'],
        'name' => $row['name'],
        'block' => $row['block'],
        'wing' => $row['wing'],
        'floor' => $row['floor'],
        'area' => $row['area'],
        'rentfor' => $row2['rentfor'],
        'rent' => $row2['rent'],
        'proptax' => $row2['proptax'],
        'othertax' => $row2['othertax'],
        'repairtax' => $row2['repairtax'],
        'total' => $row2['total'],
        'cgstperc' => $row2['gstperc']/2,
        'sgstperc' => $row2['gstperc']/2,
        'unit' => $unit,
        'mobile' => $row['mobile']
    );
    header("Content-type: application\json");
    echo json_encode($data);
}
?>

