<link href="printline.css" type="text/css" rel="stylesheet" media="print,screen"  />


<?
session_start();
include("opendb.php");
$brcode = $_SESSION['brcode'];
if(strlen($brcode)<=0)
{
    print "<script> alert('Invalid User'); parent.document.location='ind.php' </script>";
    return;
}
include("test.php");
$df=$_REQUEST['df'];
$dt=$_REQUEST['dt'];
?>
<style>
td{font-family:verdana;font-size:14;color:black;}
th{font-family:verdana;font-size:14;color:white;background-color:white}
 

body{background-color:white;}
select
  {border-style:ridge;
   border-color:black;
   height:25px;
   border-size=1;
   font-family:fixed;
   color:black;
  }
input
 {border-style:ridge;
   border-color:#22437f;
   background-color:white;
   height:25px;
   font-weight:bold;
   border-size=1;
   font-family:sans-serif;
   color:BLACK;
  }
</style>
<center>
 
<font face=fixed size=4>
<? print $branch?><br>
Debit debtors 
<table bgcolor=ivory cellpadding=1 cellspacing=1 width=100% class="grid">
<tr bgcolor='silver'><td width=90><center><b>Debtors</td> <td><center><b>Amount</td> <td width=100><center><b>PlantCode</td><td>Transactions</td>
<?


$result1=mysqli_query($db,"select * from ledger where op>0  and grp='Sundry Debtors' order by brcode,led ")or die(mysqli_error($db));
$head=1;
while($row1=mysqli_fetch_array($result1))
{
$ssq="select sum(dramt)-sum(cramt) from journal2 where brcode='$row1[$brcode]'  and (partic='$row1[led]')";
$res2=mysqli_query($db,$ssq)or die('jour err:'.mysqli_error($db));
$r2=mysqli_fetch_row($res2);
 
 if(mysqli_num_rows($res2)>0)
 {
    
    
     print "<tr><td>$row1[led]</td><td>$row1[op]</td><td>$row1[brcode]</td><td>$r2[0]</td><td>ok</td></tr>";
 }
 else
 {
      print "<tr><td>$row1[led]</td><td>$row1[op]</td><td>$row1[brcode]</td><td>$r2[0]</td><td>noook</td></tr>";
 }
/* 
 if($r2[0]<=0)  
 {
 print "<tr><td>$row1[led]</td><td>$row1[op]</td><td>$row1[brcode]</td><td>$r2[0]</td></tr>";
     
 }
*/
}
    



	


