<?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["invno"]) {
    $invno = $_REQUEST["invno"];
    $vouchno = $_REQUEST["vouchno"];
    $code = $_REQUEST["party"];

    $getprate = mysqli_query($conn, "SELECT `invno`,`party`,`vouchno` FROM `purmain` WHERE `invno`= '$invno' and `party` = '$code' and vouchno != '$vouchno'")or die(mysqli_error($conn));
    
    $row = mysqli_num_rows($getprate);
    if ($row > 0) {
        $fetch = mysqli_fetch_array($getprate);
        $vouchno = $fetch['vouchno'];
        $s = 1;
        $data = array('vouchno' => $vouchno, 's' => $s);
        header('Content-Type: application/json');
        echo json_encode($data);
    }
}
?>
