<?php 
session_start();
include_once '../config.php';
if($_POST['action'] == 'getCat'){?>
    <option value="" selected="selected" disabled="">Select Category</option>
<?php 
    $CostHeadId = $_POST['id'];
        $q = "select * from tbl_category WHERE Status='1' AND CostHeadId='$CostHeadId'";
        $r = $conn->query($q);
        while($rw = $r->fetch_assoc())
    {
?>
                <option value="<?php echo $rw['id']; ?>"><?php echo $rw['Name']; ?></option>
<?php } } 

if($_POST['action'] == 'getItem'){?>
    <option value="" selected="selected" disabled="">Select Work Item</option>
<?php 
    $StateId = $_POST['StateId'];
    $CostHeadId = $_POST['CostHeadId'];
    $CatId = $_POST['CatId'];
        $q = "select * from tbl_work_items WHERE Status='1' AND CostHeadId='$CostHeadId' AND StateId='$StateId' AND CatId='$CatId'";
        $r = $conn->query($q);
        while($rw = $r->fetch_assoc())
    {
?>
                <option value="<?php echo $rw['id']; ?>"><?php echo $rw['Name']; ?></option>
<?php } }

if($_POST['action'] == 'getCourse'){?>
    <option value="" selected="selected" disabled="">Select Course</option>
<?php 
    $DeptId = $_POST['id'];
    $CourseType = $_POST['type'];
        $q = "select * from tbl_courses WHERE DeptId = '$DeptId' AND Status='1' AND Type='$CourseType'";
        $r = $conn->query($q);
        while($rw = $r->fetch_assoc())
    {
?>
    <option value="<?php echo $rw['id']; ?>"><?php echo $rw['Name']; ?></option>
<?php } }

if($_POST['action'] == 'getBatch'){?>
    <option value="" selected="selected" disabled="">Select Batch</option>
<?php 
    $CourseId = $_POST['id'];
        $q = "select * from tbl_batches WHERE CourseId = '$CourseId' AND Status='1'";
        $r = $conn->query($q);
        while($rw = $r->fetch_assoc())
    {
?>
    <option value="<?php echo $rw['id']; ?>"><?php echo $rw['BatchName']; ?></option>
<?php } }


if($_POST['action'] == 'getTestSeriesTime'){
    $time1 = $_REQUEST['time1'];
    $time2 = $_REQUEST['time2'];
$Curr_time = date('Y-m-d H:i:s');
$currenttime = strtotime(date('Y-m-d H:i:s'));

if($currenttime>=$time1)
                {
                  if($currenttime<=$time2)
                  {
                    $active=1;
                  }
                  else
                  {
                    $active=2;
                  }
                }
              else
                {
                  $active=2;
                }

echo $active;
} 
?>