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

$formname = 'Estimate';
$maindb = 'estmain';
$trandb = 'esttran';

$printfile = "estimate_gst_print.php";
$file = 'estimate_gst.php';
$trandbexist = 1;
$keyfld = "vouchno";
$source = "ESTI";

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

$zroot = $_SESSION["zdir"];

mysqli_select_db($conn, $zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

if (isset($_POST["submit"])) {
    $a = 1;
    $vouchdt = $_POST["vouchdt"];
    $qvouch = $_POST["vouchno"];
    
    $client = $_POST["client"];
    $clientno = $_POST["clientno"];
    $delchg = $_POST["delchg"];
    $architect = $_POST["architect"];
    $archno = $_POST["archno"];
    $site = $_POST["site"];
    $createby = $_POST["createby"];
    
    $remark = mysqli_real_escape_string($conn, $_POST["remark"]);
    $remark2 = mysqli_real_escape_string($conn, $_POST["remark2"]);
    
    $status = $_POST["status"];
    $appdate = $_POST["appdate"];

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

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

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

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

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

    $totamt = $_POST["totamt"];

    $count = $_POST["items"];

    $mvouch = $qvouch;

    $salecode = 11;

    if ($a == 1) {
        mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `$trandb` WRITE ");

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

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

        $srl = 0;
        $batch = date("Y-m-d") . $mvouch;
        $cnt = 0;
        for ($i = 0; $i <= $count; $i++) {

            $srno = $_POST["srno_$i"];
            $boxqty = $_POST["boxqty_$i"];
            $unitbox = $_POST["unitbox_$i"];
            
            $particulars = mysqli_real_escape_string($conn, $_POST["particulars_$i"]);
            
            $qty = $_POST["qty_$i"];
            $unit = $_POST["unit_$i"];
            $rate = $_POST["rate_$i"];
            $amount = $_POST["amount_$i"];
            $total = $_POST["total_$i"];
            $gstperc = $_POST["gstperc_$i"];
            $gstamt = $_POST["gstamt_$i"];
            $image = $_POST["image_$i"];


            $group = $source . $barcode;


            $mqty = $qty * -1;

            $group = $source . $mvouch;

            if (!empty($amount)) {
                $srl++;

                if ($compcd == 1){
                    $path = "images/product/galaxy/";
                } else {
                    $path = "images/product/studio/";
                }   

                $filename1 = $mvouch . "_" . $srl . ".jpg";
                $img_file1 = $path . $filename1;
                $image_ftype = pathinfo($img_file1, PATHINFO_EXTENSION);
                move_uploaded_file($_FILES["image_$i"]["tmp_name"], $img_file1);
                mysqli_query($conn, "INSERT INTO `$trandb`(`vouchno`, `vouchdt`, `srno`, `boxqty`, `unitbox`, gstamt, gstperc, total,
                                                           `particulars`, `qty`, `unit`, `rate`, `amount`,`image`)
                                                    VALUES('$mvouch', '$vouchdt', '$srl', '$boxqty', '$unitbox', '$gstamt', '$gstperc', '$total',
                                                           '$particulars', '$qty', '$unit', '$rate', '$amount' ,'$img_file1')") or die(mysqli_error($conn));
            }
        }

#################################TRAN PART END #################################
############################## MAIN ######################################################
        if ($addflag == 1) {

            mysqli_query($conn, "INSERT INTO `$maindb`(`vouchno`, `vouchdt`, `client`, `clientno`, `architect`, `archno`, `totamt`, `remark`, `remark2`, `status`, `appdate`, `site`, `createby`,
                                                       `cgst5`,`sgst5`,`igst5`,`cgst12`,`sgst12`,`igst12`,`cgst18`,`sgst18`,`igst18`,`cgst28`,
                                                       `sgst28`,`igst28`,`totgst5`,`totgst12`,`totgst18`,`totgst28`, oms, netamt,`delchg`)
                                       VALUES ($qvouch, '$vouchdt',  '$client', '$clientno','$architect', '$archno', '$totamt', '$remark', '$remark2', '$status', '$appdate', '$site', '$createby',
                                                '$cgst5','$sgst5','$igst5', '$cgst12','$sgst12','$igst12', '$cgst18', '$sgst18','$igst18','$cgst28',
                                                '$sgst28','$igst28','$totgst5','$totgst12','$totgst18','$totgst28', '$oms', '$netamt','$delchg')") or die(mysqli_error($conn));
            insmess();
            $mvouch = $qvouch; //1
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        } else {
            $mvouch = $qvouch; //1
            mysqli_query($conn, "UPDATE `$maindb` SET `vouchdt`='$vouchdt', `client`='$client', `clientno`='$clientno', `architect`='$architect', oms='$oms', netamt='$netamt',
                                `archno`='$archno', `totamt`='$totamt', `remark`='$remark', `remark2`='$remark2', `status`='$status', `appdate`='$appdate',
                                `cgst5`='$cgst5',`sgst5`='$sgst5', `igst5`='$igst5',`cgst12`='$cgst12',`sgst12`='$sgst12',`igst12`='$igst12',
                                `cgst18`='$cgst18', `sgst18`='$sgst18',`igst18`='$igst18',`cgst28`='$cgst28', `sgst28`='$sgst28',`igst28`='$igst28',
                                `totgst5`='$totgst5',`totgst12`='$totgst12', `totgst18`='$totgst18',`totgst28`='$totgst28',     
                                `site`='$site', `createby`='$createby',`delchg`='$delchg' WHERE `vouchno`= '$mvouch' ") or die(mysqli_error($conn));
            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        }
    }
}

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

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

if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    delete($zdb, "$trandb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]' ";
}

include("includes/linkshead.php");
?>
<script src="MyScript/shortkeys.js?a=2" type="text/javascript"></script>
<script src="MyScript/estimate_gst.js?a=3" type="text/javascript"></script>
<script src="MyScript/estimate_gst_search.js?a=2" type="text/javascript"></script>
</head>
<body>
    <!--    <div id="preloader" class="col-lg-12 text-center">
            <h3 class="text-center">Loading</h3>
            <div id="status">&nbsp;</div>
        </div>-->
    <form action='' method='POST' enctype="multipart/form-data">
        <!-- Default box -->
        <div>
            <div class="col-lg-10 col-md-8 col-sm-12 col-xs-12  pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title" style="color:inherit"><?php Echo $formname; ?></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                            <i class="fa fa-times"></i>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-2 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-1 col-sm-3 col-xs-3 pad">
                                <input type="text" class="form-control text-size form" name="vouchno" value="<?php Echo ($addflag != 1) ? $get["vouchno"] : "$qvouch"; ?>" required readonly>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Date</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4 pad">
                                <input type="date" class="form-control form focusfield"  name="vouchdt" value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date('Y-m-d'); ?>" autofocus> 
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Client Name</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4  pad">
                                  <!--<input type="text" class="form-control form client" name="client" value="<?php // Echo ($addflag != 1) ? $get["client"] : "";           ?>"  >-->
                                <input list='client' name='client' value='<?php echo $get['client'] ?>' class='client form-control form '  autocomplete="off">
                                <datalist id='client'> 
                                    <option value=''></option>
                                    <?php
                                    $mhsncode = mysqli_query($conn, "SELECT `client` FROM `estmain` where client!='' group by client") or die(mysqli_error($conn));
                                    while ($thsncode = mysqli_fetch_array($mhsncode)) {
                                        echo "<option value='$thsncode[client]'>";
                                    }
                                    ?>
                                </datalist>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Number</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4  pad">
                                <input type="text" name="clientno" class="form-control form clientno" value="<?php echo ($addflag != 1) ? $get['clientno'] : '' ?>">
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Architect Name</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4  pad">
                                <input list='architect' name='architect' value='<?php echo $get['architect'] ?>' class='architect form-control form ' autocomplete="off">
                                <datalist id='architect'> 
                                    <option value=''></option>
                                    <?php
                                    $marchitect = mysqli_query($conn, "SELECT `architect` FROM `estmain` where architect!='' group by architect") or die(mysqli_error($conn));
                                    while ($tarchitect = mysqli_fetch_array($marchitect)) {
                                        echo "<option value='$tarchitect[architect]'>";
                                    }
                                    ?>
                                </datalist>
                                <!--<input type="text" name="architect" class="form-control form architect" value="<?php echo ($addflag != 1) ? $get['architect'] : '' ?>">-->
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg"> Architect No</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4  pad">
                                <input type="text" name="archno" class="form-control form archno" value="<?php echo ($addflag != 1) ? $get['archno'] : '' ?>">
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Out of State</label>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-3 col-xs-3  pad">
                                <select class="form-control form oms" name="oms">
                                    <option value="" <?php
                                    if ($get['oms'] == '') {
                                        echo 'selected="selected"';
                                    }
                                    ?>>No</option>
                                    <option value="1" <?php
                                    if ($get['oms'] == '1') {
                                        echo 'selected="selected"';
                                    }
                                    ?>>Yes</option>
                                </select>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Site</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4  pad">
                                <input type="text" name="site" class="form-control form site" value="<?php echo ($addflag != 1) ? $get['site'] : '' ?>">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-1 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Created By</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4  pad">
                                <input type="text" name="createby" class="form-control form createby" value="<?php echo ($addflag != 1) ? $get['createby'] : '' ?>">
                            </div>
                        </div> 
                        <div class="table-responsive">
                            <table class="table table-striped table-condensed table-bordered table-padd" width="100%">
                                <thead class="mySearchTr" >
                                    <tr>
                                        <th width="2%"></th>
                                        <th width="3%" class='text-right'>Sr.</th>
<!--                                        <th width="5%" class='text-right'>Box Qty.</th>
                                        <th width="5%">Sq.ft</th>-->
                                        <th width="15%">Particular</th>
                                        <th width="8%">Choose Image</th>
                                        <th width="4%">Image</th>
                                        <th width="5%"  class='text-right'>Qty.</th>
                                        <th width="5%">Sq.ft</th>
                                        <th width="5%">Unit</th>
                                        <th width="5%"  class='text-right'>Rate</th>
                                        <th width="5%"  class='text-right'>Amount</th>
                                        <th width="5%"  class='text-right'>GST %</th>
                                        <th width="5%"  class='text-right'>GST</th>
                                        <th width="5%"  class='text-right'>Total</th>
                                    </tr>
                                </thead>
                                <tbody class="tbody">
                                    <?php
                                    if ($addflag != 1) {
                                        $ctr = 0;
                                        $mctr = 0;
                                        $tqty = 0;
                                        $tamt = 0;
                                        $gettran = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$get[vouchno]' ORDER BY `srno`")or die(mysqli_error($conn));
                                        while ($tran = mysqli_fetch_array($gettran)) {
                                            $mctr++;
                                            Echo "<tr>";
                                            Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                            Echo "<td><input type='text' class='form-control form text-right srno'    name='srno_$ctr'     value='$mctr'></td>";
//                                            Echo "<td><input type='text' class='form-control form text-right boxqty'         name='boxqty_$ctr' value='$tran[boxqty]'></td>";
                                            Echo "<td><input type='text' class='form-control form particulars'        name='particulars_$ctr' value='$tran[particulars]'></td>";
                                            echo "<td><input type='file' class='form-control form image' name='image_$ctr' value=''></td>";
                                            echo "<td><i class='fa fa-image reqModal' style='font-size:25px'></i></td>";
                                            Echo "<td><input type='text' class='form-control form text-right qty'     name='qty_$ctr' value='$tran[qty]'></td>";
                                            Echo "<td><input type='text' class='form-control form unit'               name='unit_$ctr'  value='$tran[unit]'></td>";
                                            Echo "<td><input type='text' class='form-control form unitbox'            name='unitbox_$ctr'  value='$tran[unitbox]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right rate'    name='rate_$ctr'  value='$tran[rate]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right amount'  name='amount_$ctr'  value='$tran[amount]'readonly ></td>";
                                            Echo "<td><input type='text' class='form-control form text-right gstperc' name='gstperc_$ctr'  value='$tran[gstperc]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right gstamt'  name='gstamt_$ctr'  value='$tran[gstamt]' readonly></td>";
                                            Echo "<td><input type='text' class='form-control form text-right total'   name='total_$ctr'  value='$tran[total]' readonly></td>";
                                            Echo "</tr>";
                                            $ctr++;
                                        }
                                    } else {
                                        $pctr = 0;
                                        Echo "<tr>";
                                        Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                        Echo "<td><input type='text' class='form-control form text-right srno'    name='srno_0'     value='1'></td>";
//                                      Echo "<td><input type='text' class='form-control form text-right boxqty'  name='boxqty_0' value=''></td>";
                                        Echo "<td><input type='text' class='form-control form particulars'        name='particulars_0' value=''></td>";
                                        echo "<td><input type='file' class='form-control form image' name='image_0' value=''></td>";
                                        echo "<td><i class='fa fa-image' style='font-size:25px'></i></td>";
                                        Echo "<td><input type='text' class='form-control form text-right qty'     name='qty_0' value='0'></td>";
                                        Echo "<td><input type='text' class='form-control form unit'               name='unit_0'  value=''></td>";
                                        Echo "<td><input type='text' class='form-control form unitbox'            name='unitbox_0'  value=''></td>";
                                        Echo "<td><input type='text' class='form-control form text-right rate'    name='rate_0'  value='0'></td>";
                                        Echo "<td><input type='text' class='form-control form text-right amount'  name='amount_0'  value='0' readonly></td>";
                                        Echo "<td><input type='text' class='form-control form text-right gstperc' name='gstperc_0'  value='0'></td>";
                                        Echo "<td><input type='text' class='form-control form text-right gstamt'  name='gstamt_0'  value='0' readonly></td>";
                                        Echo "<td><input type='text' class='form-control form text-right total'   name='total_0'  value='0' ></td>";

                                        Echo "</tr>";
                                    }
                                    $pctr++;
                                    ?>
                                </tbody>
                            </table>

                        </div>

                        <div class="row">
                            <div class="col-lg-1" >
                                <button type="button" class="btn btn-square form mySearchTr"  id="addnew">
                                    <i class="fa fa-plus" style="color:#ffffff" data-toggle='tooltip' title='Add Row' ></i>    
                                </button>
                                <input type="hidden" id="items" name="items" value="<?php echo ($addflag != 1) ? $ctr : $pctr; ?>" />  
                            </div> 
                            <div class="col-lg-10 col-md-1 col-sm-8 col-xs-8 text-right pad">
                                <label class="label-control text-size marg">Taxable Value &nbsp;</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-4 col-xs-4 pad">
                                <input type="text" class="form-control form text-right totamt" name="totamt" value="<?php Echo ($addflag != 1) ? $get["totamt"] : ""; ?>" readonly>&nbsp;
                            </div>
                        </div>
<!--***-->

                                    <div class="row">
                                        <div class="col-lg-7 pad"></div>
                                        <div class="col-lg-5 pad">
                                            <div class="table-responsive">
                                                <table class="table table-striped table-condensed table-bordered" width="100%">
                                                    <thead class="mySearchTr" style="color: white">
                                                        <tr>
                                                            <th width="10%"></th>
                                                            <th width="18%" class='text-right'>CGST</th>
                                                            <th width="18%" class='text-right'>SGST</th>
                                                            <th width="18%" class='text-right'>IGST</th>
                                                            <th width="35%" ></th>
                                                        </tr>
                                                    </thead>
                                                    <tbody class="">
<!--//                                                        if ($addflag != 1) {-->

                                                            <tr>
                                                            <td class='text-right'><b>5%</b></td>
                                                            <td><input type='number' class='form-control form text-right cgst5' readonly    name='cgst5'       value="<?php Echo ($addflag != 1) ? $get['cgst5'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right sgst5' readonly    name='sgst5'       value="<?php Echo ($addflag != 1) ? $get['sgst5'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right igst5' readonly    name='igst5'       value="<?php Echo ($addflag != 1) ? $get['igst5'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right totgst5' readonly    name='totgst5'       value="<?php Echo ($addflag != 1) ? $get['totgst5'] : ""; ?>"</td>
                                                            </tr>
                                                            <tr>
                                                            <td class='text-right'><b>12%</b></td>
                                                            <td><input type='number' class='form-control form text-right cgst12' readonly    name='cgst12'       value="<?php Echo ($addflag != 1) ? $get['cgst12'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right sgst12' readonly    name='sgst12'       value="<?php Echo ($addflag != 1) ? $get['sgst12'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right igst12' readonly    name='igst12'       value="<?php Echo ($addflag != 1) ? $get['igst12'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right totgst12' readonly    name='totgst12'       value="<?php Echo ($addflag != 1) ? $get['totgst12'] : ""; ?>"</td>
                                                            </tr>
                                                            <tr>
                                                            <td class='text-right'><b>18%</b></td>
                                                            <td><input type='number' class='form-control form text-right cgst18' readonly    name='cgst18'       value="<?php Echo ($addflag != 1) ? $get['cgst18'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right sgst18' readonly    name='sgst18'       value="<?php Echo ($addflag != 1) ? $get['sgst18'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right igst18' readonly    name='igst18'       value="<?php Echo ($addflag != 1) ? $get['igst18'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right totgst18' readonly    name='totgst18'       value="<?php Echo ($addflag != 1) ? $get['totgst18'] : ""; ?>"</td>

                                                            </tr>
                                                            <tr>
                                                            <td class='text-right'><b>28%</b></td>
                                                            <td><input type='number' class='form-control form text-right cgst28' readonly    name='cgst28'       value="<?php Echo ($addflag != 1) ? $get['cgst28'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right sgst28' readonly    name='sgst28'       value="<?php Echo ($addflag != 1) ? $get['sgst28'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right igst28' readonly    name='igst28'       value="<?php Echo ($addflag != 1) ? $get['igst28'] : ""; ?>"</td>
                                                            <td><input type='number' class='form-control form text-right totgst28' readonly    name='totgst28'       value="<?php Echo ($addflag != 1) ? $get['totgst28'] : ""; ?>"</td>
                                                            </tr>
<!--//                                                        } else {-->
                                                            <!--?>-->
<!--                                                            <tr>
                                                                <td class='text-right'><b>5%</b></td>
                                                                <td><input type='number' class='form-control form text-right cgst5'  readonly   name='cgst5'       value='0' ></td>
                                                                <td><input type='number' class='form-control form text-right sgst5'  readonly   name='sgst5'       value='0' ></td>
                                                                <td><input type='number' class='form-control form text-right igst5'  readonly   name='igst5'       value='0' ></td>
                                                                <td><input type='number' class='form-control form text-right totgst5' readonly    name='totgst5'       value='0' ></td>
                                                            </tr>
                                                            <tr>
                                                                <td class='text-right'><b>12%</b></td>
                                                                <td><input type='number' class='form-control form text-right cgst12' readonly    name='cgst12'       value='0' ></td>
                                                                <td><input type='number' class='form-control form text-right sgst12'  readonly   name='sgst12'       value='0' ></td>
                                                                <td><input type='number' class='form-control form text-right igst12'   readonly  name='igst12'       value='0' ></td>
                                                                <td><input type='number' class='form-control form text-right totgst12'  readonly   name='totgst12'       value='0' ></td>
                                                            </tr>
                                                            <tr>
                                                                <td class='text-right'><b>18%</b></td>
                                                                <td><input type='number' class='form-control form text-right cgst18'     name='cgst18'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right sgst18'     name='sgst18'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right igst18'     name='igst18'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right totgst18'     name='totgst18'       value='0' readonly></td>
                                                            </tr>
                                                            <tr>
                                                                <td class='text-right'><b>28%</b></td>
                                                                <td><input type='number' class='form-control form text-right cgst28'     name='cgst28'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right sgst28'     name='sgst28'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right igst28'     name='igst28'       value='0' readonly></td>
                                                                <td><input type='number' class='form-control form text-right totgst28'     name='totgst28'       value='0' readonly></td>
                                                            </tr>-->
                                                            <?
//                                                        }
                                                        ?>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
<!--***-->                        
                        
                        <div class="row">
                            <div class="col-lg-1" >
                                
                            </div> 
                            <div class="col-lg-10 col-md-1 col-sm-8 col-xs-8 text-right pad">
                                <label class="label-control text-size marg">Delivery Charges &nbsp;</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-4 col-xs-4 pad">
                                <input type="number" class="form-control form text-right delchg" name="delchg" value="<?php Echo ($addflag != 1) ? $get["delchg"] : 0; ?>">&nbsp;
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1" >
                                
                            </div> 
                            <div class="col-lg-10 col-md-1 col-sm-8 col-xs-8 text-right pad">
                                <label class="label-control text-size marg">Net Amount &nbsp;</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-4 col-xs-4 pad">
                                <input type="text" class="form-control form text-right netamt" name="netamt" value="<?php Echo ($addflag != 1) ? $get["netamt"] : ""; ?>" readonly>&nbsp;
                            </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 text-size marg">Remark</label>
                            </div>
                            <div class="col-lg-5 col-md-5 col-sm-6 col-xs-6 pad">
                                <input type="text" class="form-control form " name="remark" value="<?php Echo ($addflag != 1) ? $get["remark"] : ""; ?>" >
                                <input type="text" class="form-control form " name="remark2" value="<?php Echo ($addflag != 1) ? $get["remark2"] : ""; ?>" >
                            </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">Status</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4 pad">
                                <select name="status" class="form-control form mode status select2">
                                    <option <?php
                                    if ($get['status'] == 'P') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="P">Pending</option>
                                    <option <?php
                                    if ($get['status'] == 'A') {
                                        echo "selected='selected'";
                                    }
                                    ?> value="A">Approved</option>
                                </select>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-3 col-xs-3  pad">
                                <label class="label-control text-size marg applbl">Apprv. Date</label> 
                            </div>
                            <div class="col-lg-2 col-md-1 col-sm-3 col-xs-3 text-right pad">
                                <input type="date" step="any" name="apprvdt" class="form-control form  apprvdt" value="<?php echo ($addflag != 1) ? $get['apprvdate'] : "" ?>" >
                            </div>
                        </div> 
                        <div class="row">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 pad">
            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <img src="MyStyle/pdficon.png" title="Pdf Print" class="btnpdf pdf" style="height:50px;display: <?= $editdisabled ?>" onclick="window.open('estimate_gst_pdf.php?vouchno=<?= $qvouch ?>')">                            
                        </div>
                        <div class="col-lg-7 col-md-7 col-sm-8 col-xs-8 text-right pad">
                            <?php include("includes/buttons.php"); ?>
                        </div>

                    </div> 

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

<div class="modal fade showingModal" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">

                    <h5 class="modal-title" id="exampleModalLongTitle">Product Image</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="imagefetch">

                    </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">Product Name</option>
                            <option value="2">Size</option>
                            <option value="3">Brand</option>
                            <option value="4">Quality</option>
                            <option value="5">Code</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 " width="100%">
                        <thead>
                            <tr class="mySearchTr">
                                <th width="20%">Product Name</th>
                                <th width="10%">Size</th>
                                <th width="10%">Brand</th>
                                <th width="10%">Quality</th>
                                <th width="10%">Itemcode</th>
                                <th width="10%">Stk.</th>
                                <th width="10%">Prod Type</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 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">
                <input type="hidden" value="<?php Echo $zseries ?>" class="form-control series">
                <input type="hidden" value="<?php Echo $get['code']; ?>" class="form-control vouchno">
                <input type="hidden" value="<?php Echo $file ?>" class="form-control file">
                <input type="hidden" value="<?php Echo $para ?>" class="form-control para">
                <div class="row">
                    <div class="col-lg-2">
                        <select class="form-control sfield">
                            <option value="1">Voucher</option>
                            <option value="2">Date</option>
                            <option value="3">Client</option>
                            <option value="4">Client No</option>
                            <option value="5">Architect</option>
                            <option value="6">Architect No</option>

                            <option value="6">Remark</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control soperator">
                            <option value="">Type of Search</option>
                            <option value="%">Like</option>
                            <option value="=">Exactly</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control sortBy">
                            <option value="">Sort By</option>
                            <option value="1">Voucher</option>
                            <option value="2">Date</option>
                            <option value="3">Client</option>
                            <option value="4">Client No</option>
                            <option value="5">Architect</option>
                            <option value="6">Architect No</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">
                </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-striped table-condensed table-bordered" width="100%">
                        <thead>
                            <tr class="mySearchTr">
                                <th style="width:8%">Voucher</th>
                                <th style="width:13%">Date</th>
                                <th style="width:20%">Client</th>
                                <th style="width:10%">Client No</th>
                                <th style="width:20%">Architect</th>
                                <th style="width:10%">Architect No</th>
                                <th style="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>
