CasperSecurity
<!doctype html>
<?php
include 'connection/config.php';
include 'connection/connection.php';
$connection = new createConnection();
$connection->connect($host, $user, $pass, $db);
// Default academic year (current year)
$academicYear = isset($_POST['academic_year']) ? $_POST['academic_year'] : date("Y");
// Fetch unique academic years from the pre_admission_student table
$acayear = "SELECT DISTINCT academic_year FROM pre_admission_student ORDER BY academic_year DESC";
$querya = mysqli_query($connection->myconn, $acayear);
// Fetching Fresher and Lateral counts based on the selected academic year
$fresherQuery = "SELECT COUNT(*) AS fresher_count FROM pre_admission_student WHERE academic_year = '$academicYear' AND admission_type = 'Fresher'";
$lateralQuery = "SELECT COUNT(*) AS lateral_count FROM pre_admission_student WHERE academic_year = '$academicYear' AND admission_type = 'Lateral'";
$fresherResult = mysqli_query($connection->myconn, $fresherQuery);
$lateralResult = mysqli_query($connection->myconn, $lateralQuery);
$fresherCount = mysqli_fetch_assoc($fresherResult)['fresher_count'];
$lateralCount = mysqli_fetch_assoc($lateralResult)['lateral_count'];
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>UIET | PREADMISSION</title>
<style>
.card-container {
display: flex;
flex-wrap: wrap;
gap: 20px; /* Add gap between cards */
justify-content: flex-start;
}
.card {
flex: 1 1 calc(25% - 20px); /* Adjust to fit four cards per row with gap */
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
}
.branch-info {
padding: 10px;
}
.branch-name {
font-weight: bold;
margin-bottom: 10px;
font-size: 20px;
}
.row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 5px; /* Adjust as needed for spacing between rows */
}
.seat-count,
.status {
font-weight: bold;
}
.count-number {
color: blue;
}
.reported-number {
color: #664507;
}
.avail-number {
color: purple;
}
.fresher {
color: green;
}
.lateral {
color: purple;
}
/* Define background colors */
.branch-1 {
background-color: #90EE90;
}
.branch-2 {
background-color: #FFA07A;
}
.branch-3 {
background-color: #20B2AA;
}
.branch-4 {
background-color: #87CEFA;
}
.branch-5 {
background-color: #FFD700;
}
.branch-6 {
background-color: #9370DB;
}
.branch-7 {
background-color: #ffcc00;
}
.branch-8 {
background-color: #8a2be2;
}
.branch-9 {
background-color: #00ced1;
}
.branch-10 {
background-color: #ff6347;
}
.academic-year-section,
.fresher-lateral-section,
.branch-section {
margin-bottom: 20px; /* Add gap between sections */
}
.academic-year-section select {
font-size: 20px;
padding: 5px;
}
/* Styling for Fresher and Lateral sections */
.fresher-card,
.lateral-card {
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
flex: 1 1 calc(50% - 20px); /* Adjust to fit two cards per row with gap */
}
.fresher-card .branch-info,
.lateral-card .branch-info {
text-align: center;
}
.fresher-card .branch-name,
.lateral-card .branch-name {
font-weight: bold;
font-size: 26px;
margin-bottom: 10px;
}
.fresher-card .count-number,
.lateral-card .count-number {
color: blue;
font-weight: bold;
font-size: 16px;
}
.count-details {
display: flex;
justify-content: space-between;
}
.count-details span {
margin-right: 20px; /* Adjust as needed for spacing between counts */
}
</style>
</head>
<body>
<div class="section-body mt-4">
<div class="container-fluid">
<div class="tab-pane active">
<div class="card" style="width: 100%;">
<!-- Form to select academic year -->
<div class="academic-year-section">
<form method="post" action="">
<label for="academic_year" style="font-size: 18px; font-weight: bold;">Select Academic Year:</label>
<select name="academic_year" id="academic_year" onchange="this.form.submit()">
<?php
while ($resultmod = mysqli_fetch_assoc($querya)) {
$year = $resultmod['academic_year'];
$selected = ($year == $academicYear) ? 'selected' : '';
echo "<option value='$year' $selected>$year</option>";
}
?>
</select>
</form>
</div>
<div class="fresher-lateral-section card-container">
<?php
// Query to get total seats for Fresher and Lateral admissions from branchwise_seat table
$totalFresherSeatsQuery = "SELECT SUM(seat) AS total_fresher_seats FROM branchwise_seat WHERE admission_type = 'Fresher'";
$totalLateralSeatsQuery = "SELECT SUM(seat) AS total_lateral_seats FROM branchwise_seat WHERE admission_type = 'Lateral'";
$totalFresherSeatsResult = mysqli_query($connection->myconn, $totalFresherSeatsQuery);
$totalLateralSeatsResult = mysqli_query($connection->myconn, $totalLateralSeatsQuery);
$totalFresherSeatsData = mysqli_fetch_assoc($totalFresherSeatsResult);
$totalLateralSeatsData = mysqli_fetch_assoc($totalLateralSeatsResult);
$totalFresherSeats = $totalFresherSeatsData['total_fresher_seats'];
$totalLateralSeats = $totalLateralSeatsData['total_lateral_seats'];
// Query to get total reported counts for Fresher and Lateral admissions from pre_admission_student table
$totalFresherReportedQuery = "SELECT COUNT(*) AS total_fresher_reported FROM pre_admission_student WHERE admission_type = 'Fresher' AND academic_year = '$academicYear'";
$totalLateralReportedQuery = "SELECT COUNT(*) AS total_lateral_reported FROM pre_admission_student WHERE admission_type = 'Lateral' AND academic_year = '$academicYear'";
$totalFresherReportedResult = mysqli_query($connection->myconn, $totalFresherReportedQuery);
$totalLateralReportedResult = mysqli_query($connection->myconn, $totalLateralReportedQuery);
$totalFresherReportedData = mysqli_fetch_assoc($totalFresherReportedResult);
$totalLateralReportedData = mysqli_fetch_assoc($totalLateralReportedResult);
$totalFresherReported = $totalFresherReportedData['total_fresher_reported'];
$totalLateralReported = $totalLateralReportedData['total_lateral_reported'];
// Calculate vacancies for Fresher and Lateral admissions
$totalFresherVacancy = $totalFresherSeats - $totalFresherReported;
$totalLateralVacancy = $totalLateralSeats - $totalLateralReported;
?>
<!-- Fresher Card -->
<div class="card fresher-card">
<div class="branch-info">
<div class="branch-name">Fresher</div>
<div class="count-details">
<span>Total Seats: <span class="count-number"><?php echo $totalFresherSeats ; ?></span></span>
<span>Reported: <span class="count-number"><?php echo $totalFresherReported; ?></span></span>
<span>Vacancy: <span class="count-number"><?php echo $totalFresherVacancy; ?></span></span>
</div>
</div>
</div>
</div>
<?php
$bselect = "SELECT
bs.branch_id,
bs.seat,bs.total_tfwseat,bs.total_nontfwseat,
bs.admission_type,
(SELECT COUNT(*) FROM pre_admission_student WHERE class_id = bs.class_id AND branch_id = bs.branch_id AND academic_year = '$academicYear' AND admission_type = bs.admission_type) AS pre_admitted_students,
(bs.seat - (SELECT COUNT(*) FROM pre_admission_student WHERE class_id = bs.class_id AND branch_id = bs.branch_id AND academic_year = '$academicYear' AND admission_type = bs.admission_type)) AS vacancy
FROM
branchwise_seat bs
WHERE
bs.admission_type = 'Fresher'";
$queryselectb = mysqli_query($connection->myconn, $bselect);
$branchData = [];
while ($row = mysqli_fetch_assoc($queryselectb)) {
$branchData[] = $row;
}
?>
<div class="branch-section card-container">
<?php foreach ($branchData as $branch) : ?>
<?php
$branchId = $branch['branch_id'];
$totalSeats = $branch['seat'];
$preAdmittedStudents = $branch['pre_admitted_students'];
$vacancy = $branch['vacancy'];
$admissionType = $branch['admission_type'];
$total_tfwseat = $branch['total_tfwseat'];
$total_nontfwseat = $branch['total_nontfwseat'];
$sell = "SELECT * FROM branchs WHERE branch_id='$branchId'";
$queryl = mysqli_query($connection->myconn, $sell);
$resultl = mysqli_fetch_assoc($queryl);
$branch_namef = $resultl['branch_name'];
// Count tfw
$select = "SELECT COUNT(*) AS tfw_reported FROM pre_admission_student WHERE admission_type = 'Fresher' AND academic_year = '$academicYear' AND branch_id='$branchId' AND tfw='TFW' AND is_active='yes'";
$qryres = mysqli_query($connection->myconn, $select);
$dataresult = mysqli_fetch_assoc($qryres);
$tfw_reported = $dataresult['tfw_reported'];
if(!empty($total_tfwseat)){
$tfwvacancy = $total_tfwseat -$tfw_reported;
}else{
$tfwvacancy=0;
}
// Count non tfw
$select2 = "SELECT COUNT(*) AS nontfw_reported FROM pre_admission_student WHERE admission_type = 'Fresher' AND academic_year = '$academicYear' AND branch_id='$branchId' AND tfw='NON-TFW' AND is_active='yes'";
$qryres2 = mysqli_query($connection->myconn, $select2);
$dataresult2 = mysqli_fetch_assoc($qryres2);
$nontfw_reported = $dataresult2['nontfw_reported'];
if(!empty($total_nontfwseat)){
$nontfwvacancy = $total_nontfwseat -$nontfw_reported;
}else{
$nontfwvacancy=0;
}
?>
<div class="card branch-<?php echo $branchId; ?>">
<div class="branch-info">
<div class="row">
<div class="branch-name"><?php echo $branch_namef; ?></div>
</div>
<div class="row">
<div class="seat-count">Total Seats: <span class="count-number"><?php echo $totalSeats; ?></span></div>
</div>
<div class="row">
<div class="seat-count">Reported : <span class="reported-number"><?php echo $preAdmittedStudents; ?></span></div>
</div>
<div class="row">
<div class="status">Vacancy : <span class="avail-number"><?php echo $vacancy; ?></span></div>
</div>
<div class="row">
<div class="status">TFW Strength : <span class="avail-number"><?php echo $total_tfwseat; ?></span></div>
</div>
<div class="row">
<div class="status">TFW Reported : <span class="avail-number"><?php echo $tfw_reported; ?></span></div>
</div>
<div class="row">
<div class="status">TFW Vacancy : <span class="avail-number"><?php echo $tfwvacancy; ?></span></div>
</div>
<div class="row">
<div class="status">NON TFW Strength : <span class="avail-number"><?php echo $total_nontfwseat; ?></span></div>
</div>
<div class="row">
<div class="status">NON TFW Reported : <span class="avail-number"><?php echo $nontfw_reported; ?></span></div>
</div>
<div class="row">
<div class="status">NON TFW Vacancy : <span class="avail-number"><?php echo $nontfwvacancy; ?></span></div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="fresher-lateral-section card-container">
<?php
// Query to get total seats for Fresher and Lateral admissions from branchwise_seat table
$totalFresherSeatsQuery = "SELECT SUM(seat) AS total_fresher_seats FROM branchwise_seat WHERE admission_type = 'Fresher'";
$totalLateralSeatsQuery = "SELECT SUM(seat) AS total_lateral_seats FROM branchwise_seat WHERE admission_type = 'Lateral'";
$totalFresherSeatsResult = mysqli_query($connection->myconn, $totalFresherSeatsQuery);
$totalLateralSeatsResult = mysqli_query($connection->myconn, $totalLateralSeatsQuery);
$totalFresherSeatsData = mysqli_fetch_assoc($totalFresherSeatsResult);
$totalLateralSeatsData = mysqli_fetch_assoc($totalLateralSeatsResult);
$totalFresherSeats = $totalFresherSeatsData['total_fresher_seats'];
$totalLateralSeats = $totalLateralSeatsData['total_lateral_seats'];
// Query to get total reported counts for Fresher and Lateral admissions from pre_admission_student table
$totalFresherReportedQuery = "SELECT COUNT(*) AS total_fresher_reported FROM pre_admission_student WHERE admission_type = 'Fresher' AND academic_year = '$academicYear'";
$totalLateralReportedQuery = "SELECT COUNT(*) AS total_lateral_reported FROM pre_admission_student WHERE admission_type = 'Lateral' AND academic_year = '$academicYear'";
$totalFresherReportedResult = mysqli_query($connection->myconn, $totalFresherReportedQuery);
$totalLateralReportedResult = mysqli_query($connection->myconn, $totalLateralReportedQuery);
$totalFresherReportedData = mysqli_fetch_assoc($totalFresherReportedResult);
$totalLateralReportedData = mysqli_fetch_assoc($totalLateralReportedResult);
$totalFresherReported = $totalFresherReportedData['total_fresher_reported'];
$totalLateralReported = $totalLateralReportedData['total_lateral_reported'];
// Calculate vacancies for Fresher and Lateral admissions
$totalFresherVacancy = $totalFresherSeats - $totalFresherReported;
$totalLateralVacancy = $totalLateralSeats - $totalLateralReported;
?>
<!-- Lateral Card -->
<div class="card lateral-card">
<div class="branch-info">
<div class="branch-name">Lateral</div>
<div class="count-details">
<span>Total Seats: <span class="count-number"><?php echo $totalLateralSeats; ?></span></span>
<span>Reported: <span class="count-number"><?php echo $totalLateralReported; ?></span></span>
<span>Vacancy: <span class="count-number"><?php echo $totalLateralVacancy; ?></span></span>
</div>
</div>
</div>
</div>
<?php
$bselect = "SELECT
bs.branch_id,
bs.seat,bs.total_tfwseat,bs.total_nontfwseat,
bs.admission_type,
(SELECT COUNT(*) FROM pre_admission_student WHERE class_id = bs.class_id AND branch_id = bs.branch_id AND academic_year = '$academicYear' AND admission_type = bs.admission_type) AS pre_admitted_students,
(bs.seat - (SELECT COUNT(*) FROM pre_admission_student WHERE class_id = bs.class_id AND branch_id = bs.branch_id AND academic_year = '$academicYear' AND admission_type = bs.admission_type)) AS vacancy
FROM
branchwise_seat bs
WHERE
bs.admission_type = 'Lateral'";
$queryselectb = mysqli_query($connection->myconn, $bselect);
$branchData = [];
while ($row = mysqli_fetch_assoc($queryselectb)) {
$branchData[] = $row;
}
?>
<div class="branch-section card-container">
<?php foreach ($branchData as $branch) : ?>
<?php
$branchId = $branch['branch_id'];
$totalSeats = $branch['seat'];
$preAdmittedStudents = $branch['pre_admitted_students'];
$vacancy = $branch['vacancy'];
$admissionType = $branch['admission_type'];
$total_tfwseat = $branch['total_tfwseat'];
$total_nontfwseat = $branch['total_nontfwseat'];
$sell = "SELECT * FROM branchs WHERE branch_id='$branchId'";
$queryl = mysqli_query($connection->myconn, $sell);
$resultl = mysqli_fetch_assoc($queryl);
$branch_namef = $resultl['branch_name'];
// Count tfw
$select = "SELECT COUNT(*) AS tfw_reported FROM pre_admission_student WHERE admission_type = 'Lateral' AND academic_year = '$academicYear' AND branch_id='$branchId' AND tfw='TFW' AND is_active='yes'";
$qryres = mysqli_query($connection->myconn, $select);
$dataresult = mysqli_fetch_assoc($qryres);
$tfw_reported = $dataresult['tfw_reported'];
if(!empty($total_tfwseat)){
$tfwvacancy = $total_tfwseat -$tfw_reported;
}else{
$tfwvacancy=0;
}
// Count non tfw
$select2 = "SELECT COUNT(*) AS nontfw_reported FROM pre_admission_student WHERE admission_type = 'Lateral' AND academic_year = '$academicYear' AND branch_id='$branchId' AND tfw='NON-TFW' AND is_active='yes'";
$qryres2 = mysqli_query($connection->myconn, $select2);
$dataresult2 = mysqli_fetch_assoc($qryres2);
$nontfw_reported = $dataresult2['nontfw_reported'];
if(!empty($total_nontfwseat)){
$nontfwvacancy = $total_nontfwseat -$nontfw_reported;
}else{
$nontfwvacancy=0;
}
?>
<div class="card branch-<?php echo $branchId; ?>">
<div class="branch-info">
<div class="row">
<div class="branch-name"><?php echo $branch_namef; ?></div>
</div>
<div class="row">
<div class="seat-count">Total Seats: <span class="count-number"><?php echo $totalSeats; ?></span></div>
</div>
<div class="row">
<div class="seat-count">Reported : <span class="reported-number"><?php echo $preAdmittedStudents; ?></span></div>
</div>
<div class="row">
<div class="status">Vacancy : <span class="avail-number"><?php echo $vacancy; ?></span></div>
</div>
<div class="row">
<div class="status">TFW Strength : <span class="avail-number"><?php echo $total_tfwseat; ?></span></div>
</div>
<div class="row">
<div class="status">TFW Reported : <span class="avail-number"><?php echo $tfw_reported; ?></span></div>
</div>
<div class="row">
<div class="status">TFW Vacancy : <span class="avail-number"><?php echo $tfwvacancy; ?></span></div>
</div>
<div class="row">
<div class="status">NON TFW Strength : <span class="avail-number"><?php echo $total_nontfwseat; ?></span></div>
</div>
<div class="row">
<div class="status">NON TFW Reported : <span class="avail-number"><?php echo $nontfw_reported; ?></span></div>
</div>
<div class="row">
<div class="status">NON TFW Vacancy : <span class="avail-number"><?php echo $nontfwvacancy; ?></span></div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
document.getElementById('academic_year').addEventListener('change', function() {
var selectedOption = this.options[this.selectedIndex];
selectedOption.style.backgroundColor = 'yellow'; // Highlight selected option
selectedOption.style.fontWeight = 'bold'; // Make font bold for selected option
});
</script>
</html>