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

$maindb = 'inwmain';
$trandb = 'inwtran';
$accdb = '';
$imgdb = "";
$printfile = "inward_print.php";
$file = 'inward.php';

$trandbexist = 1;
$comp = $_SESSION["comp_" . $dbname];
$myyear = $_SESSION[$myyear];

$gtype = $_GET['type'];
$formname = 'Inward';
$source = "IN";
$stkdb = 'transacn';

$para = "";
$keycond = "";
$keyfld = "vouchno";
$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zyear = right($zdb, 4);
$comp = $_SESSION["comp_" . $dbname];
$zStartDate = getzdates($zyear, 'S', $comp);
$zEndDate = getzdates($zyear, 'E', $comp);
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"];

    $voucher = trim($_POST["voucher"]);
    $mono = $_POST["monno"];
    $invno = $_POST["invno"];
    //    $debitac = $_POST["debitac"];
    $paidby = trim($_POST["paidby"]);
    $godown = trim($_POST["godown"]);
    $party = trim($_POST["party"]);
    $taxableamt = trim($_POST["taxableamt"]);
    $totbillamt = trim($_POST["totbillamt"]);
    $grossamt = trim($_POST["grossamt"]);
    $gstno = trim($_POST["gstno"]);
    $totdisc = trim($_POST["totdisc"]);
    $totvat = trim($_POST["totvat"]);
    $type = trim($_POST["type"]);

    $totalqty = $_POST["totalqty"];
    $rem1 = trim($_POST["remark1"]);
    $rem2 = trim($_POST["remark2"]);

    $mvouch = $qvouch;

    $oms = $_POST['oms'];

    $count = $_POST["items"];

    if ($a == 1) {

        mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `$trandb` WRITE, `product` WRITE, `$stkdb` WRITE, `accmast` WRITE");

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

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

        $cnt = 0;
        $cntamt = 0;

        for ($i = 0; $i < $count; $i++) {
            $msrno = $_POST["srno_$i"];
            $barcode = $_POST["barcode_$i"];
            $mitem = mysqli_real_escape_string($conn, $_POST["medicine_$i"]);

            $cartqty = $_POST["cartqty_$i"];
            $qty = $_POST["qty_$i"];
            $totqty = $_POST["totqty_$i"];
            $cost = $_POST["cost_$i"];
            $amt = $_POST["amount_$i"];
            $discperc = $_POST["discperc_$i"];
            $discamt = $_POST["discamt_$i"];
            $vatperc = $_POST["vatperc_$i"];
            $vat = $_POST["vat_$i"];
            $total = $_POST["total_$i"];
            $subtot = $_POST["subtot_$i"];

            $gstperc = $cgstrate + $sgstrate + $igstrate;

//            $getitt = mysqli_query($conn, "SELECT code,name FROM `product` WHERE `name`='$mitem'") or die(mysqli_error($conn));
//            if (mysqli_num_rows($getitt) > 0) {
//                $itcode = mysqli_fetch_array($getitt);
//                $itemcode = $itcode['code'];
//            } else {
//                $gensz1 = mysqli_query($conn, "SELECT MAX(code) AS maxcode FROM `product` where code != '' LIMIT 0,1 ") or die(mysqli_error($conn));
//                if (mysqli_num_rows($gensz1) > 0) {
//                    $gsz1 = mysqli_fetch_assoc($gensz1);
//                    $itemcode = $gsz1["maxcode"] + 1;
//                } else {
//                    $itemcode = '1';
//                }
//                mysqli_query($conn, "INSERT INTO `product`(`code`, `name`)
//                           VALUES('$itemcode',  '$mitem')") or die(mysqli_error($conn));
//            }

            $cnt++;
            $group = $source . $mvouch;
            if (!empty($mitem)) {

                mysqli_query($conn, "INSERT INTO `$trandb`(vouchno, vouchdt, srno, itemcode, qty, totqty, cost, amount, `discperc`, `discamt`, 
                                                          `total`,`barcode`,`subtot`,vatperc, vat)
                                                  VALUES('$mvouch', '$vouchdt', '$cnt', '$mitem', '$qty', '$totqty', '$cost', '$amt',
                                   '$discperc', '$discamt', '$total','$mitem','$subtot','$vatperc', '$vat' )") or die(mysqli_error($conn));

                mysqli_query($conn, "INSERT INTO `$stkdb`(`srno`, `yearno`, `vouchno`, `vouchdt`, `itemcode`,  `cartqty`,godown,barcode,
                                                  `qty`, `source`, amount, accode, `group` , `totqty`, `rate`, `itemgrp`, `ordno`, `monno`)
                            VALUES('$cnt', '$myyear', '$mvouch', '$vouchdt', '$mitem',  '$cartqty','$godown','$mitem',
                                   '$qty', '$source', '$amt', '$party', '$group', '$totqty', '$cost', '$itemgrp', '1', '$mono')") or die(mysqli_error($conn));
            }
        }

        ######################### STOCK PART ####################################################
        if ($addflag == 1) {
            $newvoucher = $mono . $mvouch;

            mysqli_query($conn, "INSERT INTO `$maindb`(vouchno, `vouchdt`, `voucher`, `invno`, `mono`, `party`, `paidby`, `debitac`, 
                                               `rem1`, `rem2`,  `cashvouch`, `totdisc`,`grossamt`, totvat,godown,
                                               `purcode`,`billamt`, `totalqty`)
                                      VALUES('$mvouch', '$vouchdt', '$newvoucher', '$invno', '$mono', '$party', '$paidby', '$debitac',
                                             '$rem1', '$rem2', '$mcashvouch', '$totdisc','$grossamt', '$totvat','$godown',
                                             '$purcode','$totbillamt', '$totalqty')") or die(mysqli_error($conn));

//            $_SESSION['print_voucher'] = $mvouch;
        } else {

            mysqli_query($conn, "UPDATE `$maindb` SET  `vouchdt`='$vouchdt',  `invno`='$invno', `mono`='$mono', `party`='$party', `paidby`='$paidby', godown='$godown',
                                               `rem1`='$rem1', `rem2`='$rem2', `totdisc`='$totdisc',`grossamt`='$grossamt',`debitac`='$purcode',`purcode`='$purcode',
                                               `cashvouch`='$mcashvouch',totvat='$totvat', `billamt`='$totbillamt', `totalqty`='$totalqty'
                                                WHERE `vouchno` = '$mvouch' ") or die(mysqli_error($conn));
        }
        mysqli_query($conn, "UNLOCK TABLES");
        if ($addflag == 1) {
            insmess();
            header("refresh: 1; $file?mode=edit&$keyfld=$mvouch");
        } else {
            updmess();
            header("refresh: 1; $file?mode=edit&$keyfld=$mvouch");
        }
    }
}
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);
    $getgodown = mysqli_query($conn, "SELECT * FROM `godown` WHERE `code`= '$get[godown]'") or die(mysqli_error($conn));
    $getgd = mysqli_fetch_array($getgodown);

    $delcsh = $get['cashvouch'];

    // $printdisabled = "none";
}


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

