<?php require "_header.php";
include ("Numbers/Words.php");
$nw = new Numbers_Words();
global $SiteBaseUrl;
?>
<div id="main-report" align="center">
	<style>
		.table-report {
			border: 1px solid #000;
			font-family: Verdana, Geneva, sans-serif;
			font-size: 11px;
			text-align: left;
		}

		.table-report-inner {
			font-family: Verdana, Geneva, sans-serif;
			font-size: 11px;
		}

		.table-report-footer {
			font-family: Verdana, Geneva, sans-serif;
			font-size: 10px;
		}

		.table-report tr {
			padding: 1px 1px 1px 1px;
		}

		.table-report td {
			padding: 1px 1px 1px 1px;
		}

		.table-report th {
			padding: 1px 1px 1px 1px;
			font-weight: bold;
			text-align: left;
		}

		.college_name {
			font-family: QTAbbie;
			font-size: 22px;
			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;
		}

		.break {
			page-break-after: always;

		}
	</style>
	<center>
		<h4>Student Fees Receipt</h4>
	</center>
	<div style="float:left">
		<a href="addedit-feesreceive.php">&laquo;&nbsp;Back to Fee Recive</a>
	</div>
	<br />
	<br />
	<?php
	$header_row_string = "";

	$receipt_no = $_REQUEST['receipt_no'];
	$branch_id = $_REQUEST['branch_id'];
	$semester_id = $_REQUEST['semester_id'];
	//$receipt_no = $_SESSION["receiptno1"];
	
	if ($_SESSION['VedantnrCollegeId'] != "" && isset($_SESSION['VedantnrCollegeId'])) {
		ob_start();
		$sql_receipt = "
			SELECT 
				frm.feesreceive_id,
				frm.student_id,
				frm.receipt_no,
				frm.receipt_date,
				frm.cheque_no,
				frm.bank_name,
				frm.comment_show,
				frm.comments,
				frm.branch_id,
				frm.semester_id,
				frm.createdon,
				frm.allsem,
				frm.amount_discount,
				frm.discount,
				frm.all_receive_amt,
				frm.total_receive_amt
				
				
			FROM
				cms_feesreceivemaster frm
			
			WHERE
				frm.branch_id = $branch_id AND
					frm.semester_id = $semester_id AND
				frm.receipt_no = $receipt_no AND
				frm.college_id = '" . $_SESSION['VedantnrCollegeId'] . "'  AND
				frm.year_id = " . $_SESSION["VedantnrYearId"];
		//	echo $sql_receipt; exit;			
		$res_receipt = dbQuery($sql_receipt);


		$rec_receipt = dbArray($res_receipt);

		$branch_id1 = $rec_receipt['branch_id'];
		$semester_id = $rec_receipt['semester_id'];
		$receipt_no = $rec_receipt['receipt_no'];
		$student_id = $rec_receipt['student_id'];
		$receipt_date = $rec_receipt['receipt_date'];
		$comment_show = $rec_receipt['comment_show'];
		$comments = $rec_receipt['comments'];
		$cheque_no = $rec_receipt['cheque_no'];
		$bank_name = $rec_receipt['bank_name'];
		$discount = $rec_receipt['discount'];
		//	$fees_amount = $rec_receipt['fees_amount'];
		$createdon = date('YmdHis', strtotime($rec_receipt['receipt_date']));

		$sql_student = "
					SELECT 
						stud.student_surname,
						stud.student_firstname,
						stud.student_lastname,
						stud.student_gturegno,
						bm.branch_name,
						sd.student_rollno,
						sm.semester_name,
						stud.ba_core,
						sd.ba_core,
						sd.ba_el1,
						sd.ba_el2,
						sd.msc_group,
						sd.bsc_group
					FROM
						cms_studentmaster stud,
						cms_studentdetail sd,
						cms_branchmaster bm,
						cms_semestermaster sm	
					WHERE
						stud.student_id = sd.student_id AND
						stud.student_id = $student_id AND
						sd.cur_branchid = bm.branch_id  AND
						sd.cur_semesterid = sm.semester_id AND
						sd.cur_branchid = $branch_id1 AND
						sd.college_id = '" . $_SESSION['VedantnrCollegeId'] . "'  AND
						sm.college_id = '" . $_SESSION['VedantnrCollegeId'] . "'  AND
						sd.cur_semesterid = $semester_id AND
						sd.year_id = " . $_SESSION["VedantnrYearId"];
		$res_student = dbQuery($sql_student);
		$rec_student = dbArray($res_student);

		$sql_fees = "
					SELECT
						fh.head_name,
						frd.recdetail_amt
					FROM
						cms_feesreceivemaster frm,
						cms_feesreceivedetail frd,
						cms_feeshead fh
						
					WHERE
						fh.head_name != 'College Dev. Fee' AND
						fh.head_name != 'Scope Fee' AND
						frm.receipt_no = $receipt_no AND
						frm.college_id = '" . $_SESSION['VedantnrCollegeId'] . "'  AND
						frm.feesreceive_id = frd.feesreceive_id AND
						frd.head_id = fh.head_id AND
						frm.branch_id = $branch_id1 AND
						frm.semester_id = $semester_id AND
						frm.year_id = " . $_SESSION["VedantnrYearId"] . "
					ORDER BY fh.head_id";
		$res_fees = dbQuery($sql_fees);
		//	echo $sql_fees; exit;
		if (dbRows($res_fees) > 0) {
			?>
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<td rowspan="2">
						<img src="<?php echo $SiteBaseUrl . $CollegeImagePath . $_SESSION["VedantnrCollegeLogo"]; ?>" height="60"
							width="60" />
					</td>
					<td class="college_name">
						<font size="1">MANAGED BY : KALOL TALUKA KELAVANI MANDAL</font>
						</br><?php echo $_SESSION["VedantnrCollegeName"]; ?>
					</td>
				</tr>
				<tr>
					<td class="college_address" height="30">
						<?php echo $_SESSION["VedantnrCollegeAddress"]; ?>
						<br />
						Web: <?php echo $_SESSION["VedantnrCollegeUrl"]; ?>
						&nbsp;&nbsp;
						Email: <?php echo $_SESSION["VedantnrCollegeEmail"]; ?>
						&nbsp;&nbsp;
						Phone: <?php echo $_SESSION["VedantnrCollegePhone"]; ?>
					</td>
				</tr>
			</table>
			</br>
			<h1><i>
					<center>Fee Receipt</center>
				</i></h1>
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<th style="line-height:20px;text-align:left;" width="20%">Student Name:</th>
					<td style="line-height:20px;text-align:left;" width="30%">
						<?php echo $rec_student['student_surname'] . " " . $rec_student['student_firstname'] . " " . $rec_student['student_lastname']; ?>
					</td>
					<th style="line-height:20px;text-align:left;" width="14%">Receipt No:</th>
					<td style="line-height:20px;text-align:left;" width="8%"><?php echo $receipt_no; ?></td>
				</tr>
				<tr>
					<th style="line-height:20px;text-align:left;" width="14%">GU Enr No:</th>
					<td style="line-height:20px;text-align:left;" width="40%"><?php echo $rec_student['student_gturegno']; ?>
					</td>
					<th style="line-height:20px;text-align:left;" width="14%">Roll No:</th>
					<td style="line-height:20px;text-align:left;" width="8%"><?php
					if ($rec_student['rollno_print'] == 'Yes') {
						echo $rec_student['student_rollno'];
					} else {
						echo '';
					} ?></td>
				</tr>
				<tr>
					<th style="line-height:20px;text-align:left;" width="11%">Course:</th>
					<td style="line-height:20px;text-align:left;">
						<?php echo $rec_student['branch_name'] . " - " . $rec_student['semester_name'] . " - " . $rec_student['cur_divison']; ?>
					</td>
					<th style="line-height:20px;text-align:left;" width="18%">Receipt Date:</th>
					<td style="line-height:20px;text-align:left;" width="15%">
						<?php echo date('d-m-Y', strtotime($receipt_date)); ?></td>
				</tr>
				<tr>
					<th style="line-height:20px;text-align:left;" width="11%">Subject:</th>
					<?php
					if ($rec_student['branch_name'] == 'BA') {
						?>
						<td colspan="3" style="line-height:20px;text-align:left;">
							<?php echo $rec_student['ba_core'] . '/' . $rec_student['ba_el1'] . '/' . $rec_student['ba_el2']; ?>
						</td>
						<?php
					} else if ($rec_student['branch_name'] == 'B.SC') {
						?>
							<td colspan="3" style="line-height:20px;text-align:left;">
							<?php echo $rec_student['bsc_group']; ?>
							</td>
						<?php
					} else if ($rec_student['branch_name'] == 'M.SC') {
						?>
								<td colspan="3" style="line-height:20px;text-align:left;">
							<?php echo $rec_student['msc_group']; ?>
								</td>
						<?php
					} else if ($rec_student['branch_name'] == 'B.COM') {
						?>
									<td colspan="3" style="line-height:20px;text-align:left;">
							<?php echo $rec_student['ba_core'] . '/' . $rec_student['ba_el1'] . '/' . $rec_student['ba_el2']; ?>
									</td>
						<?php
					}
					?>
				</tr>
			</table>
			</br>
			<table width="100%" cellpadding="0" cellspacing="0" border="1">
				<?php

				$total = 0;
				$total1 = 0;
				$counter = 0;
				while ($rec_fees = dbArray($res_fees)) {
					if ($i % 2 == 0) {
						echo '<tr>';
					}
					echo '<td style="line-height:20px;">&nbsp;' . $rec_fees['head_name'] . '</td>';
					echo '<td style="line-height:20px;font-weight: bold;">' . $rec_fees['recdetail_amt'] . '</td>';
					if ($i % 2 == 1) {
						echo '</tr>';
					}
					$i++;
					$total = $total + $rec_fees['recdetail_amt'];
				}
				?>
				<tr>
					<td style="line-height:35px;font-weight: bold;" colspan="3">&nbsp;&nbsp;&nbsp;Grand Total :
						<?php echo strtoupper($nw->toWords($total) . " Rs"); ?></td>
					<td style="line-height:35px;font-weight: bold;"><?php echo $total ?></td>
				</tr>
				<?php
				echo "</table>";

				$gtuo = $rec_student['student_gturegno'];
				$barcode = $receipt_no . $createdon . $gtuo;
				?>
				</br></br>
				<table width="100%" cellpadding="0" cellspacing="0" border="0">
					<td valign="top" width="20%">
						<?php echo "<img src='$SiteBaseUrl/bc.php?barcode=" . $barcode . "&width=550&height=50' alt='barcode' />"; ?>
					</td>
					<td valign="top" width="65%" style="text-align:left;">
						For Principal
					</td>
					<td valign="top" width="15%">
						<center>
							_________________</br>
							Cashier
							<center>
					</td>
				</table>
				</br>
				<hr>
				</br>

				<?php
		}

		$HtmlCode = ob_get_contents();
		//echo $HtmlCode;
		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" 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">


				//	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
	} else {
		echo "Session Expired";
	}
	?>
</div>
<?php require "_footer.php"; ?>