<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];

if (isset($_REQUEST['mobile'])) {
    $mobile = $_REQUEST['mobile'];

    $getm = mysqli_query($conn, "SELECT party,architect,ntprint FROM `salemain` WHERE `mobile`='$mobile' order by vouchno DESC limit 0,1")or die(mysqli_error($conn));
    $m = mysqli_fetch_array($getm);

    if (mysqli_num_rows($getm) <= 0) {

        $getparty = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE  `mobile` = '$mobile'") or die(mysqli_error($conn));
        $lparty = mysqli_fetch_array($getparty);
        $party = $lparty['accode'];
    } else {
        $party = $m['party'];
    }
    $architect = $m['architect'];
    $ntprint = $m['ntprint'];

    $data = array('party' => "$party", 'architect' => "$architect", 'ntprint'=> "$ntprint");
    header('Content-Type: application/json');
    echo json_encode($data);
}
?>