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

$formname = 'Container ETA Alert';
$ztit = $_SESSION["tit_" . $dbname];
$maindb = 'shipmain';
$printfile = "";
$file = 'shipeta.php';
$trandbexist = 1;
$grid = '';
$keyfld = "vouchno";
$keycond = "";
$focusfield = "party";
$bseries = $_SESSION["user_series"];
$zroot = $_SESSION["zdir"];

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

$usertype = $_SESSION["usertype"];
$user = $_SESSION['username_' . $dbname];



if ($addflag != 1) {
    $getvouch = '';
    if ($addflag == 0) {
        $getvouch = $_GET[$keyfld];
    } else {
        $getvouch = $qvouch;
    }
}

$senable = "";
$cenable = "";


include("includes/linkshead.php");
?>
</head>
<body>

    <form action='' method='POST'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-body table-responsive" style="width:100%">
                        <table style="background: white;width: 100%;border-radius: 7px;" class="table table-condensed table-bordered table-hover table">
                        <thead>
                            <tr style="background-color: #1ABC9C">
                                <th width="3%;" style="text-align: center;">Voucher</th>
                                <!-- <th width="10%;">Date</th> -->
                                <th width="18%;">Shipper</th>
                                <th width="5%;">Inv No.</th>
                                <th width="10%;">Container</th>
                                <th width="7%;">ETA</th>
                                <th width="10%;">Line</th>
                                <th width="5%;" class="text-right">Weight</th>
                                <th width="6%;" class="text-right">Inv. Amt.</th>
                                <th width="7%;">Status</th>
                                <th width="7%;" class='text-right'>DOC VALUE</th>
                                <th width="25%;" colspan="2">Remarks</th>
                                </tr>
                            </thead>
                            <tbody class="mytable table-bordered">
                                <?php
                                $date = date("Y-m-d");
                                $srchresult = mysqli_query($conn, "SELECT *,DATE_FORMAT(`vouchdt`, '%d-%m-%Y') as mydt,DATE_FORMAT(`eta`, '%d-%m-%Y') as etadt
                                                                                 FROM `$maindb` WHERE releasedt = '0000-00-00'  and vouchno != '' 
                                                                                 group by vouchno order by eta") or die(mysqli_error($conn));

                                $ctr = 0;
                                $mctr = 0;
                                while ($pmain = mysqli_fetch_array($srchresult)) {

                                    $getshipper = mysqli_query($conn, "SELECT `accode`,`name` FROM accmast WHERE accode='$pmain[name]' ") or die(mysqli_error($conn));
                                    $fetshipper = mysqli_fetch_object($getshipper);
                                    $shipper = $fetshipper->name;
                                    $container = $pmain['container'];
                                    $vouchno = $pmain['vouchno'];
                                    $eta = $pmain['etadt'];
                                    $live = $pmain['live'];
                                    $status = $pmain['status'];
                                    $docvalue = $pmain['docvalue'];
                                    $ctr++;

                                    // $url = "shipperent.php?mode=edit&vouchno=$vouchno";

                                    echo "<tr>";
                                    echo "<td style='text-align:center'><a target='_blank' href='shipperent.php?mode=edit&vouchno=$vouchno'>$vouchno</a></td>";
                                    echo "<td>$shipper</td>";
                                    echo "<td>$pmain[invno]</td>";
                                    echo "<td>$container</td>";
                                    echo "<td>$eta</td>";
                                    echo "<td>$live</td>";
                                    echo "<td  class='text-right'>$pmain[totwt]</td>";
                                    echo "<td class='text-right'>$pmain[invamt]</td>";
                                    echo "<td>$status</td>";
                                    echo "<td class='text-right'>$docvalue</td>";
                                    echo "<td colspan='2'>$pmain[remark1] $pmain[remark2]</td>";
                                    echo "</tr>";
                                }
                                ?> 
                            </tbody> 
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </form>

    <?php include("includes/linksfoot.php"); ?>

</body>
</html>
