<?php
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');
header("Content-Type: text/html;charset=UTF-8");


$formname = 'Common SMS';
$maindb = 'member';
$trandb = '';
$printfile = "";
$file = 'smsaddress.php';
$trandbexist = 0;
$grid = '';
$keyfld = "id";
$keycond = "";

$admin = $_SESSION["admin_" . $dbname];
$username = $_SESSION["username_" . $dbname];
$zroot = $_SESSION["zdbroot"];
$zroot1 = substr($zroot, 0, -4);
$myear = $_SESSION[$myyear];
$fseries = $_SESSION["society_" . $dbname];

$zdb = $_SESSION["zdbyear_" . $dbname];
//mysqli_select_db($conn, $zdb);
$result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE length(mobile) = 10 ORDER BY name") or die(mysqli_error($conn));
include("includes/linkshead.php");
?>
<style>
    input[type = checkbox]{
        width: 20px;
        height: 20px;
    }
</style>
<!--<style type="text/css">
    #table-wrapper {
        position:relative;
    }
    #table-scroll {
        height:799px;
        width:754px;
        overflow:auto;
        margin-top:20px;
    }
    #table-wrapper table {
        width:70%;

    }
    #table-wrapper table * {
        background:palegoldenrod;
        color:black;
    }
    #table-wrapper table thead th .text {
        position:absolute;   
        top:-20px;
        z-index:2;
        height:20px;
        width:45%;
        border:1px solid red;
    }
</style>-->
<script>
    $(function () {
        $("#example1").DataTable();
        $('#example2').DataTable({
            "paging": true,
            "lengthChange": false,
            "searching": false,
            "ordering": true,
            "info": true,
            "autoWidth": false
        });
    });
</script>
<script>
    $(document).ready(function () {
        $("#sms").keyup(function () {
            $('input[type="text"]').val(refresh());
        });
    });
</script>
<script src="assets/plugins/dataTables/js/jquery.dataTables2.js"></script>
<script src="assets/plugins/dataTables/js/dataTables.bootstrap2.js"></script>
<link rel="stylesheet" href="assets/plugins/dataTables/css/dataTables.css">

