<?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"];

/////////////   local sale

$source = 'SLFP';
//
//$tradesale = mysqli_query($conn, "SELECT *, sum(subtot) as chkamt from gsttran 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 tottaxamt, packchgs, canc_flag from gstmain WHERE vouchno =  '$vouchno'  ") or die(mysqli_error($conn));
//       $ftmain = mysqli_fetch_array($slmain); 
//       $mainamt = $ftmain['tottaxamt'] - $ftmain['packchgs'] ;
//       $canc = $ftmain['canc_flag'] ;
//       if ($canc != 'C') {
//           if (round($mainamt,0) != round($tranamt,0)) {
//               echo $source .  ' ' . $vouchno  . "<br>";
//           }
//       }
//}
//$tradesale = mysqli_query($conn, "SELECT * from gstmain group by vouchno ") or die(mysqli_error($conn));
//while ($fetmain = mysqli_fetch_array($tradesale)) {
//    $vouchno = $fetmain['vouchno'];
//    $taxamt = $fetmain['tottaxamt'];
//    $canc = $fetmain['canc_flag'];
//
//    $slmain = mysqli_query($conn, "SELECT amount from actran WHERE vouchno =  '$vouchno' and grpcode = '005' and source ='SLFP' ") or die(mysqli_error($conn));
//    $ftmain = mysqli_fetch_array($slmain);
//    if ($canc != 'C') {
//
//        if (round($taxamt, 0) != round($ftmain['amount'], 0)) {
//            echo $source . ' ' . $vouchno . "<br>";
//        }
//    }
//}

echo "<table>";
echo "<tr>";
echo "<td style='width:30%'>";
echo "<table class='table  table-bordered'>";
echo "<thead>";
echo "<th>Vouchno</th>";
echo "<th>Amount</th>";
echo "</thead>";
echo "<tbody>";
$tradesale = mysqli_query($conn, "SELECT vouchno, amount FROM `actran` WHERE source = 'SLFP' and grpcode = '005' ORDER BY `vouchno` ASC") or die(mysqli_error($conn));
while ($fetmain = mysqli_fetch_array($tradesale)) {
    echo "<tr>";
    echo "<td>$ctr</td>";
    echo "<td>$fetmain[vouchno]</td>";
    echo "<td>$fetmain[amount]</td>";
    echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "</td>";
echo "<td style='width:20%'>";
echo "</td>";
echo "<td style='width:30%'>";
echo "<table class='table table-bordered'>";
echo "<thead>";
echo "<th>Vouchno</th>";
echo "<th>Amount</th>";
echo "</thead>";
echo "<tbody>";
$tradesale1 = mysqli_query($conn, "SELECT vouchno, tottaxamt FROM `gstmain` WHERE canc_flag!='1' ORDER BY `vouchno` ASC") or die(mysqli_error($conn));
while ($fetmain1 = mysqli_fetch_array($tradesale1)) {
    echo "<tr>";
    echo "<td>$ctr</td>";
    echo "<td>$fetmain1[vouchno]</td>";
    echo "<td>$fetmain1[tottaxamt]</td>";
    echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "</table>";


//////////// deemed 

browse('Sale Checking Finished');
?>
