<?php
$user_id = $this->session->userdata('user_id');
$offset = $this->session->userdata('time_offset');
$you_tube_regExp = '/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/';
$vimo_regExp = '/(?:vimeo)\.com.*(?:videos|video|channels|)\/([\d]+)/i';
?>
<div class="col-sm-8 mobile_padding_zero" style="margin-top: 20px;">
    <div style="margin-left: 50px;">
        <?php
        switch ($post_value->post_type) {
            case 1:
                ?>
                <div class="col-sm-12 row padding-zero" style="height: 90px" >
                    <div class="form-group input-group col-sm-12" id="textArea" style="display: block">
                        <textarea id="note_detail"
                                  oninput="getEditTextDetails(this.value,'note')"
                                  class="form-control" 
                                  style="max-width:650px;max-height: 120px "  
                                  rows="2" 
                                  placeholder="Type your Note here.." 
                                  aria-describedby="basic-addon1"><?php 
                                  echo $this->tt_post->get_post_details_for_update($post_value->post_details);
                                          ?></textarea>
                    </div>
                    <div class="col-sm-12 text-center">
                        <span id="note_detail_error" style="color:red"></span>
                    </div>
                </div>
                <input type="hidden" id="check_url_status" value="1">
                <!--any URL view start-->
                <div class="col-sm-12 row text-left text-justify" style=" display: block" id="URLview" >
                    <img src="<?php echo base_url() ?>image/ajaxloader.gif" 
                         height="30" width="30"
                         id="loadingImage"
                         style="visibility: hidden;"
                         class="img-responsive">
                    <div class="col-sm-12 padding-zero" style=" display: block" id="editURLview">
                        <?php
                        if ($post_url) {
                            ?>
                            <input type="hidden" id="url_status" value="1">
                            <div class="col-sm-12">
                                <a href="javascript:void(0)" onclick="removePostUrl('<?php echo base_url() . 'post/remove_post_url' ?>', '<?php echo $post_url->post_comment_url_id ?>', '<?php echo $post_value->post_id ?>')">
                                    <i class="glyphicon glyphicon-remove" title="Remove Url"></i>
                                </a>
                            </div>
                            <?php
                            $url_value = explode("URL: ", $post_url->post_comment_url_info);
                            if (preg_match($you_tube_regExp, $url_value[1])) {
                                ?>
                                <div class="embed-responsive embed-responsive-16by9">
                                    <iframe class="embed-responsive-item" width="420" height="345" webkitallowfullscreen mozallowfullscreen allowfullscreen
                                            src="<?php echo $url_value[1]; ?>">
                                    </iframe>
                                </div> 
                                <?php
                            } else if (preg_match($vimo_regExp, $url_value[1])) {
                                ?>
                                <div class="embed-responsive embed-responsive-16by9">
                                    <iframe class="embed-responsive-item"  src="<?php echo $url_value[1]; ?>" 
                                            width="420" height="345" 
                                            frameborder="0" 
                                            webkitallowfullscreen mozallowfullscreen allowfullscreen>
                                    </iframe>
                                </div>     
                                <?php
                            } else {
                                ?>
                                <div class="col-sm-12 text-justify mobile_dashboard_post_url_note_padding_zero mobile_dashboard_post_url_note_width">
                                    <div class="col-sm-12 mobile_dashboard_post_url_note_padding_zero">
                                        <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 mobile_dashboard_post_url_note_padding_zero" 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 mobile_dashboard_post_url_note_padding_zero" 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
                            }
                        }
                        ?>
                    </div>
                </div>
                <!--any link view start-->
                <?php
                break;

            case 2:
                ?>
                <div class="col-sm-12 row padding-zero" style="height: 90px" >
                    <div class="form-group input-group col-sm-12" id="textArea" style="display: block">
                        <textarea id="alert_detail"
                                  oninput="getEditTextDetails(this.value,'alert')"
                                  class="form-control" 
                                  style="max-width:650px;max-height: 120px "  
                                  rows="2" 
                                  placeholder="Type your Alert here.." 
                                  aria-describedby="basic-addon1"><?php echo $this->tt_post->get_post_details_for_update($post_value->post_details); ?></textarea>
                    </div>
                    <div class="col-sm-12 text-center">
                        <span id="alert_detail_error" style="color:red"></span>
                    </div>
                </div>
                <input type="hidden" id="check_url_status" value="1">
                <!--any URL view start-->
                <div class="col-sm-12 row text-left text-justify" style=" display: block" id="URLview" >
                    <img src="<?php echo base_url() ?>image/ajaxloader.gif" 
                         height="30" width="30"
                         id="loadingImage"
                         style="visibility: hidden;"
                         class="img-responsive">
                    <div class="col-sm-12 padding-zero" style=" display: block" id="editURLview">
                        <?php
                        if ($post_url) {
                            ?>
                            <input type="hidden" id="url_status" value="1">
                            <div class="col-sm-12">
                                <a href="javascript:void(0)" onclick="removePostUrl('<?php echo base_url() . 'post/remove_post_url' ?>', '<?php echo $post_url->post_comment_url_id ?>', '<?php echo $post_value->post_id ?>')">
                                    <i class="glyphicon glyphicon-remove" title="Remove Url"></i>
                                </a>
                            </div>
                            <?php
                            $url_value = explode("URL: ", $post_url->post_comment_url_info);
                            if (preg_match($you_tube_regExp, $url_value[1])) {
                                ?>
                                <div class="embed-responsive embed-responsive-16by9">
                                    <iframe class="embed-responsive-item" width="420" height="345" webkitallowfullscreen mozallowfullscreen allowfullscreen
                                            src="<?php echo $url_value[1]; ?>">
                                    </iframe>
                                </div> 
                                <?php
                            } else if (preg_match($vimo_regExp, $url_value[1])) {
                                ?>
                                <div class="embed-responsive embed-responsive-16by9">
                                    <iframe class="embed-responsive-item"  src="<?php echo $url_value[1]; ?>" 
                                            width="420" height="345" 
                                            frameborder="0" 
                                            webkitallowfullscreen mozallowfullscreen allowfullscreen>
                                    </iframe>
                                </div>     
                                <?php
                            } else {
                                ?>
                                <div class="col-sm-12 text-justify mobile_dashboard_post_url_note_padding_zero mobile_dashboard_post_url_note_width">
                                    <div class="col-sm-12 mobile_dashboard_post_url_note_padding_zero">
                                        <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 mobile_dashboard_post_url_note_padding_zero" 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 mobile_dashboard_post_url_note_padding_zero" 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
                            }
                        }
                        ?>
                    </div>
                </div>
                <?php
                break;

            case 3:
                ?>
                <div class="col-sm-12 row" style="height: 60px" >
                    <div class="form-group col-sm-6  col-sm-offset-3">
                        <input tabindex="-1" 
                               style="position: absolute; clip: rect(0px, 0px, 0px, 0px);" 
                               id="assignment_file"
                               name="assignment_file"
                               class="" data-icon="false" type="file" value=""
                               onchange="getEditAssignmentFile(this, '<?php echo base_url() . 'post/upload_edit_assignment' ?>', '<?php echo $post_value->post_id ?>')" >
                        <div class="bootstrap-filestyle input-group">
                            <input class="form-control " disabled 
                                   type="text" 
                                   id="file_name"
                                   value="<?php echo $post_value->post_file_original_name ?>"> 
                            <span tabindex="0" class="group-span-filestyle input-group-btn">
                                <label for="assignment_file" class="btn btn-default ">
                                    <span class="buttonText">Choose file</span>
                                </label>
                            </span>
                        </div>
                    </div>

                    <!--Progress bar start-->

                    <div class="col-sm-6 col-sm-offset-3" id="viewProgressBar" style="display: none;">
                        <div class="progress" style="height: 5px; ">
                            <div id="progressBar" 
                                 class="progress-bar progress-bar-success progress-bar-striped" 
                                 role="progressbar" aria-valuenow="40" 
                                 aria-valuemin="0" 
                                 aria-valuemax="100" 
                                 style="">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-3">
                    </div>
                </div>
                <div class="col-sm-12">
                    <input type="hidden" id="assignment_file_upload_status" value="1">
                    <span id="assignment_file_error" style="color:red"></span>
                </div>
                <?php
                break;
            case $post_value->post_type == 4 || $post_value->post_type == 5:
                ?>
                <div class="col-sm-12 row" style="height: 60px" >
                    <div class="form-group col-sm-6  col-sm-offset-3">
                        <input tabindex="-1" 
                               style="position: absolute; clip: rect(0px, 0px, 0px, 0px);" 
                               id="image_video_file"
                               name="image_video_file"
                               class="" data-icon="false" type="file" value=""
                               onchange="getEditImageVideoFile(this, '<?php echo base_url() . 'post/upload_edit_image_video' ?>', '<?php echo $post_value->post_id ?>')" >
                        <div class="bootstrap-filestyle input-group">
                            <input class="form-control " disabled 
                                   type="text" 
                                   id="file_name"
                                   value="<?php echo $post_value->post_file_original_name ?>"> 
                            <span tabindex="0" class="group-span-filestyle input-group-btn">
                                <label for="image_video_file" 
                                       id="image_video_file"
                                       class="btn btn-default ">
                                    <span class="buttonText">Choose file</span>
                                </label>
                            </span>
                        </div>

                    </div>
                    <div class="col-sm-3" id="image_div" style="margin-top: -5px; margin-left: -10px; display: none">
                        <img src="" id="image_src" height="50" width="50">
                    </div>

                    <!--Progress bar start-->

                    <div class="col-sm-6 col-sm-offset-3" id="viewProgressBar" style="display: none;">
                        <div class="progress" style="height: 5px;">
                            <div id="progressBar" 
                                 class="progress-bar progress-bar-success progress-bar-striped" 
                                 role="progressbar" aria-valuenow="40" 
                                 aria-valuemin="0" 
                                 aria-valuemax="100" 
                                 style="">
                            </div>
                        </div>
                        
                        <div id="post_processing_image" style="display:none">
                            <span>Processing</span>
                            <img src="<?php echo base_url('image/ajaxloader.gif')?>" style="max-width: 35px;">
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <input type="hidden" id="image_video_file_upload_status" value="1">
                    <span id="image_video_file_error" style="color:red"></span>
                </div>
                <?php
                break;
        }
        ?>

        <div class="col-sm-12 row padding-zero">
            <div class="col-sm-6 text-left" style="padding-top: 10px;font-size: 15px">
                <a href="javascript:void(0)" onclick="getPublicationStatus('1')"><i class="fa  fa-globe" title="Public"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:void(0)" onclick="getPublicationStatus('2')"><img src="<?php echo base_url() ?>image/dashboard-tt-icon.png" title="TT User" alt="TT User"></a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:void(0)" onclick="getPublicationStatus('4')"><i class="fa  fa-users" title="Group"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:void(0)" onclick="getPublicationStatus('3')"><i class="fa  fa-link" title="Link"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="hidden" id="publication_status" value="<?php echo $post_value->post_publication_status ?>">
            </div>
            <div class="col-sm-6 text-left" style="padding-top: 10px;font-size: 16px;" id="View_User">
                <span id="status_green" style="color: #80c12c"></span>
                <span id="status_red" style="color: #a70b0c"></span>
            </div>
        </div>

        <div class="form-group col-sm-12" style="margin: 10px 0 0 38px">
            <div class="form-group col-sm-7">
                    <span id="GroupForm" style="display: none">
                        <input class="col-sm-12" type="hidden" name="to_address" id="to_address" value="" >
                        <select name="tokenize_placeholder" style="width: 280px;padding: 8px;" id="tokenize_placeholder" 
                                data-errormessage-value-missing="Group Name is Required!"
                                class="tokenize-sample validate[]"
                                title="" 
                                multiple="multiple" style="margin: 0px; padding: 0px; border: 0px; display: none;">
                                    <?php
                                    foreach ($all_approved_group as $value1) {
                                        ?>
                                <option 
                                <?php
                                if (in_array($value1->group_id, $selected_group_id)) {
                                    echo 'selected';
                                }
                                ?>
                                    value="<?php echo $value1->group_id ?>"><?php echo $value1->group_name ?></option>
                                <?php }
                                ?>
                        </select>
                        <script>
                            $('select#tokenize_placeholder').tokenize({placeholder: "Please Type Group Name"});
                        </script>
                    </span>
                    <span id="group_error" style="color:red"></span>
            </div>
            <div class="col-sm-2 form-group" style="padding-left: 2px;">
                <?php
                switch ($post_value->post_type) {
                    case 1:
                        ?>
                        <button type="button"
                                onclick="return updateNote('<?php echo base_url() . 'post/update_note' ?>', '<?php echo $post_value->post_id ?>')"
                                class="btn btn-success  " id="btn"> Update</button>
                                <?php
                                break;
                            case 2:
                                ?>
                        <button type="button"
                                onclick="return updateAlert('<?php echo base_url() . 'post/update_alert' ?>', '<?php echo $post_value->post_id ?>')"
                                class="btn btn-success  " id="btn"> Update</button>
                                <?php
                                break;
                            case 3:
                                ?>
                        <button type="button" 
                                onclick="return updateAssignment('<?php echo base_url() . 'post/update_post_file_details' ?>', '<?php echo $post_value->post_id ?>')"
                                class="btn btn-success  " id="btn"> Update</button>
                                <?php
                                break;
                            case $post_value->post_type == 4 || $post_value->post_type == 5:
                                ?>
                        <button type="button" 
                                onclick="return updateImageVideo('<?php echo base_url() . 'post/update_post_file_details' ?>', '<?php echo $post_value->post_id ?>')"
                                class=" btn btn-success"  id="btn"> Update</button>
                        <?php
                        break;
                }
                ?>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var allGroupId = new Array();
<?php foreach ($all_approved_group as $value) { ?>
        allGroupId.push('<?php echo $value->group_id; ?>');
<?php } ?>
</script>
<script type="text/javascript" src="<?php echo base_url() ?>front_end_resource/dashboard/home.js">
</script>
<script>
    getPublicationStatus('<?php echo $post_value->post_publication_status ?>');
</script>