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

$formname = 'Sale Return / Credit Note (Others)';
$maindb = 'credmain';
$trandb = 'credoth';
//$stkdb = 'transacn';
$accdb = 'actran';
$printfile = "credoth_print.php";
$file = 'credoth.php';
$trandbexist = 1;
$keyfld = "vouchno";
IF (isset($_GET[credtype]) != "") {
    $zcredtype = "$_GET[credtype]";
} ELSE {
    $zcredtype = "O";
}
$source = "SR";
$keycond = " AND `credtype`='$zcredtype' ";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
$username = $_SESSION["username_" . $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"])) {
    $vouchdt = trim($_POST["vouchdt"]);
    $invdate = trim($_POST["invdate"]);
    $invno = trim($_POST["invno"]);
    $voucher = trim($_POST["voucher"]);
    $party = trim($_POST["party"]);
    $mono = $_POST["monno"];
    $godown = trim($_POST["godown"]);
    $gsttype = trim($_POST["gsttype"]);
    $rem1 = trim($_POST["remark1"]);
    $rem2 = trim($_POST["remark2"]);
    $grossamt = trim($_POST["grossamt"]);
    $discperc = trim($_POST["discperc"]);
    $totdiscamt = trim($_POST["totdiscamt"]);
    $cgstperc = trim($_POST["cgstperc"]);
    $sgstperc = trim($_POST["sgstperc"]);
    $igstperc = trim($_POST["igstperc"]);
    $cgstamt = trim($_POST["cgstamt"]);
    $sgstamt = trim($_POST["sgstamt"]);
    $igstamt = trim($_POST["igstamt"]);
    $taxableamt = trim($_POST["taxableamt"]);
    $totbillamt = trim($_POST["totbillamt"]);
    $roundoff = trim($_POST["roundoff"]);
    $oms = $_POST['oms'];

    $netamt = $totbillamt;
    $count = $_POST["items"];
//    $gstamount = $totbillamt - $taxableamt;
    $gstamount = $cgstamt + $sgstamt + $igstamt;


    $mvouch = $qvouch;

    $salecode = 30;
    $a = 1;

    if ($a == 1) {
        mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `$trandb` WRITE, `product` WRITE,
                    `$accdb` WRITE, `cashrecp` WRITE, `accmast` WRITE, `gsttype` WRITE, `godown` WRITE ");

        if ($addflag == 1) {
            $gen1 = mysqli_query($conn, "SELECT MAX(vouchno+0) 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;
        }


        #################################TRAN PART #################################

        mysqli_query($conn, "DELETE FROM `$trandb` WHERE `$keyfld`='$mvouch'") or die(mysqli_error($conn));
        $group = $source . $mvouch;
        $srl = 0;
        for ($i = 0; $i < $count; $i++) {
            $msrno = $_POST["srno_$i"];
            $descrip = $_POST["descrip_$i"];
            $amount = $_POST["amount_$i"];

            if (!empty($descrip)) {
                $srl = $srl + 1;

                mysqli_query($conn, "INSERT INTO `$trandb`(`vouchno`, `vouchdt`, `srno`, `descrip`, `amount`) 
                    VALUES ('$qvouch', '$vouchdt', '$srl', '$descrip', '$amount')") or die(mysqli_error($conn));
            }
        }

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

        if ($netamt > 0) {
            $taxablemin = $taxableamt * -1;
            $gstmin = ($gstamount * -1);


            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount,prodtype,actamt)
                    VALUES ('$vouchdt','$mvouch', '$source', '001', '$salecode','005', '$taxablemin','$prodtype','$taxablemin')") OR die(mysqli_error($conn));
            
                        //            round off part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno,`godown`, source, trnno, accode, grpcode, amount, monno)
                            VALUES ('$vouchdt','$mvouch','$godown', '$source', '004', '25','012', '$roundoff','$mono')") or die(mysqli_error($conn));


            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount,prodtype,actamt)
                     VALUES ('$vouchdt','$mvouch', '$source', '002', '$party','010', '$netamt','$prodtype','$netamt')") or die(mysqli_error($conn));

            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount,prodtype,actamt)
                            VALUES ('$vouchdt','$mvouch', '$source', '003', '5','020', '$gstmin','$prodtype','$gstmin')") or die(mysqli_error($conn));
        }

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

            mysqli_query($conn, "INSERT INTO `$maindb`(`username`, vouchno, `vouchdt`, `voucher`, `invno`, `invdate`,`monno`, `party`, `oms`, roundoff,
                                               `rem1`, `rem2`, `discamt`,`grossamt`, `godown`,`credtype`, `cgstperc`, `sgstperc` , `igstperc`,
                                               `taxableamt`, `gsttype`, `discperc`, `cgstamt`, `sgstamt`, `igstamt`, `salecode`, `billamt`)
                                      VALUES('$username','$mvouch', '$vouchdt', '$newvoucher', '$invno', '$invdate','$mono', '$party', '$oms', '$roundoff',
                                              '$rem1', '$rem2', '$totdiscamt','$grossamt', '$godown', 'O', '$cgstperc', '$sgstperc', '$igstperc',
                                            '$taxableamt', '$gsttype', '$discperc', '$cgstamt', '$sgstamt', '$igstamt','$salecode','$totbillamt')") or die(mysqli_error($conn));
            insmess();
            $mvouch = $qvouch; //1
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit&credtype=O");
        } else {
            $mvouch = $qvouch; //1

            mysqli_query($conn, "UPDATE `$maindb` SET  `vouchdt`='$vouchdt', `invno`='$invno', `invdate`='$invdate',`monno`='$mono', `party`='$party',roundoff='$roundoff',
                                                `oms`='$oms',`rem1`='$rem1', `rem2`='$rem2', `discamt`='$totdiscamt',`grossamt`='$grossamt',`cgstperc`='$cgstperc',
                                                `sgstperc`='$sgstperc', `igstperc`='$igstperc', `godown`='$godown', `taxableamt`='$taxableamt',
                                                `gsttype`='$gsttype', `discperc`='$discperc', `cgstamt`='$cgstamt',
                                                `sgstamt`='$sgstamt', `igstamt`='$igstamt', `billamt`='$totbillamt', `username`='$username' WHERE `vouchno` = '$mvouch' ") or die(mysqli_error($conn));
            updmess();

            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit&credtype=O");
        }
    }
}

