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

    <div class="row gray">

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


            <div class="col-sm-6 col-sm-offset-3">

                <form action="#" method="post">
                    <div class="input-group">
                        <input type="text" class="form-control"  placeholder="Search here..." aria-describedby="basic-addon1">
                        <span class="input-group-addon" id="basic-addon1"><i class="fa fa-search"></i></span>
                    </div>
                </form>

            </div>
        </div>


    </div>

    <div class="row ">

        <div class="col-sm-12 ">
            <div class="col-sm-12">
                <div class="col-sm-10">
                    <h3 class="text-left">TTC Group Member</h3>
                    
                </div>                
                <div class="col-sm-2">     
                    <!--<button type="button" class="btn btn-sm btn-success"  data-toggle="modal" data-target="#AlertModel" > </button>-->
                </div>                
            </div>

            <div class="col-sm-12"><hr></div>
         
            <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-6" style="padding: 0">Name</div>
                    <div class="col-sm-3" style="padding: 0">Join Date</div>
                    <div class="col-sm-3" style="padding: 0">Action</div>
                </div>
                <div class="col-sm-12"><br></div> 
                <?php if($group_member){
                foreach ($group_member as $val){?>
                <div class="col-sm-12 gray text-center" >
                    <input type="hidden" name="url" id="url_id<?php echo $val->group_member_id;?>" value="<?php echo $grp_url; ?>">
                           
                    <div class="col-sm-6" style="padding: 10px 0 0 0  "><a href="<?php echo base_url() ?>super_admin_group/profile"><?php echo $member_info[$val->group_member_id]->person_first_name;?></a></div>
                    <!--<div class="col-sm-3" style="padding: 10px 0 0 0  "><a href="<?php echo base_url() ?>super_admin_group/group_member_quiz_details">8</a></div>-->

                    <div class="col-sm-3" style="padding: 10px 0 0 0  "><?php 
                    echo date('h:i a', strtotime($val->group_join_date_time)) . "," . "&nbsp;";
                        echo date('d F y', strtotime($val->group_join_date_time)) . ".";
                    ?></div>
                    <?php
                     $person_id = $this->session->userdata('person_id');
                    if($person_info->person_role==6||($person_info->person_role==1&& $group_id->group_created_by==$person_id)){?>
                    <div class="col-sm-3" style="padding: 10px 0 0 0  ">
                         	<?php if($val->group_member_status!=5){ ?>
                        <a href="javascript:;" onclick="active_memeber('<?php echo $val->group_member_id;?>','<?php echo $val->group_id;?>');" id="active_member<?php echo $val->group_member_id; ?>"><i class="fa  fa-user-plus" title="Active"></i></a>
                        <a href="javascript:;" onclick="inactive_memeber('<?php echo $val->group_member_id;?>','<?php echo $val->group_id;?>');"style="display: none;" id="inactive_member<?php echo $val->group_member_id; ?>"><i class="fa  fa-user-times" title="Inactive"></i></a>
                                <?php }else if($val->group_member_status!=1){  ?> 
                         <a href="javascript:;" onclick="active_memeber('<?php echo $val->group_member_id;?>','<?php echo $val->group_id;?>');" style="display: none;"id="active_member<?php echo $val->group_member_id; ?>"><i class="fa  fa-user-plus" title="Active"></i></a>
                        <a href="javascript:;" onclick="inactive_memeber('<?php echo $val->group_member_id;?>','<?php echo $val->group_id;?>');"id="inactive_member<?php echo $val->group_member_id; ?>"><i class="fa  fa-user-times" title="Inactive"></i></a>
                     
                        <?php }?>
                        <?php if($val->group_member_status!=4){ ?>
                        <a id="block<?php echo $val->group_member_id; ?>" href="javascript:;" onclick="block_member('<?php echo $val->group_member_id;?>','<?php echo $val->group_id;?>');"><i class="fa  fa-lock" title="Blocked"></i></a>
                        <?php } ?>


                        <a href="#"><i class="fa fa-archive" title="Archive"></i></a>

                        <a href="javascript:;"onclick="remove_member('<?php echo $val->group_member_id;?>','<?php echo $val->group_id;?>');"id="remove_member<?php echo $val->group_member_id; ?>"><i class="fa fa-trash-o" title="Leave Group"></i></a>
                    </div>
                    <?php }?>
                </div>
                <div id="error" ></div>
                <input type="hidden" name="group_status" id="group_status<?php echo $val->group_member_id;?>"
                <input type="hidden" name="grp_id" id="grp_id" value="<?php echo $val->group_id;?>">
                <?php } 
 
                } ?>
                <div class="col-sm-12"><br></div> 
              
                <div class="col-sm-12"><br></div> 

                <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>
    <br>
    <div class="row gray">

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

            <div class="col-sm-12 text-left">
                <label><a href="<?php echo base_url('super-admin') ?>">Dashboard </a>->><a href="<?php echo base_url('super-admin-manage-group') ?>">Manage Group</a> ->> Group Member Details</label>
            </div>    

        </div>


    </div>

