<?php
session_start();
if(!isset($_SESSION["logged_in"]) && $_SESSION["logged_in"]!=true){
    header("Location: login.php");
    exit;
}
if(empty($_GET["id"]) && $_GET["id"]==""){
    header("Location: indexnew.php");
    exit;
}
$id= base64_decode($_GET["id"]);
include_once("db_connect.php");



$sqlQuery= "SELECT tbl_admission_reg.*, tbl_userregistration_reg.userid as user_ids,tbl_userregistration_reg.name as name,tbl_userregistration_reg.fathersname as fathersname,tbl_userregistration_reg.session_from, tbl_userregistration_reg.session_to,tbl_userregistration_reg.course,tbl_userregistration_reg.comp_sub1, tbl_userregistration_reg.comp_sub2,tbl_userregistration_reg.comp_sub3, tbl_userregistration_reg.opt_sub1,tbl_userregistration_reg.opt_sub2, tbl_userregistration_reg.opt_sub3,tbl_userregistration_reg.add_sub,tbl_userregistration_reg.transaction_id,tbl_userregistration_reg.coupan_code,tbl_userregistration_reg.category,tbl_userregistration_reg.gender,tbl_userregistration_reg.response_message FROM  tbl_admission_reg LEFT JOIN  tbl_userregistration_reg ON tbl_admission_reg.userid=tbl_userregistration_reg.userid AND tbl_admission_reg.regid=tbl_userregistration_reg.id WHERE tbl_userregistration_reg.id='$id' AND tbl_userregistration_reg.userid='".$_SESSION["user_id"]."' AND tbl_userregistration_reg.response_message='Transaction successful' AND tbl_admission_reg.status='1' AND tbl_userregistration_reg.status='1'";
$fetchQry= mysqli_query($conn,$sqlQuery);
if(mysqli_num_rows($fetchQry) > 0){
    $fetchDetail= mysqli_fetch_assoc($fetchQry);
} else {
    header("Location: indexnew.php");
    exit;
}
$course= $fetchDetail["course"];
if($course=="IA"){
    $chkTable="ia_unique_reg";
    $rollprefix= "IA";
} elseif($course=="ICOM"){
    $chkTable="icm_unique_reg";
    $rollprefix= "ICOM";
} elseif($course=="ISC"){
    $chkTable="isc_unique_reg";
    $rollprefix= "ISC";
}
$getUniqno= mysqli_query($conn,"SELECT * FROM ".$chkTable." WHERE user_id='".$_SESSION["user_id"]."'");
$fetchUniqno= mysqli_fetch_assoc($getUniqno);

if($fetchUniqno["id"]<10){
    $recpNo= "recp_00".$fetchUniqno["id"];
    $rollNo= $rollprefix."_00".$fetchUniqno["id"];
} else {
    $recpNo= "recp_".$fetchUniqno["id"];
    $rollNo= $rollprefix."_".$fetchUniqno["id"];
}
$fetchQuery= mysqli_query($conn,"SELECT ref_no FROM upload_data_reg WHERE id=".$fetchDetail["user_ids"]);
$fetchUser= mysqli_fetch_assoc($fetchQuery);
?>
			

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40">
 
    <head>
    <title>Maharaja College, Ara, Bhojpur,Bihar</title>
        <style type="text/css">
        body {      
            font-family: Verdana;
        }
         
        div.invoice {
        border:1px solid #ccc;
        padding:10px;
        height:740pt;
        width:570pt;
        }
 
        div.company-address {
            border:1px solid #ccc;
            float:left;
            width:200pt;
        }
         
        div.invoice-details {
            border:1px solid #ccc;
            float:right;
            width:200pt;
        }
         
        div.customer-address {
            border:1px solid #ccc;
            float:right;
            margin-bottom:50px;
            margin-top:100px;
            width:200pt;
        }
         
        div.clear-fix {
            clear:both;
            float:none;
        }
         
        table {
            width:100%;
        }
         
        th {
            text-align: left;
        }
         
        td {
        }
         
        .text-left {
            text-align:left;
        }
         
        .text-center {
            text-align:center;
        }
         
        .text-right {
            text-align:right;
        }
        @media print {
          #afterprint {page-break-after: always;}
        }
         
        </style>
    <!--[if !mso]>
	<style>
