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

$maindb = 'visamain';
$trandb = 'visatran';
$formname = "Passport Status";
//$action = "register_fr.php";
$file = "pastatus.php";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zyear = right($zdb, 4);

$mfrdate = getzdates($zyear, 'S');
$mtodate = getzdates($zyear, 'E');
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

include("includes/linkshead.php");
?>
<!--<script src="MyScript/item.js" type="text/javascript"></script>-->
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>-->
<script>
    $(document).ready(function () {
        $("body").on("blur", '.passport', getDates);


        function getDates() {
            var passport = $(".passport").val();
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "get_medstatus.php",
                data: {passport: passport},
                success: function (response) {
                    var m = response;
                    $(".passrecd").val(m.passrecd);
                    $(".meddate").val(m.meddate);
                    $(".fitdate").val(m.fitdate);
                    $(".mofa_date").val(m.mofa_date);
                    $(".stampdate").val(m.stampdate);

                    if (m.passrecd != '0000-00-00' && m.passrecd != 'null') {
                        $(".passrecd").css("color", "blue");
                    }
                    else {
                        $(".passrecd").css("color", "black");
                    }

                    if (m.meddate != '0000-00-00' && m.meddate != 'null') {
                        $(".meddate").css("color", "blue");
                    }
                    else {
                        $(".meddate").css("color", "black");
                    }

                    if (m.fitdate != '0000-00-00' && m.fitdate != 'null') {
                        $(".fitdate").css("color", "blue");
                    } else {
                        $(".fitdate").css("color", "black");
                    }

                    if (m.mofa_date != '0000-00-00' && m.mofa_date != 'null') {
                        $(".mofa_date").css("color", "blue");
                    } else {
                        $(".mofa_date").css("color", "black");
                    }

                    if (m.stampdate != '0000-00-00' && m.stampdate != 'null') {
                        $(".stampdate").css("color", "blue");
                    } else {
                        $(".stampdate").css("color", "black");
                    }



                },
                error: function (request, textStatus, errorThrown) {
                },
            });


        }
    });
</script>



</head>
<body>
    <form method='POST' action="<?= $action; ?>">
        <!-- Default box -->
        <div>
            <div class="col-lg-6 col-md-6 col-sm-5 col-xs-12  pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php Echo $formname; ?></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                            <i class="fa fa-times"></i>
                        </div>
                    </div>
                    <div id="Div2" class="panel-body">

                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right   pad">
                                <label class="label-control marg">Passport Number</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-6 col-xs-8 pad ">
                                <input type="text" name="passport" class="form-control passport" >
                            </div>
                        </div>
                        <!--<hr>-->

                        <!--***********************************************-->
                        <div id="myDIV">
                            <div class="row">
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="control-label marg">Received Date</label>
                                </div>
                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-8  pad">
                                    <input type="date" size="80" name="passrecd" value=""class="form-control passrecd"/>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right  pad">
                                    <label class="control-label marg">Medical Date</label>
                                </div>
                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-8  pad">
                                    <input type="date" size="80" name="meddate" value=""class="form-control meddate" />
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right  pad">
                                    <label class="control-label marg">Fit Date</label>
                                </div>
                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-8  pad">
                                    <input type="date" size="80" name="fitdate" value=""class="form-control fitdate"/>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right  pad">
                                    <label class="control-label marg">Mofa Date</label>
                                </div>
                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-8  pad">
                                    <input type="date" size="80" name="mofa_date" value=""class="form-control mofa_date"/>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right  pad">
                                    <label class="control-label marg ">Stamp Date</label>
                                </div>
                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-8 pad">
                                    <input type="date" size="80" name="stampdate" value=""class="form-control stampdate"/>
                                </div>
                            </div>
                            <br>
                            <div class="panel-footer">
                                <?php include("includes/but_rep.php"); ?>
                                <script>
                                    $("#subpdf").hide();
                                    $("#excel").hide();
                                    $("#view").hide();
                                </script>
                            </div>
                            <!--</div>-->
                        </div>
                    </div>
                </div>
            </div>
    </form>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
