<?php require "_header.php";?>
<script language="javascript" type="text/javascript">
document.getElementById("main-content").style.display = 'none';
</script>
<div id="main-report" align="center">
<style>
	.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;
	}	
	.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>
<?php 
	$header_row_string = "";
	$display_str = "";
	$startdate 		   = Escape($_REQUEST['feesrec_startdate']);
	$enddate 			 = Escape($_REQUEST['feesrec_enddate']);
	$startrecno 		  = Escape($_REQUEST['feesrec_startno']);
	$endrecno 			= Escape($_REQUEST['feesrec_endno']);
	$report_type 		 = Escape($_REQUEST['report_type']);
	$fees_type 		 = Escape($_REQUEST['fees_type']);
	$fees_type1 		 = substr(Escape($_REQUEST['fees_type']),0,1);
//echo $enddate; exit;
	$report_selection 	= Escape($_REQUEST['report_selection']);
	
	if(($startdate == "" && $enddate == "") && ($startrecno == "" && $endrecno == "")){ ?>
		<script language="javascript" type="text/javascript">
			location.href='report-daily-fees-collection.php';
		</script><?php
	}
	elseif($_SESSION['VedantnrCollegeId']!="" && isset($_SESSION['VedantnrCollegeId'])){ 
		ob_start();
		
		$final_cash = 0;
		$final_bank = 0;
		$date_cash = 0;
		$date_bank = 0;
		$str_date = "";		
		$condition = "";
		
		if($report_selection == "recno_selection"){
			$condition .= " AND frm.receipt_no >= '$startrecno' AND frm.receipt_no <= '$endrecno' ";
			$display_str = "Receipt No: $startrecno - $endrecno";
		} else if($report_selection == "date_selection"){
			$condition .= " AND frm.receipt_date >= '$startdate' AND frm.receipt_date <= '$enddate' ";
			
			if($_REQUEST['feesrec_startdate'] != '' && $_REQUEST['feesrec_enddate'] != ''){
				$display_str = "Receipt Date: ".$_REQUEST['feesrec_startdate']." - ".$_REQUEST['feesrec_enddate'];
			} else{
				$display_str = "Receipt Date: ".$_POST['feesrec_startdate'];
			}
		}
		
		if($report_type == "summarize_type"){
			$SQL_SELECT = "
				SELECT
					frm.receipt_no,
					bm.branch_name,
					sem.semester_name,
					sm.student_gturegno,
					CONCAT(sm.student_surname,' ',sm.student_firstname,' ',sm.student_lastname) AS student_name,
					frm.receive_amt,
					frm.total_receive_amt,
					frm.cheque_no,
					frm.discount,
					frm.receipt_date,
					um.user_name
				FROM
					cms_feesreceivemaster frm,
					cms_studentmaster sm,
					cms_branchmaster bm,
					cms_semestermaster sem,
					cms_usermaster um	 		
				WHERE
					um.user_id = frm.login_id AND
					frm.branch_id = bm.branch_id AND
					frm.semester_id = sem.semester_id AND 
					sm.student_id = frm.student_id AND
					frm.year_id = ".$_SESSION["VedantnrYearId"];
			$SQL_SELECT .= $condition;
			$SQL_SELECT .= " ORDER BY frm.receipt_no ASC ";
			$RES_SELECT = dbQuery($SQL_SELECT);	
			
	//		echo  $SQL_SELECT; exit;
			if(dbRows($RES_SELECT) > 0){?>
				<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>Fees - Summary Report</h4></center>
                <br /><br />
                <table width="100%">
                <tr>
                <td style="text-align: left;border:none;  font-size: 11px;"><?php echo $display_str; ?></td>
                <td style="text-align: right;border:none;  font-size: 11px;">C:cash, B:cheque</td>
                </tr>
                </table>
                
                <table width="100%" class="table-report" border="1" cellpadding="0" cellspacing="0"> 
				<tr>
                	<th style="text-align:center;">Receipt No</th>
					<th style="text-align:center;">Date</th>
                    <th style="text-align:center;">Branch</th>
        			<th style="text-align:center;">Semester</th>            
		            <th style="text-align:center;">GTU Reg No</th>
                    <th style="text-align:left;">Student Name</th>
                    <th style="text-align:right;">Amount</th>
                    <th style="text-align:left;">Received By</th>
                </tr><?php
				while($REC_SELECT = dbArray($RES_SELECT)){
					$receipt_date = date('d-m-Y',strtotime($REC_SELECT['receipt_date']));
					if($startdate != $enddate){
						if($str_date != $receipt_date){
							if($date_cash > 0 || $date_bank > 0){
								if($date_cash > 0 && $date_bank > 0){?>
								<tr>
									<th colspan="5" style="text-align:right;">Cash Received</th>
									<th style="text-align:right;"><?php echo $date_cash; ?></th>
                                    <th>&nbsp;</th>
								</tr>
								<tr>
									<th colspan="5" style="text-align:right;">Cheque Received</th>
									<th style="text-align:right;"><?php echo $date_bank; ?></th>
                                    <th>&nbsp;</th>
								</tr><?php 
								}?>
								<tr>
									<th colspan="5" style="text-align:right;">Total Received Amount</th>
									<th style="text-align:right;"><?php echo $date_cash+$date_bank; ?></th>
                                    <th>&nbsp;</th>
								</tr>
								<?php	
								$date_bank = 0;
								$date_cash = 0;
							}?>           
						<tr>
							<td colspan="7">&nbsp;</td>
						</tr> 
						<tr>
							<td colspan="7" style="text-align:left;">Receipt Date: <?php echo date('d-m-Y',strtotime($REC_SELECT['receipt_date'])); ?></td>
						</tr><?php 
							$str_date = $receipt_date;
						}
					}
					?>
                	<tr>
                    	<td style="text-align:center;"><?php echo $REC_SELECT['receipt_no']; ?></td>
						<td style="text-align:center;"><?php echo date('d-m-Y',strtotime($REC_SELECT['receipt_date'])); ?></td>
                        <td style="text-align:center;"><?php echo $REC_SELECT['branch_name']; ?></td>
                        <td style="text-align:center;"><?php echo $REC_SELECT['semester_name']; ?></td>
                        <td style="text-align:center;"><?php echo $REC_SELECT['student_gturegno']; ?></td>
                        <td style="text-align:left;"><?php echo $REC_SELECT['student_name']; ?></td>
              
           <?php  if($REC_SELECT['discount'] == 0)
           {
           	?> 
                        <td style="text-align:right;">
							
							<?php echo $REC_SELECT['receive_amt'];?>
							
                            <?php
							if($REC_SELECT['cheque_no'] == ""){
								echo "(C)";
								$final_cash += $REC_SELECT['receive_amt'];
								$date_cash += $REC_SELECT['receive_amt'];
							}
							else{
								echo "(B)";
								$final_bank += $REC_SELECT['receive_amt'];
								$date_bank += $REC_SELECT['receive_amt']; 
							}
							?>
              </td>
            <?php
          }
          else
          {  
           ?>
                       <td style="text-align:right;">
							
							<?php echo $REC_SELECT['total_receive_amt'];?>
							
                            <?php
							if($REC_SELECT['cheque_no'] == ""){
								echo "(C)";
								$final_cash += $REC_SELECT['total_receive_amt'];
								$date_cash += $REC_SELECT['total_receive_amt'];
							}
							else{
								echo "(B)";
								$final_bank += $REC_SELECT['total_receive_amt'];
								$date_bank += $REC_SELECT['total_receive_amt']; 
							}
							?>
              </td>
           
          <?php
        	}
        	?>
         
                        <td style="text-align:center;"><?php echo $REC_SELECT['user_name']; ?></td>
                    </tr><?php
				}?>
                <?php
					if($startdate != $enddate){
						if($date_cash > 0 || $date_bank > 0){
							if($date_cash > 0 && $date_bank > 0){?>
							<tr>
								<th colspan="5" style="text-align:right;">Cash Received</th>
								<th style="text-align:right;"><?php echo $date_cash; ?></th>
                                <th>&nbsp;</th>
							</tr>
							<tr>
								<th colspan="5" style="text-align:right;">Cheque Received</th>
								<th style="text-align:right;"><?php echo $date_bank; ?></th>
                                <th>&nbsp;</th>
							</tr><?php 
							}?>
							<tr>
								<th colspan="5" style="text-align:right;">Total Received Amount</th>
								<th style="text-align:right;"><?php echo $date_cash+$date_bank; ?></th>
                                <th>&nbsp;</th>
							</tr>
							<?php	
							$date_bank = 0;
							$date_cash = 0;
						}?>           
						<tr>
							<th colspan="7" style="text-align:center; color:#000; background-color:#CCC;">FINAL TOTAL</th>
						</tr><?php
					}
				?>
                <?php if($final_cash > 0 && $final_bank > 0){ ?>
                <tr>
                	<th colspan="5" style="text-align:right;">Total Cash Received</th>
                    <th style="text-align:right;"><?php echo number_format($final_cash)." Rs"; ?></th>
                    <th>&nbsp;</th>
                </tr>
                <tr>
                	<th colspan="5" style="text-align:right;">Total Cheque Received</th>
                    <th style="text-align:right;"><?php echo number_format($final_bank)." Rs"; ?></th>
                    <th>&nbsp;</th>
                </tr>
                <?php }?>
                <tr>
                	<th colspan="5" style="text-align:right;">Total Received Amount</th>
                    <th style="text-align:right;"><?php echo number_format($final_cash+$final_bank)." Rs"; ?></th>
                    <th>&nbsp;</th>
                </tr>
                <tr>
					<th colspan="7" style="text-align:center; color:#000; background-color:#CCC;">Received By</th>
				</tr>
                <tr>
                	<td colspan="7" align="center">
                    	<table width="40%" border="1" cellpadding="0" cellspacing="0" class="table-report">
                        	<tr>
                            	<th>Receiver</th>
                                <th style="text-align:right; padding-right:2px;">Cash</th>
                                <th style="text-align:right; padding-right:2px;">Cheque</th>
                                <th style="text-align:right; padding-right:2px;">Total</th>
                            </tr>
                            <?php
                            	$SQL_RECEIVER = "
									SELECT
										SUM(receive_amt + total_receive_amt - amount_discount) AS receive_amt,
										um.user_id,
										um.user_name
									FROM
										cms_feesreceivemaster frm,
										cms_usermaster um	 		
									WHERE
										um.user_id = frm.login_id AND
										frm.year_id = ".$_SESSION["VedantnrYearId"];
								$SQL_RECEIVER .= $condition;	
								$SQL_RECEIVER .= " GROUP BY frm.login_id ORDER BY frm.receipt_no ASC ";
								$RES_RECEIVER = dbQuery($SQL_RECEIVER);
								if(dbRows($RES_RECEIVER) > 0){
									while($REC_RECEIVER = dbArray($RES_RECEIVER)){	
							?>
                            <tr>
                            	<td><?php echo $REC_RECEIVER['user_name']; ?></td>
                                <td style="text-align:right; padding-right:2px;">
                                	<?php 
										$SQL_CASH = "
											SELECT
												SUM(receive_amt + total_receive_amt - amount_discount) AS receive_amt
											FROM
												cms_feesreceivemaster frm
											WHERE
												frm.cheque_no = '' AND	 
												frm.login_id = ".$REC_RECEIVER['user_id']." AND
												frm.year_id = ".$_SESSION["VedantnrYearId"];
										$SQL_CASH .= $condition;	
										$RES_CASH = dbQuery($SQL_CASH);
										$REC_CASH = dbArray($RES_CASH);
										echo number_format($REC_CASH['receive_amt']);
									?>
                                </td>
                                <td style="text-align:right; padding-right:2px;">
                                	<?php 
										$SQL_CASH = "
											SELECT
												SUM(receive_amt + total_receive_amt - amount_discount) AS receive_amt
											FROM
												cms_feesreceivemaster frm
											WHERE
												frm.cheque_no != '' AND	
												frm.year_id = ".$_SESSION["VedantnrYearId"]." AND  
												frm.login_id = ".$REC_RECEIVER['user_id'];
										$SQL_CASH .= $condition;	
										$RES_CASH = dbQuery($SQL_CASH);
										$REC_CASH = dbArray($RES_CASH);
										echo number_format($REC_CASH['receive_amt']);
									?>
                                </td>
                                <td style="text-align:right; padding-right:2px;"><?php echo number_format($REC_RECEIVER['receive_amt'])." Rs"; ?></td>
                            </tr>
                            <?php
									}
								}
							?>                            
                        </table>                    
                    </td>
                </tr>
          <!--      <tr>
                    <td colspan="7" >
                    <table class="table-report-footer" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                            <td align="left" style="border:solid 0px red; padding:0px;" width="70%">Created by <b><?php echo $_SESSION["VedantnrUserName"]; ?></b> </td>
                            <td align="right" style="border:solid 0px red; padding:0px;" width="30%">Developed By <b>Aum Imagineering Pvt.Ltd.</b></td>
                        </tr>
                    </table>
                    </td>        
					</tr>         -->                  
                    
                </table><?php	
			}				
		}
		else if($report_type == "descriptive_type"){
			$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE fees_type = '$fees_type' ORDER BY head_id ASC";
			$RES_HEADING = dbQuery($SQL_HEADING);
		
			if(dbRows($RES_HEADING) > 0){?>
				<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>Fees - Summary Report</h4></center>
            	<br /><br />
                <table width="100%">
                <tr>
                <td style="text-align: left;border:none;  font-size: 11px;"><?php echo $display_str; ?></td>
                <td style="text-align: right;border:none;  font-size: 11px;">C:cash, B:cheque</td>
                </tr>
                </table>
                
            	<table class="table-report" border="1" cellpadding="0" cellspacing="0"><tr>
					<th style="text-align:center;">Receipt No</th>
                 
				<?php
				while($REC_HEADING = dbArray($RES_HEADING)){
				
					?>
					<th style="text-align:center;"><?php echo $REC_HEADING['head_name'].'-'.$REC_HEADING['head_id']; ?></th>
					<?php
				} ?>
                	
                   
					  <th style="text-align:left;">Cash</th>
					  <th style="text-align:left;">Cheque</th>
					  <th style="text-align:center;">Total Amount</th>
					   <th style="text-align:left;">Received By</th>
                </tr><?php
			
				
				$SQL_SELECT = "SELECT
						frm.feesreceive_id,
							MAX(frm.receipt_no) as receipt,
						MIN(frm.receipt_no) as receipt1,
						bm.branch_name,
						sem.semester_name,
						sm.student_gturegno,
						CONCAT(sm.student_surname,' ',sm.student_firstname,' ',sm.student_lastname) AS student_name,
						frm.receive_amt,
						frm.total_receive_amt,
						frm.discount,
						frm.cheque_no,
						frm.receipt_date,
						um.user_name
					FROM
						cms_feesreceivemaster frm,
						cms_studentmaster sm,
						cms_branchmaster bm,
						cms_semestermaster sem,
						cms_usermaster um			
					WHERE 
						um.user_id = frm.login_id AND
						frm.branch_id = bm.branch_id AND
						frm.semester_id = sem.semester_id AND
						frm.fees_type = '$fees_type1' AND
						sm.student_id = frm.student_id AND
						frm.year_id = ".$_SESSION["VedantnrYearId"];
				
				$SQL_SELECT .= $condition;	
				$SQL_SELECT .= " GROUP BY frm.receipt_date ASC ";
				$RES_SELECT = dbQuery($SQL_SELECT);	

				if(dbRows($RES_SELECT) > 0){				
					while($REC_SELECT = dbArray($RES_SELECT)){
						$RES_HEADING1 = dbQuery($SQL_HEADING);
						$RES_HEADING2 = dbQuery($SQL_HEADING);
						$RES_HEADING3 = dbQuery($SQL_HEADING);
						$RES_HEADING4 = dbQuery($SQL_HEADING);
						$receipt_date = date('d-m-Y',strtotime($REC_SELECT['receipt_date']));
						if($startdate != $enddate){
							if($str_date != $receipt_date){
								if($date_cash > 0 || $date_bank > 0){
									if($date_cash > 0 && $date_bank > 0){?>
									<tr>
										<th colspan="14" style="text-align:right;">Cash Received</th>
										<th style="text-align:right;"><?php echo number_format($date_cash); ?></th>
                                        <th>&nbsp;</th>
									</tr>
									<tr>
										<th colspan="14" style="text-align:right;">Cheque Received</th>
										<th style="text-align:right;"><?php echo number_format($date_bank); ?></th>
                                        <th>&nbsp;</th>
									</tr><?php 
									}?>
									<tr>
										<th colspan="12" style="text-align:right;">Total Received Amount</th>
										<th style="text-align:right;"><?php echo number_format($date_cash+$date_bank); ?></th>
                                        <th>&nbsp;</th>
									</tr>
									<?php	
									$date_bank = 0;
									$date_cash = 0;
								}?>           
							<tr>
								<td colspan="17">&nbsp;</td>
							</tr> 
							<tr>
								<td colspan="17" style="text-align:left;">Receipt Date: 
								<?php echo date('d-m-Y',strtotime($REC_SELECT['receipt_date'])); ?></td>
							</tr><?php 
								$str_date = $receipt_date;
							}
						}
						?>
                        <tr>
                            <td style="text-align:center;"><?php echo $REC_SELECT['receipt1']. ' - ' .$REC_SELECT['receipt']; ?></td>
							<?php
							while($REC_HEADING1 = dbArray($RES_HEADING1)){	
						//	echo "1";
							$head = $REC_HEADING1['head_id'];
								$SQL_RECEIVER1 = "SELECT
										SUM(recdetail_amt) AS receive_amt,
										frd.head_id as head
										
									FROM
										cms_feesreceivemaster frm,
										cms_feesreceivedetail frd	 		
									WHERE
										frd.feesreceive_id = frm.feesreceive_id AND
										 frm.receipt_date = '".$REC_SELECT["receipt_date"]."' AND	 
										frd.head_id = '$head' AND
										frm.year_id = ".$_SESSION["VedantnrYearId"];
										
									
								$SQL_RECEIVER1 .= $condition;	
									
								
							//	echo $SQL_RECEIVER1;
								$RES_RECEIVER1 = dbQuery($SQL_RECEIVER1);
								$REC_RECEIVER1 = dbArray($RES_RECEIVER1);
							?>	
							<td><?php echo $REC_RECEIVER1['receive_amt']; ?></td>	
						<?php			
						}
							
						

						
						while($REC_HEADING3 = dbArray($RES_HEADING3)){	
							//echo "1";
							$head = $REC_HEADING3['head_id'];
								$SQL_RECEIVER3 = "SELECT
										SUM(recdetail_amt) AS receive_amt,
										frd.head_id as head
										
									FROM
										cms_feesreceivemaster frm,
										cms_feesreceivedetail frd	 		
									WHERE
										frd.feesreceive_id = frm.feesreceive_id AND
										frm.cheque_no = '' AND
										 frm.receipt_date = '".$REC_SELECT["receipt_date"]."' AND	 
										frm.fees_type = '$fees_type1' AND
										frm.year_id = ".$_SESSION["VedantnrYearId"];
										
									
								$SQL_RECEIVER3 .= $condition;	
									
								
							//	echo $SQL_RECEIVER2;
								$RES_RECEIVER3 = dbQuery($SQL_RECEIVER3);
								$REC_RECEIVER3 = dbArray($RES_RECEIVER3);
							?>	
							<td><?php echo $REC_RECEIVER3['receive_amt']; ?></td>	
						<?php			
						break;
						}
						
						
						while($REC_HEADING4 = dbArray($RES_HEADING4)){	
							//echo "1";
							$head = $REC_HEADING4['head_id'];
								$SQL_RECEIVER4 = "SELECT
										SUM(recdetail_amt) AS receive_amt,
										frd.head_id as head
										
									FROM
										cms_feesreceivemaster frm,
										cms_feesreceivedetail frd	 		
									WHERE
										frd.feesreceive_id = frm.feesreceive_id AND
										frm.cheque_no != '' AND
										 frm.receipt_date = '".$REC_SELECT["receipt_date"]."' AND	 
										frm.fees_type = '$fees_type1' AND
										frm.year_id = ".$_SESSION["VedantnrYearId"];
										
									
								$SQL_RECEIVER4 .= $condition;	
									
								
							//	echo $SQL_RECEIVER2;
								$RES_RECEIVER4 = dbQuery($SQL_RECEIVER4);
								$REC_RECEIVER4 = dbArray($RES_RECEIVER4);
							?>	
							<td><?php echo $REC_RECEIVER4['receive_amt']; ?></td>	
						<?php			
						break;
						}
						while($REC_HEADING2 = dbArray($RES_HEADING2)){	
							//echo "1";
							$head = $REC_HEADING2['head_id'];
								$SQL_RECEIVER2 = "SELECT
										SUM(recdetail_amt) AS receive_amt,
										frd.head_id as head
										
									FROM
										cms_feesreceivemaster frm,
										cms_feesreceivedetail frd	 		
									WHERE
										frd.feesreceive_id = frm.feesreceive_id AND
										 frm.receipt_date = '".$REC_SELECT["receipt_date"]."' AND	 
										frm.fees_type = '$fees_type1' AND
										frm.year_id = ".$_SESSION["VedantnrYearId"];
										
									
								$SQL_RECEIVER1 .= $condition;	
									
								
							//	echo $SQL_RECEIVER2;
								$RES_RECEIVER2 = dbQuery($SQL_RECEIVER2);
								$REC_RECEIVER2 = dbArray($RES_RECEIVER2);
							?>	
							<td><?php echo $REC_RECEIVER2['receive_amt']; ?></td>	
						<?php			
						break;
						}
						?>
                            <td style="text-align:center;"><?php echo $REC_SELECT['user_name']; ?></td>
							 
                        </tr>
						
						<?php
                    }
					
				}
						?>
				

               
                <tr>
					<th colspan="17" style="text-align:center; color:#000; background-color:#CCC;">Received By</th>
				</tr>
                <tr>
                	<td colspan="17" align="center">
                    	<table width="40%" border="1" cellpadding="0" cellspacing="0" class="table-report">
                        	<tr>
                            	<th>Receiver</th>
                                <th style="text-align:right; padding-right:2px;">Cash</th>
                                <th style="text-align:right; padding-right:2px;">Cheque</th>
                                <th style="text-align:right; padding-right:2px;">Total</th>
                            </tr>
                            <?php
                            	$SQL_RECEIVER = "SELECT
										SUM(receive_amt + total_receive_amt - amount_discount) AS receive_amt,
										um.user_id,
										um.user_name
									FROM
										cms_feesreceivemaster frm,
										cms_usermaster um	 		
									WHERE
										um.user_id = frm.login_id AND
										frm.fees_type = '$fees_type1' AND
										frm.year_id = ".$_SESSION["VedantnrYearId"];
								$SQL_RECEIVER .= $condition;	
								$SQL_RECEIVER .= " GROUP BY frm.login_id ORDER BY frm.receipt_no ASC ";
								$RES_RECEIVER = dbQuery($SQL_RECEIVER);
								if(dbRows($RES_RECEIVER) > 0){
									while($REC_RECEIVER = dbArray($RES_RECEIVER)){	
							?>
                            <tr>
                            	<td><?php echo $REC_RECEIVER['user_name']; ?></td>
                                <td style="text-align:right; padding-right:2px;">
                                	<?php 
										$SQL_CASH = "
											SELECT
												SUM(receive_amt + total_receive_amt - amount_discount) AS receive_amt
											FROM
												cms_feesreceivemaster frm
											WHERE
												frm.cheque_no = '' AND	 
												frm.fees_type = '$fees_type1' AND
												frm.login_id = ".$REC_RECEIVER['user_id']." AND 
												frm.year_id = ".$_SESSION["VedantnrYearId"];
										$SQL_CASH .= $condition;	
										$RES_CASH = dbQuery($SQL_CASH);
										$REC_CASH = dbArray($RES_CASH);
										echo number_format($REC_CASH['receive_amt']);
									?>
                                </td>
                                <td style="text-align:right; padding-right:2px;">
                                	<?php 
										$SQL_CASH = "
											SELECT
												SUM(receive_amt + total_receive_amt - amount_discount) AS receive_amt
											FROM
												cms_feesreceivemaster frm
											WHERE
												frm.cheque_no != '' AND
												frm.fees_type = '$fees_type1' AND												
												frm.year_id = ".$_SESSION["VedantnrYearId"]." AND
												frm.login_id = ".$REC_RECEIVER['user_id'];
										$SQL_CASH .= $condition;	
										$RES_CASH = dbQuery($SQL_CASH);
										$REC_CASH = dbArray($RES_CASH);
										echo number_format($REC_CASH['receive_amt']);
									?>
                                </td>
                                <td style="text-align:right; padding-right:2px;"><?php echo number_format($REC_RECEIVER['receive_amt'])." Rs"; ?></td>
                            </tr>
                            <?php
									}
								}
							?>                            
                        </table>                    
                    </td>
                </tr>
                <tr>
                    <td colspan="17" >
                    <table class="table-report-footer" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                            <td align="left" style="border:solid 0px red; padding:0px;" width="75%">Created by <b><?php echo $_SESSION["VedantnrUserName"]; ?></b> </td>
                            <td align="right" style="border:solid 0px red; padding:0px;" width="25%">Developed By <b>Aum Imagineering Pvt.Ltd.</b></td>
                        </tr>
                    </table>
                    </td>        
					</tr>                           
                    
                </table>
                <?php
			}
		}
		
		$HtmlCode= ob_get_contents();
		ob_end_flush();
		$HtmlUrl  =	"daily-fees-collection-report.html";
		$HtmlPath =	"report/".$HtmlUrl;
		createHTMLReportPage($header_row_string,$HtmlUrl,$HtmlPath,$HtmlCode); 
	?>
		<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
	}  
   	else{
      	echo "Session Expired";      
   	} 
?>
</div>
<?php require "_footer.php";
?>
