<link rel="stylesheet" href="<?php echo base_url();?>assets/js/validationEngine.jquery.css" type="text/css" />
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/cust_paginition.css" type="text/css" />
<div class="layout-app">
    <div class="container"><div class="row row-app">
            <div class="col-md-12">
                <div class="col-separator col-separator-first col-unscrollable bg-none">
                    <div class="col-table">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="widget">
                                    <div class="widget-head">
                                        <!-- <a href="#editPromo" data-toggle="modal" class="btn btn-inverse pull-right mar" target="_blank""><i class="fa fa-fw fa-plus"></i>Send bulk Emails</a> -->
                                        <h4 class="heading">Notifications</h4>

                                    </div>

                                    <div class="widget-body">
                                        <form action="" method="GET" >
                                            <div class="col-md-12 selectBox">
                                                <div class="col-xs-4 col-md-2 bot-mar">
                                                    <label class="col-xs-12">From</label>
                                                    <input type="text" readonly class="form-control date" name="from_date" value="<?php if ($arrGetData['from_date'] != "") echo $arrGetData['from_date']; ?>"/>
                                                </div>
                                                <div class="col-xs-4 col-md-2 bot-mar">
                                                    <label class="col-xs-12">To</label>
                                                    <input type="text" readonly class="form-control date" name="to_date" value="<?php if ($arrGetData['to_date'] != "") echo $arrGetData['to_date']; ?>"/>
                                                </div>
                                                <div class="col-xs-4 col-md-2 bot-mar">
                                                    <label class="col-xs-12">Status</label>
                                                    <select class="cust_select col-xs-12" name = "status">
                                                        <option value="">--All--</option>
                                                        <option <?php if($_GET['status'] == 'sent') {?> selected
                                                        <?php } ?> value="sent">Sent</option>
                                                        <option <?php if($_GET['status'] == 'unsent') {?> selected
                                                        <?php } ?> value="unsent">Unsent</option>

                                                    </select>
                                                </div>


                                                <div class="col-xs-4 col-md-2 bot-mar">
                                                    <label class="col-xs-12">&nbsp;</label>
                                                    <div>
                                                        <button type="submit" class="btn btn-primary">Search</button>
                                                    </div>
                                                </div>
                                        </form>
                                        <div class="clearfix"></div>
                                    </div>
                                </div>
                                <table class="table table-white table-vertical-center margin-none table-striped footable">
                                    <thead>
                                    <tr>
                                        <th  class="text-center">Subscriber Name</th>
                                        <th  class="text-center" data-hide="phone,tablet">Email</th>
                                        <th  class="text-center" data-hide="phone,tablet">Transaction Id</th>
                                        <th data-hide="phone" class="text-center">Subject</th>
                                        <th data-hide="phone" class="text-center">Date</th>
                                        <th data-hide="phone,tablet" class="text-center">Status</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php
                                    if (count($arrData) > 0) {
                                        $intCounter = 1;
                                        foreach($arrData as $data) { ?>
                                            <tr>
                                                <td class="text-left"><?php echo $data['name']; ?></td>
                                                <td class="text-left" ><?php echo $data['email']; ?></td>
                                                <td class="text-center" ><?php echo $data['transaction_id']; ?></td>
                                                <td class="text-left" ><?php echo $data['subject']; ?></td>
                                                <td class="text-center" ><?php echo date('d M Y',strtotime($data['send_on'])); ?></td>
                                                <td class="text-center"><button class="btn btn-success"><?php echo $data['status']; ?></button></td>
                                            </tr>
                                            <?php $intCounter ++; } } else {?>
                                        <tr>
                                            <td class="text-center" colspan="7">Sorry, no notifications found</td>
                                        </tr>
                                    <?php } ?>
                                    </tbody>
                                </table>
                                <div class="text-center innerAll border-top pagination margin-none" align = "center">
                                    <?php echo $pagination; ?>
                                </div>
                            </div>
                            <!-- // END TRENDS -->
                        </div>


                    </div>

                </div>
                <div class="col-separator-h"></div>
            </div>
        </div>
    </div>
