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

$formname = "";
$action = "";

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

$myyear = $_SESSION[$myyear];
$zroot = $_SESSION["zdbroot"];
$vouchno = $_REQUEST["vouchno"];
$addflg = $_REQUEST["addflg"];
$tourname = $_SESSION['tourname'];
$tourcode = $_SESSION['tourcode'];
$tourcond = "AND tour = '$tourcode'";
$tourcond1 = "AND tourno = '$tourcode'";

$result = mysqli_query($conn, "SELECT fullno,halfno,halfno2,infno FROM `bookform` WHERE vouchno='$vouchno' $tourcond") or die(mysqli_error($conn));
$get = mysqli_fetch_array($result);
$fullno = $get['fullno'];
$halfno = $get['halfno'];
$halfno2 = $get['halfno2'];
$infno = $get['infno'];
$tpax = $fullno + $halfno + $halfno2 + $infno;

$result2 = mysqli_query($conn, "SELECT vouchno FROM `visaform` WHERE vregnno='$vouchno' $tourcond") or die(mysqli_error($conn));
$nopax = mysqli_num_rows($result2);
$a = 0;
if ($addflg == 1) {
    if ($nopax > $tpax) {
        $a = 1;
    }
} else {
    if ($nopax >= $tpax) {
        $a = 1;
    }
}
echo $a;
?>