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

$formname = "Estimate Register";
$action = "estreg_fr.php";

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

$zyear = right($zdb, 4);
$mfrdate = getzdates($zyear, 'S');
//$mtodate = getzdates($zyear, 'E');


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




//$mfrdate = date("Y-m-d", strtotime($date . ' - 1 days'));
//$timestamp = strtotime($mfrdate);
//$day = date('l', $timestamp);
//
//if ($day == 'Sunday') {
//    $mfrdate = date("Y-m-d", strtotime($date . ' - 2 days'));
//}
//
//if ($usertype != 1) {
//    $disp = 'readonly';
//} else {
//    $disp = '';
//}
//
//$mfrshdate = date("d-m-Y", strtotime($mfrdate));
//$mtoshdate = date("d-m-Y", strtotime($mtodate));

$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

include("includes/linkshead.php");
?>
<script>
    $(document).ready(function () {

        $(".itemname").change(function () {
            var item = $(".itemname").val();
            $(".itemcode").val(item);
        });

        $(".itemcode").change(function () {
            var itemcode = $(".itemcode").val();
            $(".itemname").val(itemcode).trigger("change");
        });

    });
</script>
</head>
<body>
    <form method='POST' action="<?= $action; ?>">
        <!-- Default box -->
        <div>
            <div class="col-lg-5 col-md-12 col-sm-12 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 class="panel-body">
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Client Name</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4  pad">
                                <input list='client' name='client' value='<?php echo $get['client'] ?>' class='client form-control'  autocomplete="off">
                                <datalist id='client'> 
                                    <option value=''></option>
                                    <?php
                                    $mhsncode = mysqli_query($conn, "SELECT `client` FROM `estmain` where client!='' group by client") or die(mysqli_error($conn));
                                    while ($thsncode = mysqli_fetch_array($mhsncode)) {
                                        echo "<option value='$thsncode[client]'>";
                                    }
                                    ?>
                                </datalist>
                            </div>
                        </div> 
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Number</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4  pad">
                                <input type="text" name="clientno" value="<?php echo $get['clientno'] ?>" class="form-control clientno" autocomplete="off">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Architect Name</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4  pad">
                                <input list='architect' name='architect' value='<?php echo $get['architect'] ?>' class='architect form-control' autocomplete="off">
                                <datalist id='architect'> 
                                    <option value=''></option>
                                    <?php
                                    $marchitect = mysqli_query($conn, "SELECT `architect` FROM `estmain` where architect!='' group by architect") or die(mysqli_error($conn));
                                    while ($tarchitect = mysqli_fetch_array($marchitect)) {
                                        echo "<option value='$tarchitect[architect]'>";
                                    }
                                    ?>
                                </datalist>
                                <!--<input type="text" name="architect" class="form-control form architect" value="<?php echo ($addflag != 1) ? $get['architect'] : '' ?>">-->
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control">From</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 pad">
                                <input type="date" class="form-control frmdate" name="fdate" value="<? echo $mfrdate; ?>">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control">To</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 pad">
                                <input type="date" class="form-control" name="tdate" value="<? echo $mtodate; ?>">
                            </div>
                        </div> 
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Status</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                <select name="status" class="form-control mode select2">
                                    <option value=""></option>
                                    <option value="P">Pending</option>
                                    <option value="A">Approved</option>
                                </select>
                            </div> 
                        </div>

                    </div>
                    <div class="panel-footer">
                        <div class="text-center pad">
                            <div class="panel-footer">
                                <?php include("includes/but_rep.php"); ?>
                            </div>
                        </div>                       
                    </div>
                </div>
            </div>
        </div>
    </form>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