v\:*         { behavior: url(#default#VML) }
o\:*         { behavior: url(#default#VML) }
.shape       { behavior: url(#default#VML) }
</style>
	<![endif]-->
	<link rel="File-List" href="testreceipt_files/filelist.xml">
<!--[if gte mso 9]>
	<xml><o:shapedefaults v:ext="edit" spidmax="1027"/>
	</xml><![endif]-->
    </head>
 
    <body>
        <form action="indexnew.php"><input value="Back"  type="button" onclick="retrnback()"> &nbsp; <input value="Print this page" onclick="window.print()" type="button"></form>
    <div class="invoice" style="width: 760px; height: 993px" id="reciptprint">
     
       <?php for($i=1; $i<=1; $i++){ ?>
		<table border="1" width="100%" bordercolorlight="#808080" style="border-collapse: collapse">
			<tr>
				<td width="100%">
				<p align="center">
				<img border="0" src="mbn.jpg" width="100%" height="101"></td>
			</tr>
			<tr>
				<td align="center"><u><font face="Times New Roman" size="2"><b>
				Registration Receipt</b></font></u></td>
			</tr>
		</table>
		<table border="1" width="100%" bordercolorlight="#808080" style="border-collapse: collapse">
			<tr>
				<td width="97"><b><font face="Times New Roman" size="2">
				Receipt-No:</font></b></td>
				<td width="114"><font face="Times New Roman" size="2">&nbsp;<?php echo $recpNo; ?></td>
				<td width="73"><b><font face="Times New Roman" size="2">Receipt 
				Date</font></b></td>
				<td width="83"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["created_at"]; ?></td>
				<td width="89"><b><font size="2" face="Times New Roman">
				Roll No</font></b></td>
				<td><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["coupan_code"]; ?></td>
			</tr>
		</table>
		<table border="1" width="100%" bordercolorlight="#808080" style="border-collapse: collapse">
			<tr>
				<td width="13%"><b><font face="Times New Roman" size="2">Name</font></b></td>
				<td width="35%"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["name"]; ?></td>
				<td width="14%"><b><font face="Times New Roman" size="2">Father's 
				Name</font></b></td>
				<td colspan="2"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["fathersname"]; ?></td>
			</tr>
			<tr>
				<td width="13%"><b><font face="Times New Roman" size="2">Transaction id</font></b></td>
				<td width="35%"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["transaction_id"]; ?></td>
				<td width="14%"><b><font face="Times New Roman" size="2">Payment Status</font></b></td>
				<td colspan="2"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["response_message"]; ?></td>
			</tr>
			<tr>
				<td width="13%"><b><font face="Times New Roman" size="2">Category</font></b></td>
				<td width="35%"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["category"]; ?></td>
				<td width="14%"><b><font face="Times New Roman" size="2">Gender</font></b></td>
				<td colspan="2"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["gender"]; ?></td>
			</tr>
			<tr>
				<td width="13%"><b><font face="Times New Roman" size="2">Reference id</font></b></td>
				<td width="35%"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchUser["ref_no"]; ?></td>
				<td width="14%"><b><font face="Times New Roman" size="2">&nbsp;</font></b></td>
				<td colspan="2"><font face="Times New Roman" size="2">&nbsp;</td>
			</tr>
			<tr>
				<td width="13%"><b><font face="Times New Roman" size="2">Subject</font></b></td>
				<td width="35%"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["comp_sub1"].", ".$fetchDetail["comp_sub2"].", ".$fetchDetail["comp_sub3"].", ".$fetchDetail["opt_sub1"].", ".$fetchDetail["opt_sub2"].", ".$fetchDetail["opt_sub3"].", ".$fetchDetail["add_sub"]; ?></td>
				<td width="14%"><b><font face="Times New Roman" size="2">Session</font></b></td>
				<td width="15%"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["session_from"]; ?></td>
				<td width="19%"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["session_to"]; ?></td>
			</tr>
		</table>
         
        <table border="1" width="100%" bordercolorlight="#808080" style="border-collapse: collapse">
			<tr>
				<td width="7%"><font face="Times New Roman" size="2"><b>Sl.No</b></font></td>
				<td colspan="2">
				<p align="center"><font face="Times New Roman" size="2"><b>
				Particulars</b></font></td>
				<td width="18%"><font face="Times New Roman" size="2"><b>Amount 
				(Rs)</b></font></td>
			</tr>
			<!-- Fee Structure -->
            	<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">1.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp;Student Fund</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["student_fund"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">2.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp;NSS</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["nss"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">3.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp;Atheletic Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["atheletic_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">4.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp;Science Caution Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["science_caution_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">5.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp;Late Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["late_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">6.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp;Cost Of Rem</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["cost_of_rem"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">7.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Flag </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["flag"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">8.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Eklavaya Fee </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["eklavaya_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">9.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Mig Fee </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["mig_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">10.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Tution Fund </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["tution_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">11.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; College Dev Fee </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["college_dev_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">12.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Admission Fee </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["admission_fee"]; ?></font></td>
			</tr>
			
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">13.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Test Fee </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["test_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">14.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp;  Cycle Stand Fee  </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["cycle_stand_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">15.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Lab Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["lab_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">16.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; UGC Charge </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["ugc_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">17.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Garden Fee </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["garden_fee"]; ?></font></td>
			</tr>
			<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">18.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Registration Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["other_fee"]; ?></font></td>
			</tr>
            <tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">19.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Exam Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["exam_fee"]; ?></font></td>
			</tr>
            <tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">20.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Local levey</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["local_levey"]; ?></font></td>
			</tr>
            <tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">21.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Marks Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["marks_fee"]; ?></font></td>
			</tr>
            <tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">22.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Provisional Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["prov_fee"]; ?></font></td>
			</tr>
            <tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">23.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Online Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["online_fee"]; ?></font></td>
			</tr>
            <tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">24.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Registration Form Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["exam_form"]; ?></font></td>
			</tr>

			<!-- NET TOtal -->
			<?php
			    $totalFee= $fetchDetail["student_fund"]+$fetchDetail["nss"]+$fetchDetail["atheletic_fee"]+$fetchDetail["college_dev_fee"]+$fetchDetail["late_fee"]+$fetchDetail["cost_of_rem"]+$fetchDetail["flag"]+$fetchDetail["eklavaya_fee"]+$fetchDetail["mig_fee"]+$fetchDetail["tution_fee"]+$fetchDetail["admission_fee"]+$fetchDetail["test_fee"]+$fetchDetail["cycle_stand_fee"]+$fetchDetail["lab_fee"]+$fetchDetail["ugc_fee"]+$fetchDetail["other_fee"]+$fetchDetail["science_caution_fee"]+$fetchDetail["garden_fee"]+$fetchDetail["exam_fee"]+$fetchDetail["local_levey"]+$fetchDetail["marks_fee"]+$fetchDetail["prov_fee"]+$fetchDetail["online_fee"]+$fetchDetail["exam_form"];
			    
			?>
			<tr>
				<td width="7%"><font face="Times New Roman" size="2">Rem:</font></td>
				<td width="54%"><font face="Times New Roman" size="2">&nbsp;<?php echo $fee_remarks ?></font></td>
				<td width="18%">
				<p align="right"><b><font face="Times New Roman" size="2">Total</font></b></td>
				<td width="18%" align="right"><b>
				<font face="Times New Roman" size="2">&nbsp;<?php echo $totalFee; ?></font></b></td>
			</tr>
			<tr>
				<td width="7%" rowspan="2">
				<font face="Times New Roman" size="2">Paid Rs.</font></td>
				<td width="54%" rowspan="2">
				<font face="Times New Roman" size="2">&nbsp;<?php //echo convertint_words($totalFee); ?></font></td>
				<td width="18%">
				<p align="right"><b><font face="Times New Roman" size="2">Fees 
				Paid</font></b></td>
				<td width="18%" align="right"><b>
				<font face="Times New Roman" size="2">&nbsp;<?php echo $totalFee ?></font></b></td>
			</tr>
			<tr>
				<td width="18%">
				<p align="right"><b><font face="Times New Roman" size="2">
				Balance/ Due Amount</font></b></td>
				<td width="18%" align="right"><b>
				<font face="Times New Roman" size="2">&nbsp;<?php echo 0.00; ?></font></b></td>
			</tr>
			<tr>
				<td width="7%">&nbsp;</td>
				<td colspan="3"><font face="Times New Roman" size="2">This is Computer generated receipt by&nbsp; : &nbsp;<?php //echo $fetchDetail["name"]; ?> 
				</font> </td>
			</tr>
			<tr>
			  <td>&nbsp;</td>
			  <td colspan="3">&nbsp;</td>
		  </tr>
		</table>
		<?php if($i==1){ ?>
		<p id="afterprint">&nbsp;</p>
         <?php } } ?>
         <!-- Second -->
        <p>&nbsp;</p>

         
      <div class="clear-fix"></div>
        </div>
    </body>
 <script>
     function retrnback(){
         // Simulate a mouse click:
window.location.href = "<?php echo SITE_URL; ?>/indexnew.php";
     }
 </script>
</html>