<body>
    <!-- Default box -->
    <form name="myform" id="devel-generate-content-form" action="smsadd.php" method="post"  enctype="multipart/form-data" accept-charset="utf-8">
        <!-- Default box -->
        <div class="">
            <div class="col-lg-6">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php Echo $formname; ?></h3>
                    </div>

                    <div class="panel-body">
                        <table  id="example1" class="table-bordered table-condensed table-hover table-striped" style="width:100%;height:200%;">
                            <thead style="background-color:#a8b878">
                                <tr style="font-size: 20px;"> 
                                    <th style='text-align: left;width:70%;'>
                                        Name
                                    </th>
    <!--                                <th  style='text-align: left;width:30%;'>
                                        Station
                                    </th>-->
                                    <th  style='text-align: left;width:20%;'>
                                        Mobile
                                    </th>
                                    <th  style='text-align: left;width:10%;'>
                                        Mark
                                    </th>
                                    <!--<th><input name="selectall" id="selectall" value="1" type="checkbox" /></th>-->
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $i = 0;
                                while ($row = mysqli_fetch_array($result)) {
                                    echo "<tr style='font-weight:900;font-size:16px;'>";
                                    echo "<td style='font-size:16px;' align='left'>$row[name]</td>";
//                                echo "<td align='left'>$row[station]</td>";
                                    echo "<td style='font-size:16px;' align='left'>$row[mobile]</td>";
                                    ?>
                                <td>
                                    <input type="checkbox" value="<? echo $row['mobile']; ?>" id="check_list" class="chk" name="check_list[]" style="width:20px"/>
                                </td>
                                    <!--<input name="check_list_$i" type='checkbox' id='check_list' class='chk' value='<? echo $row['mobile']; ?>'></td>";-->
                                <?php
                                echo "</td>";
                                echo "</tr>";
                                $i++;
                            }
                            ?>

                            </tbody>
                        </table>
                    </div>
                </div>

            </div>
            <div class="col-lg-6">
                <b style='color:red;font-size:20px'>Note : Remove {#var#} and enter details. Only add 30 Characters in replacement of {#var#}.</b>
                <table align="center">
                    <tr style="height:50px;"></tr>
                    <tr align="left">

                        <td align="right">
                            <b style="font-weight:900;font-size: 16px">
                                Select / Unselect All
                            </b> 
                        </td>
                        <td align="left">

                            <input type="checkbox" name="Check_ctr" onchange="checkAll(this)" id="example-select-all" class="chk" value="<?php echo $row['mobile']; ?>"
                                   onClick="Check(document.myform.check_list)" style="height:25px;width: 25px;">
                        </td>              
                    </tr>   
                    <tr align="right">
                        <td align="right">
                            <b style="font-weight:900;font-size: 16px" >
                                Selected No.
                            </b>
                        </td>

                        <td align="left">
                            <input type="number" style="width:20%;" name="selected" id="selected" class="selected" value="0" readonly>
                        </td>              
                    </tr>   


                    <tr align="right">
                        <td align="right"  style='text-align:right;'>
                            <b style="font-weight:900;font-size: 16px">
                                Message
                            </b>
                        </td>
                        <td align="left">
                            <p style="padding:0px; margin: 0px;font-size: 20px">
                                <textarea rows="5" cols="50" name="sms" id="sms">{#var#} ગુજરી ગયા છે ડી વિધિ {#var#} કબરસ્તાન મા થેસે - સોરઠીયા જમાત મુંબઈ</textarea>
                                <!--maxlength="160"-->
                            </p>
                        </td>              
                    </tr>   

                    <tr>
                        <td> 
                        </td>
                        <td>
                            <p style="padding:0px; margin: 0px;">
                                <input type="text" name="cnt" id="cnt" value="0" disabled="disabled" style="width: 50px; background:#66FFCC; color:red; font-weight: bold; "/>
                            </p>
                        </td>              
                    </tr>
                    <tr>
                        <td align="right">
                            <label  style="font-weight:900;font-size: 16px">Verification No.</label>
                        </td>
                        <td>
                            <p style="padding:0px; margin: 0px;">
                                <input type="text" name="alert" id="alert" value="" style="font-weight: bold; "/>
                            </p>
                        </td>              
                    </tr>
                    <tr>   

                        <td colspan="2" align="center">
                            <p style="padding:4px; margin: 4px;">
                                <input type="submit" name="submit" class=" btn" id="submit" value="Send" style="width:193px;height: 40px;background-color: #a8b878;color: white"/>
                            </p>
                        </td>
                    </tr>  
                </table>       
            </div>

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

        });
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            var $checkboxes = $('#devel-generate-content-form td input[type="checkbox"]');
            $checkboxes.change(function () {

                var countCheckedCheckboxes = $checkboxes.filter(':checked').length;
                $('#selected').val(countCheckedCheckboxes);
            });
        });
    </script>

    <script type="text/javascript">
        var total = 0;

        $(".chk").click(function () {

            var output = $.map($('.chk:checked'), function (n, i) {
                return n.value;
                return i.value;
            }).join(',');

            //            total = $('.chk:checked').length;
            //            $("#selected").val(total);
            //            $('#selchk').VAL(countCheckedCheckboxes);
            $("#selchk").val(output);

        });

    </script>
    <script type="text/javascript">
        function checkAll(ele) {
            var checkboxes = document.getElementsByTagName('input');
            if (ele.checked) {
                for (var j = 0; j < checkboxes.length; j++) {
                    if (checkboxes[j].type == 'checkbox') {
                        checkboxes[j].checked = true;
                    }
                }
            } else {
                for (var j = 0; j < checkboxes.length; j++) {
                    console.log(j)
                    if (checkboxes[j].type == 'checkbox') {
                        checkboxes[j].checked = false;
                    }
                }
            }
        }
    </script>
    <script>
        $(document).ready(function () {

        });
    </script>

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