<div class="col-sm-8">

    <div class="row ">
        <div class="col-sm-12 ">
         
            <div class="col-sm-12" style="padding: 0">

                <div class="col-sm-12 gray_ttc text-center" style="border-bottom: 2px solid #8CC73F;padding: 10px 0 10px 0;font-weight: bold">
                    <div class="col-sm-2" style="padding: 0">Group name</div>
                    <div class="col-sm-2" style="padding: 0">Type</div>
                    <div class="col-sm-2" style="padding: 0">Permission</div>
                    <div class="col-sm-2" style="padding: 0">Member</div>
                    <div class="col-sm-2" style="padding: 0">Request</div>
                    <div class="col-sm-2" style="padding: 0">Action</div>
                </div>
                <div class="col-sm-12"><br></div>

                <?php
                foreach ($member_group_list as $v_group_list) {
                    ?>
                    <div class="col-sm-12 gray text-center" >
                        <?php
                        foreach (($selected_group[$v_group_list->group_id]) as $v_selected_group) {
                            ?>

                            <div class="col-sm-2" style="padding: 10px 0 0 0  ">
                                <a href="<?php echo base_url() . 'group-detail/' . $v_group_list->url; ?>">
                                    <?php echo $v_selected_group->group_name; ?>
                                </a>
                            </div>

                            <div class="col-sm-2" style="padding: 10px 0 0 0  "><?php echo $v_selected_group->group_type_name ?></div>

                            <div class="col-sm-2" style="padding: 10px 0 0 0  ">
                                <?php
                                $group_permission = $v_selected_group->group_permission;
                                if ($group_permission == 1) {
                                    echo 'Public';
                                } else if ($group_permission == 2) {
                                    echo 'Talhatraining User';
                                } else if ($group_permission == 3) {
                                    echo 'My Link';
                                } else if ($group_permission == 4) {
                                    echo 'Only Group Member';
                                }
                                ?>
                            </div>

                            <div class="col-sm-2" style="padding: 10px 0 0 0  ">
                                <a href="<?php echo base_url() . 'group/' . $v_group_list->url . '/members'; ?>">
                                    <?php echo $total_member[$v_group_list->group_id]->total; ?>
                                </a>
                            </div>

                            <div class="col-sm-2" style="padding: 10px 0 0 0  ">
                                <a href="<?php echo base_url() . 'group/' . $v_group_list->url . '/requested-members'; ?>">
                                    <?php echo count($group_requested_members[$v_group_list->group_id]); ?>
                                </a>
                            </div>

                            <div class="col-sm-2" style="padding: 10px 0 0 0  ">

                                <a href="<?php echo base_url() . 'group/' . $v_group_list->url . '/edit-group'; ?>"><i class="fa fa-edit" title="Edit"></i></a>&nbsp;&nbsp;

                                <?php
                                $group_status = $v_selected_group->group_status;
                                if ($group_status == 0) {
                                    ?>
                                    <a href="#" onclick="return checkForAction('<?php echo base_url() . 'publish-group/' . $v_group_list->url; ?>', 'Publish')">
                                        <i class="fa  fa-user-plus" title="Publish"></i>
                                    </a>&nbsp;&nbsp;
                                <?php } else if ($group_status == 1) { ?>
                                    <a href="#" onclick="return checkForAction('<?php echo base_url() . 'unpublish-group/' . $v_group_list->url; ?>', 'Unpublish')">
                                        <i class="fa  fa-user-times" title="Unpublish"></i>
                                    </a>&nbsp;&nbsp;
                                <?php } else if ($group_status == 2) { ?>
                                    <a href="#" onclick="return checkForAction('<?php echo base_url() . 'publish-group/' . $v_group_list->url; ?>', 'Publish')">
                                        <i class="fa  fa-user-plus" title="Publish"></i>
                                    </a>&nbsp;&nbsp;
                                <?php } ?>

                                <?php if ($group_status != 2) { ?>
                                    <a  href="#" onclick="return checkForDelete('<?php echo base_url() . 'archive-group/' . $v_group_list->url; ?>')">
                                        <i class="fa fa-trash-o" title="Delete"></i>
                                    </a>&nbsp;&nbsp;
                                <?php } ?>



                            </div>

                        <?php } ?>
                    </div>
                    <div class="col-sm-12">
                        <br>
                    </div>
                <?php } ?>


                <script>

                    function checkForAction(url, action) { // check for Active Inactives
                        swal({
                            title: "",
                            text: "Are you sure you want to " + action + " this Group?",
                            type: "warning",
                            showCancelButton: true,
                            confirmButtonColor: '#DD6B55',
                            confirmButtonText: 'Yes',
                            cancelButtonText: "No",
                            closeOnConfirm: true,
                            closeOnCancel: true
                        },
                        function (isConfirm) {
                            if (isConfirm) {
                                document.location.href = url;
                            }
                        });
                    }

                    function checkForDelete(url) {
                        swal({
                            title: "",
                            text: "Are you sure you want to Delete The Group?",
                            type: "warning",
                            showCancelButton: true,
                            confirmButtonColor: '#DD6B55',
                            confirmButtonText: 'Yes, delete it!',
                            cancelButtonText: "No, cancel!",
                            closeOnConfirm: true,
                            closeOnCancel: true
                        },
                        function (isConfirm) {
                            if (isConfirm) {
                                document.location.href = url;
                            }
                        });
                    }
                </script>

                <nav class="course-pagination">
                    <ul class="pagination">
                        <li>
                            <a href="#" aria-label="Previous">
                                <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                            </a>
                        </li>
                        <li>
                            <a href="#" aria-label="Previous">
                                <span aria-hidden="true" title="Previous Page">&laquo;</span>
                            </a>
                        </li>
                        <li><a href="#">1</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">3</a></li>
                        <li><a href="#">4</a></li>
                        <li><a href="#">5</a></li>
                        <li>
                            <a href="#" aria-label="Next">
                                <span aria-hidden="true" title="Next Page">&raquo;</span>
                            </a>
                        </li>
                        <li>
                            <a href="#" aria-label="Next">
                                <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>

            </div>


        </div>
    </div>

</div>