<?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];
$zroot = $_SESSION["zdbroot"];

if (isset($_REQUEST['id'])) {

    $id = $_REQUEST['id'];
    $visatype = $_REQUEST['visatype'];
    $voucher = $_REQUEST['voucher'];
    $visano = $_REQUEST['visano'];
    $manualno = $_REQUEST['manualno'];

    if ($id == 'visano') {
        $getm = mysqli_query($conn, "SELECT visano FROM `visamain` where `visatype`='$visatype' and `vouchno` != '$voucher' and `visano`='$visano'")or die(mysqli_error($conn));
        $num = mysqli_num_rows($getm);

        if ($num > 0) {
            Echo "Visa No. Already Exist.";
        }
    } else {
        $getm = mysqli_query($conn, "SELECT manualno FROM `visamain` where `visatype`='$visatype' and `vouchno` != '$voucher' and `manualno`='$manualno'")or die(mysqli_error($conn));
        $num = mysqli_num_rows($getm);

        if ($num > 0) {
            Echo "Manual File No. Already Exist.";
        }
    }
}