<?php require "_header.php";

include("Numbers/Words.php");
$nw = new Numbers_Words();
?>
<style>
	#rcorners2 {
		border-radius: 25px;
		border: 2px solid black;
		padding-top: 10px;
		width: 230px;
		height: 20px;
	}

	#rcorners3 {
		border: 2px solid black;
		padding-top: 5px;
		width: 400px;
		height: 30px;
	}

	#rcorners4 {
		border: 2px solid black;
		padding-top: 2px;
		width: 120px;
		height: 20px;
	}

	label {
		display: block;
		padding-left: 15px;
		text-indent: -15px;
	}

	input {
		width: 13px;
		height: 13px;
		padding: 0;
		margin: 0;
		vertical-align: bottom;
		position: relative;
		top: -1px;
		*overflow: hidden;
	}

	#container1 {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
	}

	#container1>div {
		width: 100px;
		height: 150px;
	}

	#rcorners2 {
		border-radius: 25px;
		border: 2px solid;
		padding: 20px;
		width: 200px;
		height: 30px;
	}

	.college_name {
		font-family: QTAbbie;
		font-size: 24px;
		font-weight: bold;
		padding: 1px 1px 1px 1px;
		text-align: center;
		vertical-align: top;
	}

	.college_address {
		font-family: Tahoma, Geneva, sans-serif;
		font-size: 11px;
		text-align: center;
		padding: 1px 1px 1px 1px;
		vertical-align: top;
	}
</style>

