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

$maindb = 'profomain';
$trandb = 'profotran';
$accdb = 'actran';
$stkdb = 'rawsacn';
$printfile = "proforma_print.php";
$file = 'proforma.php';
$trandbexist = 1;
$source = "PRO";
$keyfld = "vouchno";
$myyear = $_SESSION["tit_" . $dbname];

date_default_timezone_set('Asia/Kolkata');
$time = date('H:i:s');

$usertype = $_SESSION["usertype"];


$formname = 'PROFORMA INVOICE';

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];

mysqli_select_db($conn, $zdb);

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

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

    $a = 1;

    $vouchdt = trim($_POST["vouchdt"]);
    $voucher = trim($_POST["voucher"]);
    $mono = $_POST["monno"];
    $add = $_POST["add"];
    $subject = $_POST["subject"];
    $mfg = $_POST["mfg"];
    $lrno = $_POST["lrno"];
    $lrdate = $_POST["lrdate"];
    $area = $_POST["area"];
    $transporter = $_POST["transporter"];
    $godown = trim($_POST["godown"]);
    $rem1 = trim($_POST["remark1"]);
    $rem2 = trim($_POST["remark2"]);
    $gstno = $_POST["gstno"];
    $mobile = $_POST["mobile"];
    $staff = trim($_POST["staff"]);
    $paidby = trim($_POST["paidby"]);
    $grossamt = trim($_POST["grossamt"]);
    $totdiscamt = trim($_POST["totdiscamt"]);
    $totcgst = trim($_POST["totcgst"]);
    $totsgst = trim($_POST["totsgst"]);
    $taxableamt = trim($_POST["taxableamt"]);
    $totbillamt = trim($_POST["totbillamt"]);

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

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

    $oms = $_POST['oms'];




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


    switch ($paidby) {
        case "R";
            $purcode = '000030';
            $party = $_POST["party"];

            $mpart = mysqli_query($conn, "SELECT accode, grpcode, name  FROM `accmast` WHERE accode='$party'") or die(mysqli_error($conn));
            $ipart = mysqli_fetch_array($mpart);
            $accode = $ipart[accode];
            $grpcode = $ipart[grpcode];
            $partyname = $ipart[name];
            break;

        case "C";
            $purcode = '000029';
            $party = $_POST["party"];
            $mpart = mysqli_query($conn, "SELECT accode, grpcode, name FROM `accmast` WHERE accode='$party'") or die(mysqli_error($conn));
            $ipart = mysqli_fetch_array($mpart);
            $accode = $ipart[accode];
            $grpcode = $ipart[grpcode];
            $partyname = $ipart[name];
            break;
    }


    if ($totbillamt <= 0) {
        browse("Bill Amount Cannot Be Zero");
        $a = 0;
    }

    if ($a == 1) {

        mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `$trandb` WRITE, `product` WRITE, `$stkdb` WRITE, `$accdb` WRITE, `cashrecp` WRITE, `accmast` 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;
        }


        //**************************************************        auto cash Entry Start  ***************************************
        $mcashvouch = $_POST["cashvouch"];

        if ($paidby == 'C') {
            if ($mcashvouch == '0' || $mcashvouch == '') {
                $gen1 = mysqli_query($conn, "SELECT MAX(vouchno+0) AS maxcode FROM `cashrecp` where vouchno!=''  LIMIT 0,1 ") or die(mysqli_error($conn));
                if (mysqli_num_rows($gen1) > 0) {
                    $vvouch = mysqli_fetch_assoc($gen1);
                    $tcashvouch = $vvouch["maxcode"] + 1;
                } else {
                    $tcashvouch = '1';
                }
                $mcashvouch = $tcashvouch;
            }

            $genrecp = mysqli_query($conn, "SELECT * FROM `cashrecp` where `vouchno` = '$mcashvouch' ") or die(mysqli_error($conn));
            if (mysqli_num_rows($genrecp) > 0) {
                $fetrecp = mysqli_fetch_array($genrecp);
                $mrecpno = $fetrecp[recpno];
                $mcashvouch = $fetrecp[vouchno];
            } else {

                $gen2 = mysqli_query($conn, "SELECT MAX(recpno+0) AS maxcode FROM `cashrecp` where bankname = '3' LIMIT 0,1 ") or die(mysqli_error($conn));
                if (mysqli_num_rows($gen2) > 0) {
                    $gvouch = mysqli_fetch_assoc($gen2);
                    $mrecpno1 = $gvouch["maxcode"] + 1;
                } else {
                    $mrecpno1 = '1';
                }
                $mrecpno = $mrecpno1;
            }

            mysqli_query($conn, "DELETE FROM `cashrecp` WHERE `$keyfld`='$mcashvouch' ") or die(mysqli_error($conn));

            mysqli_query($conn, "INSERT INTO `cashrecp`( vouchno ,`vouchdt`, `bankname`, `bankinit`, `recpno`, `party`,`amount`,`remark1`,`remark2`,`trnflag`)
                                       Values ('$mcashvouch', '$vouchdt', '3', 'COH', '$mrecpno','$accode','$totbillamt','Cash Recd. For','Sale No.$mvouch','S')") or die(mysqli_error($conn));


            // cash part  

            $minus_amt = ($totbillamt * -1);


            mysqli_query($conn, "DELETE FROM `$accdb` WHERE `$keyfld`='$mcashvouch' and `source` = 'CR' $keycond") or die(mysqli_error($conn));

            $qrygrp = mysqli_query($conn, "select `grpcode` from accmast where `accode` = '$accode'") or die(mysqli_error($conn));
            $fetgrp = mysqli_fetch_array($qrygrp);
            $pgrp = $fetgrp['grpcode'];


            mysqli_query($conn, "INSERT INTO `$accdb`(date,godown, vouchno, recpno, source, trnno, bankinit, accode, grpcode, amount, trnflag, monno)
                    VALUES ('$vouchdt','$godown','$mcashvouch', '$mrecpno', 'CR', '001', 'COH', '3','002', '$minus_amt','S','$mono')") or die(mysqli_error($conn));


            // party part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, godown, vouchno, recpno, source, trnno, bankinit, accode, grpcode, amount, trnflag, monno)
                    VALUES ('$vouchdt','$godown','$mcashvouch', '$mrecpno', 'CR', '002', 'COH', '$accode', '$pgrp', '$totbillamt','S','$mono')") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "DELETE FROM `cashrecp` WHERE `$keyfld`='$mcashvouch' $keycond") or die(mysqli_error($conn));
            mysqli_query($conn, "DELETE FROM `actran` WHERE `$keyfld`='$mcashvouch' AND `source`='CR' $keycond")or die(mysqli_error($conn));
            $mcashvouch = "";
        }


//**************************************************        auto cash Entry End    *************************************** 

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

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

        $cnt = 0;
        $cntamt = 0;

        for ($i = 0; $i < $count; $i++) {
            $cnt++;
            $msrno = $_POST["srno_$i"];
            $mbarcode = $_POST["barcode_$i"];
            $mitemcode = $_POST["itemcode_$i"];
            $mitemname = $_POST["itemname_$i"];
            $gram = $_POST["gram_$i"];
            $hsncode = $_POST["hsncode_$i"];
            $unit = $_POST["unit_$i"];
            $mrp = $_POST["mrp_$i"];
            $batch = $_POST["batch_$i"];
            $qty = $_POST["qty_$i"];
            $rate = $_POST["rate_$i"];
            $amt = $_POST["amount_$i"];
            $discperc = $_POST["discperc_$i"];
            $discamt = $_POST["discamt_$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;


            $group = $source . $mvouch;


            if (!empty($mbarcode)) {

                mysqli_query($conn, "INSERT INTO `$trandb`(`srno`,vouchno, vouchdt, itemcode, `itemname`,`barcode`, `gram`, hsncode, mrp,
                                                   unit, batch, qty, rate, amount, `discperc`, `discamt`, `cgstrate` , `cgstamt`, `sgstrate`,
                                                   `sgstamt`, `igstrate`, `igstamt`,`total`, `subtot`)
                                    VALUES('$cnt', '$mvouch', '$vouchdt', '$mitemcode', '$mitemname','$mbarcode', '$gram', '$hsncode','$mrp',
                                           '$unit', '$batch', '$qty', '$rate', '$amt', '$discperc', '$discamt', '$cgstrate', '$cgstamt', '$sgstrate',
                                          '$sgstamt', '$igstrate', '$igstamt', '$total', '$subtot')") or die(mysqli_error($conn));

                $gitemgrp = mysqli_query($conn, "SELECT `barcode`,`prodgrp` FROM `product` WHERE `barcode`= '$mbarcode'") or die(mysqli_error($conn));
                $fitemgrp = mysqli_fetch_array($gitemgrp);
                $itemgrp = $fitemgrp[prodgrp];

                mysqli_query($conn, "INSERT INTO `$stkdb`(`srno`, `yearno`, `godown`, `vouchno`, `vouchdt`, `itemcode`, `itemname`,`barcode`, `gram`, `unit`,
                                                  `qty`, `source`, `batch`, amount, accode, `group` , `rate`, `mrp`, `itemgrp`, `ordno`, `monno`)
                            VALUES('$cnt', '$myyear', '$godown', '$mvouch', '$vouchdt', '$mitemcode', '$mitemname', '$mbarcode', '$gram', '$unit',
                                   '$mqty', '$source', '$batch', '$amt', '$party', '$group', '$rate', '$mrp', '$itemgrp', '5', '$mono')") or die(mysqli_error($conn));
            }
        }

############################### Accounts Part ######################################################
//        IF ($chkledg == 1) {
        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `vouchno` = '$mvouch' AND `source` = '$source' ") OR die(mysqli_error($conn));
        if ($totbillamt > 0) {
            $minus_amt = ($totbillamt * -1);

            // sale part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno,`godown`, source, trnno, accode, grpcode, amount, monno)
                            VALUES ('$vouchdt','$mvouch','$godown', '$source', '001', '$purcode','005', '$totbillamt','$mono')") or die(mysqli_error($conn));

            // party part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, `godown`, source, trnno, accode, grpcode, amount, monno)
                                VALUES ('$vouchdt','$mvouch','$godown', '$source', '002', '$accode','010', '$minus_amt','$mono')") or die(mysqli_error($conn));
        }

        if ($addflag == 1) {
            mysqli_query($conn, "INSERT INTO `$maindb`(vouchno, `vouchdt`, `voucher`, `invno`, `monno`,`add`,`subject`,`mfg`, `party`, `mobile`, `oms`, `paidby`, `lrno`, `lrdate`,
                                               `transporter`, `area`, `staff`, `rem1`, `rem2`,  `cashvouch`, `gstno`, `discamt`,`grossamt`, `godown`,
                                               `taxableamt`,`cgst5`,`sgst5`,`igst5`,`cgst12`,`sgst12`,`igst12`,`cgst18`,`sgst18`,`igst18`,`cgst28`,
                                               `sgst28`,`igst28`,`totgst5`,`totgst12`,`totgst18`,`totgst28`, `purcode`,`billamt`)
                                      VALUES('$mvouch', '$vouchdt', '$voucher', '$mvouch', '$mono','$add','$subject','$mfg', '$party', '$mobile', '$oms', '$paidby','$lrno', '$lrdate',
                                              '$transporter', '$area', '$staff','$rem1', '$rem2', '$mcashvouch', '$gstno', '$totdiscamt','$grossamt', '$godown',
                                            '$taxableamt','$cgst5','$sgst5','$igst5', '$cgst12','$sgst12','$igst12', '$cgst18', '$sgst18','$igst18','$cgst28',
                                             '$sgst28','$igst28','$totgst5','$totgst12','$totgst18','$totgst28', '$purcode','$totbillamt')") or die(mysqli_error($conn));

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

            mysqli_query($conn, "UPDATE `$maindb` SET  `vouchdt`='$vouchdt', `voucher`='$voucher', `invno`='$mvouch', `monno`='$mono',`add`='$add',`subject`='$subject',`mfg`='$mfg', `party`='$party',
                                               `mobile`='$mobile', `paidby`='$paidby', `lrno`='$lrno', `lrdate`='$lrdate', 
                                               `transporter`='$transporter', `area`='$area', `staff`='$staff', `gstno`='$gstno', `cashvouch`='$mcashvouch',
                                                `rem1`='$rem1', `rem2`='$rem2', `discamt`='$totdiscamt',`grossamt`='$grossamt',`godown`='$godown',
                                                `taxableamt`='$taxableamt',`cgst5`='$cgst5',`sgst5`='$sgst5',
                                                `igst5`='$igst5',`cgst12`='$cgst12',`sgst12`='$sgst12',`igst12`='$igst12',
                                                `cgst18`='$cgst18', `sgst18`='$sgst18',`igst18`='$igst18',
                                                `cgst28`='$cgst28', `sgst28`='$sgst28',`igst28`='$igst28',`oms`='$oms',
                                                `totgst5`='$totgst5',`totgst12`='$totgst12', `totgst18`='$totgst18',`totgst28`='$totgst28',`billamt`='$totbillamt'
                                                 WHERE `vouchno` = '$mvouch' ") or die(mysqli_error($conn));
        }
        mysqli_query($conn, "UNLOCK TABLES");
        if ($addflag == 1) {
//            browse($fseries);
            insmess();
            header("refresh: 1; $file?mode=edit&$keyfld=$mvouch&form=$form");
        } else {
            updmess();
//            header("refresh: 1; $file?mode=edit&$keyfld=$mvouch&series=$fseries");
        }
    }
}

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);

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

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

    $gettransp = mysqli_query($conn, "SELECT `code`,`name` FROM `transport` WHERE `code`= '$get[transporter]'") or die(mysqli_error($conn));
    $ltrans = mysqli_fetch_array($gettransp);

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

    $delcsh = $get[cashvouch];
}





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

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



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

    delnew($zdb, "$maindb", "$delcond2", "$file?mode=last");
    delnew($zdb, "$trandb", "$delcond2", "$file?mode=last");
    delnew($zdb, "$stkdb", "$delcond", "$file?mode=last");
    delnew($zdb, "$accdb", "$delcond", "$file?mode=last");
    delnew($zdb, "$accdb", "$delcond1", "$file?mode=last");
    delnew($zdb, "cashrecp", "$delcond3", "$file?mode=last");

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


