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

$maindb = 'purmain';
$trandb = 'purtran';
$accdb = 'actran';
$stkdb = 'transacn';
$printfile = "purchase_print.php";
$file = 'purchase.php';

$trandbexist = 1;
$source = "PU";
$keyfld = "vouchno";
$myyear = $_SESSION["tit_" . $dbname];

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

$usertype = $_SESSION["usertype"];
$username = $_SESSION["username_" . $dbname];

//browse($username);
$formname = 'Purchase';

$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);
mysqli_set_charset($conn,"utf8mb4");

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

if (isset($_POST["cancbtn"])) {
    $mcancvouch = $_POST['cancvouch'];
    $mcashvouch2 = $_POST['cashvouch2'];
    $cancdate = $_POST['cancdate'];

//    browse($cancdate);
    if ($cancdate != '' || $cancdate != '0000-00-00') {
//    browse($mcancvouch);
//    browse($mcashvouch2);
        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `vouchno` = '$mcancvouch' AND `source` = '$source' ") OR die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM `cashpay` WHERE `$keyfld`='$mcashvouch2' ") or die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `$keyfld`='$mcashvouch2' and `source` = 'CP' $keycond") or die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM `$stkdb` WHERE vouchno='$mcancvouch'  AND `source`='$source'") or die(mysqli_error($conn));

        mysqli_query($conn, "Update `$maindb` set `cancdate`='$cancdate', cancuser='$username', canc_flag='C' where vouchno = '$mcancvouch'") or die(mysqli_error($conn));
        mysqli_query($conn, "Update `$trandb` set cancdate='C' where vouchno = '$mcancvouch'") or die(mysqli_error($conn));
        browse('Bill Cancelled');
    }
    header("refresh: 1; $file?mode=edit&$keyfld=$mcancvouch");
}
if (isset($_POST["submit"])) {

    $a = 1;

    $vouchdt = trim($_POST["vouchdt"]);
    $invdt = trim($_POST["invdt"]);
    $voucher = trim($_POST["voucher"]);
    
    $qvouch = trim($_POST["vouchno"]);
    
    $mono = $_POST["monno"];
    $invno = $_POST["invno"];
    $godown = $_POST["godown"];
    $addgst = $_POST["addgst"];
    $addpack = $_POST["addpack"];
    $gstperc = $_POST["gstperc"];
//    $debitac = $_POST["debitac"];
    $paidby = trim($_POST["paidby"]);
    $party = trim($_POST["party"]);
    $salesman = trim($_POST["salesman"]);
    $taxableamt = trim($_POST["taxableamt"]);
    $totbillamt = trim($_POST["totbillamt"]);
    $grossamt = trim($_POST["grossamt"]);
    $gstno = trim($_POST["gstno"]);
    $totdisc = trim($_POST["totdisc"]);
    $totvat = trim($_POST["totvat"]);
    $totalqty = trim($_POST["totalqty"]);
    $packby = trim($_POST["packby"]);
    $mobile = trim($_POST["mobile"]);
    $architect = trim($_POST["architect"]);
    $rem1 = trim($_POST["remark1"]);
    $rem2 = trim($_POST["remark2"]);
    $tvatperc = trim($_POST["tvatperc"]);
    $ldiscperc = trim($_POST["ldiscperc"]);
    $ntprint = trim($_POST["ntprint"]);

    $lrno = $_POST["lrno"];
    $lrdate = $_POST["lrdate"];
    $transporter = $_POST["transporter"];
    $area = $_POST["area"];

    $totadv = $_POST["totadv"];
    $totbal = $_POST["totbal"];
    $billflag = $_POST["billflag"];
    $salevcno = $_POST["salevcno"];

    date_default_timezone_set("Asia/Dubai");
    $usertime = date("Y-m-d H:i:sa");

//    $taxableamt = $grossamt - $totdiscamt + $postamt;
//    $totbillamt1 = $taxableamt + $totgst5 + $totgst12 + $totgst18 + $totgst28 + $tcsamt;
//    $gstamount = $pretcs - $taxableamt;
//
//    $totbillamt = round($totbillamt1);
//    if ($totgst1 > 0) {
//        $oms = 1;
//    } else {
    $oms = $_POST['oms'];
//    }

    $count = $_POST["items"];
    $mvouch = $qvouch;
//browse($count);
    if ($paidby == "R") {
        $purcode = '15';
    } else {
        $purcode = '14';
    }

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

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


    if ($accode == "") {
        browse("Party Cannot Be Empty");
        $a = 0;
    }

    if ($a == 1) {
        mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `$trandb` WRITE, `product` WRITE, `$stkdb` WRITE, `$accdb` WRITE, `cashpay` WRITE, `accmast` WRITE,salepurch WRITE,salepurchtemp 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;
        }

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

        if ($paidby == 'C' || $totadv > 0) {
            if ($mcashvouch == '0' || $mcashvouch == '') {
                $gen1 = mysqli_query($conn, "SELECT MAX(vouchno+0) AS maxcode FROM `cashpay` 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 `cashpay` 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 `cashpay` 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;
            }
            if ($totadv > 0) {
                $recpamt = $totadv;
            } else {
                $recpamt = $totbillamt;
            }

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

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

            // cash part  

            $minus_amt = ($recpamt * -1);

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

            mysqli_query($conn, "INSERT INTO `$accdb`(date,godown, vouchno, recpno, source, trnno, bankinit, accode, grpcode, amount, trnflag, monno)
                    VALUES ('$vouchdt','$godown','$mcashvouch', '$mrecpno', 'CP', '001', 'COH', '3','002', '$recpamt','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', 'CP', '002', 'COH', '$accode', '009', '$minus_amt','S','$mono')") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "DELETE FROM `cashpay` WHERE `$keyfld`='$mcashvouch' $keycond") or die(mysqli_error($conn));
            mysqli_query($conn, "DELETE FROM `actran` WHERE `$keyfld`='$mcashvouch' AND `source`='CP' $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));
        if ($billflag == 1) {
            $getslpr = mysqli_query($conn, "Select * FROM `salepurchtemp` WHERE `purvouch`='$mvouch' ") or die(mysqli_error($conn));

            while ($fetslpr = mysqli_fetch_array($getslpr)) {
                $titemname = $fetslpr['itemname'];
                $tsize = $fetslpr['size'];
                mysqli_query($conn, "DELETE FROM `salepurch` WHERE `purvouch`='$mvouch'  and trim(itemname) = '$titemname' and trim(size) = '$tsize'") or die(mysqli_error($conn));
                mysqli_query($conn, "INSERT INTO `salepurch`(`salevouch`, `supplier`, `billno`, `billdate`, `recdqty`, `purcost`, `itemname`, `purvouch` ,size, recdsqft, recdcalby)
                                    VALUES('$fetslpr[salevouch]', '$fetslpr[supplier]', '$fetslpr[billno]', '$fetslpr[billdate]', '$fetslpr[recdqty]', '$fetslpr[purcost]', '$fetslpr[itemname]', '$mvouch', '$fetslpr[size]', '$fetslpr[recdsqft]', '$fetslpr[recdcalby]')") or die(mysqli_error($conn));

//            if ($fetslpr['complete'] == "1") {
//                mysqli_query($conn, "Update `saletran` set delvdate='$vouchdt' WHERE `vouchno` = '$fetslpr[salevouch]' and itemname = '$fetslpr[item]' ") OR die(mysqli_error($conn));
//            }
            }
        }
        mysqli_query($conn, "DELETE FROM `salepurchtemp` WHERE `purvouch`='$mvouch' ") or die(mysqli_error($conn));

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

        $cnt = 0;
        $cntamt = 0;

        for ($i = 0; $i <= $count; $i++) {
            $msrno = $_POST["srno_$i"];
            $barcode = $_POST["barcode_$i"];
            $mitem = mysqli_real_escape_string($conn, $_POST["itemname_$i"]);
            $cartqty = $_POST["cartqty_$i"];
            $qty = $_POST["qty_$i"];
            $unit = $_POST["unit_$i"];
            $size = $_POST["size_$i"];
            $totqty = $_POST["totqty_$i"];
            $rate = $_POST["rate_$i"];
            $amt = $_POST["amount_$i"];
            $discperc = $_POST["discperc_$i"];
            $discamt = $_POST["discamt_$i"];
            $vatperc = $_POST["vatperc_$i"];
            $vat = $_POST["vat_$i"];
            $total = $_POST["total_$i"];
            $subtot = $_POST["subtot_$i"];
            $stk = $_POST["stk_$i"];
            $calby = $_POST["calby_$i"];
            $sqft = $_POST["sqft_$i"];

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

                $getit = mysqli_query($conn, "SELECT code, cost, rate FROM `product` WHERE `name`='$mitem'") or die(mysqli_error($conn));
                if (mysqli_num_rows($getit) > 0) {
                    $icode = mysqli_fetch_array($getit);
                    $itcode = $icode['code'];
//                    $cost = $icode['cost'];
//                    $rate = $icode['rate'];
                } else {
                    $genit = mysqli_query($conn, "SELECT MAX(code) AS maxcode FROM `product` where code != '' LIMIT 0,1 ") or die(mysqli_error($conn));
                    if (mysqli_num_rows($genit) > 0) {
                        $git = mysqli_fetch_assoc($genit);
                        $itcode = $git["maxcode"] + 1;
                    } else {
                        $itcode = '1';
                    }
                    mysqli_query($conn, "INSERT INTO `product`(`code`, `name`, `cost`, `adduser`,unit)
                           VALUES('$itcode',  '$mitem', '$rate', '$username','$unit')") or die(mysqli_error($conn));
                }

                $getsz = mysqli_query($conn, "SELECT code,name FROM `size` WHERE `name`='$size'") or die(mysqli_error($conn));
                if (mysqli_num_rows($getsz) > 0) {
                    $scode = mysqli_fetch_array($getsz);
                    $szcode = $scode['code'];
                } else {
                    $gensz = mysqli_query($conn, "SELECT MAX(code) AS maxcode FROM `size` where code != '' LIMIT 0,1 ") or die(mysqli_error($conn));
                    if (mysqli_num_rows($gensz) > 0) {
                        $gsz = mysqli_fetch_assoc($gensz);
                        $szcode = $gsz["maxcode"] + 1;
                    } else {
                        $szcode = '1';
                    }
                    mysqli_query($conn, "INSERT INTO `size`(`code`, `name`)
                           VALUES('$szcode',  '$size')") or die(mysqli_error($conn));
                }

                $tcartqty = $cartqty;
                $tqty = $qty;
                $ttotqty = $totqty;

                mysqli_query($conn, "INSERT INTO `$trandb`(vouchno, vouchdt, srno, itemcode, itemname, qty, cost, amount, rate,unit,size,sqft,calby)
                                                  VALUES('$mvouch', '$vouchdt', '$cnt', '$itcode', '$mitem', '$qty', '$cost', '$amt',
                                   '$rate','$unit','$size','$sqft', '$calby')") or die(mysqli_error($conn));

                mysqli_query($conn, "INSERT INTO `$stkdb`(`srno`, `yearno`, `vouchno`, `vouchdt`, `itemcode`,  `cartqty`,rate,barcode,godown,size,
                                                  `qty`, `source`, amount, accode, `group` , `totqty`, `cost`, `itemgrp`, `ordno`, `monno`)
                            VALUES('$cnt', '$myyear', '$mvouch', '$vouchdt', '$itcode',  '$tcartqty','$rate','$barcode','$godown','$size',
                                   '$tqty', '$source', '$amt', '$party', '$group', '$ttotqty', '$cost', '$itemgrp', '1', '$mono')") or die(mysqli_error($conn));
            }
        }
//        browse(1);
############################### 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','004', '$minus_amt','$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', '$party','009', '$totbillamt','$mono')") or die(mysqli_error($conn));
        }

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

            mysqli_query($conn, "INSERT INTO `$maindb`(vouchno, `vouchdt`, invdt, `voucher`, `invno`, `mono`, `party`, `paidby`, `debitac`, 
                                              `rem1`, `rem2`, `cashvouch`, `totdisc`,`grossamt`, totvat, packby, mobile, ldiscperc, gstperc,
                                               `tvatperc`,`lrno`, `lrdate`, `transporter`, `area`,  `totalqty`,`godown`,`addpack`,`addgst`,
                                               `purcode`,`billamt`,username, usertime, `totadv`, `totbal`,architect,salesman,ntprint,salevcno)
                                      VALUES('$mvouch', '$vouchdt', '$invdt', '$newvoucher', '$invno', '$mono', '$party', '$paidby', '$purcode',
                                             '$rem1', '$rem2', '$mcashvouch', '$totdisc','$grossamt', '$totvat','$packby','$mobile','$ldiscperc', $gstperc,
                                             '$tvatperc', '$lrno', '$lrdate', '$transporter', '$area', '$totalqty','$godown','$addpack','$addgst',
                                             '$purcode','$totbillamt','$username', '$usertime', '$totadv', '$totbal','$architect','$salesman','$ntprint','$salevcno')") or die(mysqli_error($conn));

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

            mysqli_query($conn, "UPDATE `$maindb` SET  `vouchdt`='$vouchdt', invdt='$invdt', `invno`='$invno', `mono`='$mono', `party`='$party', `paidby`='$paidby', 
                                         packby='$packby', `rem1`='$rem1', `rem2`='$rem2', `totdisc`='$totdisc',`grossamt`='$grossamt', salevcno='$salevcno',
                                         `debitac`='$purcode',`purcode`='$purcode', mobile='$mobile',`cashvouch`='$mcashvouch',totvat='$totvat',`godown`='$godown', 
                                         `billamt`='$totbillamt', ldiscperc='$ldiscperc', gstperc='$gstperc',lrno = '$lrno', lrdate = '$lrdate', transporter = '$transporter', 
                                          area = '$area', tvatperc='$tvatperc', `totadv`='$totadv', `totbal`='$totbal',  `username`='$username',`addpack`='$addpack',`addgst`='$addgst', 
                                         `totalqty`='$totalqty', `usertime`='$usertime',`architect`='$architect',`salesman`='$salesman' ,`ntprint`='$ntprint' 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();
            header("refresh: 1; $file?mode=edit&$keyfld=$mvouch&form=$form");
        }
    }
}

if ($addflag != 1) {

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

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

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

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

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

    $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);
//    browse($getgd[code]);
    $rd = "readonly";
    $delcsh = $get['cashvouch'];
}

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

    $delcondps = " purvouch = '$_GET[vouchno]'";
    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]'";
    $delcond1 = " source = 'CP' 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, "cashpay", "$delcond3", "$file?mode=last");
    delnew($zdb, "salepurch", "$delcondps", "$file?mode=last");

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

include("includes/linkshead.php");
?>
<script src="MyScript/purchase.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>
<!--<sCPipt src="MySCPipt/search_item_sale.js?A=<?= mt_rand(); ?>" type="text/javasCPipt"></sCPipt>-->
<script src="MyScript/purchase_search.js" type="text/javascript"></script>
<script src="MyScript/checkdate.js" type="text/javascript"></script>
<!--<sCPipt>
    $(document).ready(function () {
      
    })
</sCPipt>-->

</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-12">
                            <h3 class="panel-title" style="color:black"><a class="myPrint"><?php echo $formname; ?></a></h3>
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
                            <input type="date" value="<?= $zStartDate ?>" style="width: 1px;border: none" class="zstdate">
                            <input type="date" value="<?= $zEndDate ?>" style="width: 1px;border: none" class="zenddate">
                            <h4 class="panel-title" style="float:right"><b><?php echo $get['username'] ?></b></h4>
                        </div>

                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg" >Voucher</label>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                                <input type="text" name="vouchno" class="form-control form vouchno" id="vouchno" value="<?php echo ($addflag != 1) ? $get['vouchno'] : $qvouch ?>" >
                                <input type="hidden" name="voucher" class="form-control form voucher" value="<?php echo ($addflag != 1) ? $get['voucher'] : '' ?>" tabindex="-1" readonly required>
                                <input type="hidden" name="monno" class="form-control form monno" value="<?php echo ($addflag != 1) ? $get['monno'] : '' ?>" >
                                <input type="hidden" class="form-control addflag addflg" value="<?php echo $addflag ?>" >
                                <input type="hidden" name="source" class="form-control form source" value="<?= $source; ?>" id="source">
                                <input type="hidden" class="form-control form" name="cashvouch" value="<?php Echo ($addflag != 1) ? $get["cashvouch"] : ""; ?>" >
                                <input type="hidden" class="form-control form canc_flag" name="" value="<?php Echo ($addflag != 1) ? $get["canc_flag"] : ""; ?>" >
                                <input type="hidden" class="form-control form billflag" name="billflag" value="0">

                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-3 text-right pad">
                                <label class="label-control marg" >Date</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-4 pad">
                                <input type="date" class="form-control form vouchdt focusfield" name="vouchdt"  value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>" autofocus required>
                            </div>
                            <!--                            <div class="col-lg-1 pad text-right">
                                                            &nbsp;
                                                        </div>-->


                        </div>

                        <div class="row">
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-2  pad text-right">
                                <label class="label-control marg">Supplier</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-7 col-xs-9  pad">
                                <select class="form-control form cmbparty party supplier select2" id="party" name="party" style="width: 100%" >
                                    <option value="<?php Echo ($addflag != 1) ? $lparty["accode"] : ""; ?>"><?php Echo ($addflag != 1) ? $lparty["name"] : ""; ?></option>
                                    <?php
//                                    do not remove this condition.Talk to Fairoz Sir first.
//                                    if ($addflag == 1) {
                                    $gparty = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `grpcode`='009' order by name")or die(mysqli_error($conn));
                                    while ($party = mysqli_fetch_array($gparty)) {
                                        Echo "<option value='$party[accode]'>$party[name]</option>";
                                    }
//                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="row"><!-- comment -->

                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg" >Invoice</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-4 pad">
                                <input type="text" name="invno" class="form-control form invno" value="<?php echo ($addflag != 1) ? $get['invno'] : ""; ?>" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-3 text-right pad">
                                <label class="label-control marg" >Date</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-4 pad">
                                <input type="date" class="form-control form invdt" name="invdt"  value="<?php Echo ($addflag != 1) ? $get["invdt"] : date("Y-m-d"); ?>" >
                            </div>

                            <!-- comment -->
                        </div>

                        <div class="row">
                            <div class="col-lg-1 col-xs-2 pad text-right">
                                <label class="label-control marg">Paid By</label>
                            </div>
                            <div class="col-lg-1 col-xs-4 pad">
                                <select id="paidby" name="paidby" class="form-control form select2 paidby" required>
                                    <!-- <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 class="col-lg-1 col-md-1 col-sm-2 col-xs-3 text-right pad">
                                <label class="label-control marg" style="color: red">Sale No.</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-4 pad">
                                <input type="text" class="form-control form salevcno" name="salevcno"  style="color: red" value="<?php Echo ($addflag != 1) ? $get["salevcno"] : ""; ?>" <?= $rd ?>>
                            </div>
                        </div>



                        <div class="table-responsive">
                            <table class="table-striped table-condensed table-bordered tab" width="100%">
                                <thead  class="mySearchTr">
                                    <tr>
                                        <th style="width: 1%"></th>
                                        <th style="width: 2%">Sr. No.</th>
                                        <th style='width: 10%' class="text-left">Desciption</th>
                                        <th style="width: 5%;">Size</th> 
                                        <th style='width: 5%' class="text-right">Qty.</th>
                                        <th style='width: 5%' >Unit</th>
                                        <th style='width: 5%' class="text-right">Sq.Ft.</th>
                                        <th style='width: 5%' >Cal By</th>
                                        <th style='width: 5% ; text-align:right'>Cost</th>
                                        <th style='width: 9%' class="text-right">Amount</th>
                                        <!--<th style='width: 6%' class="text-left">Delivery Date</th>-->
                                        <?php if ($addflag != 1) { ?>
                                            <th style='width: 2%' class="text-center">Settlement</th>
                                        <?php } ?>

                                    </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)) {
                                            if ($row['calby'] == "P") {
                                                $calname = "Pc";
                                            } elseif ($row['calby'] == "S") {
                                                $calname = "Sq.Ft.";
                                            } elseif ($row['calby'] == "B") {
                                                $calname = "Box";
                                            } else {
                                                $calname = "";
                                            }

                                            Echo "<tr>";
                                            Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                            Echo "<td><input type='text' name='srno_$ctr' class='srno form-control  form'  value='$row[srno]'></td>";
                                            Echo "<td>";
                                            echo "<input list='itemname' name='itemname_$ctr' class='itemname form-control form ' autocomplete='off' value='$row[itemname]'> ";
                                            echo "<datalist id='itemname' char='#'>";
                                            echo"<option>";

                                            $msize = mysqli_query($conn, "SELECT `name` FROM `product` group by name") or die(mysqli_error($conn));

                                            while ($tsize = mysqli_fetch_array($msize)) {
                                                $sizename = $tsize['name'];
                                                echo "<option value='$sizename'>";
                                            }
                                            echo "</datalist>";
                                            echo "</td>";
                                            Echo "<td>";
                                            echo "<input list='size' name='size_$ctr' class='size form-control form ' autocomplete='off' value='$row[size]'> ";
                                            echo "<datalist id='size' char='#'>";
                                            echo"<option>";

                                            $msi = mysqli_query($conn, "SELECT `name` FROM `size` group by name") or die(mysqli_error($conn));

                                            while ($tsi = mysqli_fetch_array($msi)) {
                                                $szname = $tsi['name'];
                                                echo "<option value='$szname'>";
                                            }
                                            echo "</datalist>";
                                            echo "</td>";
//                                            Echo "<td><input type='text' class='form-control form size'            name='size_$ctr'  value='$row[size]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right qty'     name='qty_$ctr' value='$row[qty]'></td>";

                                            Echo "<td>";
                                            echo "<input list='unit' name='unit_$ctr' class='unit form-control form ' autocomplete='off' value='$row[unit]'> ";
                                            echo "<datalist id='unit' char='#'>";
                                            echo"<option>";

                                            $mun = mysqli_query($conn, "SELECT `unit` FROM `product` group by unit") or die(mysqli_error($conn));

                                            while ($tun = mysqli_fetch_array($mun)) {
                                                $unname = $tun['name'];
                                                echo "<option value='$unname'>";
                                            }
                                            echo "</datalist>";
                                            echo "</td>";
                                            Echo "<td><input type='text' class='form-control form text-right sqft'     name='sqft_$ctr' value='$row[sqft]'></td>";

                                            Echo "<td>";
                                            Echo "<select name='calby_$ctr' class='form-control form calby'>";
                                            Echo "<option value='$row[calby]'>$calname</option>";
                                            Echo "<option value='P'>Pc</option>";
                                            Echo "<option value='S'>Sq.Ft.</option>";
                                            Echo "<option value='B'>Box</option>";
                                            echo "</select>";
                                            echo "</td>";
//                                            Echo "<td><input type='text' class='form-control form unit'               name='unit_$ctr'  value='$row[unit]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right rate'    name='rate_$ctr'  value='$row[rate]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right amount'  name='amount_$ctr'  value='$row[amount]' ></td>";
//                                            Echo "<td><input type='date' class='form-control form delivery_date'  name='delivery_date_$ctr'  value='$row[delivery_date]' ></td>";
                                            Echo "<td><button type='button' class='btn btn-primary purchase form' style='margin-left: 20px;' id='btn-purchase'>Settlement</button></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 list='itemname' name='itemname_0' class='itemname form-control form' value='' required >
                                                <datalist id='itemname' char="#">
                                                    <option value=''></option>
                                                    <?php
                                                    $msize = mysqli_query($conn, "SELECT `name` FROM `product` group by name") or die(mysqli_error($conn));

                                                    while ($tsize = mysqli_fetch_array($msize)) {
                                                        $sizename = $tsize['name'];
                                                        echo "<option value='$sizename'>";
                                                    }
                                                    ?>
                                                </datalist>
                                            </td>
                                            <td>
                                                <input list='size' name='size_0' class='size form-control form' value='' required >
                                                <datalist id='size' char="#">
                                                    <option value=''></option>
                                                    <?php
                                                    $msi = mysqli_query($conn, "SELECT `name` FROM `size` group by name") or die(mysqli_error($conn));

                                                    while ($tsi = mysqli_fetch_array($msi)) {
                                                        $szname = $tsi['name'];
                                                        echo "<option value='$szname'>";
                                                    }
                                                    ?>
                                                </datalist>
                                                <!--<input type='text' name='size_0' class='size form-control form' value='' >-->
                                            </td>
                                            <!--<td><input type='text' name='size_0' class='size form-control form' value='' ></td>-->
                                            <td><input type='text' name='qty_0' class='qty text-right form-control form' value='' ></td>
                                            <td>
                                                <input list='unit' name='unit_0' class='unit form-control form' value='' required >
                                                <datalist id='unit' char="#">
                                                    <option value=''></option>
                                                    <?php
                                                    $mun = mysqli_query($conn, "SELECT `unit` FROM `product` group by unit") or die(mysqli_error($conn));

                                                    while ($tun = mysqli_fetch_array($mun)) {
                                                        $unname = $tun['name'];
                                                        echo "<option value='$unname'>";
                                                    }
                                                    ?>
                                                </datalist>
                                            </td>
                                            <td><input type='text' class='form-control form text-right sqft'     name='sqft_0' value='0'></td>

                                            <td>
                                                <select name="calby_0" class="form-control form select calby">
                                                    <option value='P'>Pc</option>
                                                    <option value='S'>Sq.Ft.</option>
                                                    <option value='B'>Box</option>
                                                </select>
                                            </td>
                                            <!--<td><input type='text' name='unit_0' class='unit form-control form' value='' ></td>-->
                                            <td><input type='text' name='rate_0' class='rate text-right form-control form' value='' ></td>
                                            <td><input type='text' name='amount_0' class='amount text-right form-control form' value='' ></td>
                                            <?php if ($addflag != 1) { ?>

                                                <td><button type='button' class='btn btn-primary purchase form' style='margin-left: 20px;' id='btn-purchase'>Settlement</button></td>
                                            <?php } ?>

                                        </tr>
                                        <?php
                                    }
                                    ?>
                                <input type="hidden" id="items" name="items" value="<?php Echo ($addflag != 1) ? $ctr : 1; ?>">  

                                </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" class="mandatoryId" name="manId" value="">-->  
                        </div>
                        <div class="col-lg-12 col-xs-12 pad">


                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-12 col-xs-12 ">
                                    <div class="col-lg-8 pad"></div>
                                    <div class="col-lg-2 col-xs-7 label-control text-right marg">Total Qty.</div>
                                    <div class="col-lg-2 col-xs-5 ">
                                        <input type="number" step="any" name="totalqty" class="form-control form text-right totalqty" value="<?php Echo ($addflag != 1) ? $get['totalqty'] : "0"; ?>">
                                    </div>
                                    <div class="col-lg-10 col-xs-7  text-right">
                                        <label class="label-control marg">Subtotal</label>
                                    </div>
                                    <div class="col-lg-2 col-xs-5 ">
                                        <input type="number" step="any" name="grossamt" class="form-control form text-right totamt grossamt" value="<?php Echo ($addflag != 1) ? $get['grossamt'] : "0"; ?>" readonly tabindex="-1">
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 ">
                                    <div class="col-lg-5 "></div>
                                    <div class="col-lg-3 col-xs-5  text-right">
                                        <label class="label-control marg text-right">Less Discount</label>
                                    </div>
                                    <div class="col-lg-1 col-xs-3 ">
                                        <input type="number" step="any" name="ldiscperc" class="form-control form text-right ldiscperc" value="<?php Echo ($addflag != 1) ? $get['ldiscperc'] : "0"; ?>">

                                    </div>
                                    <div class="col-lg-1 col-xs-1  text-right">
                                        <label class="label-control marg">%</label>
                                    </div>
                                    <div class="col-lg-2 col-xs-3 ">
                                        <input type="number" step="any" name="totdisc" class="form-control form text-right totdisc" value="<?php Echo ($addflag != 1) ? $get['totdisc'] : "0"; ?>">
                                        <input type="hidden" step="any" name="tvatperc" class="form-control form text-right tvatperc" value="<?php Echo ($addflag != 1) ? $get['tvatperc'] : "0"; ?>">
                                        <input type="hidden" step="any" name="totvat" class="form-control form text-right totvat" value="<?php Echo ($addflag != 1) ? $get['totvat'] : "0"; ?>" readonly tabindex="-1">
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 ">
                                    <div class="col-lg-5 "></div>
                                    <div class="col-lg-3 col-xs-5  text-right">
                                        <label class="label-control marg text-right">ADD GST</label>
                                    </div>
                                    <div class="col-lg-1 col-xs-3 ">
                                        <input type="number" step="any" name="gstperc" class="form-control form text-right gstperc" value="<?php Echo ($addflag != 1) ? $get['gstperc'] : "0"; ?>">

                                    </div>
                                    <div class="col-lg-1 col-xs-1  text-right">
                                        <label class="label-control marg">%</label>
                                    </div>
                                    <div class="col-lg-2 col-xs-3 ">
                                        <input type="number" step="any" name="addgst" class="form-control form text-right addgst" value="<?php Echo ($addflag != 1) ? $get['addgst'] : "0"; ?>">
                                    </div>
                                </div>
                                <div class="col-lg-12 col-xs-12 ">
                                    <div class="col-lg-3 "></div>
                                    <div class="col-lg-3 "></div>
                                    <div class="col-lg-4 col-xs-7  text-right">
                                        <label class="label-control marg">Cartage</label>
                                    </div>
                                    <div class="col-lg-2 col-xs-5 ">
                                        <input type="number" step="any" name="addpack" required="true" class="form-control form text-right  addpack" value="<?php Echo ($addflag != 1) ? $get['addpack'] : "0"; ?>">
                                    </div>
                                </div><!-- comment -->
                                <!-- <div class="col-lg-12 col-xs-12 ">
                                    <div class="col-lg-3 "></div>
                                    <div class="col-lg-3 "></div>
                                    <div class="col-lg-4 col-xs-7  text-right">
                                        <label class="label-control marg">Add GST</label>
                                    </div>
                                    <div class="col-lg-2 col-xs-5 ">
                                        <input type="number" step="any" name="addgst" required="true" class="form-control form text-right addgst " value="<?php Echo ($addflag != 1) ? $get['addgst'] : "0"; ?>">
                                    </div>
                                </div> -->

                                <div class="col-lg-12 col-xs-12 ">
                                    <div class="col-lg-3 "></div>
                                    <div class="col-lg-3 "></div>
                                    <div class="col-lg-4 col-xs-7 pad text-right">
                                        <label class="label-control marg">Net Amount</label>
                                    </div>
                                    <div class="col-lg-2 col-xs-5">
                                        <input type="number" step="any" name="totbillamt" required="true" class="form-control form text-right tottotal totbillamt" value="<?php Echo ($addflag != 1) ? $get['billamt'] : "0"; ?>" readonly tabindex="-1">
                                    </div>
                                </div>

                            </div>
                            <div class="modal fade" id="modelWindow" role="dialog">
                                <div class="modal-dialog modal-lg vertical-align-center">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                            &nbsp;
                                        </div>
                                        <div class="modal-body">
                                            <div class="table-responsive tbody2">

                                            </div>

                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" data-dismiss="modal" class="form btn btn-default pursave">Save</button>
                                        </div>
                                    </div>
                                </div>
                            </div>


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

                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-2 col-xs-3 pad text-left">
                                    <label class="label-control marg">Packed By</label>
                                </div>
                                <div class="col-lg-4 col-xs-7 pad">
                                    <input type="text" name="packby" class="form-control form packby" value="<? Echo ($addflag != 1) ? $get["packby"] : ""; ?>" tabindex="-1">
                                </div>
                            </div>
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-2 col-xs-3 pad text-left">
                                    <label class="label-control marg">Remarks</label>
                                </div>
                                <div class="col-lg-6 col-xs-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-2 col-xs-3 pad text-right"></div>
                                <div class="col-lg-6 col-xs-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>
                </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"); ?>
                            <script>
                                $(document).ready(function () {

                                    var usertype = <?= $usertype ?>;
                                    if (usertype == 3) {
                                        $("#hedit").hide();
                                    }
                                });
                            </script>
                        </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 itemModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span>&times;</span></button>
                    <h4 class="modal-title" id="myLargeModalLabel">Search <? Echo $formname; ?></h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" value="<?php // Echo $fseries                                                                                                       ?>" class="form-control series">
                    <input type="hidden" value="<?php Echo $get['vouchno']; ?>" class="form-control vouchno">
                    <input type="hidden" value="<?php Echo $file ?>" class="form-control file">
                    <!--<input type="hidden" value="<?php Echo $para ?>" class="form-control para">-->
                    <div class="row">
                        <div class="col-lg-3">
                            <select class="form-control ifield">
                                <option value="1">Name</option>
                                <option value="2">Barcode</option>
                                <option value="3">Itemcode</option>
                                <!--                            <option value="4">Gram</option>
                                                            <option value="5">Unit</option>-->
                            </select>
                        </div>
                        <div class="col-lg-2">
                            <select class="form-control ioperator">
                                <option value=""></option>
                                <option value="%">Like</option>
                                <option value="=">Exactly</option>
                            </select>
                        </div>
                        <div class="col-lg-4">
                            <input type="text" value="" class="form-control isearch">
                        </div>
                        <div class="col-lg-3">
                            <input type="button" class="btn btn-primary iload" value="Search">
                        </div>
                    </div>

                    <div class="col-lg-12 iloader text-center">
                        <img src="images/search.gif" alt="loading">       
                    </div>
                    <div class="col-lg-12 inoRecord text-center">
                        <h3>NO RECORDS FOUND</h3>
                    </div>
                    <div class="table-responsive" style="max-height: 400px;overflow: auto;">
                        <table id="" class="table table-striped table-condensed table-bordered" width="100%">
                            <thead>
                                <tr class="mySearchTr">
                                    <th width="15%">Itemcode</th>
                                    <th width="49%">Name</th>
                                    <th width="8%">Stock</th>
    <!--                                <th width="17%">Barcode</th>
                                    <th width="8%">Gram</th>
                                    <th width="8%">Unit</th>-->
                                    <th width="8%">Rate</th>
                                </tr>
                            </thead>
                            <tbody class="iTbody">
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 text-right search-action-bar">
                            <input type="button"  class="btn btn-primary iprevious" value="Previous">
                            <input type="button"  class="btn btn-primary inext" value="Next">
                        </div>
                    </div>
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
    <div class="modal fade searchModal bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg" style="margin-top: 15%">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span>&times;</span></button>
                    <h4 class="modal-title" id="myLargeModalLabel">Search <? Echo $formname; ?></h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" value="<?php Echo $fseries ?>" class="form-control series">
                    <input type="hidden" value="<?php Echo $get['vouchno']; ?>" class="form-control vouchno">
                    <input type="hidden" value="<?php Echo $file ?>" class="form-control file">
                    <input type="hidden" value="S" class="form-control parasrch">
                    <div class="row">
                        <div class="col-lg-2">
                            <select class="form-control sfield">
                                <option value="1">Supplier</option>
                                <option value="4">Voucher No.</option>
                                <option value="2">Invoice 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">Supplier</option>
                                <option value="1">Voucher No.</option>
                                <option value="2">Invoice 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 No.</th>
                                    <th width="10%">Invoice No.</th>
                                    <th width="15%">Date</th>
                                    <th width="20%">Supplier</th>
                                    <!--<th width="10%">Mobile</th>-->
                                    <th width="15%">Amount</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>