</div>
<script>
    function  active_memeber(group_member_id,group_id){
        swal({
                title: "", text: "Do you really want to active this member??",
                showCancelButton: true,
                confirmButtonColor: '#8CC73F',
                confirmButtonText: 'Yes',
                cancelButtonText: "No", closeOnConfirm: true,
                closeOnCancel: true
            },
            function (isConfirm) {
                if (isConfirm) {
        var xmlhttp4 = false;
        try {
            xmlhttp4 = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp4 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp4 = false;
            }
        }
        if (!xmlhttp4 && typeof XMLHttpRequest != 'undefined') {
            xmlhttp4 = new XMLHttpRequest();
        }
        
       
           
        var url='<?php echo base_url(); ?>' +'change-active-member-value';
            
           
            var formdata = new FormData();
            formdata.append("group_member_id", group_member_id);
            formdata.append("group_id", group_id);
          
       
         
            
        
        
        xmlhttp4.addEventListener("load", function () {
            
                 document.getElementById('group_status'+group_member_id).value=5;
                document.getElementById('inactive_member'+group_member_id).setAttribute('style','display:inline' );
                 document.getElementById('active_member'+group_member_id).setAttribute('style', 'display:none');
                 document.getElementById('block'+group_member_id).setAttribute('style','display:inline' );
           
            }, false);
            xmlhttp4.addEventListener("error", function () {
                alert("not upload");
            }, false);
            xmlhttp4.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

            xmlhttp4.open("POST", url);
            xmlhttp4.send(formdata);

        }
      });
    
    
            
     }
     
    function inactive_memeber(group_member_id,group_id){
    swal({
                title: "", text: "Do you really want to inactive this member??",
                showCancelButton: true,
                confirmButtonColor: '#8CC73F',
                confirmButtonText: 'Yes',
                cancelButtonText: "No", closeOnConfirm: true,
                closeOnCancel: true
            },
            function (isConfirm) {
                if (isConfirm) {
        var xmlhttp4 = false;
        try {
            xmlhttp4 = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp4 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp4 = false;
            }
        }
        if (!xmlhttp4 && typeof XMLHttpRequest != 'undefined') {
            xmlhttp4 = new XMLHttpRequest();
        }
        
       
           
        var url='<?php echo base_url(); ?>' +'change-inactive-member-value';
            
           
            var formdata = new FormData();
            formdata.append("group_member_id", group_member_id);
            formdata.append("group_id", group_id);
          
       
         
            
        
        
        xmlhttp4.addEventListener("load", function () {
            
                 document.getElementById('group_status'+group_member_id).value=1;
                document.getElementById('inactive_member'+group_member_id).setAttribute('style','display:none' );
                 document.getElementById('active_member'+group_member_id).setAttribute('style', 'display:inline');
                 document.getElementById('block'+group_member_id).setAttribute('style','display:inline' );
           
            }, false);
            xmlhttp4.addEventListener("error", function () {
                alert("not upload");
            }, false);
            xmlhttp4.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

            xmlhttp4.open("POST", url);
            xmlhttp4.send(formdata);

         }
      });
    }
   
   function block_member(group_member_id,group_id){
   swal({
                title: "", text: "Do you really want to block this member??",
                showCancelButton: true,
                confirmButtonColor: '#8CC73F',
                confirmButtonText: 'Yes',
                cancelButtonText: "No", closeOnConfirm: true,
                closeOnCancel: true
            },
            function (isConfirm) {
                if (isConfirm) {
        var xmlhttp3 = false;
        try {
            xmlhttp3 = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp3 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp3 = false;
            }
        }
        if (!xmlhttp3 && typeof XMLHttpRequest != 'undefined') {
            xmlhttp3 = new XMLHttpRequest();
        }
        
       
           
        var url='<?php echo base_url(); ?>' +'change-block-member-value';
            
           
            var formdata = new FormData();
            formdata.append("group_member_id", group_member_id);
            formdata.append("group_id", group_id);
          
       
         
            
        
        
        xmlhttp3.addEventListener("load", function () {
            
                 document.getElementById('group_status'+group_member_id).value=4;
                 
                document.getElementById('inactive_member'+group_member_id).setAttribute('style','display:inline' );
                document.getElementById('block'+group_member_id).setAttribute('style','display:none' );
               document.getElementById('active_member'+group_member_id).setAttribute('style', 'display:none');
               
           
            }, false);
            xmlhttp3.addEventListener("error", function () {
                alert("not upload");
            }, false);
            xmlhttp3.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

            xmlhttp3.open("POST", url);
            xmlhttp3.send(formdata);  
          }
      });
   }
   function remove_member(group_member_id,group_id){
   swal({
                title: "", text: "Do you really want to remove this member??",
                showCancelButton: true,
                confirmButtonColor: '#8CC73F',
                confirmButtonText: 'Yes',
                cancelButtonText: "No", closeOnConfirm: true,
                closeOnCancel: true
            },
            function (isConfirm) {
                if (isConfirm) {
        var xmlhttp2 = false;
        try {
            xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp2 = false;
            }
        }
        if (!xmlhttp2 && typeof XMLHttpRequest != 'undefined') {
            xmlhttp2 = new XMLHttpRequest();
        }
        
       
           
        var url='<?php echo base_url(); ?>' +'leave-group-member';
            
           
            var formdata = new FormData();
            formdata.append("group_member_id", group_member_id);
            formdata.append("group_id", group_id);
          
        xmlhttp2.addEventListener("load", function () {
//            alert(xmlhttp.responseText);
            if(xmlhttp2.responseText==1){
       document.getElementById("error").innerHTML='<span style="color:red;">You cannot delete the group member.you have to delete the group.</span>';    
            }else{
            var url=document.getElementById('url_id'+group_member_id).value;
            window.location='<?php echo base_url(); ?>'+'super-admin-manage-group';
            }
          
            }, false);
            xmlhttp2.addEventListener("error", function () {
                alert("not upload");
            }, false);
            xmlhttp2.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

            xmlhttp2.open("POST", url);
            xmlhttp2.send(formdata);  
          }
      });
   }
</script>



 <!--Alert modal start--> 

<!--        <div class="modal" style="" id="AlertModel" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content" style="top: 180px;border: 5px solid #80c12c;border-top: 20px solid #80c12c !important;margin: 0 auto;width: 450px">
                   
                    <form name="" method="" action="">
                        <div class="modal-body">

                            <h4 class="text-center">Are you sure you want to Delete this Person?</h4>
                        </div>
                        <div class="modal-footer">
                            <div  class="col-sm-12">
                                <button type="button" class="btn btn-danger col-sm-2 col-sm-offset-4" data-dismiss="modal">No</button>
                                <button style="margin-left: 20px" type="button" class="btn btn-success  col-sm-2" data-dismiss="modal">Yes</button>
                               
                            </div>

                        </div>
                    </form>
                </div>
            </div>
        </div>-->