<?php

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

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

$finyear   = $_REQUEST['finyear'];
$cono       = $_REQUEST['cono'];
$cocond = '';
if(!empty($cono)){
    $cocond = " and `cono`='$cono'";
}

$query = "SELECT  `startdate`, `lastdate`,`yearname` FROM `compyear` WHERE `finyear`='$finyear' $cocond";

$result = mysqli_query($conn, $query)or die(mysqli_error($conn));

$r = mysqli_fetch_assoc($result);
$rows = [ 'success' => true,
    'startdate' => $r[startdate],
    'lastdate' => $r[lastdate],
    'yearname' => $r[yearname],
];

header("Content-type: application\json");
echo json_encode($rows);

