<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"    oninput="searchgroup(this.value)"> 
                        <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 "><br></div>
        <div class="col-sm-12 ">
            <div class="col-sm-12">
                    <h3 class="text-left"> Group Type list</h3>
            </div>

            <div class="col-sm-12"><hr></div>
            <div class="col-sm-12 padding-zero">


                <div class="col-sm-12 gray_ttc text-center" style="border-bottom: 2px solid #8CC73F;padding: 5px 0 5px 0;font-weight: bold">

                    <div class="col-sm-6" style="padding: 0">Group Type name</div>
                    <div class="col-sm-3" style="padding: 0">Action</div>
                    <!--<div class="col-sm-3" style="padding: 0">Action</div>-->
                </div>
                <div class="col-sm-12"><br></div> 
                <div id="search">
                <?php 
                if($type_value){
                foreach($type_value as $val){
                     $serial++;?>
                <div class="col-sm-12 gray text-center" >

                    <div class="col-sm-6" style="padding: 5px 0 0 0"><?php echo $val->group_type_name;?></div>
                    
<!--                    <div class="col-sm-3" style="padding: 5px 0 0 0 ;">
                    <?php //if($val->group_type_publication_status==1){
                     //   echo '<i class="fa  fa-globe" title="Public"></i>';
                    ///}
                   // else if($val->group_type_publication_status==2){
                       // echo '<i style="color:limegreen" class="fa fa-user" title="TT User"></i>';
                    //}
                    //;?>
                    </div>-->
  <input type="hidden" name="group_type_id" id="group_type_id" value="<?php echo $val->group_type_id; ?>">
   <input type="hidden" name="group_type_status_value" id="group_type_status_value<?php echo $val->group_type_id; ?>" value="<?php echo $val->group_type_status;?>">

                    <div class="col-sm-3" style="padding: 5px 0 0 0">
                        <a href="<?php echo base_url()?>super-admin-edit-group-type/<?php $group_type_id= $this->encrypt->encode( $val->group_type_id);echo str_replace("/","%F2", $group_type_id); ?>"><i class="fa  fa-edit" title="Edit"></i></a>
                        <?php if($val->group_type_status==3){?>
                        <a href="javascript:;" onclick="pending('<?php echo $val->group_type_id; ?>')" id="pending<?php echo $val->group_type_id; ?>"><i class="fa fa-refresh fa-spin" title="Pending"></i></a>
                        <a href="javascript:;" onclick=" approved('<?php echo $val->group_type_id; ?>');"id="approved<?php echo $val->group_type_id; ?>"style="display:none;"><i class="fa fa-check-square" title="Approved"></i></a>
                        <a href="javascript:;" onclick="active('<?php echo $val->group_type_id; ?>')" id="published<?php echo $val->group_type_id; ?>" style="display:none;"><i class="fa  fa-user-plus" title="Published"></i></a>
                        <a href="javascript:;" onclick="inactive('<?php echo $val->group_type_id; ?>')" id="unpublished<?php echo $val->group_type_id; ?>"style="display:none;"><i class="fa  fa-user-times" title="UnPublished"></i></a>
                         
                       
                            <?php }else if($val->group_type_status==4){ ?>
                        <a href="javascript:;" onclick="pending('<?php echo $val->group_type_id; ?>')" id="pending<?php echo $val->group_type_id; ?>"style="display:none;"><i class="fa fa-refresh fa-spin" title="Pending"></i></a>
                        <a href="javascript:;" onclick=" approved('<?php echo $val->group_type_id; ?>');"id="approved<?php echo $val->group_type_id; ?>"><i class="fa fa-check-square" title="Approved"></i></a>
                        <a href="javascript:;" onclick="active('<?php echo $val->group_type_id; ?>')" id="published<?php echo $val->group_type_id; ?>" style="display:none;"><i class="fa  fa-user-plus" title="Published"></i></a>
                        <a href="javascript:;" onclick="inactive('<?php echo $val->group_type_id; ?>')" id="unpublished<?php echo $val->group_type_id; ?>"style="display:none;"><i class="fa  fa-user-times" title="UnPublished"></i></a>
                         
                           <?php    } else if($val->group_type_status==1){?>
                        <a href="javascript:;" onclick="pending('<?php echo $val->group_type_id; ?>')" id="pending<?php echo $val->group_type_id; ?>"style="display:none;"><i class="fa fa-refresh fa-spin" title="Pending"></i></a>
                        <a href="javascript:;" onclick=" approved('<?php echo $val->group_type_id; ?>');"id="approved<?php echo $val->group_type_id; ?>"style="display:none;"><i class="fa fa-check-square" title="Approved"></i></a>
                        <a href="javascript:;" onclick="active('<?php echo $val->group_type_id; ?>')" id="published<?php echo $val->group_type_id; ?>" ><i class="fa  fa-user-plus" title="Published"></i></a>
                        <a href="javascript:;" onclick="inactive('<?php echo $val->group_type_id; ?>')" id="unpublished<?php echo $val->group_type_id; ?>"style="display:none;"><i class="fa  fa-user-times" title="UnPublished"></i></a>
                         
                         <?php } else if ($val->group_type_status==0){?>
                        <a href="javascript:;" onclick="pending('<?php echo $val->group_type_id; ?>')" id="pending<?php echo $val->group_type_id; ?>"style="display:none;"><i class="fa fa-refresh fa-spin" title="Pending"></i></a>
                        <a href="javascript:;" onclick=" approved('<?php echo $val->group_type_id; ?>');"id="approved<?php echo $val->group_type_id; ?>"style="display:none;"><i class="fa fa-check-square" title="Approved"></i></a>
                        <a href="javascript:;" onclick="active('<?php echo $val->group_type_id; ?>')" id="published<?php echo $val->group_type_id; ?>" style="display:none;"><i class="fa  fa-user-plus" title="Published"></i></a>
                        <a href="javascript:;" onclick="inactive('<?php echo $val->group_type_id; ?>')" id="unpublished<?php echo $val->group_type_id; ?>"><i class="fa  fa-user-times" title="UnPublished"></i></a>
                            <?php } ?>
                         
                       <?php if($check_person_status->person_role==6){?>
                        
                       
                        <a href="javascript:;" onclick="remove_type(<?php echo $val->group_type_id;?>)" id="delete" ><i class="fa fa-trash-o" title="Delete"></i></a>
                       <?php }?>
                    </div>

                </div>
    
                <?php } } ?>


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

            </div>
            </div>

        </div>

    </div>


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


