<?php
$user_id = $this->session->userdata('user_id');
?>
<div class="media-bottom" style="margin-left: 75px" ><hr>
    <p class="text-justify" style="font-size: 14px;">


        <!-------------------For post like part -------------->
        <?php
        if (isset($post_value->post_like_by)) {
            $liked_person_id = explode(",", $post_value->post_like_by);
            if (in_array($user_id, $liked_person_id)) {
                ?>
                <a href="javascript:void(0)" style="color: red"
                   onclick="getLikeValue('<?php echo base_url() . 'post/add_like/' . $post_value->post_id . '/' . $user_id . '/' . 'dislike'; ?>', '<?php echo $post_value->post_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="getLikeValue('<?php echo base_url() . 'post/add_like/' . $post_value->post_id . '/' . $user_id . '/' . 'like'; ?>', '<?php echo $post_value->post_id; ?>')">
                    <img src="<?php echo base_url() ?>image/home/like-icon.png" width="15" height="20" style="margin-top: -7px;" title="Read">
                </a>-
                <?php
            }
        } else {
            ?>
            <a href="javascript:void(0)"
               onclick="getLikeValue('<?php echo base_url() . 'post/add_like/' . $post_value->post_id . '/' . $user_id . '/' . 'like'; ?>', '<?php echo $post_value->post_id; ?>')">
                <img src="<?php echo base_url() ?>image/home/like-icon.png" width="15" height="20" style="margin-top: -7px;" title="Read">
            </a>-
        <?php }
        ?>
        <!-------------------For post like part -------------->


        <!-------------------For post Write part -------------->
        <a href="javascript:void(0)"
           onclick="addWriteForm('<?php echo base_url() . 'post/add_write_form/' . $post_value->post_id . '/' . $user_id; ?>', '<?php echo $post_value->post_id; ?>')" >
               <?php
               if ($post_value->post_comment_count == NULL || $post_value->post_comment_count == 0) {
                   echo '<i class="fa fa-pencil-square" aria-hidden="true" title="Write"></i>';
               } else {
                   echo '<i class="fa fa-pencil-square" aria-hidden="true" title="Write"></i> (' . $post_value->post_comment_count . ')';
               }
               ?>
        </a>
        <!-------------------For post Write part -------------->


        <!-------------------For Content library part -------------->
        <?php
        if ($post_value->posted_by != $user_id) {
            if ($post_value->post_type == 1 || $post_value->post_type == 2) {
                if (isset($post_value->post_add_to_my_library_by)) {
                    if ($post_value->post_add_to_my_library_by == NULL) {
                        ?>
                        -<a href="javascript:void(0)"
                            onclick="libraryAction('<?php echo base_url() . 'post/add_to_my_library/' . $post_value->post_id . '/' . $user_id . '/' . 'add'; ?>', '<?php echo $post_value->post_id; ?>')" >
                            <i class="fa fa-hdd-o" aria-hidden="true" title="Add to my Note Alert"></i>
                        </a>
                        <?php
                    } else {
                        $added_library_person_id = explode(",", $post_value->post_add_to_my_library_by);
                        if (in_array($user_id, $added_library_person_id)) {
                            ?>
                            -<a href="javascript:void(0)"
                                onclick="libraryAction('<?php echo base_url() . 'post/add_to_my_library/' . $post_value->post_id . '/' . $user_id . '/' . 'remove'; ?>', '<?php echo $post_value->post_id; ?>')" >
                                <i class="fa fa-hdd-o red" aria-hidden="true" title="Remove to my Note Alert"></i> (<?php echo count($added_library_person_id); ?>)
                            </a>
                            <?php
                        } else {
                            ?>
                            -<a href="javascript:void(0)"
                                onclick="libraryAction('<?php echo base_url() . 'post/add_to_my_library/' . $post_value->post_id . '/' . $user_id . '/' . 'add'; ?>', '<?php echo $post_value->post_id; ?>')" >
                                <i class="fa fa-hdd-o" aria-hidden="true" title="Add to my Note Alert"></i>(<?php echo count($added_library_person_id); ?>)
                            </a>
                            <?php
                        }
                    }
                } else {
                    ?>
                    -<a href="javascript:void(0)"
                        onclick="libraryAction('<?php echo base_url() . 'post/add_to_my_library/' . $post_value->post_id . '/' . $user_id . '/' . 'add'; ?>', '<?php echo $post_value->post_id; ?>')" >
                        <i class="fa fa-hdd-o" aria-hidden="true" title="Add to my Note Alert"></i>
                    </a>
                    <?php
                }
            } else if ($post_value->post_type == 3 || $post_value->post_type == 4 || $post_value->post_type == 5) {
                if (isset($post_value->post_add_to_my_library_by)) {
                    if ($post_value->post_add_to_my_library_by == NULL) {
                        ?>
                        -<a href="javascript:void(0)"
                            onclick="libraryAction('<?php echo base_url() . 'post/add_to_my_library/' . $post_value->post_id . '/' . $user_id . '/' . 'add'; ?>', '<?php echo $post_value->post_id; ?>')" >
                            <i class="fa fa-hdd-o" aria-hidden="true" title="Add to my Content Library"></i>
                        </a>
                        <?php
                    } else {
                        $added_library_person_id = explode(",", $post_value->post_add_to_my_library_by);
                        if (in_array($user_id, $added_library_person_id)) {
                            ?>
                            -<a href="javascript:void(0)"
                                onclick="libraryAction('<?php echo base_url() . 'post/add_to_my_library/' . $post_value->post_id . '/' . $user_id . '/' . 'remove'; ?>', '<?php echo $post_value->post_id; ?>')" >
                                <i class="fa fa-hdd-o red" aria-hidden="true" title="Remove to my Content Library"></i> (<?php echo count($added_library_person_id); ?>)
                            </a>
                            <?php
                        } else {
                            ?>
                            -<a href="javascript:void(0)"
                                onclick="libraryAction('<?php echo base_url() . 'post/add_to_my_library/' . $post_value->post_id . '/' . $user_id . '/' . 'add'; ?>', '<?php echo $post_value->post_id; ?>')" >
                                <i class="fa fa-hdd-o" aria-hidden="true" title="Add to my Content Library"></i> (<?php echo count($added_library_person_id); ?>)
                            </a>
                            <?php
                        }
                    }
                } else {
                    ?>
                    -<a href="javascript:void(0)"
                        onclick="libraryAction('<?php echo base_url() . 'post/add_to_my_library/' . $post_value->post_id . '/' . $user_id . '/' . 'add'; ?>', '<?php echo $post_value->post_id; ?>')" >
                        <i class="fa fa-hdd-o" aria-hidden="true" title="Add to my Content Library"></i>
                    </a>
                    <?php
                }
            }
        }
        ?>
        <!-------------------For Content library part -------------->

        <!-------------------For Publication Status part -------------->
        -<a href="javascript:void(0)">
            <?php
            switch ($post_value->post_publication_status) {
                case 1:
                    echo '<i class="fa fa-globe" aria-hidden="true" title="Public"></i>';
                    break;
                case 2:
                    echo '<img src="' . base_url() . 'image/dashboard-tt-icon.png" title="TT User" alt="TT User">';
                    break;
                case 3:
                    echo '<i class="fa fa-link" aria-hidden="true" title="My Link"></i>';
                    break;
                case 4:
                    echo '<i class="fa fa-users" aria-hidden="true" title="Group"></i>';
                    break;
            }
            ?>
        </a>
        <!-------------------For Publication Status part -------------->


        <?php
        if ($post_value->posted_by == $user_id) {
            ?>
            -<a href="<?php echo base_url() . 'user/edit-post/' . $this->utility_model->encode_id($post_value->post_id, '/', 'Tt'); ?>" target="_blank">
                <i class="fa fa-edit" aria-hidden="true" title="edit"></i>
            </a>
        <?php } ?>



        -<span>
            <?php
            $this->utility_model->time_format_for_read_write($post_value->post_date_time);
            ?>
        </span>
    </p><hr>
