<?php
session_start();
include './connection_sql.php';
if ($_SESSION["CURRENT_USER"] == "") { 
    exit('Please Logging Again..');
} 
if ($_SESSION['company'] == "") { 
    exit('Please Logging Again..');
} 
 

function chk_acyear($date) {
    require ("connection_sql.php");

    $month1 = date("m", strtotime($date));
    $month1_y = date("Y", strtotime($date));

    if ($month1 <= 3) {
        $ac_year = $month1_y - 1;
    } else {
        $ac_year = $month1_y;
    }

    

    $sql = "select * from a_dep_mas where CURRENT_YEAR = '" . $ac_year . "' and lockyear ='N' and COMCODE='" . $_SESSION["company"] . "'";
    $result = $conn->query($sql);
    if ($row = $result->fetch()) {
        return $ac_year;                
    } else {
        return "N";
    }
    
    
    
    
}