</div>
<script>
function pending(group_type_id){
     swal({
                title: "", text: "Do you really want to approve the group??",
                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(); ?>' +'pending-status-change';
      
      
            var formdata = new FormData();
            formdata.append("group_type_id", group_type_id);
         xmlhttp4.addEventListener("load", function () {
          //alert(xmlhttp4.responseText);
      document.getElementById('group_type_status_value'+group_type_id).value=4;
       document.getElementById('pending'+group_type_id).setAttribute('style', 'display:none');
       document.getElementById('approved'+group_type_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);

            return true;
        }
      });
    
}
function approved(group_type_id){
    swal({
                title: "", text: "Do you really want to pending the group??",
                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(); ?>' +'approved-status-change';
      
     // alert(group_type_id);
            var formdata = new FormData();
            formdata.append("group_type_id", group_type_id);
         xmlhttp4.addEventListener("load", function () {
         // alert(xmlhttp4.responseText);
      document.getElementById('group_type_status_value'+group_type_id).value=3;
       document.getElementById('approved'+group_type_id).setAttribute('style', 'display:none');
       document.getElementById('pending'+group_type_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);

            return true;
        }
        });
    
}
function active(group_type_id){
// alert(group_type_id);
     swal({
                title: "", text: "Do you really want to inactive the group??",
                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(); ?>' +'active-status-change';
        
      
            var formdata = new FormData();
            formdata.append("group_type_id", group_type_id);
         xmlhttp4.addEventListener("load", function () {
         // alert(xmlhttp4.responseText);
       document.getElementById('group_type_status_value'+group_type_id).value=0;
       document.getElementById('published'+group_type_id).setAttribute('style', 'display:none');
       document.getElementById('unpublished'+group_type_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);

            return true;
        }
      });
    
}
function inactive(group_type_id){
//alert(group_type_id);
     swal({
                title: "", text: "Do you really want to active the group??",
                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(); ?>' +'inactive-status-change';
      
      
            var formdata = new FormData();
            formdata.append("group_type_id", group_type_id);
         xmlhttp4.addEventListener("load", function () {
          //alert(xmlhttp4.responseText);
      document.getElementById('group_type_status_value'+group_type_id).value=1;
      document.getElementById('published'+group_type_id).setAttribute('style', 'display:inline');
      document.getElementById('unpublished'+group_type_id).setAttribute('style', 'display:none');
            
            }, false);
            xmlhttp4.addEventListener("error", function () {
                alert("not upload");
            }, false);
            xmlhttp4.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

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

            return true;
        }
      });
    
}
function remove_type(type_id){
 swal({
                title: "", text: "Do you really want to delete the group??",
                showCancelButton: true,
                confirmButtonColor: '#8CC73F',
                confirmButtonText: 'Yes!',
                cancelButtonText: "No", closeOnConfirm: true,
                closeOnCancel: true
            },
            function (isConfirm) {
                if (isConfirm) {
        var xmlhttp5 = false;
        try {
            xmlhttp5 = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp5 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp5 = false;
            }
        }
        if (!xmlhttp5 && typeof XMLHttpRequest != 'undefined') {
            xmlhttp5 = new XMLHttpRequest();
        }
        var url='<?php echo base_url(); ?>' +'delete-backend-group-type';
      
      
            var formdata = new FormData();
            formdata.append("group_type_id", type_id);
         xmlhttp5.addEventListener("load", function () {
         // alert(xmlhttp5.responseText);
               if(xmlhttp5.responseText== 0){
                   swal("Sorry !! You can't delete this group.");
                   //alert("you can't delete this group");
               }     
              else if(xmlhttp5.responseText== 1){
              window.location='super-admin-manage-group-type';
                }
            }, false);
            xmlhttp5.addEventListener("error", function () {
                alert("not upload");
            }, false);
            xmlhttp5.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

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

            return true;
        }
      });
    

}
function searchgroup(value){
         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(); ?>' +'super-admin-search-group_type';
            
           
            var formdata = new FormData();
            formdata.append("value", value);
        xmlhttp4.addEventListener("load", function () {
          //alert(xmlhttp4.responseText);
          
         document.getElementById("search").innerHTML=xmlhttp4.responseText;    
           
            }, false);
            xmlhttp4.addEventListener("error", function () {
                alert("not upload");
            }, false);
            xmlhttp4.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

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

            return true;
}
</script>