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

$formname = 'Check In Form';
$maindb = 'hotmain';
$trandb = 'hottran';
// $printfile = "hallbook_pdf.php";
$file = 'checkin.php';
$trandbexist = 0;
$grid = '';
$fseries = $_SESSION["series_" . $dbname];
$keycond = " and `series`='$fseries'";
$keyfld = "vouchno";

$focusfield = "name";

$adduser = $_SESSION['username_' . $dbname];
date_default_timezone_set("Asia/Kolkata");
$adddate = date("Y-m-d");
$addtime = date("h:i:sa");
$rettime = date("h:i:sa");
$usertype = $_SESSION["usertype_" . $dbname];
$zroot = $_SESSION["zdbroot"];

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

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

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

    foreach ($_POST as $key => $value) {
        $exclude_fld = ["test"];
        if (in_array($key, $exclude_fld)) {
            continue;
        }
        $$key = $value;
        // echo "Field ".htmlspecialchars($key)." is ".htmlspecialchars($value)."<br>";
    }
    $count = $_POST["items"];

    $a = 1;

    $voucher = $vouchno;
    $mvouch = $qvouch;

    $path = "images/hotelbook/";

    #####################IMAGE#####################
    $filename1 = $mvouch . ".jpg";
    $img_file1 = $path . ($filename1);
    $image_ftype = pathinfo($img_file1, PATHINFO_EXTENSION);

    $uploadOk = 1;

    if ($uploadOk == 1) {
        move_uploaded_file($_FILES["idimg"]["tmp_name"], $img_file1);
    } else {
        browse("Sorry, there was an error uploading your file.");
        header("refresh: 1; $file?mode=last");
    }

    if ($a == 1) {

        mysqli_query($conn, "DELETE FROM `$trandb` WHERE `$keyfld`='$mvouch' $keycond") or die(mysqli_error($conn));
        // mysqli_query($conn, "DELETE FROM `$stkdb` WHERE `$keyfld`='$mvouch' and `source`='$source' $keycond") or die(mysqli_error($conn));
        //        mysqli_query($conn, "DELETE FROM $zroot.$combstkdb WHERE `$keyfld`='$mvouch' AND `source`='$source' and `compcode`='$compcd'")or die(mysqli_error($conn));


        $srl = 0;
        for ($i = 0; $i <= $count; $i++) {
            $srno = $_POST["srno_$i"];
            $paxname = $_POST["tname_$i"];
            $gender = $_POST["tgender_$i"];
            $age = $_POST["tage_$i"];

            if (!empty($paxname)) {
                $srl++;
                mysqli_query($conn, "INSERT INTO `$trandb`(`srno`, series,  `vouchno`, `paxname`, `gender`, `age`)
                                        VALUES( '$srl', '$fseries', '$voucher', '$paxname', '$gender', '$age')") or die(mysqli_error($conn));

                ##########sTOCK pART########
                // mysqli_query($conn, "INSERT INTO `$stkdb`(`srno`, series, `compcode`, `yearno`, `vouchno`, `vouchdt`, `source`, `barcode`, `itemcode`,  `qty`, `unit`, `mrp`, `rate`, `amount`,color)
                //                         VALUES( '$srl', '$fseries', '$compcd', '$myyear', '$qvouch', '$vouchdt', '$source', '$barcode', '$item', '$trqty', '$unit', '$mrp', '$rate', '$amount','$color')") or die(mysqli_error($conn));

                //                ##########Combine Stock Part########
                //                mysqli_query($conn, "INSERT INTO $zroot.$combstkdb(`srno`, `compcode`, `yearno`, `vouchno`, `vouchdt`, `source`, `barcode`, `itemcode`,  `qty`, `unit`, `mrp`, `rate`, `amount`)
                //                                        VALUES( '$srl', '$compcd', '$myyear', '$qvouch', '$vouchdt', '$source', '$barcode', '$item', '$trqty', '$unit', '$mrp', '$rate', '$amount')") or die(mysqli_error($conn));
            }
        }

        if ($addflag == 1) {
            mysqli_query($conn, "INSERT INTO `$maindb`(`vouchno`, `code`, `vouchdt`, `persons`, `chkdt`, `formem`, `memcode`, `memname`,
                                                       `add1`, `add2`, `add3`, `mob1`, `mob2`, `carno`, `vehicle`, `plfrm`, `plto`, `purpose`,
                                                     `pan`,`aadhaar`,`staff`, `agent`, `commission`, `daysno`, `outdt`,
                                                       `roomno`, `rate`, `extra`, `paytype`, `acnon`, `disc`, `advance`, `remark1`, `remark2`, `totamt`,`adddate`,
                                                        `addtime`, `series`, `idimg`, `area`, `city`, `pin`, `balance`)
                                                VALUES('$qvouch', '$code', '$vouchdt', '$persons', '$chkdt', '$formem', '$memcode', 
                                                '$memname', '$add1', '$add2', '$add3', '$mob1','$mob2', '$carno', '$vehicle', '$plfrm',
                                                '$plto', '$purpose', '$pan', '$aadhaar','$staff', '$agent', '$commission', '$daysno',
                                                '$outdt', '$roomno', '$rate', '$extra', '$paytype', '$acnon', '$disc', '$advance', '$remark1',
                                                '$remark2', '$totamt' , '$adddate', '$addtime', '$fseries', '$img_file1', '$area', '$city', '$pin', '$balance')") or die(mysqli_error($conn));
            insmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        } else {
            $mvouch = $qvouch;

            mysqli_query($conn, "UPDATE `$maindb` SET `code`='$code', `vouchdt`='$vouchdt', `persons`='$persons', `chkdt`='$chkdt', 
                                                      `formem`='$formem', `memcode`='$memcode', `memname`='$memname', 
                                                      `add1`='$add1', `add2`='$add2', `add3`='$add3', `mob1`='$mob1', `mob2`='$mob2', 
                                                      `carno`='$carno', `vehicle`='$vehicle', `plfrm`='$plfrm', `plto`='$plto',
                                                      `purpose`='$purpose', `pan`='$pan', `aadhaar`='$aadhaar', 
                                                      `staff`='$staff', `agent`='$agent', `commission`='$commission', `daysno`='$daysno', 
                                                      `outdt`='$outdt', `roomno`='$roomno', `rate`='$rate', 
                                                      `extra`='$extra',`paytype`='$paytype',`acnon`='$acnon',`disc`='$disc', `advance`='$advance', 
                                                      `remark1`='$remark1', `remark2`='$remark2', `totamt`='$totamt', `idimg`='$img_file1',
                                                      `area`='$area',`city`='$city',
                                                      `pin`='$pin', `balance`='$balance' where vouchno = '$mvouch' $keycond") 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' $keycond ") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);

    $ghall = mysqli_query($conn, "SELECT * FROM hallname WHERE code = '$get[hall]' ") or die(mysqli_error($conn));
    $fhall = mysqli_fetch_object($ghall);
}

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

if (isset($_GET["delete"])) {
    //    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    //    delete($zdb, "$trandb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    $delcondn = " vouchno = '$_GET[vouchno]' $keycond";
    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]' $keycond";
    delnew($zdb, "$maindb", "$delcondn", "$file?mode=last&series=$fseries");
    delnew($zdb, "$trandb", "$delcondn", "$file?mode=last&series=$fseries");
    // delnew($zdb, "$stkdb", "$delcond", "$file?mode=last&series=$fseries");
}

