MOON
Server: Apache
System: Linux 54-179-220-51.cprapid.com 3.10.0-1160.144.1.el7.tuxcare.els4.x86_64 #1 SMP Tue Apr 7 08:40:40 UTC 2026 x86_64
User: thehunarfound (1001)
PHP: 7.4.29
Disabled: NONE
Upload Files
File: /home/thehunarfound/www/sms/enrollment-form.php-3-nov-2020
<?php
ob_start();
include('lib/config.php');
$role=$_SESSION["Role"];
if(isset($_POST['Export_single'])){
  ob_end_clean();
//header('Content-Type: text/csv; charset=utf-8');
// header('Content-Disposition: attachment; filename = Enrollment Report.csv');
// $output = fopen("php://output", "w");
// fputcsv($output, array('ENROLLMENT DATE', 'ENROLLMENT #','FORM #', 'STUDENT NAME', 'FATHER NAME', 'PHONE NO', 'OTHER NUMBER', 'EMAIL', 'ADDRESS', 'AREA', 'CITY',
// 				'DATE OF BIRTH','SSC %','DEGREE', 'CNIC','PROGRAM','SECTION','CAMPUS', 'BATCH #', 'SHIFT','SPONSOR 1','AMOUNT','SPONSOR 2','AMOUNT ','ZAKAT ELIGIBLE','STATUS', 'DATE CREATED'));
	if($role == 'admin')
	{
  $query = "select * from query_log where form_no=".$_POST['form_no']." INNER JOIN results ON query_log.form_no = results.form_no ";
    print_r($query);
    exit;

				if($_GET['batch_no'] != '')
				$query = $query." AND s.`batch_no` = '".$_GET['batch_no']."'";
				if($_GET['campus'] != '')
					$query = $query." AND s.`campus` = '".$_GET['campus']."'";
				if($_GET['program'] != '')
					$query = $query." AND s.`trade` = '".$_GET['program']."'";
					$query = $query." AND s.fee_status = 1 ";
  }else{
    $query = "SELECT er.`form_no`, er.`enrollment_date`, er.`enrollment_no`, s.`Student_name`, af.father_name, af.phone_no, af.cell_no, af.email, af.`address`, ql.`area`, ql.`city`,
				ql.`dob`,ql.`ssc_per`, af.`degree`, af.`cnic_no`, intd.`sel_trade`, intd.`section`,s.`campus`, intd.`sel_batch`, intd.`sel_shift`,s.`sponsor_name1`,s.`amount1`,s.`sponsor_name2`,s.`amount2`,IF(intd.`zakat_eligible` = 1, 'Yes', 'NO'),IF(s.`status` = 1, 'Active', 'Dropout') , er.`date_added` from Students s INNER JOIN enrollment_report er ON s.form_no = er.form_no INNER JOIN application_form af ON s.form_no = af.form_no INNER JOIN query_log ql ON ql.form_no = af.form_no INNER JOIN interview_data intd ON intd.form_no = af.form_no where 1";

	if($_GET['batch_no'] != '')
				$query = $query." AND s.`batch_no` = '".$_GET['batch_no']."'";
			if($_GET['program'] != '')
				$query = $query." AND s.`trade` = '".$_GET['program']."'";
				$query = $query." AND s.`campus` = '" .$_SESSION["Role"]."' AND s.fee_status = 1";

  }
$res =$db->ExecuteQuery($query);
while($row = $res->FetchAsArray(MYSQL_ASSOC))
{
 fputcsv($output, $row);
}
fclose($output);

	echo 'SYSTEM GENERATED REPORT';
die;
}
if(isset($_POST["Export"])){

ob_end_clean();
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename = Enrollment Report.csv');
$output = fopen("php://output", "w");
fputcsv($output, array('ENROLLMENT DATE', 'ENROLLMENT #','FORM #', 'STUDENT NAME', 'FATHER NAME', 'PHONE NO', 'OTHER NUMBER', 'EMAIL', 'ADDRESS', 'AREA', 'CITY',
				'DATE OF BIRTH','SSC %','DEGREE', 'CNIC','PROGRAM','SECTION','CAMPUS', 'BATCH #', 'SHIFT','SPONSOR 1','AMOUNT','SPONSOR 2','AMOUNT ','ZAKAT ELIGIBLE','STATUS', 'DATE CREATED','Gender'));
	if($role == 'admin')
	{
  $query = "SELECT er.`enrollment_date`, er.`enrollment_no`,er.`form_no`, s.`Student_name`, af.father_name, af.phone_no, af.cell_no, af.email, af.`address`, ql.`area`, ql.`city`,
				ql.`dob`,ql.`ssc_per`, af.`degree`,af.`cnic_no`, intd.`sel_trade`, intd.`section`,s.`campus`, intd.`sel_batch`, intd.`sel_shift`,s.`sponsor_name1`,s.`amount1`,s.`sponsor_name2`,s.`amount2`, IF(intd.`zakat_eligible` = 1, 'Yes', 'NO') ,IF(s.`status` = 1, 'Active', 'Dropout'), er.`date_added`,af.gender from Students s INNER JOIN enrollment_report er ON s.form_no = er.form_no INNER JOIN application_form af ON s.form_no = af.form_no
        INNER JOIN query_log ql ON ql.form_no = af.form_no
        INNER JOIN interview_data intd ON intd.form_no = af.form_no where 1";

				if($_GET['batch_no'] != '')
				$query = $query." AND s.`batch_no` = '".$_GET['batch_no']."'";
				if($_GET['campus'] != '')
					$query = $query." AND s.`campus` = '".$_GET['campus']."'";
				if($_GET['program'] != '')
					$query = $query." AND s.`trade` = '".$_GET['program']."'";
					$query = $query." AND s.fee_status = 1 ";
  }else{
    $query = "SELECT  er.`enrollment_date`,er.`enrollment_no`,er.`form_no`, s.`Student_name`, af.father_name, af.phone_no, af.cell_no, af.email, af.`address`, ql.`area`, ql.`city`,
				ql.`dob`,ql.`ssc_per`, af.`degree`, af.`cnic_no`, intd.`sel_trade`, intd.`section`,s.`campus`, intd.`sel_batch`, intd.`sel_shift`,s.`sponsor_name1`,s.`amount1`,s.`sponsor_name2`,s.`amount2`,IF(intd.`zakat_eligible` = 1, 'Yes', 'NO'),IF(s.`status` = 1, 'Active', 'Dropout') , er.`date_added` from Students s INNER JOIN enrollment_report er ON s.form_no = er.form_no INNER JOIN application_form af ON s.form_no = af.form_no INNER JOIN query_log ql ON ql.form_no = af.form_no INNER JOIN interview_data intd ON intd.form_no = af.form_no where 1";

	if($_GET['batch_no'] != '')
				$query = $query." AND s.`batch_no` = '".$_GET['batch_no']."'";
			if($_GET['program'] != '')
				$query = $query." AND s.`trade` = '".$_GET['program']."'";
				$query = $query." AND s.`campus` = '" .$_SESSION["Role"]."' AND s.fee_status = 1";

  }
$res =$db->ExecuteQuery($query);
while($row = $res->FetchAsArray(MYSQL_ASSOC))
{
 fputcsv($output, $row);
}
fclose($output);

	echo 'SYSTEM GENERATED REPORT';
die;
}


