<?php

ob_start();
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$maindb = "cashrecp";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

print "<table>";
print "<tr><td>Bvoucher</td><td>Bamount</td><td>Acvoucher</td><td>Acamount</td></tr>";
$getpmain = mysqli_query($conn, "SELECT vouchno,amount FROM `$maindb` WHERE vouchno !='' ") or die(mysqli_error($conn));
while ($row = mysqli_fetch_array($getpmain)) {
    $vouchno = $row['vouchno'];
    $amount = $row['amount'];

    $qry = mysqli_query($conn, "select vouchno, amount from `actran` WHERE  source = 'CR' and vouchno = '$vouchno' and amount > 0") or die(mysqli_error($conn));
    $mismatch = mysqli_fetch_array($qry);
    $vouch = $mismatch['vouchno'];
    $acamount = $mismatch['amount'];

    if ($amount != $acamount) {
        print "<tr><td>$vouchno</td><td>$amount</td><td>$vouch</td><td>$acamount</td></tr>";
    }
//        $num = mysqli_num_rows($qry);
//    if ($num > 0) {
//        $mismatch = mysqli_fetch_array($qry);
//    }
}
print "</table>";
