<?php
  require_once("../../classes/main_classes.php");

  if(!isset($_POST["bc_id"])){
    die("<p class='alert alert-warning'>Invalid request</p>");
  }

  $bc_id=addslashes($_POST["bc_id"]);

  //OBJECTS
  $retrieveObj=new RETRIEVE();
  $rowcountObj=new ROWCOUNT();

?>



<?php
  $get_blog_comment_replies=$retrieveObj->retriever("blog_comment_replies","*","bc_id",$bc_id,"fetchAll");
  if($get_blog_comment_replies!="1020"){
?>
  <div class="comments-list">
    <ul>
      <?php
        
        foreach ($get_blog_comment_replies as $bcr) {
          
      ?>
          <li class="threaded-comments ml-0">
            <div class="comments-details">
              <div class="comments-list-img">
                <!--img src="img/blog/b02.jpg" alt="post-author"-->
                <span class="fa fa-user fa-2x text-secondary"></span>
              </div>
              <div class="comments-content-wrap">
                <span>
                    <b >
                      <?php
                        if($bcr->user_id!=""){
                          //get user information
                          $get_user_info2=$retrieveObj->retriever("users 
                            JOIN user_roles ON user_roles.user_id=users.user_id
                            JOIN user_role ON user_roles.role_id=user_role.role_id
                            WHERE users.user_id='".$bcr->user_id."'
                            ","*","fetch");
                          echo "<span class='text-primary'>";
                          echo $get_user_info2->username."";
                          if($get_user_info2->user_role=='admin' or $get_user_info2->user_role=='su_admin'){
                            echo "(Admin)";
                          }
                          echo "</span>";
                          
                        }else{
                          echo $bcr->bcr_fullname;
                        }
                      ?>
                    </b>
                    
                    <span class="post-time">
                      <?php
                        echo date("M j, Y", strtotime($bcr->bcr_time)) ;
                        echo " @ ";
                        echo date("H:i A", strtotime($bcr->bcr_time)) ;
                      ?>
                    </span>
                </span>
                    
                <p><?php echo $bcr->bcr_text; ?></p>
              </div>
        </li>
      <?php
        }
      ?>
          
    </ul>
  </div>
<?php
  }
?>