<input type="hidden" id="baseurl" value="<?php echo base_url(); ?>" >
<div class="row">
    <div class="col-md-12">
        <div class="hs_heading medium">
            <h3>Blog Comments (<?php if(!empty($all_comments)){ echo count($all_comments); }else{ echo 0; } ?>)</h3>
        </div>
        <div class="hs_datatable_wrapper">
            <table class="hs_datatable table table-bordered">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Comments</th>
						<th>Blog Title</th>
						<th>Comment Date</th>
                        <th>Status</th>
			            <th>Action</th>
                    </tr>
                </thead>
                <tbody>
				<?php

                 $i= 0;
				if(!empty($all_comments)){ 
				   foreach($all_comments as $comment){
			    ?>
				 <tr>
                        <td><?php echo ++$i; ?></td>
                        <td width="200">
                            <div class="hs_user">
								<div class="user_img"> 
									<span class="hs_user_initials"><?php 
										$uname_arr = explode(" ", $comment->comment_name);
										$first_letter='';
										foreach($uname_arr as $name){
										$first_letter .= substr($name, 0, 1);
										}	 
										echo $first_letter;
										?>
										</span>
									</div>
									<div class="user_name">
										<p><?php echo $comment->comment_name; ?></p>
									</div>
                            </div>
                        </td>
                        <td><?php echo $comment->comment_email; ?></td>
                        <td><?php 
							if(strlen($comment->comment_content) >= 50) {
							echo substr($comment->comment_content, 0, 40); ?>
							 <br><a href="javascript:;" onclick="read_more_comment('<?php echo $comment->comment_content; ?>')">Read More...</a>
						<?php }else{
								echo $comment->comment_content;
							 }
						?>
						<br></td>
						 <?php $blog_title =$this->Data_access_model->select_data('blog_title','hs_blogs',array('blog_id' =>$comment->comment_blog_id,)); 
						if($blog_title->num_rows() > 0 ){
							$btitle = $blog_title->row();
						}
						?> 
						<td><?php if(isset($btitle)){ echo $btitle->blog_title; } ?></td>
					    <td><?php echo $comment->comment_date; ?></td>
						<td>
							<label class="switch">
								<input id="comntstatus_<?php echo $comment->comment_id; ?>" onclick="change_comment_status(<?php echo $comment->comment_id; ?>);"   type="checkbox" value="" <?php if($comment->comment_status == 1){ echo "checked"; } ?> >
								<span class="slider"></span>
							</label>
                        </td>
						<td width="200">
                            <a  onclick="edit_comment(<?php echo $comment->comment_id; ?>,'<?php echo $comment->comment_name; ?>','<?php echo $comment->comment_email; ?>','<?php echo $comment->comment_content; ?>','<?php echo $comment->comment_date; ?>')" class="btn" title="Edit"><i class="fa fa-pencil" aria-hidden="true"></i></a>
                            <a href="<?php echo base_url().'admin/delete_comment/'.$comment->comment_id; ?>" class="btn" title="Delete" onclick="return delete_confirmation();"><i class="fa fa-trash" aria-hidden="true"></i></a>
                        </td>
				</tr>   
                <?php 
					}
				 }
                ?>				
                </tbody>
            </table>
        </div>
    </div>
</div>




<!-- update comment popup start -->
<div class="modal_box">
	<div id="update_comments" class="modal fade" role="dialog">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">&times;</button>
					<h4 class="modal-title"><span>Update</span> Comment</h4>
				</div>
				<div class="modal-body">
				<input type="hidden" id="baseurl" value="<?php echo base_url(); ?>" >
				<form method="post" enctype="multipart/form-data" id="update_comment_form">
					<div class="hs_input">
						<label>Comment Name</label>
						<input type="text" class="form-control add_cate_form" name="up_cooment_name" id="up_cooment_name" value="">
					</div>
					<div class="hs_input">
						<label>Comment Email</label>
						<input type="text" class="form-control add_cate_form" name="up_cooment_email" id="up_cooment_email" value="">
					</div>
					<div class="hs_input">
						<label>Comments</label>
						<textarea rows="4" class="form-control" name="up_comment_content" id="up_comment_content"></textarea>
					</div>
					 
					<div class="hs_input">
						<input type="hidden" value="" name="old_commentid" id="old_commentid">
						<button type="submit" id="add"  class="btn">Update</button>
					</div>
				</div>
				</form>
			</div>
		</div>
	</div>
</div>
<!-- update comment popup end -->

<!-- read more comment content popup start -->
<div class="modal_box">
	<div id="readmore_comment" class="modal fade" role="dialog">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">&times;</button>
					<h4 class="modal-title"><span>Read</span> Blog Comment</h4>
				</div>
				<div class="modal-body">
					<div class="hs_input">
						<label>Comments</label>
						<textarea rows="8" cols=""class="form-control" name="rm_content" id="rm_content" disabled></textarea>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- read more comment content popup start -->


