<?php    include('includes/AccountGroupMaster_Class.php');
 $table='cashbankvoucher';
$action=$_REQUEST['action'];
$daction=$_REQUEST['daction'];
$msgErr='';
$status=true;
$VPrefixName= $s->getField('voucher_master','VoucherType',$_REQUEST['VPrefix'],'VPrefix');;?>

<script language="javascript">
  $(function() {
    $(".button").click(function() {
     $('#myForm').submit();
    });
  });
  
function ShowDiv(str,hiddiv,url)
{
  if (str=="")
  {
  document.getElementById(hiddiv).innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(hiddiv).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET",url+"?q="+str,true);
xmlhttp.send();
}



 

 
 function getvocuher(str)
{
 if (str=="")
  {
  document.getElementById("voucher_code").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("voucher_code").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","GetBankPayment_Voucher.php?q="+str,true);
xmlhttp.send();

}
function selectDRCR(str)
{
if(str=='Dr'){
  	 document.getElementById("credit").disabled=true;
      document.getElementById("debit").disabled=false;
  }
 else{
  document.getElementById("debit").disabled=true;
   
    document.getElementById("credit").disabled=false;
   }
}
</script>
<script type="text/javascript">
function showLegder(str)
{
  if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","GetSubLedger.php?q="+str,true);
xmlhttp.send();
}
</script>
	<?php
 

 
		$id=$_REQUEST['voucherId'];
		$condition="B.voucherId='".$id."' and A.voucherMasterId='".$_REQUEST['TransId']."'";
	    // echo "select * from cashbankvoucher_master A,cashbankvoucher B where $condition ";
		$GetData=DB_query("select * from cashbankvoucher_master A,cashbankvoucher B where $condition ",$db);
		$RowData=DB_fetch_array($GetData);
		$BranchID=$RowData['BranchID'];
		$VoucherNo=$RowData['VoucherNo'];
		$voucher_code=$RowData['voucher_code'];
		$voucherdate=ConvertSQLDate($RowData['VDate']);
		$sub_ledger_id=$RowData['sub_ledger_id'];
		$ledger_id=$RowData['ledger_id'];
		$clientid=$RowData['clientid'];
		$dr_cr=$RowData['dr_cr'];
		$debit=$RowData['debit'];
		$credit=$RowData['credit'];
		$narration=$RowData['narration'];
		$Amount=$RowData['Amount'];
		$CaseBankId=$RowData['CaseBankId'];
		$cheque_no=$RowData['cheque_no'];
		
		 	$GetRecord1 = "Select id from cashbank_adjustment where TransId   ='".$_REQUEST['TransId']."' ";
    		 $ResultData1 = DB_query($GetRecord1,$db);
   		      while($RowData1 = DB_fetch_array($ResultData1)){
			   $adjustmentid[]=$RowData1['id'];
   	 	      }
		$adjustmentid=adjustmentid;
		//$cheque_no=$RowData['cheque_no'];
		//adjustmentid
		
	 
  



 ?><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td ><div align="right"><A HREF="javascript:history.go(-1)"> [Go Back]</A> </div></td>
  </tr>
</table>

<form action="" method="post" id="myForm">
<table width="60%" border="0" cellspacing="3" cellpadding="3" style="border:1px solid"> 
  <tr>
    <td colspan="2"><h1>
	<?php echo $fromtitle=  $s->getField('voucher_master','VoucherType',$_REQUEST['VPrefix'],'GroupName');
		echo "&nbsp;[".$VPrefixName."]&nbsp;";
	  ?> </h1></td>
  </tr>
  
  <?php if(isset($daction))
  {?>
    <tr>
     <td colspan="4" ><div class="success"><?php echo "Record ".$daction." Successfully" ?></div></td>
  </tr>
  <?php }
  if(isset($msgErr)&&$msgErr!='' )
   {?>
    <tr>
  
    <td colspan="4" ><div class="error"><?php 

for( $kp=0;$kp<count($msgErr);$kp++)
 {
		echo  '&nbsp;&nbsp; *'.$msgErr[$kp].'<br>';
 }
  ?></div></td>
  </tr>
  
   <?php }?>
   
   
  <tr>
    <td width="25%"><strong>BranchID</strong></td>
    <td width="33%">
 	<?php $_REQUEST['ledgid']=1;
  	$result_location = DB_query("SELECT prefix,locationname FROM  locations  WHERE prefix='".$BranchID."'",$db);
 			?>
 			 
 			<?php 			
 			while($myrow_location = DB_fetch_row($result_location))
			{
			  if($myrow_location[0]==$BranchID)
			 echo $myrow_location[1];
			}?>	  </td>
	 <td width="15%" ><strong>Date</strong></td>
	  <td width="27%" >
   
	  <?php echo $voucherdate;?>	</td>
  </tr>
  <tr>
     <td valign="top"><strong>Voucher No.</strong> </td>
     <td valign="top">
	<div id="voucher_code">
	<?php  echo $voucher_code;?> - 
 	<?php echo  $VoucherNo ;?> </div>	</td>
	<td ><strong>Cash/Bank</strong></td>
	 <td valign="top">
	
<?php 
  $GroupId=  $s->getFieldByCompanyId('accountgroupmaster','GroupName','CASH & BANK BALANCES ','GroupId',"CompanyId='".$_SESSION['ACGCompanyId']."'");

if($fromtitle=='Bank Payment' ||$fromtitle=='Bank Receipt'  )
{
	$result_bank = DB_query("SELECT B.AccountsID,B.AccountName from accountgroupmaster A ,accountledger B where A.GroupId=52 and B.UnderGroup=A.GroupId and  lower(B.AccountName)!='Cash In Hand' and A.CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
  }else{
	$result_bank = DB_query("SELECT  B.AccountsID,B.AccountName from accountgroupmaster A ,accountledger B where  A.GroupId=52 and  B.UnderGroup=A.GroupId  and lower(B.AccountName)='Cash In Hand' and A.CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
}	
  			while($myrow_bank = DB_fetch_row($result_bank))
			{
			  $p='';
			  if($myrow_bank[0]==$CaseBankId )
			 echo $myrow_bank[1];   }?>
				</td>
  </tr>
  
   <tr>
    <td colspan="4"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>  <td valign="top"><strong>Narration</strong></td>
     <td valign="top"><strong>Ledger Name</strong></td>
	
     <td valign="top"><b>
	<?php 
	    if($VPrefixName=='CP' || $VPrefixName=='CR')
			echo "Payee";
		else   if($VPrefixName=='BR'  || $VPrefixName=='BP')
			echo "Cheque No";
		?>		</b></td>
 
		 <td valign="top"><b>Amount</b></td>
	 
      
  </tr>
  <tr>  <td valign="top"> 
<?php echo $narration; ?></td>
     <td valign="top">
	<?php
		$result_ledger =DB_query("SELECT AccountsID,  AccountName   FROM accountledger  WHERE AccountsID='".$ledger_id."' and CompanyId='".$_SESSION['ACGCompanyId']."' order by AccountName ",$db );
		$myrow_ledger =DB_fetch_array($result_ledger)
   			?><?php echo $myrow_ledger['AccountName']; ?>
			
			<br /><br />
			
			
			<?php  if($clientid!='' && $clientid!=0){
			 
 			  $result_client = DB_query("SELECT A.c_name as AccountName,A.id as ACCID   FROM clientmaster A    where A.ledger_id='".$ledger_id ."' and A.CompanyId='".$_SESSION['ACGCompanyId']."'  and A.id='".$clientid."' ",$db);
 			  $myrow_client = DB_fetch_array($result_client);
			  if($myrow_client['AccountName']!=''){
  			 ?>
			<b>Client :</b>
			<div id="txtHint">
			 <?php echo $myrow_client['AccountName']; ?>
 			</div> <?php } ?>
			
			<?php } ?>
			</td>
     <td valign="top">
 <?php  echo $cheque_no ;?> 	 </td>
	 
     <td valign="top">
	 
	<?php  echo $Amount  ; ?>
 	</td> 
  </tr>
</table>     </td>
    </tr>
</table>
</form>
 

 
  