
<div class="right_col" role="main">
    <div class="">


        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <?php if (isset($suc_msg) && $suc_msg) { ?>
                    <div class = "alert alert-success" style="padding: 10px;">
                        <strong>Success!</strong> <span><?php echo $suc_msg ?></span>
                    </div>
                <?php } ?>
            </div>
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>Executive view</h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="hidden" class="form-control" name="delete_executive" id="delete_executive"   maxlength="50" />
                        </div>
                    </div>
                    <div class="x_content">
                        <table class="table table-hover" id="example">
                            <thead>
                                <tr>

                                    <th>Username</th>
                                    <th>First name</th>
                                    <th>Last name</th>
                                    <th>Mobile</th>
                                    <th>Type</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody id="executive_view">
                                <?php $count = 0 ?>
                                <?php foreach ($user as $row) { ?>
                                    <tr>
                                        <td><?php echo $row->username; ?></td>
                                        <td><?php echo $row->firstname; ?></td>
                                        <td><?php echo $row->lastname; ?></td>
                                        <td><?php echo $row->mobile; ?></td>
                                        <td><?php echo $row->type; ?></td>
                                        <td>
                                            <div class="row">

                                                <div class="col-xs-3">
                                                    <form id="<?php echo $count ?>"  method="post" action = "<?php echo base_url() . 'index.php/Executive/viewed' ?>">

                                                        <input type="hidden" name="username" value="<?php echo $row->username; ?>">
                                                        <a href="javascript:{}" id="deleteRow" onclick="document.getElementById(<?php echo $count ?>).submit();
                                                                    return false;"><i class="fa fa-eye" title="View"></i> </a>
                                                    </form>
                                                </div>
                                                <?php $count++ ?>
                                                <div class="col-xs-3">
                                                    <form id="<?php echo $count ?>"  method="post" action = "<?php echo base_url() . 'index.php/Executive/edit' ?>">

                                                        <input type="hidden" name="username" value="<?php echo $row->username; ?>">
                                                        <a href="javascript:{}" id="deleteRow" onclick="document.getElementById(<?php echo $count ?>).submit();
                                                                    return false;"><i class="fa fa-edit" title="Edit"></i></a>
                                                    </form>
                                                </div>

                                                <?php $count++ ?>
                                                <div class="col-xs-3">
                                                    <a style="cursor:pointer"  class="delete_executive" id="<?php echo $row->username . '- DELETE'; ?>" ><i class="fa fa-trash-o" title="Delete"></i> </a>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                    <?php $count++ ?>
                                <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="executive_delete_confirmation"> 
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">

                <h4 class="modal-title" style="color:#3c8dbc"> Confirmation for Delete!</h4>
            </div>
            <div class="modal-body">
                <p><b>Are you sure you want to deleted this executive ?</b></p>
            </div>
            <div class="modal-footer">
                <button type="button" id="delete_Ok" class="btn btn-primary">OK</button>
                <button type="button" id="delete_Cancel" class="btn btn-primary" data-dismiss="modal">Cancel</button>
            </div>
        </div>
    </div>
</div>

<!-- /page content 
<!-- jQuery -->
<script src="<?php echo base_url('assets/js/jquery.min.js'); ?>"></script>
<!-- Bootstrap -->
<script src="<?php echo base_url('assets/js/bootstrap.min.js'); ?>"></script>
<!-- FastClick -->
<script src="<?php echo base_url('assets/js/fastclick.js'); ?>"></script>
<!-- NProgress -->
<script src="<?php echo base_url('assets/js/nprogress.js'); ?>"></script>


<script src="<?php echo base_url('assets/js/custom.min.js'); ?>"></script>
<script src="<?php echo base_url('assets/js/jquery.validate.min.js'); ?>"></script>
<script src="<?php echo base_url('assets/js/jquery.dataTables.min.js'); ?>"></script>
<script src="<?php echo base_url('assets/js/dataTables.bootstrap.min.js'); ?>"></script>
<script type="text/javascript">
                                                            $(document).ready(function () {
                                                                $('#example').DataTable({
                                                                    "pagingType": "simple_numbers",
                                                                    "pageLength": 20,
                                                                    "bLengthChange": false,
                                                                    "bFilter": false

                                                                });
                                                            });


                                                            $("#executive_view").on("click", ".delete_executive", function () {
                                                                var div_id = $(this).attr("id");
                                                                var id = div_id.split("-");
                                                                $('#delete_executive').val(id[0]);
                                                                $('#executive_delete_confirmation').modal({backdrop: 'static', keyboard: false});
                                                            });

                                                            $("#delete_Ok").click(function () {

                                                                var username = $('#delete_executive').val();
                                                                jQuery.ajax({
                                                                    type: "POST",
                                                                    url: "<?php echo base_url(); ?>" + "index.php/Executive/delete",
                                                                    dataType: 'json',
                                                                    data: {username: username},
                                                                    success: function (res) {
                                                                        console.log(res);
                                                                        if (res.STATUS === 'TRUE') {
                                                                            window.location.href = "<?php echo base_url(); ?>" + "index.php/Executive/view";
                                                                            $('#executive_delete_confirmation').modal('toggle');
                                                                        }
                                                                    }
                                                                });
                                                            });

</script>
