<?
session_start();
$brcode = $_SESSION['brcode'];
$branch = $_SESSION['branch'];
$user   = $_SESSION['user'];
$level   = $_SESSION['level'];

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

$chkres=mysqli_query($db,"select distinct partic from journal2 where brcode='$brcode'") or die(mysqli_error($db));
$i=1;
while($row=mysqli_fetch_array($chkres))
{
	$sql="select led from ledger where led = '$row[0]'";
	$re=mysqli_query($db,$sql) or die(mysqli_error($db));
       $row1=mysqli_fetch_array($re);
	if ($row1[0]=='')
       {    
             if($i==1)
             {
                  print "<font color=red> Following ledgers could not be found</font> <br>";
              }
		print " $row[0] <br>";
              $i++;
	}
}
if($i>1)
	print "<a href='../ledge.php'>Create Ledger now </a>";
$sql="select led,count(led) from ledger group by led having count(led)>1";
$re=mysqli_query($db,$sql) or die(mysqli_error($db));
 print "<font color=red> Duplicate ledgers found</font> <br>";
if(mysqli_num_rows($re)>0)
{
print "<table><th>Ledger <th>Count<th>Branch";
while($row=mysqli_fetch_array($re))
{
 print "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td></tr>";
}
print "</table>";
}
?>