</div>
</div>
<div class="modal fade" id="editPromo" data-backdrop="static">
    <div class="modal-dialog" style="width: 700px">
        <div class="modal-content" id="edit_promo">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h3 class="modal-title">Send Email</h3>
            </div>
            <form action="" method="GET" >
                <div class="widget-body innerAll inner-2x" style="min-height: 500px !important;">
                    <?php for($intCounter = 0; $intCounter<= count($arrAllSubscribers); $intCounter = $intCounter + 3) { ?>
                        <p>
                            <label style="width:210px">
                                <?php if ($arrAllSubscribers[$intCounter]['id'] != null) {?>
                                    <input type="checkbox" class="checkbox1" name="subscriber" value="<?php echo $arrAllSubscribers[$intCounter]['email']; ?>"> <?php echo ucwords($arrAllSubscribers[$intCounter]['first_name']." ".$arrAllSubscribers[$intCounter]['last_name']); ?> &nbsp;
                                <?php } ?>
                            </label>
                            <label style="width:210px">
                                <?php if ($arrAllSubscribers[$intCounter+1]['id'] != null) {?>
                                    <input type="checkbox" class="checkbox1" name="subscriber" value="<?php echo $arrAllSubscribers[$intCounter+1]['email']; ?>"> <?php echo ucwords($arrAllSubscribers[$intCounter+1]['first_name']." ".$arrAllSubscribers[$intCounter+1]['last_name']); ?> &nbsp;
                                <?php } ?>
                            </label>
                            <label style="width:210px">
                                <?php if ($arrAllSubscribers[$intCounter+2]['id'] != null) {?>
                                    <input type="checkbox" class="checkbox1" name="subscriber" value="<?php echo $arrAllSubscribers[$intCounter+2]['email']; ?>"> <?php echo ucwords($arrAllSubscribers[$intCounter+2]['first_name']." ".$arrAllSubscribers[$intCounter+2]['last_name']); ?> &nbsp;
                                <?php } ?>
                            </label>
                        </p>
                    <?php } ?>

                    <br>
                    <div class="bot-mar" style="width:55%">
                        <label class="col-xs-12">Enter Message</label>
                        <textarea name="message" rows="5" cols="55" id="txt_message"></textarea>
                        <button type="button" class="btn btn-primary" id="submit_email" style="margin-top: 20px">Submit</button>

                    </div>
                </div>
            <form>
        </div>
    </div>
</div>
<script src="<?php echo base_url();?>assets/js/main.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/plugins/forms_elements_multiselect/js/jquery.multi-select.js?v=v2.0.0-rc1&sv=v0.0.1.2"></script>
<script src="<?php echo base_url();?>assets/plugins/forms_elements_bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_bootstrap-select/bootstrap-select.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_bootstrap-select/bootstrap-select.init.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_fuelux-radio/fuelux-radio.init.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_multiselect/multiselect.init.js?v=v2.0.0-rc1&sv=v0.0.1.2"></script>
<script src="<?php echo base_url();?>assets/js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/js/jquery.validationEngine.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>assets/js/subscriber.js"></script>
<script type="application/javascript">
    $("#submit_email").click(function (){
        var chkId = '';
        $('.checkbox1:checked').each(function() {
            chkId += $(this).val() + ",";
        });
        chkId = chkId.slice(0,-1);
        if (chkId == "") {
            alert("Please select some recipient");
            return false;
        }

        var message = $("#txt_message").val();
        if (message == "") {
            alert("Please enter message to send");
            return false;
        }

        $.ajax({
            url:"<?php echo base_url(); ?>index.php/subscriber/fnSendBulkEmail",
            async:false,
            'data' : {
                'email_ids' :chkId,
                'message': message
            },
            'type' : 'POST',
            success:function(result){
                alert(result);
            }
        });

        return false;
    });
</script>