<?php
if ($_SESSION['VedantnrCollegeId'] != "" && isset($_SESSION['VedantnrCollegeId'])) {
	$feesreceive_id = $_REQUEST['feesreceive_id'];

	$condition = "";
	if ($feesreceive_id != "") {
		$condition .= " AND fm.feesreceive_id = $feesreceive_id";
	}

	$objFees = new StudentFeesRecMgmt();
	$out = $objFees->getAllFeesReceipt($condition);

	// Start capturing output
	ob_start();

	// Only print the table header once
	while ($row = dbArray($out)) {
		extract($row);

		?>
		</br></br>
		<table style="width: 80%; margin: 0 auto; border-collapse: collapse; border: 1px solid;" class="table-bordered">
			<tr style="vertical-align: middle;">
				<td colspan="5" style="border: 1px solid; padding: 5px; text-align: center;">
					<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>
				</td>
			</tr>
			<tr>
				<td><b>Student Name:</b></td>
				<td><?php echo $student_name; ?></td>
				<td><b>Receipt No:</b></td>
				<td><?php echo $receipt_no; ?></td>
				<td style="padding: 20px;width: 25%;" rowspan="4">
					<!-- Fee Details Table -->
					<table cellpadding="0" cellspacing="0" width="100%" style="border: 1px solid black; ">
						<tr>
							<th style="line-height:20px; border-right:1px solid;text-align:center; border-bottom:1px solid;"
								width="50%">
								<b>Particular</b>
							</th>
							<th style="line-height:20px; text-align:center;border-bottom:1px solid; " width="40%"><b>Amount</b>
							</th>
						</tr>
						<?php

						$condition = "";
						$condition .= " AND fm.feesreceive_id = '" . $feesreceive_id . "'";
	


						// Query to get the fee details for the same feesreceive_id
						$out1 = $objFees->getAllFeesReceiptdetails($condition);
						$feestotal = 0;  // Initialize total fees variable
				
						while ($row1 = dbArray($out1)) {
							if ($row1['recdetail_amt'] != "" && $row1['recdetail_amt'] != 0) {
								?>
								<tr style="line-height:20px;">
									<td style="line-height:20px; border-right:1px solid;text-align:left;border-bottom:1px solid;"
										width="70%">
										<?php echo $row1["head_name"]; ?>
									</td>
									<td width="30%" style="line-height:20px; text-align:center;border-bottom:1px solid; ">
										<b><?php echo $row1['recdetail_amt']; ?></b>
									</td>
								</tr>
								<?php
							}
							// Add to total fees
							$feestotal += $row1['recdetail_amt'];
						}
						?>
						<tr style="line-height:20px;">
							<td width="70%"><b>Total Fees: </b></td>
							<td width="30%" style="text-align:right;padding-right:10px;">
								<b><?php print number_format($feestotal, 2) ?></b>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<!-- Other student information -->
			<tr>
				<td><b>Enrollment No:</b></td>
				<td><?php echo $student_gturegno; ?></td>
				<td><b>Receipt Date:</b></td>
				<td><?php echo date('d-m-Y', strtotime($receipt_date)); ?></td>
			</tr>
			<tr>
				<td><b>Course:</b></td>
				<td><?php echo $branch_name; ?></td>
				<td><b>Batch Year:</b></td>
				<td><?php echo $year_name; ?></td>
			</tr>
			<tr>
				<?php if ($branchyear_name != "") { ?>
					<td><b>Course Year:</b></td>
					<td><?php echo $branchyear_name; ?></td>
				<?php }
				if ($semester_name != "") { ?>
					<td><b>Semester:</b></td>
					<td><?php echo $semester_name; ?></td>
				<?php } ?>
			</tr>
			<tr style="line-height:35px; border-top:1px solid;">
				<td colspan="5">
					<p style="line-height: 30px; text-indent:50px;">This Receipt is given to Master/Miss :&nbsp;&nbsp;
						<b><?php print $student_name; ?></b>
					</p>
				</td>
			</tr>
			<tr style="line-height:35px;">
				<td colspan="5">
					<div style="width:400px; ">
						<p style="line-height: 30px; text-indent:0px;">Rs. in Words :&nbsp;&nbsp;
							<b><?php echo strtoupper($nw->toWords($feestotal) . " Rs"); ?></b>
						</p>
					</div>
				</td>
			</tr>
			<tr>
				<td colspan="5" style="border-top:1px solid;">
					<div style="width:400px; ">
						<b>Payment Mode : &nbsp;&nbsp; </b>
						<?php
						if ($cheque_no == '' && $ref_no == '') { ?><b>Cash </b>
						<?php
						}
						if($cheque_no =="" && $ref_no !=""){
							echo "<b>Online</b><br>";
						}
						if ($cheque_no != '') {
							?><b>Cheque No : &nbsp;&nbsp; </b>
							<?php print $cheque_no; ?></br>
							<b>Bank : &nbsp;&nbsp; </b>
							<?php print $bank_name;
						}
						if ($ref_no != '') {
							?><b>Ref No : &nbsp;&nbsp; </b>
							<?php print $ref_no; ?></br>
							<?php
						} ?><br>
						<b>Remark : &nbsp;&nbsp;</b>
						<?php
						if ($comments != '') {
							print $comments;
						} ?>
					</div>
				</td>
			</tr>
			<tr>
				<td colspan="5">
					<table style="width: 100%;border-bottom: hidden;border-right: hidden; border-left:hidden;">
						<tr>
							<td valign="top"><b>Total Rs Received : <?php print number_format($feestotal, 2) ?></b>
							</td>
							<td valign="top">
								<center><b>Thank You</b></center></b>
							</td>
							<td valign="top"><b>
									<center>Cashier</center>
								</b></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<?php
	}

	// Capture HTML and save it as a file
	$HtmlCode = ob_get_contents();
	ob_end_flush();
	$HtmlUrl = "feereceipt-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" style="width:50px;height:25px;" name="btnPrint" id="btnPrint" value="Print"
			onClick="SetPageAction('PRINT');" />
		<input type="button" name="btnHtml" style="width:90px;height:25px;" id="btnHtml" value="Create HTML"
			onclick="SetPageAction('HTML');" />
		<input type="button" name="btnPdf" style="width:90px;height:25px;" id="btnPdf" value="Create PDF"
			onclick="SetPageAction('PDF');" />
		<!--<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">
		//	SetPageAction('PRINT');
		function SetPageAction(varAction) {
			if (varAction == "PRINT") {
				document.frm.action = "print/create-print.php";
				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
}//section_id condition over
else {
	echo "Session Expired";
}
?>
<?php require "_footer.php"; ?>