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

$formname = 'Bank Receipt';
$maindb = 'bankrecp';
$accdb = 'actran';
$billdb = 'billsett';
$printpdffile = "bankrecp2_pdf.php";

//browse("Account name to be decided");
$para = $_REQUEST["para"];
$paracond = "";
//if($para != ''){
//    $paracond = " and `grpcode`='042'";
//}
// browse($para);
$tourcode = $_SESSION['tourcode'];
$tourcond = "AND tour = '$tourcode'";

$keycond = " and `frmac`= '$para'";

// if ($para == "M") {
//     $mgrpcode = "010";
// } else {
//     $mgrpcode = "042";
// }
//browse($keycond);
$file = 'bankrecp_sk.php';
$grid = '';
$source = 'BR';
$ord = '7';
$keyfld = "vouchno";
$trandbexist = 0;
$focusfld = "name";
$printfile = 'bankrecp_fr.php';
$type = "S";

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

//$printfile = 'bankr_voucher.php';
$society = $_SESSION["society_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zroot = $_SESSION["zdir"];

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

$admin = $_SESSION["admin_" . $dbname];

$zyear = right($zdb, 4);

//$fseries = $_SESSION["soceity_" . $dbname];
//$keycond = "and `series`= '$society'";
//$zStartDate = getzdates($zyear, 'S');
//$zEndDate = getzdates($zyear, 'E');
$zStartDate = $_SESSION["fromdate"];
$zEndDate = $_SESSION["todate"];
mysqli_select_db($conn, $zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

$bankcond = '';
$getcomp = mysqli_query($conn, "SELECT code,compname,acinterest FROM $zroot.`company` WHERE `code`='$society' ") or die(mysqli_error($conn));
$comp = mysqli_fetch_array($getcomp);
$defbank = $comp['defbank'];
$zacinterest = $comp['acinterest'];
$chkrpvouch = trim($comp['radinv']);

if (!empty($defbank)) {
    $bankcond = "and `accode` = '$defbank'";
    $gbname = mysqli_query($conn, "SELECT name FROM $zdb.`accmast` where `accode` = '$defbank'") or die(mysqli_error($conn));
    $fbname = mysqli_fetch_array($gbname);
    $defbname = $fbname['name'];
}

$mrecpvouch = $disbrpvouch = "";
if ($chkrpvouch == "A") {
    $mrecpvouch = $qvouch;
    $disbrpvouch = "readonly";
}

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

    sleep(7);

    $a = 1;
    $vouchdt = $_POST["vouchdt"];
    $bankname = $_POST["bankname"];
    $recpno = $_POST["recpno"];
    $chqno = $_POST["chqno"];
    $chqdate = $_POST["chqdate"];
    $rtgsno = $_POST["rtgsno"];
    $drawbank = $_POST["drawbank"];
    $party = $_POST["party"];
    $amount = $_POST["amount"];
    $nameprint = $_POST["nameprint"];
    $remark1 = $_POST["remark1"];
    $remark2 = $_POST["remark2"];
    $note1 = $_POST["note1"];
    $note2 = $_POST["note2"];
    $chqret = $_POST["chqret"];
    $retdate = $_POST["retdate"];
    $counter = $_POST["counter"];
    $payfor = $_POST["payfor"];
    $recdby = $_POST["recdby"];
    $regnno = $_POST["regnno"];
    $billflag = $_POST["billflag"];
    $recpagnst = $_POST["recpagnst"];
    $balamt = $_POST["balamt"];
    // browse($billflag);
    $mvouch = $qvouch;

    if ($vouchdt == "") {
        $a = 0;
        browse("Date Cannot Be Empty");
        if ($addflag == 1) {
            header("location:javascript://history.go(-1)");
        } else {
            header("refresh: ; $file?vouchno=$_GET[vouchno]");
        }
    }

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

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

    if ($amount == "") {
        $a = 0;
        browse("Amount 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, $zroot.`billingcycle` WRITE, $zroot.`company` WRITE") or die(mysqli_error($conn));

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

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

        $qrygrp = mysqli_query($conn, "select `grpcode`,flatno,interest from accmast where `accode` = '$party'") or die(mysqli_error($conn));
        $fetgrp = mysqli_fetch_array($qrygrp);
        $pgrp = $fetgrp['grpcode'];
        $flatno = $fetgrp['flatno'];
        $intopen = $fetgrp['interest'];
        if ($billflag == 1) {

            $counter = $_POST["counter"];


            mysqli_query($conn, "DELETE FROM `$billdb` WHERE `bnkvouch` = '$mvouch' AND `source` = '$source' AND `bankinit` = '$binit' ") OR die(mysqli_error($conn));

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

                if (!empty($msetoff)) {
                    mysqli_query($conn, "INSERT IGNORE INTO `$billdb`(`yearno`, `type`, `vouchno`, `billno`, `setoff`, `party`, `source`, `bnkvouch`, `bankinit`, nodays, tour, billsrc)
                                VALUES('$myearno', '$type', '$mvouchno', '$mbillno', '$msetoff', '$party', '$source', '$mvouch', '$binit', '$mdays', '$tourcode', '$mbillsrc')") or die(mysqli_error($conn));
                }
            }
        }
        #########################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);

            // cash part
            mysqli_query($conn, "INSERT INTO `$accdb`(series, date, vouchno, source, flatno, trnno, accode, bankinit, grpcode, amount, chqno,
                                              chqdate,`recpno`,`clrdate`, `chqret`, `retdate`,forac, `regnno`,recpagnst,tour, ord)
                    VALUES ('$society','$vouchdt','$mvouch', '$source','$flatno', '001', '$bankname', '$binit', '001', '$minus_amt','$chqno', 
                            '$chqdate','$recpno','$vouchdt', '$chqret', '$retdate','$para','$regnno','$recpagnst','$tourcode', '$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`,`chqret`, `retdate`,forac, regnno, recpagnst,tour, ord)
                     VALUES ('$society','$vouchdt','$mvouch', '$source','$flatno', '002', '$party', '$binit', '$pgrp', '$amount','$chqno', '$chqdate',
                             '$recpno','$vouchdt' , '$chqret', '$retdate','$para', '$regnno','$recpagnst', '$tourcode','$ord')") or die(mysqli_error($conn));
        }

        if ($addflag == 1) {

            $uuid = $_SESSION["uuid"];

            mysqli_query($conn, "INSERT INTO `$maindb`( vouchno , series, `vouchdt`, `bankcode`, bankinit, `recpno`, `rtgsno`, `chqno`,`chqdate`,
                                                `drawbank`, `flatno`,`accode`,`amount`,`narr1`,`narr2`,`retdate`, `chqret`,`frmac`,recpagnst,balamt,
                                                  adduser, adddate, addtime, `note1`, `note2`, `payfor`,`recdby`, `regnno`, `tour`, `nameprint`,uuid)
                                       Values ('$mvouch', '$society', '$vouchdt', '$bankname', '$binit', '$mvouch', '$rtgsno', '$chqno','$chqdate',
                                               '$drawbank', '$flatno', '$party','$amount','$remark1','$remark2','$retdate', '$chqret','$para','$recpagnst','$balamt',
                                               '$adduser', '$adddate', '$addtime', '$note1', '$note2', '$payfor','$recdby', '$regnno', '$tourcode', '$nameprint', '$uuid')") or die(mysqli_error($conn));
            insmess();
            $mvouch = $qvouch;
            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', chqret = '$chqret',recpagnst='$recpagnst',balamt='$balamt',
                         recpno='$recpno', rtgsno='$rtgsno', chqno='$chqno',chqdate='$chqdate',drawbank='$drawbank',flatno='$flatno',`accode`='$party',
                         amount='$amount',`narr1`='$remark1',`narr2`='$remark2',`retdate`='$retdate' ,`edituser`='$adduser',`edittime`='$edittime',
                        `editdate`='$editdate', `note1`='$note1', `note2`='$note2', `payfor`='$payfor', `recdby`='$recdby', `regnno`='$regnno', `tour`='$tourcode', `nameprint`='$nameprint'  
                         where vouchno = '$mvouch' $keycond") 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 *,DATE_FORMAT(`editdate`,'%d-%m-%Y') as editdate, DATE_FORMAT(`adddate` ,'%d-%m-%Y')AS adddate 
                           FROM `$maindb` WHERE $keyfld='$getvouch' $tourcond $keycond") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);

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

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

$senable = "";
$cenable = "";
if (isset($_GET["delete"])) {
    mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `$accdb` WRITE, $billdb WRITE ") or die(mysqli_error($conn));

    $delsett = " source = '$source' AND bnkvouch = '$_GET[vouchno]' and tour = '$tourcode'";
    delnew($zdb, "billsett", "$delsett", "$file?mode=last");

    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]'";
    $delcond2 = " vouchno = '$_GET[vouchno]' $keycond";

    delnew($zdb, "$maindb", "$delcond2", "$file?mode=last");
    delnew($zdb, "$accdb", "$delcond", "$file?mode=last");

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

include("includes/linkshead.php");
?>
<script src="MyScript/bankrecp_sk.js" type="text/javascript"></script>
<script src="MyScript/bankrecp_search.js" type="text/javascript"></script>
<script src="MyScript/checkdate.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">
                    <div class="row" style="">
                        <div class="col-lg-3"><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">
                <input type="hidden" value="<?= $society ?>" class="society">
                <input type="hidden" value="<?= $mgrpcode ?>" class="grpcode">
                <input type="hidden" class="form-control form billflag" name="billflag" value="0">

                <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-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"; ?>"  readonly>
                            <input type="hidden" class="form-control form trnflag" name="trnflag" readonly value="<?php Echo ($addflag != 1) ? $get["trnflag"] : ""; ?>" >
                        </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" name="vouchdt" id="vouchdt" value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>"  autofocus 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'] : "$defbank"; ?>" ><?php echo ($addflag != 1) ? $banknm['name'] : "$defbname"; ?></option>
                                <?php
                                $mown = mysqli_query($conn, "SELECT accode,name 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-4 col-xs-4 text-right pad">
                            <label class="label-control marg" style="color:#920aff;font-weight:bold">Receipt 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>
                                <?php if ($_SESSION["menutype"] == 1) { ?>
                                    <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>
                                        <?php
                                    }
                                    if ($_SESSION["menutype"] == 3) {
                                        ?>
                                    <option <?php
                                    if ($get['recpagnst'] == 'F') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="F">FIT</option>
                                        <?php
                                    }
                                    if ($_SESSION["menutype"] == 2) {
                                        ?>
                                    <option <?php
                                    if ($get['recpagnst'] == 'U') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="U">UMRAH</option>
                                    <?php } ?>
                            </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 lblrnm"></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"] : ""; ?>" 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">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 accode, name FROM `accmast` where (grpcode ='010' OR grpcode = '044') order by `name` ") or die(mysqli_error($conn));
                                while ($trow1 = mysqli_fetch_array($mown1)) {
                                    echo "<option value='$trow1[accode]'>$trow1[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>
                    <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-3 col-sm-3 col-xs-3 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 amount  numeric text-right" required>
                        </div>
                        <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 text-right pad">
                            <label class="control-label marg"  style="color:red">Balance Amount</label>
                        </div>
                        <div class="col-lg-2 col-md-3 col-sm-8 col-xs-8 pad">
                            <input type="text" name="balamt" id="balamt" value="<?php echo ($addflag != 1) ? $get['balamt'] : ''; ?>" class="form-control form text-right numeric balamt" readonly tabindex="-1" style="background-color:#F5ECCB;color:red">
                        </div>
                    </div>

                    <div class="row umrdiv">
                        <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-1 col-md-3 col-sm-3 col-xs-3 pad" style="">
                            <input type="radio" name="payfor" id="tkt" 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-1 col-md-3 col-sm-3 col-xs-3 pad" style="">
                            <input type="radio" name="payfor" id="tour" 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>

                    <!--<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">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">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">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>
                    <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">Drawee Bank</label>
                        </div>
                        <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7 pad">
                            <input type="text" name="drawbank" value="<?php echo ($addflag != 1) ? $get['drawbank'] : ''; ?>" class="form-control form">
                        </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">Received By</label>
                        </div>
                        <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7 pad">
                            <input type="text" name="recdby" value="<?php echo ($addflag != 1) ? $get['recdby'] : $adduser; ?>" class="form-control form">
                        </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="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> -->
                    <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">Notes</label>
                        </div>
                        <div class="col-lg-7 col-md-7 col-sm-8 col-xs-8 pad">
                            <input type="text" name="note1" value="<?php echo ($addflag != 1) ? $get['note1'] : ''; ?>" class="form-control form note1" >
                        </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="note2" value="<?php echo ($addflag != 1) ? $get['note2'] : ''; ?>" class="form-control form note2" >
                        </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">Chq. Return</label>
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-8 col-xs-8 pad">
                            <input type="checkbox" style="color:pink" class="form-control form" name="chqret" value="Y" <? Echo ($get['chqret'] == "Y") ? "checked" : ""; ?> >
                        </div>
                        <div class="col-lg-2 col-md-2 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" class="form-control form retdate " name="retdate" id="retdate" value="<?php Echo ($addflag != 1) ? $get["retdate"] : ''; ?>" >
                        </div>
                    </div>
                </div>

                <!--Button-->
                <div class="panel-footer">
                    <div class="col-lg-12">
                        <?php include("includes/buttons_sk.php"); ?>
                    </div>
                    <input type="hidden" class="form-control form mobile" name="mobile" value="<?php Echo ($addflag != 1) ? $gtpt1['mobile'] : ""; ?>" >

                    <!-- <div class="col-lg-2">
                        <button id='smscust' type="button" class="btn btn-pad btn-lg smscust" style="background-color:grey;width: 100px ">
                            SMS
                        </button>
                    </div> -->
                </div>
                <!--End of Button-->
            </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>
    </form>

    <!-- Modal start -->
    <form action='bankrecp_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 fmdate" 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">Bank</label>
                            </div>
                            <div class="col-lg-5 col-md-5 col-sm-3 col-xs-3 pad">
                                <?php
//                                $compbank = mysqli_query($conn, "SELECT `defbank` FROM $zroot.`company` where `code` = '$society' ")or die(mysqli_error($conn));
//                                $fbank = mysqli_fetch_array($compbank);
//
//                                $getbank = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` where `accode` = '$fbank[defbank]' ")or die(mysqli_error($conn));
//                                $bank = mysqli_fetch_array($getbank);
                                ?>
                                <!--<input type="text" id="defbank" name="" class="form-control form " value="<?php Echo $bank['name']; ?>" >--> 
                            </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 select2" name="narration">
                                    <option value=""></option>
                                    <option value="1">Yes</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">Page Type</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 pad">
                                <select class="form-control pagetype select2" name="pagetype">
                                    <option value="2">Double</option>
                                    <option value="1">Single</option>
                                </select> 
                            </div>
                        </div>
                        <br>
                        <div class="row ">  
                            <div class="col-lg-3">
                            </div>
                            <div class="col-lg-1">
                                <button type="submit" id='subpdf' name='subpdf' formtarget="_blank" class="btn btn-pad btn-square" style="background-color:white;border: 1px solid red" target="_blank">
                                    <i class="fa fa-file-pdf-o" style="color:red; font-size: 15px;"></i>
                                </button>

                            </div>
                            <div class="col-lg-6">
                                <button type="button" class="btn btn-default text-center proceed" name="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="">
                                <input type="hidden" class="form-control ptype" name="ptype" value="">
                            </div>
                            <div class="col-lg-6">
                                <input type="submit"  target='_blank'  class="btn text-center proceed2" value="Proceed" name="proceed">
                                <button id='smsmulti' type="button" class="btn btn-pad btn-lg smsmulti" style="background-color:grey;width: 100px ">
                                    SMS
                                </button>
                                <button type="button" class="btn btn-default text-center" data-dismiss="modal">Close</button>
                            </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">Receipt No.</option>
                                <option value="2">Bank Name</option>
                                <option value="3">Account</option>
                                <option value="6">Regn. No.</option>
                                <option value="4">Cheque</option>
                                <option value="5">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">Receipt No.</option>
                                <option value="2">Bank Name</option>
                                <option value="3">Account</option>
                                <option value="6">Regn. No.</option>
                                <option value="4">Cheque</option>
                                <option value="5">Amount</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">
                            <input type="hidden" value="<?= $para; ?>" class="form-control para" >
                        </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: 450px;overflow: auto;">
                        <table id="" class="table table-striped table-condensed table-bordered" width="100%">
                            <thead>
                                <tr class="mySearchTr">
                                    <th style="width:3%">Receipt </th>
                                    <th style="width:7%">Date</th>
                                    <th style="width:12%">Bank Name</th>
                                    <th style="width:15%">Account</th>
                                    <th style="width:5%">Regn.</th>
                                    <th style="width:6%">Against</th>
                                    <th style="width:8%">Chq. No.</th>
                                    <th style="width:8%;text-align: right;">Amount</th>
                                    <th style="width:3%">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>
