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

mysqli_query($conn, "SET NAMES 'utf8'");
mysqli_query($conn, 'SET CHARACTER SET utf8');

ini_set('display_errors', 1);
error_reporting(E_ERROR);

$zdir = $dbname;
$usercode = $_SESSION["usercode_" . $dbname];
$usertype = $_SESSION["usertype"];
$ztit = $_SESSION["tit_" . $dbname];
$menucolor = $_SESSION["menucolor"];

if ($menucolor == "#5f2b54"){
   $bgrowback = "#846d7fff";
}else{
    $bgrowback = "#d5bdaf";
}

$formname = 'SHIPMENT STATUS';
$file = 'shipmentstatus.php';
$keyfld = "vouchno";

$keycond = "";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
$compcd = $_SESSION["comp_" . $dbname];

$zroot = $_SESSION["zdir"];


$getUserOrigin = mysqli_query($conn, "SELECT `origin` FROM $zroot.`userorigin` WHERE `username` = '$usercode'  order by origin") or die(mysqli_error($conn));

$originArray = [];
while ($fetUserOrigin = mysqli_fetch_object($getUserOrigin)) {
    $originArray[] = "'" . mysqli_real_escape_string($conn, $fetUserOrigin->origin) . "'";
}

if (count($originArray) > 0) {
    $origins = implode(",", $originArray);
    $origincond = "AND name IN ($origins)";
} else {
    $origincond = "";
}

if ($usertype < 3) {
    $origincond = "";
}


mysqli_select_db($conn, $zdb);

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

<script src="MyScript/shipmentstatus_search.js?a=<?= mt_rand() ?>" type="text/javascript"></script>
<style>
    .project-details {
        display: inline-block;
        font-size: 16px;
        letter-spacing: 0.5px;
        word-spacing: 5px;
        font-size: 1.5rem;
        font-weight: 600;
        margin: 0;
        color: <?= $menucolor ?>;
        padding-top: 12px;
        padding-bottom: 6px;
    }

    .form-control {
        background-color: #ffffff;
        border-radius: 4px;
    }


    .Sticky {
        position: sticky;
        top: 0;
        background-color: #f8f9fa;
        z-index: 1;
    }

    .bg-row {
        background-color: <?= $bgrowback ?>;

        /* background-color: #d5bdaf; */
        align-items: center;
        vertical-align: center;
        padding-top: 12px;
        margin-left: 0px;
        margin-right: 0px;
        line-height: 2.7;
    }

    .combodiv {
        background-color: <?= $menucolor ?>;
        color: #ffffff;
        margin-left: 0px;
        margin-right: 0px;
    }

    .combodiv1 {
        /* background-color: #a98467; */
        /* color: #ffffff; */
        margin-left: 0px;
        margin-right: 0px;
    }

    th,
    td {
        white-space: nowrap;
    }

    .table-responsive .table th,
    .table-responsive .table td {
        white-space: nowrap;
    }

    .searchBtn {
        margin-top: -8px !important;
        height: 30px;
        border-radius: 4px;
    }

    .txtt {
        color: whitesmoke;
        text-transform: uppercase;
        font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif
    }

    .txttnew {
        color: <?= $menucolor ?>;
        text-transform: uppercase;
        font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
        margin-bottom: -23px;
        background-color: #ffffff;
        overflow: overlay;
        padding: 8px;
        font-size: 18px;
    }

    .bordertxt {
        border: 1px solid black;
    }

    #borderimg {
        border: 2px solid <?= $menucolor ?>;
        padding: 4px;
        border-radius: 7px;
    }

    .skk {
        border-bottom: 1px solid grey !important;
        color: white;
    }
</style>
</head>

<body>
    <!-- <form action='' method='POST'> -->
    <div class="col-lg-12">
        <div class="panel panel-default shadow-sm border-0">
            <div class="row combodiv text-center">
                <label class="label-control marg">
                    <h3 class="panel-title"><?php echo $formname; ?></h3>
                </label>
            </div>

            <div class="row table-responsive">
                <div class="col-lg-4"></div>
                <div class="col-lg-4 text-center">
                    <label class="txttnew"><b>Origin</b></label>
                    <p id="borderimg">
                        <?php
                        echo "<select name='origin' id='origin'  class='origin skk  select2' style='width:100%;' autocomplete='off'> ";
                        // echo "<option value=''></option>";
                        $getOrigin = mysqli_query($conn, "SELECT `code`,`name` FROM `origin` WHERE name != '' $origincond order by name") or die(mysqli_error($conn));
                        while ($fetOrigin = mysqli_fetch_array($getOrigin)) {
                            echo "<option value='$fetOrigin[name]'>$fetOrigin[name]</option>";
                        }
                        echo "</select>";
                        ?>
                    </p>
                </div>
            </div>

            <div class="dataDiv">
            </div>

            <div class="row">
                <div class="col-xs-11 text-right search-action-bar">
                    <input type="button" class="btn btn-primary sprev" style="border-radius: 4px;margin-bottom:5px"
                        value="Previous">
                    <input type="button" class="btn btn-primary snext" style="border-radius: 4px;margin-bottom:5px"
                        value="Next">
                </div>
            </div>
        </div>
    </div>

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

</html>