<?php

if (!empty($_POST['college'])) {

    $clg_id = $_POST['college'];

    $conditions[] = "pCollege = '" . $clg_id . "'";

}



if (!empty($_POST['course'])) {

    $course_id = $_POST['course'];

    $conditions[] = "product = '" . $course_id. "'";

}



if (!empty($_POST['StatusValue'])) {

    $conditions[] = "pStatus = '" . $_POST['StatusValue'] . "'";

}



if (!empty($_POST['CategoryValue'])) {

    $conditions[] = "pCat = '" . mysqli_real_escape_string($con, $_POST['CategoryValue']) . "'";

}



// Add date range filters

if (!empty($_POST['StartDate']) && !empty($_POST['EndDate'])) {

    $startDate = mysqli_real_escape_string($con, $_POST['StartDate']);

    $endDate = mysqli_real_escape_string($con, $_POST['EndDate']);

    $conditions[] = "pCreateDate BETWEEN '$startDate' AND '$endDate'";  

} elseif (!empty($_POST['StartDate'])) {

    $startDate = mysqli_real_escape_string($con, $_POST['StartDate']);

    $conditions[] = "pCreateDate >= '$startDate'"; 

} elseif (!empty($_POST['EndDate'])) {

    $endDate = mysqli_real_escape_string($con, $_POST['EndDate']);

    $conditions[] = "pCreateDate <= '$endDate'";  

}

$conditions[] = "pSubFranchiee = '" . $_SESSION['uid'] . "'";

?>