<?php
require 'includes/dbconnect.php';
include 'includes/function.php';
include 'includes/check_auth_user.php';
//echo'abc';
$formname = 'Billing';
$maindb = 'kotmain';
$trandb = 'kottran';
$accdb = 'actran';
$cashdb = 'cashrecp';
$bankdb = 'bankrecp';

$file = 'bill.php';
$trandbexist = 0;
$keyfld = "vouchno";
$focusfield = "";
$keycond = "";
$keycond1 = "";
$printfile = "bill_print.php";

//browse($zdir);
$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

include("includes/vouchno_generate.php");
include("includes/prev&next.php");
$para = $_GET["para"];
$zroot = $_SESSION["zdbroot"];
$admin = $_SESSION["admin_" . $dbname];



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

//$zroot = $_SESSION["zdb"];


if (isset($_POST["submit"])) {
    $matcount = $_POST['items'];
    $labcount = $_POST['labour'];
    $mvouch = $qvouch;

    $vouchdt = $_POST["vouchdt"];
    $staff = $_POST["staff"];
    $tableno = $_POST["tableno"];
    $gstperc = $_POST["gstperc"];
    $subtot = $_POST["subtot"];
    $discamt = $_POST["discamt"];
    $taxable = $_POST["taxable"];
    $discperc = $_POST["discperc"];
    $cgstperc = $_POST["cgstperc"];
    $sgstperc = $_POST["sgstperc"];
    $cgstamt = $_POST["cgstamt"];
    $sgstamt = $_POST["sgstamt"];
    $netamt = $_POST["netamt"];

    $cashamt = $_POST["cashamt"];
    $ccamt = $_POST["ccamt"];
    $cashchk = $_POST["cashchk"];
    $cardchk = $_POST["cardchk"];
    $bothchk = $_POST["bothchk"];
    $paymode = $_POST["paymode"];
    $parcel = '';
    if($tableno == 0){
        $parcel = 'Y';
    }

    $count = $_POST["items"];
    $ctr = 0;
    $ptr = 0;

    mysqli_query($conn, "Lock tables `$maindb` WRITE, `$trandb` WRITE ,`tablemast` WRITE,`kottable` WRITE");


    if ($addflag == 1) {
        $gen = mysqli_query($conn, "Select max($keyfld)  AS maxcode from `$maindb` where $keyfld != '' $keycond limit 0,1") or die(mysqli_error($conn));
        if (mysqli_num_rows($gen) > 0) {
            $vvouch = mysqli_fetch_assoc($gen);
            $qvouch = $vvouch["maxcode"] + 1;
        } else {
            $qvouch = '1';
        }
    }
    $mvouch = $qvouch;

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

    $tqty = 0;
    for ($i = 0; $i <= $matcount; $i++) {

        $item = $_POST["item_$i"];
        $subvouch = $_POST["subvouch_$i"];
        $kotprint = $_POST["kotprint_$i"];
        $qty = $_POST["qty_$i"];
        $rate = $_POST["rate_$i"];
        $amount = $_POST["amount_$i"];
        $cdiscperc = $_POST["cdiscperc_$i"];
        $cdiscamt = $_POST["cdiscamt_$i"];
        $total = $_POST["total_$i"];
        $remtran = $_POST["remtran_$i"];

        if (!empty($item)) {
            $ctr++;
            $srno = $ctr;
            $tqty = $tqty + $qty;
            mysqli_query($conn, "INSERT INTO `$trandb`(`vouchno`, `vouchdt`, `subvouch`, `kotprint`, `srno`, `item`, `qty`, `rate`, `amount`, 
                                                       `cdiscperc`, `cdiscamt`, `remtran`, `total`)
                                              VALUES ('$mvouch', '$vouchdt', '$subvouch', '$kotprint', '$srno', '$item', '$qty', '$rate', '$amount',
                                                       '$cdiscperc', '$cdiscamt', '$remtran', '$total')") OR die(mysqli_error($conn));
        }
    }
    $totitems = $srno;
    $totqty = $tqty;
    $billdone = '';
    if ($cashchk != '' || $cardchk != '') {
        $billdone = 'Y';
    }

    if ($addflag == 1) {
        mysqli_query($conn, "INSERT INTO `$maindb`(`vouchno`, `tableno`, `vouchdt`, `vouchtime`, `user`, `billdone`, 
                                                   `totitems`, `totqty`, `netamt`, `subtotal`, `cgstperc`, `sgstperc`,
                                                   `cgstamt`, `sgstamt`, `discperc`, `discamt`, `gstperc`, `cashchk`, 
                                                   `cashamt`, `cardchk`, `ccamt`, `bothchk`, `cashvouch`, `bankvouch`,
                                                   `bankname`, `taxable`, `paymode`, `parcel`)
                                              VALUES ('$qvouch', '$tableno', '$vouchdt', CURRENT_TIME(), '$staff', '$billdone', 
                                                   '$totitems', '$totqty', '$netamt', '$subtotal', '$cgstperc', '$sgstperc',
                                                   '$cgstamt', '$sgstamt', '$discperc', '$discamt', '$gstperc', '$cashchk', 
                                                   '$cashamt', '$cardchk', '$ccamt', '$bothchk', '$cashvouch', '$bankvouch',
                                                   '$bankname', '$taxable', '$paymode', '$parcel')") OR die(mysqli_error($conn));
//        insmess();
        header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
    } else {

        mysqli_query($conn, "Update `$maindb` set gstperc='$gstperc',  `subtotal`='$subtot',cgstperc='$cgstperc',discperc='$discperc', `parcel`='$parcel',
                                              sgstperc='$sgstperc',cgstamt='$cgstamt',discamt='$discamt', `ccamt`='$ccamt', `totitems`='$totitems',
                                              sgstamt='$sgstamt', `taxable`='$taxable', netamt='$netamt',`cashchk`='$cashchk',`cashamt`='$cashamt',
                                             `cardchk`='$cardchk', `bothchk`='$bothchk', `bankvouch`='$mbankvouch',`bankname`='$bankname',`totqty`='$totqty',
                                             `cashvouch`='$mcashvouch', `billdone`='$billdone', `paymode`='$paymode' where vouchno='$mvouch'") or die(mysqli_error($conn));

        if ($cashamt > 0 || $ccamt > 0) {
            $getmultitbl = mysqli_query($conn, "SELECT `tableno` FROM `kottable` WHERE `vouchno`='$mvouch'") or die(mysqli_error());
            while ($multitbl = mysqli_fetch_array($getmultitbl)) {
                mysqli_query($conn, "Update `tablemast` set `book`='' where `code`='$multitbl[tableno]'") or die(mysqli_error($conn));
            }
        }
        mysqli_query($conn, "unlock tables");

//        updmess();/
        echo "<script>";
        echo "window.open('bill_print.php?vouchno=$qvouch')";
        echo "</script>";
//    echo "<script>window.location.open='bill_print.php?vouchno=$qvouch'</script>";

        header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
    }
}

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


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);
    $tbno = $get['tableno'];

    $gettab = mysqli_query($conn, "SELECT code,name FROM `tablemast` WHERE code='$get[tableno]'") or die(mysqli_error($conn));
    $fettab = mysqli_fetch_array($gettab);

    $getgst = mysqli_query($conn, "SELECT * FROM `gsttype` WHERE per='$get[gstperc]'") or die(mysqli_error($conn));
    $fetgst = mysqli_fetch_array($getgst);

    $gtptyp = mysqli_query($conn, "Select * from `paytype` where code='$get[paymode]'") or die(mysqli_error($conn));
    $ftpay = mysqli_fetch_array($gtptyp);
}


