<div class="col-sm-8">
    <div class="row gray">
        <div class="col-sm-12 ">
            <div class="col-sm-12">
                <nav class="text-justify">
                    <center>
                        <div class="col-sm-12 padding-zero" >
                            <span class="clo-sm-4 padding-zero" title="Upload Video">
                                <span class="text-left label" style="color: #000;font-size: 16px;font-weight: normal">Edit Upload Video</span>
                            </span>
                        </div>
                    </center>
                </nav>
                <div class="col-sm-12"><br></div>
            </div>
            <div class="col-sm-12"><br></div>
            <div class="col-sm-12">
                <?php
                $url = 'save-uploaded-video/' . $video_course_info->url;
                echo form_open_multipart($url, 'class="" id="formID2" name="uploadVideoForm" onsubmit="return checkVideoCourseWorkFIle();"');
                ?>
                <div class="col-sm-12 padding-zero">
                    <div class="col-sm-12 padding-zero" id="video_section_area">
                        <?php
                        $section_counter_array = array();
                        foreach ($all_video_section as $section_value) {
                            ++$section_counter;
                            $section_counter_array[] = $section_counter;
                            ?>
                            <div id="upload_video_section<?php echo $section_counter; ?>" class="col-sm-12 section-color">
                                <div class="col-sm-12 padding-zero white" ><br>
                                    <div class="form-group col-sm-10">
                                        <div class="input-group">
                                            <input type="text" 
                                                   class="form-control"
                                                   id="video_section_name<?php echo $section_counter; ?>"
                                                   name="video_section_name[<?php echo $section_counter; ?>]"
                                                   oninput="getSectionName(this.value,'<?php echo $video_course_info->video_management_id ?>','<?php echo $section_counter; ?>','<?php echo base_url() . 'check-section-name-exist' ?>')"
                                                   value="<?php echo $section_value->upload_video_section_name; ?>"
                                                   placeholder="Type Video Section Name.." >
                                            <span class="input-group-addon"  title="Type Video Section Name"><i class="fa fa-folder"></i></span>
                                        </div>
                                        <input type="hidden" id="video_section_validate<?php echo $section_counter; ?>" value="">
                                        <div class="col-sm-12" id="video_section_name_errror<?php echo $section_counter; ?>" style="color: red"></div>
                                    </div>
                                    <div class="form-group col-sm-2" >
                                        <a href="javascript:void(0)" 
                                           onclick="removeSingleVideoSection('<?php echo $section_counter ?>', '<?php echo base_url() . 'remove-video-course-section' ?>')">
                                            <i class="fa fa-times-circle fa-2x"></i>
                                        </a>
                                    </div>
                                </div>


                                <div class="col-sm-12 padding-zero" id="upload_video_section_view<?php echo $section_counter ?>">
                                    <?php
                                    $video_counter = 0;
                                    $all_video_counter = array();
                                    $all_video_upload_id = array();
                                    $all_video_work_file_counter = array();
                                    $all_video_work_file_id = array();
                                    foreach ($upload_video_info[$section_value->upload_video_section_name] as $upload_video_value) {
                                        ++$video_counter;
                                        $all_video_counter[] = $video_counter;
                                        $all_video_upload_id[] = $upload_video_value->upload_video_id;
                                        ?>
                                    <div id="upload_video_area<?php echo $section_counter . '_video' . $video_counter ?>" class="col-sm-12 padding-zero">
                                            <div class="col-sm-12 padding-zero margin-top-20 white form-group">
                                                <div class="col-sm-12"><br> </div>
                                                <div class="form-group col-sm-10">
                                                    <div class="input-group">
                                                        <input type="text" 
                                                               class="form-control"
                                                               id="video_name_sec<?php echo $section_counter . '_video' . $video_counter ?>"
                                                               name="upload_video_name[<?php echo $section_counter ?>][<?php echo $video_counter ?>]"
                                                               oninput="getUploadVideoName(this.value,'<?php echo $video_course_info->video_management_id ?>','<?php echo $section_counter; ?>','<?php echo $video_counter; ?>','<?php echo base_url() . 'check-video-file-name-exist' ?>')"
                                                               value="<?php echo $upload_video_value->upload_video_name; ?>"
                                                               placeholder=" Please Type Video Title Name.." >
                                                        <span class="input-group-addon"  title="Please Type Video Title Name"><i class="fa fa-file"></i></span>
                                                    </div>
                                                    <input type="hidden" id="video_name_validate_sec<?php echo $section_counter . '_video' . $video_counter ?>" value="">
                                                    <div class="col-sm-12" id="video_name_error_sec<?php echo $section_counter . '_video' . $video_counter ?>" style="color: red"></div>
                                                </div>
                                                <div class="form-group col-sm-2" >
                                                    <a href="javascript:void(0)"
                                                       onclick="removeSingleVideo('<?php echo $section_counter ?>', '<?php echo $video_counter ?>', '<?php echo base_url() . 'remove-single-video-course' ?>')">
                                                        <i class="fa fa-times-circle fa-2x"></i>
                                                    </a>
                                                    <input type="hidden" id="upload_video_id_sec<?php echo $section_counter . '_video' . $video_counter ?>" value="<?php echo $upload_video_value->upload_video_id; ?>">
                                                </div>
                                                <div class="col-sm-12"><br></div>

                                                <div class="form-group col-sm-12" >
                                                    <div class="input-group text-left">
                                                        <label>Video Transcript</label>
                                                        <textarea class="form-control"
                                                                  id="upload_video_transcript<?php echo $section_counter . '_video' . $video_counter ?>"
                                                                  name="upload_video_transcript[<?php echo $section_counter; ?>][<?php echo $video_counter; ?>]"
                                                                  placeholder="Please Type Video transcripts.." rows="4" cols="55" style="max-width: 550px; max-height: 150px;"><?php echo $upload_video_value->upload_video_transcript; ?></textarea>
                                                    </div>
                                                </div>
                                                <div class="col-sm-12"><br></div>




                                                <div class="col-sm-12 padding-zero">
                                                    <?php
                                                    $video_name = explode('/', $upload_video_value->upload_video_location);
                                                    ?>
                                                    <div class="form-group col-sm-6 " >
                                                        <input type="file"
                                                               onchange="uploadVideo(this, '<?php echo $video_course_info->video_management_id ?>', '<?php echo $section_counter; ?>', '<?php echo $video_counter; ?>', '<?php echo base_url() . 'course-video-file-upload' ?>');"
                                                               class="" data-icon="false"
                                                               name="video_file"
                                                               id="videoFile_sec<?php echo $section_counter . '_video' . $video_counter; ?>"
                                                               tabindex="-1" style="position: absolute; clip: rect(0px 0px 0px 0px);">
                                                        <div class="bootstrap-filestyle input-group">
                                                            <input type="text" disabled class="form-control" 
                                                                   id="view_video_file_name<?php echo $section_counter . '_video' . $video_counter; ?>" value="<?php echo $video_name[4]; ?>">
                                                            <span class="group-span-filestyle input-group-btn" tabindex="1" >
                                                                <label for="videoFile_sec<?php echo $section_counter . '_video' . $video_counter; ?>" class="btn btn-default ">
                                                                    <span class="buttonText">Choose Video</span>
                                                                </label>
                                                            </span>
                                                        </div>
                                                        <span class="pull-left" id="upload_video_error_sec<?php echo $section_counter . '_video' . $video_counter; ?>" 
                                                              style="color: red">
                                                            <span ><label style="color: #666;">[ Upload Video ]</label></span>
                                                        </span>
                                                        <input type="hidden" id="video_status_sec<?php echo $section_counter . '_video' . $video_counter; ?>" value="1">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <div class="col-sm-12" id="progressID_sec<?php echo $section_counter . '_video' . $video_counter; ?>" style="display: none">
                                                            <div class="progress-bar progress-bar-success progress-bar-striped"
                                                                 id="videoProgressBar_sec<?php echo $section_counter . '_video' . $video_counter; ?>"
                                                                 role="progressbar"
                                                                 aria-valuenow="90" 
                                                                 aria-valuemin="0" aria-valuemax="100" 
                                                                 style="">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12" style="color: green;" id="view_file_size_sec<?php echo $section_counter . '_video' . $video_counter; ?>">
                                                        <?php
                                                        $fileSize = round(($upload_video_value->upload_video_size / 1024), 2);
                                                        if ($fileSize > 1024) {
                                                            echo 'File Size : ' . $fileSize = round(($fileSize / 1024), 2) . ' MB';
                                                        } else {
                                                            echo 'File Size : ' . $fileSize = ($fileSize) . ' KB';
                                                        }
                                                        ?></div>
                                                </div>
                                                <div class="col-sm-12 "><br></div>




                                                <div class="col-sm-12 ">
                                                    <div class="form-group col-sm-4 text-left padding-zero" style="margin-top: 10px">  <label > Work files  :  &nbsp;&nbsp;</label></div>
                                                    <div class="form-group radio radio-success col-sm-6 text-left"  >
                                                        <input  onclick="getWorkFileStatus(this.value, '<?php echo $video_course_info->video_management_id ?>', '<?php echo $section_counter; ?>', '<?php echo $video_counter; ?>', '<?php echo base_url() . 'add-video-work-file-view' ?>', '<?php echo base_url() . 'remove-video-work-file-view' ?>')"
                                                                type="radio" 
                                                                name="work_file_status[<?php echo $section_counter; ?>][<?php echo $video_counter; ?>]"
                                                                id="work_file_yes<?php echo $section_counter . '_video' . $video_counter; ?>"  
                                                                value="1" >
                                                        <label for="work_file_yes<?php echo $section_counter . '_video' . $video_counter; ?>">Yes</label>
                                                        <span style="margin-right: 30px"></span>
                                                        <input  onclick="getWorkFileStatus(this.value, '<?php echo $video_course_info->video_management_id ?>', '<?php echo $section_counter; ?>', '<?php echo $video_counter; ?>', '<?php echo base_url() . 'add-video-work-file-view' ?>', '<?php echo base_url() . 'remove-video-work-file-view' ?>')" 
                                                                type="radio"
                                                                name="work_file_status[<?php echo $section_counter; ?>][<?php echo $video_counter; ?>]" 
                                                                id="work_file_no<?php echo $section_counter . '_video' . $video_counter; ?>" 
                                                                value="2">
                                                        <label for="work_file_no<?php echo $section_counter . '_video' . $video_counter; ?>">No</label>
                                                    </div>
                                                    <input type="hidden" id="work_file_status_validate_sec_<?php echo $section_counter . '_video' . $video_counter ?>" value="1">
                                                    <span class="col-sm-12" id="video_work_file_status_error_sec<?php echo $section_counter . '_video' . $video_counter; ?>" 
                                                          style="color: red; margin-top: -15px;"></span>
                                                </div>
                                                <script>
                                                    document.forms['uploadVideoForm'].elements['work_file_status[<?php echo $section_counter; ?>][<?php echo $video_counter; ?>]'].value = '<?php echo $upload_video_value->video_work_files; ?>';
                                                </script>
                                                <input type="hidden" 
                                                       id="upload_video_work_file_id_sec<?php echo $section_counter . '_video' . $video_counter ?>" 
                                                       value="<?php echo $video_work_file_info[$upload_video_value->upload_video_id]->work_files_management_id ?>">
                                                <div class="col-sm-12 "><br><br></div>



                                                <div id="work_file_area_sec<?php echo $section_counter . '_video' . $video_counter ?>" <?php
                                                if ($upload_video_value->video_work_files == 1) {
                                                    echo 'style="display: block"';
                                                } else if ($upload_video_value->video_work_files == 2) {
                                                    echo 'style="display: none"';
                                                }
                                                ?>>

                                                    <?php
                                                    if ($upload_video_value->video_work_files == 1) {
                                                        $all_video_work_file_counter[] = $video_counter;
                                                        $all_video_work_file_id[] = $video_work_file_info[$upload_video_value->upload_video_id]->work_files_management_id;
                                                    }
                                                    ?>

                                                    <div class="form-group col-sm-6">
                                                        <div class="input-group">
                                                            <input type="text" 
                                                                   class="form-control"
                                                                   id="work_files_name_sec<?php echo $section_counter . '_video' . $video_counter; ?>"
                                                                   name="work_files_name[<?php echo $section_counter; ?>][<?php echo $video_counter; ?>]"
                                                                   oninput="getWorkFileName(this.value,'<?php echo $video_course_info->video_management_id ?>','<?php echo $section_counter; ?>','<?php echo $video_counter; ?>','<?php echo base_url() . 'check-video-work-file-name-exist' ?>')"
                                                                   value="<?php echo $video_work_file_info[$upload_video_value->upload_video_id]->work_files_name ?>"
                                                                   placeholder="Please Type Work File Name"  >
                                                            <span class="input-group-addon "  title="Please Type Work File Name"><i class="fa fa-file"></i></span>
                                                        </div>
                                                        <input type="hidden" id="work_files_name_validate_sec<?php echo $section_counter . '_video' . $video_counter; ?>" value="">
                                                        <span class="col-sm-12" id="work_files_name_error_sec<?php echo $section_counter . '_video' . $video_counter; ?>" style="color: red;"></span>
                                                    </div>
                                                    <div class="col-sm-12"><br></div>



                                                    <div class="form-group col-sm-12 padding-zero" >
                                                        <?php
                                                        $work_file_name = explode('/', $video_work_file_info[$upload_video_value->upload_video_id]->work_files_url);
                                                        ?>
                                                        <div class="col-sm-6"> 
                                                            <input tabindex = "-1"
                                                                   style = "position: absolute; clip: rect(0px, 0px, 0px, 0px);"
                                                                   id="workFile_sec<?php echo $section_counter . '_video' . $video_counter; ?>"
                                                                   data-icon = "false" type = "file" value = ""
                                                                   onchange="getVideoWorkFile(this, '<?php echo $video_course_info->video_management_id ?>', '<?php echo $section_counter; ?>', '<?php echo $video_counter; ?>', '<?php echo base_url() . 'upload-video-course-work-file' ?>')" >
                                                            <div class = "bootstrap-filestyle input-group">
                                                                <input class = "form-control " disabled type = "text" 
                                                                       id="view_work_file_name<?php echo $section_counter . '_video' . $video_counter; ?>" 
                                                                       value="<?php echo $work_file_name[4]; ?>">
                                                                <span tabindex = "0" class = "group-span-filestyle input-group-btn">
                                                                    <label for = "workFile_sec<?php echo $section_counter . '_video' . $video_counter; ?>" class = "btn btn-default ">
                                                                        <span class = "buttonText">Choose file</span>
                                                                    </label>
                                                                </span>
                                                            </div>



                                                            <span class="pull-left" id="upload_work_file_error_sec<?php echo $section_counter . '_video' . $video_counter; ?>" 
                                                                  style="color: red">
                                                                <span ><label style="color: #666;">[ Upload work file ]</label></span>
                                                            </span>
                                                            <input type="hidden" id="work_file_upload_status_sec<?php echo $section_counter . '_video' . $video_counter; ?>" value="1">
                                                        </div>
                                                        <div class="col-sm-4"> 
                                                            <div class="col-sm-12" id="workFileProgressID_sec<?php echo $section_counter . '_video' . $video_counter; ?>" style="display: none">
                                                                <div class="progress-bar progress-bar-success progress-bar-striped"
                                                                     id="workProgressBar_sec<?php echo $section_counter . '_video' . $video_counter; ?>"
                                                                     role="progressbar"
                                                                     aria-valuenow="90" 
                                                                     aria-valuemin="0" aria-valuemax="100" 
                                                                     style="">
                                                                </div>
                                                            </div>
                                                        </div>



                                                        <div class="col-sm-12" style="color: green;" id="view_work_file_size_sec<?php echo $section_counter . '_video' . $video_counter; ?>">
                                                            <?php
                                                            $fileSize2 = round(($video_work_file_info[$upload_video_value->upload_video_id]->work_file_size / 1024), 2);
                                                            if ($fileSize2 > 1024) {
                                                                echo 'File Size : ' . $fileSize = round(($fileSize2 / 1024), 2) . ' MB';
                                                            } else {
                                                                echo 'File Size : ' . $fileSize = ($fileSize2) . ' KB';
                                                            }
                                                            ?></div>
                                                    </div>

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

                                <div class="col-sm-12 form-group" style="margin-top: 10px;">
                                    <div class="form-group col-sm-3">
                                        <input type="hidden" 
                                               name="all_upload_video_counter[<?php echo $section_counter ?>]"
                                               id="allUploadVideoCounter_sec_<?php echo $section_counter ?>" 
                                               value="<?php echo implode(',', $all_video_counter); ?>">
                                        <input type="hidden" 
                                               name="all_upload_video_ok_counter[<?php echo $section_counter ?>]"
                                               id="allUploadVideoOKcounter_sec_<?php echo $section_counter ?>" 
                                               value="<?php echo implode(',', $all_video_counter); ?>">
                                        <input type="hidden" 
                                               name="all_upload_video_id[<?php echo $section_counter ?>]"
                                               id="allUploadVideoID_sec_<?php echo $section_counter ?>" 
                                               value="<?php echo implode(',', $all_video_upload_id); ?>">
                                        <input type="hidden" 
                                               name="allUploadVideoID1[<?php echo $section_counter ?>]"
                                               id="allUploadVideoID1_sec_<?php echo $section_counter ?>" 
                                               value="<?php echo implode(',', $all_video_upload_id); ?>">
                                        <input type="hidden" 
                                               name="all_upload_video_work_file_counter[<?php echo $section_counter ?>]"
                                               id="allUploadVideoWorkFileCounter_sec_<?php echo $section_counter ?>" 
                                               value="<?php echo implode(',', $all_video_work_file_counter); ?>">
                                        <input type="hidden" 
                                               name="all_upload_video_work_file_id[<?php echo $section_counter ?>]"
                                               id="allUploadVideoWorkFileID_sec_<?php echo $section_counter ?>" 
                                               value="<?php echo implode(',', array_filter($all_video_work_file_id)); ?>">
                                        <input type="hidden" 
                                               name="all_upload_video_work_file_ok_counter[<?php echo $section_counter ?>]"
                                               id="allUploadVideoWorkFileOKCounter_sec_<?php echo $section_counter ?>" 
                                               value="<?php echo implode(',', $all_video_work_file_counter); ?>">
                                        <a type="button" 
                                           class="btn btn-success" 
                                           onclick="addMoreVideo('<?php echo $video_course_info->video_management_id ?>', '<?php echo $section_counter ?>', '<?php echo base_url() . 'add-single-video-course-area' ?>')" 
                                           style="" >Add More Video</a>
                                    </div>
                                    <div class="form-group col-sm-8 col-sm-offset-1 text-left" 
                                         style="color: red;" 
                                         id="video_course_submit_error<?php echo $section_counter ?>">
                                    </div>
                                </div>
                            </div>
                            <?php
                        }
                        ?>
                    </div>
                    <div class="col-sm-12"><br></div>


                    <div class="form-group col-sm-12">
                        <div class="form-group col-sm-3">
                            <input type="hidden"
                                   name="all_section_counter"
                                   id="allSectionCounter" value="<?php echo implode(',', $section_counter_array); ?>">
                            <a type="button" 
                               class="btn btn-success" 
                               onclick="addMoreVideoSection('<?php echo $video_course_info->video_management_id ?>', '<?php echo base_url() . 'add-video-section-area' ?>')" 
                               >Add More Section </a>
                        </div>
                        <div class="form-group col-sm-8 col-sm-offset-1 text-left" 
                             style="color: red;" 
                             id="section_error">
                        </div>
                    </div>


                    <div class="col-sm-12">
                        <div class="col-sm-12 text-center" style="color: red" id="submit_error">
                        </div>
                        <br>
                        <br>
                    </div>

                    <div class="form-group col-sm-12 padding-zero">
                        <div class="col-sm-1"></div>
                        <div class="col-sm-2"><a href="<?php echo base_url() . 'edit-video-management/' . $video_course_info->url; ?>" class="btn btn-success">Previous</a></div>
                        <div class="form-group col-sm-6">
                            <input type="submit" 
                                   class="green-btn btn btn-default" 
                                   value="Update Video and Work File" ><br/><br/>
                        </div>

                        <div class="col-sm-2">
                            <a href="javascript:void(0);" onclick="askForSkipEditVideoCourseWorkFile('<?php echo $video_course_info->url ?>', '<?php echo base_url() . 'skip-edit-video-course-work-file' ?>', '<?php echo base_url() . 'video-course-review-and-publish' ?>')"class="btn btn-success">
                                Skip !
                            </a>
                        </div>
                        <div class="col-sm-1"></div>
                    </div>
                </div>
                <!--</form>-->
                <?php echo form_close(); ?>
            </div><!-- /.row gray -->


            <script type="text/javascript" src="<?php echo base_url(); ?>front_end_resource/video_course/video_course.js">
            </script>
            <script>
                videoFileSizeResponseURL = '<?php echo base_url() . 'course-video-file-size' ?>';
                removeUploadWorkFileURl = '<?php echo base_url(); ?>remove-video-work-file-view';
            </script> 
        </div>
    </div>
</div>