<?php
$user_id = $this->session->userdata('user_id');
$offset = $this->session->userdata('time_offset');
$count_comments = 0;
$you_tube_regExp = '/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/';
$vimo_regExp = '/(?:vimeo)\.com.*(?:videos|video|channels|)\/([\d]+)/i';
foreach ($post_comment[$post_value->post_id] as $comment_value) {
    ?>
    <div class="like_margin">
        <div class="col-sm-12"><hr></div>


        <!-----------------(4-a) Start Comment User Image --------------------->
        <div class="media-left">
            <a href="<?php echo base_url() . $comment_value->url . '/profile'; ?>">
                <img class="media-object post_comment_image" src="<?php
                if ($comment_value->person_image) {
                    echo base_url() . 'content-library/' . $comment_value->url . '/' . $comment_value->person_image;
                } else {
                    echo base_url() . 'image/no_profile_picture.png';
                }
                ?>" alt="<?php echo $comment_value->person_first_name . ' ' . $comment_value->person_last_name; ?>">
            </a>
        </div>
        <!-----------------(4-a) END Comment User Image --------------------->


        <!-----------------(4-b) Start Comment User Comments and Name --------------------->
        <div class="media-body">
            <h5 class="media-heading green text-justify" style="font-size: 16px;text-align: left !important">
                <a href="<?php echo base_url() . $comment_value->url . '/profile'; ?>">
                    <?php
                    if(strlen($comment_value->person_first_name) && strlen($comment_value->person_last_name) < 20){
                        echo $comment_value->person_first_name . ' ' . $comment_value->person_last_name; 
                        }
                    else{
                            echo substr($comment_value->person_first_name, 0, 30).' '.substr($comment_value->person_last_name, 0, 20);
                        }
                    //echo $comment_value->person_first_name . ' ' . $comment_value->person_last_name; 
                    ?>
                </a>
            </h5>
            <p class="text-justify" id="comment_detail<?php echo $comment_value->comment_id ?>">
                <?php
                $function_name = 'viewDetails(&quot;' . base_url('post/view_post_details/' . $comment_value->comment_id . '/comment') . '&quot;,&quot;comment_detail&quot;,&quot;' . $comment_value->comment_id . '&quot;)';
                echo $this->tt_post->get_post_data($comment_value->comment_details, 100, $function_name);
                ?>
            </p>
        </div>
        <!-----------------(4-b) END Comment User Comments and Name --------------------->



        <!-----------------Start View URL Details (if user Comment URL)------------------------>
        <?php
        if ($comment_url[$comment_value->comment_id]) {
            $url_value = explode("URL: ", $comment_url[$comment_value->comment_id]->post_comment_url_info);

            if (preg_match($you_tube_regExp, $url_value[1])) {
                ?>
                <div class="col-sm-12 text-left" style="margin: -10px 0 0 40px; ">
                    <div class="col-sm-4 col-xs-12 text-left">
                        <div class="embed-responsive embed-responsive-16by9" >
                            <iframe class="embed-responsive-item" width="200" height="150" webkitallowfullscreen mozallowfullscreen allowfullscreen
                                    src="<?php echo $url_value[1]; ?>">
                            </iframe>
                        </div>
                    </div>
                </div>
                <?php
            } else if (preg_match($vimo_regExp, $url_value[1])) {
                ?>
                <div class="col-sm-12 text-left" style="margin: -10px 0 0 40px; ">
                    <div class="col-sm-4 col-xs-12 text-left">
                        <div class="embed-responsive embed-responsive-16by9" >
                            <iframe class="embed-responsive-item" src="<?php echo $url_value[1]; ?>" 
                                    width="200" height="150" 
                                    frameborder="0" 
                                    webkitallowfullscreen mozallowfullscreen allowfullscreen>
                            </iframe>
                        </div>
                    </div>
                </div>
                <?php
            } else {
                ?>
                <div class="col-sm-12 text-left" style="margin: -10px 0 0 40px; ">
                    <div class="col-sm-12">
                        <h5>
                            <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                                <?php echo $url_value[2]; ?>
                            </a>
                        </h5>
                    </div>
                    <div class="col-sm-12" style="margin-top: -10px;">
                        <p style="font-size: 12px;">
                            <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                                <?php echo $url_value[3]; ?>
                            </a>
                        </p>
                    </div>
                    <div class="col-sm-12" style="margin-top: -10px;">
                        <h6>
                            <?php
                            if ($url_value[1]) {
                                ?>
                                <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                                    <?php echo $url_value[1]; ?>
                                </a>
                                <?php
                            }
                            if ($url_value[4] == '') {
                                echo '';
                            } else {
                                echo 'BY | ';
                                ?>
                                <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457"><?php echo $url_value[4]; ?></a>
                                <?php
                            }
                            ?>
                        </h6>
                    </div>
                </div>
                <?php
            }
        }
        ?>
        <!-----------------END View URL Details (if user Comment URL)------------------------>


        <!-----------------(4-c) Start Comments action --------------------->
        <div id="comment_like<?php echo $comment_value->comment_id; ?>">
            <div class="media-bottom" style="margin-left: 75px" >
                <p class="text-justify" style="font-size: 14px;">

                    <?php
                    $post_comment_like_array = explode(",", $comment_value->comment_like_by);
                    if (in_array($user_id, $post_comment_like_array)) {
                        ?>
                        <a href="javascript:void(0)"
                           onclick="getCommentLikeValue('<?php echo base_url() . 'post/add_comment_like/' . $comment_value->comment_id . '/' . $user_id . '/' . 'dislike'; ?>', '<?php echo $comment_value->comment_id; ?>')" >
                            <img src="<?php echo base_url() ?>image/home/red_like_icon.png" width="15" height="20" style="margin-top: -7px;" title="Unread">
                        </a> -
                    <?php } else { ?>
                        <a href="javascript:void(0)"
                           onclick="getCommentLikeValue('<?php echo base_url() . 'post/add_comment_like/' . $comment_value->comment_id . '/' . $user_id . '/' . 'like'; ?>', '<?php echo $comment_value->comment_id; ?>')" >
                            <img src="<?php echo base_url() ?>image/home/like-icon.png" width="15" height="20" style="margin-top: -7px;" title="Read">
                        </a> -
                    <?php }
                    ?>

                    <a href="javascript:void(0)"
                       onclick="replayWriteForm('<?php echo base_url() . 'post/add_replay_write_form/' . $comment_value->comment_id . '/' . $user_id; ?>', '<?php echo $comment_value->comment_id; ?>')" >
                        <i class="fa fa-share" style=" -ms-transform: rotate(90deg); -webkit-transform: rotate(90deg); transform: rotate(90deg);" aria-hidden="true" title="Reply"></i>
                    </a>

                    <?php
                    if ($post_value->posted_by == $user_id || $comment_value->comment_reply_by == $user_id) {
                        ?>
                        - <a href="javascript:void(0)"
                             onclick="deleteComment('<?php echo base_url() . 'post/delete_post_comment' ?>', '<?php echo $comment_value->comment_id; ?>', '<?php echo $post_value->post_id ?>', 'comment')" >
                            <i class="fa fa-trash"  aria-hidden="true" title="Delete"></i>
                        </a>
                    <?php } ?>

                    -<span>
                        <?php
                        $this->utility_model->time_format_for_read_write($comment_value->comment_date_time);
                        ?>
                    </span>
                </p>
            </div>
            <div class="text-left" style="margin-left: 75px;">
                <?php
                if ($comment_value->comment_like_by != '') {
                    $comment_like_value = $comment_value->comment_like_by;
                    $this->cf->read_write_status($user_id, $comment_like_value, 'comment' . $comment_value->comment_id);
                    $comment_like_id_array = explode(',', $comment_like_value);
                    ?>
                    <div id="viewLikeModal_comment<?php echo $comment_value->comment_id ?>" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
                        <div class="modal-dialog modal-md">
                            <div class="modal-content white_ttc" >

                                <div class="modal-header  text-left" style="padding: 20px 20px 0 20px;">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close" style=" opacity: 1"><span aria-hidden="true"><strong  style="color: #80c12c;">&times;</strong></span></button>
                                    <span class="modal-title" id="gridSystemModalLabel">
                                        <img class="pull-left" style="width: 30px" src="<?php echo base_url() ?>image/home/like-icon.png">
                                        <div class="form-group"></div> <strong><?php echo '&nbsp;&nbsp;&nbsp;' . count($comment_like_id_array); ?></strong>
                                    </span>
                                </div>
                                <div class="modal-body padding-top-zero">
                                    <div class="row">
                                        <div class="col-sm-12 padding-zero"  style="border-top: 2px solid #80c12c;height: 320px;overflow-y: scroll">
                                            <div class="col-sm-12 form-group"></div>
                                            <div class="col-sm-12">
                                                <?php
                                                foreach ($comment_liked_person[$comment_value->comment_id] as $comment_person_value) {
                                                    ?>
                                                    <div class="media">
                                                        <div class="media-left">
                                                            <?php if ($comment_person_value->person_image != '') {
                                                                ?>
                                                                <img class="media-object" src="<?php echo base_url() . 'content-library/' . $comment_person_value->url . '/' . $comment_person_value->person_image; ?>" 
                                                                     alt="<?php echo $comment_person_value->person_first_name . ' ' . $comment_person_value->person_last_name ?>" style="width: 50px;height: 50px">
                                                                     <?php
                                                                 } else {
                                                                     ?>
                                                                <img class="media-object" src="<?php echo base_url() . 'image/no_profile_picture.png'; ?>" 
                                                                     alt="<?php echo $comment_person_value->person_first_name . ' ' . $comment_person_value->person_last_name ?>" style="width: 50px;height: 50px">
                                                                     <?php
                                                                 }
                                                                 ?>
                                                        </div>
                                                        <div class="media-body">
                                                            <h2 class="media-heading" style="margin-top: 15px">
                                                                <a href="<?php echo $comment_person_value->url ?>" target="_blank">
                                                                    <?php echo $comment_person_value->person_first_name . ' ' . $comment_person_value->person_last_name ?>
                                                                </a>
                                                                <?php
                                                                if ($comment_person_value->person_id != $user_id) {
                                                                    if (!in_array($comment_person_value->person_id, $all_link)) {
                                                                        ?>
                                                                        <span style="color: #80c12c" class="pull-right" title="Add to your link"> 
                                                                            <sub style="font-weight: bold"> + </sub> <i class="fa fa-link"></i>
                                                                        </span>
                                                                        <?php
                                                                    }
                                                                }
                                                                ?>
                                                            </h2>
                                                        </div>
                                                        <hr>
                                                    </div>
                                                    <?php
                                                }
                                                ?>
                                            </div>
                                        </div> 
                                    </div>
                                </div>
                            </div><!-- /.modal-content -->
                        </div>
                    </div>
                    <?php
                } else {
                    $this->cf->read_write_status($user_id, '', '');
                }
                ?>
            </div>



            <!-----------------(4-c-i) Start Comments action --------------------->
            <div class="col-sm-12" 
                 id="add_replay_write_form<?php echo $comment_value->comment_id; ?>" style="margin-left: 40px; display: none">
            </div>
            <!-----------------(4-c-i) Start Comments action --------------------->


        </div>
        <!-----------------(4-c) END Comments action --------------------->



        <!------------------------------------(4-d) Start Comment Replay view----------------------------- -->
        <div id="comment_replay<?php echo $comment_value->comment_id; ?>" class="padding-zero col-sm-12" >
            <?php
            $replay_comment_counter = 0;
            foreach ($comment_reply[$comment_value->comment_id] as $comment_replay_value) {
                ?>
                <div  class="col-sm-12"><hr></div>
                <div class="media col-sm-10 col-sm-offset-2" style="font-size: 14px">


                    <!------------------------------------(4-d-i) Start Comment Replay User Image view----------------------------- -->

                    <div class="media-left">
                        <a href="<?php echo base_url() . $comment_replay_value->url . '/profile'; ?>">
                            <img class="media-object post_comment_image" 
                                 src="<?php
                                 if ($comment_replay_value->person_image) {
                                     echo base_url() . 'content-library/' . $comment_replay_value->url . '/' . $comment_replay_value->person_image;
                                 } else {
                                     echo base_url() . 'image/no_profile_picture.png';
                                 }
                                 ?>" 
                                 alt="<?php echo $comment_replay_value->person_first_name . ' ' . $comment_replay_value->person_last_name; ?>">
                        </a>
                    </div>
                    <!------------------------------------(4-d-i) END Comment Replay User Image view----------------------------- -->


                    <!------------------------------------(4-d-ii) Start Comment Reply User Name and Reply view----------------------------- -->
                    <div class="media-body">
                        <h5 class="media-heading green text-justify" style="font-size: 16px;text-align: left !important">
                            <a href="<?php echo base_url() . $comment_replay_value->url . '/profile'; ?>">
                                <?php echo $comment_replay_value->person_first_name . ' ' . $comment_replay_value->person_last_name; ?>
                            </a>
                        </h5>
                        <p class="text-justify" id="reply_comment_detail<?php echo $comment_replay_value->comment_id; ?>">
                            <?php
                            $function_name = 'viewDetails(&quot;' . base_url('post/view_post_details/' . $comment_replay_value->comment_id . '/reply') . '&quot;,&quot;reply_comment_detail&quot;,&quot;' . $comment_replay_value->comment_id . '&quot;)';
                            echo $this->tt_post->get_post_data($comment_value->comment_details, 80, $function_name);
                            ?>
                        </p>
                    </div>
                    <!------------------------------------(4-d-ii) END Comment Reply User Name and Reply view----------------------------- -->



                    <!-----------------Start View URL Details (if user Comment Reply URL)------------------------>
                    <?php
                    if ($reply_comment_url[$comment_replay_value->comment_id]) {
                        $url_value = explode("URL: ", $reply_comment_url[$comment_replay_value->comment_id]->post_comment_url_info);

                        if (preg_match($you_tube_regExp, $url_value[1])) {
                            ?>
                            <div class="col-sm-12 text-left" style="margin: -10px 0 0 40px; ">
                                <div class="col-sm-4 col-xs-12 text-left">
                                    <div class="embed-responsive embed-responsive-16by9" >
                                        <iframe class="embed-responsive-item"   width="200" height="150" webkitallowfullscreen mozallowfullscreen allowfullscreen
                                                src="<?php echo $url_value[1]; ?>">
                                        </iframe>
                                    </div>
                                </div>
                            </div>
                            <?php
                        } else if (preg_match($vimo_regExp, $url_value[1])) {
                            ?>
                            <div class="col-sm-12 text-left" style="margin: -10px 0 0 40px; ">
                                <div class="col-sm-4 col-xs-12 text-left">
                                    <div class="embed-responsive embed-responsive-16by9" >
                                        <iframe class="embed-responsive-item"  src="<?php echo $url_value[1]; ?>" 
                                                width="200" height="150" 
                                                frameborder="0" 
                                                webkitallowfullscreen mozallowfullscreen allowfullscreen>
                                        </iframe>
                                    </div>
                                </div>
                            </div>
                            <?php
                        } else {
                            ?>
                            <div class="col-sm-12 text-left" style="margin: -10px 0 0 40px; ">
                                <div class="col-sm-12">
                                    <h5>
                                        <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                                            <?php echo $url_value[2]; ?>
                                        </a>
                                    </h5>
                                </div>
                                <div class="col-sm-12" style="margin-top: -10px;">
                                    <p style="font-size: 12px; text-align: justify;">
                                        <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                                            <?php echo $url_value[3]; ?>
                                        </a>
                                    </p>
                                </div>
                                <div class="col-sm-12" style="margin-top: -10px;">
                                    <h6>
                                        <?php
                                        if ($url_value[1]) {
                                            ?>
                                            <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                                                <?php echo $url_value[1]; ?>
                                            </a>
                                            <?php
                                        }
                                        if ($url_value[4] == '') {
                                            echo '';
                                        } else {
                                            echo 'BY | ';
                                            ?>
                                            <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457"><?php echo $url_value[4]; ?></a>
                                            <?php
                                        }
                                        ?>
                                    </h6>
                                </div>
                            </div>
                            <?php
                        }
                    }
                    ?>
                    <!-----------------END View URL Details (if user Comment Reply URL)------------------------>


                    <!------------------------------------(4-d-iii) Start Comment Reply User Name and Reply view----------------------------- -->
                    <div id="reply_comment_like<?php echo $comment_replay_value->comment_id ?>" class="padding-zero">
                        <div class="media-bottom" style="margin-left: 55px" >
                            <p class="text-justify">   

                                <?php
                                $comment_reply_like_array = explode(",", $comment_replay_value->comment_like_by);
                                if (in_array($user_id, $comment_reply_like_array)) {
                                    ?>
                                    <a href="javascript:void(0)"
                                       onclick="getReplyLikeValue('<?php echo base_url() . 'post/add_comment_reply_like/' . $comment_replay_value->comment_id . '/' . $user_id . '/' . 'dislike'; ?>', '<?php echo $comment_replay_value->comment_id; ?>')" >
                                        <img src="<?php echo base_url() ?>image/home/red_like_icon.png" width="15" height="20" style="margin-top: -7px;" title="Unread">
                                    </a> -
                                <?php } else { ?>
                                    <a href="javascript:void(0)"
                                       onclick="getReplyLikeValue('<?php echo base_url() . 'post/add_comment_reply_like/' . $comment_replay_value->comment_id . '/' . $user_id . '/' . 'like'; ?>', '<?php echo $comment_replay_value->comment_id; ?>')" >
                                        <img src="<?php echo base_url() ?>image/home/like-icon.png" width="15" height="20" style="margin-top: -7px;" title="Read">
                                    </a> -
                                <?php }
                                ?>

                                <a href="javascript:void(0)"
                                   onclick="addNestedReplyForm('<?php echo base_url() . 'post/add_comment_nested_reply_form/' . $comment_replay_value->comment_id . '/' . $user_id; ?>', '<?php echo $comment_replay_value->comment_id; ?>')" >
                                    <i class="fa fa-share" style=" -ms-transform: rotate(90deg); -webkit-transform: rotate(90deg); transform: rotate(90deg);" aria-hidden="true" title="Reply"></i>
                                </a> -

                                <?php
                                if ($post_value->posted_by == $user_id || $comment_value->comment_reply_by == $user_id || $comment_replay_value->comment_reply_by == $user_id) {
                                    ?>
                                    - <a href="javascript:void(0)"
                                         onclick="deleteComment('<?php echo base_url() . 'post/delete_comment_reply' ?>', '<?php echo $comment_replay_value->comment_id; ?>', '<?php echo $comment_value->comment_id ?>', 'reply')" >
                                        <i class="fa fa-trash"  aria-hidden="true" title="Delete"></i>
                                    </a> 
                                <?php } ?>

                                - <span>
                                    <?php
                                    $this->utility_model->time_format_for_read_write($comment_replay_value->comment_date_time);
                                    ?>
                                </span> 
                            </p>
                        </div>
                        <div class="text-justify padding-top-zero" style="margin-left: 55px;">
                            <?php
                            if ($comment_replay_value->comment_like_by != '') {
                                $reply_like_value = $comment_replay_value->comment_like_by;
                                $this->cf->read_write_status($user_id, $comment_replay_value->comment_like_by, 'reply' . $comment_replay_value->comment_id);
                                $reply_like_id_array = explode(',', $reply_like_value);
                                ?>
                                <div id="viewLikeModal_reply<?php echo $comment_replay_value->comment_id ?>" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
                                    <div class="modal-dialog modal-md">
                                        <div class="modal-content white_ttc" >

                                            <div class="modal-header  text-left" style="padding: 20px 20px 0 20px;">
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close" style=" opacity: 1"><span aria-hidden="true"><strong  style="color: #80c12c;">&times;</strong></span></button>
                                                <span class="modal-title" id="gridSystemModalLabel">
                                                    <img class="pull-left" style="width: 30px" src="<?php echo base_url() ?>image/home/like-icon.png">
                                                    <div class="form-group"></div> <strong><?php echo '&nbsp;&nbsp;&nbsp;' . count($reply_like_id_array); ?></strong>
                                                </span>
                                            </div>
                                            <div class="modal-body padding-top-zero">
                                                <div class="row">
                                                    <div class="col-sm-12 padding-zero"  style="border-top: 2px solid #80c12c;height: 320px;overflow-y: scroll">
                                                        <div class="col-sm-12 form-group"></div>
                                                        <div class="col-sm-12">
                                                            <?php
                                                            foreach ($reply_liked_person[$comment_replay_value->comment_id] as $reply_person_value) {
                                                                ?>
                                                                <div class="media">
                                                                    <div class="media-left">
                                                                        <?php if ($reply_person_value->person_image != '') {
                                                                            ?>
                                                                            <img class="media-object" src="<?php echo base_url() . 'content-library/' . $reply_person_value->url . '/' . $reply_person_value->person_image; ?>" 
                                                                                 alt="<?php echo $reply_person_value->person_first_name . ' ' . $reply_person_value->person_last_name ?>" style="width: 50px;height: 50px">
                                                                                 <?php
                                                                             } else {
                                                                                 ?>
                                                                            <img class="media-object" src="<?php echo base_url() . 'image/no_profile_picture.png'; ?>" 
                                                                                 alt="<?php echo $reply_person_value->person_first_name . ' ' . $reply_person_value->person_last_name ?>" style="width: 50px;height: 50px">
                                                                                 <?php
                                                                             }
                                                                             ?>
                                                                    </div>
                                                                    <div class="media-body">
                                                                        <h2 class="media-heading" style="margin-top: 15px">
                                                                            <a href="<?php echo $reply_person_value->url ?>" target="_blank">
                                                                                <?php echo $reply_person_value->person_first_name . ' ' . $reply_person_value->person_last_name ?>
                                                                            </a>
                                                                            <?php
                                                                            if ($reply_person_value->person_id != $user_id) {
                                                                                if (!in_array($reply_person_value->person_id, $all_link)) {
                                                                                    ?>
                                                                                    <span style="color: #80c12c" class="pull-right" title="Add to your link"> 
                                                                                        <sub style="font-weight: bold"> + </sub> <i class="fa fa-link"></i>
                                                                                    </span>
                                                                                    <?php
                                                                                }
                                                                            }
                                                                            ?>
                                                                        </h2>
                                                                    </div>
                                                                    <hr>
                                                                </div>
                                                                <?php
                                                            }
                                                            ?>
                                                        </div>
                                                    </div> 
                                                </div>
                                            </div>
                                        </div><!-- /.modal-content -->
                                    </div>
                                </div>
                                <?php
                            } else {
                                $this->cf->read_write_status($user_id, '', '');
                            }
                            ?>
                        </div>



                        <!------------------------------------(4-d-iii-1) Start Comment Nested Reply Form----------------------------- -->
                        <div class="col-sm-12" style="margin-left: -30px; display: none"
                             id="add_nested_reply_form<?php echo $comment_replay_value->comment_id; ?>">
                        </div>
                        <div style="display: none"
                             id="view_saaved_nested_replies<?php echo $comment_replay_value->comment_id; ?>" >
                        </div>
                        <!------------------------------------(4-d-iii-1) END Comment Nested Reply Form----------------------------- -->



                    </div>
                    <!------------------------------------(4-d-iii) END Comment Reply User Name and Reply view----------------------------- -->


                    <!------------------------------------(4-d-iv) Start view replies----------------------------- -->
                    <div id="view_nested_replies<?php echo $comment_replay_value->comment_id; ?>">

                        <?php
                        $nested_comment_counter = 0;
                        if ($total_nested_reply[$comment_replay_value->comment_id]->total_comment > 0 && $total_nested_reply[$comment_replay_value->comment_id]->total_comment != $nested_comment_counter) {
                            ?>
                            <div class="col-sm-12 text-left" style="margin-left: 40px;">
                                <a href="javascript:void(0)"
                                   onclick="viewNestedReplies('<?php echo base_url() . 'post/view_nested_replies/' . $comment_replay_value->comment_id . '/' . $nested_comment_counter; ?>', '<?php echo $comment_replay_value->comment_id; ?>')" >
                                    view replies
                                </a>
                            </div>
                        <?php } ?>
                    </div>
                    <!------------------------------------(4-d-iv) End view replies----------------------------- -->


                </div>

                <?php
                $replay_comment_counter++;
            }
            if ($total_comment_reply[$comment_value->comment_id]->total_comment > $replay_comment_counter) {
                ?>
                <div class="col-sm-12 text-left" style="margin-left: 120px;">
                    <br>
                    <a href="javascript:void(0)"
                       onclick="viewMoreReply('<?php echo base_url() . 'post/view_more_reply/' . $comment_value->comment_id . '/' . $replay_comment_counter; ?>', '<?php echo $comment_value->comment_id; ?>')" >
                        view more reply
                    </a>
                </div>
            <?php } ?>
        </div>
        <!---------------------------------------(4-d)END Comment Replay view----------------------------- -->


    </div>
    <?php
    $count_comments++;
}
?>



<!------------------------(4-e)View Writes Counter-------------------------------->
<?php
if ($total_comment->total_comment > $count_comments) {
    ?>
    <div class="col-sm-12 text-left" style="margin-left: 120px;">
        <br>
        <a href="javascript:void(0)"
           onclick="viewWrites('<?php echo base_url() . 'post/view_writes/' . $post_value->post_id . '/' . $count_comments; ?>', '<?php echo $post_value->post_id; ?>')" >
            view writes
        </a>
    </div>
<?php } ?>
<!------------------------(4-e)View Writes Counter-------------------------------->