<?php
$user_id = $this->session->userdata('user_id');
// $this->cf->dd($person_detail);
?>
<input id="baseUrl" type="hidden" value="<?php echo base_url(); ?>">
<div class="col-sm-8">
    <div class="row ">
        <div class="col-sm-12 ">

            <div id="content_library_rows" class="col-sm-12" style="padding: 0">
                <div class="col-sm-12 gray_ttc text-left" style="border-bottom: 2px solid #8CC73F;padding: 10px 0 10px 0;font-weight: bold">
                    <div class="col-sm-2" style="padding: 10px">Image</div>
                    <div class="col-sm-5" style="padding: 10px">Title</div>
                    <div class="col-sm-3" style="padding: 10px">Date</div>
                    <div class="col-sm-2" style="padding: 10px">Action</div>
                </div>
                <div class="col-sm-12"><br></div> 
<!--                Post image album part start-->
            <?php if(isset($post_images) && !empty($post_images)){ ?>
                <div class="col-sm-12 gray text-left" >
                    <div class="col-sm-2" style="padding: 10px 0 0 20px  ">
                        <img src="<?php echo base_url('content-library/'.$this->session->person_url.'/'.$post_last_image->image_location);?>" width="50px">
                    </div>
                    <div class="col-sm-5" style="padding: 10px 0 0 20px  ">
                        <a href="<?php echo base_url() ?>post-image-album">Post Image Album </a>
                    </div>
                    <div class="col-sm-offset-3 col-sm-2" style="padding: 10px 0 0 20px  ">
                        <a href="<?php echo base_url() ?>post-image-album" title="Details Album"><i class="fa fa-th"></i></a>
                    </div>
                </div>
                <div class="col-sm-12"><br></div>
            <?php } ?>
<!--                Post image album part End           -->
<!--                Profile image album part start              -->
            <?php if(isset($profile_images) && !empty($profile_images)){ ?>
                <div class="col-sm-12 gray text-left" >
                    <div class="col-sm-2" style="padding: 10px 0 0 20px  ">
                        <img src="<?php 
                                    if(isset($person_detail->person_image)){
                                        echo base_url('content-library/'.$this->session->person_url.'/'.$person_detail->person_image);
                                    }
                                    else{
                                        echo base_url('image/no_profile_picture.png');
                                    }
                                ?>" width="50px">
                    </div>
                    <div class="col-sm-5" style="padding: 10px 0 0 20px  ">
                        <a href="<?php echo base_url() ?>profile-image-album" title="Details Album"> Profile Image Album </a>
                    </div>
                    <div class="col-sm-offset-3 col-sm-2" style="padding: 10px 0 0 20px  ">
                        <a href="<?php echo base_url() ?>profile-image-album" title="Details Album"><i class="fa fa-th"></i></a>
                    </div>
                </div>
                <div class="col-sm-12"><br></div>
                <?php } ?>
