<?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`,`vouchno`, `party` FROM `salemain` WHERE  party = '$code' and `invno`= '$invno' and `vouchno` != '$vouchno' ")or die(mysqli_error($conn));


    $row = mysqli_num_rows($getprate);
    if ($row > 0) {
        $fetch = mysqli_fetch_array($getprate);
        $vouchno = $fetch['vouchno'];
        $party = $fetch['party'];
        $s = 1;
        $data = array('vouchno' => $vouchno, 'party' => $party, 's' => $s);
        header('Content-Type: application/json');
        echo json_encode($data);
    }
}
?>
