<?php
ob_start();
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');
$maindb = 'bankpay';
$accdb = 'actran';
$billdb = 'billsett';

$file = 'bankpay.php';
$grid = '';
$source = 'BP';
$ord = '8';
$keyfld = "vouchno";
$trandbexist = 0;
$focusfld = "bankname";
$printfile = 'bankpay_fr.php';
$type = "P";
$myear = $_SESSION["tit_" . $dbname];
$usertype = $_SESSION["usertype_" . $dbname];
$adduser = $_SESSION['username_' . $dbname];

$tourname = $_SESSION['tourname'];
$tourcode = $_SESSION['tourcode'];

$tourcond = "AND tour = '$tourcode'";

date_default_timezone_set("Asia/Kolkata");
$adddate = date("Y-m-d");
$addtime = date("h:i:sa");
$keycond = "";
$para = $_REQUEST["para"];
$paracond = " and `frmac`='$para'";
if ($para == "H") {
    $formname = 'Bank Payment';
} else {
    $formname = 'Bank Payment Expense';
}

$fseries = $_SESSION["society_" . $dbname];

if (empty($fseries)) {
    browse("Invalid Society Credentials Forced Logout.");
    print '<script type="text/javascript">';
    print " top.window.location = 'index.php'";
    print '</script>';
}

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zroot = $_SESSION["zdir"];
$bankcond = '';
$getcomp = mysqli_query($conn, "SELECT code,compname FROM `company` WHERE `code`='$fseries' ") or die(mysqli_error($conn));
$comp = mysqli_fetch_array($getcomp);

$zyear = right($zdb, 4);
$zStartDate = $_SESSION["fromdate"];
$zEndDate = $_SESSION["todate"];