<!--                Post image album part End           -->
                <?php
                foreach ($content_library as $content_library_value) {
                    if($content_library_value->post_type != 4){
                    ?>
                
                    <div class="col-sm-12 gray text-left" >
                        <?php
                        switch ($content_library_value->post_type) {
                            case 5:
                                ?>
                                <div class="col-sm-2" style="padding: 10px 0 0 20px  ">
                                    <a href="javascript:void(0)"
                                       onclick="downloadContentLibrary('<?php echo base_url() . 'download-content-library' ?>', '<?php echo $content_library_value->post_id; ?>')">
                                        <img src="<?php echo base_url() ?>image/assignment/video.png">
                                    </a>
                                </div>
                                <?php
                                break;

                            case 4:
                                ?>
                                <div class="col-sm-2" style="padding: 10px 0 0 20px  ">
                                    <a href="javascript:void(0)"
                                       onclick="downloadContentLibrary('<?php echo base_url() . 'download-content-library' ?>', '<?php echo $content_library_value->post_id; ?>')">
                                        <img height="50" width="50"
                                             src="<?php echo base_url() . 'content-library/' . $content_library_value->url . '/' . $content_library_value->post_details; ?>">
                                    </a>
                                </div>
                                <?php
                                break;
                            case 3:
                                ?>
                                <div class="col-sm-2" style="padding: 10px 0 0 20px  ">
                                    <?php
                                    $file_name = explode(".", $content_library_value->post_details);
                                    switch (strtolower($file_name[1])) {
                                        case 'pdf':
                                            ?>
                                            <a href="javascript:void(0)"
                                               onclick="downloadContentLibrary('<?php echo base_url() . 'download-content-library' ?>', '<?php echo $content_library_value->post_id; ?>')">
                                                <img src="<?php echo base_url() . 'image/assignment/pdf.png' ?>">
                                            </a>
                                            <?php
                                            break;
                                        case $file_name[1] == 'zip' || $file_name[1] == 'rar':
                                            ?>
                                            <a href="javascript:void(0)"
                                               onclick="downloadContentLibrary('<?php echo base_url() . 'download-content-library' ?>', '<?php echo $content_library_value->post_id; ?>')" >
                                                <img src=" <?php echo base_url() . 'image/assignment/rar.png' ?>">
                                            </a>
                                            <?php
                                            break;
                                        case $file_name[1] == 'doc' || $file_name[1] == 'docx':
                                            ?>
                                            <a href="javascript:void(0)" 
                                               onclick="downloadContentLibrary('<?php echo base_url() . 'download-content-library' ?>', '<?php echo $content_library_value->post_id; ?>')" >
                                                <img src=" <?php echo base_url() . 'image/assignment/word.png' ?>">
                                            </a>
                                            <?php
                                            break;
                                        case $file_name[1] == 'xls' || $file_name[1] == 'xlsx':
                                            ?>
                                            <a href="javascript:void(0)" 
                                               onclick="downloadContentLibrary('<?php echo base_url() . 'download-content-library' ?>', '<?php echo $content_library_value->post_id; ?>')" >
                                                <img src=" <?php echo base_url() . 'image/assignment/excel.png' ?>">
                                            </a>
                                            <?php
                                            break;
                                        case $file_name[1] == 'ppt' || $file_name[1] == 'pptx':
                                            ?>
                                            <a href="javascript:void(0)" 
                                               onclick="downloadContentLibrary('<?php echo base_url() . 'download-content-library' ?>', '<?php echo $content_library_value->post_id; ?>')" >
                                                <img src=" <?php echo base_url() . 'image/assignment/powerpoint.png' ?>">
                                            </a>
                                            <?php
                                            break;
                                        default :
                                            ?>
                                            <a href="javascript:void(0)"
                                               onclick="downloadContentLibrary('<?php echo base_url() . 'download-content-library' ?>', '<?php echo $content_library_value->post_id; ?>')" >
                                                <img src=" <?php echo base_url() . 'image/assignment/unknown.png' ?>">
                                            </a>
                                            <?php
                                            break;
                                    }
                                    ?>
                                </div>
                                <?php
                                break;
                        }
                        ?>

                        <div class="col-sm-5" style="padding: 10px 0 0 0  ">
                            <a href="<?php echo base_url() . 'view-content/' . $this->utility_model->encode_id($content_library_value->post_id, '/', 'Tt') . '/2'; ?>"><?php
                                if (strlen($content_library_value->post_file_original_name) > 20) {
                                    echo mb_substr($content_library_value->post_file_original_name, 0, 25, 'utf-8') . '...';
                                } else {
                                    echo $content_library_value->post_file_original_name;
                                }
                                ?></a>
                        </div>
                        <div class="col-sm-3" style="padding: 10px 0 0 0  "><?php
                            echo $this->utility_model->date_time_format_with_offset($content_library_value->post_date_time);
                            ?></div>
                        <div class="col-sm-2" style="padding: 10px 0 0 0" id="content_action<?php echo $content_library_value->post_id ?>">
                            <?php
                            if ($content_library_value->posted_by == $user_id) {
                                if ($content_library_value->post_status == 1) {
                                    ?>
                                    <a href="javascript:void(0)" onclick="changePostStatus('<?php echo base_url() . 'post/change_post_status/' . $content_library_value->post_id . '/inactive/content' ?>', 'content', '<?php echo $content_library_value->post_id ?>')">
                                        <i class="fa fa-user-times " title="Inactive"></i>
                                    </a>&nbsp;
                                <?php } else { ?>
                                    <a href="javascript:void(0)" onclick="changePostStatus('<?php echo base_url() . 'post/change_post_status/' . $content_library_value->post_id . '/active/content' ?>', 'content', '<?php echo $content_library_value->post_id ?>')">
                                        <i class="fa fa-user-plus " title="Active"></i>
                                    </a>&nbsp;
                                <?php } ?>
                                <a href="<?php echo base_url() . 'user/edit-post/' . $this->utility_model->encode_id($content_library_value->post_id, '/', 'Tt'); ?>" target="_blank">
                                    <i class="fa fa-edit" aria-hidden="true" title="edit"></i>
                                </a>&nbsp;&nbsp;
                                <a href="javascript:void(0)" onclick="changePostDelete('<?php echo base_url() . 'post/change_post_status/' . $content_library_value->post_id . '/delete/content' ?>', 'content', '<?php echo $content_library_value->post_id ?>')">
                                    <i class="fa fa-trash-o" title="Delete"></i>
                                </a>&nbsp;&nbsp;
                                <a href="<?php echo base_url() . 'view-content/' . $this->utility_model->encode_id($content_library_value->post_id, '/', 'Tt') . '/2'; ?>">
                                    <i class="fa fa-th" title="View"></i>
                                </a>&nbsp;&nbsp;
                            <?php } else { ?>
                                <a href="<?php echo base_url() . 'view-content/' . $this->utility_model->encode_id($content_library_value->post_id, '/', 'Tt') . '/2'; ?>" target="_blank">
                                    <i class="fa fa-th" title="View"></i>
                                </a>&nbsp;&nbsp;
                            <?php } ?>
                        </div>
                    </div>
                    <div class="col-sm-12"><br></div>
                <?php }}
                ?>           


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

                <!--            Pagination start            -->
                <?php
               
                    echo $pagination_link;
               ?>
                <!--            Pagination End            -->

            </div>
        </div>
    </div>
