<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');
error_reporting(E_ERROR);
ini_set('display_errors', 1);

$zdb = $_SESSION["zdbyear_$dbname"];
mysqli_select_db($conn, $zdb);

//echo "<h2>FOR STOCK QTY MISSING</h2>";
//
//$getprate2 = mysqli_query($conn, "SELECT s.vouchno, s.qty 
//         FROM saletran s
//         LEFT JOIN transacn t ON t.vouchno = s.vouchno AND t.itemcode = s.item
//         WHERE  t.vouchno IS NULL"
//        ) or die(mysqli_error($conn));
//
//print table($getprate2);

echo "<hr>";

echo "<h2>FOR SALE ITEM TOTAL MISSMATCH WITH SUBTOTAL</h2>";

$getprate = mysqli_query($conn, "SELECT b.vouchno, b.vouchdt, b.subtotal, SUM(a.amount) AS mamt 
     FROM rawtran a
     JOIN rawmain b ON a.vouchno = b.vouchno
     GROUP BY a.vouchno 
     HAVING mamt != subtotal"
        ) or die(mysqli_error($conn));

print table($getprate);
?>
