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

$formname = 'Cancelled Lead';
$maindb = 'leadenq';
$printfile = "";
$file = 'cancldmn.php';
$trandbexist = 0;
$grid = 'canclead.php';
$keyfld = "vouchno";
$keycond = " ";
$focusfield = "name";
$mgrpcode = '009';

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn,$zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

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

include("includes/linkshead.php");
?>
<!--<script src="MyScript/leadenq.js" type="text/javascript"></script>-->
<style type="text/css">
    table th{
        color: black;
    }
</style>
</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'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-5">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?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-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Voucher</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                                <input type="text" class="form-control form" id="vouchno" name="vouchno" disabled="" value="<?php Echo ($addflag != 1) ? $get["vouchno"] : "$qvouch"; ?>" >
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Enquiry Date</label>
                            </div>
                            <div class="col-lg-4 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control form vouchdt" name="vouchdt" value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date('Y-m-d'); ?>" >
                            </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-9 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form name" name="name" value="<?php Echo ($addflag != 1) ? $get["name"] : ""; ?>" autofocus="autofocus">
                            </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">Last Name</label>
                            </div>
                            <div class="col-lg-9 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form lastname" name="lastname" value="<?php Echo ($addflag != 1) ? $get["lastname"] : ""; ?>" >
                            </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">Remarks</label>
                            </div>
                            <textarea name="remarks" rows="2" cols="50"><?php Echo ($addflag != 1) ? $get["remarks"] : ""; ?></textarea>
                        </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 1</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" class="form-control form mobile" name="mobile" value="<?php Echo ($addflag != 1) ? $get["mobile"] : ""; ?>" >
                            </div>
                            <div class="col-lg-3 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Mobile 2</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" class="form-control form mobile2" name="mobile2" value="<?php Echo ($addflag != 1) ? $get["mobile2"] : ""; ?>" >
                            </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">Tel. 1</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" class="form-control form tel" name="tel" value="<?php Echo ($addflag != 1) ? $get["tel"] : ""; ?>" >
                            </div>
                            <div class="col-lg-3 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Tel. 2</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" class="form-control form tel2" name="tel2" value="<?php Echo ($addflag != 1) ? $get["tel2"] : ""; ?>" >
                            </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">Email Id</label>
                            </div>
                            <div class="col-lg-6 col-md-5 col-sm-5 col-xs-5 pad">
                                <input type="text" class="form-control form email" name="email" value="<?php Echo ($addflag != 1) ? $get["email"] : ""; ?>" >
                            </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">Email Id.2</label>
                            </div>
                            <div class="col-lg-6 col-md-5 col-sm-5 col-xs-5 pad">
                                <input type="text" class="form-control form email" name="email2" value="<?php Echo ($addflag != 1) ? $get["email2"] : ""; ?>" >
                            </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">Source</label>
                            </div>
                            <div class="col-lg-9 col-md-8 col-sm-8 col-xs-8 pad">
                                <select class="form-control form select2 source"  name="source">
                                    <option value="<? Echo ($addflag != 1 ) ? $get[source] : "" ?>"><? Echo ($addflag != 1 ) ? $get[source] : "" ?></option>
                                    <?
                                    $getsource = mysqli_query($conn,"SELECT * FROM `source`")or die(mysqli_error($conn));
                                    while ($msource = mysqli_fetch_array($getsource)) {
                                        Echo "<option value='$msource[name]'>$msource[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">Destination</label>
                            </div>
                            <div class="col-lg-9 col-md-8 col-sm-8 col-xs-8 pad">
                                <select class="form-control form select2 destination" name="destination">
                                    <option value="<? Echo ($addflag != 1 ) ? $get[destination] : "" ?>"><? Echo ($addflag != 1 ) ? $get[destination] : "" ?></option>
                                    <?
                                    $getdest = mysqli_query($conn,"SELECT * FROM `destination`")or die(mysqli_error($conn));
                                    while ($mdest = mysqli_fetch_array($getdest)) {
                                        Echo "<option value='$mdest[name]'>$mdest[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">Travel Date</label>
                            </div>
                            <div class="col-lg-4 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control form travdate" name="travdate" value="<?php Echo ($addflag != 1) ? $get["deptdate"] : ""; ?>" >
                            </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">Adult</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control form adult" name="adult" value="<?php Echo ($addflag != 1) ? $get["adult"] : "0"; ?>" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg">Child</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control form child" name="child" value="<?php Echo ($addflag != 1) ? $get["child"] : "0"; ?>" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg">Infant</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control form infant" name="infant" value="<?php Echo ($addflag != 1) ? $get["infant"] : "0"; ?>" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg">Semi Infant</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control form semiinf" name="semiinf" value="<?php Echo ($addflag != 1) ? $get["semiinf"] : "0"; ?>" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <label style="color: red;" class="label-control marg">Total</label>
                            </div>
                            <div style="color: red;" class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text"  style="color: red;background-color: #E7E7E7;" class="form-control form totpax" name="totpax" value="<?php Echo ($addflag != 1) ? $get["totpax"] : "0"; ?>" >
                            </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">City</label>
                            </div>
                            <div class="col-lg-6 col-md-5 col-sm-5 col-xs-5 pad">
                                <input type="text" class="form-control form city" name="city" value="<?php Echo ($addflag != 1) ? $get["city"] : ""; ?>" >
                            </div>
                        </div>
                    </div>
                    <div style="padding-left: 40%;" class="panel-footer">

                        <input type="button" name="exit" value="Exit" id="cancel" class="btn btn-danger" onClick="window.location.href = '<?= $file . "?mode=last" ?>'">
                    </div>

                </div>
            </div>
            
        </div>
    </form>
    <script>
        $(document).ready(function () {

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