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

date_default_timezone_set('Asia/Kolkata');

$formname = 'Sale GST';
$maindb = 'salemain';
$trandb = 'saletran';
$ptsdb = 'pointsacn';
$stkdb = 'transacn';
$accdb = 'actran';
$cashdb = 'cashrecp';
$bankdb = 'bankrecp';
$printfile = "salegstmulti_print.php";
$printpdf = "salegstmulti_print.php";
$file = 'salegstmulti.php';
$trandbexist = 1;
$keyfld = "vouchno";
$source = "SL";

$fseries = $_SESSION["series_" . $dbname];
$keycond = " and `series`='$fseries'";

//browse($fseries);
$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zyear = $myear = $_SESSION[$myyear];
$zStartDate = getzdates($zyear, 'S');
$zEndDate = getzdates($zyear, 'E');
$compcd = $_SESSION["comp_" . $dbname];
$usertype = $_SESSION["usertype_" . $dbname];
$username = $_SESSION["username_" . $dbname];
$rd = "";
if ($usertype != 1) {
    $rd = "readonly";
}

$stkdb1 = 'tran';
$zroot = $_SESSION["zdir"];
$combstkdb = $stkdb1 . $zyear;

$zroot1 = substr($zroot, 0, -4);
//$getcm = mysqli_query($conn, "SELECT perpntrate FROM $zroot.`company` WHERE code='$compcd'") or die(mysqli_error($conn));
//$fetcm = mysqli_fetch_array($getcm);
//$pointrate = $fetcm['perpntrate'];

$currcono = $compcd;
$curryear = $zyear;