if ($addflag != 1) {

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

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

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

    $getgst = mysqli_query($conn, "SELECT * FROM `gsttype` WHERE per='$get[gsttype]'") or die(mysqli_error($conn));
    $fetgst = mysqli_fetch_array($getgst);

    $getgodown = mysqli_query($conn, "SELECT * FROM `godown` WHERE `code`= '$get[godown]'") or die(mysqli_error($conn));
    $getgd = mysqli_fetch_array($getgodown);
}

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

if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last&credtype=O");
    delete($zdb, "$trandb", "$keyfld", $_GET[$keyfld], "$file?mode=last&credtype=O");
    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]' ";
    delnew($zdb, "$accdb", "$delcond", "$file?mode=last&credtype=O");
}

include("includes/linkshead.php");
?>
<script src="MyScript/credoth.js" type="text/javascript"></script>
<script src="MyScript/credoth_search.js" 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" style="height:40px">
                        <div class="col-lg-10 col-md-10 col-sm-10  col-xs-10">
                            <h3 class="panel-title" style="color:#78909C"><a class="myPrint"><?php echo $formname; ?></a></h3>
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-2  col-xs-2">
                            <input type="date" value="<?= $zStartDate ?>" style="width: 1px;border: none" class="zstdate">
                            <input type="date" value="<?= $zEndDate ?>" style="width: 1px;border: none" class="zenddate">
                            <h4 class="panel-title" style="float:right"><b><?php echo $get['username'] ?></b></h4>
                        </div>
                    </div>
                    <div class="panel-body">
                        <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">Credit No.</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="hidden" name="voucher" class="form-control form voucher" value="<?php echo ($addflag != 1) ? $get['voucher'] : '' ?>" tabindex="-1" readonly>
                                <input type="hidden" name="monno" class="form-control form monno" value="<?php echo ($addflag != 1) ? $get['monno'] : '' ?>" >
                                <input type="text" name="vouchno" class="form-control form vouchno" value="<?php echo ($addflag != 1) ? $get['vouchno'] : $qvouch ?>" tabindex="-1" readonly>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Credit Date</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-1 col-xs-8 pad">
                                <input type="date" class="form-control form vouchdt" 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 godown select2">
                                    <option value="<?php echo ($addflag != 1) ? $getgd['code'] : " "; ?>"><?php echo ($addflag != 1) ? $getgd['gcode'] : " "; ?></option>
                                    <?php
                                    $mown = mysqli_query($conn, "SELECT * FROM `godown`") or die(mysqli_error($conn));
                                    while ($trow = mysqli_fetch_array($mown)) {
                                        echo "<option value=$trow[code]>$trow[gcode]</option>";
                                    }
                                    ?>
                                </select>
                            </div> 
                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">Party</label>
                            </div>
                            <div class="col-lg-3 pad">
                                <select class="form-control form cmbparty select2" name="party" style="width: 100%" required>
                                    <option value="<?php Echo ($addflag != 1) ? $lparty["accode"] : ""; ?>"><?php Echo ($addflag != 1) ? $lparty["name"] : ""; ?></option>
                                    <?php
