<?php
ob_start();
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');
$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

$zroot = $_SESSION["zdir"];
include("includes/linkshead.php");
?>
<script type="text/javascript">
    $(document).ready(function () {
        $("body").on('click', '.checkdata', getData);
        function getData() {
            var district = $(".district").val(),
                    state = $(".state").val(),
                    forr = $(".for").val(),
                    airline = $(".airline").val(),
                    flightno = $(".flightno").val(),
                    batch = $(".batch").val(),
                    bjdate = $(".bjdate").val(),
                    jbdate = $(".jbdate").val(),
                    fromhaji = $(".fromhaji").val(),
                    tohaji = $(".tohaji").val(),
                    frompax = $(".frompax").val(),
                    topax = $(".topax").val();
            $(".tbody").empty();

            $.post('checkSmsData.php', {district: district, state: state, forr: forr, airline: airline,
                flightno: flightno, batch: batch, bjdate: bjdate, jbdate: jbdate,
                fromhaji: fromhaji, tohaji: tohaji, frompax: frompax, topax: topax}, function (data) {
                $(data).appendTo('.tbody');
            });

        }
    });
</script>

</head>
<body>

    <form action="smsnew.php" method="post">
        <div class="row">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><?php Echo $formname; ?></h3>
                    <!--<h3 class="pull-right" style="padding:0px"></h3>-->
                </div>
                <div class="panel-body">
                    <div class="col-lg-10">

                        <div class="row">
                            <div class="col-lg-1 text-right">
                                <label class="label-control">District</label>
                            </div>
                            <div class="col-lg-2">
                                <select name="district" class="form-control district">
                                    <option value=""></option>
                                    <?php
                                    $getdis = mysqli_query($conn, "SELECT DISTINCT `district` FROM `pax` ORDER BY `district` ") or die(mysqli_error($conn));
                                    while ($getdis2 = mysqli_fetch_assoc($getdis)) {
                                        echo "<option value=\"$getdis2[district]\">$getdis2[district]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1 text-right">
                                <label class="label-control">State</label>
                            </div>
                            <div class="col-lg-2">
                                <select name="state" class="form-control state">
                                    <option value=""></option>
                                    <?php
                                    $getstate = mysqli_query($conn, "SELECT DISTINCT `state` FROM `pax` ORDER BY `state` ") or die(mysqli_error($conn));
                                    while ($getstate2 = mysqli_fetch_assoc($getstate)) {
                                        echo "<option value=\"$getstate2[state]\">$getstate2[state]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1 text-right">
                                <label class="label-control">For</label>
                            </div>
                            <div class="col-lg-2">
                                <select name="for" class="form-control for">
                                    <option value=""></option>
                                    <?php
                                    $getfor = mysqli_query($conn, "SELECT `name` FROM $zroot.`vistingfor`") or die(mysqli_error($conn));
                                    while ($getfor2 = mysqli_fetch_assoc($getfor)) {
                                        echo "<option value=\"$getfor2[name]\">$getfor2[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1 text-right">
                                <label class="label-control">Airline</label>
                            </div>
                            <div class="col-lg-2">
                                <select name="airline" class="form-control airline">
                                    <option value=""></option>
                                    <?php
                                    $getair = mysqli_query($conn, "SELECT DISTINCT `airline_code` FROM `airline_detail` ORDER BY `airline_code` ") or die(mysqli_error($conn));
                                    while ($getair2 = mysqli_fetch_assoc($getair)) {
                                        echo "<option value=\"$getair2[airline_code]\">$getair2[airline_code]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <!--                            <div class="col-lg-1 text-right">
                                                            <label class="label-control">Batch</label>
                                                        </div>
                                                        <div class="col-lg-1 text-right">
                                                            <input type="text" name="batch" id="batch" class="form-control" style="width: 100px;"  />
                                                        </div>-->
                        </div>
                        <div class="row">
                            <div class="col-lg-1 text-right">
                                <label class="label-control">Flight No.</label>
                            </div>
                            <div class="col-lg-2">
                                <select name="flightno" class="form-control flightno">
                                    <option value=""></option>
                                    <?php
                                    $getflt = mysqli_query($conn, "SELECT DISTINCT `flightno` FROM `airline_detail` ORDER BY `flightno` ") or die(mysqli_error($conn));
                                    while ($getflt2 = mysqli_fetch_assoc($getflt)) {
                                        echo "<option value=\"$getflt2[flightno]\">$getflt2[flightno]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <div class="col-lg-1 text-right">
                                <label class="label-control">Batch</label>
                            </div>
                            <div class="col-lg-1 text-right">
                                <input type="text" name="batch" id="batch" class="form-control batch" style="width: 100px;"  />
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1 text-right">
                                <label class="label-control">Flight Date</label>
                            </div>
                            <div class="col-lg-2">
                                <select name="bjdate" class="form-control bjdate">
                                    <option value=""></option>
                                    <?php
                                    $getdate = mysqli_query($conn, "SELECT DISTINCT `dept_date` FROM `airline_detail` ORDER BY `dept_date` ") or die(mysqli_error($conn));
                                    while ($getdate2 = mysqli_fetch_assoc($getdate)) {
                                        echo "<option value=\"$getdate2[dept_date]\">" . $getdate2["dept_date"] . "</option>";
                                    }
                                    ?>
                                </select>
                            </div>
<!--                            <div class="col-lg-1 text-right">
                                <label class="label-control">J/B Date</label>
                            </div>
                            <div class="col-lg-2">
                                <select name="jbdate" class="form-control jbdate">
                                    <option value=""></option>
                                    <?php
//                                    $getarv = mysqli_query($conn, "SELECT DISTINCT `dept_date` FROM `airline_detail` WHERE srno = 2 ORDER BY `dept_date` ") or die(mysqli_error($conn));
//                                    while ($getarv2 = mysqli_fetch_assoc($getarv)) {
//                                        echo "<option value=\"$getarv2[dept_date]\">" . $getarv2["dept_date"] . "</option>";
//                                    }
                                    ?>
                                </select>       
                            </div>-->
                        </div>
                        <!--                        <div class="row">
                                                    <div class="col-lg-1 text-right">
                                                        <label class="label-control">Sister Concern</label>
                                                    </div>
                                                    <div class="col-lg-3">
                                                        <select name="siscono" class="form-control">
                                                            <option value="">All</option>
                        <?php
//                                    $getsiscon = mysqli_query($conn, "SELECT * FROM $zroot.`sisterconcern`  ORDER BY `name` ") or die(mysqli_error($conn));
//                                    while ($getsiscon2 = mysqli_fetch_assoc($getsiscon)) {
//                                        echo "<option value=\"$getsiscon2[siscono]\">" . $getsiscon2["name"] . "</option>";
//                                    }
                        ?>
                                                        </select>
                                                    </div>
                        
                                                </div>-->
                        <div class="row">
                            <div class="col-lg-1 text-right">
                                <label class="label-control">From Haji No.</label>
                            </div>
                            <div class="col-lg-2">
                                <input type="text" class="form-control fromhaji" name="fromhaji" id="fromhaji" style="" value="0"  />  &nbsp; 

                            </div>
                            <div class="col-lg-1 text-right">
                                <label class="label-control">To Haji No.</label>
                            </div>
                            <div class="col-lg-2">
                                <input type="text" class="form-control tohaji" name="tohaji" id="tohaji" style="" value="0"  />  &nbsp; 

                            </div>

                        </div>
                        <div class="row">
                            <div class="col-lg-1 text-right">
                                <label class="label-control">From Pax No.</label>
                            </div>
                            <div class="col-lg-2">
                                <input type="text" class="form-control frompax" name="frompax" id="frompax" style="" value="0"  />  &nbsp; 

                            </div>
                            <div class="col-lg-1 text-right">
                                <label class="label-control">To Pax No.</label>
                            </div>
                            <div class="col-lg-2">
                                <input type="text" class="form-control topax" name="topax" id="topax" style="" value="0"  />  &nbsp; 

                            </div>


                        </div>
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-2">
                                <input type="button" name="checkdata" class="checkdata" value="Check Data" />
                            </div>

                        </div>
                        <div class="row smsdata tbody" style="overflow-y: scroll;height:400px">

                        </div>
                    </div>

                    <div class="col-lg-2">
                        <div style="float:right;">
                            <p style="padding:4px; margin: 4px;">
                                <textarea rows="5" cols="50" name="sms" id="sms" maxlength="160"></textarea>
                            </p>
                            <p style="padding:4px; margin: 4px;">
                                <input type="text" name="cnt" id="cnt" value="0" disabled="disabled" style="width: 50px; background:#66FFCC; color:red; font-weight: bold; " />

                            </p>
                            <p style="padding:4px; margin: 4px;">
                                <input type="submit" name="submit" value="Send" />
                            </p>
                        </div>
                        <div style="clear:both"></div>
                    </div>
                </div>
            </div>


        </div>

    </form>
</body>

<script type="text/javascript">
    $(function () {
        $("#sms").keypress(function () {
            var sms = $(this).val().length;
            if (sms >= 160) {
                $(this).attr("maxlength", "160");
            }
            $("#cnt").val(sms);
        });

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