<?php //error_reporting(0);
$PageSecurity = 3;
 include ('includes/session.inc');
  include ('includes/function_lib.php');
 global $db;
 include('includes/Class_Branch.php');
	include('includes/AccountGroupMaster_Class.php');
 
	$modid=$_REQUEST['modid'];
	$frmid=$_REQUEST['frmid'];
	$rurl="&modid=".$modid."&frmid=".$frmid;
	setlocale(LC_MONETARY, 'en_IN');
?>	 
<?php
   echo '<link href="'.$rootpath. '/css/'. $_SESSION['Theme'] .'/default1.css" rel="stylesheet" type="text/css" />';
   $BillBookType=  $s->getField('voucher_master','VoucherType',$_REQUEST['VPrefix'],'VPrefix');

   $query="select *  from account_book  where id='".$_REQUEST['id']."' ";
   	$result=DB_query($query,$db);
		$i=1;
		if(DB_num_rows($result)>0)
		{
			while($myrow=DB_fetch_array($result))
			{
			$voucher_no=$myrow['Voucher_NO'];
			$Dates=$myrow['Dates'];
			  $Ref_no=$myrow['Ref_no'];
			$voucher_no=$myrow['Voucher_NO'];			
			$narration=trim($myrow['narration']);
			$document_type=trim($myrow['document_type']);
			
			
			
			 $transation_type=$myrow['transation_type'];
			$Branch=$myrow['Branch'];
 		 	$banks_checkno=$myrow['banks_checkno'];
			// $myrow['banks_checkdate'];
			$banks_checkdate=$myrow['banks_checkdate'];
			$banks_receivedfrom=$myrow['banks_receivedfrom'];
			$favouring_name=$myrow['favouring_name'];
			$cross_inst=$myrow['cross_inst'];			
 			$deposit_vouchertype=$myrow['deposit_vouchertype'];
			$dcrno=$myrow['dcrno'];
			$deposit_voucherdate=ConvertSQLDate($myrow['deposit_voucherdate']);
			$depositedby=$myrow['depositedby'];
$Compamies=DB_query("select * from companies",$db);
$CompamiesRow=DB_fetch_array($Compamies);
$sql1 = "SELECT * FROM companies where CompanyId='".$_SESSION['ACGCompanyId']."'";
  $sqlres = DB_query($sql1,$db);
  $companyRow = DB_fetch_array($sqlres);
  $s=new db_query(); 
	 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
  <title>Stock Ledger Register</title>

<style type="text/css" media="print">
  @page port {size: portrait;}
@page land {size: landscape;}
 .portrait {page: port;}
.wrapper {page: land;}

</style>

<style type="text/css"> 
@print {size: portrait; margin:10px;}


@media print{
body{ margin:0px; padding:0px;  font-size:12px; line-height: 18px; font-family: Arial, Helvetica, sans-serif; color:#000; font-weight:normal;}

h1,h2,h3,h4,h5,p{ margin:0px; padding:0px;}
p{ text-align:left;}

h1{
  font-size: 20px; line-height: 24px;
  font-weight:normal;
  font-family:Arial, Helvetica, sans-serif !important;
}
h2{
  font-size: 18px; line-height: 22px;
  font-weight:normal;
  font-family:Arial, Helvetica, sans-serif !important;
}
thead{display: table-header-group;}
.wrapper{width:99%; height: auto; float:left; border:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_first, .div_first .full{
  width: 100%; height: auto;
  /*border-bottom: #000000 1px solid;
  border-top: #000000 1px solid;*/
  /*border-left: #000000 1px solid;
  border-right: #000000 1px solid;*/
  float: left; position: relative;
}
 .div_first .left
 {
    width:18%; text-align:left; height:auto; vertical-align:middle; height:auto; padding: 1%; float:left;
  }
  .div_first .middle
  {
    width:58%; text-align:center; padding: 1%; margin:0 auto; float: left;
  }
  .div_first .right
  {
    width:18%; text-align:right; padding: 1%; float: left;
  }

.div_first .full{text-align: center; border: 0;}
.div_second, .div_third{
  width: 100%;
  height:auto;
  /*border-top: #000000 1px solid;*/
  /*border-bottom: #000000 1px solid;*/
  /*border-left: #000000 1px solid;
  border-right: #000000 1px solid;*/
  float: left;
}
.div_second table tr th, .div_second table tr td{border-right:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_second table tr th{text-align: left; border-top:#000000 1px solid;}
.div_second table tr th:last-child, .div_second table tr td:last-child{border-right:0;}
.div_second table tr:last-child td{border-bottom:0;}
.div_second table tr td > table tr td{border-right:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_second table tr td > table tr td:last-child{border-right:0;}
.div_second table tr td > table tr:last-child td{border-bottom:0;}

.div_third table tr th, .div_third table tr td{ border-bottom:#000 1px solid; border-right:#000 1px solid;}
.div_third table tr th{background-color:transparent; text-align: left;}
.div_third table tr th:last-child, .div_third table tr td:last-child{border-right:none;}
.div_third table tr:last-child td{border-bottom:none;}

.f12{ font-weight: bold; color:#000; font-size:12px;}
.f11{color:#000; font-size:12px; line-height:18px;}
.f14{color:#000; font-size:18px;}
.mt26{margin-top:4px; width:90%;}
.mt27{margin-top:0px; width:90%;}
.mt28{margin-top:0px; width:100%;}
.border_top{border-top:#000 1px solid;}
.border_bottom{border-bottom:#000 1px solid;}
.wdt1{width:8%;}
.wdt2{width:100px;}
.wdt3{width: 66px;}
.wdt4{width: 80px;}
.wdt5{width: 52px;}
.wdt6{width: 60px;}
}

@media screen{
/* CSS Document */
body{ margin:0px; padding:0px; background-color:#fff; font-size:12px; font-family: Arial, Helvetica, sans-serif; color:#000; font-weight:normal;}
h1,h2,h3,h4,h5,p{ margin:0px; padding:0px;}
p{ text-align:left;}

#foo{width:1070px; height: auto; margin:0px auto;}
.wrapper{width:1070px; height: auto; margin:10px auto; border-top:#000000 1px solid;}

h1{
  font-size: 24px; line-height: 28px;
  font-weight:bold;
  font-family:Arial, Helvetica, sans-serif !important;
}
h2{
  font-size: 18px; line-height: 22px;
  font-weight:normal;
  font-family:Arial, Helvetica, sans-serif !important;  
}
.div_first, .div_first .full{
  width: 100%; height: auto;
  /*border-bottom: #000000 1px solid;
  border-top: #000000 1px solid;*/
  border-left: #000000 1px solid;
  border-right: #000000 1px solid;
  float: left; position: relative; display: table;
}
.div_first .full{text-align: center; border: 0; margin:10px 0 0;}
.div_first .left, .div_first .middle, .div_first .right{float: left; display: table-cell; vertical-align: middle;}
.div_first .left
{
  width:18%; text-align:center; height:auto; vertical-align:middle; padding: 1%; 
}
.div_first .middle
{
  width:58%; text-align:center; padding: 1%; position: relative; margin:0 auto;
}
.div_first .right
{
  width:18%; text-align:center; padding:1%; 
}
.div_second, .div_third, .div_forth, .div_fifth{
  width: 100%; height: auto;
  /*border-bottom: #000000 1px solid;*/
  border-top: #000000 1px solid;
  border-left: #000000 1px solid;
  border-right: #000000 1px solid;
  float: left;
}
.div_fifth{border-bottom:#000000 1px solid;}

.div_second table tr th, .div_second table tr td{border-right:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_second table tr th{background-color: #ccc; text-align: left;}
.div_second table tr th:last-child, .div_second table tr td:last-child{border-right:0;}
.div_second table tr:last-child td{border-bottom:0;}
.div_second table tr td > table tr td{border-right:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_second table tr td > table tr td:last-child{border-right:0;}
.div_second table tr td > table tr:last-child td{border-bottom:0;}

.div_third table tr th, .div_third table tr td, .div_forth table tr th, .div_forth table tr td{ border-bottom:#000 1px solid; border-right:#000 1px solid;}
.div_third table tr th{background-color: #ccc; text-align: left;}
.div_third table tr th:last-child, .div_third table tr td:last-child, .div_forth table tr th:last-child, .div_forth table tr td:last-child{border-right:none;}
.div_third table tr:last-child td, .div_forth table tr:last-child td{border-bottom:none;}

.f12{font-weight: bold; color:#000; font-size:12px;}
.f11{ color:#000; font-size:12px; line-height:18px;}
.f14{ color:#000; font-size:18px;}
.mt26{margin-top:4px; width:90%;}
.mt27{margin-top:0px; width:100%;}
.mt28{margin-top:0px; width:90%;}
.border_top{border-top:#000 1px solid;}
.border_bottom{border-bottom:#000 1px solid;}
.wdt1{width:10%;}
.wdt2{width:180px;}
.wdt3{width: 66px;}
.wdt4{width: 120px;}
.wdt5{width: 52px;}
.wdt6{width: 70px;}
}
</style>

 </head>
 <body>
<div id="foo">
  <p style="text-align:right;"><input type="button" onclick="javascript:toggle_visibility('foo');" value="Print" /></p>
</div>

<div class="wrapper">
<div class="div_first">
<?php $logoImage=($CompamiesRow['CompanyLogo']=='')?'Final_Logo_RM.png':$CompamiesRow['CompanyLogo']; 
 $sql1 = DB_fetch_array(DB_query("SELECT CompanyName FROM companies where CompanyId='".$_SESSION['ACGCompanyId']."'",$db)); ?>
      <div class="left"><img src="Setup/CompanyLogo/<?php echo $logoImage;  ?>" class="mt26" /></div>
      <div class="middle"><?php 
    if($CompamiesRow['CompanyName']!="") {echo "<h1>".$CompamiesRow['CompanyName']."</h1>"; } else { echo "";}
    
    if($InoRow['deladd1']!="") { echo $InoRow['deladd1']; } else { echo "";}
    if($InoRow['deladd2']!="") { echo ", ". $InoRow['deladd2']; } else { echo "";}
    if($InoRow['deladd3']!="") { echo ", ". $InoRow['deladd3']; } else { echo "";}
    if($InoRow['city']!="") { echo ", ". $s->getFieldValue("city_master", "id='".$InoRow['city']."'", "city"); } else { echo "";}
    if($InoRow['pincode']!="") { echo " - ".$InoRow['pincode']; } else { echo "";}
    if($InoRow['state']!="") { echo ", ". $s->getFieldValue("state_master", "id='".$InoRow['state']."'", "state"); } else { echo "";}
    if($InoRow['country']!="") { echo ", ". $s->getFieldValue("country_master", "id='".$InoRow['country']."'", "country");
    
     } else { echo "";}
    ?>
     <div class="full"><span class="f11"><?php echo "Phone No.:".$CompamiesRow['Phone'].",   Fax No.: ".$CompamiesRow['fax'].", Email ID.: ".$CompamiesRow['email'].",   Website: ".$CompamiesRow['website']; ?><br>
  <?php  echo $_SESSION['mess1']; ?>
  </span></div>
    <h2><?php echo $fromtitle=  $s->getField('voucher_master','VoucherType',$_REQUEST['VPrefix'],'GroupName'); ?></h2>
      </div>
      <div class="right"></div>
</div>
<div class="div_second">
	<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td class="f12">Branch</td>
    <td class="f11"><?php 	echo $s->getField('locations','loccode',$myrow['Branch'],'locationname');?></td>
    <td class="f12">Voucher No. </td>
    <td class="f11"><?php echo $voucher_no;?></td>
  </tr>
  <tr>
    <td class="f12">Date</td>
    <td class="f11"><?php echo ConvertSQLDate($Dates);?></td>
    <td class="f12">Ref. No.</td>
    <td class="f11"><?php echo $Ref_no;?></td>
  </tr>
  <?php  if($BillBookType=='JV'){?>
 <tr bgcolor="#FFFFFF">
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td class="f12">Document </td>
    <td class="f11"><input name="document_type" type="text"   value="<?php echo $document_type;?>"   style="width:98%"/></td>
	</tr>
	<?php }?>
</table>

    </div>
    <div class="div_third">
    	<table width="100%" border="0" cellspacing="0" cellpadding="3">
  	  <tr class="f12">
  	    <th>Ledger Name</th>
  	    <th>Debit</th>
  	    <th>Credit</th> 
   	    </tr>
		<?php 
		 
		$total_cr=array();$total_dr=array();
	   $query1="select *  from account_book_details where account_bookid ='".$myrow['id']."'  ";
   		$result1=DB_query($query1,$db);
			while($myrow1=DB_fetch_array($result1))
			{
 
//foreach ($_SESSION['ACGLedgerId'] as $i => $LED)
 
		//  for($i=0;$i<count($_SESSION['ACGLedgerId']);$i++)
		 
		?>
  	  <tr class="f11">
  	    <td><?php  //echo $i;?> <?php  echo $s->getField('accountledger','AccountsID',$myrow1['ledgerid'],'AccountName');;?></td>
  	    <td><?php  echo  money_format('%!i',($myrow1['amount_type']=='DR'? $myrow1['amount']:"0"));
		 $total_dr[]=($myrow1['amount_type']=='DR'? $myrow1['amount']:"0");
		 ?></td>  	    
  	    <td><?php
		echo money_format('%!i',($myrow1['amount_type']=='CR'? $myrow1['amount']:"0"));
		$total_cr[]=($myrow1['amount_type']=='CR'? $myrow1['amount']:"0");		
		?></td>	 
  	  </tr>
		<?php 
}		
		?>  	   
	  </table>
    </div>
    <div class="div_forth" >
    
	<h2 style="border-bottom:#000 1px solid; padding:3px;" class="f12">Bank / Cheque Details</h2>
 	<table width="100%" cellpadding="3" cellspacing="0" border="0">	 
 	<tr>
	   <td width="13%" class="f12">Transaction Type</td>
    <td width="20%" class="f11"><?php echo $s->getField('conf_bank_master','id',$transation_type,'bank_name'); //echo $transation_type; ?></td>
    <td width="13%" class="f12">Instrument No.</td>
    <td width="20%" class="f11"><?php echo $banks_checkno; ?></td>
    <td width="13%" class="f12">Instrument Date</td>
    <td class="f11"><?php if($banks_checkdate!='0000-00-00') { echo ConvertSQLDate($banks_checkdate); } else { echo ''; }   ?></td>   

   
  </tr>
 <!-- 	<tr>
	 <td class="f12">Received From</td>
     <td class="f11"><?php echo ($banks_receivedfrom!=''?$banks_receivedfrom:'') ; ?></td>   
 	  <td class="f12">Favouring name</td>
 	  <td class="f11"><?php echo $favouring_name; ?></td>
 	  <td class="f12">CSross inst</td>
 	  <td class="f11"><?php echo $cross_inst; ?></td>
 	 </tr> -->
  </table>
  
  <?php if($deposit_vouchertype!==''){?>
  <!-- <h2 style="border-bottom:#000 1px solid; padding:3px;"> Deposit Voucher Type </h2>

 	<table width="100%"  border="0" cellspacing="2" >	 
 	<tr>
    <td>Voucher Type</td>
    <td><?php echo $deposit_vouchertype?></td>
    <td>DCR No.</td>
    <td><?php echo $dcrno; ?></td>   
    </tr>
 	<tr>
 	  <td>Date</td>
 	  <td><?php echo $deposit_voucherdate; ?></td>
 	  <td>Deposited By</td>
 	  <td><?php echo $depositedby; ?></td>
 	  </tr>
  </table>  -->
  <?php } ?>
    </div>
    <br />

    <div class="div_forth" style="border-top:#000 1px solid;">
    	<table width="100%" cellpadding="5" cellspacing="0" border="0">
      <tr bgcolor="#fff">
    	<td width="13%" class="f12">Total Credit Amt.</td>
    	<td width="20%" class="f11"><?php echo money_format('%!i',array_sum($total_cr)); $totalCR =array_sum($total_cr); ?></td>
    	<td width="13%" class="f12">Total Debit Amt.</td>
    	<td class="f11" width="20%"><?php echo money_format('%!i',array_sum($total_dr)); $totalDR=array_sum($total_dr); ?></td>
    	<td class="f12" width="13%">Difference Amt.</td>
    	<td class="f11"><?php echo money_format('%!i',$totalCR-$totalDR); ?></td>
  	  </tr>
  	<tr>
    	<td class="f12">Narration</td>
    	<td colspan="5" class="f11"><?php echo $narration;?> </td>
    </tr>
  		</table>
    </div>
    <div class="div_fifth">
    	<table width="100%" cellpadding="3" cellspacing="0">
    	<tr>
	   		<td height="80" valign="bottom" width="33%" class="f12">Signature</td>
            <td height="50" valign="bottom" width="33%" class="f12" style="text-align:center;">Approved By</td>
   		  <td valign="bottom" align="right" class="f12" style="text-align:right;">Authorised Signature</td>
	    </tr>
        </table>
    </div>
</div>
</div>
			   <?php 
			}
			}
?>