//                                do not remove this lock, talk to firoz sir. 
                                    if ($addflag == 1) {
                                        $gparty = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `grpcode`='010' order by name")or die(mysqli_error($conn));
                                        while ($party = mysqli_fetch_array($gparty)) {
                                            Echo "<option value='$party[accode]'>$party[name]</option>";
                                        }
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <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">Invoice</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" name="invno" class="form-control form invno" value="<?php echo ($addflag != 1) ? $get['invno'] : $qvouch; ?>" tabindex="-1" >
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Invoice Date</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-1 col-xs-8 pad">
                                <input type="date" class="form-control form invdate" name="invdate"  value="<?php Echo ($addflag != 1) ? $get["invdate"] : date("Y-m-d"); ?>">
                            </div>

                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-3 numeric text-right pad">
                                <label class="label-control marg">GST %</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <select class="form-control form select2 gstperc" name="gsttype" style="width:100%" required>
                                    <option value="<?php echo ($addflag != 1) ? $fetgst['per'] : ""; ?>"><? echo ($addflag != 1) ? $fetgst['name'] : ""; ?></option>
                                    <?php
                                    $ggsttype = mysqli_query($conn, "SELECT * FROM `gsttype` order by per")or die(mysqli_error($conn));
                                    while ($fgsttype = mysqli_fetch_object($ggsttype)) {
                                        Echo "<option value='$fgsttype->per'>$fgsttype->name</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Oms</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad" tabindex="-1">
                                <input type="checkbox"  class="form-control form oms" <?php
                                    if ($get[oms] == "1") {
                                        Echo "checked";
                                    }
                                    ?> value="1" name="oms" style="background-color: yellowgreen; ">                            
                            </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="">

                    </div>
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-condensed table-bordered" width="100%">
                                <thead  class="mySearchTr">
                                    <tr>
                                        <th width="5%"></th>
                                        <th width="5%" class='text-right'>Sr.</th>
                                        <th width="70%" class='text-left'>Description</th>
                                        <th width="20%" class='text-right'>Amount</th>
                                    </tr>
                                </thead>
                                <tbody class="tbody">
                                    <?php
                                    if ($addflag != 1) {
                                        $ctr = 0;
                                        $gettran = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$get[vouchno]' ORDER BY `srno`")or die(mysqli_error($conn));
                                        while ($tran = mysqli_fetch_array($gettran)) {
                                            Echo "<tr>";
                                            Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                            Echo "<td><input type='text' class='form-control form text-right srno' name='srno_$ctr' value='$tran[srno]'></td>";
                                            Echo "<td>";
                                            Echo "<input type='text' class='form-control form descrip' name='descrip_$ctr' value='$tran[descrip]'>";
                                            Echo "</td>";
                                            Echo "<td>";
                                            Echo "<input type='number' step='any' class='form-control text-right form amount' name='amount_$ctr' value='$tran[amount]'>";
                                            Echo "</td>";
                                            Echo "</tr >";
                                            $ctr++;
                                        }
                                    } else {
                                        ?>
                                        <tr>
                                            <td><i class="fa fa-close remove"></i></td>
                                            <td><input type="text" class="form-control form text-right srno" name="srno_0" value="1"></td>
                                            <td><input type="text" class="form-control form itemcode barcode" name="descrip_0" name="descrip" required></td>
                                            <td><input type='number' step='any' class="form-control form text-right amount"   name="amount_0"  value="0" required></td>
                                        </tr>  
                                        <?
                                    }
                                    ?>
                                </tbody>
                            </table>
                        </div>
                        <div class="col-lg-12 pad">
                            <!--<input type="button" style="height: 30px; width: 30px; padding: 0px" id="addnew" class="btn btn-success btn-lg form" accode="addnew2" value="+" />-->
                            <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>
                </div>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12  pad">
                <div class="panel panel-default">
                    <div class="">
                    </div>
                    <div class="panel-body">
                        <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 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-3 pad"></div>
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-3 pad text-right">
                                        <label class="label-control marg">Subtotal</label>
                                    </div>
                                    <div class="col-lg-3 pad">
                                        <input type="number" step="any" name="grossamt" class="form-control form text-right grossamt" value="<?php Echo ($addflag != 1) ? $get['grossamt'] : "0"; ?>" readonly >
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-3 pad text-right">
                                        <label class="label-control marg">Discount</label>
                                    </div>
                                    <div class="col-lg-2 pad text-right">
                                        <input type="number" step="any" name="discperc" class="form-control form text-right discperc" value="<?php Echo ($addflag != 1) ? $get['discperc'] : "0"; ?>"  >
                                    </div>
                                    <div class="col-lg-1 pad">
                                        <label class="label-control marg">%</label>
                                    </div>
                                    <div class="col-lg-3 pad">
                                        <input type="number" step="any" name="totdiscamt" class="form-control form text-right totdiscamt" value="<?php Echo ($addflag != 1) ? $get['discamt'] : "0"; ?>"  readonly>
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-3 pad text-right">
                                        <label class="label-control marg">Taxable Amount</label>
                                    </div>
                                    <div class="col-lg-3 pad">
                                        <input type="number" step="any" name="taxableamt" class="form-control form text-right taxableamt" value="<?php Echo ($addflag != 1) ? $get['taxableamt'] : "0"; ?>" readonly >
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-5 pad"></div>
                                    <div class="col-lg-1 pad">
                                        <label class="label-control marg">CGST</label>                                        
                                    </div>
                                    <div class="col-lg-2 pad text-right">
                                        <input type="number" step="any" name="cgstperc" class="form-control form text-right cgstperc" value="<?php Echo ($addflag != 1) ? $get['cgstperc'] : "0"; ?>"  >
                                    </div>
                                    <div class="col-lg-1 pad">
                                        <label class="label-control marg">%</label>
                                    </div>
                                    <div class="col-lg-3 pad">
                                        <input type="number" step="any" name="cgstamt" class="form-control form text-right cgstamt" value="<?php Echo ($addflag != 1) ? $get['cgstamt'] : "0"; ?>" readonly >
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-5 pad"></div>
                                    <div class="col-lg-1 pad">
                                        <label class="label-control marg">SGST</label>                                        
                                    </div>
                                    <div class="col-lg-2 pad text-right">
                                        <input type="number" step="any" name="sgstperc" class="form-control form text-right sgstperc" value="<?php Echo ($addflag != 1) ? $get['sgstperc'] : "0"; ?>"  >

                                    </div>
                                    <div class="col-lg-1 pad">
                                        <label class="label-control marg">%</label>
                                    </div>
                                    <div class="col-lg-3 pad">
                                        <input type="number" step="any" name="sgstamt" class="form-control form text-right sgstamt" value="<?php Echo ($addflag != 1) ? $get['sgstamt'] : "0"; ?>" readonly >
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-5 pad"></div>
                                    <div class="col-lg-1 pad text-right">
                                        <label class="label-control marg">IGST</label>
                                    </div>
                                    <div class="col-lg-2 pad">
                                        <input type="number" step="any" name="igstperc" class="form-control form text-right igstperc" value="<?php Echo ($addflag != 1) ? $get['igstperc'] : "0"; ?>"  >
                                    </div>
                                    <div class="col-lg-1 pad">
                                        <label class="label-control marg">%</label>
                                    </div>
                                    <div class="col-lg-3 pad">
                                        <input type="number" step="any" name="igstamt" class="form-control form text-right igstamt" value="<?php Echo ($addflag != 1) ? $get['igstamt'] : "0"; ?>" readonly >
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-3 pad text-right">
                                        <label class="label-control marg">Round Off</label>
                                    </div>
                                    <div class="col-lg-3 pad">
                                        <input type="number" step="any" name="roundoff"  class="form-control form text-right roundoff" value="<?php echo ($addflag != 1) ? $get['roundoff'] : "0"; ?>" tabindex="-1">
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-3 pad text-right">
                                        <label class="label-control marg">Net Amount</label>
                                    </div>
                                    <div class="col-lg-3 pad">
                                        <!--<input type="text"  name="totbillamt" required="true" class="form-control form text-right totbillamt" value="<?php Echo ($addflag != 1) ? $get['billamt'] : "0"; ?>" readonly tabindex="-1">-->
                                        <input type="number" step="any" name="totbillamt" class="form-control form text-right totbillamt" value="<?php Echo ($addflag != 1) ? $get['billamt'] : "0"; ?>" readonly >
                                    </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>
        </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">
                    <input type="hidden" value="<?php Echo $file ?>" class="form-control file">

                    <div class="row">
                        <div class="col-lg-2">
                            <select class="form-control sfield">
                                <option value="1">Party</option>
                                <option value="2">Voucher</option>
                                <option value="3">Date</option>
                                <option value="4">GST%</option>
                                <option value="5">Godown</option>
                                <option value="6">Net 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">Party</option>
                                <option value="2">Voucher</option>
                                <option value="3">Date</option>
                                <option value="4">GST%</option>
                                <option value="5">Godown</option>
                                <option value="6">Net 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:#1ABC9C;">
                                    <th width="10%">Vocher</th>
                                    <th width="15%">Date</th>
                                    <th width="20%">Party</th>
                                    <th width="10%">Godown</th>
                                    <th width="10%">GST%</th>
                                    <th width="15%">Net Amount</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 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>