mysqli_select_db($conn, $zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

if (isset($_POST["submit"])) {
    $a = 1;
    $invno = $_POST["invno"];
    $vouchdt = $_POST["vouchdt"];
    $invdt = $_POST["invdt"];
    $party = $_POST["party"];
    $type = $_POST["type"];
    $prodtype = $_POST["prodtype"];
    $salesman = $_POST["salesman"];
    $stafcode = $_POST["stafcode"];
    $driver = $_POST["driver"];
    $dcperc = $_POST["dcperc"];
    $dcbperc = $_POST["dcbperc"];
    $dcamt = $_POST["dcamt"];
    $subtotal = $_POST["subtotal"];
    $litemdisc = $_POST["litemdisc"];
    $cdiscperc = $_POST["cdiscperc"];
    $cdiscamt = $_POST["cdiscamt"];
    $coukg = $_POST["coukg"];
    $courate = $_POST["courate"];
    $couamt = $_POST["couamt"];
    $netamt = $_POST["netamt"];
    $oldamt = $_POST["oldamt"];
    $cashamt = $_POST["cashamt"];
    $ccamt = $_POST["ccamt"];
    $upiamt = $_POST["upiamt"];
    $upiname = $_POST["upiname"];
    $upichk = $_POST["upichk"];
    $credamt = $_POST["credamt"];
    $cashchk = $_POST["cashchk"];
    $cardchk = $_POST["cardchk"];
    $bothchk = $_POST["bothchk"];
    $prnflag = $_POST["prnflag"];
    $lesother = $_POST["lesother"];
    $remark1 = $_POST["remark1"];
    $remark2 = $_POST["remark2"];
    $disctotp = $_POST["disctotp"];
    $bankname = $_POST["bankname"];

    $email = $_POST["email"];
    $gstno = $_POST["gstno"];

    $oms = $_POST["oms"];
    $taxamt = $_POST["taxamt"];
    $totcgst = $_POST["totcgst"];
    $totsgst = $_POST["totsgst"];
    $totigst = $_POST["totigst"];
    $sgstperc = $_POST["sgstperc"];
    $cgstperc = $_POST["cgstperc"];
    $igstperc = $_POST["igstperc"];
    $gstperc = $_POST["gstperc"];

    $cgst5 = $_POST['cgst5'];
    $sgst5 = $_POST['sgst5'];
    $igst5 = $_POST['igst5'];

    $cgst12 = $_POST['cgst12'];
    $sgst12 = $_POST['sgst12'];
    $igst12 = $_POST['igst12'];

    $cgst18 = $_POST['cgst18'];
    $sgst18 = $_POST['sgst18'];
    $igst18 = $_POST['igst18'];

    $cgst28 = $_POST['cgst28'];
    $sgst28 = $_POST['sgst28'];
    $igst28 = $_POST['igst28'];

    $totqty = $_POST['totqty'];
    $totgst5 = $_POST['totgst5'];
    $totgst12 = $_POST['totgst12'];
    $totgst18 = $_POST['totgst18'];
    $totgst28 = $_POST['totgst28'];
    $totalgst = $totgst5 + $totgst12 + $totgst18 + $totgst28;
    $nameprint = $_POST['nameprint'];
    $printmobile = $_POST['printmobile'];
    $refmobile = $_POST['refmobile'];
    $totalamount = $_POST['totalamount'];
    $roundoff = $_POST['roundoff'];
    $redeem = $_POST['redeem'];
    $redeempoint = $_POST['redeempoint'];
    $pointrate = $_POST['pointrate'];
    $stafcomm = $_POST['stafcomm'];

    $count = $_POST["items"];

    if ($igstperc > 0) {
        $gstp = $igstperc;
    } else {
        $gstp = $cgstperc + $sgstperc;
    }

    $mvouch = $qvouch;
    if ($type == 'C') {
        $salecode = 14;
    } else {
        $salecode = 15;
    }


    if ($a == 1) {


        if ($addflag == 1) {
            $enttime = date("h:i A");
            $gen1 = mysqli_query($conn, "SELECT MAX(vouchno) AS maxcode FROM `$maindb` where $keyfld != '' $keycond LIMIT 0,1 ") or die(mysqli_error($conn));
            if (mysqli_num_rows($gen1) > 0) {
                $vvouch = mysqli_fetch_assoc($gen1);
                $qvouch = $vvouch["maxcode"] + 1;
            } else {
                $qvouch = '1';
            }
            $mvouch = $qvouch;
        }

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

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

        $srl = $tsint = $sintamt = $sint = 0;
        for ($i = 0; $i <= $count; $i++) {
            $msrno = $_POST["srno_$i"];
            $barcode = $_POST["barcode_$i"];
            $mitem = $_POST["item_$i"];
            $unit = $_POST["unit_$i"];
            $qty = $_POST["qty_$i"];
            $mrp = $_POST["mrp_$i"];
            $msp = $_POST["msp_$i"];
            $rate = $_POST["rate_$i"];
            $cost = $_POST["cost_$i"];
            $ratebfdisc = $_POST["ratebfdisc_$i"];
            $amount = $_POST["amount_$i"];

            $discperc = $_POST["discperc_$i"];
            $discamt = $_POST["discamt_$i"];
            $discperc2 = $_POST["discperc2_$i"];
            $discount2 = $_POST["discount2_$i"];
            $cgstrate = $_POST["cgstrate_$i"];
            $cgstamt = $_POST["cgstamt_$i"];
            $sgstrate = $_POST["sgstrate_$i"];
            $sgstamt = $_POST["sgstamt_$i"];
            $igstrate = $_POST["igstrate_$i"];
            $igstamt = $_POST["igstamt_$i"];
            $total = $_POST["total_$i"];
            $subtot = $_POST["subtot_$i"];

            $otprowsucs = $_POST["otprowsucs_$i"];
            $otpvalue = $_POST["otpvalue_$i"];
            $hsncode = $_POST["hsncode_$i"];

            $purvouch = $_POST["purvouch_$i"];
            $pursrno = $_POST["pursrno_$i"];
            $sintrate = $_POST["sintrate_$i"];
            $grp = $_POST["grp_$i"];
            $stkqt = $_POST["stkqty_$i"];

            $gstperc = $cgstperc + $sgstperc + $igstperc;

            $stkqty = $qty * -1;


            if (!empty($mitem)) {
                $srl = $srl + 1;
                $sintamt = $sintrate * $qty;

                mysqli_query($conn, "INSERT INTO `$trandb`(`vouchno`, `series`, `vouchdt`, `srno`, `barcode`, `item`, `qty`, `unit`, 
                                   `mrp`, `msp`, `rate`, `amount`, `discperc`, `discount`, `discperc2`, `discount2`, `otprowsucs`, `otpvalue`,`hsncode`,
                                   `cgstrate` , `cgstamt`, `sgstrate`, `ratebfdisc`,stkqty,cost,
                                   `sgstamt`, `igstrate`, `igstamt`,`total`, `subtot`, `gstperc`,`sintrate`, `grp`) 
                    VALUES ('$qvouch', '$fseries', '$vouchdt', '$srl', '$barcode', '$mitem', '$qty', '$unit', 
                            '$mrp', '$msp', '$rate', '$amount', '$discperc', '$discamt', '$discperc2', '$discount2', '$otprowsucs', '$otpvalue','$hsncode',
                             '$cgstrate', '$cgstamt', '$sgstrate', '$ratebfdisc','$stkqt','$cost',
                            '$sgstamt', '$igstrate', '$igstamt', '$total', '$subtot', '$gstperc', '$sintrate', '$grp')") or die(mysqli_error($conn));

                ###########Stock Part############

                mysqli_query($conn, "INSERT INTO `$stkdb`(`vouchno`, `series`, `compcode`, `yearno`, `vouchdt`, `srno`, `barcode`, `itemcode`, `qty`, `unit`,  `source`,
                                `mrp`, `rate`, `amount`,`ratebfdisc`,cost) 
                    VALUES ('$qvouch', '$fseries', '$compcd', '$zyear', '$vouchdt', '$srl', '$barcode', '$mitem', '$stkqty', '$unit', '$source',
                                '$mrp', '$rate', '$amount','$ratebfdisc','$cost')") or die(mysqli_error($conn));
                $tsint = $tsint + $sintamt;
            }
        }


        ############################## MAIN ######################################################
        if ($addflag == 1) {
            mysqli_query($conn, "INSERT INTO `$maindb`(`vouchno`, `series`, `enttime`, `username`, `invno`, `invdt`, `vouchdt`, `party`, `transporter`, `lrno`, `stafcode`, `stafcomm`,
                        `lrdate`, `cashcred`, `prodtype`, `salesman`, `driver`, `dcperc`, `dcbperc`, `dcamt`, `totqty`, `subtotal`, `litemdisc`, `cashchk`, `cardchk`, `bothchk`, `prnflag`,
                        `cdiscperc`, `cdiscamt`, `coukg`, `courate`, `couamt`, `discperc`, `discount`, `netamt`, `cashamt`,`ccamt`,`credamt`, `lesother`,  `upichk`, `upiamt`,upiname,
                        `remark1`, `remark2`,`cashvouch`,`disctotp`,`purcono`,`purvouch`,`bankvouch`,`bankname`, `oms`, `cgstperc`, `sgstperc`, `igstperc`, 
                        `totcgst`, `totsgst`, `totigst`, `tottaxamt`,`gstperc`,`cgst5`,`sgst5`,`igst5`,`cgst12`,`sgst12`,`igst12`,`cgst18`,`sgst18`,`igst18`,`cgst28`,
                        `totalgst`,`sgst28`,`igst28`,`totgst5`,`totgst12`,`totgst18`,`totgst28`,`nameprint`,`printmobile`,`totalamount`,`roundoff`, `gstno`, `email`, 
                        `redeem`, `refmobile`, `pointrate`, redeempoint,incentive) 
                        VALUES ('$qvouch', '$fseries', '$enttime', '$username', '$invno', '$vouchdt', '$vouchdt', '$party', '$transporter', '$lrno', '$stafcode', '$stafcomm',
                        '$lrdate', '$type', '$prodtype', '$salesman', '$driver', '$dcperc', '$dcbperc', '$dcamt', '$totqty', '$subtotal', '$litemdisc',  '$cashchk', '$cardchk', '$bothchk', '$prnflag',
                        '$cdiscperc', '$cdiscamt', '$coukg', '$courate', '$couamt', '$discperc', '$discount', '$netamt', '$cashamt','$ccamt','$credamt', '$lesother', '$upichk', '$upiamt','$upiname',
                        '$remark1', '$remark2','$mcashvouch', '$disctotp','$purcono','$mpurvouch','$mbankvouch','$bankname', '$oms', '$cgstperc', '$sgstperc', '$igstperc',
                        '$totcgst', '$totsgst', '$totigst', '$taxamt','$gstperc','$cgst5','$sgst5','$igst5', '$cgst12','$sgst12','$igst12', '$cgst18', '$sgst18','$igst18','$cgst28',
                        '$totalgst','$sgst28','$igst28','$totgst5','$totgst12','$totgst18','$totgst28','$nameprint','$printmobile','$totalamount','$roundoff', '$gstno', '$email',
                        '$redeem', '$refmobile', '$pointrate', '$redeempoint','$tsint')") or die(mysqli_error($conn));
//            insmess();

            $mvouch = $qvouch; //1
//            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        } else {
            $mvouch = $qvouch; //1

            mysqli_query($conn, "UPDATE `$maindb` SET `invno`='$invno',`username`='$username', `invdt`='$vouchdt',`vouchdt`='$vouchdt',
                       `nameprint`='$nameprint', `printmobile`='$printmobile',`party`='$party',`transporter`='$transporter',  upichk='$upichk', upiamt='$upiamt',
                       `lrno`='$lrno',`lrdate`='$lrdate',`cashcred`='$type',`prodtype`='$prodtype',`salesman`='$salesman',
                       `driver`='$driver',`dcperc`='$dcperc',`dcbperc`='$dcbperc',`dcamt`='$dcamt',`totqty`='$totqty',
                       `subtotal`='$subtotal', `stafcode`='$stafcode', `stafcomm`='$stafcomm', `litemdisc`='$litemdisc',
                       `cdiscperc`='$cdiscperc',`cdiscamt`='$cdiscamt',`coukg`='$coukg',`courate`='$courate',`couamt`='$couamt',
                       `discperc`='$discperc',`discount`='$discount',`netamt`='$netamt',`credamt`='$credamt',`ccamt`='$ccamt',
                       `cashamt`='$cashamt', `lesother`='$lesother',`remark1`='$remark1', `remark2`='$remark2', 
                       `cashvouch`='$mcashvouch',`disctotp`='$disctotp',`purcono`='$purcono',`purvouch`='$mpurvouch',
                       `bankvouch`='$mbankvouch',`bankname`='$bankname', `oms`='$oms',`cgstperc`='$cgstperc',`gstperc`='$gstperc',
                       `sgstperc`='$sgstperc', `igstperc`='$igstperc', `totcgst`='$totcgst', `totsgst`='$totsgst', 
                       `totigst`='$totigst', `tottaxamt`='$taxamt', `cgst5`='$cgst5',`sgst5`='$sgst5', `igst5`='$igst5',
                       `cgst12`='$cgst12',`sgst12`='$sgst12',`igst12`='$igst12', `cgst18`='$cgst18', `sgst18`='$sgst18', 
                       `igst18`='$igst18',`totalgst`='$totalgst', `cashchk`='$cashchk', upiname= '$upiname', `cardchk`='$cardchk', `bothchk`='$bothchk',
                       `cgst28`='$cgst28', `sgst28`='$sgst28',`igst28`='$igst28',`totalamount`='$totalamount',
                       `roundoff`='$roundoff', `prnflag`='$prnflag',`totgst5`='$totgst5',`totgst12`='$totgst12', 
                       `totgst18`='$totgst18',`totgst28`='$totgst28', `email`='$email', `gstno`='$gstno', `redeem`='$redeem', `refmobile`='$refmobile',
                       `pointrate`='$pointrate', redeempoint='$redeempoint',incentive='$tsint' WHERE `vouchno`='$qvouch' and series='$fseries'") or die(mysqli_error($conn));


//            updmess();
        }
        if ($prnflag == '1') {
            $_SESSION['print_voucher'] = $mvouch;
        }


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

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

    $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE $keyfld='$getvouch' $keycond") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);
    $delcsh = $get['cashvouch'];
    $delbnk = $get['bankvouch'];
    $delpurcono = $get['purcono'];
    $delpurvch = $get['purvouch'];

    if ($get["oms"] == 1) {
        $ofs = "Out of State";
    } else {
        $ofs = "In State";
    }

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

    $findsalem = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `accode`='$get[salesman]' AND `grpcode`='040'") or die(mysqli_error($conn));
    $lsalem = mysqli_fetch_array($findsalem);

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

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

    $getcomp2 = mysqli_query($conn, "SELECT * FROM $zroot.`company` WHERE code='$get[tocomp]'") or die(mysqli_error($conn));
    $fetcomp2 = mysqli_fetch_array($getcomp2);

    $getupi = mysqli_query($conn, "SELECT code,name FROM `paytype` WHERE `code` = '$get[upiname]'");
    $lupi = mysqli_fetch_array($getupi);
}

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

if (isset($_GET["delete"])) {
    $delcond2 = " series = '$fseries' and vouchno = '$_GET[vouchno]' ";
    $delcond1 = " source = '$source' and vouchno = '$_GET[vouchno]' and series = '$fseries'";
    delnew($zdb, "$maindb", "$delcond2", "$file?mode=last");
    delnew($zdb, "$trandb", "$delcond2", "$file?mode=last");
    delnew($zdb, "$stkdb", "$delcond1", "$file?mode=last");
    delnew($zdb, "$ptsdb", "$delcond2", "$file?mode=last");
}



include("includes/linkshead.php");
?>
<script src="MyScript/shortkeys.js" type="text/javascript"></script>
<script src="MyScript/checkdate.js" type="text/javascript"></script>
<script src="MyScript/salegstmulti.js?a=4" type="text/javascript"></script>
<script src="MyScript/salegstmulti_search.js?a=<?= mt_rand(); ?>" type="text/javascript"></script>

<style>
    label{
        font-size: 13px;
    }
    table tr{
        font-size: 12px;
        font-weight: normal;
    }
    input[type = checkbox]{
        width: 20px;
        height: 20px;
    }
</style>
</head>
<body >
    <form action='' method='POST'>
        <div class="col-lg-5 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>
            <button type="button" id="close_form1" style="float: right;font-weight: bold;font-size: 18px;color:red;" ><i class="fa fa-close"></i></button>
            <div class="normotp">
                <div style='width:100%;' id='browdata'>
                    MSP
                </div>
                <div class="ratemspless">
                    <label class="label-control">Rate Cannot Be Less Than Msp</label>
                    <label class="label-control">To Sell Below MSP Generate OTP</label>

                    <input type="button" name="genotp" class="form-control genotp" style="color:red;border: none" value="Click here to Generate OTP">
                    <input type="hidden" name="rowsrno" id="rowsrno" class="form-control rowsrno">
                    <input type="hidden" name="rowitm" id="rowitm" class="form-control rowitm">
                    <input type="hidden" name="rowqty" id="rowqty" class="form-control rowqty">
                    <input type="hidden" name="rowrate" id="rowrate" class="form-control rowrate">
                    <input type="hidden" name="rowmrp" id="rowmrp" class="form-control rowmrp">
                    <input type="hidden" name="rowmsp" id="rowmsp" class="form-control rowmsp">
                    <input type="hidden" name="idget" id="idget" class="form-control idget">
                    <div class="row">
                        <div class="col-lg-4 text-right"><label class="label-control">Enter OTP</label></div>
                        <div class="col-lg-4">
                            <input type="text" name="otprecv" id="otprecv" class="form-control otprecv" style="background-color: white;color: green;">
                        </div>
                    </div>
                    <input type="hidden" name="otpsend" id="otpsend" class="form-control otpsend">
                    <!--<a id="genotp" name="genotp" class="form-control genotp" style="color:red;"><u>Generate OTP</u></a>-->
                    <div class="row">
                        <div class="col-lg-4 text-right"></div>
                        <div class="col-lg-4 ">
                            <input type="button" name="subotp" id="subotp" class="form-control form subotp" style="color: blue;background-color: whitesmoke" value="Submit OTP">
                        </div>
                    </div>
                    <input type="hidden" name="otpsucs" id="otpsucs" class="form-control otpsucs">
                </div>
            </div>
            <div class="lesdsotp">

                <!--<a id="genotp" name="genotp" class="form-control genotp" style="color:red;"><u>Generate OTP</u></a>-->
                <div class="row">
                    <label class="label-control">Total Amount of Bill is Less Than Msp Total</label>
                    <label class="label-control">To Sell Below MSP Total Generate OTP</label>
                </div>
                <div class="row">
                    <div class="col-lg-12">    
                        <input type="button" name="gendsotp" class="form-control gendsotp form" style="color:red;border: none;" value="Click to Generate Discount OTP">
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-4 text-right"><label class="label-control">Discount OTP</label></div>
                    <div class="col-lg-4">
                        <input type="text" name="otpdsrecv" id="otpdsrecv" class="form-control otpdsrecv" style="background-color: white;color: green;">
                        <input type="hidden" name="otpdssend" id="otpdssend" class="form-control otpdssend">
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-4 text-right"></div>
                    <div class="col-lg-4 ">
                        <input type="button" name="subdsotp" id="subdsotp" class="form-control form subdsotp" style="color: blue;background-color: whitesmoke" value="Submit Discount OTP">
                    </div>
                </div>
                <input type="hidden" name="otpdssucs" id="otpdssucs" class="form-control otpdssucs">

            </div>
        </div>

        <!-- Default box -->
        <div class="w3-mobile">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 w3-mobile 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>

                    <div class="panel-body ">
                        <div class="row w3-mobile">
                            <div class="col-lg-1 col-md-2 col-sm-5 col-xs-4 text-right pad">
                                <label class="label-control marg">Voucher</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-2 pad">
                                <input type="text" class="form-control form vouchno" name="vouchno" value="<?php Echo ($addflag != 1) ? $get["vouchno"] : "$qvouch"; ?>" required readonly>
                                <input type="hidden" class="form-control form" name="cashvouch" value="<?php Echo ($addflag != 1) ? $get["cashvouch"] : ""; ?>" readonly>
                                <input type="hidden" class="form-control form" name="bankvouch" value="<?php Echo ($addflag != 1) ? $get["bankvouch"] : ""; ?>" readonly>
                                <input type="hidden" class="form-control form addflg" name="addflg" value="<?php Echo "$addflag"; ?>" readonly>
                                <input type="hidden" class="form-control form formname" name="formname" value="<?php Echo $file; ?>" readonly>

                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Date</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4 pad">
                                <input type="date" class="form-control form vouchdt focusfield" name="vouchdt" value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>" autofocus="autofocus" style="padding:0px" >
                            </div>                            
                            <!--                        </div>
                                                    <div class="row">-->
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-4 text-right pad">
                                <label class="label-control marg" style="text-align:right;">Invoice No.</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control form" name="invno" value="<?php Echo ($addflag != 1) ? $get["invno"] : "$qvouch"; ?>"  >
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-5 col-xs-3 text-right pad">
                                <label class="label-control marg">Party</label>
                            </div>
                            <div class="col-lg-3 col-md-8 col-sm-3 col-xs-7 pad">
                                <select class="form-control form  select2 party" name="party" style="width: 95%" required>
                                    <option value="<?php Echo ($addflag != 1) ? $get["party"] : ""; ?>"><?php Echo ($addflag != 1) ? $lparty["name"] : ""; ?></option>
                                    <?php
                                    $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 class="col-lg-1 col-md-2 col-sm-7 col-xs-7 pad ">
                                <input type="hidden" class="form-control form oms" name="oms" value="<?= $get["oms"]; ?>" readonly="">

                                <label class="label-control marg  text-right ofs" style="color:red"><?= $ofs ?></label>
                            </div>
                            <input type="hidden" class="form-control form prodtype " name="prodtype" value="O" style="width: 100%" required>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-striped table-condensed table-bordered tab" width="100%">


                                <thead  class="mySearchTr">
                                    <tr>
                                        <th style='width: 1%'></th>
                                        <th style='width: 2%' class='text-center'>Sr.</th>
                                        <th style='width: 12%' class='text-center'>Item</th>
                                        <th style='width: 3%' class='text-center'>Hsn Code</th>
                                        <!--<th style='width: 3%' class='text-center'>Stock</th>-->
                                        <th style='width: 3%' class='text-center'>Qty.</th>
                                        <th style='width: 3.5%' class='text-center'>Unit</th>
                                        <!--<th style='width: 4%' class='text-center'>Mrp</th>-->
                                        <th style='width: 4%' class='text-center'>Rate</th>
                                        <!--<th style='width: 4%' class='text-center'>Rate Disc.</th>-->
                                        <!--<th style='width: 4%' class='text-center'>Act. Rate</th>-->
                                        <th style='width: 5.5%' class='text-center'>Amount</th>
                                        <th style='width: 3%' class='text-center'>Disc. %</th>
                                        <th style='width: 5%' class='text-center'>Disc. Amt.</th>
                                        <th style='width: 5.5%' class='text-center'>Taxable value</th>
                                        <th style='width: 4%' class='text-center'>CGST Rate</th>
                                        <th style='width: 5%' class='text-center'>CGST Amt.</th>
                                        <th style='width: 4%' class='text-center'>SGST Rate</th>
                                        <th style='width: 5%' class='text-center'>SGST Amt.</th>
                                        <th style='width: 4%' class='text-center'>IGST Rate</th>
                                        <th style='width: 5%' class='text-center'>IGST Amt.</th>
                                        <th style='width: 5.5%' class='text-center'>Total</th>
                                    </tr>
                                </thead>
                                <tbody class="tbody" id="saledtltab">
                                    <?php
                                    if ($addflag != 1) {
                                        $ctr = 0;
                                        $gettran = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$get[vouchno]' $keycond ORDER BY `srno`")or die(mysqli_error($conn));
                                        while ($tran = mysqli_fetch_array($gettran)) {
                                            $finditem = mysqli_query($conn, "SELECT `code`,`name` FROM `product` WHERE `code`='$tran[item]'") or die(mysqli_error($conn));
                                            $fitem = mysqli_fetch_array($finditem);

                                            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]' tabindex='-1'>
                                                      <input type='hidden' class='form-control form text-right purvouch' name='purvouch_$sctr' value='$fetquery[purvouch]'>
                                                      <input type='hidden' class='form-control form text-right pursrno' name='pursrno_$sctr' value='$fetquery[pursrno]'></td>";

                                            Echo "<td>";
                                            Echo "<select class='form-control form item select2' name='item_$ctr' style='width:100%'>";
                                            Echo "<option value='$fitem[code]'>$fitem[name]</option>";
//                                            if ($usertype == 1) {
                                            $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 type='hidden' class='msp' name='msp_$ctr' value='$tran[msp]' >";
                                            Echo "<input type='hidden' class='otprowsucs' name='otprowsucs_$ctr' value='$tran[otprowsucs]' >";
                                            Echo "</td>";
                                            Echo "<td><input type='text' class='form-control form hsncode'                name='hsncode_$ctr'     tabindex='-1'   value='$tran[hsncode]'></td>";
//                                            Echo "<td><input type='text' class='form-control form text-right stkqty'      name='stkqty_$ctr'      value='$tran[stkqty]'  tabindex='-1' readonly style='background-color:yellow'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right qty'      name='qty_$ctr'      value='$tran[qty]'></td>";
                                            Echo "<td><input type='text' class='form-control form  unit'      name='unit_$ctr'      value='$tran[unit]' readonly  tabindex='-1'>";

                                            Echo "<input type='hidden' class='msp' name='msp_$ctr' >";
                                            Echo "<input type='hidden' class='otpvalue' id='otpvalue_$ctr' name='otpvalue_$ctr' value='$tran[otpvalue]'>";
                                            Echo "</td>";
//                                            Echo "<td><input type='text' class='form-control form text-right mrp'      name='mrp_$ctr'      value='$tran[mrp]' readonly  tabindex='-1'></td>";
                                            echo "<td><input type='text' name='ratebfdisc_$ctr' class='ratebfdisc form-control text-right  form'  value='$tran[ratebfdisc]' $rd>"
                                            . "<input type='hidden' name='cost_$ctr' class='cost form-control text-right  form'  value='$tran[cost]' >"
                                            . "<input type='hidden' name='sintrate_$ctr' class='sintrate form-control text-right  form'  value='$tran[sintrate]' >"
                                            . "<input type='hidden' name='discperc2_$ctr' class='discperc2 form-control text-right  form'  value='$tran[discperc2]' >"
                                            . "<input type='hidden' name='discount2_$ctr' class='discount2 form-control text-right  form'  tabindex='-1'   value='$tran[discount2]' >"
                                            . "<input type='hidden' class='form-control form text-right rate'     name='rate_$ctr'     value='$tran[rate]' readonly tabindex='-1'></td>";
//                                            Echo "<td><input type='text' name='discount2_$ctr' class='discount2 form-control text-right  form'  value='$tran[discount2]' ></td>";
                                            Echo "<td><input type='text' class='form-control form text-right amount'   name='amount_$ctr'   value='$tran[amount]' readonly tabindex='-1'>
                                            <input type='hidden' class='form-control form text-right mspamount'   name='mspamount_$ctr'   value='$tran[mspamount]' readonly tabindex='-1'></td>";
                                            Echo "<td><input type='text' name='discperc_$ctr' class='discperc form-control text-right  form'  value='$tran[discperc]' $rd></td>";
                                            Echo "<td><input type='text' name='discamt_$ctr' class='discamt form-control text-right  form' value='$tran[discount]' $rd></td>";
                                            Echo "<td><input type='text' name='subtot_$ctr' class='subtot form-control text-right  form' tabindex='-1' value='$tran[subtot]' readonly></td>";
                                            Echo "<td><input type='text' name='cgstrate_$ctr' class='cgstrate form-control text-right  form' tabindex='-1' value='$tran[cgstrate]' readonly></td>";
                                            Echo "<td><input type='text' name='cgstamt_$ctr' class='cgstamt form-control text-right  form' tabindex='-1' value='$tran[cgstamt]' readonly></td>";
                                            Echo "<td><input type='text' name='sgstrate_$ctr' class='sgstrate form-control text-right  form' tabindex='-1' value='$tran[sgstrate]' readonly></td>";
                                            Echo "<td><input type='text' name='sgstamt_$ctr' class='sgstamt form-control text-right  form' tabindex='-1' value='$tran[sgstamt]' readonly></td>";
                                            Echo "<td><input type='text' name='igstrate_$ctr' class='igstrate form-control text-right  form' tabindex='-1' value='$tran[igstrate]' readonly></td>";
                                            Echo "<td><input type='text' name='igstamt_$ctr' class='igstamt form-control text-right  form' tabindex='-1' value='$tran[igstamt]' readonly></td>";
                                            Echo "<td><input type='text' name='total_$ctr' class='total form-control text-right  form' tabindex='-1' value='$tran[total]' readonly></td>";
                                            Echo "</tr >";
                                            $ctr++;
                                        }
                                    } else {
                                        $pctr = 0;
                                        ?>
                                        <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"  tabindex='-1'>
                                                <input type="hidden" class="form-control form text-right purvouch" name="purvouch_0" value="">
                                                <input type="hidden" class="form-control form text-right pursrno" name="pursrno_0" value=""></td>
                                            <td>
                                                <select class="form-control form item select2" id="item" name="item_0" style='width:100%'>
                                                    <option value=""></option>
                                                    <?php
//                                                    if ($usertype == 1) {
                                                    $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 type='hidden' class='msp' name='msp_0' >
                                                <input type='hidden' class='otprowsucs' name='otprowsucs_0' >
                                                <input type='hidden' class='otpvalue' name='otpvalue_0' >
                                            </td>
                                            <td><input type="text" class="form-control form text-left hsncode"     name="hsncode_0"      value=""  tabindex='-1'></td>
                                            <!--<td><input type='text' class='form-control form text-right stkqty'      name='stkqty_0' readonly     value='0' style='background-color:yellow' tabindex='-1'></td>-->

                                            <td><input type="text" class="form-control form text-right qty"      name="qty_0"         value="0"></td>
                                            <td>
                                                <input type="text" class="form-control form unit"      name="unit_0"         value="" readonly tabindex='-1'>
                                            </td>
                                            <!--<td><input type="text" class="form-control form text-right mrp"      name="mrp_0"         value="0" readonly  tabindex='-1'></td>-->
                                            <td><input type="text" class="form-control form text-right ratebfdisc"  id="ratebfdisc_<?= $pctr ?>"   name="ratebfdisc_0"  <?= $rd ?>      value="0">
                                                <input type="hidden" class="form-control form text-right cost"  id="cost_<?= $pctr ?>"   name="cost_0"        value="0" tabindex='-1'>
                                                <input type="hidden" class="form-control form text-right sintrate"  id="sintrate_<?= $pctr ?>"   name="sintrate_0"        value="0" tabindex='-1'>
                                                <input type="hidden" class="form-control form text-right discperc2"  id="discperc2_<?= $pctr ?>"   name="discperc2_0"        value="0" tabindex='-1'>
                                                <input type="hidden" class="form-control form text-right discount2"  id="discount2_<?= $pctr ?>"   name="discount2_0"        value="0" tabindex='-1'>
                                            <!--<td><input type='text' name='discount2_0' class='discount2 text-right form-control form  ' value='0.00'  ></td>--> 
                                                <input type="hidden" class="form-control form text-right rate"  id="rate_<?= $pctr ?>"   name="rate_0"        value="0" <?= $rd ?> readonly tabindex='-1'></td>
                                            <td><input type="text" class="form-control form text-right amount"   name="amount_0"      value="0" readonly tabindex='-1'>
                                                <input type="hidden" class="form-control form text-right mspamount"   name="mspamount_0"      value="0" readonly tabindex='-1'></td>
                                            <td><input type='text' name='discperc_0' class='discperc text-right form-control form ' value='0.00' <?= $rd ?>></td> 
                                            <td><input type='text' name='discamt_0' class='discamt text-right form-control form  ' value='0.00'  <?= $rd ?>></td> 
                                            <td><input type='text' name='subtot_0' class='subtot text-right form-control form  ' value='0.00' tabindex='-1' readonly></td> 
                                            <td><input type='text' name='cgstrate_0' class='cgstrate text-right form-control form  ' value='0.00' tabindex='-1' readonly></td> 
                                            <td><input type='text' name='cgstamt_0' class='cgstamt text-right form-control form  ' value='0.00' tabindex='-1' readonly></td> 
                                            <td><input type='text' name='sgstrate_0' class='sgstrate text-right form-control form  ' value='0.00' tabindex='-1' readonly></td> 
                                            <td><input type='text' name='sgstamt_0' class='sgstamt text-right form-control form  ' value='0.00' tabindex='-1' readonly></td> 
                                            <td><input type='text' name='igstrate_0' class='igstrate text-right form-control form  ' value='0.00' tabindex='-1' readonly></td> 
                                            <td><input type='text' name='igstamt_0' class='igstamt text-right form-control form  ' value='0.00' tabindex='-1' readonly></td> 
                                            <td><input type='text' name='total_0' class='total text-right form-control form  ' value='0.00' tabindex='-1' readonly></td>
                                        </tr>  
                                        <?
                                        $pctr++;
                                    }
                                    ?>
                                <input type="hidden" id="items" name="items" value="<?php echo ($addflag != 1) ? $ctr : 1; ?>" />  

                                </tbody>
                            </table>

                        </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">
                        <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">Salesman</label>
                                                                        </div>
                                                                        <div class="col-lg-6 pad">
                                                                            <select class="form-control form  select2" name="salesman" style="width: 100%">
                                                                                <option value="<?php // Echo ($addflag != 1) ? $get["salesman"] : "";                                                                                        ?>"><?php // Echo ($addflag != 1) ? $lsalem["name"] : "";                                                                                        ?></option>
                                    <?php
//                                            $gsales = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `grpcode`='040'")or die(mysqli_error($conn));
//                                            while ($sales = mysqli_fetch_array($gsales)) {
//                                                Echo "<option value='$sales[accode]'>$sales[name]</option>";
//                                            }
                                    ?>
                                                                            </select>
                                                                        </div>-->
                                </div>
                                <!--                                <div class="col-lg-12 col-xs-12 pad">
                                                                    <div class="col-lg-3 pad text-right">
                                                                        <label class="label-control marg">Driver</label>
                                                                    </div>
                                                                    <div class="col-lg-6 pad">
                                                                        <select class="form-control form driver select2" name="driver" style="width: 100%">
                                                                            <option value="<?php // Echo ($addflag != 1) ? $get["driver"] : "";                                                                  ?>"><?php // Echo ($addflag != 1) ? $ldriver["name"] : "";                                                                  ?></option>
                                                                            <option value=""></option>
                                <?php
//                                            $gdriver = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` where grpcode = '028' ORDER BY `name`")or die(mysqli_error($conn));
//                                            while ($driver = mysqli_fetch_array($gdriver)) {
//                                                Echo "<option value='$driver[code]'>$driver[name]</option>";
//                                            }
                                ?>
                                                                        </select>
                                                                    </div>
                                                                </div>-->
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad text-right">
                                        <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>
                                    </div>

                                </div>
                                <div class="col-lg-12 col-xs-12 pad">

                                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad text-right">
                                        <label class="label-control marg">Remarks</label>
                                    </div>
                                    <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 pad">
                                        <input type="text" name="remark1" class="form-control form remark1" value="<? Echo ($addflag != 1) ? $get["remark1"] : ""; ?>">
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3  pad text-right"></div>
                                    <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 pad">
                                        <input type="text" name="remark2" class="form-control form remark2" value="<? Echo ($addflag != 1) ? $get["remark2"] : ""; ?>">
                                    </div>
                                </div>

                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="row">
                                        <div class="col-lg-3 pad"></div>
                                        <div class="col-lg-9 pad">
                                            <div class="table-responsive">
                                                <table class="table table-striped table-condensed table-bordered" width="100%">
                                                    <thead class="mySearchTr" style="color: white">
                                                        <tr>
                                                            <th width="10%"></th>
                                                            <th width="18%" class='text-right'>CGST</th>
                                                            <th width="18%" class='text-right'>SGST</th>
                                                            <th width="18%" class='text-right'>IGST</th>
                                                            <th width="35%" ></th>
                                                        </tr>
                                                    </thead>
                                                    <tbody class="">
                                                        <?php
                                                        if ($addflag != 1) {

                                                            Echo "<tr>";
                                                            Echo "<td class='text-right'><b>5%</b></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right cgst5'     name='cgst5'       value='$get[cgst5]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right sgst5'     name='sgst5'       value='$get[sgst5]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right igst5'     name='igst5'       value='$get[igst5]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right totgst5'     name='totgst5'       value='$get[totgst5]' readonly></td>";
                                                            Echo "</tr>";
                                                            Echo "<tr>";
                                                            Echo "<td class='text-right'><b>12%</b></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right cgst12'     name='cgst12'       value='$get[cgst12]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right sgst12'     name='sgst12'       value='$get[sgst12]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right igst12'     name='igst12'       value='$get[igst12]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right totgst12'     name='totgst12'       value='$get[totgst12]' readonly></td>";
                                                            Echo "</tr>";
                                                            Echo "<tr>";
                                                            Echo "<td class='text-right'><b>18%</b></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right cgst18'     name='cgst18'       value='$get[cgst18]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right sgst18'     name='sgst18'       value='$get[sgst18]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right igst18'     name='igst18'       value='$get[igst18]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right totgst18'     name='totgst18'       value='$get[totgst18]' readonly></td>";

                                                            Echo "</tr>";
                                                            Echo "<tr>";
                                                            Echo "<td class='text-right'><b>28%</b></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right cgst28'     name='cgst28'       value='$get[cgst28]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right sgst28'     name='sgst28'       value='$get[sgst28]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right igst28'     name='igst28'       value='$get[igst28]' readonly></td>";
                                                            Echo "<td><input type='number' class='form-control form text-right totgst28'     name='totgst28'       value='$get[totgst28]' readonly></td>";
                                                            Echo "</tr>";
                                                        } else {
                                                            ?>
                                                            <tr>
                                                                <td class='text-right'><b>5%</b></td>
                                                                <td><input type='number' class='form-control form text-right cgst5'     name='cgst5'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right sgst5'     name='sgst5'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right igst5'     name='igst5'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right totgst5'     name='totgst5'       value='0' readonly></td>
                                                            </tr>
                                                            <tr>
                                                                <td class='text-right'><b>12%</b></td>
                                                                <td><input type='number' class='form-control form text-right cgst12'     name='cgst12'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right sgst12'     name='sgst12'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right igst12'     name='igst12'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right totgst12'     name='totgst12'       value='0' readonly></td>
                                                            </tr>
                                                            <tr>
                                                                <td class='text-right'><b>18%</b></td>
                                                                <td><input type='number' class='form-control form text-right cgst18'     name='cgst18'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right sgst18'     name='sgst18'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right igst18'     name='igst18'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right totgst18'     name='totgst18'       value='0' readonly></td>
                                                            </tr>
                                                            <tr>
                                                                <td class='text-right'><b>28%</b></td>
                                                                <td><input type='number' class='form-control form text-right cgst28'     name='cgst28'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right sgst28'     name='sgst28'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right igst28'     name='igst28'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right totgst28'     name='totgst28'       value='0' readonly></td>
                                                            </tr>
                                                            <?
                                                        }
                                                        ?>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </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-4 col-md-4 col-sm-2 col-xs-2  pad text-right">
                                        <label class="label-control marg" style='color:#337AB7'>Total Qty. </label>
                                    </div>
                                    <div class="col-lg-2 pad col-md-3 col-sm-3 col-xs-3 ">
                                        <input type="text" name="totqty" class="form-control form text-right totqty"  value="<?php echo ($addflag != 1) ? $get['totqty'] : "0.00"; ?>" readonly>
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3  pad text-right">
                                        <label class="label-control marg" style='color:#337AB7'>SubTotal</label>
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4  pad">
                                        <input type="text" class="form-control form subtotal text-right" value="<? Echo ($addflag != 1) ? $get['subtotal'] : "0"; ?>" name="subtotal" readonly>
                                        <input type="hidden" class="form-control form msptotal text-right" value="<? Echo ($addflag != 1) ? $get['msptotal'] : "0"; ?>" name="msptotal" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-2 pad"></div>
                                    <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4  pad text-right">
                                        <label class="label-control marg">Less Item Discount</label>
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4  pad">
                                        <input type="text" class="form-control form litemdisc text-right" value="<? Echo ($addflag != 1) ? $get['litemdisc'] : "0"; ?>" name="litemdisc" readonly>
                                    </div>
                                </div>
                                <!--                                <div class="col-lg-12 col-xs-12 pad">
                                                                    <div class="col-lg-3 pad">   
                                                                        <input type="button" name="gendsotp" class="form-control gendsotp form" style="color:red;border: none;" value="Generate Discount OTP">
                                                                    </div>
                                                                    <div class="col-lg-3 pad text-right">
                                                                        <label class="label-control marg">Less Cash Discount</label>
                                                                    </div>
                                                                    <div class="col-lg-2 pad">
                                                                        <input type="text" class="form-control form cdiscperc text-right" value="<? Echo ($addflag != 1) ? $get['cdiscperc'] : "0"; ?> "  name="cdiscperc">
                                                                    </div>
                                                                    <div class="col-lg-1 pad">
                                                                        <label class="label-control marg">%</label>
                                                                    </div>
                                                                    <div class="col-lg-3 pad">
                                                                        <input type="text" class="form-control form cdiscamt text-right" value="<? Echo ($addflag != 1) ? $get['cdiscamt'] : "0"; ?>" name="cdiscamt" readonly>
                                                                    </div>
                                                                </div>
                                -->         
                                <!--                                <div class="col-lg-12 col-md-12 col-xs-12 pad">
                                                                    <div class="col-lg-3 col-md-3 pad"></div>
                                                                    <div class="col-lg-3 col-md-3 text-right pad">
                                                                    </div>
                                                                    <div class="col-lg-3 col-md-3 text-right pad">      
                                                                        <label class="label-control marg">Less Other</label>
                                                                    </div>
                                                                    <div class="col-lg-3 col-md-3 pad">-->
                                <input type="hidden" class="form-control form lesother text-right" value="<? Echo ($addflag != 1) ? $get['lesother'] : "0"; ?>" name="lesother" readonly>
                                <input type="hidden" class="form-control form disctotp text-right" value="<? Echo ($addflag != 1) ? $get['disctotp'] : ""; ?>" name="disctotp" >
                                <!--                            </div>
                                                        </div>-->
                                <!--                                <div class="col-lg-12 col-xs-12 pad">
                                                                    <div class="col-lg-2 pad text-right">
                                                                        <label class="label-control marg">Add Courier</label>
                                                                    </div>
                                                                    <div class="col-lg-2 pad text-right">
                                                                        <input type="text" class="form-control form coukg text-right" value="<? Echo ($addflag != 1) ? $get['coukg'] : "0"; ?>" name="coukg" >
                                                                    </div>
                                                                    <div class="col-lg-1 pad text-left">
                                                                        <label class="label-control marg">/Kg</label>
                                                                    </div>
                                                                    <div class="col-lg-3 pad">
                                                                        <input type="text" class="form-control form courate text-right" value="<? Echo ($addflag != 1) ? $get['courate'] : "0"; ?>" name="courate">
                                                                    </div>
                                                                    <div class="col-lg-1 pad">
                                                                        <label class="label-control marg">Rate</label>
                                                                    </div>
                                                                    <div class="col-lg-3 pad">
                                                                        <input type="text" class="form-control form couamt text-right" value="<? Echo ($addflag != 1) ? $get['couamt'] : "0"; ?>" name="couamt" readonly>
                                                                    </div>
                                                                </div>-->
                                <div class="col-lg-12 col-md-12 col-xs-12 pad">
                                    <div class="col-lg-3 col-md-3 pad"></div>
                                    <div class="col-lg-3 col-md-3 text-right pad">
                                        <!--<label class="label-control marg">Less Other</label>-->
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-8 col-xs-8 pad text-right">
                                        <label class="label-control marg">Taxable Value</label>

                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 pad">
                                        <input type="text" class="form-control form taxamt numeric" value="<? Echo ($addflag != 1) ? $get['tottaxamt'] : "0"; ?>" name="taxamt" readonly>
                                    </div>
                                </div>


                                <div class="col-lg-12 col-md-12 col-xs-12 pad">
                                    <div class="col-lg-3 col-md-3 pad"></div>
                                    <div class="col-lg-3  text-right pad">
                                        <!--<label class="label-control marg">Less Other</label>-->
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-8 col-xs-8 pad text-right">
                                        <label class="label-control marg">Total Gst</label>

                                    </div>
                                    <div class="col-lg-3  col-md-3 col-sm-4 col-xs-4 pad">
                                        <input type="text" class="form-control form text-right totalgst" value="<? Echo ($addflag != 1) ? $get['totalgst'] : "0"; ?>" name="totalgst" readonly>
                                    </div>
                                </div>

                                <div class="col-lg-12 col-md-12 col-xs-12 pad">
                                    <div class="col-lg-3 col-md-3 pad"></div>
                                    <div class="col-lg-3  text-right pad">
                                        <!--<label class="label-control marg">Less Other</label>-->
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-8 col-xs-8 pad text-right">
                                        <label class="label-control marg">Total Amount</label>

                                    </div>
                                    <div class="col-lg-3  col-md-3 col-sm-4 col-xs-4 pad">
                                        <input type="text" class="form-control form totalamount numeric" value="<? Echo ($addflag != 1) ? $get['totalamount'] : "0"; ?>" name="totalamount" 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  col-md-3 col-sm-8 col-xs-8 pad text-right">
                                        <label class="label-control marg">Round Off</label>
                                    </div>
                                    <div class="col-lg-3  col-md-3 col-sm-4 col-xs-4 pad">
                                        <input type="text" class="form-control form roundoff text-right " value="<? Echo ($addflag != 1) ? $get['roundoff'] : "0"; ?>" name="roundoff">
                                    </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 col-md-3 col-sm-8 col-xs-8 pad text-right">
                                        <label class="label-control marg">Netamt (Rs.)</label>
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 pad">
                                        <input type="text" class="form-control form netamt text-right totbillamt" value="<? Echo ($addflag != 1) ? $get['netamt'] : "0"; ?>" name="netamt" readonly>
                                        <input type="hidden" class="form-control form oldamt text-right" value="<? Echo ($addflag != 1) ? $get['netamt'] : "0"; ?>" name="oldamt" readonly>
                                    </div>
                                </div>

                                <!--                                <div class="col-lg-12 col-xs-12 pad">
                                                                    <div class="col-lg-3 pad text-right">
                                                                        <label class="label-control marg">DC On</label>
                                                                    </div>
                                                                    <div class="col-lg-2 pad text-right">
                                                                        <input type="text" class="form-control form dcperc text-right" value="<? Echo ($addflag != 1) ? $get['dcperc'] : "0"; ?>" name="dcperc" >
                                                                    </div>
                                                                    <div class="col-lg-1 pad text-left">
                                                                        <label class="label-control marg">%</label>
                                                                    </div>
                                                                    <div class="col-lg-2 pad">
                                                                        <input type="text" class="form-control form dcbperc text-right" value="<? Echo ($addflag != 1) ? $get['dcbperc'] : "0"; ?>" name="dcbperc">
                                                                    </div>
                                                                    <div class="col-lg-1 pad">
                                                                        <label class="label-control marg">On</label>
                                                                    </div>
                                                                    <div class="col-lg-3 pad">
                                                                        <input type="text" class="form-control form dcamt text-right" value="<? Echo ($addflag != 1) ? $get['dcamt'] : "0"; ?>" name="dcamt" readonly>
                                                                    </div>
                                                                </div>-->
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-3 col-md-3 col-sm-3  col-xs-3 pad text-right">
                                    </div>
                                    <div class="col-lg-2 col-md-2 col-sm-2 col-xs-1 pad text-right">
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-2 pad text-right" style="padding-right:1%">
                                        <!--<label class="label-control marg" style="color:red;font-size: 22px">Print</label>-->

                                    </div>

                                    <div class="col-lg-1 col-md-2 col-sm-2 col-xs-3 pad">
<!--                                        <input type="checkbox" style="height:30px;width:30px" class="form  prnflag" id="prnflag" name="prnflag" value="1" <?
                                        if ($get['prnflag'] == 1) {
                                            Echo "checked";
                                        }
                                        ?>>-->

                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                        <input type="button" id="finishTab" class="btn btn-primary pull-right form mySearchTr" style="color: #fff;" value="Check & Finish">
                                    </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>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--<div class="row">-->
            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="col-lg-1">
        <!--                        <a id='drivslip' class="btn btn-pad btn-square " style="" href="drivslip_fr.php?vouchno=<?= $qvouch; ?>" target="_blank">
                            <i class="fa fa-car" style="font-size:48px;color:#78909C"></i>
                        </a>-->
                                    <!--<input type="button" id="drivslip" class="btn btn-primary pull-right" href="drivslip_fr.php?vouchno=<?= $qvouch; ?>" target="_blank" style="background-color: #fff;color:#78909C;" value="Driver Slip">-->
                                    <!--<input type="button" id="drivslip" class="btn btn-primary pull-right" onclick="window.location.href = 'drivslip_fr.php?vouchno=<?= $qvouch; ?>'" target="_blank" style="background-color: #fff;color:#78909C;" value="Driver Slip">-->
                    </div>
                    <div class="col-lg-11 col-md-11 col-sm-11 col-xs-11 pad">
                        <?php include("includes/buttons.php"); ?>
                    </div>
                    <!--                    <div class="col-lg-11 col-md-11 col-sm-11 col-xs-11 pad">
                    
                                            <a id='subpdf' class="btn btn-pad btn-square " style="background-color:white;border: 1px solid red" href="<?= $printpdf ?>?vouchno=<?= $qvouch; ?>" target="_blank">
                                                <i class="fa fa-file-pdf-o" style="color:red; font-size: 15px;"></i>
                                            </a>
                                        </div>-->
                </div>
            </div>
            <!--</div>-->
            <!--                <div class="panel panel-default">
                                <div class="panel-body">
                                </div>
                            </div>-->
        </div>
    </div>
</form>
<?php
if ($fitapp == 1) {
    echo $fitapp;
} elseif ($inkzipp < "20") {
    echo $keyapp;
} else {
    echo $zipperink;
}
?>
<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 $zseries ?>" class="form-control series">
                <input type="hidden" value="<?php Echo $get['code']; ?>" 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-2">
                        <select class="form-control sfield">
                            <option value="1">Voucher</option>
                            <option value="2">Date</option>
                            <option value="3">Invoice</option>
                            <option value="4">Party</option>
                            <option value="5">Mobile No.</option>
                            <option value="6">Net Amt.</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control soperator">
                            <option value="">Type of Search</option>
                            <option value="%">Like</option>
                            <option value="=">Exactly</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control sortBy">
                            <option value="">Sort By</option>
                            <option value="1">Voucher</option>
                            <option value="2">Date</option>
                            <option value="3">Invoice</option>
                            <option value="4">Party</option>
                            <option value="5">Mobile No.</option>
                            <option value="6">Net Amt.</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">
                </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-striped table-condensed table-bordered" width="100%">
                        <thead>
                            <tr class="mySearchTr">
                                <th style="width:13%">Voucher</th>
                                <th style="width:13%">Invoice</th>
                                <th style="width:13%">Date</th>
                                <th style="width:26%">Party</th>
                                <th style="width:15%">Mobile</th>
                                <th style="width:15%" class="text-right">Net Amt.</th>
                                <th style="width:5%">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>

<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-2">
                        <select class="form-control ifield">
                            <option>Sort By Field</option>
                            <option value="1">Barcode</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-2">
                        <select class="form-control isortBy">
                            <option>Sort By</option>
                            <option value="2">Barcode</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control iorderAs">
                            <option value="desc">Desc</option>
                            <option value="asc">Asc</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <input type="text" value="" class="form-control isearch">
                    </div>
                    <div class="col-lg-2">
                        <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="20%">Barcode</th>
                                <th width="20%">Name</th>
                                <th width="10%">Unit</th>
                                <th width="10%">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>

<?php include("includes/linksfoot.php"); ?>
</body>
</html>
