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

ini_set('display_errors', 1);
error_reporting(E_ERROR);

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

$admin = $_SESSION["admin_" . $dbname];
if ($_REQUEST["deptcode"]) {
    $deptcode = $_REQUEST["deptcode"];
    $yearno = $_REQUEST["yearno"];
    $divcode = $_REQUEST["divcode"];
    $mon = $_REQUEST["mon"];
    $vouchno = $_REQUEST["vouchno"];
    if ($deptcode != '' && $mon != '') {
        $chkattend = mysqli_query($conn, "SELECT mon, deptcode, vouchno from attdtran  where mon = '$mon' and deptcode = '$deptcode' and yearno = '$yearno' and vouchno != '$vouchno' ")or die(mysqli_error($conn));
        if (!empty($chkattend)) {
            $fattend = mysqli_num_rows($chkattend);
            if ($fattend > 0) {
                echo "Attendance For This Month & Department & Division Already Exist";
            }
        }
    }
}
?>