include("includes/linkshead.php");
?>

<script src="MyScript/checkin.js" type="text/javascript"></script>
<script src="MyScript/checkin_search.js" type="text/javascript"></script>
</head>

<body>
    <form action='' method='POST' enctype="multipart/form-data">
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php echo $formname .
                                                    "<span style='float:right'>  Created At :  " . humanDate($get['created_at']) . "<br /> Updated At : " . humanDate($get['updated_at']) . "</span> "; ?></h3>
                    </div>
                    <!-- <br>
                    <br> -->
                    <div class="panel-body" style="margin-top: 8px;">
                        <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">Booking No</label>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" name="vouchno" class="form-control form vouchno" value="<?php echo ($addflag != 1) ? $get["vouchno"] : $qvouch; ?>" readonly>
                                <input type="hidden" name="voucher" class="form-control form voucher" value="<?php echo ($addflag != 1) ?: $qvouch; ?>">
                                <input type="hidden" class="form-control form code" name="code" value="<?php echo ($addflag != 1) ? $get["code"] : ""; ?>">
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Booking Date</label>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" name="vouchdt" class="form-control  form vouchdt" value="<?php echo ($addflag != 1) ? $get["vouchdt"] : date('Y-m-d'); ?>">
                            </div>
                            <!-- <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">No. Of Pers.</label>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" name="persons" class="form-control  form persons" value="<?php echo ($addflag != 1) ? $get["persons"] : ""; ?>">
                            </div> -->
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Check In Date</label>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="datetime-local" name="chkdt" class="form-control form chkdt" value="<?php echo ($addflag != 1) ? $get["chkdt"] : date('Y-m-d'); ?>">
                            </div>


                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <button type="button" id="paxdtls" class="form-control paxdtls" data-toggle="modal" data-target="#add_data_modal" style="background-color:#DAF7A6;">
                                    Pax Details
                                </button>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">No. Of Person</label>
                            </div>
                            <?php $result2 = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$get[vouchno]' $keycond ORDER BY `srno`") or die(mysqli_error($conn));
                            $personcount = mysqli_num_rows($result2);
                            ?>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <input type="text" name="persons" style="width:50%" class="form-control form persons" value="<?php echo ($addflag != 1) ? $personcount : ""; ?>" readonly tabindex="-1">
                            </div>

                        </div>
                        <hr style="border:2px solid black">
                        <div class="col-lg-6" style="border-right:2px solid black">
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">For</label>
                                </div>
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                    <select class="form-control form formem" name="formem" id="formem">
                                        <option value="<?= $get['formem'] ?>"><?= $get['formem'] ?></option>
                                        <option value="Member">Member</option>
                                        <option value="Non-Member">Non-Member</option>
                                    </select>
                                </div>
                                <?php
                                $vis = "";
                                if ($get['formem'] != 'Member') {
                                    $vis = "style ='display:none'";
                                } ?>
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right hidemem pad" <?= $vis ?>>
                                    <label class="label-control marg">Member Code</label>
                                </div>
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 hidemem pad" <?= $vis ?>>
                                    <input type="text" name="memcode" class="form-control form memcode" value="<?php echo ($addflag != 1) ? $get['memcode'] : ""; ?>">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Name</label>
                                </div>
                                <div class="col-lg-8 col-md-3 col-sm-3 col-xs-3 pad">
                                    <input type="text" name="memname" class="form-control form memname" value="<?php echo ($addflag != 1) ? $get['memname'] : ""; ?>">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Address</label>
                                </div>
                                <div class="col-lg-8 col-md-3 col-sm-3 col-xs-3 pad">
                                    <input type="text" name="add1" class="form-control form add1" value="<?php echo ($addflag != 1) ? $get['add1'] : ""; ?>">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg"></label>
                                </div>
                                <div class="col-lg-8 col-md-3 col-sm-3 col-xs-3 pad">
                                    <input type="text" name="add2" class="form-control form add2" value="<?php echo ($addflag != 1) ? $get['add2'] : ""; ?>">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg"></label>
                                </div>
                                <div class="col-lg-8 col-md-3 col-sm-3 col-xs-3 pad">
                                    <input type="text" name="add3" class="form-control form add3" value="<?php echo ($addflag != 1) ? $get['add3'] : ""; ?>">
                                </div>
                            </div>
                            <div class="row">
                                <!-- <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Area</label>
                                </div>
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                    <input type="text" name="area" class="form-control form area" value="<?php echo ($addflag != 1) ? $get['area'] : ""; ?>">
                                </div> -->
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">City</label>
                                </div>
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                    <input type="text" name="city" class="form-control form city" value="<?php echo ($addflag != 1) ? $get['city'] : ""; ?>">
                                </div>
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Pin</label>
                                </div>
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                    <input type="text" name="pin" class="form-control form pin" value="<?php echo ($addflag != 1) ? $get['pin'] : ""; ?>">
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Mobile</label>
                                </div>
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                    <input type="text" name="mob1" class="form-control form mob1" value="<?php echo ($addflag != 1) ? $get['mob1'] : ""; ?>">
                                </div>
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Tel.</label>
                                </div>
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                    <input type="text" name="mob2" class="form-control form mob2" value="<?php echo ($addflag != 1) ? $get['mob2'] : ""; ?>">
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Vehicle No.</label>
                                </div>
                                <div class="col-lg-3 col-md-8 col-sm-8 col-xs-8 pad">
                                    <input type="text" name="carno" class="form-control form carno" value="<?php echo ($addflag != 1) ? $get['carno'] : ""; ?>">
                                </div>
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Vehicle Name</label>
                                </div>
                                <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                    <input type="text" name="vehicle" class="form-control form vehicle" value="<?php echo ($addflag != 1) ? $get['vehicle'] : ""; ?>">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Place From</label>
                                </div>
                                <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                    <input type="text" name="plfrm" class="form-control form plfrm" value="<?php echo ($addflag != 1) ? $get['plfrm'] : ""; ?>">
                                </div>
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">To Where</label>
                                </div>
                                <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                    <input type="text" name="plto" class="form-control form plto" value="<?php echo ($addflag != 1) ? $get['plto'] : ""; ?>">
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Purpose of Visit</label>
                                </div>
                                <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                    <input type="text" class="form-control form purpose" name="purpose" value="<?php echo ($addflag != 1) ? $get["purpose"] : ""; ?>">
                                </div>
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Photo ID</label>
                                </div>
                                <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                    <input type="file" class="form-control form  idimg" name="idimg">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Pan Card</label>
                                </div>
                                <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                    <input type="text" class="form-control form  pan" name="pan" value="<?php echo ($addflag != 1) ? $get["pan"] : ""; ?>">
                                </div>
                                <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad" style="float: right;">
                                    <img src="<?= $get['idimg'] ?>" alt="Insert Img" style="height:100px;width:200px;margin-bottom:-120px">
                                </div>
                            </div>
                            <div class="row">
                            </div>
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Aadhaar Card</label>
                                </div>
                                <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                    <input type="text" class="form-control form  aadhaar" name="aadhaar" value="<?php echo ($addflag != 1) ? $get["aadhaar"] : ""; ?>">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Agent</label>
                                </div>
                                <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                    <select class="form-control form agent select2" id="agent" name="agent" style="width: 100%">
                                        <?php
                                        $getagent = mysqli_query($conn, "SELECT * FROM hotelag where code='$get[agent]'") or die(mysqli_error($conn));
                                        $fetagent = mysqli_fetch_object($getagent);
                                        ?>
                                        <option value="<?php echo ($addflag != 1) ? $fetagent->code : ""; ?>"><?php echo ($addflag != 1) ? $fetagent->name : ""; ?></option>
                                        <?php
                                        $gagent = mysqli_query($conn, "SELECT * FROM hotelag WHERE `code`!='' ") or die(mysqli_error($conn));
                                        while ($fagent = mysqli_fetch_array($gagent)) {
                                            echo "<option value='$fagent[code]'>$fagent[name]</option>";
                                        }
                                        //                                    }
                                        ?>
                                    </select>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                    <label class="label-control marg">Commission </label>
                                </div>
                                <div class="col-lg-3 col-md-2 col-sm-2 col-xs-2 pad">
                                    <input type="text" class="form-control form text-right commission" name="commission" value="<?php echo ($addflag != 1) ? $get["commission"] : ""; ?>">
                                </div>

                            </div>
                        </div>
                    </div>
                    <hr style="border:2px solid black">
                    <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">Check Out Date</label>
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="datetime-local" class="form-control form outdt" name="outdt" value="<?php echo ($addflag != 1) ? $get["outdt"] : ""; ?>">
                        </div>

                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Room No.</label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <select class="form-control form roomno select2" id="roomno" name="roomno" style="width: 100%">

                                <option value="<?php echo ($addflag != 1) ? $get['roomno'] : ""; ?>"><?php echo ($addflag != 1) ? $get['roomno'] : ""; ?></option>
                                <?php
                                $getroom = mysqli_query($conn, "SELECT * FROM $zroot.`room` WHERE `code`!='' ") or die(mysqli_error($conn));
                                while ($froom = mysqli_fetch_array($getroom)) {
                                    echo "<option value='$froom[roomno]'>$froom[roomno]</option>";
                                }

                                ?>
                            </select>
                        </div>
                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Rate Per Day</label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form text-right rate" name="rate" value="<?php echo ($addflag != 1) ? $get["rate"] : 0; ?>">
                        </div>
                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Extra Charges</label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form text-right extra" name="extra" value="<?php echo ($addflag != 1) ? $get["extra"] : 0; ?>">
                        </div>
                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">No. Of Days </label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form text-right daysno" name="daysno" value="<?php echo ($addflag != 1) ? $get["daysno"] : ""; ?>" readonly tabindex="-1">
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-4 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Payment Type</label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <select class="form-control form paytype" name="paytype" id="paytype">
                                <option value=" <?php echo ($addflag != 1) ? $get['paytype'] : "";  ?>"><?php echo ($addflag != 1) ? $get['paytype'] : ""; ?></option>
                                <option value=""></option>
                                <option value="Cash">Cash</option>
                                <option value="Bank Payment">Bank Payment</option>
                                <option value="UPI ID">UPI ID</option>
                            </select>
                        </div>
                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Room Type</label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form acnon" name="acnon" value="<?php echo ($addflag != 1) ? $get["acnon"] : ""; ?>">
                        </div>
                        <div class="col-lg-3  col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Discount</label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form text-right disc" name="disc" value="<?php echo ($addflag != 1) ? $get["disc"] : 0; ?>">
                        </div>


                    </div>

                    <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">Remarks</label>
                        </div>
                        <div class="col-lg-5 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form remark1" name="remark1" value="<?php echo ($addflag != 1) ? $get["remark1"] : ""; ?>">
                        </div>
                        <div class="col-lg-4 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Total Amount</label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form text-right totamt" name="totamt" value="<?php echo ($addflag != 1) ? $get["totamt"] : ""; ?>" readonly>
                        </div>
                    </div>

                    <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"></label>
                        </div>
                        <div class="col-lg-5 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form remark2" name="remark2" value="<?php echo ($addflag != 1) ? $get["remark2"] : ""; ?>">
                        </div>
                        <div class="col-lg-4  col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Advance</label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form text-right advance" name="advance" value="<?php echo ($addflag != 1) ? $get["advance"] : 0; ?>">
                        </div>
                        <!-- <div class="col-lg-4 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Bill Amount</label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form text-right netamt" name="netamt" value="<?php echo ($addflag != 1) ? $get["netamt"] : 0; ?>" readonly>
                        </div> -->
                    </div>
                    

                    <div class="row">
                        <div class="col-lg-10 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Balance</label>
                        </div>
                        <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="text" class="form-control form text-right balance" name="balance" value="<?php echo ($addflag != 1) ? $get["balance"] : ""; ?>" readonly>
                        </div>
                    </div>
                    <div class="panel-footer">
                        <?php include("includes/buttons.php"); ?>
                    </div>
                </div>
            </div>
        </div>



        <div class="modal fade-modal tranmodal" id="add_data_modal" 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">Pax Details</h4>
                    </div>
                    <div class="modal-body">
                        <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="50%">Name</th>
                                        <th width="20%">Gender</th>
                                        <th width="20%">Age</th>
                                    </tr>
                                </thead>
                                <tbody class="tbody">
                                    <?php
                                    if ($addflag != 1) {
                                        $ctr = 0;
                                        $gettran = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$get[vouchno]' $keycond ORDER BY `srno`") or die(mysqli_error($conn));
                                        while ($tran = mysqli_fetch_array($gettran)) {

                                            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='$tran[srno]'></td>";

                                            echo "<td><input type='text' class='form-control form tname'  name='tname_$ctr' value='$tran[paxname]'>  </td>";
                                            echo "<td><input type='text' class='form-control form tgender'   name='tgender_$ctr'        value='$tran[gender]'>   </td>";
                                            echo "<td><input type='text' class='form-control form tage' name='tage_$ctr' value='$tran[age]'> </td>";
                                            echo "</tr >";
                                            $ctr++;
                                        }
                                    } else {
                                        $pctr = 0;
                                    ?>
                                        <tr>
                                            <td><i class="fa fa-close remove"></i></td>
                                            <td><input type="text" class="form-control form text-right srno" name="srno_0" value="1"></td>
                                            <td><input type="text" class="form-control form tname" name="tname_0" value=""></td>
                                            <td><input type="text" class="form-control form tgender" name="tgender_0" value=""></td>
                                            <td><input type="text" class="form-control form tage" name="tage_0" value=""></td>
                                        </tr>
                                    <?php
                                    }
                                    $pctr++;
                                    ?>
                                </tbody>
                            </table>
                            <div class="row">
                                <div class="col-lg-1">
                                    <button type="button" class="btn btn-square form" style="background-color: #78909C" 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>


                        </div>
                    </div>
                    <div class="modal-footer">
                        <!-- <button type="button" class="btn btn-primary savepart form">Exit</button> -->
                    </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">
                                <option value="1">Voucher</option>
                                <option value="2">Booking Date</option>
                                <option value="3">Name</option>
                                <option value="4">Address</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="1">Voucher</option>
                                <option value="2">Booking Date</option>
                                <option value="3">Name</option>
                                <option value="4">Address</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" style="border-radius: 5px" 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="3%">Voucher No</th>
                                    <th width="7%">Booking Date</th>
                                    <th width="30%">Name</th>
                                    <th width="20%">Address</th>
                                    <th width="5%">Mobile</th>
                                    <th width="10%">Amount</th>
                                    <th width="5%">Action</th>
                                </tr>
                            </thead>
                            <tbody class="sTbody">
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 text-right search-action-bar">
                            <input type="button" style="border-radius: 5px" class="btn btn-primary sprev" value="Previous">
                            <input type="button" style="border-radius: 5px" 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>