if(isset($_GET['DID']))
{
  $db->ExecuteQuery("delete from enrollment_report where form_no = ".$_GET['form_no']);
  $db->ExecuteQuery("delete from Students where form_no = ".$_GET['form_no']);

  echo "<script>alert('Record Deleted !');</script>";
  reDirectUsingJavascript('enrollment-form.php');
}

?>

<script>
function doSingleDelete(did)
	{

		if(confirm("Are you sure you want to delete"))
		{
		 location.href='<?php 'enrollment-form.php'; ?>?DID='+did;
    }

}
</script>
<!DOCTYPE html>
<html lang="en">
	<head>
		<!-- head scripts -->
		<?php include('includes/head-scripts.php')?>
	</head>


	<body>
		<div id="sb-site">

			<!-- chat sidebar -->
			<?php include('includes/chat-drawer.php')?>


			<!-- page-wrapper -->
			<div id="page-wrapper">
				<div id="mobile-navigation"><button id="nav-toggle" class="collapsed" data-toggle="collapse" data-target="#page-sidebar"><span></span></button>
			</div>


			<!-- Left NAV  -->
			<?php include('includes/sidebar.php'); ?>


			<!-- Right Content Area  -->
			<div id="page-content-wrapper">
				<div id="page-content">

					<?php include('includes/header.php'); ?>


					<!-- Query log --->
					<div id="page-title">
						<h2>Enrollment Form</h2>
					</div>
					<div class="panel">
						<div class="panel-body">
							<div class="example-box-wrapper">
								<div id="datatable-responsive_wrapper" class="dataTables_wrapper form-inline">
									<div class="row">

									</div>

									<br/>

										<div class="row">

											<div class="col-md-3">

												<div class="dataTables_length" id="datatable-responsive_length">

													<select name="datatable-responsive_length" aria-controls="datatable-responsive" class="form-control">
														<option value="10">10</option>
														<option value="25">25</option>
														<option value="50">50</option>
														<option value="100">100</option>
													</select>
													records per page

												</div>
											</div>

											<div class="col-md-6">
												<form class="form-horizontal" action="" method="post" name="upload_excel" enctype="multipart/form-data">
													<input type="submit" name="Export" class="btn btn-lg btn-primary srhBTN" value="Download Excel File"/>
												</form>
											</div>
