<?php require "_header.php";?>
<script language="javascript" type="text/javascript">
</script>
<style type="text/css">
	.table-report{
		font-family:Verdana, Geneva, sans-serif;
		font-size:12px;
		text-align:left;
		border-right:0px none;
		border-bottom:0px none;
	}
	.table-report-inner{
		font-family:Verdana, Geneva, sans-serif;
		font-size:12px;
	}
	.table-report tr{
		padding:2px 2px 2px 2px;
	}
	.table-report td{
		padding:2px 2px 2px 2px;
		border-top:0px none;
		border-left:0px none;
	}
	.table-report th{
		padding:2px 2px 2px 2px;
		font-weight:bold;
		text-align:left;
		border-top:0px none;
		border-left:0px none;
	}	
	.break { page-break-before: always; }
</style>
<div id="main-report">
<?php
if($_REQUEST['branch_hidden'] == "")
{
?>
	<script language="javascript" type="text/javascript">
		location.href='report-student-detainlist.php';
	</script>
<?php
}
elseif($_SESSION['VedantnrCollegeId']!="" && isset($_SESSION['VedantnrCollegeId'])) 
{ 
	ob_start();
	
	$branch_id 		 = Escape($_REQUEST['branch_hidden']);
	$year_id	   = Escape($_REQUEST['year_hidden']);
	$branchyear_id	   = Escape($_REQUEST['branchyear_hidden']);
	$shift			 = Escape($_REQUEST['shift']);
	$gturegno_start	= Escape($_REQUEST['gturegno_start']);
	$gturegno_end	  = Escape($_REQUEST['gturegno_end']);
	$branch_name = Escape($_REQUEST['branch_disp']);
	$year_name = Escape($_REQUEST['year_disp']);
	$branchyear_name = Escape($_REQUEST['branchyear_disp']);
	$semester_name = Escape($_REQUEST['semester_disp']);
	
	$gender 			= Escape($_REQUEST['gender']);
	$cast	 		  = Escape($_REQUEST['cast']);
	$AYEAR 			 = Escape($_REQUEST['AYEAR']);
	$admtype 		   = Escape($_REQUEST['admtype']);
	

	
	
	$order_by = $_REQUEST['hid_orderby'];
	$condition  = "";
	
	/*$SQL_STUDENT = "
		SELECT 
	  			sm.student_id,
				sm.student_gturegno,
				sm.student_admdate, 
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
				sm.student_birthdate,
				sm.student_gender,
				sm.student_addressat,
				sm.student_addresspost,	
				sm.student_pincode,
				sm.taluko_nameeng,
				sm.dist_nameeng,
				sm.state_nameeng,		
				sm.student_admby,
				sm.student_category,	
				student_mobileother,
			student_fathermobile,
				sm.leave_type,
			  	(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '".$_SESSION["VedantnrCollegeId"]."' and sec.branch_id=sd.cur_branchid) AS branch_name,
	  		  		(SELECT year_name 
				FROM cms_yearmaster ym 
				WHERE ym.year_id=sd.year_id) AS year_name,
	  		  	(SELECT branchyear_name 
				FROM cms_branchyear bry 
				WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and bry.branchyear_id=sd.cur_branchyearid) AS branchyear_name,
	  		  	(SELECT 
					semester_name
			   	 FROM 
				 	cms_semestermaster sem 
			     WHERE 
				 sem.college_id   = '".$_SESSION["VedantnrCollegeId"]."'
				 AND sem.semester_id = sd.cur_semesterid) AS semester_name,
				 sd.year_id, 	
				(SELECT year_name 
				FROM cms_yearmaster yr 
				WHERE year_id   = sd.year_id) AS year_name		   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '".$_SESSION["VedantnrCollegeId"]."' 
				AND sm.student_id=sd.student_id
				AND sm.student_active=0
				AND sm.leave_type='d'";*/
	
	if($branch_id != "" &&  $branch_id != "All"){
		$condition .= " AND sd.cur_branchid = ".$branch_id;
	}
	if($semester_id != "" && $semester_id != "undefined"){
		$condition .= " AND sd.cur_semesterid = ".$semester_id;
	}
	
	if ($year_id != "" && $year_id != "undefined") {
		$condition .= " AND sd.year_id = " . $year_id;
	}
	if ($branchyear_id != "" && $branchyear_id != "undefined") {
		$condition .= " AND sd.cur_branchyearid = " . $branchyear_id;
	}
	
	if($gender != "" && $gender != "undefined"){
		$condition .= " AND sm.student_gender = '".$gender."'";
	}
	
	if($cast != "" && $cast != "undefined"){
		$condition .= " AND sm.student_category = '".$cast."'";
	}
	
	if($AYEAR != "" && $AYEAR != "undefined"){
		$condition .= " AND YEAR(sm.student_admdate) = '".$AYEAR."'";
	}
	
	
	if($admtype != "" && $admtype != "undefined")
	{
		if($admtype == 'ACPDC-Certificate')
		{
			$condition .= " AND sm.student_admby = 'ACPDC' AND sm.student_techcerti != ''";
		}
		elseif($admtype == 'Transfered Students')
		{
			$condition .= " AND sm.student_lastcollege != ''";
		}
		else{
			$condition .= " AND sm.student_admby = '".$admtype."'";
		}
	}
	
	if($gturegno_start != "" && $gturegno_start != "Start From"){ 
		$condition .= " AND sm.student_gturegno >= '".$gturegno_start."' ";
	}
	if($gturegno_end != "" && $gturegno_start != "End To"){
		$condition .= " AND sm.student_gturegno <= '".$gturegno_end."' ";
	}
	
	$condition .= " ORDER BY sd.cur_branchid ";
	
	if($order_by != "" && $order_by != "undefined"){
		$condition .= ",".$order_by." ASC ";
	}
	else{
		$condition .= " ,sm.student_gturegno ASC ";
	}
	
	
	//echo $SQL_STUDENT;

	//$RES_STUDENT = dbQuery($SQL_STUDENT);
	$objStudentMgmt = new StudentMgmt();
		$RES_STUDENT = $objStudentMgmt->getstudentdetain($condition);
	if(dbRows($RES_STUDENT)>0){?>
        <center><h4>Detain Student List</h4></center>
      
		<div align="left">
				<b>Course</b> :
				<?php echo $branch_name; ?>
			</div>
			<div align="right">
				<b>Batch Year</b>:
				<?php echo $year_name; ?>
			</div>
			<div align="left">
				<?php if ($branchyear_id != "") { ?>
					<b>Course Name</b>:
					<?php echo $branchyear_name; ?>
				</div>
				<div align="left">
				<?php } if ($semester_id != "") { ?>
					<b>Semester</b>:
					<?php echo $semester_name;
				} ?>
			</div><br />
		<table class="table-report" border="1" cellpadding="0" cellspacing="0" width="100%">
        <tr>
        	<th style="text-align:center;" width="5%">Sr</th>
            <th style="text-align:center;" width="10%">Admission Date</th>
            <th style="text-align:center;" width="8%">Adm. By</th>
            <th style="text-align:center;" width="13%">Enrollment Reg No</th>
            <th style="text-align:left;"   width="20%">Student Name</th>
            <!--<th style="text-align:center;" width="4%">Gen</th>-->
            <th style="text-align:center;" width="17%" >Address</th>
            <th style="text-align:center;" width="10%" >Ph(Parents)</th>
            <th style="text-align:center;" width="10%">Ph(Student)</th>
            <th style="text-align:center;" width="5%">Fees Paid?</th>
            <th style="text-align:center;" width="10%">Remarks</th>
        </tr>
		<?php
		$i = 1;
		$temp = "";
		$temp1="";
		while($REC_STUDENT = dbArray($RES_STUDENT)){
			 if(($REC_STUDENT['branch_name'] != $temp && $branch_disp==':: All ::') || ($REC_STUDENT['semester_name'] != $temp1 && $semester_disp=='' ) ){
				$temp = $REC_STUDENT['branch_name'];
				$temp1 = $REC_STUDENT['semester_name'];
				$i = 1;?>
                <tr><th colspan="10"><?php echo strtoupper($temp)."  ".$REC_STUDENT['semester_name'].'-'.$REC_STUDENT['cur_divison']; ?></th></tr><?php
			}?>
            <tr>
				<td style="text-align:center;">&nbsp;<?php echo $i++; ?></td>
                <td style="text-align:center;">&nbsp;<?php echo date("d-m-Y",strtotime($REC_STUDENT['student_admdate'])); ?></td>
                <td style="text-align:center;">&nbsp;<?php 
				echo $REC_STUDENT['student_admby'];
					
				?></td>
                <td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_gturegno']; ?></td>
                <td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['studentname']; ?></td>
                <td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_address']; ?></td>
                <!--<td style="text-align:center;">&nbsp;<?php //echo $REC_STUDENT['student_gender']; ?></td>-->
                <td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_fathermobile']; ?></td>
                <td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_mobileother']; ?></td>
                <td style="text-align:center;">&nbsp;<?php 
				if($REC_STUDENT['tfw_scheme']!=1)
				{
					$student_id = $REC_STUDENT['student_id'];
					$semester_id = $REC_STUDENT['cur_semesterid'];
					$branch_id = $REC_STUDENT['cur_branchid'];
					
					$sql_fees = "SELECT * FROM cms_feesreceivemaster 
								 WHERE 
								 	student_id = '".$student_id."' AND 
									branch_id = '".$branch_id."' AND
									semester_id = '".$semester_id."' AND 
									year_id = '".$_SESSION["VedantnrYearId"]."' ";
									
					$res_fees = dbQuery($sql_fees);				
					
					if(dbRows($res_fees) > 0){
						echo "Y";
					} 
					else{
						echo "N";
					}
				}else
				{
					echo "<b>T</b>";
				}?>
               	</td>
                <td>&nbsp;</td>
       		</tr><?php
		}
		?>
		</table>
		<?php
	}
	else{
		echo "NO DATA FOUND!";	
	}
	
?>

<?php
	$HtmlCode = ob_get_contents();
	ob_end_flush();
	$header_row_string="";
	$HtmlUrl = "studentlist-report.html";
	$HtmlPath =	"report/".$HtmlUrl;
	createHTMLReportPage($header_row_string,$HtmlUrl,$HtmlPath,$HtmlCode,false);
?>
<br/>
<form name="frm" id="frm" action="" method="post">		
    <input type="hidden"   name="txtFile" id="txtFile" value="<?php echo $HtmlUrl ;?>" />
    <input type="button"  name="btnPrint" id="btnPrint" value="Print" onClick="SetPageAction('PRINT');"/>
    <input type="button"  name="btnPdf" id="btnPdf" value="Create PDF" onClick="SetPageAction('PDF');"/>
    <input type="button" name="btnHtml" id="btnHtml" value="Create HTML" onClick="SetPageAction('HTML');"/>
    <input type="button" name="btnWord" id="btnWord" value="Create WORD" onClick="SetPageAction('WORD');"/>
    <input type="button" name="btnExcel" id="btnExcel" value="Create EXCEL" onClick="SetPageAction('Excel');"/>
</form>
<script language="javascript" type="text/javascript">
function SetPageAction(varAction) {
	if(varAction=="PRINT"){			
		document.frm.action="print/create-print.php";
		document.frm.target = "_blank";
		document.frm.submit();
	}
	else if(varAction=="PDF"){			
		document.frm.action="convertpdf/create-pdf.php";
		document.frm.target = "_blank";
		document.frm.submit();
	}
	else if(varAction=="HTML"){
		document.frm.action="<?php echo $HtmlPath ;?>";
		document.frm.target = "_blank";
		document.frm.submit();
	}
	else if(varAction=="WORD"){
		document.frm.action="convertword/create-word.php";
		document.frm.target="_blank";
		document.frm.submit();
	}
	else if(varAction=="Excel"){
		document.frm.action="convertword/create-excel.php";
		document.frm.target="_blank";
		document.frm.submit();
	}
}
</script>
<?php } ?>
</div>
<?php 
	require "_footer.php";
?>
