<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
include("test.php");
include("opendb.php");
include("includes/function.php");
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='index.php' </script>";
  return;
}

$inno=$_REQUEST[inno];
$jtype=$_REQUEST[jtype];
$company=mysqli_query($db,"select * from branch where brcode='$brcode'")or die(mysqli_error($db));
$company1=mysqli_fetch_row($company);

$addr= "PSN AUTOMOTIVE MARKETING P LTD";
$add1=$company1[3];
$cont='Tel:'.$company1[5];
$add2=$company1[4];

$tran=mysqli_query($db,"select * from journal2  where brcode='$brcode' and j_type='$jtype' and tr_no='$inno' ")or die(mysqli_error($db));
$tran1=mysqli_fetch_row($tran);
if ($jtype=='CR')
{
$tran2=mysqli_query($db,"select * from journal2  where brcode='$brcode' and jvno='$tran1[1]' and type='Cr'")or die(mysqli_error($db));
}

if ($jtype=='BR')
{
$tran2=mysqli_query($db,"select * from journal2  where brcode='$brcode' and jvno='$tran1[1]' and type='Cr'")or die(mysqli_error($db));
}


$tran3=mysqli_fetch_row($tran2);

 $amount=explode('.', $tran3[5]);

 

?>
<html>
 <head>

<script type="text/javascript" src="number_to_word.js"></script>
 <style>

body {
   
   // background-color: #404040;
    //background-image: url(images/texture.png);
background-repeat: no-repeat;
}
  .conts{

   border:0px solid black;
   margin-left:0px
   margin-right:0px;
  vertical-align:bottom;
   }  
 .conts1{
 
   border:0px solid black;
   border-bottom:1px solid black;
   border-style:dotted;
   margin-left:0px
   margin-right:0px;
   vertical-align:bottom;
   min-width:600px;
  }

  .cshtot table, td,th {
  width :90px;
  height:30px;
  bordre:1px solid black;
  border-collapse:collapse;
  }
 p{

  margin:0px;
  padding:0px;
 }

</style>

</head>
<body >
<br>
<center>
<table  border=0 align=center>
 <tr>
   <td align=center colspan=3><img src='images1/shared/logo.jpg' ></TD>
 </TR>
<tr>
   <td align=center colspan=3><?print $addr?> </TD>
 </TR>
<tr>
   <td align=center colspan=3><?print $add1?> </TD>
 </TR>
<tr>
   <td align=center colspan=3><?print $cont?>-<?print $add2?> </TD>
 </TR>
 <tr> 
   <td style="width:30%";>
<!--
    <?

  
       print "<p>".$add1."</p>";
       print "<p>".$cont."</p>";
        print "<p>".$add2."</p>	";

     ?>
-->
   </td>
<?
if ($jtype=='CR')
{
?>
   <td align='center' valign='bottom' style="width:40%";><h3><u>Cash Receipt Voucher</u></h3></td>
<?
}
?>

<?
if ($jtype=='BR')
{
?>
   <td align='center' valign='bottom' style="width:40%";><h3><u>Bank Receipt Voucher</u></h3></td>
<?
}
?>


   <td align='right' style="width:30%";>
       <!--<p>address in arabic ..</p>
       <p>address in arabic ..</p>
       <p>address in arabic ..</p>
       <p>address in arabic ..</p>--></td>

   </tr>

   <tr>
     <td><b>No:<?echo $inno; ?></td>
     <td align=right colspan=2><b>Date:<u style='border-bottom: 1px dashed #000; text-decoration: none;' ><? echo month_alph($tran1[0]); ?></u></TD>
   </TR>    
   <tr>

     <td colspan=3>
  

  
   <table border=1 id='main' align='center'  style='border-collapse:collapse;' width=100%>
   <tr>
      <td class='conts' ><i>Received&nbsp;From&nbsp;Mr/Messrs&nbsp;</i></td><td class='conts1' ><? echo $tran3[3]; ?></td><td class='conts' ></td>

   </tr>
    <tr>
      <td class='conts' ><i>The&nbsp;Sum&nbsp;Of</i></td><td class='conts1'><? print "<script>document.write(toWords($tran3[5]));</script> only"; ?></td><td class='conts' ></td>

   </tr>
      <tr>
      <td class='conts' ><i>For</i></td><td class='conts1' ><? echo $tran1[6]; ?></td><td class='conts' ></td>

   </tr>
      <tr>
<?
if ($jtype=='CR')
{
?>
      <td class='conts' ><i>By&nbsp;Cash</i></td><td class='conts1' >Cash</td><td class='conts' ></td>
<?
}
?>
<?
if ($jtype=='BR')
{
?>
      <td class='conts' ><i>By&nbsp;Cheque</i></td><td class='conts1' >Cheque (<?print $tran3[10]?>)</td><td class='conts' ></td>
<?
}
?>

   </tr>
      <tr>
      <td class='conts1' colspan=3></td>

   </tr>
  <tr>
     <td colspan=3 align='right' class='conts' style="height:120px;">
     
        <table class='cshtot' border=1 style="border-collapse:collapse; height:90px;" >
          <tr>
             <tH>Rs.</TH><th>Ps.</td>
          </tr>

         <tr>
             <td align=center><? echo $amount[0]; ?></td>
             <td align=center>
              <? 
   
                  echo $amount[1];

              ?>
             </td>

         </tr>

   

        </table>

   <tr>
       <td colspan=3 class='conts' >

          <table border=1 style='border-collapse:collapse;' width=100%> 
            <tr>
       

      	       <td valign='middle' align='right' >For PSN AUTOMOTIVE MARKETING P LTD<br><br><br>Authorised Signatory</td>
          </tr>

       </table>

 </tr>

 </table>
 </td>
 </tr>
</table>

</body>
</html>