<?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_ug2.*, tbl_userregistration_ug2.userid as user_ids,tbl_userregistration_ug2.name as name,tbl_userregistration_ug2.fathersname as fathersname,tbl_userregistration_ug2.session_from, tbl_userregistration_ug2.session_to,tbl_userregistration_ug2.course,tbl_userregistration_ug2.comp_sub1, tbl_userregistration_ug2.comp_sub2,tbl_userregistration_ug2.comp_sub3, tbl_userregistration_ug2.opt_sub1,tbl_userregistration_ug2.opt_sub2, tbl_userregistration_ug2.opt_sub3,tbl_userregistration_ug2.add_sub,tbl_userregistration_ug2.transaction_id,tbl_userregistration_ug2.coupan_code,tbl_userregistration_ug2.category,tbl_userregistration_ug2.gender,tbl_userregistration_ug2.response_message FROM  tbl_admission_ug2 LEFT JOIN  tbl_userregistration_ug2 ON tbl_admission_ug2.userid=tbl_userregistration_ug2.userid AND tbl_admission_ug2.regid=tbl_userregistration_ug2.id WHERE tbl_userregistration_ug2.id='$id' AND tbl_userregistration_ug2.userid='".$_SESSION["user_id"]."' AND tbl_userregistration_ug2.response_message='Transaction successful' AND tbl_admission_ug2.status='1' AND tbl_userregistration_ug2.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_ug2";
//    $rollprefix= "IA";
//} elseif($course=="ICOM"){
//    $chkTable="icm_unique_reg";
//    $rollprefix= "ICOM";
//} elseif($course=="ISC"){
//    $chkTable="isc_unique_reg";
   $rollprefix= "UG";
//}

$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_ug2 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>H.D.Jain 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>
    </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>
				Admission Receipt-UG-Part-II</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="102"><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="16%"><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="16%"><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="16%"><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="16%"><b><font face="Times New Roman" size="2">Course</font></b></td>
				<td colspan="2"><font face="Times New Roman" size="2">&nbsp;<?php echo $fetchDetail["course"]; ?></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["opt_sub1"].", ".$fetchDetail["opt_sub2"].", ".$fetchDetail["opt_sub3"].", ".$fetchDetail["add_sub"]; ?></td>
				<td width="16%"><b><font face="Times New Roman" size="2">Session</font></b></td>
				<td width="14%"><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;Athletic 
				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;Security Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["sec_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; Misc 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">10.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; 
				Tuition 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; 
				NCC Fee </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["ncc"]; ?></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; 
				Parking 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; 
				Practical 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; Smart ICard Fee </font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["icard"]; ?></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; 
				Library&nbsp; Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["lib_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; Science Caution Money</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">20.</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">21.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Electrical Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["elect_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; College Magazine Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["coll_mag"]; ?></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; Admission Form Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["form_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; Annual Function Fee</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["anff"]; ?></font></td>
			</tr>
<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">25.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Generator Charge</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["gen_fee"]; ?></font></td>
			</tr>
<tr>
				<td width="7%"><b><font size="2" face="Traditional Arabic">26.</font></b></td>
				<td colspan="2"><b><font size="2" face="Times New Roman">&nbsp; Student Union</font></b></td>
				<td width="18%" align="right">
				<font size="2" face="Times New Roman">&nbsp;<?php echo $fetchDetail["stud_union"]; ?></font></td>
			</tr>

			<!-- NET TOtal -->
			<?php
			    //$totalFee= $fetchDetail["student_fund"]+$fetchDetail["nss"]+$fetchDetail["sport"]+$fetchDetail["certify_fee"]+$fetchDetail["late_fee"]+$fetchDetail["cost_of_rem"]+$fetchDetail["flag"]+$fetchDetail["eklavaya_fee"]+$fetchDetail["mig_fee"]+$fetchDetail["tution_fee"]+$fetchDetail["college_dev_fee"]+$fetchDetail["admission_fee"]+$fetchDetail["test_fee"]+$fetchDetail["cycle_stand_fee"]+$fetchDetail["lab_fee"]+$fetchDetail["ugc_fee"]+$fetchDetail["i_card_fee"]+$fetchDetail["marks_fee"]+$fetchDetail["exam_fee"]+$fetchDetail["local_levey"]+$fetchDetail["prov_fee"]+$fetchDetail["online_fee"]+$fetchDetail["exam_form_fee"];
			   $totalFee= $fetchDetail["nss"]+ $fetchDetail["student_fund"]+ $fetchDetail["college_dev_fee"]+ $fetchDetail["ugc_fee"]+ $fetchDetail["lab_fee"]+ $fetchDetail["cycle_stand_fee"]+ $fetchDetail["sec_fee"]+ $fetchDetail["admission_fee"]+ $fetchDetail["tution_fee"]+$fetchDetail["atheletic_fee"]+$fetchDetail["stud_union"]+ $fetchDetail["flag"]+ $fetchDetail["eklavaya_fee"]+ $fetchDetail["other_fee"]+$fetchDetail["late_fee"]+ $fetchDetail["science_caution_fee"]+ $fetchDetail["garden_fee"]+ $fetchDetail["cost_of_rem"]+ $fetchDetail["ncc"]+ $fetchDetail["icard"]+ $fetchDetail["lib_fee"]+ $fetchDetail["elect_fee"]+ $fetchDetail["coll_mag"]+ $fetchDetail["anff"]+ $fetchDetail["gen_fee"]+ $fetchDetail["form_fee"];
			    
			?>
			<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>