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

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

$maindb = 'salemain';
$trandb = 'saletran';
$zroot = $_SESSION["zdbroot"];

$tradesale = mysqli_query($conn, "SELECT *, sum(subtot) as chkamt from saletran group by vouchno ") or die(mysqli_error($conn));
while ($fetmain = mysqli_fetch_array($tradesale)) {
       $tranamt = $fetmain[chkamt] ;
       $vouchno = $fetmain[vouchno] ;
       
       $slmain = mysqli_query($conn, "SELECT taxableamt, postamt, canc_flag from salemain WHERE vouchno =  '$vouchno'  ") or die(mysqli_error($conn));
       $ftmain = mysqli_fetch_array($slmain); 
       $mainamt = $ftmain[taxableamt] - $ftmain[postamt] ;
       $canc = $ftmain[canc_flag] ;
       if ($canc != 'C') {
           if (round($mainamt,0) != round($tranamt,0)) {
               echo $vouchno  . "<br>";
           }
       }
}

?>
