<?
session_start();
$brcode = $_SESSION['brcode'];
 include("../test.php");
 include ("../opendb.php");

$chkres=mysqli_query($db,"select distinct partic from journal2 where brcode='$brcode'") or die(mysqli_error());
$i=1;
while($row=mysqli_fetch_array($chkres))
{
	$sql="select led from ledger where brcode = '$brcode' and led = '$row[0]'";
	$re=mysqli_query($db,$sql) or die(mysqli_error());
       $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),brcode from ledger group by led,brcode having count(led)>1";
$re=mysqli_query($db,$sql) or die(mysqli_error());
 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>";
}
?>
