<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="jquery-barcode.js"></script>
<?php
//include('barcode/barcode.inc.php');
//include('barcode/BarcodeGenerator.php');
//include('barcode/BarcodeGeneratorHTML.php');
include('../db_con.php');
session_start(); 
include('methodlist.php');

$res = mysqli_query($con,"select app_id, salu, surname, givenname, created_date, passport_no, visa_type, total_fee, v_uid, refer_no from applicant_table where app_id='$_GET[appid]'");
$resrow=mysqli_fetch_array($res);

$salu=$resrow["salu"];
$gname=$resrow["givenname"];
$sname=$resrow["surname"];
$code=$resrow["refer_no"];
$passport=$resrow["passport_no"];
$mainvisatypename=get_parent_mainvisatype_name($resrow["visa_type"],$con);
$visatypename=get_visatype_name($resrow["visa_type"],$con);
$visafee=get_visa_fee($resrow["visa_type"],$con);
$totalvisafee=$visafee;

//$totalfee=$resrow["total_fee"];

echo "<div style='text-align:center; padding: 15px; line-height: 20px; width:250px; font-weight:bold;'>";

echo "<div style='margin-top:0px;'>";
echo "<img src='../assets/img/sglogo.jpg' style='width:90%'></div>";

echo "<div style='font-size:16px;'>Thai Visa Application Center</div>";

echo "<div style='font-size:14px;margin-top:30px;'>
Saimon Centre, House# 4A, <br/>
Road# 22, Gulshan-1,Dhaka-1212<br/> 
E-mail: support@thaivisabd.com<br/>
Tel: 88-02-9898080, 09606556655<br>
<p style='font-weight:normal;'>Counter User:".get_session_user_fullname($con)."</p></div>";

echo "<div style='font-size:14px;margin-top:40px;'><b>Application Fee Reciept</b>";
echo "<br/><span style='font-weight:normal;'>Date: ".date('d-m-Y', strtotime(substr($resrow['created_date'], 0, 10)));
echo "</span></div>";

echo "</div>";

echo "<div style='margin-top: -20px; font-size: 11px; line-height: 20px; width:250px; text-align:left; padding: 15px;'>";
echo "<br/><b> Applicant Name: ".$salu." ".$gname." ".$sname."</b>";
echo "<br/><b> Reference No: </b>".$code;
echo "<br/><b> Passport No: </b>".$passport;
echo "<br/><b> Visa Category: </b>".$mainvisatypename." ".$visatypename;
echo "<br/><b> Visa Fee: </b>".number_format($visafee,2)."/- BDT </div>";

echo "<div id='demo' style='margin: 0px 10px 0px 20px; text-align:center;'> </div>";
?>
<script>
$("#demo").barcode(
//"DFF1234567890128", // Value barcode (dependent on the type of barcode)
"<?php echo $code; ?>",
"code128"

);     
</script>
<?php
$child=0;
$countres = mysqli_query($con,"select app_id from  applicant_table where parent='$resrow[app_id]'");
$child=mysqli_num_rows($countres);
$i=1;
if($child>0){

	while($countrow=mysqli_fetch_array($countres)){

		$childres = mysqli_query($con,"select salu, surname, givenname, passport_no, visa_type, refer_no from applicant_table where app_id='$countrow[app_id]'");
		$childrow=mysqli_fetch_array($childres);

		$salu=$childrow["salu"];
		$gname=$childrow["givenname"];
		$sname=$childrow["surname"];
		$code=$childrow["refer_no"];
		$passport=$childrow["passport_no"];
		$mainvisatypename=get_parent_mainvisatype_name($childrow["visa_type"],$con);
		$visatypename=get_visatype_name($childrow["visa_type"],$con);
		$visafee=get_visa_fee($childrow["visa_type"],$con);
		$totalvisafee=$totalvisafee+$visafee;

	    echo "<div style='font-size: 11px; line-height: 20px; width:250px; text-align:left; padding: 15px;'>";
		echo "<br/><b> Applicant Name: ".$salu." ".$gname." ".$sname."</b>";
		echo "<br/><b> Reference No: </b>".$code;
		echo "<br/><b> Passport No: </b>".$passport;
		echo "<br/><b> Visa Category: </b>".$mainvisatypename." ".$visatypename;
		echo "<br/><b> Visa Fee: </b>".number_format($visafee,2)."/- BDT </div>";
		
		
		echo "<div style='margin: 0px 10px 0px 20px; text-align:center;' id='demo".$i."'> </div>"; ?>
		
		<script>
			$("#demo<?php echo $i; ?>").barcode(
			//"DFF1234567890128", // Value barcode (dependent on the type of barcode)
			"<?php echo $code; ?>",
			"code128"

			);     
		</script>
		<?php $i++;
	}

}

 echo "<div style='font-size: 11px; line-height: 20px; width:250px; text-align:left; padding: 15px;'>";    
$totalservicefee=0;
$child=$child+1;
$sql = "SELECT * FROM `setting_table` order by s_id";
$sresult = mysqli_query($con,$sql);
while($srow = mysqli_fetch_array($sresult)){

	echo "<br/>".$srow["setting_name"]." (x".$child.") :".$srow["value"]*$child."/- BDT ";
	$totalservicefee=$totalservicefee+$srow["value"]*$child;	
}

echo "<br/><br/><b> Total Payment : ".number_format($totalvisafee+$totalservicefee,2)."/- BDT </b><br/></div>";
echo "</div>";

?>