</div>
<script>
     $(document).on('click', "a[id^=content_library_pagination]", function(){
        var page_number = this.id.replace('content_library_pagination', '');        
        var url = $('#baseUrl').val() + 'profile/my_content_library_ajax';        
       $.post(url, 
              {
                 page_number: page_number, 
              }, 
              function(data){
           $('#content_library_rows').html(data);
       })
    })
</script>
<script type="text/javascript" src="<?php echo base_url() ?>front_end_resource/dashboard/home.js"></script>

<div id="EditAlbumImageVideoUploadModel" class="modal fade bs-example-modal-md" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
    <div class="modal-dialog modal-md">
        <div class="modal-content gray_ttc" >
            <div class="modal-header" style="padding: 10px 20px 5px 10px">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="gridSystemModalLabel" style="    font-size: 18px;font-weight: normal;color: #8899a6;text-align: center !important;">Edit Album photo</h4>
            </div>

            <div class="modal-body" style="background: #fff;padding-bottom: 0">
                <div class="row">
                    <div class="col-sm-12" style="margin-bottom: 15px;">
                        <div class="col-sm-12 padding-zero" style="border: 1px solid #80c12c">
                            <textarea placeholder="What's happening ?" class="form-control" rows="3"  style="max-width: 100%;max-height: 90px;border-bottom: 1px solid limegreen;border-top: none;border-left: none; border-right: none; "></textarea>

                            <div class="row" style="padding: 10px;height: 160px;overflow-y: scroll;" >
                                <div class="col-xs-6 col-sm-3" >
                                    <a href="#" class="thumbnail" style="margin-bottom: 0px;border: none">
                                        <img src="<?php echo base_url() ?>image/no_profile_picture.png" alt="Image Title" class="img-rounded box-shadow">
                                    </a>
                                    <a href="#">
                                        <span class="badge" style="position: absolute;z-index: 9999;right: 22px;top: 6px;"><i class="fa fa-times"></i></span>
                                    </a>
                                </div>

                                <div class="col-xs-6 col-sm-3" >
                                    <a href="#" class="thumbnail" style="margin-bottom: 0px;border: none">
                                        <img src="<?php echo base_url() ?>image/no_profile_picture.png" alt="Image Title" class="img-rounded box-shadow">
                                    </a>
                                    <a href="#">
                                        <span class="badge" style="position: absolute;z-index: 9999;right: 22px;top: 6px;"><i class="fa fa-times"></i></span>
                                    </a>
                                </div>

                                <div class="col-xs-6 col-sm-3" >
                                    <a href="#" class="thumbnail" style="margin-bottom: 0px;border: none">
                                        <img src="<?php echo base_url() ?>image/no_profile_picture.png" alt="Image Title" class="img-rounded box-shadow">
                                    </a>
                                    <a href="#">
                                        <span class="badge" style="position: absolute;z-index: 9999;right: 22px;top: 6px;"><i class="fa fa-times"></i></span>
                                    </a>
                                </div>

                                <div class="col-xs-6 col-sm-3" >
                                    <a href="#" class="thumbnail" style="margin-bottom: 0px;border: none">
                                        <img src="<?php echo base_url() ?>image/no_profile_picture.png" alt="Image Title" class="img-rounded box-shadow">
                                    </a>
                                    <a href="#">
                                        <span class="badge" style="position: absolute;z-index: 9999;right: 22px;top: 6px;"><i class="fa fa-times"></i></span>
                                    </a>
                                </div>

                                <div class="col-xs-6 col-sm-3" >
                                    <a href="#" class="thumbnail" style="margin-bottom: 0px;border: none">
                                        <img src="<?php echo base_url() ?>image/no_profile_picture.png" alt="Image Title" class="img-rounded box-shadow">
                                    </a>
                                    <a href="#">
                                        <span class="badge" style="position: absolute;z-index: 9999;right: 22px;top: 6px;"><i class="fa fa-times"></i></span>
                                    </a>
                                </div>


                            </div>

                        </div>
                    </div>
                </div>
                <div class="row" style="background: #F2F9EA">
                    <div class="col-sm-12" style="padding: 10px">
                        <div class="col-sm-1  col-xs-3 form-group" title="Add Photos or Video">
                            <input tabindex="-1" 
                                   style="position: absolute; clip: rect(0px, 0px, 0px, 0px);" 
                                   id="assignment_file"
                                   name="assignment_file"
                                   class="filestyle" data-icon="true" data-input="false" data-buttonText=" " data-iconName="glyphicon glyphicon-camera" type="file" value=""
                                   onchange="getAssignmentFileName(this)" >

                            <!--                            <div class="bootstrap-filestyle input-group">
                            
                                                            <label for="assignment_file" class="btn btn-default ">
                                                                <span class="buttonText"><i class="fa fa-camera"></i></span>
                                                            </label>
                                                        </div>-->
                        </div>
                        <div class="col-sm-1 col-xs-3  form-group" title="Add Title">
                            <a href="#" class="btn btn-success"> <i class="fa  fa-pencil" aria-hidden="true"></i></a>
                        </div>
                        <div class="col-sm-1 col-xs-3  form-group" title="Add Description">
                            <a href="#" class="btn btn-success"> <i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
                        </div>
                        <div class="col-sm-1 col-xs-3  form-group" title="Tags">
                            <a href="#" class="btn btn-success"> <i class="fa fa-tags" aria-hidden="true"></i></a>
                        </div>
                        <div class="col-sm-1 col-xs-3  form-group" title="Add Location">
                            <a href="#" class="btn btn-success"> <i class="fa fa-location-arrow" aria-hidden="true"></i></a>
                        </div>
                        <div class="col-sm-3  col-xs-12 pull-right  form-group">
                            <a href="#" class="btn btn-success"> Update</a>
                        </div>
                    </div>
                </div>

            </div><!-- /.modal-content -->
        </div>

    </div>
</div>