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

$maindb = 'billmain';
$trandb = 'billtran';
$accdb = 'actran';
$stkdb = 'transacn';
$printfile = "billentry_pdf.php";
$file = 'billentry.php';
$trandbexist = 1;
$source = "BL";
$keyfld = "vouchno";
$myyear = $_SESSION["tit_" . $dbname];
$salelock = $_SESSION["salelock"];
date_default_timezone_set('Asia/Kolkata');
$time = date('H:i:s');
$keycond = "";
$usertype = $_SESSION["usertype"];
$username = $_SESSION["username_" . $dbname];
//browse($_SESSION["stcode"]);
$formname = 'BILL';
$zroot = $_SESSION["zdbroot"];


$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zyear = right($zdb, 4);
$zStartDate = getzdates($zyear, 'S');
$zEndDate = getzdates($zyear, 'E');
mysqli_select_db($conn, $zdb);

include("includes/vouchno_generate.php");
include("includes/prev&next.php");

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

    $a = 1;

    $vouchdt = $_POST["vouchdt"];
    $voucher = trim($_POST["voucher"]);
    $qvouch = $_POST["vouchno"];

    $mono = $_POST["monno"];
    $billno = $_POST["billno"];
    $lrno = $_POST["lrno"];
    $lrdate = $_POST["lrdate"];
    $area = $_POST["area"];
    $transporter = $_POST["transporter"];
    $godown = trim($_POST["godown"]);
    $rem1 = trim($_POST["remark1"]);
    $rem2 = trim($_POST["remark2"]);
    $nocase = $_POST["nocase"];
    $gstno = $_POST["gstno"];
    $mobile = $_POST["mobile"];
    $staff = trim($_POST["staff"]);
    $paidby = trim($_POST["paidby"]);
    $prodtype = trim($_POST["prodtype"]);
    $paytype = trim($_POST["paytype"]);
    $addtype = trim($_POST["addtype"]);
    $grossamt = trim($_POST["grossamt"]);
    $totdiscamt = trim($_POST["totdiscamt"]);
    $totcgst = trim($_POST["totcgst"]);
    $totsgst = trim($_POST["totsgst"]);
    $taxableamt = trim($_POST["taxableamt"]);
    $postperc = trim($_POST["postperc"]);
    $postamt = trim($_POST["postamt"]);
    $freeflag = trim($_POST["freeflag"]);
    $ccattach = trim($_POST["ccattach"]);
    $freeamount = trim($_POST["freeamount"]);
    $deemexp = trim($_POST["deemexp"]);

    $cgst1 = $_POST['cgst1'];
    $sgst1 = $_POST['sgst1'];
    $igst1 = $_POST['igst1'];
    $tottaxble1 = $_POST['tottaxble1'];
    $tottaxable0 = $_POST['tottaxable0'];

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

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

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

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

    $totgst1 = $_POST['totgst1'];
    $totgst5 = $_POST['totgst5'];
    $totgst12 = $_POST['totgst12'];
    $totgst18 = $_POST['totgst18'];
    $totgst28 = $_POST['totgst28'];
    $pretcs = $_POST['pretcs'];

    $party = $_POST["party"];
    $haltinv = $_POST["haltinv"];

    $vessel = $_POST["vessel"];
    $vesscode = $_POST["vesscode"];
    $rotateno = $_POST["rotateno"];
    $commence = $_POST["commence"];
    $complete = $_POST["complete"];
    $portname = $_POST["port"];
    $locname = $_POST["delvadd"];
    $roundoff = $_POST["roundoff"];
    $pono = $_POST["pono"];
    $podt = $_POST["podt"];
    $ms = $_POST["ms"];

    // $totbillamt1 = $pretcs + $tcsamt;
    // $roundoff = round($totbillamt1, 0) - $totbillamt1;
    // $totbillamt = round($totbillamt1);
    $totbillamt = $_POST["totbillamt"];
    //    $taxableamt = $grossamt - $totdiscamt + $postamt;
    //    $totbillamt1 = $taxableamt + $totgst5 + $totgst12 + $totgst18 + $totgst28 + $tcsamt;


    $oms = $_POST['oms'];
    //    }

    $count = $_POST["items"];
    $mvouch = $qvouch;


    if ($paidby == "R") {
        $purcode = '30';
    } else {
        $purcode = '29';
    }

    $accode = $party;
    $grpcode = '010';



    if ($vouchdt == '0000-00-00') {
        browse("Voucher Date Cannot Be Empty");
        $a = 0;
    }

    if ($vouchdt == '') {
        browse("Voucher Date Cannot Be Empty");
        $a = 0;
    }




    if ($a == 1) {

        $getpty = mysqli_query($conn, "SELECT code,name FROM `port` WHERE `name`='$portname'") or die(mysqli_error($conn));
        if (mysqli_num_rows($getpty) > 0) {
            $fetpty = mysqli_fetch_array($getpty);
            $port = $fetpty['code'];
        } else {
            $genbr = mysqli_query($conn, "SELECT MAX(code) AS maxcode FROM `port` where code != '' LIMIT 0,1 ") or die(mysqli_error($conn));
            if (mysqli_num_rows($genbr) > 0) {
                $gbr = mysqli_fetch_assoc($genbr);
                $port = $gbr["maxcode"] + 1;
            } else {
                $port = '1';
            }
            mysqli_query($conn, "INSERT INTO `port`(`code`, `name`)
                                                    VALUES('$port', '$portname')") or die(mysqli_error($conn));
        }

        $getloc = mysqli_query($conn, "SELECT code,name FROM `location` WHERE `name`='$locname'") or die(mysqli_error($conn));
        if (mysqli_num_rows($getloc) > 0) {
            $fetloc = mysqli_fetch_array($getloc);
            $location = $fetloc['code'];
        } else {
            $genbr2 = mysqli_query($conn, "SELECT MAX(code) AS maxcode FROM `location` where code != '' LIMIT 0,1 ") or die(mysqli_error($conn));
            if (mysqli_num_rows($genbr2) > 0) {
                $gbr2 = mysqli_fetch_assoc($genbr2);
                $location = $gbr2["maxcode"] + 1;
            } else {
                $location = '1';
            }
            mysqli_query($conn, "INSERT INTO `location`(`code`, `name`)
                                                    VALUES('$location', '$locname')") or die(mysqli_error($conn));
        }

        mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `$trandb` WRITE, `accmast` WRITE,manservice WRITE, mansup WRITE ");

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

            $time = strtotime($vouchdt);
            $month = date("m", $time);
            $intmonth = intval($month);
            if ($intmonth < 10) {
                $intmonth = '0' . $intmonth;
            }
            $voucher = $intmonth . $mvouch;
        }
        ////////////////////////////////// TRAN PART //////////////////////////////
        mysqli_query($conn, "DELETE FROM `$trandb` WHERE vouchno='$mvouch' ") or die(mysqli_error($conn));

        $cnt = 0;
        $cntamt = 0;

        for ($i = 0; $i <= $count; $i++) {
            $cnt++;
            $msrno = $_POST["srno_$i"];
            $mdescrip1 = $_POST["descrip1_$i"];
            $mdescrip2 = $_POST["descrip2_$i"];
            $hsncode = $_POST["hsncode_$i"];
            $qty = $_POST["qty_$i"];
            $rate = $_POST["rate_$i"];
            $amt = $_POST["amount_$i"];
            $discperc = $_POST["discperc_$i"];
            $discamt = $_POST["discamt_$i"];
            $gstperc = $_POST["gstrate_$i"];
            $gstamt = $_POST["gstamt_$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"];
            $mqty = $qty * -1;


            if (!empty($hsncode)) {

                mysqli_query($conn, "INSERT INTO `$trandb`(`srno`,vouchno, vouchdt, hsncode, `hsnportal`, `descrip1`, `descrip2`,
                                                           `qty`, rate, amount, `discperc`, `discamt`, `cgstrate` , `cgstamt`, `sgstrate`,
                                                           `sgstamt`, `igstrate`, `igstamt`,`total`, `subtot`, `gstrate`,`gstamt`)
                                                    VALUES('$cnt', '$mvouch', '$vouchdt', '$hsncode', '$hsncode', '$mdescrip1', '$mdescrip2',
                                                           '$qty', '$rate', '$amt', '$discperc', '$discamt', '$cgstrate', '$cgstamt', '$sgstrate',
                                                           '$sgstamt', '$igstrate', '$igstamt', '$total', '$subtot', '$gstperc', '$gstamt')") or die(mysqli_error($conn));
                if ($hsncode != "") {

                    if ($ms == "M") {
                        $getpty = mysqli_query($conn, "SELECT hsncode FROM `matsup` WHERE `hsncode`='$hsncode' AND descrip1='$mdescrip1' AND descrip2='$mdescrip2'") or die(mysqli_error($conn));
                        if (mysqli_num_rows($getpty) > 0) {
                            
                        } else {
                            $gen2 = mysqli_query($conn, "SELECT MAX(code+0) AS maxcode FROM `matsup` where code != '' $keycond LIMIT 0,1 ") or die(mysqli_error($conn));
                            if (mysqli_num_rows($gen2) > 0) {
                                $vvouch2 = mysqli_fetch_assoc($gen2);
                                $qvouch2 = $vvouch2["maxcode"] + 1;
                            } else {
                                $qvouch2 = '1';
                            }
                            mysqli_query($conn, "INSERT INTO `matsup`(`code`, `hsncode`, `descrip1`, `descrip2`)
                                                            VALUES('$qvouch2',  '$hsncode', '$mdescrip1', '$mdescrip2')") or die(mysqli_error($conn));
                        }
                    } else if ($ms == "S") {
                        $getpty = mysqli_query($conn, "SELECT hsncode FROM `manservice` WHERE `hsncode`='$hsncode' AND descrip1='$mdescrip1' AND descrip2='$mdescrip2' ") or die(mysqli_error($conn));
                        if (mysqli_num_rows($getpty) > 0) {
                            
                        } else {
                            $gen2 = mysqli_query($conn, "SELECT MAX(code+0) AS maxcode FROM `manservice` where code != '' $keycond LIMIT 0,1 ") or die(mysqli_error($conn));
                            if (mysqli_num_rows($gen2) > 0) {
                                $vvouch2 = mysqli_fetch_assoc($gen2);
                                $qvouch2 = $vvouch2["maxcode"] + 1;
                            } else {
                                $qvouch2 = '1';
                            }
                            mysqli_query($conn, "INSERT INTO `manservice`(`code`, `hsncode`, `descrip1`, `descrip2`)
                                                            VALUES('$qvouch2',  '$hsncode', '$mdescrip1', '$mdescrip2')") or die(mysqli_error($conn));
                        }
                    }
                }
            }
        }

        if ($addflag == 1) {

            mysqli_query($conn, "INSERT INTO `$maindb`(`username`, vouchno, `vouchdt`, `voucher`, `billno`, `monno`, `party`, `mobile`, `oms`,
                                                       `rem1`, `rem2`,  `cashvouch`, roundoff, `taxableamt`,`cgst5`,`sgst5`,`igst5`,`cgst12`,`sgst12`,`igst12`,`cgst18`,`sgst18`,
                                                       `igst18`,`cgst28`,`sgst28`,`igst28`,`totgst5`,`totgst12`,`totgst18`,`totgst28`,`billamt`,
                                                       `haltinv`, `vessel`, `vesscode`, `rotateno`, `commence`, `complete`, `port`, `delvadd`, `pono`, `podt`, `ms`)
                                                VALUES('$username', '$mvouch', '$vouchdt', '$voucher', '$billno', '$mono', '$party', '$mobile', '$oms',
                                                       '$rem1', '$rem2', '$mcashvouch', '$roundoff', '$taxableamt','$cgst5','$sgst5','$igst5', '$cgst12','$sgst12','$igst12', '$cgst18', '$sgst18',
                                                       '$igst18','$cgst28','$sgst28','$igst28','$totgst5','$totgst12','$totgst18','$totgst28', '$totbillamt',
                                                       '$haltinv', '$vessel', '$vesscode', '$rotateno', '$commence', '$complete', '$port', '$location', '$pono', '$podt', '$ms')") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "UPDATE `$maindb` SET  `vouchdt`='$vouchdt', `voucher`='$voucher', `billno`='$billno', `monno`='$mono', `party`='$party',
                                                       `mobile`='$mobile', `cashvouch`='$mcashvouch', `rem1`='$rem1', `rem2`='$rem2', `oms`='$oms',
                                                       `taxableamt`='$taxableamt',`cgst5`='$cgst5',`sgst5`='$sgst5',
                                                       `igst5`='$igst5',`cgst12`='$cgst12',`sgst12`='$sgst12',`igst12`='$igst12',roundoff='$roundoff',
                                                       `cgst18`='$cgst18', `sgst18`='$sgst18',`igst18`='$igst18',
                                                       `cgst28`='$cgst28', `sgst28`='$sgst28',`igst28`='$igst28',
                                                       `totgst5`='$totgst5',`totgst12`='$totgst12', `totgst18`='$totgst18',`totgst28`='$totgst28',
                                                       `billamt`='$totbillamt', `username`='$username',
                                                       `haltinv`='$haltinv', `vessel`='$vessel', `rotateno`='$rotateno', `commence`='$commence',
                                                       `complete`='$complete', `port`='$port', `delvadd`='$location', `ms`='$ms',
                                                       `pono`='$pono', `podt`='$podt'  WHERE `vouchno` = '$mvouch' ") or die(mysqli_error($conn));
        }


        mysqli_query($conn, "UNLOCK TABLES");
        if ($addflag == 1) {
            insmess();
            header("refresh: 1; $file?mode=edit&$keyfld=$mvouch&form=$form");
        } else {
            updmess();
        }
    }
}

if ($addflag != 1) {

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

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

    $getporty = mysqli_query($conn, "SELECT `code`,`name` FROM `port` WHERE `code`= '$get[port]'") or die(mysqli_error($conn));
    $lport = mysqli_fetch_array($getporty);

    $getloc = mysqli_query($conn, "SELECT `code`,`name` FROM `location` WHERE `code`= '$get[delvadd]'") or die(mysqli_error($conn));
    $fetloc = mysqli_fetch_array($getloc);

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

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

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

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

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

include("includes/linkshead.php");
?>
<script src="MyScript/billentry.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>
<script src="MyScript/search_item.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>
<script src="MyScript/billentry_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">
                            <input type="date" value="<?= $salelock ?>" style="width: 1px;border: none" class="salelock">
                            <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" style="color: #26A69A; font-weight: 600;">Voucher</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" name="vouchno" class="form-control vouchno" id="vouchno" value="<?php echo ($addflag != 1) ? $get['vouchno'] : $qvouch ?>" required readonly >
                                <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'] : '' ?>">
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg" style="color: #26A69A; font-weight: 600;">Date</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-1 col-xs-8 pad" style="width:10%">
                                <input type="date" class="form-control form vouchdt focusfield" name="vouchdt" value="<?php echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>" autofocus required>
                            </div>

                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg" style="color: #26A69A; font-weight: 600;">Bill No.</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" name="billno" class="form-control form billno" value="<?php echo ($addflag != 1) ? $get['billno'] : ""; ?>">
                            </div>



                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg" style="color: red; font-weight: 600;">Halt E-Invoice</label>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-1 col-xs-1 pad">
                                <select name="haltinv" class="form-control form haltinv select2" style="width: 50%" required>
                                    <option <?php
                                    if ($get['haltinv'] == 'N') {
                                        echo "selected=selected";
                                    }
                                    ?> value='N'>NO</option>
                                    <option <?php
                                    if ($get['haltinv'] == 'Y') {
                                        echo "selected=selected";
                                    }
                                    ?> value='Y'>YES</option>
                                </select>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg" style="color: green; font-weight: 600;">M/S</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-1 col-xs-1 pad">
                                <select name="ms" class="form-control form ms select2" style="width: 50%" required>

                                    <option <?php
                                    if ($get['ms'] == 'S') {
                                        echo "selected=selected";
                                    }
                                    ?> value='S'>Service</option>
                                    <option <?php
                                    if ($get['ms'] == 'M') {
                                        echo "selected=selected";
                                    }
                                    ?> value='M'>Material</option>
                                </select>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">Party</label>
                            </div>
                            <div class="col-lg-3 pad" style="width:26.50%">
                                <select class="form-control form cmbparty party select2" id="party" name="party" style="width: 100%" required>
                                    <option value="<?php echo ($addflag != 1) ? $lparty["accode"] : ""; ?>"><?php echo ($addflag != 1) ? $lparty["name"] : ""; ?> (<?php echo ($addflag != 1) ? $lparty["city"] : ""; ?>)</option>
                                    <?php
                                    $gparty = mysqli_query($conn, "SELECT `accode`,`name`,`city` 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] ($party[city])</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">Out Of State</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="checkbox" class="form-control form oms" <?php
                                if ($get['oms'] == "1") {
                                    echo "checked";
                                }
                                ?> value="1" name="oms" onclick="return false;">
                            </div>

                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">Mobile</label>
                            </div>
                            <div class="col-lg-1 pad">
                                <input type="text" name="mobile" class="form-control form mobile" value="<?php echo ($addflag != 1) ? $get['mobile'] : ''; ?>" tabindex="">
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">Vessel</label>
                            </div>
                            <div class="col-lg-3 pad" style="width:26.50%">
                                <select class="form-control form vessel select2" name="vessel" style="width: 100%">
                                    <option value="<?php echo ($addflag != 1) ? $get["vessel"] : ""; ?>"><?php echo ($addflag != 1) ? $get["vessel"] : ""; ?></option>
                                    <?php
                                    $gparty = mysqli_query($conn, "SELECT `name` FROM `vessel` order by name") or die(mysqli_error($conn));
                                    while ($party = mysqli_fetch_array($gparty)) {
                                        echo "<option value='$party[name]'>$party[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">Vessel Code</label>
                            </div>
                            <div class="col-lg-1 pad">
                                <input type="text" name="vesscode" class="form-control form vesscode" value="<?php echo ($addflag != 1) ? $get['vesscode'] : ''; ?>" tabindex="">
                            </div>
                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">Rotation No.</label>
                            </div>
                            <div class="col-lg-1 pad">
                                <input type="text" name="rotateno" class="form-control form rotateno" value="<?php echo ($addflag != 1) ? $get['rotateno'] : ''; ?>" tabindex="">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">Commenced On</label>
                            </div>
                            <div class="col-lg-1 pad">
                                <input type="date" name="commence" class="form-control form commence" value="<?php echo ($addflag != 1) ? $get['commence'] : ''; ?>" tabindex="">
                            </div>

                            <div class="col-lg-1 pad text-right" style="width:9.9%">
                                <label class="label-control marg">Completed On</label>
                            </div>
                            <div class="col-lg-1 pad">
                                <input type="date" name="complete" class="form-control form complete" value="<?php echo ($addflag != 1) ? $get['complete'] : ''; ?>" tabindex="">
                            </div>
                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">P.O. No.</label>
                            </div>
                            <div class="col-lg-2     pad">
                                <input type="text" name="pono" class="form-control form pono" value="<?php echo ($addflag != 1) ? $get['pono'] : ''; ?>" tabindex="">
                            </div>

                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">P.O. Date</label>
                            </div>
                            <div class="col-lg-1 pad">
                                <input type="date" name="podt" class="form-control form podt" value="<?php echo ($addflag != 1) ? $get['podt'] : ''; ?>" tabindex="">
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">Location of Vessel</label>
                            </div>
                            <div class="col-lg-3 pad" style="width:26.50%">
                                <input list='port' name='port' value="<?php echo ($addflag != 1 ) ? $lport['name'] : '' ?>" class='port form-control form port' autocomplete="off">
                                <datalist id='port' char="#">
                                    <option value=''></option>
                                    <?php
                                    $getname = mysqli_query($conn, "SELECT `name` FROM `port` order by name") or die(mysqli_error($conn));
                                    while ($fetname = mysqli_fetch_array($getname)) {
                                        $name = $fetname['name'];
                                        echo "<option value='$name'>";
                                    }
                                    ?>
                                </datalist>
                            </div>
                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">Delivery Address</label>
                            </div>
                            <div class="col-lg-3 pad" style="width:26.50%">
                                <input list='delvadd' name='delvadd' value="<?php echo ($addflag != 1 ) ? $fetloc['name'] : '' ?>" class='delvadd form-control form ' autocomplete="off">
                                <datalist id='delvadd' char="#">
                                    <option value=''></option>
                                    <?php
                                    $getdelvadd = mysqli_query($conn, "SELECT `name` FROM `location` order by name") or die(mysqli_error($conn));
                                    while ($fetdelvadd = mysqli_fetch_array($getdelvadd)) {
                                        $delvaddname = $fetdelvadd['name'];
                                        echo "<option value='$delvaddname'>";
                                    }
                                    ?>
                                </datalist>
                            </div>


                        </div>

                        <div class="onldata">
                            <div class="table-responsive">
                                <table class="table-striped table-condensed table-bordered" style="width: 120%">
                                    <thead class="mySearchTr">
                                        <tr>
                                            <th style="width: 1%"></th>
                                            <th style="width: 1%">Sr.</th>
                                            <th style='width: 5%'>Hsncode</th>
                                            <th style="width: 8%;">Description 1</th>
                                            <th style="width: 8%;">Description 2</th>
                                            <th style='width: 3%' class="text-right">Qty.</th>
                                            <th style='width: 3%' class="text-right">Rate</th>
                                            <th style='width: 5%' class="text-right">Taxable value</th>
                                            <th style='width: 3%' class="text-right">GST%</th>
                                            <th style='width: 3%' class="text-right">CGST%</th>
                                            <th style='width: 4%' class="text-right">CGST Amt.</th>
                                            <th style='width: 3%' class="text-right">SGST%</th>
                                            <th style='width: 4%' class="text-right">SGST Amt.</th>
                                            <th style='width: 3%' class="text-right">IGST%</th>
                                            <th style='width: 4%' class="text-right">IGST Amt.</th>
                                            <th style='width: 4%' class="text-right">Total</th>
                                        </tr>
                                    </thead>
                                    <tbody class="tbody">
                                        <?php
                                        if ($addflag != 1) {
                                            $qry = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE vouchno='$getvouch' ORDER BY srno") or die(mysqli_error($conn));
                                            $ctr = 0;
                                            while ($row = mysqli_fetch_array($qry)) {

                                                echo "<tr>";
                                                echo "<input type='hidden' name='itemcode_$ctr' class='itemcode form-control form' value='$geti[code]'>";
                                                echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                                echo "<td><input type='text' name='srno_$ctr' class='srno form-control  form'  value='$row[srno]'></td>";

                                                echo "<td><input type='text' name='hsncode_$ctr' required='true' class='hsncode form-control  form' value='$row[hsncode]'></td>";

                                                echo "<td><input list='browsers' name='descrip1_$ctr' value='$row[descrip1]' maxlength='25' class='descrip1  form-control form '>";
                                                echo "<datalist id='browsers' class='datadescrip1'> ";
                                                echo "<option value=''></option>";

                                                echo "</datalist>";
                                                echo "</td>";

                                                echo "<td><input list='browsers2' name='descrip2_$ctr' value='$row[descrip2]' maxlength='25' class='descrip2  form-control form '>";
                                                echo "<datalist id='browsers2' class='datadescrip2'> ";
                                                echo "<option value=''></option>";

                                                echo "</datalist>";
                                                echo "</td>";

                                                echo "<td><input type='number' name='qty_$ctr' class='qty form-control  text-right form' step='any' value='$row[qty]' ></td>";
                                                echo "<td><input type='number' step='any' name='rate_$ctr' class='rate form-control text-right  form'  value='$row[rate]' >";
                                                echo "<input type='hidden' step='any' name='amount_$ctr' class='amount form-control text-right  form' value='$row[amount]'  tabindex='-1' readonly>
                                                      <input type='hidden' name='discperc_$ctr' class='discperc form-control text-right  form'    value='$row[discperc]'>
                                                      <input type='hidden' name='discamt_$ctr' class='discamt form-control text-right  form'      value='$row[discamt]' ></td>";
                                                echo "<td><input type='text' name='subtot_$ctr' class='subtot form-control text-right  form'      value='$row[subtot]'   tabindex='-1' readonly></td>";
                                                echo "<td><input type='text' name='gstrate_$ctr' class='gstrate form-control text-right  form'    value='$row[gstrate]'>
                                                          <input type='hidden' name='gstamt_$ctr' class='gstamt form-control text-right  form'    value='$row[gstamt]'></td>";
                                                echo "<td><input type='text' name='cgstrate_$ctr' class='cgstrate form-control text-right  form'  value='$row[cgstrate]' tabindex='-1' readonly></td>";
                                                echo "<td><input type='text' name='cgstamt_$ctr' class='cgstamt form-control text-right  form'    value='$row[cgstamt]'  tabindex='-1' readonly></td>";
                                                echo "<td><input type='text' name='sgstrate_$ctr' class='sgstrate form-control text-right  form'  value='$row[sgstrate]' tabindex='-1' readonly></td>";
                                                echo "<td><input type='text' name='sgstamt_$ctr' class='sgstamt form-control text-right  form'    value='$row[sgstamt]'  tabindex='-1' readonly></td>";
                                                echo "<td><input type='text' name='igstrate_$ctr' class='igstrate form-control text-right  form'  value='$row[igstrate]' tabindex='-1' readonly></td>";
                                                echo "<td><input type='text' name='igstamt_$ctr' class='igstamt form-control text-right  form'    value='$row[igstamt]'  tabindex='-1' readonly></td>";
                                                echo "<td><input type='text' name='total_$ctr' class='total form-control text-right  form'        value='$row[total]'    tabindex='-1' readonly></td>";
                                                echo "</tr>";
                                                $ctr++;
                                            }
                                        } else {
                                            ?>
                                            <tr>
                                                <td><i class='fa fa-close remove'></i></td>
                                                <td><input type='text' name='srno_0' class='srno form-control form' value='1'></td>
                                                <td><input type='text' name='hsncode_0' required='true' maxlength='10' class='hsncode form-control  form' value=''></td>
                                                <td><input list='browsers' name='descrip1_0' value='' maxlength='25' class='descrip1  form-control form '>
                                                    <datalist id='browsers' class='datadescrip1'>
                                                        <option value=''></option>

                                                    </datalist>
                                                </td>
                                                <td><input list='browsers2' name='descrip2_0' value='' maxlength='25' class='descrip2  form-control form '>
                                                    <datalist id='browsers2' class='datadescrip2'>
                                                        <option value=''></option>

                                                    </datalist>
                                                </td>
                                                <td><input type='number' name='qty_0' class='qty form-control  text-right form' step="any" value='0.00'></td>
                                                <td><input type="number" step="any" name='rate_0' class='rate form-control text-right form zero' value='0'>
                                                    <input type="hidden" step="any" name='amount_0' class='amount text-right form-control form zero' value='0' tabindex='-1' readonly>
                                                    <input type='hidden' name='discperc_0' class='discperc text-right form-control form ' value='0.00' >
                                                    <input type='hidden' name='discamt_0' class='discamt text-right form-control form  ' value='0.00'></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='gstrate_0' class='gstrate text-right form-control form  '   value='0.00'>
                                                    <input type='hidden' name='gstamt_0' class='gstamt text-right form-control form  '   value='0.00' readonly></td>
                                                <td><input type='text' name='cgstrate_0' class='cgstrate text-right form-control form  ' value='0.00' readonly tabindex='-1'></td>
                                                <td><input type='text' name='cgstamt_0' class='cgstamt text-right form-control form  '   value='0.00' readonly tabindex='-1'></td>
                                                <td><input type='text' name='sgstrate_0' class='sgstrate text-right form-control form  ' value='0.00' readonly tabindex='-1'></td>
                                                <td><input type='text' name='sgstamt_0' class='sgstamt text-right form-control form  '   value='0.00' readonly tabindex='-1'></td>
                                                <td><input type='text' name='igstrate_0' class='igstrate text-right form-control form  ' value='0.00' readonly tabindex='-1'></td>
                                                <td><input type='text' name='igstamt_0' class='igstamt text-right form-control form  '   value='0.00' readonly tabindex='-1'></td>
                                                <td><input type='text' name='total_0' class='total text-right form-control form  '       value='0.00' readonly tabindex='-1'></td>
                                            </tr>
                                            <?php
                                        }
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                            <div class="col-lg-12 pad">
                                <button type="button" class="btn btn-primary btn-square form" id="addnew">
                                    <i class="fa fa-plus" data-toggle='tooltip' title='Add Row'></i>
                                </button>
                                <input type="hidden" id="items" name="items" value="<?php echo ($addflag != 1) ? $ctr : 1; ?>">
                            </div>
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-6 col-xs-12 pad">


                                    <div class="col-lg-12 col-xs-12 pad">
                                        <div 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 class="col-lg-12 col-xs-12 pad">
                                        <div class="col-lg-9 pad">

                                    <?php
//                                        browse($get['canc_flag']);
                                    if ($get['canc_flag'] != '') {
                                        ?>
                                                                            <img src="images/cancel.jpg" alt="Cancelled Bill" style="width:100%;height:100%">
                                    <?php } ?>

                                        </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">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 tabindex="-1">
                                        </div>
                                    </div>
                                    <div class="col-lg-12 col-xs-12 ">
                                        <div class="row">
                                            <div class="col-lg-5 "></div>
                                            <div class="col-lg-7 ">
                                                <div class="table-responsive">
                                                    <table class="table table-striped table-condensed table-bordered" width="100%">
                                                        <thead style="color: white">
                                                            <tr class="mySearchTr">
                                                                <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]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right sgst5'     name='sgst5'       value='$get[sgst5]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right igst5'     name='igst5'       value='$get[igst5]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right totgst5'     name='totgst5'       value='$get[totgst5]' tabindex='-1' 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]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right sgst12'     name='sgst12'       value='$get[sgst12]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right igst12'     name='igst12'       value='$get[igst12]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right totgst12'     name='totgst12'       value='$get[totgst12]' tabindex='-1' 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]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right sgst18'     name='sgst18'       value='$get[sgst18]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right igst18'     name='igst18'       value='$get[igst18]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right totgst18'     name='totgst18'       value='$get[totgst18]' tabindex='-1' 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]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right sgst28'     name='sgst28'       value='$get[sgst28]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right igst28'     name='igst28'       value='$get[igst28]' tabindex='-1' readonly></td>";
                                                                echo "<td><input type='number' class='form-control form text-right totgst28'     name='totgst28'       value='$get[totgst28]' tabindex='-1' 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' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right sgst5' name='sgst5' value='0' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right igst5' name='igst5' value='0' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right totgst5' name='totgst5' value='0' tabindex='-1' 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' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right sgst12' name='sgst12' value='0' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right igst12' name='igst12' value='0' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right totgst12' name='totgst12' value='0' tabindex='-1' 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' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right sgst18' name='sgst18' value='0' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right igst18' name='igst18' value='0' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right totgst18' name='totgst18' value='0' tabindex='-1' 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' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right sgst28' name='sgst28' value='0' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right igst28' name='igst28' value='0' tabindex='-1' readonly>
                                                                    </td>
                                                                    <td><input type='number' class='form-control form text-right totgst28' name='totgst28' value='0' tabindex='-1' readonly></td>
                                                                </tr>
                                                                <?
                                                            }
                                                            ?>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </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 hflag" style='color:red'>Free Adjusted Amount</label>
                                        </div>
                                        <div class="col-lg-3 pad">
                                            <input type="number" step="any" name="freeamount" class="form-control form text-right hflag freeamount" value="<?php echo ($addflag != 1) ? $get['freeamount'] : "0"; ?>" style='color:red' readonly 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" style=''>Pre TCS</label>
                                        </div>
                                        <div class="col-lg-3 pad">
                                            <input type="number" step="any" name="pretcs" class="form-control form text-right pretcs" value="<?php echo ($addflag != 1) ? $get['pretcs'] : "0"; ?>" style='color:red' readonly tabindex="-1">
                                        </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-2 pad text-right">
                                            <label class="label-control marg" style=''>TCS</label>
                                        </div>
                                        <div class="col-lg-1 pad">
                                            <input type="number" step="any" name="tcsperc" class="form-control form text-right tcsperc" value="<?php echo ($addflag != 1) ? $get['tcsperc'] : "0"; ?>" style='color:red' readonly tabindex="-1">
                                        </div>
                                        <div class="col-lg-1 pad">
                                            <label class="label-control marg" style=''>%</label>
                                        </div>
                                        <div class="col-lg-3 pad">
                                            <input type="number" step="any" name="tcsamt" class="form-control form text-right tcsamt" value="<?php echo ($addflag != 1) ? $get['tcsamt'] : "0"; ?>" style='color:red' readonly 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">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"; ?>">
                                        </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="number" step="any" name="totbillamt" required="true" class="form-control form text-right totbillamt" value="<?php echo ($addflag != 1) ? $get['billamt'] : "0"; ?>" readonly tabindex="-1">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="row">


                            <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 text-center pad">

                                <?php include("includes/buttons.php"); ?>
                            </div>
                            <!--<div class="col-lg-2 col-md-1 col-sm-1 col-xs-1 text-left pad">-->
                            <input type="hidden" class="tno" value="<?= $tno ?>" />

                            <?php // if ($get['ewaybillno'] == "" && $get['billamt'] > 50000) {   ?>
                            <!--                                <div class="col-lg-2  col-md-2 col-sm-3 col-xs-3 text-center pad">
                                                                <a id='ewaygen' class="btn btn-pad btn-square " style="background-color:#5BC0DE;" href="ewaybillgenerate.php?invno=<?= $get['invno']; ?>&series=LO" target="_blank">
                                                                    <i class="fa fa-truck" style="color:#ffffff"> E-way Generate</i>
                                                                </a>
                                                            </div>-->
                            <?php // }   ?>


                        </div>

                    </div>
                </div>
            </div>
        </div>
    </form>

    <div class="modal fade" id="cancmodel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="col-lg-11">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">Cancel Bill</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-lg-12 upload">
                                <form id="upload_form" method="post">

                                    <div class="row pad">
                                        <input type="hidden" name="cancvouch" id="cancvouch" value='<?php echo ($addflag != 1) ? $get['vouchno'] : "$qvouch"; ?>'>
                                        <input type="hidden" name="cashvouch2" id="cashvouch2" value='<?php echo ($addflag != 1) ? $get['cashvouch'] : ""; ?>'>
                                        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-5 text-right">
                                            <label class="label-control marg">Cancel Date</label>
                                        </div>
                                        <div class="col-lg-4 col-md-4 col-sm-6 col-xs-7">

                                            <input type="date" name="cancdate" value="<?php echo ($addflag != 1) ? $get['cancdate'] : ""; ?>" class="form-control cancdate">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-lg-6 col-md-6 col-sm-7 col-xs-8 text-right">
                                            <input type="submit" value="Cancel" name="cancbtn" class="btn btn-square" style="background-color: #C0CA33; color: white">
                                        </div>
                                    </div>

                                </form>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="imageUpload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="col-lg-11">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">Article Image Upload</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-lg-12 upload">
                                <form id="upload_form" enctype="multipart/form-data" method="post">

                                    <div class="col-lg-3 pad">
                                        <span class="btn btn-default btn-file btn-square btn-warning">
                                            Choose File <input type="file" name="file1" id="file1">
                                        </span>
                                        <input type="hidden" name="code" id="vouchno" value='<?php echo ($addflag != 1) ? $get['vouchno'] : "$qvouch"; ?>'>
                                        <input type="button" value="Upload File" id="uploadbtn" class="btn btn-square" style="background-color: #C0CA33; color: white">
                                    </div>
                                    <div class="col-lg-6">
                                        <div class="progress">
                                            <progress id="progressBar" class="progress-bar" role="progressbar" value="0" max="100" style="width:100%;color: red;"></progress>
                                        </div>
                                        <h3 id="status"></h3>
                                        <p id="loaded_n_total"></p>
                                    </div>
                                </form>
                            </div>
                            <div class="col-lg-10 upload">
                                <img id="preview" src="" alt="your image" />
                            </div>
                        </div>
                    </div>
                </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-3">
                            <select class="form-control ifield">
                                <option value="1">HSN Code</option>
                            </select>
                        </div>
                        <div class="col-lg-2">
                            <select class="form-control ioperator">
                                <option value=""></option>
                                <option value="%">Like</option>
                                <option value="=">Exactly</option>
                            </select>
                        </div>
                        <div class="col-lg-4">
                            <input type="text" value="" class="form-control isearch">
                        </div>
                        <div class="col-lg-3">
                            <input type="button" class="btn btn-primary iload" value="Search">
                        </div>
                    </div>

                    <div class="col-lg-12 iloader text-center">
                        <img src="images/search.gif" alt="loading">
                    </div>
                    <div class="col-lg-12 inoRecord text-center">
                        <h3>NO RECORDS FOUND</h3>
                    </div>
                    <div class="table-responsive" style="max-height: 400px;overflow: auto;">
                        <table id="" class="table table-striped table-condensed table-bordered" width="100%">
                            <thead>
                                <tr class="mySearchTr">
                                    <th width="8%">HSN Code</th>
                                    <th width="20%">Description 1</th>
                                    <th width="20%">Description 2</th>

                                </tr>
                            </thead>
                            <tbody class="iTbody">
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 text-right search-action-bar">
                            <input type="button" class="btn btn-primary iprevious" value="Previous">
                            <input type="button" class="btn btn-primary inext" value="Next">
                        </div>
                    </div>
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
    <div class="modal fade searchModal bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg" style="margin-top: 15%">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span>&times;</span></button>
                    <h4 class="modal-title" id="myLargeModalLabel">Search <? echo $formname; ?></h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" value="<?php echo $fseries ?>" class="form-control series">
                    <input type="hidden" value="<?php echo $get['vouchno']; ?>" class="form-control vouchno">
                    <input type="hidden" value="<?php echo $file ?>" class="form-control file">
                    <input type="hidden" value="<?php echo $para ?>" class="form-control para">
                    <div class="row">
                        <div class="col-lg-2">
                            <select class="form-control sfield">
                                <option value="1"> Party Name</option>
                                <option value="4">Voucher</option>
                                <option value="2">Bill No.</option>
                                <option value="3">Date</option>
                                <option value="5">Mobile</option>
                                <option value="6">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="4"> Party Name</option>
                                <option value="1">Voucher</option>
                                <option value="2">Bill No.</option>
                                <option value="3">Date</option>
                                <option value="5">Mobile</option>
                                <option value="6">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 class="mySearchTr">
                                    <th width="5%">Voucher</th>
                                    <th width="10%">Bill No.</th>
                                    <th width="15%">Date</th>
                                    <th width="20%">Party Name</th>
                                    <th width="10%">Mobile</th>
                                    <th width="15%" style="text-align: right;">Amount</th>
                                    <th 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>
    <?php include("includes/linksfoot.php"); ?>
</body>

</html>