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

$formname = ' Lavajam';
$maindb = 'member';
$printfile = "drawbank_print.php";
$file = 'lavajam.php';
$trandbexist = 0;
$grid = '';
$keyfld = "accode";
$focusfield = "name";

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

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

if (isset($_POST["submit"])) {

    $a = 1;
    $code = $_POST["code"];
    $openbal = $_POST["openbal"];

    $mvouch = $qvouch;

    mysqli_query($conn, "UPDATE `$maindb` SET `lavajam`='$openbal' WHERE `accode` = '$code' ") or die(mysqli_error($conn));
    updmess();
//    header("refresh: 1; $file?$keyfld=$mvouch&mode=true");
}

if ($addflag != 1) {

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

    $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE $keyfld='$getvouch'") 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");
?>
<style>

    .btn{
        border-radius: 5px;
    }

</style>
<script type="text/javascript">
    $(document).ready(function () {
        $("body").on("keyup blur", ".memno", getDetail);

        function getDetail() {
            var memno = $(".memno").val();

            $.ajax({
                type: "POST",
                dataType: "json",
                url: "getmemname.php",
                data: {memno: memno},
                success: function (response) {
                    if (response != "") {
                        var memname = response.memname;
                        var openbal = response.openbal,
                            add1 = response.add1,
                            add2 = response.add2,
                            add3 = response.add3;
                        $('.memname').val(memname);
                        $('.openbal').val(openbal);
                        $('.add1').val(add1);
                        $('.add2').val(add2);
                        $('.add3').val(add3);
                    }
                },
                error: function (request, textStatus, errorThrown) {
                }
            });
        }
    })
</script>
</head>
<body>
    <form action='' method='POST'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-8">
                <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-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Member ID</label>
                            </div>
                            <div class="col-lg-1 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form focusfield memno" name="code" value="" required>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Name</label>
                            </div>
                            <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="hidden" class="form-control form " value="<?php Echo ($addflag != 1) ? $qvouch : $qvouch; ?>" >
                                <input type="text" class="form-control form memname" name="name" value="" readonly>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Address</label>
                            </div>
                            <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form add1" name="name" value="" readonly>
                                <input type="text" class="form-control form add2" name="name" value="" readonly>
                                <input type="text" class="form-control form add3" name="name" value="" readonly>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Balance</label>
                            </div>
                            <div class="col-lg-2 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form openbal text-right" name="openbal" value="" >
                            </div>
                        </div>
                        <div class="row">
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad"></div>
                                <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <button id='submit' type='submit' name='submit' value='<?php echo ($addflag == 0) ? "Update" : "Save"; ?>' class="btn btn-pad btn-square " style="background-color:#008D4C; ">
                                        <i class="fa fa-check" style="color:#ffffff">Save</i>
                                    </button>
                                </div>
                                <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <button id='exit' type="button" class="btn btn-pad btn-square " style="background-color:#cccccc; "  onClick="window.location.href = '<?= 'default.php' ?>'">
                                        <i class="fa fa-power-off" style="color:red">Exit</i>
                                    </button>
                                </div>
    <!--<td class=" buttonform tooltip-bottom pad" id="ssubmit" style="display: <? // Echo $savedisabled       ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Save Record">-->

                                <!--</td>-->
                                <!--<td class=" buttonform tooltip-bottom" id="hexit" style="display: <? // Echo $exitdisabled       ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Exit">-->

                                <!--</td>-->
                            </div>
                        </div>
                        <div class="panel-footer">
                            <?php include("../includes/buttons.php"); ?>
                        </div>
                    </div>
                </div>
            </div>
    </form>
    <!--    <div class="modal fade bs-example-modal-lg searchModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button class="close" data-dismiss="modal"><span>&times;</span></button>
                        <h4 class="modal-title" id="myLargeModalLabel">Search <? Echo $formname; ?></h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-lg-2">
                                <select class="form-control sfield">
                                    <option value="1">Name</option>
                                </select>
                            </div>
                            <div class="col-lg-2">
                                <select class="form-control soperator">
                                    <option value="">Type of Search</option>
                                    <option value="%">Like</option>
                                    <option value="=">Exactly</option>
                                </select>
                            </div>
                            <div class="col-lg-2">
                                <select class="form-control sortBy">
                                    <option value="">Sort By</option>
                                    <option value="1">Name</option>
                                </select> 
                            </div>
                            <div class="col-lg-2">
                                <select class="form-control orderAs">
                                    <option value="desc">Desc</option>
                                    <option value="asc">Asc</option>
                                </select>
                            </div>
                            <div class="col-lg-2">
                                <input type="text" value="" class="form-control ssearch" placeholder="Search Here">
                            </div>
                            <div class="col-lg-2">
                                <input type="button" class="btn btn-primary sload" value="Search" >
                            </div>
                        </div>
                        <div class="col-lg-12 sloader text-center">
                            <img src="images/search.gif" alt="loading">       
                        </div>
                        <div class="col-lg-12 snoRecord text-center">
                            <h3>NO RECORDS FOUND</h3>
                        </div>
                        <div class="table-responsive" style="max-height: 400px;overflow: auto;">
                            <table id="" class="table table-striped table-condensed table-bordered" width="100%">
                                <thead>
                                    <tr class="mySearchTr">
                                        <th width="80%">Name</th>
                                        <th width="20%">Action</th>
                                    </tr>
                                </thead>
                                <tbody class="sTbody">
                                </tbody>
                            </table>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 text-right search-action-bar">
                                <input type="button"  class="btn btn-primary sprev" value="Previous">
                                <input type="button"  class="btn btn-primary snext" value="Next">
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer"></div>
                </div>
            </div>
        </div>-->
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