if (isset($_GET["delete"])) {
    mysqli_query($conn, "Lock tables `$maindb` WRITE, `$trandb` WRITE ,`tablemast` WRITE, `kottable` WRITE");

    $delcond = " vouchno='$getvouch' ";
    $getmultitbldel = mysqli_query($conn, "SELECT `tableno` FROM `kottable` WHERE `vouchno`='$getvouch'") or die(mysqli_error());
    while ($multitbldel = mysqli_fetch_array($getmultitbldel)) {
        mysqli_query($conn, "Update `tablemast` set `book`='' where `code`='$multitbldel[tableno]'") or die(mysqli_error($conn));
    }
    delnew($zdb, "$maindb", "$delcond", "$file?mode=last", $conn);
    delnew($zdb, "$trandb", "$delcond", "$file?mode=last", $conn);
    mysqli_query($conn, "unlock tables");
}


include("includes/linkshead.php");
?>
<script type="text/javascript" src="MyScript/bill.js"></script>
<style type="text/css">
    .padrow{
        margin-right:-3px;
        margin-left: 1px;
    }
</style>
</head>
<body>
    <form action='' method='POST' autocomplete="off">
        <!-- Default box -->
        <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 pad">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title" style="color:#BE99E9"><?php Echo $formname; ?><b class="pull-right"><?= $get['vouchtime'] ?></b></h3>

                </div>
                <div class="panel-body">

                    <div class="row">
                        <div class="col-lg-3 col-md-2 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">B. No.</label>
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-1 col-xs-1 pad">
                            <input type="text" class="form-control form vouchno" name="vouchno" value="<?php Echo ($addflag != 1) ? $qvouch : " $qvouch"; ?>" required readonly>
                            <input type="hidden" class="form-control form para" name="para" value="<?php Echo "$para"; ?>" >
                            <input type="hidden" class="form-control form admin" name="admin" value="<?php Echo "$admin"; ?>" >
                        </div>
                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">B. Date</label>
                        </div>
                        <div class="col-lg-3 col-md-3 col-sm-5 col-xs-5 pad">
                            <input type="date" class="form-control form vouchdt"  name="vouchdt" style="padding-right: 0px;" value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>" required  readonly >
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Staff</label>
                        </div>
                        <div class="col-lg-4 col-md-4 col-sm-8 col-xs-8 pad">
                            <select class="form-control form staff select2" name="staff" id="staff">
                                <option value="<?php echo ($addflag != 1) ? $get[user] : "" ?>"><?php echo ($addflag != 1) ? $get[user] : "" ?></option>
                                <?php
                                if ($addflag == 1) {
                                    $getwai2 = mysqli_query($conn, "Select code, user from $zroot.`passmain` where usertype = 'W' order by user") or die(mysqli_error($conn));
                                    while ($fettwai2 = mysqli_fetch_array($getwai2)) {
                                        echo "<option value='$fettwai2[user]'>$fettwai2[user]</option>";
                                    }
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Table</label>
                        </div>
                        <div class="col-lg-4 col-md-4 col-sm-8 col-xs-8 pad">
                            <select class="form-control form tableno  select2" name="tableno" id="tableno">
                                <option value="<?php echo ($addflag != 1) ? $get[tableno] : "" ?>"><?php echo ($addflag != 1) ? $fettab[name] : "" ?></option>
                                <?php
                                if ($addflag == 1) {
                                    $gettbl1 = mysqli_query($conn, "Select code, name from `tablemast` where book = '' order by name") or die(mysqli_error($conn));
                                    while ($fettbl1 = mysqli_fetch_array($gettbl1)) {
                                        echo "<option value='$fettbl1[code]'>$fettbl1[name]</option>";
                                    }
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="row">
                        <!--                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                                        <label class="label-control marg">Oms</label>
                                                    </div>
                                                    <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                                        <input type="checkbox" style="height:25px;width:25px" class="form-control form oms" <?php
                        if ($get[oms] == "1") {
                            Echo "checked";
                        }
                        ?> value="1" name="oms" style="background-color: yellowgreen; ">                            
                                                    </div>-->

                    </div>

                    <div class="panel-body table-responsive">
                        <table class="table table-bordered table-condensed" style="width: 100%">
                            <thead class="matdtl">
                                <tr class="mySearchTr" style="color: black">
                                    <!--<td style="width: 5%"></td>-->
                                    <td style="width: 5%">Sr.</td>
                                    <td style="width: 30%">Item</td>
                                    <td style="width: 6%"  class="text-right">Qty.</td>
                                    <td style="width: 9%"  class="text-right">Rate</td>
                                    <td style="width: 10%" class="text-right">Amount</td>
                                    <td style="width: 8%"  class="text-right">Disc %</td>
                                    <td style="width: 10%" class="text-right">Total</td>
                                    <td style="width: 18%">Remark</td>
                                </tr>
                            </thead>
                            <tbody class="matbody">
                                <?php
                                if ($addflag != 1) {
                                    $ctr = 0;
                                    $tctr = 0;
                                    $gettran = mysqli_query($conn, "Select * from `$trandb` where `vouchno` = '$get[vouchno]' order by subvouch ") or die(mysqli_error($conn));

                                    while ($tran = mysqli_fetch_array($gettran)) {
                                        $tctr++;
                                        $getitem = mysqli_query($conn, "Select code, name from `item` where code='$tran[item]'") or die(mysqli_error($conn));
                                        $fetitem = mysqli_fetch_array($getitem);

                                        Echo "<tr>";

//                                        Echo "<td><i class='' style='display:none;'></i></td>";
                                        Echo "<td><input type='text'   class='form-control form text-right srno'       name='srno_$ctr'       value='$tctr'></td>";
                                        Echo "<td>";
                                        Echo "<select class='form-control form item select2' name='item_$ctr' style='width:100%'>";
                                        Echo "<option value='$fetitem[code]'>$fetitem[name]</option>";
                                        $gitem = mysqli_query($conn, "SELECT `code`,`name` FROM `item` order by name")or die(mysqli_error($conn));
                                        while ($item = mysqli_fetch_array($gitem)) {
                                            Echo "<option value='$item[code]'>$item[name]</option>";
                                        }
                                        Echo "</select>";
                                        echo "</td>";
                                        Echo "<td><input type='number' class='form-control form text-right qty'      name='qty_$ctr'     value='$tran[qty]' step='any'></td>";
                                        Echo "<td><input type='number' class='form-control form text-right rate focusfield'     name='rate_$ctr'    value='$tran[rate]' step='any'></td>";
                                        Echo "<td><input type='number' class='form-control form text-right amount'   name='amount_$ctr'  value='$tran[amount]' step='any' readonly></td>";
                                        Echo "<td><input type='number' class='form-control form text-right cdiscperc' name='cdiscperc_$ctr'  value='$tran[cdiscperc]' step='any' format='#.00'>"
                                        . "<input type='hidden' class='form-control form text-right cdiscamt' name='cdiscamt_$ctr'  value='$tran[cdiscamt]' step='any'></td>"
                                        . "<input type='hidden' class='form-control form ' name='subvouch_$ctr'  value='$tran[subvouch]' step='any'></td>"
                                        . "<input type='hidden' class='form-control form ' name='kotprint_$ctr'  value='$tran[kotprint]' step='any'></td>";
                                        Echo "<td><input type='number' class='form-control form text-right total'    name='total_$ctr'  value='$tran[total]' step='any' readonly></td>";
                                        Echo "<td><input type='remtran' class='form-control form remtran'            name='remtran_$ctr'  value='$tran[remtran]' maxlength='15'></td>";
                                        Echo "</tr>";
                                        $ctr++;
                                    }
                                } else {
                                    ?>
                                    <tr>
                                        <!--<td><i class='' style='display:none;'></i></td>-->
                                        <td><input type='text'   class='form-control form text-right srno'       name='srno_0'       value='1'></td>
                                        <td>
                                            <select class='form-control form item select2' name='item_0' style='width:100%'>
                                                <option value=''></option>
                                                <?php
                                                $gitem = mysqli_query($conn, "SELECT `code`,`name` FROM `item` order by name")or die(mysqli_error($conn));
                                                while ($item = mysqli_fetch_array($gitem)) {
                                                    echo "<option value = '$item[code]'>$item[name]</option>";
                                                }
                                                ?>
                                            </select>
                                        </td>
                                        <td><input type='number' class='form-control form text-right qty'       name='qty_0'     value='0' step='any'></td>
                                        <td><input type='number' class='form-control form text-right rate'      name='rate_0'    value='0' step='any'></td>
                                        <td><input type='number' class='form-control form text-right amount'    name='amount_0'  value='0' step='any'></td>
                                        <td><input type='number' class='form-control form text-right cdiscperc'  name='cdiscperc_0'  value='0' step='any'>
                                            <input type='hidden' class='form-control form text-right cdiscamt'   name='cdiscamt_0'  value='0' step='any'>
                                            <input type='hidden' class='form-control form text-right'   name='subvouch_0'  value='0' step='any'>
                                            <input type='hidden' class='form-control form text-right'   name='kotprint_0'  value='0' step='any'>
                                        </td>
                                        <td><input type='number' class='form-control form text-right total'     name='total_0'    value='0' step='any'></td>
                                        <td><input type='text'   class='form-control form remtran'              name='remtran_0'  value='' maxlength="15"></td>
                                    </tr>
                                    <?php
                                }
                                ?>
                            </tbody>

                        </table>
                        <div class="matdtl">
                            <input type="button" style="height: 30px; width: 30px; padding: 0px" id="addnew" class="btn btn-success btn-lg form" value="+" />
                        </div>
                        <input type="hidden" id="items" name="items" value="<?php echo ($addflag != 1) ? $ctr : 1; ?>" />  
                        <div class="row padrow">

                            <div class="col-lg-10 col-md-2 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg">Sub Total</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                                <input type="number" step="any" class="form-control form  text-right  subtot" name="subtot" value="<?php Echo ($addflag != 1) ? $get["subtotal"] : "0" ?>" readonly>
                            </div>
                        </div>
                        <div class="row padrow">
                            <div class="col-lg-8 col-md-7 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg">Discount</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <input type="number" step="any" class="form-control form text-right  discperc" name="discperc" value="<?php Echo ($addflag != 1) ? $get["discperc"] : "0" ?>" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1  text-right  pad">
                                <label class="label-control marg">%</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                                <input type="number" step="any" class="form-control form text-right  discamt" name="discamt" value="<?php Echo ($addflag != 1) ? $get["discamt"] : "0" ?>" >
                            </div>
                        </div>
                        <div class="row padrow">

                            <div class="col-lg-10 col-md-7 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg">Taxable Value</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                                <input type="number" step="any" class="form-control form  text-right  taxable" name="taxable" value="<?php Echo ($addflag != 1) ? $get["taxable"] : "0" ?>" readonly>
                            </div>
                        </div>
                        <div class="row padrow">
                            <!--<div class="col-lg-6 col-md-6 col-sm-3 col-xs-3 numeric text-right pad">-->
                            <!--<label class="label-control marg">GST %</label>-->
                            <!--</div>-->
                            <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 pad" style="display:none">
                                <select class="form-control form select2 gstperc" name="gstperc" style="width:100%;" required>
                                    <option value="<?php echo ($addflag != 1) ? $fetgst['per'] : "5"; ?>"><? echo ($addflag != 1) ? $fetgst['name'] : "GST 5"; ?></option>
                                    <?php
                                    $ggsttype = mysqli_query($conn, "SELECT * FROM `gsttype` order by per")or die(mysqli_error($conn));
                                    while ($fgsttype = mysqli_fetch_object($ggsttype)) {
                                        Echo "<option value='$fgsttype->per'>$fgsttype->name</option>";
                                    }
                                    ?>
                                </select>
                            </div>

                            <div class="col-lg-8 col-md-7 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg">CGST</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <input type="number" step="any" class="form-control form text-right  cgstperc" name="cgstperc" value="<?php Echo ($addflag != 1) ? $get["cgstperc"] : "2.5" ?>" readonly>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1  text-right  pad">
                                <label class="label-control marg">%</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                                <input type="number" step="any" class="form-control form text-right  cgstamt" name="cgstamt" value="<?php Echo ($addflag != 1) ? $get["cgstamt"] : "0" ?>" readonly>
                            </div>
                        </div>
                        <div class="row padrow">
                            <div class="col-lg-8 col-md-7 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg">SGST</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <input type="number" step="any" class="form-control form text-right  sgstperc" name="sgstperc" value="<?php Echo ($addflag != 1) ? $get["sgstperc"] : "2.5" ?>" readonly>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1  text-right  pad">
                                <label class="label-control marg">%</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                                <input type="number" step="any" class="form-control form text-right  sgstamt" name="sgstamt" value="<?php Echo ($addflag != 1) ? $get["sgstamt"] : "0" ?>" readonly>
                            </div>
                        </div>

                        <div class="row padrow">

                            <div class="col-lg-10 col-md-7 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg">Net Amount</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                                <input type="number" step="any" class="form-control form text-right  netamt" name="netamt" value="<?php Echo ($addflag != 1) ? $get["netamt"] : "0" ?>" readonly>
                            </div>
                        </div>
                        <div class="row padrow">
                            <div class="col-lg-3  col-md-3 col-sm-8 col-xs-8 pad text-right" style="border : 1px solid black;padding-left: 10%">
                                <label class="label-control marg">Cash</label>
                                <input type="checkbox" class="form  cashchk" id="cashchk" name="cashchk" value="1" <?
                                if ($get['cashchk'] == 1) {
                                    Echo "checked";
                                }
                                ?>>

                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 pad" style="border : 1px solid black;border-left: none">
                                <input type="text" class="form-control form cashamt text-right" value="<? Echo ($addflag != 1) ? $get['cashamt'] : "0"; ?>" name="cashamt"  style="height:33px">
                            </div>
                        </div>
                        <div class="row padrow">
                            <div class="col-lg-3 col-md-3 col-sm-8 col-xs-8 pad text-right" style="border : 1px solid black;padding-left: 10%">
                                <label class="label-control marg">Other</label>
                                <input type="checkbox" class="form  cardchk" id="cardchk" name="cardchk" value="1" <?
                                if ($get['cardchk'] == 1) {
                                    Echo "checked";
                                }
                                ?>>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 pad" style="border : 1px solid black;border-left: none">
                                <input type="text" class="form-control form ccamt text-right" value="<? Echo ($addflag != 1) ? $get['ccamt'] : "0"; ?>" name="ccamt"  style="height:33px">
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 pad paymode" style="border : 1px solid black;border-left: none">
                                <select class="form-control form paytype  select2" name="paymode" >
                                    <option value="<? Echo ($addflag != 1 ) ? $get['paymode'] : "" ?>"><? Echo ($addflag != 1 ) ? $ftpay["name"] : "" ?></option>
                                    <?php
                                    $gtptype = mysqli_query($conn, "Select * from `paytype` order by name") or die(mysqli_error($conn));
                                    while ($fttype = mysqli_fetch_array($gtptype)) {
                                        echo "<option value='$fttype[code]'>$fttype[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <!--                        <div class="row padrow">
                                                    <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 pad text-right" align="center" style="border : 1px solid black;padding-left: 20%">
                                                        <label class="label-control marg">Both</label>
                                                        <input type="checkbox" class="form  bothchk" id="bothchk" name="bothchk" value="1" <?
                        if ($get['bothchk'] == 1) {
                            Echo "checked";
                        }
                        ?>>
                                                    </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 col-md-3 col-sm-4 col-xs-4 pad" style="border : 1px solid black;border-left: none">
                                                    <input type="hidden" class="form-control form credamt text-right" value="<? Echo ($addflag != 1) ? $get['credamt'] : "0"; ?>" name="credamt" >
                                                    </div>
                                                </div>-->
                    </div>

                </div>
                <div class="row">
                    <div class="col-lg-9">
                        <?php include("includes/buttons.php"); ?>
                    </div>
                    <div class="col-lg-2">
                        <input type="button" id="finishTab" class="btn btn-primary pull-right form" style="background-color:#78909C;color: #fff;" value="Check & Finish">
                    </div>
                </div>
            </div>


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

    </form>
    <div class="modal fade bs-example-modal-lg searchModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span>&times;</span></button>
                    <h4 class="modal-title" id="myLargeModalLabel">Search <? Echo $formname; ?></h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-lg-2">
                            <select class="form-control sfield select2 ">
                                <option value="1">B.No</option>
                                <option value="2">Date</option>
                                <option value="3">Time</option>
                                <option value="4">Waiter</option>
                                <option value="5">Total Items</option>
                                <option value="6">Total Qty.</option>
                            </select>
                        </div>
                        <div class="col-lg-2">
                            <select class="form-control select2 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 select2 sortBy">
                                <option value="">Sort By</option>
                                <option value="1">B.No</option>
                                <option value="2">Date</option>
                                <option value="3">Time</option>
                                <option value="4">Waiter</option>
                                <option value="5">Total Items</option>
                                <option value="6">Total Qty.</option>
                            </select> 
                        </div>
                        <div class="col-lg-2">
                            <select class="form-control orderAs select2 ">
                                <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 style="background-color:#26A69A;">
                                    <th>B.No</th>
                                    <th>Date</th>
                                    <th>Time</th>
                                    <th>Table</th>
                                    <th>Waiter</th>
                                    <th>Total Items</th>
                                    <th>Total Qty.</th>
                                    <th>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>


    <style type="text/css">
        @media screen and (min-width: 768px) {
            .modal-dialog {
                width: 700px; /* New width for default modal */
            }
            .modal-sm {
                width: 350px; /* New width for small modal */
            }
        }
        @media screen and (min-width: 992px) {
            .modal-lg {
                width: 950px; /* New width for large modal */
            }
        }
    </style>





    <?php include("includes/linksfoot.php"); ?>
</body>
</html> 