<!--                       <div class="col-md-6">
												<form class="form-horizontal" action="" method="post" name="upload_excel" enctype="multipart/form-data">
                          <div class="col-md-2">
                            <input type="text" name="form_no" style="width:150px" class="form-control" value="" placeholder="Enter Form No."/>
                          </div>
                           <div class="col-md-2" style="margin-left:150px">
													  <input type="submit" name="Export_single" class="btn btn-lg btn-primary srhBTN" value="Download Single Record"/>
                          </div>
												</form>
											</div> -->
										</div>

										<div class="row" style="margin-top: 30px; margin-bottom: 30px;">
											<form>
												<div id="datatable-responsive_filter" class="dataTables_filter">

													<?php		if($role == 'admin')
													{	?>
													<div class="col-md-3">
														<select id="campus" name="campus" class="form-control" data-parsley-id="0001">
															<option disabled selected value="">-Selected-</option>
															<option value="DMSTI" <?php if("DMSTI" == $_GET['campus']){ echo "selected"; }?>>DMSTI</option>
															<option value="FAASTI" <?php if("FAASTI" == $_GET['campus']){ echo "selected"; }?>>FAASTI</option>
															<option value="SDAMKTI" <?php if("SDAMKTI" == $_GET['campus']){ echo "selected"; }?>>SDAMKTI</option>
															<option value="HAKTI" <?php if("HAKTI" == $_GET['campus']){ echo "selected"; }?>>HAKTI </option>
															<option value="PATTI" <?php if("PATTI" == $_GET['campus']){ echo "selected"; }?>>PATTI</option>
															<option value="CVI" <?php if("CVI" == $_GET['campus']){ echo "selected"; }?>>CVI</option>
                              <option value="THF-SNTI" <?php if("THF-SNTI" == $_GET['campus']){ echo "selected"; } ?>>THF-SNTI</option>
														</select>
													</div>
													<?php } ?>

													<div class="col-md-3">
														<select name="program" class="form-control" aria-controls="datatable-responsive">
															<option disabled selected value="">-Program-</option>
															<?php
																	$sql =  "SELECT `value` FROM `add_setup` WHERE name='program'" ;
															$res = $db->ExecuteQuery($sql);
															while(list($available_prog) = $res->FetchAsArray()){
															?>
															<option value="<?=$available_prog?>" <?php if($available_prog == $_GET['program']){ echo "selected"; } ?>><?=$available_prog?></option>
															<?php } ?>
														</select>
													</div>

													<div class="col-md-2">
														<select name="batch_no" class="form-control" aria-controls="datatable-responsive">
															<option  selected value="">-Batch-</option>
															<?php
                        	if($role == 'admin'){
                                $sql = "SELECT `value` FROM add_setup WHERE name='batch'";
                          }else{
                             $sql =  "SELECT DISTINCT batch FROM admission_setup WHERE campus = '".$_SESSION["Role"]."'";
                             }
                              $res = $db->ExecuteQuery($sql);
                              while(list($batch_no_val) = $res->FetchAsArray())
														{
															?>
															<option value="<?=$batch_no_val?>" <?php if($batch_no_val == $_GET['batch_no']){ echo "selected"; } ?>><?=$batch_no_val?></option>
															<?php   } ?>
														</select>
													</div>

													<div class="col-md-2">
														<input type="search" style="width: 100%; margin-left: 0px;" class="form-control" placeholder="By Name and form #" value="<?=$_GET['search']?>" name="search" aria-controls="datatable-responsive">
													</div>

													<div class="col-md-2">
														<button type="submit" class="btn btn-lg btn-primary srhBTN">Search</button>
													</div>
												</div>
											</form>
										</div>



										<div id="#dtable" >
											<table id="datatable-responsive" class="table table-striped table-bordered responsive no-wrap dataTable dtr-inline check" cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">
												<thead>
													<tr role="row " class="thead-color">
														<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" >Form No</th>
														<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" >Enrollment Date</th>
														<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" style="width: 160px;" >Enrollment #</th>
														<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" >Student Name</th>

														<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" >Selected Trade</th>
														<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" style="width: 117px;" >Batch #</th>
														<th class="" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" >Campus</th>

													</tr>
												</thead>
												<tbody>
													<?php
													$campus = $_SESSION["Role"];
													if(isset($_GET['campus'])){
													$campus = $_GET['campus'];
													}
													$numrows = $db->GetSingleRecord("Select COUNT(*) from Students s INNER JOIN enrollment_report er ON s.form_no = er.form_no where s.`batch_no` like '%".$_GET['batch_no']."%' AND s.`trade` like '%".$_GET['program']."%' AND s.fee_status = 1 AND ( s.Student_name like '%".$_GET['search']."%' OR s.form_no like '%".$_GET['search']."%') ");
													// number of rows to show per page
													$rowsperpage = 10;
													// find out total pages
													$totalpages = ceil($numrows / $rowsperpage);
													// get the current page or set a default
													if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
													// cast var as int
													$currentpage = (int) $_GET['currentpage'];
													} else {
													// default page num
													$currentpage = 1;
													} // end if
													// if current page is greater than total pages...
													if ($currentpage > $totalpages) {
													// set current page to last page
													$currentpage = $totalpages;
													} // end if
													// if current page is less than first page...
													if ($currentpage < 1) {
													// set current page to first page
													$currentpage = 1;
													} // end if
													// the offset of the list, based on current page
													$offset = ($currentpage - 1) * $rowsperpage;

													if($role == 'admin')
													{
													$query =  "SELECT s.`form_no`, s.`Student_name`, s.`Contact_no`, s.`trade`, s.`section`, s.`batch_no`, s.`campus`, er.enrollment_date, er.enrollment_no,er.id from Students s INNER JOIN enrollment_report er ON s.form_no = er.form_no where 1";
													if($_GET['batch_no'] != '')
													$query = $query." AND s.`batch_no` = '".$_GET['batch_no']."'";
													if($_GET['campus'] != '')
													$query = $query." AND s.`campus` = '".$_GET['campus']."'";
													if($_GET['program'] != '')
													$query = $query." AND s.`trade` = '".$_GET['program']."'";
													if($_GET['search'] != ''){
													$query = $query." AND (s.Student_name like '%".$_GET['search']."%'";
													$query = $query." OR s.`form_no` like '%".$_GET['search']."%')";
													}
													$query = $query." AND s.fee_status = 1 order by s.id DESC LIMIT ".$offset.", ".$rowsperpage;
													}
													else
													{

													$query =  "SELECT s.`form_no`, s.`Student_name`, s.`Contact_no`, s.`trade`,s.`section`, s.`batch_no`,s.`campus`, er.enrollment_date, er.enrollment_no, er.id from Students s INNER JOIN enrollment_report er ON s.form_no = er.form_no where 1";

													if($_GET['batch_no'] != '')
													$query = $query." AND s.`batch_no` = '".$_GET['batch_no']."'";
													if($_GET['program'] != '')
													$query = $query." AND s.`trade` = '".$_GET['program']."'";
													if($_GET['search'] != ''){
													$query = $query." AND (s.Student_name like '%".$_GET['search']."%'";

													$query = $query." OR s.`form_no` like '%".$_GET['search']."%')";
													}
													$query = $query." AND s.`campus` ='" .$_SESSION["Role"]."' AND s.fee_status = 1 order by s.id DESC LIMIT ".$offset.", ".$rowsperpage;
													}

													$res = $db->ExecuteQuery($query);
													$num = $res->GetSelectedRows();
													if($num==0){
													echo '<h2>NO RESULT FOUND</h2>';
													}

													while(list($form_no,$student_name,$contact_no,$trade,$section,$batch_no,$campus,$enrollment_date,$enrollment_no,$id) = $res->FetchAsArray())

													{
													?>
													<tr role="row" class="odd">
														<td class=""><?=$form_no?></td>
														<td class=""><?=$enrollment_date?></td>
														<td class=""><?=$enrollment_no?></td>
														<td class=""><?=$student_name?></td>
														<td class=""><?=$trade?></td>
														<td class=""><?=$batch_no?></td>
														<td class=""><?=$campus?></td>
												</tr>
													<?php
													} ?>

												</tbody>

											</table>


											<!--  pagination -->
											<div class="row"><br>
												<div class="col-sm-6">
													<div class="dataTables_info" aria-live="polite">Showing <?=$offset+1?> to <?php if($currentpage == $totalpages) { echo $numrows; }else{ echo $currentpage*$rowsperpage; }?> of <?=$numrows?> entries</div>
												</div>

												<div class="col-sm-6">
													<div class="dataTables_paginate paging_bootstrap" id="datatable-responsive_paginate">
														<ul class="pagination">
															<?php
															$range = 3;
															// if not on page 1, don't show back links
															if ($currentpage > 1) {
																$prevpage = $currentpage - 1;
															?>
															<li class="previous"><a href="<?php echo $_SERVER['SCRIPT_URI'].'?currentpage.='.$prevpage; ?>">Previous</a></li>
															<?php }else{ ?>
															<li class="previous disabled"><a href="<?php echo $_SERVER['SCRIPT_URI'].'?currentpage.=1'; ?>">Previous</a></li>
															<?php }
															// loop to show links to range of pages around current page
															for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
															// if it's a valid page number...
															if (($x > 0) && ($x <= $totalpages)) {
															// if we're on current page...
															if ($x == $currentpage) {
															// 'highlight' it but don't make a link
															echo '<li class="active"><a href="javascript:void(0);">'.$x.'</a></li>';
															// if not current page...
															} else {
															// make it a link
															echo '<li><a href="'.$_SERVER['SCRIPT_URI'].'?currentpage='.$x.'&batch_no='.$_GET['batch_no'].'&campus='.$_GET['campus'].'&program='.$_GET['program'].'">'.$x.'</a></li>';
															} // end else
															} // end if
															} // end f
															// if not on last page, show forward and last page links
															if ($currentpage != $totalpages) {
															// get next page
															$nextpage = $currentpage + 1;
															// echo forward link for next page
															echo "<li class='next'><a href='".$_SERVER['SCRIPT_URI']."?currentpage=".$nextpage."&batch_no=".$_GET['batch_no']."&campus=".$_GET['campus']."&program=".$_GET['program']."'>Next</a></li>";
															// echo forward link for lastpage
															//echo " <a href='".$_SERVER['SCRIPT_URI']."?currentpage=".$totalpages."'>>></a> ";
															} // end if
															?>
														</ul>
													</div>
												</div>
											</div>

										</div>
									</div>
								</div>
							</div>


						</div>
					</div>
					<!-- Right Content Area  -->

				</div>
				<!-- page-wrapper -->


				<!-- foot Scripts -->
				<?php include('includes/foot-scripts.php')?>


			</div>
		</body>
	</html>