<?php
ob_start();
//echo "1";
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');
//browse(1);
$maindb = 'purfuelmain';
$trandb = 'purfueltran';
$accdb = 'actran';
$stkdb = 'transacn';
$printfile = "purfuel_print.php";
$file = 'purfuel.php';
$trandbexist = 1;
$source = "PUF";
$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('Work in progress...');

$formname = 'Purchase Fuel';

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

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

if (isset($_POST["submit"])) {
    $a = 1;

    $vouchdt = trim($_POST["vouchdt"]);
    $voucher = trim($_POST["voucher"]);
    $mono = $_POST["monno"];
    $party = $_POST["party"];
    $billno = $_POST["billno"];
    $purtype = $_POST["purtype"];
    $type = $_POST["type"];
    $matamt = $_POST["matamt"];
    $labamt = $_POST["labamt"];
    $tdsamt = $_POST["tdsamt"];
    $subtot = $_POST["subtot"];
    $totdisc = $_POST["totdisc"];
    $cdperc = $_POST["cdperc"];
    $cdamt = $_POST["cdamt"];
    $totvat = $_POST["totvat"];
    $tottcs = $_POST["tottcs"];
    $totvatadd = $_POST["totvatadd"];
    $licenfee = $_POST["licenfee"];
    $dealcomm = $_POST["dealcomm"];
    $othchgs = $_POST["othchgs"];
    $billamt = $_POST["billamt"];
    $rem1 = trim($_POST["rem1"]);
    $rem2 = trim($_POST["rem2"]);

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

    $oms = $_POST['oms'];

    $count = $_POST["items"];
    $mvouch = $qvouch;
    $paidby = $type;
    if ($paidby == "R") {
        $purcode = '12';
    } else {
        $purcode = '11';
    }

    $accode = $party;
    $grpcode = '009';

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

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

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

    if ($a == 1) {

        $time = strtotime($vouchdt);
        $mono = date("n", $time);

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

            $intmonth = intval($mono);
            if ($intmonth < 10) {
                $intmonth = '0' . $intmonth;
            }
            $voucher = $intmonth . $mvouch;
        }

        //**************************************************    auto cash Entry Start  ***************************************

        $mcashvouch = $_POST["cashvouch"];

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

        //        browse($mcashvouch);
        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 = $billamt;
            }

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

            $getbankinit = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode` = '3'");
            $fetinit = mysqli_fetch_array($getbankinit);
            $binit = $fetinit['bankinit'];




            // cash part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, recpno, trnno, bankinit, accode,  grpcode, amount)
                    VALUES ('$vouchdt','$mcashvouch', 'CP', '$mrecpno',  '001', '$binit', '3', '002', '$recpamt')");

            // party part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, recpno, trnno, bankinit, accode, grpcode, amount)
                     VALUES ('$vouchdt','$mcashvouch', 'CP', '$mrecpno', '002', '$binit', '$accode',  '$pgrp', '$minus_amt')");
        } 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));

        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"];
            $prodtype = $_POST["prodtype_$i"];
            $mprodcode = mysqli_real_escape_string($conn, $_POST["prodcode_$i"]);
            $particulars = $_POST["particulars_$i"];
            $unit = $_POST["unit_$i"];
            $qty = $_POST["qty_$i"];
            $freeqty = $_POST["freeqty_$i"];
            $totalqty = $_POST["totalqty_$i"];
            $tcsamt = $_POST["tcsamt_$i"];
            $amt = $_POST["amount_$i"];
            $discperc = $_POST["discperc_$i"];
            $discamt = $_POST["discount_$i"];
            $vat = $_POST["vat_$i"];
            $vatadd = $_POST["vatadd_$i"];
            $total = $_POST["total_$i"];

            if (!empty($prodtype)) {
                $cnt++;
                $group = $source . $mvouch;
                //                $tcartqty = $cartqty * 1;
                $tqty = $qty;
                if ($qty > 0) {
                    $rate = round($amt / $qty, 0);
                } else {
                    $rate = 0;
                }
                $cost = $rate;

                mysqli_query($conn, "INSERT INTO `$trandb`(vouchno, vouchdt, srno, prodtype, prodcode, particulars,unit,qty,freeqty,totalqty,
                                                           tcsamt,amount,discperc,discount,vat,vatadd,total)
                                                    VALUES('$mvouch', '$vouchdt', '$cnt', '$prodtype','$mprodcode','$particulars','$unit','$qty',
                                                           '$freeqty','$totalqty','$tcsamt','$amt','$discperc','$discamt',
                                                           '$vat','$vatadd','$total')") or die(mysqli_error($conn));

                mysqli_query($conn, "INSERT INTO `$stkdb`(`srno`, `yearno`, `vouchno`, `vouchdt`, `prodcode`, `qty`, rate, godown, 
                                                  `source`, amount, accode, `group` , `cost`, `itemgrp`, `ordno`, `monno`)
                                     VALUES('$cnt', '$myyear', '$mvouch', '$vouchdt', '$mprodcode',  '$totalqty', '$rate','$godown',
                                                   '$source', '$amt', '$party', '$group', '$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 ($billamt > 0) {
            $minus_amt = ($billamt * -1);
            $m_matamt = $matamt * -1;
            $m_labamt = $labamt * -1;
            $m_tcs = $tcsamt * -1;
            $m_vat = ($vat + $vatadd) * -1;
            $m_licen = $licenfee * -1;
            $m_othchgs = $othchgs * -1;

            if ($matamt > 0) {
                // purchase part
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                            VALUES ('$vouchdt','$mvouch', '$source', '001', '$purcode','004', '$m_matamt') ") or die(mysqli_error($conn));
            } if ($labamt > 0) {

                // labour part
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                            VALUES ('$vouchdt','$mvouch', '$source', '002', '9','012', '$m_labamt') ") or die(mysqli_error($conn));
            } if ($tcsamt > 0) {

                // tcs part
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                            VALUES ('$vouchdt','$mvouch', '$source', '003', '33','020', '$m_tcs') ") or die(mysqli_error($conn));
            } if ($vat + $vatadd > 0) {

                // vat part
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                            VALUES ('$vouchdt','$mvouch', '$source', '004', '5','020', '$m_vat') ") or die(mysqli_error($conn));
            } if ($dealcomm > 0) {

                // deal comm part
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                            VALUES ('$vouchdt','$mvouch', '$source', '005', '29','011', '$dealcomm') ") or die(mysqli_error($conn));
            } if ($licenfee > 0) {

                // licen fee part
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                            VALUES ('$vouchdt','$mvouch', '$source', '006', '30','012', '$m_licen') ") or die(mysqli_error($conn));
            } if ($othchgs > 0) {

                // other charges part
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                            VALUES ('$vouchdt','$mvouch', '$source', '007', '26','012', '$m_othchgs') ") or die(mysqli_error($conn));
            } if ($billamt > 0) {

                // party part
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                                VALUES ('$vouchdt','$mvouch', '$source', '008', '$party','$pgrp', '$billamt') ") or die(mysqli_error($conn));
            } if ($discamt > 0) {

                // discount part
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                                VALUES ('$vouchdt','$mvouch', '$source', '009', '1','011', '$discamt') ") or die(mysqli_error($conn));
            }
            if ($tdsamt > 0) {
                // tds part
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount,type)
                                VALUES ('$vouchdt','$mvouch', '$source', '010', '4','020', '$tdsamt','T') ") or die(mysqli_error($conn));
                // tds party part
                $m_tds = $tdsamt * -1;
                mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount,type)
                                VALUES ('$vouchdt','$mvouch', '$source', '011', '$party','$pgrp', '$m_tds', 'T') ") or die(mysqli_error($conn));
            }
        }

        if ($addflag == 1) {
            mysqli_query($conn, "INSERT INTO `$maindb`(vouchno, `vouchdt`,  `party`, `billno`,`purtype`, `type`,`matamt`,labamt,tdsamt,cashvouch,
                                                  subtot,totdisc,cdperc,cdamt,tottcs,totvatadd,totvat,licenfee,dealcomm,othchgs,billamt,rem1,rem2)
                                      VALUES('$mvouch', '$vouchdt', '$party', '$billno','$purtype', '$type','$matamt','$labamt','$tdsamt','$mcashvouch',
                                             '$subtot','$totdisc','$cdperc','$cdamt','$tottcs','$totvatadd','$totvat','$licenfee','$dealcomm','$othchgs','$billamt','$rem1','$rem2')") or die(mysqli_error($conn));

            //            $_SESSION['print_voucher'] = $mvouch;
        } else {
            mysqli_query($conn, "UPDATE `$maindb` SET  `vouchdt`='$vouchdt',  `party`='$party', `billno`='$billno', `purtype`='$purtype', `type`='$type',`matamt`='$matamt',`labamt`='$labamt',
                                 `tdsamt` = '$tdsamt',subtot = '$subtot',totdisc ='$totdisc',cdperc = '$cdperc',cdamt = '$cdamt',tottcs = '$tottcs',totvatadd='$totvatadd',totvat ='$totvat',
                                 `licenfee` ='$licenfee', dealcomm = '$dealcomm' ,othchgs = '$othchgs',billamt = '$billamt' , rem1 = '$rem1' , rem2 ='$rem2',cashvouch='$mcashvouch'   WHERE `vouchno` = '$mvouch' ") or die(mysqli_error($conn));
        }

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

if ($addflag != 1) {

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

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

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

    $delcsh = $get['cashvouch'];
}

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/purfuel.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>
<script src="MyScript/purfuel_search.js" type="text/javascript"></script>
<!--<script src="MyScript/search_item_sale.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>-->
<script src="MyScript/checkdate.js" type="text/javascript"></script>
<!--<script>
    $(document).ready(function () {
      
    })
</script>-->

</head>

<body>
    <form action='' method='POST'>
        <div class="col-lg-3 pad text-center" id="overlay_form" style="display:none;z-index:999;">
            <button type="button" id="close_form" style="float: right;font-weight: bold;font-size: 18px;color:red;"><i class="fa fa-close"></i></button>
            <div style='width:100%;' id='browdata'>
            </div>
        </div>
        <!-- Default box -->
        <div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12  pad">
                <div class="panel panel-default">
                    <div class="panel-heading" style="height:40px">
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-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="cashvouch" id="cashvouch" value='<?php echo ($addflag != 1) ? $get['cashvouch'] : ""; ?>'>

                            </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-2 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>
                        <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">Party Name</label>
                            </div>
                            <div class="col-lg-4 col-md-3 col-sm-7 col-xs-9  pad">
                                <select name="party" class="form-control form party select2">
                                    <option value="<?php echo ($addflag != 1) ? $lparty['accode'] : ""; ?>"><?php echo ($addflag != 1) ? $lparty['name'] : ""; ?></option>
                                    <?php
                                    $getcust = mysqli_query($conn, "SELECT accode,name FROM accmast WHERE grpcode = '009' ") or die(mysqli_error($conn));
                                    while ($trow = mysqli_fetch_array($getcust)) {
                                        echo "<option value='$trow[accode]'>$trow[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>

                        <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">Invoice No.</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-4 pad">
                                <input type="text" name="billno" class="form-control form billno" id="billno" value="<?php echo ($addflag != 1) ? $get['billno'] : "" ?>">
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Type</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-4 pad">
                                <select name="type" class="form-control form select2">
                                    <option></option>
                                    <option <?php
                                    if ($get['type'] == 'R') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="R">Credit</option>
                                    <option <?php
                                    if ($get['type'] == 'C') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="C">Cash</option>



                                </select>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Purchase Type</label>
                            </div>
                            <div class="col-lg-2 col-md-1 col-sm-3 col-xs-4 pad">
                                <select name="purtype" class="form-control form select2">
                                    <option></option>
                                    <option <?php
                                    if ($get['purtype'] == 'CF') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="CF">Co. Fuel</option>
                                    <option <?php
                                    if ($get['purtype'] == 'CL') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="CL">Co. Lubes</option>
                                    <option <?php
                                    if ($get['purtype'] == 'OL') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="OL">Other Lubes</option>
                                    <option <?php
                                    if ($get['purtype'] == 'AC') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="AC">Accessories</option>
                                    <option <?php
                                    if ($get['purtype'] == 'FA') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="FA">Fixed Asset</option>
                                    <option <?php
                                    if ($get['purtype'] == 'OT') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="OT">Others</option>
                                </select>
                            </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.</th>
                                        <th style="width: 3%">#</th>
                                        <th style='width: 3%' class="text-left">Prodcode</th>
                                        <th style='width: 14%' class="text-left">Particulars</th>
                                        <th style='width: 5%' class="text-center">Unit</th>
                                        <th style='width: 5%' class="text-right">Qty.</th>
                                        <th style='width: 5%' class="text-right">Free Qty.</th>
                                        <th style='width: 5%' class="text-right">Total Qty.</th>
                                        <th style='width: 5%' class="text-right">TCS. Amt.</th>
                                        <th style='width: 5%' class="text-right">Amount</th>
                                        <th style='width: 5%' class="text-right">Discperc</th>
                                        <th style='width: 5%' class="text-right">Discount</th>
                                        <th style='width: 5%' class="text-right">V.A.T.</th>
                                        <th style='width: 5%' class="text-right">VAT Addl.</th>
                                        <th style='width: 5%' class="text-right">Total</th>


                                    </tr>
                                </thead>
                                <tbody class="tbody">
                                    <?php
                                    if ($addflag != 1) {
                                        $qry = mysqli_query($conn, "SELECT * FROM  `$trandb` WHERE `vouchno`='$get[vouchno]' ORDER BY srno") or die(mysqli_error($conn));
                                        $ctr = 0;
                                        $mctr = $ctr;
                                        $mctr++;
                                        while ($row = mysqli_fetch_array($qry)) {
                                            if ($row['prodtype'] == "P") {
                                                $getpd = mysqli_query($conn, "SELECT * FROM `product` WHERE `prodcode`= '$row[prodcode]'") or die(mysqli_error($conn));
                                                $lpd = mysqli_fetch_array($getpd);
                                                $disp = "style=display:none";
                                                $disp1 = "";
                                            } else {
                                                $disp1 = "style=display:none";
                                                $disp = "";
                                            }

                                            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 text-right form' value='$row[srno]'></td>";
                                            echo "<td>";
                                            echo "<select class='form-control form prodtype' name='prodtype_$ctr'>";
                                            echo "<option value='$row[prodtype]'>$row[prodtype]</option>";
                                            echo "<option value='P'>P</option>";
                                            echo "<option value='L'>L</option>";
                                            echo "</select>";
                                            echo "</td>";
                                            echo "<td><input type='text' class='form-control form prodcode' name='prodcode_$ctr' value='$row[prodcode]'></td>";
                                            echo "<td $disp1 class='prodtd'>";
                                            echo "<select class='form-control form particulars' name=''>";
                                            echo "<option value='$row[prodcode]'>$lpd[name]</option>";
                                            $getpd1 = mysqli_query($conn, "SELECT * FROM `product` order by name") or die(mysqli_error($conn));
                                            while ($row1 = mysqli_fetch_array($getpd1)) {
                                                echo "<option value='$row1[prodcode]'>$row1[name]</option>";
                                            }
                                            echo "</select>";
                                            echo "</td>";


                                            echo "<td $disp class='parttd'><input type='text' class='form-control form particulars' name='particulars_$ctr' value='$row[particulars]' ></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 qty' name='qty_$ctr' value='$row[qty]'></td>";
                                            echo "<td><input type='text' class='form-control form text-right freeqty' name='freeqty_$ctr' value='$row[freeqty]'></td>";
                                            echo "<td><input type='text' class='form-control form text-right totalqty' name='totalqty_$ctr' value='$row[totalqty]' ></td>";
                                            echo "<td><input type='text' class='form-control form text-right tcsamt' name='tcsamt_$ctr' value='$row[tcsamt]'></td>";
                                            echo "<td><input type='text' class='form-control form text-right amount' name='amount_$ctr' value='$row[amount]'></td>";
                                            echo "<td><input type='text' class='form-control form text-right disperc' name='discperc_$ctr' value='$row[discperc]'></td>";
                                            echo "<td><input type='text' class='form-control form text-right discamt' name='discount_$ctr' value='$row[discount]'></td>";
                                            echo "<td><input type='text' class='form-control form text-right vat' name='vat_$ctr' value='$row[vat]'></td>";
                                            echo "<td><input type='text' class='form-control form text-right vatadd' name='vatadd_$ctr' value='$row[vatadd]'></td>";
                                            echo "<td><input type='text' class='form-control form text-right total' name='total_$ctr' value='$row[total]' readonly tabindex='-1'></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>
                                                <select class='form-control form prodtype' name='prodtype_0'>
                                                    <option value=''></option>;
                                                    <option value='P'>P</option>
                                                    <option value='L'>L</option>
                                                </select>
                                            </td>
                                            <td><input type='text' name='prodcode_0' class='prodcode form-control form' value=''></td>
                                            <td style="display:none" class='prodtd'>
                                                <select class='form-control form particulars' name=''>
                                                    <option value=''></option>
                                                    <?php
                                                    $getpd1 = mysqli_query($conn, "SELECT * FROM `product` order by name") or die(mysqli_error($conn));
                                                    while ($row1 = mysqli_fetch_array($getpd1)) {
                                                        echo "<option value='$row1[prodcode]'>$row1[name]</option>";
                                                    }
                                                    ?>
                                                </select>
                                            </td>
                                            <td class='parttd'><input type='text' name='particulars_0' class='particulars form-control form' value=''></td>
                                            <td><input type='text' name='unit_0' class='unit form-control form' value=''></td>
                                            <td><input type='text' name='qty_0' class='qty text-right form-control form' value='0'></td>
                                            <td><input type='text' name='freeqty_0' class='freeqty text-right form-control form' value='0'></td>
                                            <td><input type='text' name='totalqty_0' class='totalqty text-right form-control form' value='0'></td>
                                            <td><input type='text' name='tcsamt_0' class='tcsamt text-right form-control form' value='0'></td>
                                            <td><input type='text' name='amount_0' class='amount text-right form-control form' value='0'></td>
                                            <td><input type='text' name='disperc_0' class='disperc text-right form-control form' value='0'></td>
                                            <td><input type='text' name='discount_0' class='discamt text-right form-control form' value='0'></td>
                                            <td><input type='text' name='vat_0' class='vat text-right form-control form' value='0'></td>
                                            <td><input type='text' name='vatadd_0' class='vatadd text-right form-control form' value='0'></td>
                                            <td><input type='text' name='total_0' class='total text-right form-control form' value='0' readonly tabindex='-1'></td>
                                        </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-3 pad"></div>
                                <div class="col-lg-3 pad"></div>
                                <div class="col-lg-4 col-xs-7 pad text-right">
                                    <label class="label-control marg">Material Amount</label>
                                </div>
                                <div class="col-lg-2 col-xs-5 pad">
                                    <input type="number" step="any" name="matamt" class="form-control form text-right  matamt" value="<?php echo ($addflag != 1) ? $get['matamt'] : "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-4 col-xs-7 pad text-right">
                                    <label class="label-control marg">Labour Amount</label>
                                </div>
                                <div class="col-lg-2 col-xs-5 pad">
                                    <input type="number" step="any" name="labamt" class="form-control form text-right  labamt" value="<?php echo ($addflag != 1) ? $get['labamt'] : "0"; ?>" readonly tabindex="-1">
                                </div>
                            </div>

                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-4 pad"></div>
                                <div class="col-lg-4 col-xs-5 pad text-right">
                                    <label class="label-control marg text-right">TDS on Basic</label>
                                </div>
                                <div class="col-lg-1 col-xs-3 pad">
                                    <input type="number" step="any" name="tdsamt" class="form-control form text-right tdsamt" style="background-color: cyan;" value="<?php echo ($addflag != 1) ? $get['tdsamt'] : "0"; ?>" readonly tabindex="-1">
                                </div>
                                <div class="col-lg-1 col-xs-1 pad text-right">
                                    <label class="label-control marg">Subtotal</label>
                                </div>
                                <div class="col-lg-2 col-xs-3 pad">
                                    <input type="number" step="any" name="subtot" class="form-control form text-right subtot" value="<?php echo ($addflag != 1) ? $get['subtot'] : "0"; ?>" readonly tabindex="-1">
                                </div>
                            </div>
                            <!-- comment -->

                            <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-4 col-xs-7 pad text-right">
                                    <label class="label-control marg">Less Item Discount</label>
                                </div>
                                <div class="col-lg-2 col-xs-5 pad">
                                    <input type="number" step="any" name="totdisc" class="form-control form text-right totdisc" value="<?php echo ($addflag != 1) ? $get['totdisc'] : "0"; ?>" readonly tabindex="-1">
                                </div>
                            </div>

                            <!--                            <div class="col-lg-5 pad"></div>
                                                        <div class="col-lg-3 col-xs-5 pad text-right">
                                                            <label class="label-control marg text-right">Less Discount</label>
                                                        </div>
                                                        <div class="col-lg-1 col-xs-3 pad">
                                                            <input type="number" step="any" name="cdperc" class="form-control form text-right cdperc" value="<?php echo ($addflag != 1) ? $get['cdperc'] : "0"; ?>" readonly tabindex="-1">
                                                        </div>
                                                        <div class="col-lg-1 col-xs-1 pad text-right">
                                                            <label class="label-control marg">%</label>
                                                        </div>
                                                        <div class="col-lg-2 col-xs-3 pad">
                                                            <input type="number" step="any" name="cdamt" class="form-control form text-right cdamt" value="<?php echo ($addflag != 1) ? $get['cdamt'] : "0"; ?>">    
                                                        </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-4 col-xs-7 pad text-right">
                                    <label class="label-control marg">Add TCS</label>
                                </div>
                                <div class="col-lg-2 col-xs-5 pad">
                                    <input type="number" step="any" name="tottcs" class="form-control form text-right tottcs" value="<?php echo ($addflag != 1) ? $get['tottcs'] : "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-4 col-xs-7 pad text-right">
                                    <label class="label-control marg">Add VAT%</label>
                                </div>
                                <div class="col-lg-2 col-xs-5 pad">
                                    <input type="number" 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 pad">
                                <div class="col-lg-3 pad"></div>
                                <div class="col-lg-3 pad"></div>
                                <div class="col-lg-4 col-xs-7 pad text-right">
                                    <label class="label-control marg">Add VAT Addl.</label>
                                </div>
                                <div class="col-lg-2 col-xs-5 pad">
                                    <input type="number" step="any" name="totvatadd" class="form-control form text-right totvatadd" value="<?php echo ($addflag != 1) ? $get['totvatadd'] : "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-4 col-xs-7 pad text-right">
                                    <label class="label-control marg">Add License Fee</label>
                                </div>
                                <div class="col-lg-2 col-xs-5 pad">
                                    <input type="number" step="any" name="licenfee" class="form-control form text-right licenfee" value="<?php echo ($addflag != 1) ? $get['licenfee'] : "0"; ?>">
                                </div>
                            </div>
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-3 pad"></div>
                                <div class="col-lg-3 pad"></div>
                                <div class="col-lg-4 col-xs-7 pad text-right">
                                    <label class="label-control marg">Less Dealer's Comm.</label>
                                </div>
                                <div class="col-lg-2 col-xs-5 pad">
                                    <input type="number" step="any" name="dealcomm" class="form-control form text-right dealcomm" value="<?php echo ($addflag != 1) ? $get['dealcomm'] : "0"; ?>">
                                </div>
                            </div>
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-3 pad"></div>
                                <div class="col-lg-3 pad"></div>
                                <div class="col-lg-4 col-xs-7 pad text-right">
                                    <label class="label-control marg">Other Chgs.</label>
                                </div>
                                <div class="col-lg-2 col-xs-5 pad">
                                    <input type="number" step="any" name="othchgs" class="form-control form text-right othchgs" value="<?php echo ($addflag != 1) ? $get['othchgs'] : "0"; ?>">
                                </div>
                            </div>
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-3 pad"></div>
                                <div class="col-lg-3 pad"></div>
                                <div class="col-lg-4 col-xs-7 pad text-right">
                                    <label class="label-control marg">Net Amount(Rs.)</label>
                                </div>
                                <div class="col-lg-2 col-xs-5 pad">
                                    <input type="number" step="any" name="billamt" class="form-control form text-right billamt" value="<?php echo ($addflag != 1) ? $get['billamt'] : "0"; ?>" readonly tabindex="-1">
                                </div>
                            </div>

                        </div>


                        <div class="row">
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-3 text-right pad">
                                <label class="label-control marg">Narration</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-9 col-xs-9  pad">
                                <input type="text" class="form-control form" name="rem1" value="<?php echo ($addflag != 1) ? $get["rem1"] : ""; ?>" >
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-3 text-right pad">
                                <label class="label-control marg"></label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-9 col-xs-9  pad">
                                <input type="text" class="form-control form" name="rem2" value="<?php echo ($addflag != 1) ? $get["rem2"] : ""; ?>">
                            </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>
                                        <h4 class="modal-title">Purchase</h4>
                                    </div>
                                    <div class="modal-body">
                                        <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.</th>
                                                        <th style='width: 20%' class="text-left">Supplier</th>
                                                        <th style='width: 5%'>Bill No</th>
                                                        <th style="width: 5%;">Bill Date</th>
                                                        <th style='width: 5%' class="text-right">Qty</th>
                                                        <th style='width: 9%' class="text-right">Cost</th>
                                                        <th style='width: 10%' class="text-right">Amount</th>
                                                    </tr>
                                                </thead>
                                                <tbody class="tbody2">
                                                    <?php
                                                    //                                                        if ($addflag != 1) {
                                                    //                                                            $qry = mysqli_query($conn, "SELECT * FROM  `salepurch` WHERE vouchno='$getvouch' ORDER BY srno") or die(mysqli_error($conn));
                                                    //                                                            $ctr = 0;
                                                    //                                                            while ($row = mysqli_fetch_array($qry)) {
                                                    //                                                                
                                                    //                                                            $sup = mysqli_query($conn, "SELECT accode,name FROM `accmast` WHERE `code`='$row[itemcode]'") or die(mysqli_error($conn));
                                                    //                                                            $fsup = mysqli_fetch_array($sup);
                                                    //                                                                
                                                    //                                                                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 "<select class='form-control form supplier select2' name='supplier_$ctr' style='width:100%'>";
                                                    //                                                                Echo "<option value='$fsup[code]'>$fsup[name]</option>";
                                                    //                                                                $gsupplier = mysqli_query($conn, "SELECT accode,name FROM `accmast` WHERE grpcode='009' order by name")or die(mysqli_error($conn));
                                                    //                                                                while ($supplier = mysqli_fetch_array($gsupplier)) {
                                                    //                                                                Echo "<option value='$supplier[code]'>$supplier[name]</option>";
                                                    //                                                                }
                                                    //                                                                Echo "</select>";
                                                    //                                                                Echo "</td>";
                                                    //                                                                
                                                    ////                                                                Echo "<td><input type='text' class='form-control form text-right supplier'     name='supplier_$ctr' value='$row[supplier]'></td>";
                                                    //                                                                Echo "<td><input type='text' class='form-control form billno'               name='billno_$ctr'  value='$row[billno]'></td>";
                                                    //                                                                Echo "<td><input type='date' class='form-control form billdate'            name='billdate_$ctr'  value='$row[billdate]'></td>";
                                                    //                                                                Echo "<td><input type='text' class='form-control form text-right purqty'    name='purqty_$ctr'  value='$row[purqty]'></td>";
                                                    //                                                                Echo "<td><input type='text' class='form-control form text-right purcost'    name='purcost_$ctr'  value='$row[purcost]'></td>";
                                                    //                                                                Echo "<td><input type='text' class='form-control form text-right puramt'  name='puramt_$ctr'  value='$row[puramt]' ></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='supplier_0' class='supplier form-control form' value='' ></td>
                                                            <td><input type='text' name='billno_0' class='billno form-control form' value='' ></td>
                                                            <td><input type='date' name='billdate_0' class='billdate form-control form' value='' ></td>
                                                            <td><input type='text' name='purqty_0' class='purqty form-control form' value='' ></td>
                                                            <td><input type='text' name='purcost_0' class='purqty form-control form' value='' ></td>
                                                            <td><input type='text' name='puramt_0' class='puramt form-control form' value='' ></td>
                                                        </tr>-->
                                                    <?php
                                                    //                                                        }
                                                    ?>
                                                    <!--<input type="hidden" id="itemspur" name="itemspur" value="<?php echo ($addflag != 1) ? $ctr : 1; ?>">-->

                                                </tbody>
                                            </table>
                                        </div>

                                    </div>
                                    <div class="modal-footer">
                                        <div class="col-lg-1 pad">
                                            <button type="button" class="btn btn-primary btn-square form" id="puradd">
                                                <i class="fa fa-plus" data-toggle='tooltip' title='Add Row'></i>
                                            </button>
                                        </div>

                                        <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 bs-example-modal-lg searchModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal"><span>&times;</span></button>
                <h4 class="modal-title" id="myLargeModalLabel">Search <? echo $formname; ?></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-lg-2">
                        <select class="form-control sfield">
                            <option value="1">Voucher</option>
                            <option value="2">Date</option>
                            <option value="3">Party Name</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control soperator">
                            <option value="">Type of Search</option>
                            <option value="%">Like</option>
                            <option value="=">Exactly</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control sortBy">
                            <option value="">Sort By</option>
                            <option value="1">Voucher</option>
                            <option value="2">Date</option>
                            <option value="3">Party Name</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control orderAs">
                            <option value="asc">Asc</option>
                            <option value="desc">Desc</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <input type="text" value="" class="form-control ssearch" placeholder="Search Here">
                    </div>
                    <div class="col-lg-2">
                        <input type="button" class="btn btn-primary sload" value="Search">
                    </div>
                </div>
                <div class="col-lg-12 sloader text-center">
                    <!--<img src="images/search.gif" alt="loading">-->
                </div>
                <div class="col-lg-12 snoRecord text-center">
                    <h3>NO RECORDS FOUND</h3>
                </div>
                <div class="table-responsive" style="max-height: 400px;overflow: auto;">
                    <table id="" class="table table-striped table-condensed table-bordered" width="100%">
                        <thead>
                            <tr style="background-color:#1ABC9C;">
                                <th width="20%">Voucher No </th>
                                <th width="50%">Voucher Date</th>
                                <th width="25%">Party Name</th>
                                <th width="5%">Action</th>
                            </tr>
                        </thead>
                        <tbody class="sTbody">
                        </tbody>
                    </table>
                </div>
                <div class="row">
                    <div class="col-xs-12 text-right search-action-bar">
                        <input type="button" class="btn btn-primary sprev" value="Previous">
                        <input type="button" class="btn btn-primary snext" value="Next">
                    </div>
                </div>
            </div>
            <div class="modal-footer"></div>
        </div>
    </div>
</div>
<?php include("includes/linksfoot.php"); ?>
</body>

</html>