include("includes/linkshead.php");
?>
<script src="MyScript/proforma.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>
<script src="MyScript/search_itempro.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>
<script src="MyScript/proforma_search.js" type="text/javascript"></script>
</head>
<body>
    <form action='' method='POST'>
        <div class="col-lg-3 pad text-center" id="overlay_form" style="display:none;z-index:999;">
            <button type="button" id="close_form" style="float: right;font-weight: bold;font-size: 18px;color:red;" ><i class="fa fa-close"></i></button>
            <div style='width:100%;' id='browdata'>
            </div>
        </div>
        <!-- Default box -->
        <div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12  pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title" style="color:#78909C"><a class="myPrint"><?php Echo $formname; ?></a></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="row">

                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Voucher</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" name="voucher" class="form-control form voucher" value="<?php echo ($addflag != 1) ? $get['voucher'] : '' ?>" tabindex="-1" readonly>
                                <input type="hidden" name="monno" class="form-control form monno" value="<?php echo ($addflag != 1) ? $get['monno'] : '' ?>" >
                                <input type="hidden" name="vouchno" class="form-control form vouchno" value="<?php echo ($addflag != 1) ? $get['vouchno'] : $qvouch ?>" >
                                <input type="hidden" class="form-control form" name="cashvouch" value="<?php Echo ($addflag != 1) ? $get["cashvouch"] : ""; ?>" >
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Date</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-1 col-xs-8 pad">
                                <input type="date" class="form-control form vouchdt" name="vouchdt"  value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>" autofocus>
                            </div>
                            <div class="col-lg-1 pad text-right">
                                &nbsp;
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Invoice</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" name="invno" class="form-control form invno" value="<?php echo ($addflag != 1) ? $get['invno'] : $qvouch; ?>" tabindex="-1" readonly>
                            </div>
                            <div class="col-lg-1 pad text-right">
                                &nbsp;
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Godown</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <select name="godown" class="form-control form godown" required>
                                    <option value="<?php echo ($addflag != 1) ? $getgd['code'] : " "; ?>"><?php echo ($addflag != 1) ? $getgd['gcode'] : " "; ?></option>
                                    <?php
                                    $mown = mysqli_query($conn, "SELECT * FROM `godown`") or die(mysqli_error($conn));
                                    while ($trow = mysqli_fetch_array($mown)) {
                                        echo "<option value=$trow[code]>$trow[gcode]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <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">Oms</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" >                            
                            </div>
                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">Party</label>
                            </div>
                            <div class="col-lg-3 pad">
                                <select class="form-control form cmbparty select2" name="party" style="width: 100%">
                                    <option value="<?php Echo ($addflag != 1) ? $lparty["accode"] : ""; ?>"><?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 pad text-right">
                                <label class="label-control marg">Mobile</label>
                            </div>
                            <div class="col-lg-2 pad">
                                <input type="text" name="mobile" class="form-control form mobile" value="<?php echo ($addflag != 1) ? $get['mobile'] : ''; ?>" tabindex="" >
                            </div>
                            <div class="col-lg-1 pad text-right">
                                <label class="label-control marg">Paid By</label>
                            </div>
                            <div class="col-lg-1 pad">
                                <select id="paidby" name="paidby" class="form-control form select2 paidby" required>
                                    <option value=""></option>
                                    <option 
                                    <?php
                                    if ($get[paidby] == 'C') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="C">Cash</option>
                                    <option
                                    <?php
                                    if ($get[paidby] == 'R') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="R">Credit</option>
                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Subject</label>
                            </div>
                            <div class="col-lg-2 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text"  class="form-control form subject" name="subject" value="<?php Echo ($addflag != 1) ? $get["subject"] : ""; ?>" >                            
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Mfg.Lic.NO</label>
                            </div>
                            <div class="col-lg-2 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text"  class="form-control form mfg" name="mfg" value="<?php Echo ($addflag != 1) ? $get["mfg"] : ""; ?>" >                            
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Address</label>
                            </div>
                            <div class="col-lg-3 col-md-8 col-sm-8 col-xs-8 pad">
                                <textarea rows="4" cols="60" class="form-control form  add" style="resize:none;" name="add"><?php Echo ($addflag != 1) ? $get["address"] : ""; ?></textarea>
                            </div>
                        </div>
                        <div class="row">
                            <div class='col-lg-1 col-md-1 col-sm-1 col-xs-1'>
                                <button type='button' class='btn btn-primary lrtab form  btn-square' style="color: white">
                                    LR. Detail
                                </button>
                            </div>
                            <div class='col-lg-10 col-md-10 col-sm-10 col-xs-10 lrdetail'>
                                <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">LR No.</label>
                                    </div>
                                    <div class="col-lg-2 col-md-1 col-sm-1 col-xs-1 pad">
                                        <input type="text"  class="form-control form lrno" name="lrno" value="<?php Echo ($addflag != 1) ? $get["lrno"] : ""; ?>" >                            
                                    </div>
                                    <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                        &nbsp;
                                    </div>
                                    <div class="col-lg-1 col-md-1 col-sm-3 col-xs-3 text-right pad">
                                        <label class="label-control marg">LR Date</label>
                                    </div>
                                    <div class="col-lg-2 col-md-2 col-sm-1 col-xs-1 pad">
                                        <input type="date"  class="form-control form lrdate" name="lrdate" value="<?php Echo ($addflag != 1) ? $get["lrdate"] : ""; ?>">                            
                                    </div>
                                </div>
                                <div class='row'>
                                    <div class="col-lg-1 pad text-right">
                                        <label class="label-control marg">Transporter</label>
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-1 col-xs-1 pad">
                                        <select class="form-control form transporter select2" name="transporter" style="width: 100%">
                                            <option value="<?php Echo ($addflag != 1) ? $ltrans["code"] : ""; ?>"><?php Echo ($addflag != 1) ? $ltrans["name"] : ""; ?></option>
                                            <?php
                                            $gtrans = mysqli_query($conn, "SELECT `code`,`name` FROM `transport` order by name")or die(mysqli_error($conn));
                                            while ($ftrans = mysqli_fetch_array($gtrans)) {
                                                Echo "<option value='$ftrans[code]'>$ftrans[name]</option>";
                                            }
                                            ?>
                                        </select>
                                    </div>
                                    <div class="col-lg-1 pad text-right">
                                        <label class="label-control marg">Area</label>
                                    </div>
                                    <div class="col-lg-2 pad">
                                        <input type="text" name="area" class="form-control form area" value="<?php echo ($addflag != 1) ? $get['area'] : ''; ?>" tabindex="" >
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table-striped table-condensed table-bordered tab" style="width: 140%">
                                <thead  class="mySearchTr">
                                    <tr>
                                        <th style="width: 1%"></th>
                                        <th style="width: 2%">Sr.</th>
                                        <th style="width: 13%;">Description Of Goods</th>
                                        <th style="width: 6%;">STD Packing DZ</th> 
                                        <th style="width: 6%;">Case</th> 
                                        <th style='width: 7%' class="text-right">Qty.</th>
                                        <th style='width: 6%'>Unit</th>
                                        <th style='width: 6%' class="text-right">Rate(foregen $)</th>
                                        <th style='width: 6%' class="text-right">Rate</th>
                                        <th style='width: 6%' class="text-right">FOB</th>
                                        <th style='width: 6%' class="text-right">ROE</th>
                                        <th style='width: 9%' class="text-right">Amount INR</th>
                                        <th style='width: 6%' class="text-right">L</th>
                                        <th style='width: 6%' class="text-right">B</th>
                                        <th style='width: 6%' class="text-right">H</th>
                                        <th style='width: 8%' class="text-right">CMB</th>
<!--                                        <th style='width: 4%' class="">Batch</th>
                                        <th style='width: 2%' class="text-right">Disc. %</th>
                                        <th style='width: 4%' class="text-right">Disc. Amt.</th>
                                        <th style='width: 5%' class="text-right">Taxable value</th>
                                        <th style='width: 2%' class="text-right">CGST Rate</th>
                                        <th style='width: 4%' class="text-right">CGST Amt.</th>
                                        <th style='width: 2%' class="text-right">SGST Rate</th>
                                        <th style='width: 4%' class="text-right">SGST Amt.</th>
                                        <th style='width: 2%' class="text-right">IGST Rate</th>
                                        <th style='width: 4%' class="text-right">IGST Amt.</th>
                                        <th style='width: 6%' 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>";
                                            Echo "<input type='text' name='descrip_$ctr' class='descrip form-control form' value='$row[descrip]' readonly required>";
                                            Echo "</td>";
                                            Echo "<td>";
                                            Echo "<input type='text' name='std_$ctr' required='true' class='std form-control  form' value='$row[std]' >";
                                            Echo "</td>";
                                            Echo "<td>";
                                            Echo "<input type='text' name='case_$ctr' required='true' class='casec form-control  form' value='$row[case]' >";
                                            Echo "</td>";
                                            Echo "<td><input type='number' name='qty_$ctr' class='qty form-control  text-right form' step='any' value='$row[qty]' required></td>";
                                            Echo "<td><input type='text' name='unit_$ctr' class='unit form-control  form' value='$row[unit]' readonly></td>";
                                            Echo "<td><input type='number' step='any' name='ratef_$ctr' class='ratef form-control text-right  form' tabindex='-1' value='$row[ratef]' ></td>";
                                            Echo "<td><input type='number' step='any' name='rate_$ctr' class='rate form-control text-right  form' tabindex='-1' value='$row[rate]' ></td>";
                                            Echo "<td><input type='number' step='any' name='fob_$ctr' class='fob form-control text-right  form' tabindex='-1' value='$row[fob]' ></td>";
                                            Echo "<td><input type='number' step='any' name='roe_$ctr' class='roe form-control text-right  form' tabindex='-1' value='$row[roe]' ></td>";
                                            Echo "<td><input type='number' step='any' name='amount_$ctr' class='amount form-control text-right  form' tabindex='-1' value='$row[amount]' readonly></td>";
                                            Echo "<td><input type='number' step='any' name='l_$ctr' class='l form-control text-right  form' tabindex='-1' value='$row[l]' ></td>";
                                            Echo "<td><input type='number' step='any' name='b_$ctr' class='b form-control text-right  form' tabindex='-1' value='$row[b]' ></td>";
                                            Echo "<td><input type='number' step='any' name='m_$ctr' class='h form-control text-right  form' tabindex='-1' value='$row[m]' ></td>";
                                            Echo "<td><input type='number' step='any' name='cmb_$ctr' class='cmb form-control text-right  form' tabindex='-1' value='$row[cmb]'readonly ></td>";
//                                            
//                                            Echo "<td><input type='text' name='gram_$ctr' class='gram form-control  form' value='$row[gram]' readonly></td>";
//                                            Echo "<td><input type='text' name='mrp_$ctr' class='mrp form-control text-right  form' value='$row[mrp]' readonly></td>";
//                                            Echo "<td><input type='text' name='batch_$ctr' class='batch form-control   form' value='$row[batch]' ></td>";
//                                            Echo "<td><input type='text' name='discperc_$ctr' class='discperc form-control text-right  form' tabindex='-1' value='$row[discperc]' readonly></td>";
//                                            Echo "<td><input type='text' name='discamt_$ctr' class='discamt form-control text-right  form' tabindex='-1' value='$row[discamt]' readonly></td>";
//                                            Echo "<td><input type='text' name='subtot_$ctr' class='subtot form-control text-right  form' tabindex='-1' value='$row[subtot]' readonly></td>";
//                                            Echo "<td><input type='text' name='cgstrate_$ctr' class='cgstrate form-control text-right  form' tabindex='-1' value='$row[cgstrate]' readonly></td>";
//                                            Echo "<td><input type='text' name='cgstamt_$ctr' class='cgstamt form-control text-right  form' tabindex='-1' value='$row[cgstamt]' readonly></td>";
//                                            Echo "<td><input type='text' name='sgstrate_$ctr' class='sgstrate form-control text-right  form' tabindex='-1' value='$row[sgstrate]' readonly></td>";
//                                            Echo "<td><input type='text' name='sgstamt_$ctr' class='sgstamt form-control text-right  form' tabindex='-1' value='$row[sgstamt]' readonly></td>";
//                                            Echo "<td><input type='text' name='igstrate_$ctr' class='igstrate form-control text-right  form' tabindex='-1' value='$row[igstrate]' readonly></td>";
//                                            Echo "<td><input type='text' name='igstamt_$ctr' class='igstamt form-control text-right  form' tabindex='-1' value='$row[igstamt]' readonly></td>";
//                                            Echo "<td><input type='text' name='total_$ctr' class='total form-control text-right  form' tabindex='-1' value='$row[total]' 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='descrip_0' class='descrip form-control form' value='' readonly required></td> 
                                            <td><input type='text' name='std_0' required='true' class='std form-control  form' value=''  ></td>
                                            <td><input type='text' name='case_0' required='true' class='casec form-control  form' value='' ></td>                                            
                                            <td><input type='number' name='qty_0' class='qty form-control  text-right form' step="any" value='0.00'required ></td>                                           
                                            <td><input type='text' name='unit_0' class='unit form-control  form' value='' ></td>
                                            <td><input type="number" step="any" name='ratef_0' class='ratef form-control text-right form '  value='0' ></td> 
                                            <td><input type="number" step="any" name='rate_0' class='rate form-control text-right form '  value='0' ></td> 
                                            <td><input type="number" step="any" name='fob_0' class='fob form-control text-right form '  value='0' ></td> 
                                            <td><input type="number" step="any" name='roe_0' class='roe form-control text-right form ' value='0' ></td> 
                                            <td><input type="number" step="any" name='amount_0' class='amount text-right form-control form ' value='0'  readonly></td> 
                                            <td><input type="number" step="any" name='l_0' class='l form-control text-right form '  value='0' ></td> 
                                            <td><input type="number" step="any" name='b_0' class='b form-control text-right form '  value='0' ></td> 
                                            <td><input type="number" step="any" name='m_0' class='h form-control text-right form '  value='0' ></td> 
                                            <td><input type="number" step="any" name='cmb_0' class='cmb form-control text-right form '  value='0' readonly></td> 
<!--                                            <td><input type='text' name='mrp_0' class='mrp text-right form-control   form' value='' readonly></td>
                                            <td><input type='text' name='batch_0' class='batch form-control   form' value='' ></td>
                                            <td><input type='text' name='discperc_0' class='discperc text-right form-control form ' value='0.00' tabindex='-1' readonly></td> 
                                            <td><input type='text' name='discamt_0' class='discamt text-right form-control form  ' value='0.00' tabindex='-1' readonly></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>
                                        <?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; ?>">  
                            <input type="hidden" class="mandatoryId" name="manId" value="">  
                        </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">Staff</label>
                                    </div>
                                    <div class="col-lg-6 pad">
                                        <select class="form-control form staff select2" name="staff" style="width :100%">
                                            <option value="<?php Echo ($addflag != 1) ? $lstaff["accode"] : ""; ?>"><?php Echo ($addflag != 1) ? $lstaff["name"] : ""; ?></option>
                                            <?php
                                            $gstaff = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `grpcode`='040'")or die(mysqli_error($conn));
                                            while ($staff = mysqli_fetch_array($gstaff)) {
                                                Echo "<option value='$staff[accode]'>$staff[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">G.S.T NO.</label>
                                    </div>
                                    <div class="col-lg-9 pad">
                                        <input type="text" name="gstno" class="form-control form gstno" value="<? Echo ($addflag != 1) ? $get["gstno"] : ""; ?>" tabindex="-1">
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-3 pad text-right">
                                        <label class="label-control marg">Remarks</label>
                                    </div>
                                    <div class="col-lg-9 pad">
                                        <input type="text" name="remark1" class="form-control form " value="<? Echo ($addflag != 1) ? $get["rem1"] : ""; ?>">
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-3 pad text-right"></div>
                                    <div class="col-lg-9 pad">
                                        <input type="text" name="remark2" class="form-control form " value="<? Echo ($addflag != 1) ? $get["rem2"] : ""; ?>">
                                    </div>
                                </div>
                            </div>

                            <div class="col-lg-6 col-xs-12 pad">
                                <div class="col-lg-12 col-xs-12 pad">
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-3 pad"></div>
                                    <div class="col-lg-3 pad text-right">
                                        <label class="label-control marg">Subtotal</label>
                                    </div>
                                    <div class="col-lg-3 pad">
                                        <input type="number" step="any" name="grossamt" class="form-control form text-right grossamt" value="<?php Echo ($addflag != 1) ? $get['grossamt'] : "0"; ?>" readonly 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">Disc. Amount</label>
                                    </div>
                                    <div class="col-lg-3 pad">
                                        <input type="number" step="any" name="totdiscamt" class="form-control form text-right totdiscamt" value="<?php Echo ($addflag != 1) ? $get['discamt'] : "0"; ?>" readonly 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">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 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  style="background: #26a69a;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 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 class="col-lg-12 col-md-12 col-sm-12 col-xs-12 pad">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <?php include("includes/buttons.php"); ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>

    <div class="modal fade itemModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span>&times;</span></button>
                    <h4 class="modal-title" id="myLargeModalLabel">Search <? Echo $formname; ?></h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" value="<?php // Echo $fseries                                  ?>" class="form-control series">
                    <input type="hidden" value="<?php Echo $get[vouchno]; ?>" class="form-control vouchno">
                    <input type="hidden" value="<?php Echo $file ?>" class="form-control file">
                    <input type="hidden" value="<?php Echo $para ?>" class="form-control para">
                    <div class="row">
                        <div class="col-lg-3">
                            <select class="form-control ifield">
                                <option value="1">Name</option>
                                <option value="2">Barcode</option>
                                <option value="3">Itemcode</option>
                                <option value="4">Gram</option>
                                <option value="5">Unit</option>
                            </select>
                        </div>
                        <div class="col-lg-2">
                            <select class="form-control ioperator">
                                <option value=""></option>
                                <option value="%">Like</option>
                                <option value="=">Exactly</option>
                            </select>
                        </div>
                        <div class="col-lg-4">
                            <input type="text" value="" class="form-control isearch">
                        </div>
                        <div class="col-lg-3">
                            <input type="button" class="btn btn-primary iload" value="Search">
                        </div>
                    </div>

                    <div class="col-lg-12 iloader text-center">
                        <img src="images/search.gif" alt="loading">       
                    </div>
                    <div class="col-lg-12 inoRecord text-center">
                        <h3>NO RECORDS FOUND</h3>
                    </div>
                    <div class="table-responsive" style="max-height: 400px;overflow: auto;">
                        <table id="" class="table table-striped table-condensed table-bordered" width="100%">
                            <thead>
                                <tr class="mySearchTr">
                                    <th width="20%">Name</th>
                                    <th width="20%">Barcode</th>
                                    <th width="15%">Itemcode</th>
                                    <th width="15%">Gram</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>
    <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">Voucher</option>
                                <option value="2">Bill No.</option>
                                <option value="3">Date</option>
                                <option value="4"> Party Name</option>
                                <option value="5">Mobile</option>
                                <option value="6">Amount</option>
                                <option value="7">Remark</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">Bill No.</option>
                                <option value="3">Date</option>
                                <option value="4"> Party Name</option>
                                <option value="5">Mobile</option>
                                <option value="6">Amount</option>
                                <option value="7">Remark</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%">Amount</th>
                                    <th width="20%">Remark</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 sprevious" value="Previous">
                            <input type="button"  class="btn btn-primary snext" value="Next">
                        </div>
                    </div>
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
  