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

$formname = 'Sale/Purchase Lock';
$maindb = 'compyear';
$printfile = "";
$file = 'salelock.php';
$trandbexist = 0;
$grid = '';
$keyfld = "finyear";
$focusfield = "narr1";
$action = "narr_print.php";


////////////////// FB ////////////////////
$adduser = $_SESSION['username_' . $dbname];
date_default_timezone_set("Asia/Kolkata");
$adddate = date("Y-m-d");
$addtime = date("h:i:sa");
//$usertype = $_SESSION["usertype_" . $dbname];
$usertype = $_SESSION["usertype"];



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

//mysqli_select_db($conn, $zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");


if (isset($_POST["submit"])) {
    $a = 1;

    if ($a == 1) {
        $salelock = $_POST["salelock"];


        ############################## MAIN  ######################################################
        mysqli_query($conn, "UPDATE `$maindb` SET `salelock`='$salelock' WHERE `finyear` = '$yearno' ") or die(mysqli_error($conn));
        browse("Record Updated. Login Again to Continue");
        print '<script type="text/javascript">';
        print " top.window.location = 'logout.php'";
        print '</script>';

//        updmess();
    }
}

if ($addflag != 1) {

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

    $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE finyear='$yearno'") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);
}

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


if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
}

include("includes/linkshead.php");
?>
<script type="text/javascript">
    $(document).ready(function () {
        $("#hadd").hide();
        $("#hdelete").hide();
        $("#hsearch").hide();
        $("#hprevious").hide();
        $("#hprint").hide();
        $("#hnext").hide();
    })
</script>
</head>
<body>
    <!--    <div id="preloader" class="col-lg-12 text-center">
            <h3 class="text-center">Loading</h3>
            <div id="status">&nbsp;</div>
        </div>-->
    <form action='' method='POST'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-4">
                <div class="panel panel-default">
                    <div 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" style="color:red;font-size: 20px">Sale Lock</label>
                            </div>
                            <div class="col-lg-5 col-md-5 col-sm-6 col-xs-6 pad">
                                <input type="date" class="form-control form focusfield"  style="color:red;font-size: 20px" name="salelock" value="<?php Echo ($addflag != 1) ? $get["salelock"] : ""; ?>">
                            </div>
                        </div>

                    </div>
                    <div class="panel-footer">
                        <?php include("includes/buttons.php"); ?>
                    </div>
                </div>
            </div>
        </div>
    </form>

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