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

$formname = 'Cash Payment';
$maindb = 'cashpay';
$accdb = 'actran';
$billdb = 'billsett';

$file = 'cashpay.php';
$grid = '';
$source = 'CP';
$ord = '6';
$keyfld = "vouchno";
$trandbexist = 0;
$focusfld = "name";
$printfile = 'cashpay_fr.php';
$zyear = right($zdb, 4);
$zStartDate = $_SESSION["fromdate"];
$zEndDate = $_SESSION["todate"];
$fseries = $_SESSION["society_" . $dbname];
$usertype = $_SESSION["usertype_" . $dbname];
$adduser = $_SESSION['username_' . $dbname];
date_default_timezone_set("Asia/Kolkata");
$adddate = date("Y-m-d");
$addtime = date("h:i:sa");
$keycond = "";

$para = $_GET["para"];
// $paracond = "AND `frmac`='$para'";
$paracond = "";

$tourcode = $_SESSION['tourcode'];
$tourname = $_SESSION['tourname'];
$tourcond = "AND tour = '$tourcode'";

$admin = $_SESSION["admin_" . $dbname];
$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;
    $vouchdt = $_POST["vouchdt"];
    $bankname = $_POST["bankname"];
    $nameprint = $_POST["nameprint"];
    $recpno = $_POST["recpno"];
    $party = $_POST["party"];
    $flatno = $_POST["flatno"];
    $amount = $_POST["amount"];
    $remark1 = $_POST["narr1"];
    $givenby = $_POST["givenby"];
    $remark2 = $_POST["narr2"];
    $payfor = $_POST["payfor"];
    $tour = $_POST["tour"];
    $regnno = $_POST["regnno"];
    $recpagnst = $_POST["recpagnst"];

    // browse($qvouch);
    $mvouch = $qvouch;

    if ($bankname == "") {
        $a = 0;
        browse("Bank Name Cannot Be Empty");
        header("refresh: ; $file?vouchno=$_GET[vouchno]");
    }

    if ($party == "") {
        $a = 0;
        browse("A/c. Name Cannot Be Empty");
        header("refresh: ; $file?vouchno=$_GET[vouchno]");
    }

    if ($amount == "") {
        $a = 0;
        browse("Amount Cannot Be Empty");
        header("refresh: ; $file?vouchno=$_GET[vouchno]");
    }

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

        if ($addflag == 1) {
            $gen1 = mysqli_query($conn, "SELECT MAX(vouchno+0) AS maxcode FROM `$maindb`  where $keyfld != ''  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';
            }

            $mvouch = $qvouch;
        }


        #########################END BILL SETTLEMENT###############################################

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

        if ($amount > 0) {
            $minus_amt = ($amount * -1);
            $getbankinit = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode` = '$bankname'");
            $bankinit = mysqli_fetch_array($getbankinit);
            $binit = $bankinit['init'];

            $qrygrp = mysqli_query($conn, "select `grpcode` from accmast where `accode` = '$party'") or die(mysqli_error($conn));
            $fetgrp = mysqli_fetch_array($qrygrp);
            $pgrp = $fetgrp['grpcode'];

            // cash part
            mysqli_query($conn, "INSERT INTO `$accdb`(series, date, vouchno, source , flatno, recpno, trnno, bankinit, accode,  grpcode, amount, forac, tour, `regnno`, `recpagnst`, `ord`)
                    VALUES ('$fseries','$vouchdt','$mvouch', '$source', '$flatno', '$recpno',  '001', '$binit', '$bankname', '002', '$amount', '$para', '$tour', '$regnno', '$recpagnst', '$ord') ") or die(mysqli_error($conn));

            // party part
            mysqli_query($conn, "INSERT INTO `$accdb`(series, date, vouchno, source, flatno, `recpno`, trnno, bankinit, accode, grpcode, amount, forac, tour, `regnno`, `recpagnst`, `ord`)
                     VALUES ('$fseries','$vouchdt','$mvouch', '$source', '$flatno', '$recpno', '002', '$binit', '$party',  '$pgrp', '$minus_amt', '$para', '$tour', '$regnno', '$recpagnst', '$ord')") or die(mysqli_error($conn));
        }

        if ($addflag == 1) {
            mysqli_query($conn, "INSERT INTO `$maindb`(series, vouchno ,`vouchdt`, `bankcode`, `recpno`, `flatno`,`accode`,`amount`,`narr1`,`narr2`,frmac,
                                                 adduser, adddate, addtime, tour, `payfor`, `givenby`, `regnno`, `recpagnst`,`nameprint`)
                                       Values ('$fseries', '$mvouch', '$vouchdt', '$bankname', '$recpno', '$flatno','$party','$amount','$remark1','$remark2','$para',
                                                '$adduser', '$adddate', '$addtime','$tour', '$payfor', '$givenby', '$regnno', '$recpagnst', '$nameprint')") or die(mysqli_error($conn));
        } else {
            $editdate = date("Y-m-d");
            $edittime = date("h:i:sa");
            mysqli_query($conn, "UPDATE `$maindb` SET  vouchdt='$vouchdt', bankcode='$bankname', `recpno`='$recpno' ,`accode`='$party',
                         amount='$amount', flatno='$flatno', `narr1`='$remark1', `narr2`='$remark2', `edituser`='$adduser', tour='$tour',
                         `edittime`='$edittime',`editdate`='$editdate', `frmac`='$para', `payfor`='$payfor',`givenby`='$givenby', `regnno`='$regnno', `recpagnst`='$recpagnst', `nameprint`='$nameprint'
                          where vouchno = '$mvouch' $paracond") or die(mysqli_error($conn));
        }
        mysqli_query($conn, "UNLOCK TABLES");

        if ($addflag == 1) {
            //            insmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit&para=$para");
        } else {
            //            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit&para=$para");
        }
    }
}

if ($addflag != 1) {
    $getvouch = '';
    if ($addflag == 0) {
        $getvouch = $_GET[$keyfld];
    } else {
        $getvouch = $qvouch;
    }
    $result = mysqli_query($conn, "SELECT *,DATE_FORMAT(`editdate`,'%d-%m-%Y') as editdate, DATE_FORMAT(`adddate` ,'%d-%m-%Y')AS adddate 
                           FROM `$maindb` WHERE $keyfld='$getvouch' $paracond $tourcond") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);

    $getcash = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode` = '$get[bankcode]' ");
    $cash = mysqli_fetch_array($getcash);

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

    $gettour = mysqli_query($conn, "SELECT code,name FROM tour where code='$get[tour]'") or die(mysqli_error($conn));
    $fettour = mysqli_fetch_array($gettour);
}

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


