<?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/' . $v_group_list->url; ?>">
                                   <?php 
                                    if(strlen($v_selected_group->group_name)>20){
                                    echo  mb_substr($v_selected_group->group_name, 0, 20).'...' ; 
                                    }
                                    else 
                                    {
                                    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 } ?>
<?php
// echo $total_limit_value->total_type;
$totall_count = count($count_member_group_list);

$total_page = ceil($totall_count / 10);
if ($total_page > 1) {
    ?>
    <nav class="course-pagination">
        <ul class="pagination">
            <?php
            if ($page > 2) {
                ?>
                <li>
                    <a href="javascript:;" onclick="AscdscdingOrderGroupPagination('<?php echo base_url() . 'ascdscding-order-group' ?>')" aria-label="Previous">
                        <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                    </a>
                </li>
                <li>
                    <a href="javascript:;" onclick="AscdscdingOrderGroupPagination('<?php echo base_url() . 'ascdscding-order-group' . '/' . ($page - 1); ?>')" aria-label="Previous">
                        <span aria-hidden="true" title="Previous Page">&laquo;</span>
                    </a>
                </li>
            <?php } elseif ($page > 1) { ?>
                <li>
                    <a href="javascript:;" onclick="AscdscdingOrderGroupPagination('<?php echo base_url() . 'ascdscding-order-group/' . ($page - 1); ?>')" aria-label="Previous">
                        <span aria-hidden="true" title="Previous Page">&laquo;</span>
                    </a>
                </li>
                <?php
            }
            for ($i = 0; $total_page > $i; $i++) {
                ?>
                <li><a href="javascript:;" onclick="AscdscdingOrderGroupPagination('<?php echo base_url().'ascdscding-order-group/'.($i + 1) ?> ')"><?php echo ($i + 1) ?></a></li>
            <?php
                }
            if ($total_page != $page) {
                ?>
                <li>
                    <a href="javascript:;" onclick="AscdscdingOrderGroupPagination('<?php echo base_url() . 'ascdscding-order-group/' . ($page + 1); ?>')" aria-label="Next">
                        <span aria-hidden="true" title="Next Page">&raquo;</span>
                    </a>
                </li>
                <li>
                    <a href="javascript:;" onclick="AscdscdingOrderGroupPagination('<?php echo base_url() . 'ascdscding-order-group/' . $total_page; ?>')" aria-label="Next">
                        <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                    </a>
                </li>
            <?php } ?>
        </ul>
    </nav>
<?php } ?>
