<link href="css/form.css" type="text/css" rel="stylesheet" media="screen"  />
<html>
<body >

<?
session_start();
if(strlen($user)<=0)
{
 print "<script> alert('You are not logged in') </script>";
 include("logout.php");
 return;
}

include("opendb.php");
include("test.php");

$re=mysqli_query($db,"select distinct(brcode) from customer order by brcode")or die(mysqli_error($db));
$i=1;





while($row=mysqli_fetch_array($re))
{

$br_det=mysqli_query($db,"select brcode,brstate,brname from branch where brcode = '$brcode'");
$br_info1=mysqli_fetch_array($br_det);
$br_det1=mysqli_query($db,"select brcode,brstate,brname from branch where brcode = '$row[brcode]'");
$br_info11=mysqli_fetch_array($br_det1);

if($br_info1[1]==$br_info11[1])
{


$re1=mysqli_query($db,"select * from customer where brcode='$row[brcode]' and cramt>0 order by acname")or die(mysqli_error($db));
$i=1;
if(mysqli_num_rows($re1)>0)
{




?>
<title>PSN Telcon</title>
    <script type="text/javascript" src="scripts/jquery-latest.js"></script>
	<link type="text/css" href="includes/style1.css" rel="stylesheet" />
	<link href="css/form.css" type="text/css" rel="stylesheet" media="screen" />
    <script type="text/javascript">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });        
    </script>
<body background="back_ground.jpg">
<?php include('logo1.php'); ?>
<?php include('includes/top.php'); ?>

<br>
<table class="container"><tr><td>
<table border=1 cellspacing=1 cellpadding=3 class='report'>
<th>No. <th>Name <th>A/C Name<th>Dist <th>State <th>Cramt<th>Crdays<th>Branch<th>LedgerBalance
<?

while($row1=mysqli_fetch_array($re1))
{
$balance=0;
$re2=mysqli_query($db,"select sum(op) from ledger where grp='Sundry Debtors' and led='$row1[acname]' ")or die(mysqli_error($db));
$srow=mysqli_fetch_array($re2);
$opbal=$srow[0];
 $sql="select sum(dramt)-sum(cramt) from journal2 where partic='$row1[acname]'";
 $balres=mysqli_query($db,$sql)or die('err1'.mysqli_error($db));
 $balrow=mysqli_fetch_row($balres)or die('err2'.mysqli_error($db));
 $balance=$opbal+$balrow[0];
  print "\n<form action='editcust.php'>\n<input type=hidden name='code' value='$row1[1]'>";
 print "\n<tr bgcolor=aliceblue><td>".$i++."</td><td>$row1[cname]</td><td>$row1[acname]</td><td>$row1[dist1]</td><td>$row1[state1]</td>";
 print "<td>$row1[cramt]</td><td>$row1[crdays]</td><td>".getbrname($row1[brcode])."</td><td align=right>".round($balance,2)."</td></tr></form>";
}
}
}
}
?>
</table>
</td></tr></table>

