<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="jquery-barcode.js"></script>
<style>
#passport {
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    transform: rotate(-90deg);
    font-weight: bold;
}
.mydiv{
	padding-top: 5px;
	height: 13px; font-size: 13px; font-weight: bold; width:250px;
}
</style>
<?php
include('../db_con.php');
include('methodlist.php');

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

// find the delivery location shortcode ////

$date=date('d-m-Y', strtotime(substr($resrow["created_date"], 0, 10)));
$salu=$resrow["salu"];
$gname=$resrow["givenname"];
$sname=$resrow["surname"];
$seq=$resrow["v_uid"];
$mainvisatypename=get_parent_mainvisatype_name($resrow["visa_type"],$con);
$visa=get_visatype_name($resrow["visa_type"],$con);
$visafee=get_visa_fee($resrow["visa_type"],$con);
$total=$resrow["total_fee"];
$pass=$resrow["passport_no"];
$center=get_deliverycenter_name($resrow["deliverycenter"],$con);
$code=$resrow["refer_no"];

$countres = mysqli_query($con,"select app_id from  applicant_table where parent='$_GET[appid]'");
$child=mysqli_num_rows($countres);

/*
echo "<div class='mydiv'>";
echo "<div style='float:left'></div> 
	  <div  style='float:right'>".$date." (".$seq.")</div></div>";

echo "<div class='mydiv'>";
echo "<div style='float:left'>".$gname." ".$sname."</div> 
	  <div  style='float:right'></div></div>";	  

echo "<div class='mydiv'>";
echo "<div style='float:left'></div> 
	  <div  style='float:right'>".$center."</div></div>";	  

echo "<div class='mydiv'>";
echo "<div style='float:left'></div> 
	  <div  style='float:right; text-align:right;'>".$visa." / BDT ".number_format($total,2)."</div></div>";

echo "<div class='mydiv'>";
echo "<div style='float:left'><div id='passport' style='margin-left: -35px; margin-top: 30px; height:50px;'></div></div> 
	  <div  style='float:right'><div id='demo' style='style='float:right'></div></div></div>";	  
*/
for($i=0; $i<2;$i++){
echo "<table style='font-weight: bold; margin-bottom: 30px;' >
<tr><td>
<div style=' height:70px; width:300px;'>
		 <div id='demo".$i."' style='font-weight: bold;'></div>	
</div>
</td>
<td style='font-size:20px; font-family: Arial Black, Arial Bold; text-align: right;vertical-align: top;'>
<b ><span style=''> ".substr_replace($date,'',6,2)." &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp ".$seq."</span><br><br>(".($child+1).")&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp".$center."</b>	
            </td>
</tr>


<tr><td style='font-size:22px; font-family: Arial Black, Arial Bold; width:600px;' colspan='2'>

	".$salu." ".$gname." ".$sname."<br><span style='font-size:19px'>".$pass." / ".$mainvisatypename." ".$visa." / BDT ".number_format($visafee)."</span>
	</b>	
	
	</td></tr>

</table>";
?>
<script>
$("#demo<?php echo $i;?>").barcode(
//"DFF1234567890128", // Value barcode (dependent on the type of barcode)
"<?php echo $code; ?>",
"code128",
{barWidth:2, barHeight:50, fontSize: 22}

);  
</script>
<?php
}

$i=1;
$j=1;

if($child>0){

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

		$childres = mysqli_query($con,"select created_date, salu, surname, givenname, v_uid, visa_type,  total_fee, passport_no, deliverycenter, refer_no,  parent from applicant_table where app_id='$countrow[app_id]'");
		$childrow=mysqli_fetch_array($childres);
		
		$salu=$childrow["salu"];
        $gname=$childrow["givenname"];
        $sname=$childrow["surname"];
        $seq=$childrow["v_uid"];
        $mainvisatypename=get_parent_mainvisatype_name($childrow["visa_type"],$con);
        $visa=get_visatype_name($childrow["visa_type"],$con);
        $visafee=get_visa_fee($childrow["visa_type"],$con);
        $total=$childrow["total_fee"];
        $pass=$childrow["passport_no"];
        $center=get_deliverycenter_name($childrow["deliverycenter"],$con);
        $code=$childrow["refer_no"];
        
        for($i=0; $i<2;$i++){
            echo "<div style='height: 8px; '></div><table style='font-weight: bold; margin-bottom: 30px;' >
            <tr><td>
            <div style=' height:70px; width:300px;'>
            		 <div id='demo".$j.$i."' style='font-weight: bold;'></div>	
            </div>
            </td>
            <td style='font-size:20px; font-family: Arial Black, Arial Bold; text-align: right;vertical-align: top;'>
            <b ><span style=''> ".substr_replace($date,'',6,2)." &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp ".$seq."</span><br><br>(".($child+1).")&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp".$center."</b>	
            </td>
            </tr>
            
            
            <tr><td style='font-size:22px; font-family: Arial Black, Arial Bold; width:600px;' colspan='2'>
            
            	".$salu." ".$gname." ".$sname."<br><span style='font-size:19px'>".$pass." / ".$mainvisatypename." ".$visa." / BDT ".number_format($visafee)."</span>
            		
            	
            	</td></tr>
            
            </table>";
            ?>
            <script>
            $("#demo<?php echo $j.$i;?>").barcode(
            //"DFF1234567890128", // Value barcode (dependent on the type of barcode)
            "<?php echo $code; ?>",
            "code128",
            {barWidth:2, barHeight:50, fontSize: 22}
            
            );  
            </script>
            <?php
        }
        $j++;
	}
}
?>
