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

$formname = 'Previous - Cash Receipt';
$maindb = 'prevcsrecp';
$accdb = 'acprev';
$billdb = 'billsett';

$file = 'prevcsrecp.php';
$grid = '';
$source = 'CRPV';
$type = "S";

$keyfld = "vouchno";
$trandbexist = 0;
$focusfld = "name";
$printfile = 'prevcsrecp_fr.php';
//$printfile = 'cashr_voucher.php';

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zyear = right($zdb, 4);
$zStartDate = getzdates($zyear, 'S');
$zEndDate = getzdates($zyear, 'E');
mysqli_select_db($conn, $zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

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

    $a = 1;
    $username = $_SESSION["username_" . $dbname];

    $vouchdt = $_POST["vouchdt"];
    $bankname = $_POST["bankname"];
    $recpno = $_POST["recpno"];
    $custcode = $_POST["custcode"];
    $party = $_POST["party"];
    $amount = $_POST["amount"];
    $exam = $_POST["exam"];
    $paytype = $_POST["paytype"];
    $remark1 = $_POST["remark1"];
    $remark2 = $_POST["remark2"];
    $counter = $_POST["counter"];
    $billflag = $_POST["billflag"];



    $gschool = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode` = '$party'") or die(mysqli_error($conn));
    $fschool = mysqli_fetch_array($gschool);

    $fexm = mysqli_query($conn, "SELECT * FROM `exam` WHERE `code`='$exam'") or die(mysqli_error($conn));
    $gexm = mysqli_fetch_array($fexm);

    $gbank = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode`='$bankname'") or die(mysqli_error($conn));
    $fbank = mysqli_fetch_array($gbank);

    $schlname = mysqli_real_escape_string($conn, $fschool['name']);
    $bname = $fbank['name'];
    $examname = $gexm['name'];

    $mvouch = $qvouch;

    if ($bankname == "") {
        $a = 0;
        browse("Name 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) AS maxcode FROM `$maindb` LIMIT 0,1 ") or die(mysqli_error($conn));
            if (mysqli_num_rows($gen1) > 0) {
                $vvouch = mysqli_fetch_assoc($gen1);
                $qvouch = $vvouch["maxcode"] + 1;
            } else {
                $qvouch = '1';
            }
        }


        $in = mysqli_query($conn, "SELECT * FROM accmast WHERE accode='$bankname'") or die(mysqli_error($conn));
        $getinit = mysqli_fetch_array($in);
        $bankinit = $getinit["bankinit"];

        $gr = mysqli_query($conn, "SELECT * FROM accmast WHERE accode='$party'") or die(mysqli_error($conn));
        $grp = mysqli_fetch_array($gr);
        $pgrp = $grp["grpcode"];


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

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

        if ($billflag == 1) {
            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];
                $msetoff = $_POST["setoff_" . $i];
                $mdays = $_POST["days_" . $i];

                if (!empty($msetoff)) {
                    mysqli_query($conn, "INSERT INTO `billsett`(`yearno`, `type`, `vouchno`, `billno`, `setoff`, `party`, `source`, `bnkvouch`, `bankinit`, nodays,`bnkdate`,`examcode`)
                                VALUES('$myearno', '$type', '$mvouchno', '$mbillno', '$msetoff', '$party', '$source', '$mvouch', '$binit', '$mdays','$vouchdt','$exam')") or die(mysqli_error($conn));
                }
            }
        }

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

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