</div>
<div class="text-left" style="margin-left: 75px;">
    <?php
    if (isset($post_value->post_like_by)) {
        $post_like_id = $post_value->post_like_by;
        $this->cf->read_write_status($user_id, $post_like_id, 'post' . $post_value->post_id);
        $post_like_id_array = explode(',', $post_like_id);
        ?>
        <div id="viewLikeModal_post<?php echo $post_value->post_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($post_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 ($post_liked_person as $post_person_value) {
                                        ?>
                                        <div class="media">
                                            <div class="media-left">
                                                <?php if ($post_person_value->person_image != '') {
                                                    ?>
                                                    <img class="media-object" src="<?php echo base_url() . 'content-library/' . $post_person_value->url . '/' . $post_person_value->person_image; ?>" 
                                                         alt="<?php echo $post_person_value->person_first_name . ' ' . $post_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 $post_person_value->person_first_name . ' ' . $post_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 $post_person_value->url ?>" target="_blank">
                                                        <?php echo $post_person_value->person_first_name . ' ' . $post_person_value->person_last_name ?>
                                                    </a>
                                                    <?php
                                                    if ($post_person_value->person_id != $user_id) {
                                                        if (!in_array($post_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>

<!------------- Start after Post Comments FORM----------------- -->
<div class="col-sm-12" 
     id="add_write_form<?php echo $post_value->post_id; ?>" style="margin-left: 40px; display: none">
</div>
<!-- END after Post Comments FORM -->