<div class="col-sm-10 ">
    <div class="col-sm-12">
        <div class="col-sm-12">
            <h3 class="text-left" style="margin-top: 0">Group Photo </h3>
              <input type="text" class="form-control"  
                   placeholder="Search here..." 
                   aria-describedby="basic-addon1" 
                   oninput="searchgroup(this.value,'<?php echo $url;?>')">
        </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-2" style="padding: 0">Image</div>
            <div class="col-sm-4" style="padding: 0">Title</div>
            <div class="col-sm-2" style="padding: 0">Posted By</div>
            <div class="col-sm-2" style="padding: 0">Posted Date</div>
      
            <div class="col-sm-2" style="padding: 0">Action</div>
        </div>
        <div class="col-sm-12"><br></div> 
        <div id="search">
<?php 
if($total_post){
if($total_post_info ){
    foreach ($total_post_info as $value){
        if( $post_info[$value->post_id]){ 
            $serial++;
            $profile_url = $this->post_model->get_profile_url($post_info[$value->post_id]->posted_by);
            $file_path = 'content-library/'.$profile_url->url.'/'.$post_info[$value->post_id]->post_details;
            
            ?>
            
        <div class="col-sm-12 gray text-center">
            <input type="hidden" name="group_id" id="group_id" value="<?php echo $grp_id->group_id;?>">
            <input type="hidden" name="url_id" id="url_id" value="<?php echo $url; ?>">

            <div class="col-sm-2" style="padding: 10px 0 0 0  ">  
                   <a href="javascript:;" onclick="downloadAssignment('<?php echo $post_info[$value->post_id]->post_id; ?>')"> <img class="img-responsive" style="margin: 0 auto; max-height: 50px; max-width: 50px; cursor: pointer;" 
                         src="<?php echo base_url() .$file_path;?>" 
                         alt="image File" ></a></div>
            <div class="col-sm-4" style="padding: 10px 0 0 0  "><a href="<?php echo base_url().'view-post-group-viedo/'.$value->post_id;?>"><?php echo $post_info[$value->post_id]->post_file_original_name; ?></a></div>
            <div class="col-sm-2" style="padding: 10px 0 0 0  "><a href="#"><?php echo $person_info[$value->post_id]->person_first_name ." ". $person_info[$value->post_id]->person_last_name;?></a></div>
            <div class="col-sm-2" style="padding: 10px 0 0 0  ">
                          <?php  echo date('h:i a' , strtotime( $post_info[$value->post_id]->post_date_time)).",";
                           echo date('d F'  , strtotime( $post_info[$value->post_id]->post_date_time));
                        ?></div>
            
            
            <div class="col-sm-2" style="padding: 10px 0 0 0  ">
               
                <?php 
                $person_id = $this->session->userdata('person_id');
                if($check_person_status->person_role==6 ||($check_person_status->person_role==1 && $person_id==$grp_id->group_created_by)){ ?>
               
                <a href="javascript:;" onclick="remove_photo('<?php echo $post_info[$value->post_id]->post_id ?>')"> <i class="fa fa-trash-o" title="Delete"></i></a>
                <?php }
               
               $person_id = $this->session->userdata('person_id');
//               echo $check_person_status->person_role;
//               echo $grp_id->group_created_by;
//               echo $person_id;
                if($check_person_status->person_role==6 ||($check_person_status->person_role==1 && $person_id==$grp_id->group_created_by)){
                switch($post_info[$value->post_id]->post_status){
                  case 1:
                      ?>
                <a href="javascript:;" id="active<?php echo $value->post_id;?>" onclick="active_inactive('<?php echo $value->post_id;?>')"><i class="fa  fa-user-plus" title="active"></i></a>
                <a style="display: none;" id="inactive<?php echo $value->post_id;?>"onclick="active_inactive('<?php echo $value->post_id;?>')"><i class="fa fa-user-times" title="inactive"></i></a>
              
                <?php break ;
                case 2:?>
                   <a style="display: none;" id="active<?php echo $value->post_id;?>"onclick="active_inactive('<?php echo $value->post_id;?>')"><i class="fa  fa-user-plus" title="active"></i></a>
                   <a href="javascript:;" id="inactive<?php echo $value->post_id;?>"onclick="active_inactive('<?php echo $value->post_id;?>')"><i class="fa fa-user-times" title="inactive"></i></a>
               <?php 
                break;
                  case 4:?>
                     <a><i class="fa fa-archive" title="Archive"></i></a>
               <?php } } ?>
                  
                   
                   <input type="hidden" name="post_status" id="post_status<?php echo $value->post_id;?>" value="<?php echo $post_info[$value->post_id]->post_status?>">
            </div>
        </div>
         <?php } 

        }

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

      <?php
                // echo $total_limit_value->total_type;
                $total_page = ceil($total_photo->total_photo / 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-group-photo/'.$url ?>" aria-label="Previous">
                                        <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                    </a>
                                </li>
                                <li>
                                    <a href="<?php echo base_url() . 'super-admin-group-photo/'.$url.'/'. ($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-group-photo/'.$url.'/'. ($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-group-photo/'.$url.'/'. ($i + 1) . '">' . ($i + 1) . '</a></li>';
                            }
                            if ($total_page != $page) {
                                ?>
                                <li>
                                    <a href="<?php echo base_url() . 'super-admin-group-photo/'.$url.'/'. ($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-group-photo/'.$url.'/'. $total_page; ?>" aria-label="Next">
                                        <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                    </a>
                                </li>
                            <?php } ?>
                        </ul>
                    </nav>
                <?php } }?>
        </div>
    </div>


</div>
<script>
   function downloadAssignment(post_id) {
  

  
    var xmlhttp = false;
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
            xmlhttp = new XMLHttpRequest();
        }
        var url= '<?php echo base_url();?>'+'download-assigment-file-authenticate';
       var formdata = new FormData();
      formdata.append("post_id",post_id);
        xmlhttp.addEventListener("load", function () {
             //alert(xmlhttp.responseText);
            var downloadUrl= '<?php echo base_url();?>'+'download-assignment-file-group/'+post_id; 
           if( xmlhttp.responseText == 1){
              
               window.location.replace(downloadUrl);
               
           }
  
              
            }, false);
            xmlhttp.addEventListener("error", function () {
                alert("not sent");
            }, false);
            xmlhttp.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

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

        
    return true;

   }
   function remove_photo(post_id){
         
      swal({
                title: "", text: "Do you really want to delete the photo??",
                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(); ?>' +'remove-group-media-file-backend';
            
           var group_id=document.getElementById("group_id").value;
           var url_name=document.getElementById("url_id").value;
           
            var formdata = new FormData();
            formdata.append("post_id", post_id);
            formdata.append("group_id", group_id);
           
          
       
         
            
        
        
        xmlhttp4.addEventListener("load", function () {
          // alert( xmlhttp4.responseText);
           if( xmlhttp4.responseText==1){
               swal('you can not delete this group.');
              
           }
           else{
               window.location='<?php echo base_url(); ?>'+'super-admin-group-photo/'+url_name;

           }
           
                
           
            }, 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 searchgroup(value,url_name){

         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();
        }
//       alert(post_id_array);
//       exit();
//     
            //var post_id_array=document.getElementById("post_id_array").value;     
        var url='<?php echo base_url(); ?>' +'super-admin-group-photo-search';
            
           
            var formdata = new FormData();
            formdata.append("value", value);
            formdata.append("url_name", url_name);
          
       
         
            
        
        
        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>