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

$maindb = 'pricelocmain';
$trandb = 'priceloctran';
$printfile = "price_print.php";
$file = 'pricelocal.php';
$trandbexist = 1;
$keyfld = "vouchno";
$myyear = $_SESSION["tit_" . $dbname];
date_default_timezone_set('Asia/Kolkata');
$time = date('H:i:s');

$zroot = $_SESSION["zdbroot"];

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

$formname = 'Price Local';
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

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




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


    $a = 1;
    $vouchdt = trim($_POST["vouchdt"]);
    $voucher = trim($_POST["voucher"]);
    $mono = trim($_POST["mono"]);
    $count = $_POST["items"]; 

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

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

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

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


    if ($a == 1) {

        mysqli_query($conn, "LOCK TABLES $zroot.`$maindb` WRITE, $zroot.`$trandb` WRITE, `product` WRITE");

        if ($addflag == 1) {
            $gen1 = mysqli_query($conn, "SELECT MAX(vouchno+0) AS maxcode FROM $zroot.$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;
        }
        $mvouch = $qvouch;






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

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


        for ($i = 0; $i <= $count; $i++) {
            $cnt++;
            $msrno = $_POST["srno_$i"];
            $mbarcode = $_POST["barcode_$i"];
            $rate = $_POST["rate_$i"];
            $mitemcode = $_POST["itemcode_$i"];
            $hsncode = $_POST["hsncode_$i"];
            $subtot = $_POST["subtot_$i"];
            $gram = $_POST["gram_$i"];
            $mrp = $_POST["mrp_$i"];
            $wh_dz = $_POST["wh_dz_$i"];
            $innpkgbox = $_POST["innpkgbox_$i"];
            $innunit = $_POST["innunit_$i"];
            $mastunit = $_POST["mastunit_$i"];
            $mastpkgbox = $_POST["mastpkgbox_$i"];




            if (!empty($mbarcode)) {
             
                mysqli_query($conn, "INSERT INTO $zroot.`$trandb`(`srno`, `vouchno`, `barcode`, `itemcode`, `hsncode`, `subtot`, `rate`, 
                                                            `gram`, `mrp`, `wh_dz`, `innpkgbox`, `mastpkgbox`,innunit,mastunit)
                                                   VALUES('$cnt', '$mvouch', '$mbarcode', '$mitemcode', '$hsncode', '$subtot', '$rate',
                                                             '$gram', '$mrp', '$wh_dz', '$innpkgbox', '$mastpkgbox','$innunit','$mastunit')") or die(mysqli_error($conn));

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


        if ($addflag == 1) {
          
            mysqli_query($conn, "INSERT INTO $zroot.`$maindb`(`username`, vouchno, `vouchdt`, `voucher`, `monno`, `rem1`, `rem2`)
                                               VALUES('$username', '$mvouch', '$vouchdt', '$voucher', '$mono', '$rem1', '$rem2')") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "UPDATE $zroot.`$maindb` SET `vouchdt`='$vouchdt', `voucher`='$voucher', `monno`='$mono', `rem1`='$rem1', `rem2`='$rem2'  WHERE `vouchno` = '$mvouch' ") or die(mysqli_error($conn));
            // updmess();
            
            header("refresh: 1; $file?mode=last");
        }
        
        mysqli_query($conn, "UNLOCK TABLES");
    }
}

if ($addflag != 1) {

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

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

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

    $delcond = "vouchno = '$_GET[vouchno]'";

    delnew($zroot,"$maindb", "$delcond", "$file?mode=last");
    delnew($zroot,"$trandb", "$delcond", "$file?mode=last");

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

include("includes/linkshead.php");
?>
<script src="MyScript/pricelocal.js?A=<?= mt_rand(); ?>" type="text/javascript"></script>
 <script src="MyScript/search_item.js?A=<?= mt_rand(); ?>" type="text/javascript"></script> 
<script src="MyScript/pricelocal_search.js" type="text/javascript"></script>
<script src="MyScript/checkdate.js" type="text/javascript"></script>

</head>
<body>
    <form action='' method='POST'>
        <div class="col-lg-3 pad text-center" id="overlay_form" style="display:none;z-index:999;">
            <button type="button" id="close_form" style="float: right;font-weight: bold;font-size: 18px;color:red;" ><i class="fa fa-close"></i></button>
            <div style='width:100%;' id='browdata'>
            </div>
        </div>
        <!-- Default box -->
        <div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12  pad">
                <div class="panel panel-default">
                    <div class="panel-heading" style="height:40px">
                        <div class="col-lg-10 col-md-10 col-sm-10  col-xs-10">
                            <h3 class="panel-title" style="color:#78909C"><a class="myPrint"><?php echo $formname; ?></a></h3>
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-2  col-xs-2">
                            <input type="date" value="<?= $zStartDate ?>" style="width: 1px;border: none" class="zstdate">
                            <input type="date" value="<?= $zEndDate ?>" style="width: 1px;border: none" class="zenddate">
                            <h4 class="panel-title" style="float:right"><b><?php echo $get['username'] ?></b></h4>
                        </div>

                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg" style="color: #26A69A; font-weight: 600;">Voucher</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" name="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" value="<?php echo $addflag ?>" >
                                <input type="hidden" name="source" class="form-control form source" value="<?= $source; ?>" id="source">
                                <input type="hidden" name="vouchno" class="form-control form vouchno" id="vouchno" value="<?php echo ($addflag != 1) ? $get['vouchno'] : $qvouch ?>" >
                                <input type="hidden" class="form-control form" name="cashvouch" value="<?php Echo ($addflag != 1) ? $get["cashvouch"] : ""; ?>" >
                                <input type="hidden" class="form-control form canc_flag" name="" value="<?php Echo ($addflag != 1) ? $get["canc_flag"] : ""; ?>" >
                            </div>
                            <?php 
                               if($addflag == 1){
                                $readonly = "";
                            } else {
                                $readonly = "readonly";
                            } ?>

                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg" style="color: #26A69A; font-weight: 600;">Date</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-1 col-xs-8 pad" style="width:10%">
                                <input type="date" class="form-control form vouchdt focusfield" name="vouchdt"  value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>" autofocus required>
                            </div>
                            <!--                            <div class="col-lg-1 pad text-right">
                                                            &nbsp;
                                                        </div>-->

                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table-striped table-condensed table-bordered" style="width: 100%">
                            <thead  class="mySearchTr">
                                <tr>
                                    <th style="width: 1%"></th>
                                    <th style="width: 2%">Sr.</th>
                                    <th style="width: 8%;">Barcode</th>
                                    <th style="width: 5%;display: none">Item code</th> 
                                    <th style="width: 30%;">Product Name</th> 
                                    <th style='width: 6%'>Hsncode</th>
                                    <th style="width: 6%;">Rate of Tax</th>
                                    <!--<th style='width: 6%' class="text-right">Taxable value</th>-->
                                    <th style='width: 6%'>Weight In Gms</th>
                                    <th style='width: 6%' class="text-right">Mrp</th>
                                    <th style='width: 8%' class="text-right">WholeSale/DZ</th>
                                    <th style='width: 8%' class="text-right">Inner Packing Box</th>
                                    <th style='width: 4%' class="text-right">Unit</th>
                                    <th style='width: 8%' class="text-right">Master Packing Box</th>
                                    <th style='width: 4%' class="text-right">Unit</th>
                                </tr>
                            </thead>
                            <tbody class="tbody">
                                <?php
                                if ($addflag != 1) {
                                    $qry = mysqli_query($conn, "SELECT * FROM $zroot.`$trandb` WHERE vouchno='$getvouch' ORDER BY srno") or die(mysqli_error($conn));
                                    $ctr = 0;
                                    while ($row = mysqli_fetch_array($qry)) {

                                        $gitemname = mysqli_query($conn, "SELECT `code`,`name` FROM `product` WHERE `prodcode`='$row[itemcode]'")or die(mysqli_error($conn));
                                        $fitemname = mysqli_fetch_array($gitemname);

                                        Echo "<tr>";
                                        Echo "<input type='hidden' name='itemcode_$ctr' class='itemcode form-control form' value='$geti[code]'>";
                                        Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                        Echo "<td><input type='text' name='srno_$ctr' class='srno form-control  form'  value='$row[srno]'></td>";
                                        Echo "<td>";
                                        Echo "<input type='text' name='barcode_$ctr' class='barcode form-control form' value='$row[barcode]' required>";
                                        Echo "</td>";
                                        Echo "<td  style='display:none' >";
                                        Echo "<input type='text' name='itemcode_$ctr' required='true' class='itemcode form-control  form' value='$row[itemcode]' readonly required>";
                                        Echo "</td>";
                                        Echo "<td>";
                                        Echo "<input type='text' name='itemname_$ctr' required='true' class='itemname form-control  form' value='$fitemname[name]' readonly required>";
                                        Echo "</td>";
                                        Echo "<td>";
                                        Echo "<input type='text' name='hsncode_$ctr' required='true' class='hsncode form-control  form' value='$row[hsncode]' readonly required>";
                                        Echo "</td>";
                                        Echo "<td>";
                                        Echo "<input type='text' name='rate_$ctr' class='gstperc form-control form' value='$row[rate] %' >";
                                        Echo "</td>";
//                                        Echo "<td><input type='text' name='subtot_$ctr' class=' form-control text-right rate form' tabindex='-1' value='$row[subtot]' readonly></td>";

                                        Echo "<td><input type='text' name='gram_$ctr' class='gram form-control  form' value='$row[gram]' readonly></td>";
                                        Echo "<td><input type='text' name='mrp_$ctr' class='mrp form-control text-right  form' value='$row[mrp]' readonly></td>";

                                        Echo "<td><input type='text' name='wh_dz_$ctr' class='wh_dz form-control text-right  form' value='$row[wh_dz] ' ></td>";
                                        Echo "<td><input type='text' name='innpkgbox_$ctr' class='innpkgbox form-control text-right form' value='$row[innpkgbox]' ></td>";
                                        Echo "<td><input type='text' name='innunit_$ctr' class='innunit form-control form' value='$row[innunit]' ></td>";
                                        Echo "<td><input type='text' name='mastpkgbox_$ctr' class='mastpkgbox form-control text-right form' value='$row[mastpkgbox]'></td>";
                                        Echo "<td><input type='text' name='mastunit_$ctr' class='mastunit form-control form' value='$row[mastunit]'></td>";
                                        $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='barcode_0' class='barcode  form-control form' value='' required></td> 
                                        <td style="display:none">
                                            <input type='text' name='itemcode_0' required='true' class='itemcode form-control  form' value='' readonly required>
                                        </td>
                                        <td>
                                            <input type='text' name='itemname_0' required='true' class='itemname form-control  form' value='' readonly required>
                                        </td>
                                        <td>
                                            <input type='text' name='hsncode_0' required='true' class='hsncode form-control  form' value='' readonly required>
                                        </td>
                                        <td>
                                            <input type='text' name='rate_0' required='true' class=' gstperc form-control  form' value=''  required>
                                        </td> 
                                       <!--<td><input type='text' name='subtot_0' class=' text-right form-control form rate ' value='0.00' tabindex='-1' ></td>--> 
                                        <td><input type='text' name='gram_0' class='gram form-control  form' value='' readonly></td>
                                        <td><input type='text' name='mrp_0' class='mrp text-right form-control   form' value='' readonly></td>
                                        <td><input type='text' name='wh_dz_0' class='wh_dz text-right form-control   form' value='' ></td>
                                        <td><input type='text' name='innpkgbox_0' class='innpkgbox text-right form-control   form' value='' ></td>
                                        <td><input type='text' name='innunit_0' class='innunit form-control   form' value='' ></td>
                                        <td><input type='text' name='mastpkgbox_0' class='mastpkgbox text-right form-control   form' value='' ></td>
                                        <td><input type='text' name='mastunit_0' class='mastunit form-control   form' value='' ></td>
                                    </tr>
                                    <?php
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="col-lg-12 pad">
                        <button type="button" class="btn btn-primary btn-square form"  id="addnew">
                            <i class="fa fa-plus" data-toggle='tooltip' title='Add Row'></i>    
                        </button>
                        <input type="hidden" id="items" name="items" value="<?php Echo ($addflag != 1) ? $ctr : 1; ?>">  
                        <!--<input type="hidden" class="mandatoryId" name="manId" value="">-->  
                    </div>
                    <div class="col-lg-12 col-xs-12 pad">


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

<!--                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-3 pad text-right">
                                    <label class="label-control marg">G.S.T NO.</label>
                                </div>
                                <div class="col-lg-4 pad">
                                    <input type="text" name="gstno" class="form-control form gstno" value="<? Echo ($addflag != 1) ? $get["gstno"] : ""; ?>" tabindex="-1">
                                </div>
                            </div>-->
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-3 pad text-right">
                                    <label class="label-control marg">Remarks</label>
                                </div>
                                <div class="col-lg-9 pad">
                                    <input type="text" name="remark1" class="form-control form " value="<? Echo ($addflag != 1) ? $get["rem1"] : ""; ?>">
                                </div>
                            </div>
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-3 pad text-right"></div>
                                <div class="col-lg-9 pad">
                                    <input type="text" name="remark2" class="form-control form " value="<? Echo ($addflag != 1) ? $get["rem2"] : ""; ?>">
                                </div>
                            </div>
                            <div class="col-lg-12 col-xs-12 pad">
                                <div class="col-lg-9 pad">

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

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


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

                                </div>
                                <!--                                        <div class="col-lg-9 pad">
                                                                            <div class="table-responsive">
                                                                                <table class="table table-striped table-condensed table-bordered" width="100%">
                                                                                    <thead  style="background: #26a69a;color: white">
                                                                                        <tr>
                                                                                            <th width="20%">Taxable Amt.</th>
                                                                                            <th width="10%"></th>
                                                                                            <th width="18%" class='text-right'>CGST</th>
                                                                                            <th width="18%" class='text-right'>SGST</th>
                                                                                            <th width="18%" class='text-right'>IGST</th>
                                                                                            <th width="35%" ></th>
                                                                                        </tr>
                                                                                    </thead>
                                                                                    <tbody class="">
                                <?php
                                if ($addflag != 1) {

                                    Echo "<tr>";
                                    Echo "<td class='text-right'><b><input type='number' class='form-control form text-right tottaxble0' style='color:red' name='tottaxable0' value='$get[tottaxable0]' readonly></b></td>";
                                    Echo "<td class='text-right'><b>0%</b></td>";
                                    Echo "<td><input type='number' class='form-control form text-right cgst0'     name='cgst0'       value='$get[cgst0]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right sgst0'     name='sgst0'       value='$get[sgst0]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right igst0'     name='igst0'       value='$get[igst0]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right totgst0'     name='totgst0'       value='$get[totgst0]' readonly tabindex='-1'></td>";
                                    Echo "</tr>";
                                    Echo "<tr>";
                                    Echo "<td class='text-right'><b><input type='number' class='form-control form text-right tottaxble1' style='color:red' name='tottaxble1' value='$get[tottaxble1]' readonly tabindex='-1'></b></td>";
                                    Echo "<td class='text-right'><b>0.1%</b></td>";
                                    Echo "<td><input type='number' class='form-control form text-right cgst1'     name='cgst1'       value='$get[cgst1]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right sgst1'     name='sgst1'       value='$get[sgst1]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right igst1'     name='igst1'       value='$get[igst1]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right totgst1'     name='totgst1'       value='$get[totgst1]' readonly tabindex='-1'></td>";
                                    Echo "</tr>";
                                    Echo "<tr>";
                                    Echo "<tr>";
                                    Echo "<td class='text-right'><b><input type='number' class='form-control form text-right tottaxble5' style='color:red' name='tottaxble5' value='$get[tottaxble5]' readonly tabindex='-1'></b></td>";
                                    Echo "<td class='text-right'><b>5%</b></td>";
                                    Echo "<td><input type='number' class='form-control form text-right cgst5' name='cgst5' value='$get[cgst5]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right sgst5' name='sgst5' value='$get[sgst5]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right igst5' name='igst5' value='$get[igst5]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right totgst5' name='totgst5' value='$get[totgst5]' readonly tabindex='-1'></td>";
                                    Echo "</tr>";
                                    Echo "<tr>";
                                    Echo "<td class='text-right'><b><input type='number' class='form-control form text-right tottaxble12'  style='color:red'   name='tottaxble12'       value='$get[tottaxble12]' readonly tabindex='-1'></b></td>";
                                    Echo "<td class='text-right'><b>12%</b></td>";
                                    Echo "<td><input type='number' class='form-control form text-right cgst12'     name='cgst12'       value='$get[cgst12]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right sgst12'     name='sgst12'       value='$get[sgst12]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right igst12'     name='igst12'       value='$get[igst12]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right totgst12'     name='totgst12'       value='$get[totgst12]' readonly tabindex='-1'></td>";
                                    Echo "</tr>";
                                    Echo "<tr>";
                                    Echo "<td class='text-right'><b><input type='number' class='form-control form text-right tottaxble18' style='color:red'    name='tottaxble18' value='$get[tottaxble18]' readonly tabindex='-1'></b></td>";
                                    Echo "<td class='text-right'><b>18%</b></td>";
                                    Echo "<td><input type='number' class='form-control form text-right cgst18'     name='cgst18'       value='$get[cgst18]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right sgst18'     name='sgst18'       value='$get[sgst18]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right igst18'     name='igst18'       value='$get[igst18]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right totgst18'     name='totgst18'       value='$get[totgst18]' readonly tabindex='-1'></td>";

                                    Echo "</tr>";
                                    Echo "<tr>";
                                    Echo "<td class='text-right'><b><input type='number' class='form-control form text-right tottaxble28'  style='color:red'   name='tottaxble28' value='$get[tottaxble28]' readonly tabindex='-1'></b></td>";
                                    Echo "<td class='text-right'><b>28%</b></td>";
                                    Echo "<td><input type='number' class='form-control form text-right cgst28'     name='cgst28'       value='$get[cgst28]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right sgst28'     name='sgst28'       value='$get[sgst28]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right igst28'     name='igst28'       value='$get[igst28]' readonly tabindex='-1'></td>";
                                    Echo "<td><input type='number' class='form-control form text-right totgst28'     name='totgst28'       value='$get[totgst28]' readonly tabindex='-1'></td>";
                                    Echo "</tr>";
                                } else {
                                    ?>
                                                                                                    <tr>
                                                                                                        <td><input type='number' class='form-control form text-right tottaxble0' name='tottaxable0'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td class='text-right'><b>0%</b></td>
                                                                                                        <td><input type='number' class='form-control form text-right cgst0' name='cgst0'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right sgst0' name='sgst0'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right igst0' name='igst0'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right totgst0' name='totgst0'       value='0' readonly tabindex='-1'></td>
                                                                                                    </tr>
                                                                                                    <tr>
                                                                                                        <td><input type='number' class='form-control form text-right tottaxble1' name='tottaxble1'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td class='text-right'><b>0.1%</b></td>
                                                                                                        <td><input type='number' class='form-control form text-right cgst1' name='cgst1'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right sgst1' name='sgst1'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right igst1' name='igst1'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right totgst1' name='totgst1'       value='0' readonly tabindex='-1'></td>
                                                                                                    </tr>
                                                                                                    <tr>
                                                                                                        <td><input type='number' class='form-control form text-right tottaxble5' name='tottaxble5'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td class='text-right'><b>5%</b></td>
                                                                                                        <td><input type='number' class='form-control form text-right cgst5' name='cgst5'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right sgst5' name='sgst5'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right igst5' name='igst5'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right totgst5' name='totgst5'       value='0' readonly tabindex='-1'></td>
                                                                                                    </tr>
                                                                                                    <tr>
                                                                                                        <td><input type='number' class='form-control form text-right tottaxble12' name='tottaxble12' value='0' readonly tabindex='-1'></td>
                                                                                                        <td class='text-right'><b>12%</b></td>
                                                                                                        <td><input type='number' class='form-control form text-right cgst12'     name='cgst12'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right sgst12'     name='sgst12'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right igst12'     name='igst12'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right totgst12'     name='totgst12'       value='0' readonly tabindex='-1'></td>
                                                                                                    </tr>
                                                                                                    <tr>
                                                                                                        <td><input type='number' class='form-control form text-right tottaxble18' name='tottaxble18'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td class='text-right'><b>18%</b></td>
                                                                                                        <td><input type='number' class='form-control form text-right cgst18'     name='cgst18'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right sgst18'     name='sgst18'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right igst18'     name='igst18'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right totgst18'     name='totgst18'       value='0' readonly tabindex='-1'></td>
                                                                                                    </tr>
                                                                                                    <tr>
                                                                                                        <td><input type='number' class='form-control form text-right tottaxble28' name='tottaxble28'  value='0' readonly tabindex='-1'></td>
                                                                                                        <td class='text-right'><b>28%</b></td>
                                                                                                        <td><input type='number' class='form-control form text-right cgst28'     name='cgst28'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right sgst28'     name='sgst28'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right igst28'     name='igst28'       value='0' readonly tabindex='-1'></td>
                                                                                                        <td><input type='number' class='form-control form text-right totgst28'     name='totgst28'       value='0' readonly tabindex='-1'></td>
                                                                                                    </tr>
                                    <?
                                }
                                ?>
                                                                                    </tbody>
                                                                                </table>
                                                                            </div>
                                                                        </div>-->
                            </div>
                        </div>

                        <!--                                <div class="col-lg-12 col-xs-12 pad">
                                                            <div class="col-lg-3 pad"></div>
                                                            <div class="col-lg-3 pad"></div>
                                                            <div class="col-lg-3 pad text-right">
                                                                <label class="label-control marg" style=''>Pre TCS</label>
                                                            </div>
                                                            <div class="col-lg-3 pad">
                                                                <input type="number" step="any" name="pretcs" class="form-control form text-right pretcs" value="<?php Echo ($addflag != 1) ? $get['pretcs'] : "0"; ?>" style='color:red' readonly tabindex="-1">
                                                            </div>
                                                        </div>-->
                        <!--                                <div class="col-lg-12 col-xs-12 pad">
                                                            <div class="col-lg-3 pad"></div>
                                                            <div class="col-lg-2 pad"></div>
                                                            <div class="col-lg-2 pad text-right">
                                                                <label class="label-control marg" style=''>TCS</label>
                                                            </div>
                                                            <div class="col-lg-1 pad">
                                                                <input type="number" step="any" name="tcsperc" class="form-control form text-right tcsperc" value="<?php Echo ($addflag != 1) ? $get['tcsperc'] : "0"; ?>" style='color:red' readonly tabindex="-1">
                                                            </div>
                                                            <div class="col-lg-1 pad">
                                                                <label class="label-control marg" style=''>%</label>
                                                            </div>
                                                            <div class="col-lg-3 pad">
                                                                <input type="number" step="any" name="tcsamt" class="form-control form text-right tcsamt" value="<?php Echo ($addflag != 1) ? $get['tcsamt'] : "0"; ?>" style='color:red' readonly tabindex="-1">
                                                            </div>
                                                        </div>-->

                    </div>
                </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/buttsale.php"); ?>
                </div>
            </div>
        </div>
    </div>
</div>
</form>

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

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

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

                            </form>
                        </div>

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

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

                                <div class="col-lg-3 pad">
                                    <span class="btn btn-default btn-file btn-square btn-warning">
                                        Choose File <input type="file" name="file1" id="file1">
                                    </span>
                                    <input type="hidden" name="code" id="vouchno" value='<?php Echo ($addflag != 1) ? $get['vouchno'] : "$qvouch"; ?>'>
                                    <input type="button" value="Upload File"  id="uploadbtn" class="btn btn-square" style="background-color: #C0CA33; color: white">
                                </div>
                                <div class="col-lg-6">
                                    <div class="progress">
                                        <progress id="progressBar" class="progress-bar"  role="progressbar" value="0" max="100" style="width:100%;color: red;"></progress>
                                    </div>
                                    <h3 id="status"></h3>
                                    <p id="loaded_n_total"></p>
                                </div>
                            </form>
                        </div>
                        <div class="col-lg-10 upload">
                            <img id="preview" src="" alt="your image"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade itemModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal"><span>&times;</span></button>
                <h4 class="modal-title" id="myLargeModalLabel">Search <? Echo $formname; ?></h4>
            </div>
            <div class="modal-body">
                <input type="hidden" value="<?php // Echo $fseries                                                                            ?>" class="form-control series">
                <input type="hidden" value="<?php Echo $get[vouchno]; ?>" class="form-control vouchno">
                <input type="hidden" value="<?php Echo $file ?>" class="form-control file">
                <input type="hidden" value="<?php Echo $para ?>" class="form-control para">
                <div class="row">
                    <div class="col-lg-3">
                        <select class="form-control ifield">
                            <option value="1">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="8%">Itemcode</th>
                                <th width="49%">Name</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="<?php Echo $para ?>" class="form-control para">
                <div class="row">
                    <div class="col-lg-2">
                        <select class="form-control sfield">
                            <option value="1"> Party Name</option>
                            <option value="4">Voucher</option>
                            <option value="2">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"> Party Name</option>
                            <option value="1">Voucher</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</th>
                                <th width="10%">Invoice No.</th>
                                <th width="15%">Date</th>
                                <th width="20%">Party Name</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>
