<?php require "_header.php";
 ?>
<script language="javascript" type="text/javascript">
	document.getElementById("main-content").style.display = 'none';
</script>

<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']);

//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: " . $_REQUEST['feesrec_startdate'];
		}
	}
	if ($report_type == "summarize_type") {
		$SQL_SELECT = "SELECT
					frm.receipt_no,
					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.branch_id,
					frm.year_id,
					frm.branchyear_id,
					frm.semester_id,
					frm.student_id,
					frm.receipt_date,
					(SELECT branch_name 
								FROM cms_branchmaster bm 
								WHERE bm.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and frm.branch_id =bm.branch_id) AS branch_name,
						(SELECT year_name 
								FROM cms_yearmaster ym  WHERE  frm.year_id  =ym.year_id) AS year_name,
						(SELECT branchyear_name
								FROM cms_branchyear bry 
								WHERE  bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND frm.branchyear_id = bry.branchyear_id) AS branchyear_name,
						(SELECT semester_name
								FROM cms_semestermaster sem 
								WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND frm.semester_id = sem.semester_id) AS semester_name	  							
				FROM
					cms_feesreceivemaster frm,
					cms_studentmaster sm	
				WHERE
					sm.student_id = frm.student_id ";
		$SQL_SELECT .= $condition;
		$SQL_SELECT .= " ORDER BY frm.receipt_no ASC ";

		//echo  $SQL_SELECT; exit;
		$RES_SELECT = dbQuery($SQL_SELECT);


		if (dbRows($RES_SELECT) > 0) { ?>
			<center>
				<h4>Daily Fees Collection - Summary Report</h4>
			</center>
			<table style="width: 70%; margin: 0 auto; border-collapse: collapse; border: 1px solid;" class="table-bordered">
				<tr style="vertical-align: middle;">
					<td colspan="4" style="border: 1px solid; padding: 5px; text-align: center;">
						<img src="<?php echo $CollegeImagePath . $_SESSION["VedantnrCollegeLogo"]; ?>" alt="College Logo"
							style="width: 80px; height: auto; float: left; margin-right: 10px;">
						<div style="display: inline-block; vertical-align: middle;">
							<b style="font-size: 35px;"><?php echo $_SESSION["VedantnrCollegeName"]; ?></b><br>
							<?php echo $_SESSION["VedantnrCollegeAddress"]; ?><br>
							Phone: <?php echo $_SESSION["VedantnrCollegePhone"]; ?><br>
							Email: <?php echo $_SESSION["VedantnrCollegeEmail"]; ?>
						</div>
					</td>
				</tr>
				<tr>
					<td style="text-align: left;border:none;  "><?php echo $display_str; ?></td>
					<td style="text-align: right;border:none; ">C:cash, B:cheque</td>
				</tr>
				<tr>
					<td colspan="4">
						<table border="1"
							style="width: 100%; border-collapse: collapse; border-right: hidden; border-left:hidden; ">
							<tr>
								<th style="text-align:center;"><b>Receipt No</b></th>
								<th style="text-align:center;"><b>Date</b></th>
								<th style="text-align:center;"><b>Course</b></th>
								<th style="text-align:center;"><b>Batch Year</b></th>
								<th style="text-align:center;"><b>Course Year</b></th>
								<th style="text-align:center;"><b>Semester</b></th>
								<th style="text-align:center;"><b>GU Reg No</b></th>
								<th style="text-align:left;"><b>Student Name</b></th>
								<th style="text-align:right;"><b>Amount</b></th>
								<th style="text-align:left;"><b>Received By</b></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="7" style="text-align:right;">Cash Received</th>
													<th style="text-align:right;"><?php echo $date_cash; ?></th>
													<th>&nbsp;</th>
													<th>&nbsp;</th>
												</tr>
												<tr>
													<th colspan="7" style="text-align:right;">Cheque Received</th>
													<th style="text-align:right;"><?php echo $date_bank; ?></th>
													<th>&nbsp;</th>
													<th>&nbsp;</th>
												</tr><?php
											} ?>
											<tr>
												<th colspan="7" style="text-align:right;">Total Received Amount</th>
												<th style="text-align:right;"><?php echo $date_cash + $date_bank; ?></th>
												<th>&nbsp;</th>
												<th>&nbsp;</th>
											</tr>
											<?php
											$date_bank = 0;
											$date_cash = 0;
										} ?>
										<tr style="page-break-after: always;">
											<td colspan="10"></td>
										</tr>
										<tr>
											<td colspan="10" 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['year_name']; ?></td>
									<td style="text-align:center;"><?php echo $REC_SELECT['branchyear_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>



									<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="7" style="text-align:right;">Cash Received</th>
											<th style="text-align:right;"><?php echo $date_cash; ?></th>
											<th>&nbsp;</th>
										</tr>
										<tr>
											<th colspan="7" 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="7" 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="7" 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="7" 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="7" 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="9" style="text-align:center; color:#000; background-color:#CCC;">Received By</th>
							</tr>
							<tr>
								<td colspan="9" 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>


						</table>
						<?php
		}
	} else if ($report_type == "descriptive_type") {
		$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name != 'College Dev. Fee' and head_name != 'Scope Fee' and college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";
		$RES_HEADING = dbQuery($SQL_HEADING);

		$count = dbRows($RES_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>Daily Fees Collection - Descriptive Report</h4>
							</center>
							<?php
							$SQL_SELECT = "SELECT
						DISTINCT(receipt_date) as receipt_date
					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.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' AND
						frm.year_id = " . $_SESSION["VedantnrYearId"];

							$SQL_SELECT .= $condition;
							$SQL_SELECT .= " ORDER BY frm.receipt_date,bm.branch_name,sem.semester_name,frm.receipt_no ASC ";
							$RES_SELECT = dbQuery($SQL_SELECT);
							$counter = 1;
							if (dbRows($RES_SELECT) > 0) {
								while ($REC_SELECT = dbArray($RES_SELECT)) {
									$SQL_HEADING1 = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name != 'College Dev. Fee' and head_name != 'Scope Fee' and college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";
									$RES_HEADING1 = dbQuery($SQL_HEADING1);

									$count1 = dbRows($RES_HEADING1);
									?>
									<table class="table-report" border="1" cellpadding="0" cellspacing="0" width="100%"
										style="page-break-after:always;">
										<tr>
											<td style="text-align:center;" width="1%">Roll No</td>
											<td style="text-align:center;" width="1%">Receipt No</td>

											<td style="text-align:left;" width="10%">Student Name<font color="white">
													............................................</font>
											</td>
											<?php
											while ($REC_HEADING1 = dbArray($RES_HEADING1)) { ?>
												<td style="text-align:center;" width="1%"><?php echo $REC_HEADING1['head_name']; ?></td>
											<?php
											} ?>
											<td style="text-align:center;" width="1%">Total Amount</td>
											<td style="text-align:center;" width="1%">College Dev. Fee</td>
											<td style="text-align:center;" width="1%">Scope Fee</td>
											<td style="text-align:left;" width="1%">Received By</td>
										</tr>
										<tr>
											<td colspan="<?php echo $count + 7 ?>" style="text-align:left;">Receipt Date:
											<?php echo date('d-m-Y', strtotime($REC_SELECT['receipt_date'])); ?>
											</td>
										</tr>
										<?php
										$SQL_Branch = "SELECT
							DISTINCT bm.branch_name,
							sem.semester_name,bm.branch_id,sem.semester_id
						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.receipt_date = '" . $REC_SELECT["receipt_date"] . "' AND
							frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' AND
							frm.year_id = " . $_SESSION["VedantnrYearId"];
										$SQL_Branch .= " ORDER BY bm.branch_name,sem.semester_name";
										$RES_Branch = dbQuery($SQL_Branch);

										while ($REC_Branch = dbArray($RES_Branch)) {
											?>
											<tr>
												<td colspan="<?php echo $count + 7 ?>" style="text-align:left;">Branch -
												<?php echo $REC_Branch['branch_name']; ?> Semester - <?php echo $REC_Branch['semester_name']; ?>
												</td>
											</tr>
											<?php
											$SQL_Fees = "SELECT
							frm.feesreceive_id,
							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.discount,
							frm.student_id,
							frm.branch_id,
							frm.semester_id,
							frm.cheque_no,
							frm.receipt_date,
							um.user_name,
							sem.rollno_print
						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.branch_id = '" . $REC_Branch["branch_id"] . "' AND
							frm.receipt_date = '" . $REC_SELECT["receipt_date"] . "' AND
							frm.semester_id = '" . $REC_Branch["semester_id"] . "' AND
							frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' AND
							frm.year_id = " . $_SESSION["VedantnrYearId"];
											$SQL_Fees .= " ORDER BY frm.receipt_no ASC ";
											$RES_Fees = dbQuery($SQL_Fees);
											$RES_Total = dbRows($RES_Fees);
											while ($REC_Fees = dbArray($RES_Fees)) {
												?>
												<tr>
												<?php $rollno = "select student_rollno from cms_studentdetail where student_id ='" . $REC_Fees['student_id'] . "' 
							AND cur_semesterid = '" . $REC_Fees['semester_id'] . "'AND cur_branchid= '" . $REC_Fees['branch_id'] . "'";

												$rqry = dbQuery($rollno);
												$rollqry = dbArray($rqry);
												?>
													<td style="text-align:center;">
														<?php
														if ($REC_Fees['rollno_print'] == 'Yes') {
															echo $REC_Fees['student_rollno'];
														} else {
															echo '';
														}
														?>
													</td>
													<td style="text-align:center;"><?php echo $REC_Fees['receipt_no']; ?></td>
													<td style="text-align:left;"><?php echo $REC_Fees['student_name']; ?>
														<?php
														$feesreceive_id = $REC_Fees['feesreceive_id'];
														$SQL_DATAIL = "SELECT 
										cms_feeshead.head_id,
										recdetail_amt,
										cms_feeshead.college_id										
									FROM 
										cms_feeshead LEFT JOIN cms_feesreceivedetail
										ON cms_feeshead.head_id = cms_feesreceivedetail.head_id AND 
										feesreceive_id = $feesreceive_id  AND
										cms_feesreceivedetail.head_id != '39' AND
										cms_feesreceivedetail.head_id != '40' AND
										cms_feesreceivedetail.head_id != '86' AND
										cms_feesreceivedetail.head_id != '72' AND
										cms_feeshead.college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  AND
										cms_feesreceivedetail.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' 
									ORDER BY cms_feeshead.head_id ASC";

														$RES_DETAIL = dbQuery($SQL_DATAIL);
														$totalamount = 0;

														if (dbRows($RES_DETAIL) > 0) {
															while ($REC_DETAIL = dbArray($RES_DETAIL)) {
																if ($REC_DETAIL['college_id'] == $_SESSION["VedantnrCollegeId"]) {
																	if ($REC_DETAIL['head_id'] != '39' && $REC_DETAIL['head_id'] != '40' && $REC_DETAIL['head_id'] != '72' && $REC_DETAIL['head_id'] != '86') {
																		?>
																	<td style="text-align:right; padding-right:2px;">
																		<?php
																		if ($REC_DETAIL['recdetail_amt'] != "" && $REC_DETAIL['recdetail_amt'] != "0") {
																			if ($REC_DETAIL['discount'] == 0) {
																				echo $REC_DETAIL['recdetail_amt'];
																			}
																		} else {
																			echo '-';
																		}
																		?>
																	</td><?php
																	}
																}

																$totalamount += $REC_DETAIL['recdetail_amt'];
															}
															?>
														<td style="text-align:center;"><?php echo $totalamount ?></td>
													<?php
														}
														$feesreceive_id = $REC_Fees['feesreceive_id'];
														$SQL_DATAILdev = "SELECT 
										recdetail_amt,college_id									
									FROM 
										cms_feesreceivedetail
										where 
										feesreceive_id = $feesreceive_id  AND
										(head_id = '39' || head_id = '72')  AND
										college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ";

														$RES_DETAILdev = dbQuery($SQL_DATAILdev);
														$REC_DETAILdev = dbArray($RES_DETAILdev);
														?>
													<td style="text-align:right; padding-right:2px;">
														<?php
														if ($REC_DETAILdev['recdetail_amt'] != "" && $REC_DETAILdev['recdetail_amt'] != "0") {
															echo $REC_DETAILdev['recdetail_amt'];
														} else {
															echo '-';
														}
														?>
													</td>

													<?php
													$feesreceive_id = $REC_Fees['feesreceive_id'];
													$SQL_DATAILscop = "SELECT 
										recdetail_amt,college_id									
									FROM 
										cms_feesreceivedetail
										where 
										feesreceive_id = $feesreceive_id  AND
										(head_id = '40' || head_id = '86') AND
										college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ";
													$RES_DETAILscop = dbQuery($SQL_DATAILscop);
													$REC_DETAILscop = dbArray($RES_DETAILscop)
														?>
													<td style="text-align:right; padding-right:2px;">
														<?php
														if ($REC_DETAILscop['recdetail_amt'] != "" && $REC_DETAILscop['recdetail_amt'] != "0") {

															echo $REC_DETAILscop['recdetail_amt'];

														} else {
															echo '-';
														}
														?>
													</td>
													<td style="text-align:center;"><?php echo $REC_Fees['user_name']; ?></td>
												</tr>
											<?php
											}
											?>
											<tr>
												<td colspan="3" style="text-align:center;">Total - <?php echo $RES_Total ?></td>
												<?php
												$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name != 'College Dev. Fee'  and head_name != 'Scope Fee'and college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";
												$RES_HEADING = dbQuery($SQL_HEADING);
												$datetotal = 0;
												while ($REC_HEADING = dbArray($RES_HEADING)) {
													$SQL_DATAIL = "SELECT 
										SUM(recdetail_amt) as Total																			
										FROM 
										cms_feesreceivemaster as frm,
										cms_feesreceivedetail as frd
										Where
										frm.feesreceive_id = frd.feesreceive_id AND
										frm.branch_id = '" . $REC_Branch["branch_id"] . "' AND
										frm.receipt_date = '" . $REC_SELECT["receipt_date"] . "' AND
										frm.semester_id = '" . $REC_Branch["semester_id"] . "' AND
										frd.head_id ='" . $REC_HEADING["head_id"] . "'  AND
										frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  AND
										frd.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' ";

													$RES_DETAIL = dbQuery($SQL_DATAIL);
													$REC_DETAIL = dbArray($RES_DETAIL); ?>
													<td style="text-align:right; padding-right:2px;">
														<?php
														if ($REC_DETAIL['Total'] != "" && $REC_DETAIL['Total'] != "0") {
															echo $REC_DETAIL['Total'];
														} else {
															echo '-';
														}
														?>
													</td>
													<?php
													$datetotal += $REC_DETAIL['Total'];
												}
												?>
												<td style="text-align:center;"><?php echo $datetotal ?></td>
												<?php
												$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name = 'College Dev. Fee' AND college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";
												$RES_HEADING = dbQuery($SQL_HEADING);
												$totalamountdev = 0;
												while ($REC_HEADING = dbArray($RES_HEADING)) {
													$SQL_DATAIL = "SELECT 
										SUM(recdetail_amt) as Total																			
										FROM 
										cms_feesreceivemaster as frm,
										cms_feesreceivedetail as frd
										Where
										frm.feesreceive_id = frd.feesreceive_id AND
										frm.branch_id = '" . $REC_Branch["branch_id"] . "' AND
										frm.receipt_date = '" . $REC_SELECT["receipt_date"] . "' AND
										frm.semester_id = '" . $REC_Branch["semester_id"] . "' AND
										frd.head_id ='" . $REC_HEADING["head_id"] . "'  AND
										frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  AND
										frd.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' ";

													$RES_DETAIL = dbQuery($SQL_DATAIL);
													$REC_DETAIL = dbArray($RES_DETAIL);
													?>
													<td style="text-align:right; padding-right:2px;">
														<?php
														if ($REC_DETAIL['Total'] != "" && $REC_DETAIL['Total'] != "0") {
															echo $REC_DETAIL['Total'];
														} else {
															echo '-';
														}
														?>
													</td>
													<?php
													$totalamountdev += $REC_DETAIL['Total'];
												}
												?>
												<?php
												$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name = 'Scope Fee' AND college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";
												$RES_HEADING = dbQuery($SQL_HEADING);
												$totalamountdev = 0;
												while ($REC_HEADING = dbArray($RES_HEADING)) {
													$SQL_DATAIL = "SELECT 
										SUM(recdetail_amt) as Total																			
										FROM 
										cms_feesreceivemaster as frm,
										cms_feesreceivedetail as frd
										Where
										frm.feesreceive_id = frd.feesreceive_id AND
										frm.branch_id = '" . $REC_Branch["branch_id"] . "' AND
										frm.receipt_date = '" . $REC_SELECT["receipt_date"] . "' AND
										frm.semester_id = '" . $REC_Branch["semester_id"] . "' AND
										frd.head_id ='" . $REC_HEADING["head_id"] . "'  AND
										frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  AND
										frd.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' ";
													$RES_DETAIL = dbQuery($SQL_DATAIL);
													$REC_DETAIL = dbArray($RES_DETAIL);
													?>
													<td style="text-align:right; padding-right:2px;">
														<?php
														if ($REC_DETAIL['Total'] != "" && $REC_DETAIL['Total'] != "0") {
															echo $REC_DETAIL['Total'];
														} else {
															echo '-';
														}
														?>
													</td>
													<?php
													$totalamountdev += $REC_DETAIL['Total'];
												}
												?>
												<td style="text-align:center;">&nbsp;</td>
											</tr>
										<?php
										}
										?>
										<tr>
											<td colspan="3" style="text-align:center;">Grand Total</td>
											<?php
											$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name != 'College Dev. Fee'  and head_name != 'Scope Fee'and college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";

											$RES_HEADING = dbQuery($SQL_HEADING);
											$alldatetotal = 0;
											while ($REC_HEADING = dbArray($RES_HEADING)) {
												$SQL_DATAIL = "SELECT 
										SUM(recdetail_amt) as Total																			
										FROM 
										cms_feesreceivemaster as frm,
										cms_feesreceivedetail as frd
										Where
										frm.feesreceive_id = frd.feesreceive_id AND
										frm.receipt_date = '" . $REC_SELECT["receipt_date"] . "' AND
										frd.head_id ='" . $REC_HEADING["head_id"] . "'  AND
										frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  AND
										frm.year_id ='" . $_SESSION["VedantnrYearId"] . "'  AND
										frd.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' ";

												$RES_DETAIL = dbQuery($SQL_DATAIL);
												$REC_DETAIL = dbArray($RES_DETAIL);
												?>
												<td style="text-align:right; padding-right:2px;">
													<?php
													if ($REC_DETAIL['Total'] != "" && $REC_DETAIL['Total'] != "0") {
														echo $REC_DETAIL['Total'];
													} else {
														echo '-';
													}
													?>
												</td>
												<?php
												$alldatetotal += $REC_DETAIL['Total'];
											}
											?>
											<td style="text-align:center;"><?php echo $alldatetotal ?></td>
											<?php
											$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name = 'College Dev. Fee' and college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";

											$RES_HEADING = dbQuery($SQL_HEADING);
											$alldevdatetotal = 0;
											while ($REC_HEADING = dbArray($RES_HEADING)) {
												$SQL_DATAIL = "SELECT 
										SUM(recdetail_amt) as Total																			
										FROM 
										cms_feesreceivemaster as frm,
										cms_feesreceivedetail as frd
										Where
										frm.feesreceive_id = frd.feesreceive_id AND
										frm.receipt_date = '" . $REC_SELECT["receipt_date"] . "' AND
										frd.head_id ='" . $REC_HEADING["head_id"] . "'  AND
										frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  AND
										frd.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' ";
												$RES_DETAIL = dbQuery($SQL_DATAIL);
												$REC_DETAIL = dbArray($RES_DETAIL);
												?>
												<td style="text-align:right; padding-right:2px;">
													<?php
													if ($REC_DETAIL['Total'] != "" && $REC_DETAIL['Total'] != "0") {
														echo $REC_DETAIL['Total'];
													} else {
														echo '-';
													}
													?>
												</td>
												<?php
												$alldevdatetotal += $REC_DETAIL['Total'];
											}
											?>
											<?php
											$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name = 'Scope Fee' and college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";
											$RES_HEADING = dbQuery($SQL_HEADING);
											$allscopdatetotal = 0;
											while ($REC_HEADING = dbArray($RES_HEADING)) {
												$SQL_DATAIL = "SELECT 
										SUM(recdetail_amt) as Total																			
										FROM 
										cms_feesreceivemaster as frm,
										cms_feesreceivedetail as frd
										Where
										frm.feesreceive_id = frd.feesreceive_id AND
										frm.receipt_date = '" . $REC_SELECT["receipt_date"] . "' AND
										frd.head_id ='" . $REC_HEADING["head_id"] . "'  AND
										frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  AND
										frd.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' 	";
												$RES_DETAIL = dbQuery($SQL_DATAIL);
												$REC_DETAIL = dbArray($RES_DETAIL);
												?>
												<td style="text-align:right; padding-right:2px;">
													<?php
													if ($REC_DETAIL['Total'] != "" && $REC_DETAIL['Total'] != "0") {
														echo $REC_DETAIL['Total'];
													} else {
														echo '-';
													}
													?>
												</td>
												<?php
												$allscopdatetotal += $REC_DETAIL['Total'];
											}
											?>
											<td style="text-align:center;">&nbsp;</td>
										</tr>
									<?php
								}
							}
							?>
								<tr>
									<td colspan="3">All Date Grand Total</td>
									<?php
									$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name != 'College Dev. Fee'  and head_name != 'Scope Fee'and college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";
									$RES_HEADING = dbQuery($SQL_HEADING);
									$alldatetotal = 0;
									while ($REC_HEADING = dbArray($RES_HEADING)) {
										$SQL_DATAIL = "SELECT 
										SUM(recdetail_amt) as Total																			
										FROM 
										cms_feesreceivemaster as frm,
										cms_feesreceivedetail as frd
										Where
										frm.feesreceive_id = frd.feesreceive_id AND
										frm.receipt_date >= '$startdate' AND frm.receipt_date <= '$enddate' AND
										frd.head_id ='" . $REC_HEADING["head_id"] . "'  AND
										frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  AND
										frm.year_id ='" . $_SESSION["VedantnrYearId"] . "'  AND
										frd.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' ";

										$RES_DETAIL = dbQuery($SQL_DATAIL);
										$REC_DETAIL = dbArray($RES_DETAIL); ?>

										<td style="text-align:right; padding-right:2px;">
											<?php
											if ($REC_DETAIL['Total'] != "" && $REC_DETAIL['Total'] != "0") {
												echo $REC_DETAIL['Total'];
											} else {
												echo '-';
											}
											?>
										</td>
										<?php
										$alldatetotal1 += $REC_DETAIL['Total'];
									}
									?>
									<td style="text-align:center;"><?php echo $alldatetotal1 ?></td>
									<?php
									$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name = 'College Dev. Fee' and college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";

									$RES_HEADING = dbQuery($SQL_HEADING);
									$alldevdatetotal = 0;
									while ($REC_HEADING = dbArray($RES_HEADING)) {
										$SQL_DATAIL = "SELECT 
										SUM(recdetail_amt) as Total																			
										FROM 
										cms_feesreceivemaster as frm,
										cms_feesreceivedetail as frd
										Where
										frm.feesreceive_id = frd.feesreceive_id AND
										frm.receipt_date >= '$startdate' AND frm.receipt_date <= '$enddate' AND
										frd.head_id ='" . $REC_HEADING["head_id"] . "'  AND
										frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  AND
										frd.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' ";

										$RES_DETAIL = dbQuery($SQL_DATAIL);
										$REC_DETAIL = dbArray($RES_DETAIL); ?>
										<td style="text-align:right; padding-right:2px;">
											<?php
											if ($REC_DETAIL['Total'] != "" && $REC_DETAIL['Total'] != "0") {
												echo $REC_DETAIL['Total'];
											} else {
												echo '-';
											}
											?>
										</td>
										<?php
										$alldevdatetotal += $REC_DETAIL['Total'];
									}
									?>
									<?php
									$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name = 'Scope Fee' and college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  ORDER BY head_id ASC";
									$RES_HEADING = dbQuery($SQL_HEADING);
									$allscopdatetotal = 0;
									while ($REC_HEADING = dbArray($RES_HEADING)) {
										$SQL_DATAIL = "SELECT 
										SUM(recdetail_amt) as Total																			
										FROM 
										cms_feesreceivemaster as frm,
										cms_feesreceivedetail as frd
										Where
										frm.feesreceive_id = frd.feesreceive_id AND
										frm.receipt_date >= '$startdate' AND frm.receipt_date <= '$enddate' AND
										frd.head_id ='" . $REC_HEADING["head_id"] . "'  AND
										frm.college_id ='" . $_SESSION["VedantnrCollegeId"] . "'  AND
										frd.college_id ='" . $_SESSION["VedantnrCollegeId"] . "' ";

										$RES_DETAIL = dbQuery($SQL_DATAIL);
										$REC_DETAIL = dbArray($RES_DETAIL); ?>
										<td style="text-align:right; padding-right:2px;">
											<?php
											if ($REC_DETAIL['Total'] != "" && $REC_DETAIL['Total'] != "0") {
												echo $REC_DETAIL['Total'];
											} else {
												echo '-';
											}
											?>
										</td>
										<?php
										$allscopdatetotal += $REC_DETAIL['Total'];
									}
									?>
									<td style="text-align:center;">&nbsp;</td>
								</tr>
</table>
</td>
</tr>
</table>

							</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";
}

?>
<?php require "_footer.php"; ?>