<?php require "_header.php";

?>
<script language="javascript" type="text/javascript">

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

	.report_name {
		font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
		font-size: 13px;
		background-color: #CCC;
		text-align: center;
		font-weight: bold;
		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']);
$objFees = new StudentFeesRecMgmt();
//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;
	$final_online = 0;
	$date_cash = 0;
	$date_bank = 0;
	$date_online = 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'] . " to " . $_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.ref_no,
						  frm.discount,
						  frm.branch_id,
						  frm.year_id,
						  frm.branchyear_id,
						  frm.semester_id,
						  frm.student_id,
						  frm.receipt_date,
						  (SELECT user_name 
									  FROM cms_usermaster um 
									  WHERE um.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and frm.login_id =um.user_id) AS user_name,
						  
						  (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;
			  //echo  $SQL_SELECT; exit;
			  //$RES_SELECT = dbQuery($SQL_SELECT);*/
			  $condition10 ="";
$condition10 .=$condition;
		$condition10 .= " ORDER BY frm.receipt_no ASC ";
		
		$RES_SELECT = $objFees->getfeescollection($condition10);

		if (dbRows($RES_SELECT) > 0) { ?>
			<img src="<?php echo $SiteBaseUrl . $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: 30px;"><?php echo $_SESSION["VedantnrCollegeName"]; ?></b><br>
									<?php echo $_SESSION["VedantnrCollegeAddress"]; ?><br>
									Phone: <?php echo $_SESSION["VedantnrCollegePhone"]; ?>&nbsp;&nbsp;
									Email: <?php echo $_SESSION["VedantnrCollegeEmail"]; ?>
								</div>


			<div class="report_name">
				Daily Fees Collection - Summary Report</div>
			<table width="100%">

				<tr>
					<td style="text-align: left;border:none;  font-size: 12px;"><?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;"><b>Receipt No</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>
					<?php if ($REC_SELECT['semester_name'] != "") { ?>
						<th style="text-align:center;"><b>Semester</b></th>
					<?php } ?>
					<th style="text-align:center;"><b>Enrollment 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 || $date_online > 0) {
								if ($date_cash > 0 && $date_bank > 0 && $date_online > 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>
									<tr>
										<th colspan="7" style="text-align:right;">Online Received</th>
										<th style="text-align:right;"><?php echo $date_online; ?></th>
										<th>&nbsp;</th>

									</tr><?php
								} ?>
								<tr>
									<th colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 7 : 6 ?>" style="text-align:right;">Total Received
										Amount</th>
										<th style="text-align:right;"><?php echo $date_cash + $date_bank +$date_online; ?></th>
									<th>&nbsp;</th>
								</tr>
								<?php
								$date_bank = 0;
								$date_cash = 0;
								$date_online= 0;
							} ?>
							<tr style="page-break-after: always;">

							</tr>
							<tr>
								<td colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 9 : 8 ?>" 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 $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>
						<?php if ($REC_SELECT['semester_name'] != "") { ?>
							<td style="text-align:center;"><?php echo $REC_SELECT['semester_name']; ?></td>
						<?php } ?>

						<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'] == "" && $REC_SELECT['ref_no'] == "") {
									echo "(C)";
									$final_cash += $REC_SELECT['receive_amt'];
									$date_cash += $REC_SELECT['receive_amt'];
								} else if ($REC_SELECT['cheque_no'] != "") {
									echo "(B)";
									$final_bank += $REC_SELECT['receive_amt'];
									$date_bank += $REC_SELECT['receive_amt'];
								}
								else if ($REC_SELECT['ref_no'] != "") {
									echo "(O)";
									$final_online += $REC_SELECT['receive_amt'];
									$date_online += $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'] == "" && $REC_SELECT['ref_no'] == "" ) {
									echo "(C)";
									$final_cash += $REC_SELECT['total_receive_amt'];
									$date_cash += $REC_SELECT['total_receive_amt'];
								} else if ($REC_SELECT['cheque_no'] != "") {
									echo "(B)";
									$final_bank += $REC_SELECT['total_receive_amt'];
									$date_bank += $REC_SELECT['total_receive_amt'];
								}
								else if ($REC_SELECT['ref_no'] != "") {
									echo "(O)";
									$final_online += $REC_SELECT['total_receive_amt'];
									$date_online += $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 || $date_online > 0) {
						if ($date_cash > 0 && $date_bank > 0 && $date_online > 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>
							<tr>
								<th colspan="7" style="text-align:right;">Online Received</th>
								<th style="text-align:right;"><?php echo $date_online; ?></th>
								<th>&nbsp;</th>
							</tr><?php
						} ?>
						<tr>
							<th colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 7 : 6 ?>" style="text-align:right;">Total Received
								Amount</th>
								<th style="text-align:right;"><?php echo $date_cash + $date_bank + $date_online; ?></th>
							<th>&nbsp;</th>
						</tr>
						<?php
							$date_bank = 0;
							$date_cash = 0;
							$date_online= 0;
					} ?>
					<tr>
						<th colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 9 : 8 ?>"
							style="text-align:center; color:#000; background-color:#CCC;">FINAL TOTAL</th>
					</tr><?php
				}
				?>
				<?php if ($final_cash > 0 && $final_bank > 0 && $final_online > 0) { ?>
					<tr>
						<th colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 7 : 6 ?>" 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="<?php echo $REC_SELECT['semester_name'] != "" ? 7 : 6 ?>" 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>
					<tr>
						<th colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 7 : 6 ?>" style="text-align:right;">Total Online
							Received</th>
						<th style="text-align:right;"><?php echo number_format($final_online) . " Rs"; ?></th>
						<th>&nbsp;</th>
					</tr>
				<?php } ?>
				<tr>
					<th colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 7 : 6 ?>" style="text-align:right;">Total Received
						Amount</th>
						<th style="text-align:right;"><?php echo number_format($final_cash + $final_bank + $final_online) . " Rs"; ?></th>
						<th>&nbsp;</th>
				</tr>
				<tr>
					<th colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 9 : 8 ?>"
						style="text-align:center; color:#000; background-color:#CCC;">Received By</th>
				</tr>
				<tr>
					<td colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 9 : 8 ?>" 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;">Online</th>
								<th style="text-align:right; padding-right:2px;">Total</th>
							</tr>
							<?php
							/*$SQL_RECEIVER = "
														 SELECT
															 SUM(receive_amt -discount) AS receive_amt,
															 um.user_id,
															 um.user_name
														 FROM
															 cms_feesreceivemaster frm,
															 cms_usermaster um	 		 
														 WHERE
															 um.user_id = frm.login_id";
																 $SQL_RECEIVER .= $condition;
												 $RES_RECEIVER = dbQuery($SQL_RECEIVER);*/


							$condition1 = "";
						
							$condition1 .= $condition;
							$condition1 .= " GROUP BY frm.login_id ORDER BY frm.receipt_no ASC ";
							$RES_RECEIVER = $objFees->getfeescollection2($condition1);


							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  - discount) AS receive_amt
																			 FROM
																				 cms_feesreceivemaster frm
																			 WHERE
																				 frm.cheque_no = ''  and frm.ref_no = '' ";
																			 $SQL_CASH .= $condition;
																			 $RES_CASH = dbQuery($SQL_CASH);*/
											$condition2 = "";
											$condition2 .= $condition;
											$condition2 .= "AND frm.cheque_no = '' and frm.ref_no = '' ORDER BY frm.receipt_no ASC ";
											
											$RES_CASH = $objFees->getfeescollection3($condition2);
											$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 -discount) AS receive_amt
																						 FROM
																							 cms_feesreceivemaster frm
																						 WHERE
																							 frm.cheque_no != '' ";
																			 $SQL_CASH .= $condition;
																			 $RES_CASH = dbQuery($SQL_CASH);*/

											$condition3 = "";
											$condition3 .= $condition;
											$condition3 .= "AND frm.cheque_no != '' ORDER BY frm.receipt_no ASC";
											
											$RES_CASH = $objFees->getfeescollection3($condition3);
											$REC_CASH = dbArray($RES_CASH);
											echo number_format($REC_CASH['receive_amt']);
										$receive_amt=+number_format($REC_CASH['receive_amt']);
											?>
										</td>
										<td style="text-align:right; padding-right:2px;">
											<?php

											/*$SQL_CASH = "
																						 SELECT
																							 SUM(receive_amt -discount) AS receive_amt
																						 FROM
																							 cms_feesreceivemaster frm
																						 WHERE
																							 frm.ref_no != '' ";
																			 $SQL_CASH .= $condition;
																			 $RES_CASH = dbQuery($SQL_CASH);*/

											$condition4 = "";
											$condition4 .= $condition;
											$condition4 .= "AND frm.ref_no != '' ORDER BY frm.receipt_no ASC";
											
											$RES_CASH = $objFees->getfeescollection3($condition4);
											$REC_CASH = dbArray($RES_CASH);
											echo number_format($REC_CASH['receive_amt']);
										$receive_amt=+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 {
			echo "No records found.";
		}
	} else if ($report_type == "descriptive_type") {
	
		$RES_HEADING = $objFees->getfeescollection4($condition ="");
		//$SQL_HEADING = "SELECT head_id,head_name FROM cms_feeshead WHERE head_name != 'ACPDC Adm Fee' ORDER BY head_id ASC";
		//$RES_HEADING = dbQuery($SQL_HEADING);
		if (dbRows($RES_HEADING) > 0) { ?>
				<img src="<?php echo $SiteBaseUrl . $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: 30px;"><?php echo $_SESSION["VedantnrCollegeName"]; ?></b><br>
									<?php echo $_SESSION["VedantnrCollegeAddress"]; ?><br>
									Phone: <?php echo $_SESSION["VedantnrCollegePhone"]; ?>&nbsp;&nbsp;
									Email: <?php echo $_SESSION["VedantnrCollegeEmail"]; ?>
								</div>


				<div class="report_name">
					Daily Fees Collection - Descriptive Report</div>

				<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, O:Online</td>
					</tr>
				</table>

				<table class="table-report" border="1" cellpadding="0" cellspacing="0">
					<tr>
						<th style="text-align:center;">Receipt No</th>
						<th style="text-align:center;">Course</th>
						<th style="text-align:center;"><b>Batch Year</b></th>
						<th style="text-align:center;"><b>Course Year</b></th>
					<?php if ($semester_id != "") { ?>
							<th style="text-align:center;"><b>Semester</b></th>
					<?php } ?>
						<th style="text-align:center;">Enrollment No</th>
						<th style="text-align:left;">Student Name</th>
						<?php
						while ($REC_HEADING = dbArray($RES_HEADING)) { ?>
							<th style="text-align:center;"><?php echo $REC_HEADING['head_name']; ?></th>
						<?php
						} ?>
						<th style="text-align:center;">Total Amount</th>
						<th style="text-align:left;">Received By</th>
					</tr><?php
					/*$SQL_SELECT = "SELECT
				frm.feesreceive_id,
				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.discount,
				frm.cheque_no,
				frm.ref_no,
				frm.receipt_date,
				(SELECT user_name 
								FROM cms_usermaster um 
								WHERE um.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and frm.login_id =um.user_id) AS user_name,
					
					(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;
					$RES_SELECT = dbQuery($SQL_SELECT);*/
					$condition ="";					
					$condition .= " ORDER BY frm.receipt_no ASC ";
		
					$RES_SELECT = $objFees->getfeescollection($condition);
			
					if (dbRows($RES_SELECT) > 0) {
						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 || $$date_online > 0) {
										if ($date_cash > 0 && $date_bank > 0  && $$date_online > 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>
											<tr>
												<th colspan="14" style="text-align:right;">Online Received</th>
												<th style="text-align:right;"><?php echo number_format($date_online); ?></th>
												<th>&nbsp;</th>
											</tr><?php
										} ?>
										<tr>
											<th colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 9 :8?>" style="text-align:right;">Total Received
												Amount</th>
												<th style="text-align:right;"><?php echo number_format($date_cash + $date_bank +$date_online ); ?></th>
												<th>&nbsp;</th>
										</tr>
										<?php
									$date_bank = 0;
									$date_cash = 0;
									$date_online =0;
									} ?>
									<tr>
										<td colspan="15" 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 $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>
							<?php if ($semester_id != "") { ?>
									<td style="text-align:center;"><?php echo $REC_SELECT['semester_name']; ?></td>
							<?php } ?>
								<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
								$feesreceive_id = $REC_SELECT['feesreceive_id'];
								/*$SQL_DATAIL = "SELECT 
								cms_feeshead.head_id,
								recdetail_amt 
							FROM 
								cms_feeshead LEFT JOIN cms_feesreceivedetail
								ON cms_feeshead.head_id = cms_feesreceivedetail.head_id AND 
								feesreceive_id = $feesreceive_id  
							ORDER BY cms_feeshead.head_id ASC";

								$RES_DETAIL = dbQuery($SQL_DATAIL);*/ 
								$condition5 ="";
								$condition5 .=" AND feesreceive_id = $feesreceive_id";
								$condition5 .=" ORDER BY cms_feeshead.head_id ASC";
								$RES_DETAIL = $objFees->getfeescollection5($condition5);

								if (dbRows($RES_DETAIL) > 0) {
									while ($REC_DETAIL = dbArray($RES_DETAIL)) {
										if ($REC_DETAIL['head_id'] != 1) { ?>
											<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 $REC_DETAIL['total_receive_amt'];
													}
												} else {
													echo '-';
												}
												?>
											</td><?php
										}
									}
								}
								if ($REC_SELECT['discount'] != 0) { ?>
									<td style="text-align:right;">
									<?php echo $REC_SELECT['total_receive_amt'];
									$final_total += $REC_SELECT['total_receive_amt']; ?>
										<?php
										if ($REC_SELECT['cheque_no'] == "" && $REC_SELECT['ref_no'] == "") {
											echo "(C)";
											$final_cash += $REC_SELECT['total_receive_amt'];
											$date_cash += $REC_SELECT['total_receive_amt'];
										} else if($REC_SELECT['cheque_no'] != "") {
											echo "(B)";
											$final_bank += $REC_SELECT['total_receive_amt'];
											$date_bank += $REC_SELECT['total_receive_amt'];
										} else if($REC_SELECT['ref_no'] != "") {
											echo "(O)";
											$final_online += $REC_SELECT['total_receive_amt'];
											$date_online += $REC_SELECT['total_receive_amt'];
										}
										?>
									</td>
								<?php
								} else {
									?>
									<td style="text-align:right;">
									<?php echo $REC_SELECT['receive_amt'];
									$final_total += $REC_SELECT['receive_amt']; ?>
									<?php
										if ($REC_SELECT['cheque_no'] == "" && $REC_SELECT['ref_no'] == "") {
											echo "(C)";
											$final_cash += $REC_SELECT['receive_amt'];
											$date_cash += $REC_SELECT['receive_amt'];
										} else if($REC_SELECT['cheque_no'] != "") {
											echo "(B)";
											$final_bank += $REC_SELECT['receive_amt'];
											$date_bank += $REC_SELECT['receive_amt'];
										} else if($REC_SELECT['ref_no'] != "") {
											echo "(O)";
											$final_online += $REC_SELECT['receive_amt'];
											$date_online += $REC_SELECT['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 || $date_online > 0) {
							if ($date_cash > 0 && $date_bank > 0 && $date_online > 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>
								<tr>
									<th colspan="14" style="text-align:right;">Cheque Received</th>
									<th style="text-align:right;"><?php echo number_format($date_online); ?></th>
									<th>&nbsp;</th>
								</tr><?php
							} ?>
							<tr>
								<th colspan="<?php echo $REC_SELECT['semester_name'] != "" ? 10 : 9  ?>" style="text-align:right;">Total Received
									Amount</th>
									<th style="text-align:right;"><?php echo number_format($date_cash + $date_bank + $date_online); ?></th>
								<th>&nbsp;</th>
							</tr>
							<?php
							$date_bank = 0;
							$date_cash = 0;
							$date_online =0;
						} ?>
						<tr>
							<th colspan="17" style="text-align:center; color:#000; background-color:#CCC;">FINAL TOTAL</th>
						</tr><?php
					}
					?>
				<?php if ($final_cash > 0 && $final_bank > 0 && $final_online > 0) { ?>
						<tr>
							<th colspan="9" 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="9" 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>
						<tr>
							<th colspan="9" style="text-align:right;">Total Online Received</th>
							<th style="text-align:right;"><?php echo number_format($final_online) . " Rs"; ?></th>
							<th>&nbsp;</th>
						</tr>
				<?php } ?>
					<tr>
						<th colspan="<?php echo $REC_SELECT['semester_name'] != "" ?10: 9 ?>" style="text-align:right;">Total Received
							Amount</th>
							<th style="text-align:right;"><?php echo number_format($final_cash + $final_bank + $final_online) . " Rs"; ?></th>
							<th>&nbsp;</th>
					</tr>
					<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;">Online</th>
									<th style="text-align:right; padding-right:2px;">Total</th>
								</tr>
								<?php
								/*$SQL_RECEIVER = "
								SELECT
									SUM(receive_amt -discount) AS receive_amt,
									um.user_id,
									um.user_name
								FROM
									cms_feesreceivemaster frm,
									cms_usermaster um	 		 
								WHERE
									um.user_id = frm.login_id";
								$SQL_RECEIVER .= $condition;
								$SQL_RECEIVER .= " GROUP BY frm.login_id ORDER BY frm.receipt_no ASC ";
								//echo $SQL_RECEIVER;
								$RES_RECEIVER = dbQuery($SQL_RECEIVER);*/

								$condition1 .= " GROUP BY frm.login_id ORDER BY frm.receipt_no ASC ";
						

							$RES_RECEIVER = $objFees->getfeescollection2($condition1);
								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  - discount) AS receive_amt
										FROM
											cms_feesreceivemaster frm
										WHERE
											frm.cheque_no = '' and frm.ref_no = '' ";
												$SQL_CASH .= $condition;
												$RES_CASH = dbQuery($SQL_CASH);*/

												$condition2 .= "AND frm.cheque_no = '' AND frm.ref_no = ''";
											$condition2 .= $condition;
											$RES_CASH = $objFees->getfeescollection3($condition2);
												$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 -discount) AS receive_amt
													FROM
														cms_feesreceivemaster frm
													WHERE
														frm.cheque_no != '' ";
												$SQL_CASH .= $condition;
												$RES_CASH = dbQuery($SQL_CASH);*/
												$condition3 .= "AND frm.cheque_no != '' ";
											$condition3 .= $condition;
											$RES_CASH = $objFees->getfeescollection3($condition3); 
												$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 -discount) AS receive_amt
													FROM
														cms_feesreceivemaster frm
													WHERE
														frm.ref_no != '' ";
												$SQL_CASH .= $condition;
												$RES_CASH = dbQuery($SQL_CASH);*/
											$condition4 .= "AND frm.ref_no != '' ";
											$condition4.= $condition;
											$RES_CASH = $objFees->getfeescollection3($condition4); 
												$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";
}
?>
<?php require "_footer.php"; ?>