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

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

$date = date("Y-m-d");

$getcontrels = mysqli_query($conn, "SELECT count(*)as contrels FROM `shipmain` WHERE relcheck = '1' ")or die(mysqli_error($conn));
$fetcontrels = mysqli_fetch_array($getcontrels);

$getcontsail = mysqli_query($conn, "SELECT count(*)as contsail FROM `shipmain` WHERE relcheck != '1' ")or die(mysqli_error($conn));
$fetcontsail = mysqli_fetch_array($getcontsail);

$getpuramt = mysqli_query($conn, "SELECT sum(billamt)as billamt,sum(totexpamt)as totexpamt,sum(tqty)as tqty FROM `purmain`  ")or die(mysqli_error($conn));
$fetpuramt = mysqli_fetch_array($getpuramt);

$getsaleamt = mysqli_query($conn, "SELECT sum(tqty)as tqty,sum(netamt)as netamt FROM `salemain`  ")or die(mysqli_error($conn));
$fetsaleamt = mysqli_fetch_array($getsaleamt);

$getbalestk = mysqli_query($conn, "SELECT sum(a.qty)as tqty FROM `transacn` a, `item` b WHERE a.`itemcode` =  b.`barcode` AND a.`vouchdt` <= '$date' ")or die(mysqli_error($conn));
$fetbalestk = mysqli_fetch_array($getbalestk);

?>

<style>
    .spantext {
        font-weight: 700 !important;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 19px !important;
        color: #1abc9c;
    }

    .overview-box {
        background-image: linear-gradient(135deg, #FFFEFF 10%, #D7FFFE 100%);
        border-radius: 10px;
        box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.15);
        height: 115px;
        margin-bottom: 10px;
    }

    .text{
        text-align: center;
    }
</style>
</head>

<body>
    <form method="post">
        <!-- Default box -->
        <br>
        <br>
        <div class="row m-t-25">
            <div class="col-lg-2 col-md-2 col-sm-1 "></div>
            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
                <div class="overview-item overview-item--c1">
                    <div class="overview__inner">
                        <div class="overview-box clearfix">

                            <div class="text">
                                <h3><?= $fetcontrels['contrels']; ?></h3>
                                <span class="spantext">No. of Containers <br>
                                Released</span>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
                <div class="overview-item overview-item--c2">
                    <div class="overview__inner">
                        <div class="overview-box clearfix">

                            <div class="text">
                                <h3><?= $fetcontsail['contsail']; ?></h3>
                                <span class="spantext">No. of Containers <br>
                                 Sailing</span>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
                <div class="overview-item overview-item--c3">
                    <div class="overview__inner">
                        <div class="overview-box clearfix">

                            <div class="text">
                                <h3><?= number_format($fetbalestk['tqty'],0);?></h3>
                                <span class="spantext">No. of Bales in 
                                <br> Stock </span>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
                <div class="overview-item overview-item--c4">
                    <div class="overview__inner">
                        <div class="overview-box clearfix">

                            <div class="text">
                                <h3><?= number_format($fetsaleamt['tqty'],0); ?></h3>
                                <span class="spantext">No. of Bales <br>
                                Sold</span>
                            </div>
                        </div>

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

        <br>

        <div class="row m-t-25">
            <div class="col-lg-2 col-md-2 col-sm-4 "></div>
            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
                <div class="overview-item overview-item--c6">
                    <div class="overview__inner">
                        <div class="overview-box clearfix">

                            <div class="text">
                                <h3><b>$</b> <?= number_format($fetpuramt['billamt'],0); ?></h3>
                                <span class="spantext">Total Purchase <br> Amount </span>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
                <div class="overview-item overview-item--c7">
                    <div class="overview__inner">
                        <div class="overview-box clearfix">

                            <div class="text">
                                <h3><b>₹</b> <?= number_format($fetpuramt['totexpamt'],0); ?></h3>
                                <span class="spantext">Total Purchase <br> Expense Amount</span>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
                <div class="overview-item overview-item--c5">
                    <div class="overview__inner">
                        <div class="overview-box clearfix">

                            <div class="text">
                                <h3><b>₹</b> <?= number_format($fetsaleamt['netamt'],0); ?></h3>
                                <span class="spantext">Total Sales <br> Amount</span>
                            </div>
                        </div>

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

            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
                <div class="overview-item overview-item--c10">
                    <div class="overview__inner">
                        <div class="overview-box clearfix">

                            <div class="text">
                                <h3><?= number_format($fetpuramt['tqty'],0); ?></h3>
                                <span class="spantext">No. of Bales <br> Purchased</span>
                            </div>
                        </div>

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

        <!--task given-->

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

</html>