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

$formname = 'Bank Receipt';
$bild = 'billsett';

$file = 'bankrecp.php';
$grid = '';
$source = 'BR';
$keyfld = "vouchno";
$trandbexist = 0;
$focusfld = "name";
$printfile = 'bankrecp_fr.php';
$type = "S";

$acc = 'actran';
$bank = 'bankrecp';
$cust = 'accmast';

$ztit = $_SESSION["tit_" . $dbname];
$usertype = $_SESSION["usertype_" . $dbname];
$accdb = $acc;
$maindb = $bank;
$custdb = $cust;
$billdb = $bild;

$compcd = $_SESSION["comp_" . $dbname];

//$printfile = 'bankr_voucher.php';

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

$zStartDate = getzdates($zyear, 'S', $conn);
$zEndDate = getzdates($zyear, 'E', $conn);
mysqli_select_db($conn, $zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");


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

    $a = 1;
    $vouchdt = $_POST["vouchdt"];
    $bankname = $_POST["bankname"];
    $recpno = $_POST["recpno"];
    $chqno = $_POST["chqno"];
    $chqdate = $_POST["chqdate"];
    $drawbank = $_POST["drawbank"];
    $party = $_POST["party"];
    $amount = $_POST["amount"];
    $remark1 = $_POST["remark1"];
    $remark2 = $_POST["remark2"];
    $counter = $_POST["counter"];
    $company = $_POST["cmbcomp"];
    $cmbstaff = $_POST["cmbstaff"];
    $chqret1 = $_POST["chqret"];
    $cleardt = $vouchdt;
    $retdate = $_POST["retdate"];
    $recvdate = $_POST["recvdate"];
    $billflag = $_POST["billflag"];
    //    if ($chqret1 != '') {
//        $chqret = 'Y';
//    } else {
//        $chqret = 'N';
//    }
    if ($retdate != '' or $cleardt != '') {
        $postchq = "1";
    } else {
        $postchq = "";
    }
    if ($retdate != '') {
        $chqret = 'Y';
    } else {
        $chqret = 'N';
    }
    $date = date("Y-m-d");
    //    if ($chqdate > $date) {
//        $postchq = "";
//    } else {
//        $postchq = "1";
//    }
//    browse($chqret);
    // browse($qvouch);


    $mvouch = $qvouch;

    if ($bankname == "") {
        $a = 0;
        browse("Name Cannot Be Empty");
        if ($addflag == 1) {
            header("location:javascript://history.go(-1)");
        } else {
            header("refresh: ; $file?vouchno=$_GET[vouchno]");
        }
    }
    //    if ($cmbstaff == "") {
//        $a = 0;
//        browse("Staff Cannot Be Empty");
//        if ($addflag == 1) {
//            header("location:javascript://history.go(-1)");
//        } else {
//            header("refresh: ; $file?vouchno=$_GET[vouchno]");
//        }
//    }
    if ($party == "") {
        $a = 0;
        browse("A/c Name Cannot Be Empty");
        if ($addflag == 1) {
            header("location:javascript://history.go(-1)");
        } else {
            header("refresh: ; $file?vouchno=$_GET[vouchno]");
        }
    }

    if ($a == 1) {
        mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `$custdb` WRITE, `$accdb` WRITE, `$billdb` WRITE") or die(mysqli_error($conn));

        if ($addflag == 1) {
            $gen1 = mysqli_query($conn, "SELECT MAX(vouchno) AS maxcode FROM `$maindb` LIMIT 0,1 ") or die(mysqli_error($conn));
            if (mysqli_num_rows($gen1) > 0) {
                $vvouch = mysqli_fetch_assoc($gen1);
                $qvouch = $vvouch["maxcode"] + 1;
            } else {
                $qvouch = '1';
            }
        }

        ######################## ACCOUNTS PART ######################################
        #########################START BILL SETTLEMENT###############################################
        $getbankinit = mysqli_query($conn, "SELECT * FROM `$custdb` WHERE `accode` = '$bankname'");
        $bankinit = mysqli_fetch_array($getbankinit);
        $binit = $bankinit["init"];


        $qrygrp = mysqli_query($conn, "select `grpcode` from `$custdb` where `accode` = '$party'") or die(mysqli_error($conn));
        $fetgrp = mysqli_fetch_array($qrygrp);
        $pgrp = $fetgrp['grpcode'];
        if ($vouchdt <= '2020-08-17') {
            $rdate = $recvdate;
        } else {
            $rdate = $vouchdt;
        }

        //        $bqry = mysqli_query($conn, "SELECT `bankinit` FROM `accmast` WHERE `accode` = '$bankname' LIMIT 0,1 ");
//        $init = mysqli_fetch_assoc($bqry);
//        $pbinit = $init["bankinit"];
        if ($billflag == 1) {

            mysqli_query($conn, "DELETE FROM `$billdb` WHERE `bnkvouch` = '$mvouch' AND `source` = '$source'") or die(mysqli_error($conn));
            $billstr2 = 'Received For Bill No. ';

            for ($i = 0; $i <= $counter; $i++) {
                $myearno = $_POST["yearno_" . $i];
                $mvouchno = $_POST["vouchno_" . $i];
                $mbillno = $_POST["billno_" . $i];
                $msetoff = $_POST["setoff_" . $i];
                $mdays = $_POST["days_" . $i];
                $mbillsrc = $_POST["billsrc_" . $i];
                $mbilldate = $_POST["billdate_" . $i];

                if (!empty($msetoff)) {
                    mysqli_query($conn, "INSERT IGNORE INTO `$billdb`(`yearno`, `type`, `vouchno`, `billno`, `setoff`, `party`, `source`, `bnkvouch`, `bankinit`, nodays, billsrc, bnkdate, billdate)
                                VALUES('$myearno', '$type', '$mvouchno', '$mbillno', '$msetoff', '$party', '$source', '$mvouch', '$binit', '$mdays', '$mbillsrc', '$rdate', '$mbilldate')") or die(mysqli_error($conn));
                    $billstr2 = $billstr2 . $mbillno . ",";
                }
            }
            $remark1 = $billstr2; 
        }
        #########################END BILL SETTLEMENT###############################################


        mysqli_query($conn, "DELETE FROM `$accdb` WHERE vouchno='$mvouch' AND `source`='$source'") or die(mysqli_error($conn));

        
        if ($amount > 0) {
            $minus_amt = ($amount * -1);

            // cash part
            mysqli_query($conn, "INSERT IGNORE INTO `$accdb`(date, vouchno, source, trnno, accode, bankinit, grpcode, amount, chqno, chqdate, retdate, chqret, clrdate)
                    VALUES ('$vouchdt', '$mvouch', '$source', '001', '$bankname', '$binit', '001', '$minus_amt','$chqno', '$chqdate', '$retdate', '$chqret', '$cleardt')");
            // party part
            mysqli_query($conn, "INSERT IGNORE INTO `$accdb`(date, vouchno, source, trnno, accode, bankinit, grpcode, amount, chqno, chqdate, retdate, chqret, clrdate)
                     VALUES ('$vouchdt','$mvouch', '$source', '002', '$party', '$binit', '$pgrp', '$amount','$chqno', '$chqdate', '$retdate', '$chqret', '$cleardt')");
        }
        if ($addflag == 1) {
            mysqli_query($conn, "INSERT IGNORE INTO `$maindb`( vouchno ,`vouchdt`, `bankname`, bankinit, `recpno`, `chqno`,`chqdate`, retdate, chqret,
                                                `drawbank`,`party`,`amount`,`remark1`,`remark2`,`cleardt`)
                                       Values ('$qvouch', '$vouchdt', '$bankname', '$binit',  '$recpno','$chqno','$chqdate', '$retdate', '$chqret',
                                    '$drawbank', '$party','$amount','$remark1','$remark2','$cleardt')") or die(mysqli_error($conn));
            insmess();
            $mvouch = $qvouch;
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        } else {
            $mvouch = $qvouch;
            mysqli_query($conn, "UPDATE `$maindb` SET   vouchdt='$vouchdt', `company`='$company', bankname='$bankname', bankinit='$binit', `retdate` = '$retdate', chqret='$chqret', 
                    recpno='$recpno' ,chqno='$chqno',chqdate='$chqdate',drawbank='$drawbank',`party`='$party', 
                    amount='$amount',`remark1`='$remark1',`remark2`='$remark2',`cleardt`='$cleardt' where vouchno = '$mvouch' ") or die(mysqli_error($conn));
            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        }
        mysqli_query($conn, "UNLOCK TABLES");
    }
}

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);

    $getbank = mysqli_query($conn, "SELECT * FROM `$custdb` WHERE `accode` = '$get[bankname]'");
    $banknm = mysqli_fetch_array($getbank);

    $getparty = mysqli_query($conn, "SELECT * FROM `$custdb` WHERE `accode` = '$get[party]'");
    $gtpt = mysqli_fetch_array($getparty);

    //    $getstaff = mysqli_query($conn, "SELECT * FROM `$custdb` WHERE `accode` = '$get[staff]'");
//    $fetstaff = mysqli_fetch_array($getstaff);

    $result2 = mysqli_query($conn, "SELECT * FROM `$billdb` WHERE source = '$source' and bnkvouch = '$get[vouchno]'") or die(mysqli_error($conn));




    if ($usertype == 3) {

        if ($get["cleardt"] != '0000-00-00') {
            $editdisabled = "none";
            $deletedisabled = "none";
        }
        if ($get["retdate"] != "0000-00-00") {
            $editdisabled = "none";
            $deletedisabled = "none";
        }
    }
    $amount = $get['amount'];
}


$repeatVoucher = "";


if (isset($_GET["vouchno"])) {
    $repeatVoucher = $_GET["vouchno"];
}

if ($_GET["mode"] == "last") {
    $repeatVoucher = $qvouch;
}

if (isset($_GET["repeat"])) {

    $zdb = $_SESSION["zdbyear_" . $dbname];
    mysqli_select_db($conn, $zdb);
    $addflag = 0;

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

    $getbank = mysqli_query($conn, "SELECT * FROM `$custdb` WHERE `accode` = '$get[bankname]'");
    $banknm = mysqli_fetch_array($getbank);

    $getparty = mysqli_query($conn, "SELECT * FROM `$custdb` WHERE `accode` = '$get[party]'");
    $gtpt = mysqli_fetch_array($getparty);


    //    $getstaff = mysqli_query($conn, "SELECT * FROM `$custdb` WHERE `accode` = '$get[staff]'");
//    $fetstaff = mysqli_fetch_array($getstaff);
    $result2 = mysqli_query($conn, "SELECT * FROM `$billdb` WHERE source = 'BR' and bnkvouch = '$get[vouchno]'") or die(mysqli_error($conn));


    if ($usertype == 3) {

        if ($get["cleardt"] != '0000-00-00') {
            $editdisabled = "none";
            $deletedisabled = "none";
        }
        if ($get["retdate"] != "0000-00-00") {
            $editdisabled = "none";
            $deletedisabled = "none";
        }
    }

    $gen1 = mysqli_query($conn, "SELECT MAX($keyfld) AS maxcode FROM `$maindb` LIMIT 0,1 ") or die(mysqli_error($conn));

    if (mysqli_num_rows($gen1) > 0) {
        $vvouch = mysqli_fetch_assoc($gen1);
        $rqvouch = $vvouch["maxcode"] + 1;
    } else {
        $rqvouch = '1';
    }
    $qvouch = $rqvouch;
    $amount = 0;
}


if (isset($_GET["delete"])) {
    mysqli_query($conn, "LOCK TABLES `bankrecp` WRITE, `actran` WRITE, `billsett` WRITE") or die(mysqli_error($conn));

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

    $delsett = " source = '$source' AND bnkvouch = '$_GET[vouchno]'";
    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]' ";
    delnew($zdb, "$accdb", "$delcond", "$file?mode=last");
    delnew($zdb, "$billdb", "$delsett", "$file?mode=last");


    mysqli_query($conn, "UNLOCK TABLES");
}

include("includes/linkshead.php");
?>
<script type="text/javascript">
    //    $(document).ready(function () {
    //        $('body').on('change', '#party', getBalance);
    //        function getBalance() {
    //            var acname = $("#party").val();
    //            var vouchdt = $(".vouchdt").val();
    //            $(".fetbal").html("");
    //            if (acname != '') {
    //                $.post('get_Balance_show.php', {acname: acname, vouchdt: vouchdt}, function (data) {
    //                    $(".fetbal").html(data);
    //                });
    //            }
    //        }
    //    });
</script>
<script>
    $(document).ready(function () {
        <?php
        if (isset($_GET["repeat"])) {
            ?>
            $('body').find('.form').removeAttr('disabled', 'disabled');
            <?php
        }
        ?>
    });
</script>

<script src="MyScript/bankrecp.js" type="text/javascript"></script>
<script src="MyScript/checkdate.js" type="text/javascript"></script>
<script src="MyScript/shortkeys.js" type="text/javascript"></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-6">
                <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>
                    <input type="date" value="<?= $zStartDate ?>" style="width: 1px;border: none" class="zstdate">
                    <input type="date" value="<?= $zEndDate ?>" style="width: 1px;border: none" class="zenddate">
                    <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">Receipt Voucher</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control form vouchno" id="vouchno" name="vouchno"
                                    value="<?php echo ($addflag != 1) ? $get["vouchno"] : "$qvouch"; ?>" required
                                    readonly>
                                <input type="hidden" class="form-control form trnflag" name="trnflag"
                                    value="<?php echo ($addflag != 1) ? $get["trnflag"] : ""; ?>" readonly>
                                <input type="hidden" class="form-control form billwise" name="billwise"
                                    value="<?php echo $gtpt["billwise"]; ?>" readonly>
                                <input type="hidden" class="form-control form billflag" name="billflag" value="0">

                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Voucher Date</label>
                            </div>
                            <div class="col-lg-4 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control form vouchdt focusfield" name="vouchdt"
                                    value="<?php echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>" required>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                                <a class="btn btn-primary" href="bankr_voucher.php?vouchno=<?= $qvouch; ?>"
                                    tabindex="-1" target="_blank">Voucher</a>
                            </div>
                        </div>


                        <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">Bank Name</label>
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7 pad">
                                <select class="form-control form select2" id="bankname" name="bankname"
                                    style='width:100%' required>
                                    <option value="<?php echo ($addflag != 1) ? $banknm['accode'] : ""; ?>">
                                        <?php echo ($addflag != 1) ? $banknm['name'] : ""; ?></option>
                                    <?php
                                    $mown = mysqli_query($conn, "SELECT * FROM `$custdb` where `grpcode` = '001' order by name ") or die(mysqli_error($conn));
                                    while ($trow = mysqli_fetch_array($mown)) {
                                        echo "<option value=$trow[accode]>$trow[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <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">Receipt No.</label>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" name="recpno"
                                    value="<?php echo ($addflag != 1) ? $get['recpno'] : ""; ?>"
                                    class="form-control form recpno" readonly>
                            </div>

                        </div>
                        <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">Cheque / NEFT / RTGS No.</label>
                            </div>
                            <div class="col-lg-5 col-md-2 col-sm-2 col-xs-2 pad">
                                <input type="text" name="chqno"
                                    value="<?php echo ($addflag != 1) ? $get['chqno'] : ''; ?>"
                                    class="form-control form">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Cheque Date</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" name="chqdate"
                                    value="<?php echo ($addflag != 1) ? $get['chqdate'] : date('d-m-Y'); ?>"
                                    class="form-control form chqdate">
                            </div>
                        </div>

                        <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">Account</label>
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7 pad">
                                <select id="party" name="party" class="select2 form-control form party" required>
                                    <option value="<?php echo ($addflag != 1) ? $gtpt['accode'] : ""; ?>">
                                        <?php echo ($addflag != 1) ? $gtpt['name'] : ""; ?></option>
                                    <?php
                                    $mown1 = mysqli_query($conn, "SELECT * FROM `$custdb` where grpcode > '002' order by `name`") or die(mysqli_error($conn));
                                    while ($trow1 = mysqli_fetch_array($mown1)) {
                                        echo "<option value=$trow1[accode]>$trow1[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg balamt" style="color:red"></label>
                            </div>
                        </div>
                        <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">Amount</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" name="amount" id="amount" text-right
                                    value="<?php echo ($addflag != 1) ? $amount : ''; ?>"
                                    class="form-control form amount  numeric text-right" required>
                            </div>
                        </div>

                        <?php
                        if (!empty($result2)) {
                            $billstr2 = 'Received For Bill No. ';
                            $count = mysqli_num_rows($result2);
                            $no = 1;
                            while ($row2 = mysqli_fetch_array($result2)) {
                                $billstr2 = $billstr2 . $row2['billno'] . ",";
                            }
                            $billstri = $billstr2 . $row2['billno'] . ".&nbsp";
                        }

                        if ($get['remark1'] != '') {
                            $billstr = $get['remark1'];
                        } else {
                            $billstr = $billstri;
                        }
                        //                        browse($result2);
                        ?>
                        <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">Remark</label>
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7 pad">
                                <input type="text" name="remark1" value="<?php echo ($addflag != 1) ? $billstr : ''; ?>"
                                    class="form-control form remark1">
                            </div>
                        </div>
                        <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"></label>
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-8 col-xs-8 pad">
                                <input type="text" name="remark2"
                                    value="<?php echo ($addflag != 1) ? $get['remark2'] : ''; ?>"
                                    class="form-control form remark2">
                            </div>
                        </div>
                    </div>
                    <!--                    <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">Return</label> 
                                                                    </div>
                                                                    <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                                                                        <input type="checkbox" name="chqret" style="color:red" value="1" <?php echo ($get['chqret'] == "Y" ? 'checked' : ''); ?> class="form-control form" >
                                                                    </div>
                                            <div class="col-lg-3 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                <label class="label-control marg" style="color:green">Clear Date</label>
                                            </div>
                                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                                <input type="date"  name="cleardt" style="color:green" value="<?php echo ($addflag != 1) ? $get['cleardt'] : ""; ?>" class="form-control form cleardt">
                                            </div>
                                                                    <div class="col-lg-1 col-md-1 col-sm-2 col-xs-2 text-right pad">
                                                                        <label class="label-control marg" style="color:red">Return Date</label>
                                                                    </div>
                                                                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                                                        <input type="date"  name="retdate" style="color:red" value="<?php echo ($addflag != 1) ? $get['retdate'] : ""; ?>" class="form-control form retdate">
                                                                    </div>
                                        </div>-->
                    <div class="panel-footer">
                        <div class="row">
                            <div class='col-lg-10 col-md-11 col-sm-8 col-xs-10 pad'>
                                <?php include("includes/buttons.php"); ?>
                            </div>
                            <div class='col-lg-2 col-md-2 col-sm-2 col-xs-2 pad'>
                                <!--<input type='button' value='Repeat' class="btn btn-primary" name="repeat" id="repeatbut" onclick="window.location.href = 'bankrecp.php?mode=true&repeat=true&vouchno=<?php echo $repeatVoucher; ?>'" >-->
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal fade " tabindex="" id="settmodal" 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">Bill Settlement</h4>
                            </div>
                            <div class="modal-body">
                                <div class=" table-responsive">
                                    <div class="toolbar">
                                        <div class="row">
                                            <div class="col-lg-2"><label class="label-control marg"
                                                    style="color:red">Total Remain</label></div>
                                            <div class="col-lg-2"><input type="text" id="remain" name="remain"
                                                    class="form-control" readonly style=""></div>
                                            <div class="col-lg-2"><label class="label-control marg"
                                                    style="color:blue">Total Setoff</label></div>
                                            <div class="col-lg-2"><input type="text" id="totsetoff" name="totsetoff"
                                                    class="form-control" readonly style=""></div>
                                            <!--<div class="col-lg-2"><input id="submit" type='submit' name='submit' value='<?php // echo ($addflag == 0) ? "Update" : "Save";                                ?>' class="btn btn-primary"></div>-->
                                            <?php
                                            //                                    if (!isset($_GET["method"])) {
                                            ?>
                                            <!--<div class="col-lg-2"><input type='button' name='exit' value='Exit' class="btn btn-danger" onClick="window.location.href = '<?php echo $grid; ?>'"></div>-->
                                            <?php // }       ?>
                                        </div>
                                    </div>
                                    </header>
                                    <div id="div-2" class="accordion-body collapse in body">
                                        <div style="max-height:300px;overflow: auto; border: 0px solid;">
                                            <div id="data"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-5 col-md-12 col-sm-12 col-xs-12  pad">
                <div class="panel-body fetbal">

                </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">Voucher</option>
                                <option value="2">V.Date</option>
                                <option value="3">Account</option>
                                <option value="4">Amount</option>
                                <!-- <option value="5">NEFT</option>
                                <option value="6">Cheque Date</option>
                                <option value="6">Account</option>
                                <option value="7">Amount</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="1">Voucher</option>
                                <option value="2">V.Date</option>
                                <option value="3">Account</option>
                                <option value="4">Amount</option>
                                <!-- <option value="5">NEFT</option>
                                <option value="6">Cheque Date</option>
                                <option value="6">Account</option>
                                <option value="7">Amount</option> -->
                            </select>
                        </div>
                        <div class="col-lg-2">
                            <select class="form-control orderAs">
                                <option value="asc">Asc</option>
                                <option value="desc">Desc</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">
                    </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 style="background-color:#78909C;">
                                    <th width="7%">Voucher</th>
                                    <th width="8%">V.Date</th>
                                    <th width="8%">Account</th>
                                    <!-- <th width="8%">Receipt</th>
                                    <th width="8%">NEFT</th>
                                    <th width="8%">Cheque Date</th>
                                    <th width="8%">Account</th> -->
                                    <th width="8%">Amount</th>
                                    <th width="8%">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>