<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
include("../opendb.php");

if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../inde.php'; </script>";
 return;
}

?>
<html>
 <head>
<?


$re=mysqli_query($db,"select distinct jvno,j_type from journal2 where brcode='$brcode' and jvno='$jvno'  ");
print"<hr>";
$row1=mysqli_fetch_row($re);
//print $row1[1];
switch ($row1[1])
{
case 'BR':
$jtype="Bank Receipt";
break;

case 'BP':
$jtype="Bank Payment";
break;

case 'CR':
$jtype="Cash Receipt";
break;

case 'CP':
$jtype="Cash Payment";
break;

case 'JV':
$jtype="Journal Voucher";

//print $jtype;
break;

case 'V sale':
$jtype="Vehicle Sale";
break;
case 'V pur':
$jtype="Vehicle Purchase";
break;
case 'TDSJV':
$jtype="TDS Journal";
break;
case 'I pur':
$jtype="Item Purchase";
break;

case 'P Ret':
$jtype="Purchase Return";
break;

case 'sale ret':
$jtype="Sales Return";
break;


default:

print "";

}








$company=mysqli_query($db,"select * from company_master  where brcode='$brcode'")or die(mysqli_error($db));
$company1=mysqli_fetch_row($company);

$add =explode(",", $company1[4]);
$add1=$company1[5];
$cont='Tel:'.$company1[7].",".'Fax:'.$company1[8];
$add2=$company1[6];

//$tran=mysqli_query($db,"select * from cshrec  where brcode='$brcode' and crno='$crno' ")or die(mysqli_error($db));
//$tran1=mysqli_fetch_row($tran);

// $amount=explode('.', $tran1[5]);
?>
 


<script type="text/javascript" src="../number_to_word.js"></script>
 <style>
  .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;
 }
#add_td{
font-size:12px;
height:15px;
}
#add_td br{
margin:0px;
padding:0px;
}
</style>

</head>
<body onload='window.print();'>
<br>
<center>
<table border='0' width='100%'>
     
         
           
	<tr>
	<td align='left' width='60%' id='add_td'> 
<?

	$qry1=mysqli_query($db,"select * from company_master where brcode='$brcode'");
	$row1=mysqli_fetch_array($qry1);
	 print "<font size='2'><b>".$row1[2]."</b></font><p >".$row1[4].", ".$row1[5].",".$row1[6];
	if(($row1[7]>0)&&($row1[7]!=''))
   		 print "</p><p>Tel: ".$row1[7];
 	if(($row1[8]>0)&&($row1[8]!=''))
  		 print " Fax: ".$row1[8];
	print "</p><p>Email: ".$row1[10];
	if($row1[11]!='')
		print ",".$row1[11]."<br>Web: ".$row1[12];
	else
		print "</p><p>Web: ".$row1[12];
?>
	</td>

	<td align='right'  width='40%'> <img src="../images/logo.gif" width="60" height="60" /> </td></tr></table>
       <br>
	<table border='1' width='100%' style='border-collapse:collapse;'><tr>
	<th  align='center'  width='100%' style='border:0px solid white;height:20px;font-size:18px;' id='head'><? echo $jtype;?></th></tr></table>
<table  border=0 align=center width='60%'>



   <tr>
     <td><b>No:<?echo $jvno; ?></td>
<?

//print $row1[1];
$re=mysqli_query($db,"select * from journal2 where brcode='$brcode' and jvno='$jvno' and type='Dr'");
$row=mysqli_fetch_array($re);
$amount=explode('.', $row[4]);
?>
     <td align=right colspan=2><b>Date:<u style='border-bottom: 1px dashed #000; text-decoration: none;' ><? echo month_alph($row[date]); ?></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>Payment&nbsp;made&nbsp;to&nbsp;M/s</i></td><td class='conts1' ><? echo $row[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($row[4]));</script> only"; ?></td><td class='conts' ></td>

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

   </tr>
      <tr>
      <td class='conts' ><i>By&nbsp;Cash/Cheque</i></td><td class='conts1' >Cash</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 colspan=2>Total</th>
          </tr>

         <tr>
             <td><? echo $amount[0]; ?></td>
             <td>
              <? 
   
                  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='center' style='height:120px;'>General Manager<br>...................</td>

       	<td valign='middle' align='center' >Accountant<br>...................</td>

      	       <td valign='middle' align='center' >Receiver<br>...................</td>
          </tr>

       </table>

 </tr>

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

</body>
</html>
  

     

  

