<?php require "_header.php";?>
<script language="javascript" type="text/javascript">
document.getElementById("main-content").style.display = 'none';
</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;
		background-color:#eee; 
		font-weight:bold;
		text-align:left;
		border-top:0px none;
		border-left:0px none;
	}
						
	.college_name{
		font-family:QTAbbie;
		font-size:22px;	
		font-weight:bold;
		padding:2px 2px 2px 2px;
		text-align:center;
	}
	.college_address{
		font-family:Tahoma, Geneva, sans-serif;
		font-size:11px;	
		text-align:center;
		padding:2px 2px 2px 2px;
	}
</style>
<div id="main-report">
<?php
							
if($_REQUEST['student_gturegno'] == "" &&  $_REQUEST['branch_hidden'] == "" && $_REQUEST['semester_hidden'] == ""  && $_REQUEST['division_id'] == ""  && $_REQUEST['student_hidden'] == "")
{
	   
?>
	<script language="javascript" type="text/javascript">
		location.href='report-student-fees-records.php';
	</script>
<?php
}
elseif($_SESSION['VedantnrCollegeId']!="" && isset($_SESSION['VedantnrCollegeId'])) 
{ 
	ob_start();
	$show_detail= $_REQUEST['show_detail'];
	$branch_id= $_REQUEST['branch_hidden'];
	$semester_id= $_REQUEST['semester_hidden'];
	$stuid		= Escape($_REQUEST['student_hidden']);
//	echo $stuid; exit; 
/*

*/
?>
     <div class="college_name"><?php echo $_SESSION["VedantnrCollegeName"]; ?></div>
        <div class="college_address"><?php echo $_SESSION["VedantnrCollegeAddress"]; ?></div>
        <div class="college_address">
    Web Site: <?php echo $_SESSION["VedantnrCollegeUrl"] ;?> 
                        &nbsp;&nbsp; 
                        Email: <?php echo $_SESSION["VedantnrCollegeEmail"] ;?> 
                        &nbsp;&nbsp; 
                        Phone: <?php echo $_SESSION["VedantnrCollegePhone"] ;?> 
                    </div>							
        <center><h4>Student Fees Records</h4></center>
        <br />
    <?php
if($stuid != "undefined"){ 
	$SQL_CONDITION  = "";
		
	$SQL_STUDENT = "
		SELECT
			sm.student_id,
			sd.cur_semesterid,
			sd.cur_branchid,
			student_admdate,
			CONCAT(student_surname,' ',student_firstname,' ',SUBSTR(student_lastname,1,1),'.') AS student_name,
			student_address,
			student_emailid,
			student_birthdate,
			student_gturegno,
			SUBSTR(student_gender,1,1) AS student_gender,
			student_mobilestudents,
			student_mobileparents,
			semester_name,
			branch.branch_name,
			sm.student_admby,
			sm.tfw_scheme ,
			sd.batch_id,
			sm.leave_type,
			sd.cur_divison,
			frm.all_receive_amt,
			group_concat(frm.receipt_date) as receipt_date,
			group_concat(frm.receipt_no) as receipt_no,
			group_concat(frm.total_receive_amt) as total_receive_amt
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd,
			cms_semestermaster sem,
			cms_branchmaster branch,
			cms_feesreceivemaster frm
			
		WHERE  
			sm.student_id = sd.student_id AND
			frm.student_id=sm.student_id And
			frm.allsem='on' AND 
			
			sd.cur_semesterid = sem.semester_id AND
			sd.cur_branchid = branch.branch_id 	 ";
																
																
														
	if($branch_id != "" &&  $branch_id != "All"){
		$SQL_CONDITION .= " AND sd.cur_branchid = ".$branch_id;
	}
	if($semester_id != "" && $semester_id != "undefined"){
		$SQL_CONDITION .= " AND sd.cur_semesterid = ".$semester_id;
	}
	
		$SQL_CONDITION .= " AND sm.student_id = '".$stuid."' ";
	
	
	
	$SQL_CONDITION .= " AND sd.current_active = 1 ";
	$SQL_CONDITION .= " Group BY sm.student_id  ";

	if($order_by != "" && $order_by != "undefined"){
		$SQL_CONDITION .= ",frm.receipt_no ASC ";
	}
	else{
		$SQL_CONDITION .= " ,student_gturegno ASC ";
	}
	
	
	if($SQL_CONDITION != ""){
		 $SQL_STUDENT .= $SQL_CONDITION;
	}
	 //echo $SQL_STUDENT;
	}
	else
	{
	$SQL_CONDITION  = "";
		
	$SQL_STUDENT = "
		SELECT
			sm.student_id,
			sd.cur_semesterid,
			sd.cur_branchid,
			student_admdate,
			CONCAT(student_surname,' ',student_firstname,' ',SUBSTR(student_lastname,1,1),'.') AS student_name,
			student_address,
			student_emailid,
			student_birthdate,
			student_gturegno,
			SUBSTR(student_gender,1,1) AS student_gender,
			student_mobilestudents,
			student_mobileparents,
			semester_name,
			branch.branch_name,
			sm.student_admby,
			sm.tfw_scheme ,
			sd.batch_id,
			sm.leave_type,
			sd.cur_divison,
			frm.all_receive_amt,
			group_concat(frm.receipt_date) as receipt_date,
			group_concat(frm.receipt_no) as receipt_no,
			group_concat(frm.total_receive_amt) as total_receive_amt
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd,
			cms_semestermaster sem,
			cms_branchmaster branch,
			cms_feesreceivemaster frm
			
		WHERE  
			sm.student_id = sd.student_id AND
			frm.student_id=sm.student_id And
			frm.allsem='on' AND 
			
			sd.cur_semesterid = sem.semester_id AND
			sd.cur_branchid = branch.branch_id 	 ";
																
																
														
	if($branch_id != "" &&  $branch_id != "All"){
		$SQL_CONDITION .= " AND sd.cur_branchid = ".$branch_id;
	}
	if($semester_id != "" && $semester_id != "undefined"){
		$SQL_CONDITION .= " AND sd.cur_semesterid = ".$semester_id;
	}
	
	
	
	$SQL_CONDITION .= " AND sd.current_active = 1 ";
	$SQL_CONDITION .= " Group BY sm.student_id  ";

	if($order_by != "" && $order_by != "undefined"){
		$SQL_CONDITION .= ",frm.receipt_no ASC ";
	}
	else{
		$SQL_CONDITION .= " ,student_gturegno ASC ";
	}
	
	
	if($SQL_CONDITION != ""){
		 $SQL_STUDENT .= $SQL_CONDITION;
	}
	// echo $SQL_STUDENT;
	}	
	$RES_STUDENT = dbQuery($SQL_STUDENT);
	
	if(dbRows($RES_STUDENT)>0){?>
    	
  <?php
		
		while($REC_STUDENT = dbArray($RES_STUDENT))
		{
	?>	
        <h3>Student Profile Detail </h3>
        
        	<table class="table-report" border="1" cellpadding="0" cellspacing="0" width="90%">
		
         		<tr>
        	  	<th style="text-align:left;" width="20%"  >Student Name</th>
            	<td style="text-align:left;" width="40%"  ><?php echo $REC_STUDENT['student_name']; ?></td>
            	<th style="text-align:left;" width="15%"  >Enrollment No</th>
            	<td style="text-align:left;" width="25%"  ><?php echo $REC_STUDENT['student_gturegno']; ?></td>
        	</tr>
         
          <tr>
        		<th style="text-align:left;"    >Address</th>
            <td style="text-align:left;" colspan="3"   ><?php echo $REC_STUDENT['student_address']; ?></td>
          </tr>
          
      		<tr>
            <th style="text-align:left;"   >Phone(Parents)</th>
            <td style="text-align:left;"   ><?php echo $REC_STUDENT['student_mobileparents']; ?></td>
            <th style="text-align:left;"   >Phone(Student)</th>
            <td style="text-align:left;"   ><?php echo $REC_STUDENT['student_mobilestudents']; ?></td>
          </tr>
           <tr>
           <th style="text-align:left;"   >Email ID</th>
           <td style="text-align:left;"   ><?php echo $REC_STUDENT['student_emailid']; ?></td>
        	 <th style="text-align:left;"   >DOB</th>
           <td style="text-align:left;"   ><?php echo date('d-m-Y',strtotime($REC_STUDENT['student_birthdate'])); ?></td>
          </tr>
         
        </table>
        <br />
        <hr />
        <br />
        
        <?php  ?>
        <?php
																									
											if(dbRows($RES_STUDENT) > 0)
											{ ?>
       <h3>Student Fees Records</h3>
       																	
       <table width="90%">							
          <tr>
             <td style="text-align: left;border:none;  font-size: 11px;"><b>Branch:-</b><?php echo $REC_STUDENT['branch_name'];  ?></td>
             <td style="text-align: right;border:none; font-size: 11px;"><b>Sem:-</b><?php echo  $REC_STUDENT['semester_name'].'-'.$REC_STUDENT['cur_divison']; ?></td>
          </tr>
      </table>
         		<?php
						
											$totalfees=0;
											
	 										    $feesreceive_id=$REC_STUDENT['feesreceive_id'];
	 										    
	 										    $a= $REC_STUDENT['total_receive_amt'];
	 										    $liaison_one_chunks = explode(',' , $a);
	 										    
	 										    $b= $REC_STUDENT['receipt_no'];
	 										    $liaison_one_chunks1 = explode(',' , $b);
	 										    
	 										    $c= $REC_STUDENT['receipt_date'];
	 										  	
	 										  
	 										    $liaison_one_chunks2 = explode(',' , $c);
											//	  $totalfees += $REC_STUDENT['all_receive_amt'];
											?>
       <table class="table-report" border="1" cellpadding="0" cellspacing="0" width="90%">	
           <tr>
              <th style="padding:2px;text-align:center;font-weight:bold;width:15%">Receipt No.</th>
              <th style="padding:2px;text-align:center;font-weight:bold;width:15%">Date</th>
              
              <th style="padding:2px;text-align:center;font-weight:bold;width:20%">Amount</th>
          </tr>
                         
		      <tr>
					   <td style="padding:2px;text-align:center;">
									<?php
								 echo '<table border="01">';
    foreach($liaison_one_chunks1 as $row){
        echo '<tr >';
        $row = explode(',',$row);
    foreach($row as $cell){
            echo '<td width="320">';
            echo $cell;
            echo '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';		
    ?>			
					</td>	
						   <td style="padding:2px;text-align:center;">
									<?php
								 echo '<table border="01">';
    foreach($liaison_one_chunks2 as $row){
        echo '<tr >';
        $row = explode(',',$row);
    foreach($row as $cell){
            echo '<td width="320">';
            echo $cell;
            echo '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';		
    ?>			
					</td>	
              
                                             
              
			<td style="padding:2px;text-align:center;">
									<?php
								 echo '<table border="01">';
    foreach($liaison_one_chunks as $row){
        echo '<tr >';
        $row = explode(',',$row);
    foreach($row as $cell){
            echo '<td width="520">';
            echo $cell;
            echo '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';		
    ?>			
					</td>			</tr> 
					
					<tr>
						
						<td colspan="2"><center><b>Total</b></center></td>
						<td colspan="2"><center><b><?php echo array_sum($liaison_one_chunks); ?></b></center></td>	
						</tr>
					
					</table><br /><br />
             
                <br /><br />
                            <?php   ?>
                            <?php } ?>
                            <hr />
          <?php
		}
		
	}
	else{
		echo "NO DATA FOUND!";	
	}?>
	<?php
	 
?>

<?php
	$HtmlCode = ob_get_contents();
	ob_end_flush();
	$header_row_string="";
	$HtmlUrl = "student-overall-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 } ?>
<?php 
	require "_footer.php";
?>