mysqli_select_db($conn, $zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");
if (isset($_POST["submit"])) {

    $a = 1;
    $vouchdt = $_POST["vouchdt"];
    $qvouch = $_POST["vouchno"];

    $recpno = $_POST["recpno"];
    $bankname = $_POST["bankname"];
    $givenby = $_POST["givenby"];
    $chqno = $_POST["chqno"];
    $nameprint = $_POST["nameprint"];
    $chqdate = $_POST["chqdate"];
    $rtgsno = $_POST["rtgsno"];
    $drawbank = $_POST["drawbank"];
    $flatno = $_POST["flatno"];
    $party = $_POST["party"];
    $amount = $_POST["amount"];
    $remark1 = $_POST["remark1"];
    $remark2 = $_POST["remark2"];
    $chqret = $_POST["chqret"];
    $retdate = $_POST["retdate"];
    $counter = $_POST["counter"];
    $payfor = $_POST["payfor"];
    $tour = $_POST["tour"];
    $regnno = $_POST["regnno"];
    $recpagnst = $_POST["recpagnst"];


    $rsword = rsword($amount);
    $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 ($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;
        }

        ######################## ACCOUNTS PART ######################################
        //        #########################START BILL SETTLEMENT###############################################

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


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

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

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

        $minus_amt = ($amount * -1);
        // bank part
        mysqli_query($conn, "INSERT INTO `$accdb`(series, date, vouchno, source, flatno, trnno, accode, bankinit, grpcode, amount, chqno,
                                          chqdate,recpno,clrdate,forac, tour, `regnno`, `recpagnst`, `ord`)
                    VALUES ('$fseries', '$vouchdt','$mvouch', '$source', '$flatno', '001', '$bankname', '$binit', '001', '$amount','$chqno',
                            '$chqdate','$recpno','$vouchdt','$para', '$tour', '$regnno', '$recpagnst', '$ord')") or die(mysqli_error($conn));

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


        if ($addflag == 1) {
            $para = $_REQUEST["para"];
            $uuid = $_SESSION["uuid"];
            mysqli_query($conn, "INSERT INTO `$maindb`( `vouchno`, `series`, `vouchdt`, `bankcode`, bankinit, `recpno`, `rtgsno`, `chqno`,`chqdate`,tour,
                                                `drawbank`, `flatno`,`accode`,`amount`,`narr1`,`narr2`,`retdate`, adduser, adddate, addtime,frmac,`payfor`,
                                                 `givenby`, `regnno`, `recpagnst`,`nameprint`,uuid)
                                       Values ('$mvouch', '$fseries', '$vouchdt', '$bankname', '$binit', '$recpno', '$rtgsno', '$chqno','$chqdate','$tour',
                                               '$drawbank', '$flatno', '$party','$amount','$remark1','$remark2','$retdate', '$adduser', '$adddate', '$addtime','$para', 
                                               '$payfor', '$givenby', '$regnno', '$recpagnst', '$nameprint', '$uuid')") or die(mysqli_error($conn));
            insmess();
            mysqli_query($conn, "UNLOCK TABLES");
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit&para=$para");
        } else {
            $mvouch = $qvouch;
            $editdate = date("Y-m-d");
            $edittime = date("h:i:sa");

            mysqli_query($conn, "UPDATE `$maindb` SET   vouchdt='$vouchdt', bankcode='$bankname', bankinit='$binit', tour='$tour',
                    recpno='$recpno', rtgsno='$rtgsno', chqno='$chqno',chqdate='$chqdate',drawbank='$drawbank',flatno='$flatno',`accode`='$party',
                    `amount`='$amount',`narr1`='$remark1',`narr2`='$remark2',`retdate`='$retdate',`rsword`='$rsword',
                    `edituser`='$adduser',`edittime`='$edittime',`editdate`='$editdate', `payfor`='$payfor', `givenby`='$givenby',`regnno`='$regnno', `recpagnst`='$recpagnst', `nameprint`='$nameprint'
                     where vouchno = '$mvouch' $paracond") or die(mysqli_error($conn));
            updmess();
            mysqli_query($conn, "UNLOCK TABLES");

            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 * FROM `$maindb` WHERE $keyfld='$getvouch' $tourcond $paracond") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);

    $getbank = mysqli_query($conn, "SELECT accode, name FROM `accmast` WHERE `accode` = '$get[bankcode]' ") or die(mysqli_error($conn));
    $banknm = mysqli_fetch_array($getbank);

    $getparty = mysqli_query($conn, "SELECT accode, name,grpcode FROM `accmast` WHERE `accode` = '$get[accode]'") or die(mysqli_error($conn));
    $gtpt = mysqli_fetch_array($getparty);

    $amt = $get['amount'];

    $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 = "";

if (isset($_GET["delete"])) {
    mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `accmast` WRITE, `$accdb` WRITE, `billsett` 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/bankpay.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>

    <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">
                                <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">
                            <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>
                                </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">Payment Voucher</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 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 year" value="<?php echo $myear ?>">
                                <input type="hidden" class="form-control form para" value="<?php echo $para ?>">
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Date</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 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"); ?>" required>
                            </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>

                        <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'] : "$qvouch"; ?>" class="form-control form">
                            </div>
                        </div>

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

                        if ($para == "H") {
                            $expcond = "grpcode IN ('009','044','010')";
                        ?>
                            <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-2 col-sm-2 col-xs-2 pad">
                                    <input type="text" class="form-control form regnno" id="regnno" name="regnno" style="font-size: 17px;" 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-7 col-xs-7 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-3 col-xs-3 pad">
                                <input name="amount" id="amount" style="font-weight: bold;font-size: 18px" value="<?php echo ($addflag != 1) ? $get['amount'] : ''; ?>" class="form-control form amount  numeric text-right" 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">Given By</label>
                            </div>
                            <div class="col-lg-4 col-md-2 col-sm-3 col-xs-3 pad">
                                <input name="givenby" id="givenby" 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">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="bankcode" 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 `accmast` where `grpcode` = '001'  ") 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">Cheque No.</label>
                            </div>
                            <div class="col-lg-2 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 class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">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">RTGS No.</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-2 col-xs-2 pad">
                                <input type="text" name="rtgsno" value="<?php echo ($addflag != 1) ? $get['rtgsno'] : ''; ?>" class="form-control form">
                            </div>
                        </div>
                        <br>
                        <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="remark1" value="<?php echo ($addflag != 1) ? $get['narr1'] : ''; ?>" class="form-control form remark1">
                            </div>
                        </div>
                        <?php
                        $billstr2 = 'Received 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="remark2" value="<?php echo ($addflag != 1) ? $get['narr2'] : ''; ?>" class="form-control form remark2">
                            </div>
                        </div>
                        <br>
                        <br>

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

                    </div>
                </div>
            </div>
            <div class="col-lg-6">
                <div class="row tranmesg">
                    <!--<div class="col-lg-2"></div>-->
                    <div class="col-lg-10">
                        <label class="label-control ">
                            <input type="text" style="width:200%;color: red" class="form-control trnmsg" readonly>
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <form action='bankpay_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-8 col-md-8 col-sm-3 col-xs-3 pad">
                                <select id="account" name="accode" class="form-control select2 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 select2 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">Bank Name</option>
                                <option value="6">Receipt No.</option>
                                <option value="7">Cheque No.</option>
                                <option value="8">Date</option>
                                <option value="9">RTGS No.</option>
                                <option value="10">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">Bank Name</option>
                                <option value="6">Receipt No.</option>
                                <option value="7">Cheque No.</option>
                                <option value="8">Date</option>
                                <option value="9">RTGS No.</option>
                                <option value="10">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" 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="5%">Voucher</th>
                                    <th width="5%">Date</th>
                                    <th width="10%">Account</th>
                                    <th width=10%">Amount</th>
                                    <th width="20%">Bank Name</th>
                                    <th width="8%">Receipt No.</th>
                                    <th width="8%">Cheque No.</th>
                                    <th width="8%">Date</th>
                                    <th width="8%">RTGS No.</th>
                                    <th width="8%">Narration</th>
                                    <th 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="" class="btn btn-primary sprev" value="Previous">
                            <input type="button" style="" 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>