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

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

  foreach($_POST as $r=>$s)
  {
     $_POST[$r] = trim($s);
  }
  $myBranch = $_POST['Branch'];
    
?>
<script type="text/javascript" src="../../include/datetimepicker.js"></script>

<title>Trial Balance  Printing</title>
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
<body style=" background:url(../../images/body_bg.jpg) repeat-x; font-family:Arial, Helvetica, sans-serif; font-size:12px;">
<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="987" height="196" align="center" cellpadding=4 cellspacing=4  >
  <form name='myForm01' method='POST' action='<?=$_SERVER['PHP_SELF']?>'>


<tr><td ><div align="left"><font face="Arial, Helvetica, sans-serif">Select Company</font>
</div></td>
<td 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>

<?
$brQuery = mysqli_query($conn,"select distinct code,name from branches where compcode = '$myCompany' order by name");
?>
	<tr><td ><div align="left"><font face="Arial, Helvetica, sans-serif">Select Profit Centre</font>
        </div></td><td>

  <SELECT name='Branch'   onChange="javascript:submit();">

<?

	      echo "<option selected value=\" ALL\"> ALL";
    while($row = mysqli_fetch_row($brQuery))
    {

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


<form method="POST" name="regform" action="trial_print.php" target="_blank">
  <div align="left"></div>






<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">Seperate Opening Balance &nbsp;</font> </div></td>
		<td><input type="checkbox" name="opdiff" value="Yes"></td></tr>

		<tr > 
		<tr > 


	<td width="367"  align="left"><div align="left"><font  face="Arial, Helvetica, sans-serif">Date &nbsp;</font> </div></td>
		<td width="357" class="small_site_font_black" > 
       <input name="enddt"  id="enddt" value="<?=$enddt?>" type="text" size="10">
<a href="javascript:NewCal('enddt','DDMMYYYY')"><img
 src="../../images/cal.gif" alt="Pick a date" 
border="0"></a> 	</td>
		</tr>		
        
        
        
		<tr > 


	<td width="367"  align="left"><div align="left"><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="branch" value="<?=$myBranch?>">		
	
<tr>
<td colspan="2" align="center">
 <blockquote>  <input type =submit name=submit value = "Submit" style="background:#4B6A65; font-size:12px; font-weight:bold; padding:3px 6px 3px 6px; color:#FFFFFF; cursor:pointer; border:0px;font-family:Arial, Helvetica, sans-serif"></blockquote>

</table>





                                                                             
</body>
</form>