if (isset($_GET["delete"])) {
    mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `$trandb` WRITE, `$stkdb` WRITE") or die(mysqli_error($conn));

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

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

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

include("includes/linkshead.php");
?>

<script src="MyScript/inward.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>
<script src="MyScript/search_item.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>
<script src="MyScript/inward_mi_search.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>
<!--<script src="MyScript/checkdate.js" type="text/javascript"></script>-->

</head>
<body>
    <form action='' method='POST'>
        <div class="col-lg-3 pad text-center" id="overlay_form" style="display:none;z-index:999;">
            <button type="button" id="close_form" style="float: right;font-weight: bold;font-size: 18px;color:red;" ><i class="fa fa-close"></i></button>
            <div style='width:100%;' id='browdata'>
            </div>
        </div>
        <!-- Default box -->
        <div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12  pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title" style="color:#78909C"><a class="myPrint"><?php Echo $formname; ?></a></h3>
                        <!--                        <div class="actions pull-right">
                                                    <i class="fa fa-chevron-down"></i>-->
                    </div>
                </div>
                <div class="panel-body">
                    <input type="date" value="<?= $zStartDate ?>" style="display: none;border: none" class="zstdate">
                    <input type="date" value="<?= $zEndDate ?>" style="display: none;border: none" class="zenddate">
                    <div class="row">
                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Voucher</label>
                        </div>
                        <div class="col-lg-1 col-md-8 col-sm-8 col-xs-8 pad">
                            <input type="hidden" class="form-control addflag" value="<?php echo $addflag ?>" >
                            <input type="hidden" name="voucher" class="form-control form voucher"  value="<?php echo ($addflag != 1) ? $get['voucher'] : '' ?>" tabindex="-1" readonly>
                            <input type="hidden" name="source" class="form-control form source" value="<?= $source; ?>" id="source">
                            <input type="hidden" name="monno" class="form-control form monno" value="<?php echo ($addflag != 1) ? $get['monno'] : '' ?>" >
                            <input type="hidden" name="type" class="form-control form type gtype" value="<?php echo ($addflag != 1) ? $get['mattype'] : $gtype ?>" >
                            <input type="text" name="vouchno" class="form-control form vouchno" value="<?php echo ($addflag != 1) ? $get['vouchno'] : $qvouch ?>" >
                            <input type="hidden" class="form-control form" name="cashvouch" value="<?php Echo ($addflag != 1) ? $get["cashvouch"] : ""; ?>" >

                        </div>
                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Date</label>
                        </div>
                        <div class="col-lg-1 col-md-8 col-sm-8 col-xs-8 pad">
                            <input type="date" class="form-control form vouchdt focusfield" name="vouchdt" value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d") ?>" autofocus>
                        </div>
                        <!--                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                                    <label class="label-control marg" >Godown</label>
                                                </div>
                                                <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad ">
                                                    <select name="godown" class="form-control form  select2 godown" required>
                                                        <option value="<?php echo ($addflag != 1) ? $getgd['code'] : ""; ?>"><?php echo ($addflag != 1) ? $getgd['gcode'] : ""; ?></option>
                        <?php
                        $mown = mysqli_query($conn, "SELECT * FROM `godown` order by name") or die(mysqli_error($conn));
                        while ($trow = mysqli_fetch_array($mown)) {
                            echo "<option value='$trow[code]'>$trow[gcode]</option>";
                        }
                        ?>
                                                    </select>
                                                </div>-->


                    </div>
                    <div class="table-responsive" style="overflow-y: scroll;height: 400px">
                        <table class="table-striped table-condensed table-bordered tab" width="100%">
                            <thead  class="mySearchTr">
                                <tr>
                                    <th style="width: 1%"></th>
                                    <th style="width: 2%">Sr.</th>
                                    <!--<th style='width: 6%'>Code</th>-->
                                    <th style="width: 22%;">Item Name</th> 
                                    <!--<th style='width: 5%' class="text-right">Qty. in Ctn.</th>-->
                                    <th style='width: 5%' class="text-right">Qty.</th>
                                    <!--<th style='width: 5%' class="text-right">Total Qty.</th>-->
                                    <th style='width: 4%' class="text-right">Cost</th>
                                    <th style='width: 9%' class="text-right">Amount</th>
                                </tr>
                            </thead>
                            <tbody class="tbody">
                                <?php
                                if ($addflag != 1) {
                                    $qry = mysqli_query($conn, "SELECT t.*,p.name FROM `$trandb` t LEFT JOIN product p ON t.itemcode = p.code 
                                                                     WHERE t.vouchno='$getvouch' ORDER BY t.srno") or die(mysqli_error($conn));
                                    $ctr = 0;
                                    while ($row = mysqli_fetch_array($qry)) {
                                        Echo "<tr>";
                                        Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                        Echo "<td><input type='text' name='srno_$ctr' class='srno form-control  form'  value='$row[srno]'></td>";
                                        echo "<td>";
                                        echo "<select class='form-control form medicine select2' name='medicine_$ctr' style='width:100%'>";
                                        echo "<option value='$row[itemcode]'>$row[name]</option>";
                                        $gitem = mysqli_query($conn, "SELECT `code`,`name` FROM `product`  order by name") or die(mysqli_error($conn));
                                        while ($item = mysqli_fetch_array($gitem)) {
                                            echo "<option value='$item[code]'>$item[name]</option>";
                                        }
                                        echo "</select>";
//                                        echo "<input list='medicine' name='medicine_$ctr' class='medicine form-control form ' autocomplete='off' value='$row[name]'> ";
//                                        echo "<datalist id='medicine' char='#'>";
//                                        echo "<option>";
//
//                                        $mit2 = mysqli_query($conn, "SELECT `name` FROM `product` group by name  order by name") or die(mysqli_error($conn));
//
//                                        while ($tit2 = mysqli_fetch_array($mit2)) {
//                                            $itname2 = $tit2['name'];
//                                            echo "<option value='$itname2'>";
//                                        }
//
//                                        echo "</datalist>";
                                        echo "</td>";
//                                        Echo "<td><input type='text' name='barcode_$ctr' class='barcode form-control  form' value='$row[barcode]' ></td>";
//                                        Echo "<td>";
//                                        Echo "<input type='text' name='itemname_$ctr' required='true' class='itemname form-control  form' value='$row[itemname]' tabindex='-1' readonly required>";
//                                        Echo "</td>";
//                                    Echo "<td><input type='number' name='cartqty_$ctr' class='cartqty form-control text-right  form' value='$row[cartqty]' ></td>";
                                        Echo "<td><input type='number' step='any' name='qty_$ctr' class='qty form-control  text-right form' value='$row[qty]'></td>";
//                                    Echo "<td><input type='number' step='any' name='totqty_$ctr' class='totqty form-control text-right  form' value='$row[totqty]' tabindex='-1' readonly></td>";
                                        Echo "<td><input type='number' step='any' name='cost_$ctr' class='cost rate  form-control text-right  form' value='$row[cost]' ></td>";
                                        Echo "<td><input type='number' step='any' name='amount_$ctr' id='amount_$ctr' class='amount form-control text-right  form'  value='$row[amount]' tabindex='-1' readonly></td>";
                                        Echo "</tr>";
                                        $ctr++;
                                    }
                                } else {
                                    ?>
                                    <tr>                                    
                                        <td><i class='fa fa-close remove'></i></td>
                                        <td><input type='text' name='srno_0' class='srno form-control form' value='1'></td>
                                        <td>
                                            <select class="form-control form medicine select2" id="medicine" name="medicine_0" style='width:100%'>
                                                <option value=""></option>
                                                <?php
                                                $gitem = mysqli_query($conn, "SELECT * FROM `product` order by name") or die(mysqli_error($conn));
                                                while ($item = mysqli_fetch_array($gitem)) {
                                                    echo "<option value='$item[code]'>$item[name]</option>";
                                                }
                                                ?>
                                            </select>
    <!--                                            <input list='medicine' name='medicine_0' class='medicine form-control form ' autocomplete='off' value=''>
                                        <datalist id='medicine' char='#'>
                                            <option>
                                            <?php
//                                                    $mit = mysqli_query($conn, "SELECT `name` FROM `product` group by name  order by name") or die(mysqli_error($conn));
//
//                                                    while ($tit = mysqli_fetch_array($mit)) {
//                                                        $itname = $tit['name'];
//                                                        echo "<option value='$itname'>";
//                                                    }
                                            ?>
                                        </datalist>-->
                                        </td>
    <!--                                        <td><input type='text' name='barcode_0' class='barcode form-control form' value='' required></td>
                                    <td><input type='text' name='itemname_0' class='itemname form-control form' value='' required readonly tabindex='-1'></td>-->
                                    <!--<td><input type='number' name='cartqty_0' class='cartqty text-right form-control form' value='0' ></td>--> 
                                        <td><input type="number" step="any" name='qty_0' class='qty form-control text-right form zero' value='0' ></td> 
                                        <!--<td><input type="number" step="any" name='totqty_0' class='totqty form-control text-right form zero' tabindex='-1' value='0' readonly></td>--> 
                                        <td><input type="number" step="any" name='cost_0' class='cost rate form-control text-right form zero' value='0' ></td> 
                                        <td><input type="number" step="any" name='amount_0' id="amount_0" class='amount text-right form-control form zero' value='0' tabindex='-1' readonly></td> 
                                    </tr>
                                    <?php
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="col-lg-12 pad">
                        <button type="button" class="btn btn-primary btn-square form"  id="addnew">
                            <i class="fa fa-plus" data-toggle='tooltip' title='Add Row'></i>    
                        </button>
                        <input type="hidden" id="items" name="items" value="<?php Echo ($addflag != 1) ? $ctr : 1; ?>" >
                    </div>
                    <div class="col-lg-12 col-xs-12 pad">
                        <div class="col-lg-6 col-xs-12 pad">
                            <div class="col-lg-12 col-xs-12 pad">
                            </div>
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-3 pad text-right">
                                    <label class="label-control marg">Remarks</label>
                                </div>
                                <div class="col-lg-9 pad">
                                    <input type="text" name="remark1" class="form-control form " value="<? Echo ($addflag != 1) ? $get["rem1"] : ""; ?>">
                                </div>
                            </div>
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-3 pad text-right"></div>
                                <div class="col-lg-9 pad">
                                    <input type="text" name="remark2" class="form-control form " value="<? Echo ($addflag != 1) ? $get["rem2"] : ""; ?>">
                                </div>
                            </div>
                        </div>

                        <div class="col-lg-6 col-xs-12 pad">
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-2 pad"></div>
                                <div class="col-lg-2 label-control marg text-rigt pad">Total Qty.</div>
                                <div class="col-lg-2 pad">
                                    <input type="number" step="any" name="totalqty" class="form-control form text-right totalqty" value="<?php Echo ($addflag != 1) ? $get['totalqty'] : "0"; ?>">
                                </div>
                                <div class="col-lg-3 pad text-right">
                                    <label class="label-control marg">Total</label>
                                </div>
                                <div class="col-lg-3 pad">
                                    <input type="number" step="any" name="grossamt" class="form-control form text-right totamt grossamt" value="<?php Echo ($addflag != 1) ? $get['grossamt'] : "0"; ?>" readonly tabindex="-1">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 pad">
            <div class="panel panel-default">
                <div class="panel-body">
                    <?php include("includes/buttons.php"); ?>
                </div>
            </div>
        </div>
    </form>

    <div class="modal fade itemModal" 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">
                    <input type="hidden" value="<?php // Echo $fseries                                                                                      ?>" class="form-control series">
                    <input type="hidden" value="<?php Echo $get['vouchno']; ?>" class="form-control vouchno">
                    <input type="hidden" value="<?php Echo $file ?>" class="form-control file">
                    <input type="hidden" value="<?php Echo $para ?>" class="form-control para">
                    <div class="row">
                        <div class="col-lg-3">
                            <select class="form-control ifield">
                                <option value="1">Name</option>
                                <option value="2">Barcode</option>
                                <option value="3">Itemcode</option>
                                <!--                            <option value="4">Gram</option>
                                                            <option value="5">Unit</option>-->
                            </select>
                        </div>
                        <div class="col-lg-2">
                            <select class="form-control ioperator">
                                <option value=""></option>
                                <option value="%">Like</option>
                                <option value="=">Exactly</option>
                            </select>
                        </div>
                        <div class="col-lg-4">
                            <input type="text" value="" class="form-control isearch">
                        </div>
                        <div class="col-lg-3">
                            <input type="button" class="btn btn-primary iload" value="Search">
                        </div>
                    </div>

                    <div class="col-lg-12 iloader text-center">
                        <img src="images/search.gif" alt="loading">       
                    </div>
                    <div class="col-lg-12 inoRecord 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="15%">Itemcode</th>
                                    <th width="49%">Name</th>
    <!--                                <th width="17%">Barcode</th>
                                    <th width="8%">Gram</th>
                                    <th width="8%">Unit</th>-->
                                    <th width="8%">Rate</th>
                                </tr>
                            </thead>
                            <tbody class="iTbody">
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 text-right search-action-bar">
                            <input type="button"  class="btn btn-primary iprevious" value="Previous">
                            <input type="button"  class="btn btn-primary inext" value="Next">
                        </div>
                    </div>
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
    <div class="modal fade searchModal bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg" style="margin-top: 15%">
            <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">
                    <input type="hidden" value="<?php Echo $fseries ?>" class="form-control series">
                    <input type="hidden" value="<?php Echo $get['vouchno']; ?>" class="form-control vouchno">
                    <input type="hidden" value="<?php Echo $file ?>" class="form-control file">
                    <input type="hidden" value="<?php Echo $gtype ?>" class="form-control para">
                    <div class="row">
                        <div class="col-lg-2">
                            <select class="form-control sfield">
                                <option value="1">Voucher</option>
                                <option value="2">Date</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 >
                            </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="15%">Voucher</th>
                                    <th width="15%">Date</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"  class="btn btn-primary sprevious" 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>