/* DELETE */
if (isset($_GET["delete"])) {
    mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `accmast` WRITE, `$accdb` WRITE") or die(mysqli_error($conn));

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

    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]' ";
    delnew($zdb, "$accdb", "$delcond", "$file?mode=last&para=$para");

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

include("includes/linkshead.php");
?>
<script src="MyScript/cashpay_search.js" type="text/javascript"></script>
<script src="MyScript/cashpay.js" type="text/javascript"></script>
</head>

<body>
    <form action='' method='POST'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-6">
                <div class="panel panel-default">
                    <div class="panel-heading" style="padding-top:5px;padding-bottom: 0px">

                        <div class="row" style="background-color:#F5F5F5">
                            <div class="col-lg-4" style="color:black">
                                <h4><?php echo $formname; ?></h4>
                            </div>
                            <?php if ($usertype == 1) { ?>

                                <div class="col-lg-3"><label class=" marg" style="color:green;font-size: 14px">&nbsp;<?php echo $get["adduser"]; ?></label><br>
                                    <?php if ($get["edituser"] != '') { ?>
                                        <label class="marg" style="color:red;font-size: 14px"><?php echo $get["edituser"]; ?></label>
                                    <? } ?>
                                </div>
                                <div class="col-lg-2"><label class=" marg" style="color:green;font-size: 14px"><?php echo $get["adddate"]; ?></label>
                                    <?php if ($get["editdate"] != '00-00-0000') { ?>
                                        <label class="marg" style="color:red;font-size: 14px"><?php echo $get["editdate"]; ?></label>
                                    <? } ?>
                                </div>
                                <div class="col-lg-1"><label class="marg" style="color:green;font-size: 14px"><?php echo $get["addtime"]; ?></label>
                                    <?php if ($get["edittime"] != '00:00:00') { ?>
                                        <label class=" marg" style="color:red;font-size: 14px"><?php echo $get["edittime"]; ?></label>
                                    <? } ?>
                                </div>
                            <? } ?>

                        </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 showmesg">
                            <div class="col-lg-2 col-md-3 col-sm-4 col-xs-4  pad text-right"></div>
                            <div class="col-lg-8 col-md-3 col-sm-4 col-xs-4  pad text-right">

                                <input type="text" class="form-control tranmesg getmesg form" style="color:red;font-size: 25px;" readonly="readonly">
                            </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">Tour</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2  pad">
                                <select name="tour" class="form-control form tour select2" style="width:100%">
                                    <option value="<?php echo ($addflag != 1) ? $fettour['code'] : "$tourcode"; ?>"><?php echo ($addflag != 1) ? $fettour['name'] : "$tourname"; ?></option>
                                    <?php
                                    //                                    $mowntr = mysqli_query($conn, "SELECT `code`, `name` FROM `tour` ORDER BY name") or die(mysqli_error($conn));
                                    //                                    while ($trowtr = mysqli_fetch_array($mowntr)) {
                                    //                                        echo "<option value='$trowtr[code]'>$trowtr[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">Voucher</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-8 col-xs-8 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 year" value="<?php echo $myear ?>">
                                <input type="hidden" class="form-control form para" value="<?php echo $para ?>">
                                <input type="hidden" class="form-control form trnflag" name="trnflag" value="<?php echo ($addflag != 1) ? $get["trnflag"] : ""; ?>" readonly>

                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Date</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-8 col-xs-8 pad">
                                <input type="date" class="form-control form vouchdt focusfield" name="vouchdt" id="vouchdt" value="<?php echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>">
                            </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">Cash Name</label>
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-8 col-xs-8 pad">
                                <select class="form-control form select2" name="bankname" id="bankname" style='width:100%'>
                                    <?php
                                    // if ($para == "M") {
                                        $mcode = "3";
                                        $mname = "CASH ON HAND";
                                    // } else {
                                    //     if ($para == "O") {
                                    //         $mcode = "37";
                                    //         $mname = "PETTY CASH";
                                    //     } else {
                                    //         $mcode = "38";
                                    //         $mname = "PETTY CASH MATERIAL";
                                    //     }
                                    // }
                                    ?>
                                    <option value="<?php echo ($addflag != 1) ? $cash['accode'] : "$mcode"; ?>"><?php echo ($addflag != 1) ? $cash['name'] : "$mname"; ?></option>
                                    <?php
                                    if ($para != "E") {
                                        $mown = mysqli_query($conn, "SELECT `accode`, `name` FROM `accmast` where `grpcode` = '002'") 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-4 col-xs-4 text-right pad">
                                <label class="label-control marg" style="color:#920aff;font-weight:bold">Payment Against</label>
                            </div>
                            <div class="col-lg-2 col-md-8 col-sm-8 col-xs-8 pad " style="border: 2px solid #920aff;border-radius:5px">
                                <select id="recpagnst" name="recpagnst" class="form-control select2 form pad recpagnst" required>
                                    <option></option>
                                    <option <?php
                                            if ($get['recpagnst'] == 'F') {
                                                echo "selected='selected'";
                                            }
                                            ?> value="F">FIT</option>
                                    <option <?php
                                            if ($get['recpagnst'] == 'U') {
                                                echo "selected='selected'";
                                            }
                                            ?> value="U">UMRAH</option>
                                </select>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label style="color:#26A69A" label-control marg><b id="bankamt"></b></label>
                            </div>
                        </div>

                        <?php
                        $expcond = "grpcode = '012'";

                        if ($para == "H") {
                            $expcond = "grpcode IN ('009','044','010','022')";
                        ?>
                        <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">Regn. No.</label>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" class="form-control form regnno" id="regnno" style="font-size: 17px;" name="regnno" value="<?php echo ($addflag != 1) ? $get["regnno"] : ""; ?>">
                            </div>
                        </div>
                        <?php } ?>


                        <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-8 col-xs-8 pad">
                                <select id="party" name="party" class="form-control form select2 party">
                                    <option value="<?php echo ($addflag != 1) ? $gtpt['accode'] : " "; ?>"><?php echo ($addflag != 1) ? $gtpt['name'] : " "; ?></option>
                                    <?php
                                    $mown = mysqli_query($conn, "SELECT * FROM `accmast` where $expcond order by `name`") or die(mysqli_error($conn));
                                    while ($trow = mysqli_fetch_array($mown)) {
                                        echo "<option value=$trow[accode]>$trow[name]</option>";
                                    }
                                    ?>
                                </select>
                                <input type="hidden" name="grpcode" id="grpcode" value="<?php echo ($addflag != 1) ? $gtpt['grpcode'] : ''; ?>" class="form-control form grpcode numeric ">
                            </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">Name to Print</label>
                            </div>
                            <div class="col-lg-6 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" name="nameprint" id="nameprint" style="font-weight: bold;font-size: 18px" value="<?php echo ($addflag != 1) ? $get['nameprint'] : ''; ?>" class="form-control form nameprint">
                            </div>
                        </div>

                        <?PHP if ($para == "H") { ?>

                        <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">Ticket</label>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="radio" name="payfor" id="payfor" style="font-weight: bold;font-size: 15px;height:20px" value="T" <?php
                                                                                                                                                if ($get['payfor'] == "T") {
                                                                                                                                                    echo "checked";
                                                                                                                                                }
                                                                                                                                                ?> class="form-control form amount  numeric text-right">
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Tour</label>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="radio" name="payfor" id="payfor" style="font-weight: bold;font-size: 15px;height:20px" value="U" <?php
                                                                                                                                                if ($get['payfor'] == "U") {
                                                                                                                                                    echo "checked";
                                                                                                                                                }
                                                                                                                                                ?> class="form-control form amount  numeric text-right">
                            </div>
                        </div>
                        <?PHP } ?>


                        <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-2 col-md-2 col-sm-8 col-xs-8 pad">
                                <input type="text" name="amount" id="amount" style="font-weight: bold;font-size: 18px" value="<?php echo ($addflag != 1) ? $get['amount'] : ''; ?>" class="form-control form text-right amount">
                            </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">Given By</label>
                            </div>
                            <div class="col-lg-4 col-md-2 col-sm-3 col-xs-3 pad">
                                <input name="givenby" id="givenby" maxlength="20" style="font-weight: bold;font-size: 18px" value="<?php echo ($addflag != 1) ? $get['givenby'] : ''; ?>" class="form-control form" required>
                            </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">Narration</label>
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7 pad">
                                <input type="text" name="narr1" value="<?php echo ($addflag != 1) ? $get['narr1'] : ''; ?>" class="form-control form narr1">
                            </div>
                        </div>
                        <?php
                        //                        $billstr2 = 'Paid For Bill No. ';
                        //                        if ($result2 != '') {
                        //                            $count = mysqli_num_rows($result2);
                        //                            $no = 1;
                        //
                        //                            while ($row2 = mysqli_fetch_array($result2)) {
                        //                                $billstri = $billstr2 . $row2[billno] . ",&nbsp";
                        //                            }
                        //
                        ////                            $billstri = $billstr2 . $row2[billno] . ".&nbsp";
                        //                        }
                        if ($get['narr2'] != '') {
                            $billstr = $get['narr2'];
                        } else {
                            $billstr = $billstri;
                        }
                        ?>
                        <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="narr2" value="<?php echo ($addflag != 1) ? $get['narr2'] : ''; ?>" class="form-control form narr2">
                            </div>
                        </div>
                    </div>
                    <div class="panel-footer">
                        <?php include("includes/buttons.php"); ?>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <form action='cashpay_mult_fr.php' target="_blank" method='POST'>
        <div class="modal fade" id="myModal" role="dialog">
            <div class="modal-dialog">

                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title text-center">Multiple Prints</h4>
                    </div>
                    <div class="modal-body primarymodal">
                        <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">From Date</label>
                            </div>
                            <div class="col-lg-4 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" name="frmdate" class="form-control mfrmdt" value="<?php echo Date("Y-m-d"); ?>" />
                            </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">To Date</label>
                            </div>
                            <div class="col-lg-4 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" name="todt" class="form-control todate" value="<?php echo Date("Y-m-d"); ?>" />
                            </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-5 col-md-5 col-sm-3 col-xs-3 pad">
                                <select id="account" name="accode" class="select2 form-control accode">
                                    <option value=""></option>
                                    <?php
                                    $mown1 = mysqli_query($conn, "SELECT * FROM `accmast` where grpcode > '002' and grpcode !='011' and grpcode !='010'
                                             and series = '$fseries' 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>
                        <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">Print Narration</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 pad">
                                <select class="form-control narr" name="narration">
                                    <option value=""></option>
                                    <option value="1">Yes</option>
                                </select>
                            </div>
                        </div>
                        <br>
                        <div class="row ">
                            <div class="col-lg-3">
                            </div>
                            <div class="col-lg-6">
                                <button type="button" class="btn btn-default text-center proceed">Proceed</button>
                                <button type="button" class="btn btn-default text-center" data-dismiss="modal">Close</button>
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>

                    <!--2nd modal-->
                    <div class="modal-body secondrymodal">
                        <div class="mprint " style="max-height: 400px;overflow: auto;">

                        </div>
                        <br>
                        <div class="row ">
                            <div class="col-lg-3">
                                <input type="hidden" class="form-control fdate" name="mfrmdate" value="">
                                <input type="hidden" class="form-control tdate" name="mtodate" value="">
                            </div>
                            <div class="col-lg-6">
                                <input type="submit" target='_blank' class="btn text-center proceed2" value="Proceed">
                                <button type="button" class="btn btn-default text-center" data-dismiss="modal">Close</button>
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>
                    <!--2nd Modal End-->

                    <div class="modal-footer">
                    </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">Voucher</option>
                                <option value="2">Date</option>
                                <option value="3">Account</option>
                                <option value="4">Amount</option>
                                <option value="5">Cash Name</option>
                                <option value="6">Receipt No.</option>
                                <option value="7">Narration</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">Voucher</option>
                                <option value="2">Date</option>
                                <option value="3">Account</option>
                                <option value="4">Amount</option>
                                <option value="5">Cash Name</option>
                                <option value="6">Receipt No.</option>
                                <option value="7">Narration</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" style="color: black; background-color:#F17B25;" 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 style="color: black;" width="12%">Voucher</th>
                                    <th style="color: black;" width="12%">Date</th>
                                    <th style="color: black;" width="12%">Account</th>
                                    <th style="color: black;" width="12%">Amount</th>
                                    <th style="color: black;" width="20%">Cash Name</th>
                                    <!--<th style="color: black;" width="12%">Receipt No.</th>-->
                                    <th style="color: black;" width="10%">Narration</th>
                                    <th style="color: black;" width="10%">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" style="color: black; background-color:#EFE4B0;" class="btn btn-primary sprev" value="Previous">
                            <input type="button" style="color: black; background-color:#EFE4B0;" 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>