//        browse($amount);

        if ($amount > 0) {
//            browse('suf');
            $minus_amt = ($amount * -1);

            $getbankinit = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode` = '$bankname'");
            $bankinit = mysqli_fetch_array($getbankinit);
            $binit = $bankinit[bankinit];

            $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`(date, vouchno, recpno, source, trnno, bankinit, accode, grpcode, amount)
                    VALUES ('$vouchdt','$mvouch', '$recpno', '$source', '001', '$binit', '$bankname','002', '$minus_amt')") or die(mysqli_error($conn));

            // party part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, recpno, source, trnno, bankinit, accode, grpcode, amount)
                    VALUES ('$vouchdt','$mvouch', '$recpno', '$source', '002', '$binit', '$party', '$pgrp', '$amount')") or die(mysqli_error($conn));
        }
        if ($addflag == 1) {
            mysqli_query($conn, "INSERT INTO `$maindb`( vouchno ,`vouchdt`, `bankname`, `bankinit`, `recpno`,
                                               `custcode`, `party`, `amount`,`examcode`, `remark1`, `remark2`,
                                               `schlname`,`examname`,`paytype`,`bname`)
                                       Values ('$qvouch', '$vouchdt', '$bankname', '$binit', '$recpno',
                                               '$custcode', '$party', '$amount','$exam', '$remark1','$remark2',
                                               '$schlname', '$examname', '$paytype', '$bname')")
                    or die(mysqli_error($conn));
        } else {
            $mvouch = $qvouch;
            mysqli_query($conn, "UPDATE `$maindb` SET  vouchdt='$vouchdt', bankname='$bankname', bankinit='$binit', recpno='$recpno' ,
                                              `custcode`='$custcode',`party`='$party',amount='$amount',examcode='$exam',
                                              `remark1`='$remark1', `remark2`='$remark2' ,`schlname` = '$schlname',
                                              `examname` = '$examname',`paytype`='$paytype',`bname`='$bname' where vouchno = '$mvouch'") or die(mysqli_error($conn));
        }

        mysqli_query($conn, "UNLOCK TABLES");

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

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

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

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

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

    $gexam = mysqli_query($conn, "SELECT * FROM `exam` WHERE `code` = '$get[examcode]'");
    $shexam = mysqli_fetch_array($gexam);


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

/* DELETE */
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");

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


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

include("includes/linkshead.php");
?>
<script src="MyScript/cashrecp.js" type="text/javascript"></script>
<script src="MyScript/cashrecp_search.js" type="text/javascript"></script>
<script src="MyScript/checkdate.js" type="text/javascript"></script>
<script src="MyScript/shortkeys.js" type="text/javascript"></script>
<script src="MyScript/school.js" type="text/javascript"></script>
</head>
<body>
    <!--    <div id="preloader" class="col-lg-12 text-center">
            <h3 class="text-center">Loading</h3>
            <div id="status">&nbsp;</div>
        </div>-->
    <form action='' method='POST'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php Echo $formname; ?></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                        </div>
                    </div>
                    <input type="date" value="<?= $zStartDate ?>" style="width: 1px;border: none" class="zstdate">
                    <input type="date" value="<?= $zEndDate ?>" style="width: 1px;border: none" class="zenddate">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4  pad text-right">
                                <label class="label-control">Receipt Voucher</label>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-8 col-xs-8 pad"> 
                                <input type="text" name="vouchno" id="vouchno"  placeholder="vouchno" value="<?php echo ($addflag != 1) ? $get['vouchno'] : $qvouch; ?>" class="form-control form"  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 billflag" name="billflag" value="0">
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-4 col-xs-4 text-right">
                                <label class="label-control">Date</label>
                            </div>
                            <div class="col-lg-4 col-md-3 col-sm-8 col-xs-8 pad"> 
                                <input type="date" name="vouchdt"   placeholder="date" value="<?php echo ($addflag != 1) ? $get['vouchdt'] : date('Y-m-d'); ?>" class="form-control form vouchdt" style="height: 30px;" required autofocus="autofocus">
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-8 col-xs-8 pad">
                                <a class="btn btn-primary" href="cashr_voucher.php?vouchno=<?= $qvouch; ?>" target="_blank">Voucher</a>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 text-right">
                                <label class="label-control">Cash Name</label>
                            </div>
                            <div class="col-lg-6 col-md-8 col-sm-8 col-xs-8   pad"> 
                                <select id="bankname" name="bankname" class="form-control form" required>
                                    <option value="<?php echo ($addflag != 1) ? $banknm['accode'] : " "; ?>"><?php echo ($addflag != 1) ? $banknm['name'] : " "; ?></option>
                                    <?php
                                    $mown1 = mysqli_query($conn, "SELECT accode, `name` FROM `accmast` where `grpcode` = '002' ") 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-4 col-xs-4 text-right">
                                <label class="label-control"> Receipt No. </label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-8 col-xs-8 pad"> 
                                <input type="text" name="recpno" placeholder="recpno" value="<?php echo ($addflag != 1) ? $get['recpno'] : $qvouch; ?>" class="form-control form" readonly>
                            </div> 
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg" >Code</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form custcode readonly"  name="custcode" value="<?php Echo ($addflag != 1) ? $gtpt['custcode'] : '' ?>">
                            </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">School Name</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 school">
                                    <option value="<?php echo ($addflag != 1) ? $gtpt['accode'] : " "; ?>"><?php echo ($addflag != 1) ? $gtpt['name'] : " "; ?></option>
                                    <?php
                                    $gschl = mysqli_query($conn, "SELECT * FROM `accmast` where grpcode = '010' order by `name`") or die(mysqli_error($conn));
                                    while ($schl = mysqli_fetch_array($gschl)) {
                                        echo "<option value=$schl[accode]>$schl[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <a href='ledger_fr.php' class='btn btn primary ledger form' target='_blank' tabindex="-1">Ledger</a>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 text-right">
                                <label class="control-label"> Amount </label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-8 col-xs-8 pad"> 
                                <input type="text" name="amount" id="amount" placeholder="Amount" text-right value="<?php echo ($addflag != 1) ? $get['amount'] : ''; ?>" class="form-control form text-right numeric "  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">Exam</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-7 col-xs-7 pad">
                                <select id="exam" name="exam" class="select2 form-control form">
                                    <option value="<?php echo ($addflag != 1) ? $shexam['code'] : ""; ?>"><?php echo ($addflag != 1) ? $shexam['name'] : ""; ?></option>
                                    <?php
                                    $gexam = mysqli_query($conn, "SELECT `code`,`name` FROM `exam` order by `name`") or die(mysqli_error($conn));
                                    while ($exam = mysqli_fetch_array($gexam)) {
                                        echo "<option value=$exam[code]>$exam[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Payment Type</label>
                            </div>
                            <div class="col-lg-2 col-md-5 col-sm-7 col-xs-7 pad">
                                <select name="paytype" class="form-control form pad select2 paytype">

                                    <option
                                    <?php
                                    if ($get['paytype'] == 'C') {
                                        echo "selected=selected";
                                    }
                                    ?> value='CH'>Cash</option>
                                    <option
                                    <?php
                                    if ($get['paytype'] == 'D') {
                                        echo "selected=selected";
                                    }
                                    ?> value='M'>M.O</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">Remark</label>
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-8 col-xs-8 pad">
                                <input type="text" name="remark1" value="<?php echo ($addflag != 1) ? $get['remark1'] : ''; ?>" class="form-control form remark1" >
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-8 col-xs-8 pad">
                                <input type="text" name="remark2" value="<?php echo ($addflag != 1) ? $get['remark2'] : ''; ?>" class="form-control form remark2" >
                            </div>
                        </div>
                    </div>
                    <div class="panel-footer">
                    <div style="overflow: auto; ">
                            <table class="table-condensed" style="margin: 0 auto;">
                                <tr>
                                    <td class=" buttonform tooltip-bottom " id="hprevious" style="display: <? Echo $pdisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Previous">
                                        <button id='previous' type="button" class="btn btn-pad btn-square btn-square prevBtn hvr-float-shadow" style="background-color:#B38A6C; "  onClick="window.location.href = '<?= $file . "?mode=edit&$keyfld=$prevvouch" . $para; ?>'" <? Echo $pdisabled1 ?>>
                                            <i class="fa fa-chevron-left" style="color:#ffffff"></i>
                                        </button>
                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="hnext" style="display: <? Echo $ndisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Next">
                                        <button id='next' type="button" class="btn btn-pad btn-square nextBtn hvr-float-shadow" style="background-color:#F89693;  " onClick="window.location.href = '<?= $file . "?mode=edit&$keyfld=$nextvouch" . $para; ?>'" <? Echo $ndisabled1 ?>>
                                            <i class="fa fa-chevron-right" style="color:#ffffff"></i>    
                                        </button>
                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="hsearch" style="display: <? Echo $searchdisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Search">
                                        <button id="search" type="button" class="btn btn-pad btn-square " style="background-color:#B19CD9; " data-toggle="modal" data-target=".bs-example-modal-lg" >
                                            <i class="fa fa-search" style="color:#ffffff"></i>
                                        </button>
                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="hprint" style="display: <? Echo $printdisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Print">
                                        <a id='print' class="btn btn-pad btn-square " style="background-color:#5BC0DE;" href="<?= $printfile ?>?vouchno=<?= $qvouch . $para; ?>" target="_blank">
                                            <i class="fa fa-print" style="color:#ffffff"></i>
                                        </a>
                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="hadd" style="display: <? Echo $adddisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Add Record" >
                                        <button id='add' type="button" class="btn btn-pad btn-square " style="background-color:#C0CA33; " onclick="window.location.href = '<?= $file . "?mode=true" . $para; ?>'" class="btn btn-labeled btn-success ">
                                            <i class="fa fa-plus" style="color:#ffffff"></i>    
                                        </button>
                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="hedit" style="display: <? Echo $editdisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Edit Record">
                                        <button id='edit' type="button" style="background-color:#F0AD4E; " class="btn btn-pad btn-square">
                                            <i class="fa fa-pencil" style="color:#ffffff"></i>
                                        </button>
                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="hdelete" style="display: <? Echo $deletedisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete Record">
                                        <a id='delete' class="btn btn-pad btn-square delete-entry" href="?delete&<?= $keyfld . "=" . $qvouch . "&series=$zseries" . "&source='$msource'" ?>"  onClick="return confirm('Confrim Delete?');" style="background-color:#D9534F;">
                                            <i class="fa fa-trash" style="color:#ffffff"></i>
                                        </a>
                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="hexit" style="display: <? Echo $exitdisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Exit">
                                        <button id='exit' type="button" class="btn btn-pad btn-square " style="background-color:#cccccc; "  onClick="window.location.href = '<?= 'default.php' ?>'">
                                            <i class="fa fa-power-off" style="color:red"></i>
                                        </button>
                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="ssubmit" style="display: <? Echo $savedisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Save Record">
                                        <button id='submit' type='submit' name='submit' value='<?php echo ($addflag == 0) ? "Update" : "Save"; ?>' class="btn btn-pad btn-square " style="background-color:#008D4C; ">
                                            <i class="fa fa-check" style="color:#ffffff"></i>
                                        </button>
                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="scancel" style="display: <? Echo $canceldisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Cancel Record">
                                        <button id='cancel' type="button" class="btn btn-pad btn-square " style="background-color:#39CCCC; "  onClick="window.location.href = '<?= $file . "?mode=last" . $para; ?>'">
                                            <i class="fa fa-times" style="color:#ffffff"></i>
                                        </button>
                                    </td>
                                    <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
                                    <td class=" buttonform tooltip-bottom" id="" style="display: <? ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Multiple Print">
<!--                                        <button id='' type="button" class="btn btn-pad btn-lg " data-toggle="modal" data-target="#myModal" style="background-color:#6082BF;color:white ">
                                            Multiple Print
                                        </button>-->
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </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 class="modal fade " tabindex="" id="settmodal" role="dialog" aria-labelledby="myLargeModalLabel">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button class="close" data-dismiss="modal"><span>&times;</span></button>
                            <h4 class="modal-title" id="myLargeModalLabel">Bill Settlement</h4>
                        </div>
                        <div class="modal-body">
                            <div class=" table-responsive">
                                <div class="toolbar">
                                    <div class="row">
                                        <div class="col-lg-2"><label class="label-control marg" style="color:red">Total Remain</label></div>
                                        <div class="col-lg-2"><input type="text" id="remain" name="remain" class="form-control" readonly style=""></div>
                                        <div class="col-lg-2"><label class="label-control marg" style="color:blue">Total Setoff</label></div>
                                        <div class="col-lg-2"><input type="text" id="totsetoff" name="totsetoff" class="form-control" readonly style=""></div>
                                        <!--<div class="col-lg-2"><input id="submit" type='submit' name='submit' value='<?php // echo ($addflag == 0) ? "Update" : "Save";                ?>' class="btn btn-primary"></div>-->
                                        <?php
//                                    if (!isset($_GET["method"])) {
                                        ?>
                                        <!--<div class="col-lg-2"><input type='button' name='exit' value='Exit' class="btn btn-danger" onClick="window.location.href = '<?php echo $grid; ?>'"></div>-->
                                        <?php // }  ?>
                                    </div>
                                </div>
                                </header>
                                <div id="div-2" class="accordion-body collapse in body">
                                    <div style="max-height:300px;overflow: auto; border: 0px solid;">
                                        <div id="data"></div>  
                                    </div>
                                </div>    
                            </div>
                        </div>
                        <div class="modal-footer"></div>
                    </div>
                </div>
            </div>
        </div>

    </form>

<form action='cashrecp_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" style="background-color:#6082BF">
                        <h4 class="modal-title text-center" style="color:white">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 Voucher No.</label>
                            </div>  
                            <div class="col-lg-4 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text"  name="frmrecp" class="form-control frmvouch frmrecp " value="" 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">To Voucher No.</label>
                            </div> 
                            <div class="col-lg-4 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" name="torecp" class="form-control tovouch torecp" value="" required> 
                            </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" style="background-color:#6082BF">Proceed</button>
                                <button type="button" class="btn btn-default text-center" data-dismiss="modal"style="background-color:#6082BF">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 frecpno" name="mfrmrecp" value="">
                                <input type="hidden" class="form-control trecpno" name="mtorecp" value="">
                                <!-- <input type="hidden" class="form-control mtorecp" name="mtorecp" value=""> -->
                            </div>
                            <div class="col-lg-6">
                                <input type="submit"  target='_blank'  style="background-color:#6082BF; color:white" class="btn text-center proceed2" value="Proceed">
                                <button type="button" class="btn btn-default text-center" data-dismiss="modal" style="background-color:#6082BF">Close</button>
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>
                    <!--2nd Modal End-->

                    <div class="modal-footer">
                    </div>
                </div>
            </div>
        </div> 
    </form>

<!-- Modal End -->




    <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 No.</option>
                                <option value="2">Cash Name</option>
                                <option value="3">School</option>
                                <option value="4">Exam</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="">Sort By</option>
                                <option value="1">Voucher No.</option>
                                <option value="2">Cash Name</option>
                                <option value="3">School</option>
                                <option value="4">Exam</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">
                        </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 style="background-color:#6082BF;">
                                    <th width="9%">Voucher No.</th>
                                    <th width="21%">Cash Name</th>
                                    <th width="30%">School</th>
                                    <th width="19%">Exam</th>
                                    <th width="13%">Amount</th>
                                    <th width="8%">Action</th>

                                </tr>
                            </thead>
                            <tbody class="sTbody">
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 text-right search-action-bar">
                            <input type="button"  class="btn btn-primary sprev" value="Previous">
                            <input type="button"  class="btn btn-primary snext" value="Next">
                        </div>
                    </div>

                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
