<?php include ("../../include/dbconnect.php");


?>
<title>Ledger Printing</title>
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
<body background="../../images/fibermat.gif">
<center>
<?

  foreach($_POST as $r=>$s)
  {
     $_POST[$r] = trim($s);
  }
  $myCompany = $_POST['Company'];


    
?>
<script type="text/javascript" src="../../include/datetimepicker.js"></script>
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
<title>Ledger</title>

<body style=" background:url(../../images/body_bg.jpg) repeat-x; font-family:Arial, Helvetica, sans-serif; font-size:12px;">
  <form name='myForm01' method='POST' action='<?=$_SERVER['PHP_SELF']?>'>

<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="50" colspan="2" align="center" style="font-size:27px; font-weight:bold; color:#FFFFFF">Welcome to Trial Balance  Printing</td>
  </tr>
  <tr>
    <td colspan="2" style="background:#DFEAEC; border:1px #67B15C solid; padding:20px;"><table width="700" border="0" align="center" cellpadding="0" cellspacing="0" style="background:#F1F1F1; border:1px #67B15C solid;">
      <tr>
        <td height="30" style="background:#BDE09E; text-indent:10px;"><span class="style1">Criteria Selection</span></td>
      </tr>
      <tr>
        <td width="372" align="center"><table width="328" height="196" align="center" cellpadding=4 cellspacing=4  >


<tr><td width="165" ><div align="left"><font face="Arial, Helvetica, sans-serif">Select Company</font>
</div></td>
<td width="562" colspan=2>  <SELECT name='Company'   onChange="javascript:submit();">

<?

$brQuery = mysqli_query($conn,"select distinct compcode,name from company order by name");
     echo "<option selected value=\" 0\"> Company";
    while($row = mysqli_fetch_row($brQuery))
    {

		$temp = $row[1];
        if(isset($myCompany) && preg_match("/" . preg_quote($myCompany, '/') . "/", $row[0]))
	    {
            echo "<option selected value=\"$row[0]\">$temp";
        }
        else{
            echo "<option value=\"$row[0]\">$temp";
        }
    }
?>
        </SELECT></td>
</tr>

</table>
</form>

<table cellpadding=0 cellspacing=4 width=590>

<form method="POST" name="regform" action="ledg_print.php" target="_blank">
<tr><td ><div align="right"><font face="Arial, Helvetica, sans-serif"><b>Select Account Head</b></font>
</div></td>
<td colspan=2>
<select name=acctcode[] size=10 multiple>
<?   
//$result=mysqli_query($conn,"(select distinct ledger.acctcode,acctmast.description from acctmast,ledger where ledger.acctcode = acctmast.acctcode and ledger.branch_code = '$myBranch' and compcode = '$myCompany' ) union (select distinct openbalance.acctcode,acctmast.description from acctmast,openbalance where openbalance.acctcode = acctmast.acctcode and openbalance.branch_code = '$myBranch') order by description")  or die(mysqli_error());
$result=mysqli_query($conn,"select acctmast.acctcode,acctmast.description 
from acctmast where acctcode in (select acctcode from ledger where  ledger.branch_code = '$myBranch' ) 
union select acctmast.acctcode,acctmast.description 
from acctmast where acctcode in (select acctcode from openbalance where  openbalance.branch_code = '$myBranch' ) order by description")  or die(mysqli_error());


      while ( $row= mysqli_fetch_row($result))
      {
          echo "<option value='$row[0]'>";
	  echo $row[1];
	  echo "\n";
      }
?>
</select></td></tr>


<SCRIPT LANGUAGE="JavaScript" src="../../include/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var cal = new CalendarPopup();
</SCRIPT>

		<tr > 


	<td width="367"  align="left"><div align="right"><font  face="Arial, Helvetica, sans-serif">Start   
	  Date &nbsp;</font> </div></td>
		<td width="357" class="small_site_font_black" > 
		<?
		$startdt = $mystartdt;
		//$startdt=strftime ("%d/%m/%Y", mktime(0,0,0,date("m"),date("d"),date("Y"))); ?>
		
		<input name="startdt"  type="text" onKeyPress="return event.keyCode!=13"  class="text_box_button" value="<?=$startdt?>" size="10" > 
		<a href="#" onClick="cal.select(document.regform.startdt,'anchor1','dd/MM/yyyy'); return false;"name="anchor1" id="anchor1"><img  src="../../images/cal.gif" border="0"></a>		</td>
		</tr>
		

		<tr > 


	<td width="367"  align="left"><div align="right"><font  face="Arial, Helvetica, sans-serif">End   
	  Date &nbsp;</font> </div></td>
		<td width="357" class="small_site_font_black" > 
		<?
		
		$enddt=strftime ("%d/%m/%Y", mktime(0,0,0,date("m"),date("d"),date("Y"))); ?>
		<input name="enddt"  type="text" onKeyPress="return event.keyCode!=13"  class="text_box_button" value="<?=$enddt?>" size="10" > 
		<a href="#" onClick="cal.select(document.regform.enddt,'anchor1','dd/MM/yyyy'); return false;"name="anchor1" id="anchor1"><img  src="../../images/cal.gif" border="0"></a>		</td>
		</tr>		


<tr> 
	<td width="367"  align="left"><div align="right"><font  face="Arial, Helvetica, sans-serif">Starting   
	  Page No(Print purpose) &nbsp;</font> </div></td>
		<td width="357" class="small_site_font_black" > 
		<input type="text" name="page_no" value="1"></td></tr>
		
		<tr > 


	<td width="367"  align="left"><div align="right"><font  face="Arial, Helvetica, sans-serif">Accounting Year &nbsp;</font> </div></td>
		<td width="357" class="small_site_font_black" > 		
		
<?
	$result = mysqli_query($conn,"select distinct account_year from ledger order by account_year desc ") or die(mysqli_error());
	?>
	<select name="account_year">
	<?
	while($row = mysqli_fetch_row($result))
	{
          echo "<option value='$row[0]'>";
	  echo $row[0];
	  echo "\n";	
	}
?>
</select>
</td></tr>
<?

?>
<input type="hidden" name="compcode" value="<?=$myCompany?>">

<input  type="hidden" name="tfile" value="<?=$tfile?>">
<tr>
<td colspan="2" align="center">
 <blockquote>  <input type =submit name=submit value = "Submit"></blockquote>
</table>




                                                                             
</body>
</form>
