<script>
    var urlValue = '';
</script>
<?php
$person_id = $this->session->userdata('user_id');
$person_role = $this->session->userdata('person_role');
?>
<div class="col-sm-8 ">
    <div class="row gray_ttc">
        <div class="col-sm-12 row"><br>
            <nav class="text-justify">
                <center>
                    <div class="col-sm-12" style="padding: 0">
                        <span class="clo-sm-4" title="Video Management Information" style="padding: 0">
                            <span class="text-left label" style="color: #000;font-size: 16px;font-weight: normal">Add Video Information</span>
                        </span>
                    </div>
                </center>
            </nav>
        </div>

        <div class="col-sm-12"><br><br></div>
        <div class="col-sm-12">
            <div class="col-sm-12">
                <?php
//                echo validation_errors(); //id="formID2" 
                $url = 'user/add-video-course';
                echo form_open_multipart($url, 'class="" id="addVideoCourseForm" name="videoForm"');
                ?>
                <div class="form-group col-sm-12">
                    <div class="input-group">
                        <input type="text" 
                               data-errormessage-value-missing="Video Title is Required"
                               class="form-control tokenize-sample" 
                               name="video_course_title" 
                               id="video_course_title"
                               oninput="getUrlValue(this.value, urlValue,'<?php echo base_url() . 'user/video-url-existance'; ?>')" 
                               value="<?php echo set_value('video_course_title') ?>"
                               placeholder="Please Type Video Course Title.." aria-describedby="basic-addon1">
                        <span class="input-group-addon" id="basic-addon1" title="Please Type Video Title"><i class="fa fa-video-camera"></i></span>
                    </div>
                    <span id="video_course_title_error" style="color:red;"><?php echo form_error('video_course_title'); ?></span>
                </div>
                <div class="col-sm-12"><br></div>





                <div class="form-group col-sm-6">
                    <div class="input-group">
                        <input type="text" 
                               data-errormessage-value-missing="Video Course Url is Required!" 
                               class="form-control"
                               id="video_course_url" 
                               name="video_course_url" 
                               oninput="getUrlValue('', this.value,'<?php echo base_url() . 'user/video-url-existance'; ?>')"
                               value="<?php echo set_value('video_course_url'); ?>"
                               title="Video Course Url"
                               placeholder="Please Type Video Course URL.." aria-describedby="basic-addon1"
                               maxlength="100">
                        <span class="input-group-addon" id="basic-addon1" title="Please Type Video Course URL"><i class="fa fa-link"></i></span>
                    </div>
                    <input type="hidden" id="video_url_exist" value="">
                    <span id="video_course_url_error" style="color:red;"><?php echo form_error('video_course_url'); ?></span>
                </div>
                <div class="form-group col-sm-12"></div>
                <script>

                    /*
                     * @Function            : getUrlValue 
                     * @Used IN             : @function-'user/video/add_video_course.php(2)'
                     * @Description         : get name from video title if user input in url field than did not make url from title 
                     * @Developed By        : MD JAherul Islam
                     * @Start DateTime      : 24-02-2016 11:27 AM
                     * @Parameter           : videoCourseName[STRING], urlInput[STRING], url[STRING]
                     * @Return              : NULL      
                     * @Status              : available      
                     */
                    function getUrlValue(videoCourseName, urlInput, url) {
                        urlValue = urlInput;
                        if (urlValue === '') {
                            makeCourseUrl(videoCourseName, url);
                        } else {
                            checkCourseUrl(urlValue, url);
                        }
                    }
                </script>

                <div class="form-group col-sm-6">
                    <select data-errormessage-value-missing="Course Category is Required!" 
                            class="form-control" 
                            name="category_id"
                            id="category_id" 
                            onchange="otherCategory();"
                            title="Course Category">
                        <option value="">Select Category</option>
                        <?php
                        foreach ($all_course_category as $category_value) {
                            ?>
                            <option value="<?php echo $category_value->course_category_id; ?>"><?php echo $category_value->course_category_name; ?></option>
                            <?php
                        }
                        if ($resource_person_info->resource_person_type != 1) {
                            echo '<option value="other">Other Category</option>';
                        }
                        ?>
                    </select>
                    <span id="category_id_error" style="color:red;"><?php echo form_error('category_id'); ?></span>
                    <script>
                        document.forms['videoForm'].elements['category_id'].value = '<?php echo set_value('category_id'); ?>';
                    </script>
                </div>






                <div class="form-group col-sm-6"  id="other_course_category" style="display: none">
                    <input type="text" 
                           data-errormessage-value-missing="Category Name is required!" 
                           class="form-control" 
                           id="course_category_name" 
                           name="course_category_name" 
                           maxlength="150"
                           oninput="checkCourseCategory(this.value,'<?php echo base_url() . 'user/video-category-exixtence'; ?>')"
                           placeholder="Please Enter Category Name"  
                           value="<?php echo set_value('course_category_name'); ?>"
                           title="New Category Name">
                    <input type="hidden" name="course_category_name_exist" id="course_category_name_exist" value="">
                    <span id="course_category_name_message" style="color:red;"><?php echo form_error('course_category_name'); ?></span>
                </div>
                <div class="col-sm-12"><br></div>





                <?php if ($person_role == 4) { ?>
                    <div class="form-group col-sm-6">
                        <select data-errormessage-value-missing="Resource person is Required!" 
                                class="form-control" 
                                name="resource_person_id" 
                                id="resource_person_id" 
                                title="Resource person">
                            <option value="">Select Resource Person</option>
                            <option value="<?php echo $resource_person_info->resource_person_id ?>"><?php echo $person_info->person_first_name . ' ' . $person_info->person_last_name; ?></option>
                            <?php foreach ($all_resource_person as $resource_person_value) { ?>
                                <option value="<?php echo $resource_person_value->resource_person_id; ?>"><?php echo $resource_person_value->person_first_name . ' ' . $resource_person_value->person_last_name; ?></option>
                            <?php } ?>
                        </select>
                        <span id="resource_person_id_error" style="color:red;"><?php echo form_error('resource_person_id'); ?></span>
                    </div>
                    <script>
                        document.forms['videoForm'].elements['resource_person_id'].value = '<?php echo set_value('resource_person_id'); ?>';
                    </script>
                <?php } ?>




                <div class="form-group col-sm-6">
                    <select data-errormessage-value-missing="Video Course Level is Required!" 
                            class="form-control" 
                            name="video_course_level" 
                            id="video_course_level"
                            title="Video Course Level">
                        <option value="">Select Course Level</option>
                        <option value="0">Any</option>
                        <option value="1">Basic</option>
                        <option value="2">Intermediate</option>
                        <option value="3">Advance</option>
                    </select>
                    <span id="video_course_level_error" style="color:red;"><?php echo form_error('video_course_level'); ?></span>
                    <script>
                        document.forms['videoForm'].elements['video_course_level'].value = '<?php echo set_value('video_course_level'); ?>';
                    </script>
                </div>
                <div class="col-sm-12"><br></div>





<!--                <div class="form-group col-sm-6">
                    <div class=" col-sm-12" style="padding: 0">
                        <label class="col-xs-4 col-sm-4  text-left" style="padding: 0">Course type: </label>
                        <div  class="col-xs-8 col-sm-8 radio radio-success" style="margin: 0">
                            <input data-errormessage-value-missing="Course Type is Required!" 
                                   class="validate[required] text-input radio" 
                                   type="radio" 
                                   name="video_course_type" 
                                   id="paid" 
                                   value="1" 
                                   onclick="getVideoCourseType(this.value)">
                            <label for="paid">Paid</label>
                            <span style="margin-right: 30px"></span>
                            <input  data-errormessage-value-missing="Course Type is Required!" 
                                    class="validate[required] text-input radio"  
                                    type="radio" 
                                    name="video_course_type" 
                                    id="free" 
                                    value="2" 
                                    onclick="getVideoCourseType(this.value)">
                            <label for="free">Free</label>
                            <div id="video_course_type_error" style="color: red"><?php echo form_error('video_course_type'); ?></div>
                            <script>
                                document.forms['videoForm'].elements['video_course_type'].value = '<?php echo set_value('video_course_type'); ?>';
                            </script>
                        </div>
                    </div>
                </div>-->




<!--
                <div class="form-group col-sm-6">
                    <div style="display:<?php
                    //if (set_value('video_course_type')) {
                        //if (set_value('video_course_type') == 1) {
                           // echo 'block;';
                       // } else {
                          //  echo 'none;';
                     //   }
                   // } else {
                       // echo 'none;';
                   // }
                    ?>;" id="course_price_view">
                        <div class="col-sm-5">
                            <select class="form-control validate[required]"
                                    name="video_course_price_currency" 
                                    id="video_course_price_currency">
                                <option value="1">BDT</option>
                                <option value="2">USD</option>
                            </select>
                            <script>
                                document.forms['videoForm'].elements['video_course_price_currency'].value = '<?php echo set_value('video_course_price_currency'); ?>';
                            </script>
                            <span id="video_course_price_currency_error" class="col-sm-12" style="color: red"><?php echo form_error('video_course_price_currency'); ?></span>
                        </div>
                        <div class="col-sm-7">
                            <div class="input-group">
                                <input type="text" 
                                       data-errormessage-value-missing="Course Price is Required!" 
                                       class="form-control validate[required, custom[integer], custom[nonZeroValue]]" 
                                       id="video_course_price" 
                                       name="video_course_price"  
                                       value="<?php //echo set_value('video_course_price'); ?>"
                                       maxlength="10" title="Video Course Price"
                                       placeholder="Set Course Price" >
                                <span class="input-group-addon" id="basic-addon1" title="Video course price"><i class="fa fa-usd"></i></span>
                            </div>
                            <span id="video_course_price_error" class="col-sm-12" style="color: red"><?php //echo form_error('video_course_price'); ?></span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12"><br></div>-->





<!--                <div class="form-group col-sm-12">
                    <div class=" col-sm-12" style="padding: 0">
                        <label class="col-xs-4 col-sm-4  text-left" style="padding: 0">Upload Video Type: </label>
                        <div  class="col-xs-8 col-sm-8 radio radio-success" style="margin: 0">
                            <input data-errormessage-value-missing="Upload VIdeo Type is Required!" 
                                   class="validate[required]" 
                                   type="radio" 
                                   name="video_course_upload_video_type" 
                                   id="talhatraining"
                                   onclick="getUploadVideoType(this.value)"
                                   value="1">
                            <label for="Talha Training">Talha Training</label>
                            <span style="margin-right: 30px"></span>
                            <input data-errormessage-value-missing="Upload VIdeo Type is Required!" 
                                   class="validate[required]" 
                                   type="radio" 
                                   name="video_course_upload_video_type" 
                                   id="youtube"
                                   onclick="getUploadVideoType(this.value)"
                                   value="2">
                            <label for="YouTube">YouTube</label>
                            <span style="margin-right: 30px"></span>
                            <input  data-errormessage-value-missing="Upload VIdeo Type is Required!" 
                                    class="validate[required]"  
                                    type="radio" 
                                    name="video_course_upload_video_type" 
                                    id="vimo"
                                    onclick="getUploadVideoType(this.value)"
                                    value="3">
                            <label for="Vimo">Vimo</label>
                        </div>
                        <div class="col-sm-12" id="upload_video_type_error" style="color: red"><?php //echo form_error('video_course_upload_video_type'); ?></div>
                        <script>
                            document.forms['videoForm'].elements['video_course_upload_video_type'].value = '<?php //echo set_value('video_course_upload_video_type'); ?>';
                        </script>
                    </div>
                </div>
                <div class="col-sm-12"><br></div>-->






                <div class="form-group col-sm-6" id="video_folder_name_area">
                    <div class="input-group">
                        <input type="text"
                               data-errormessage-value-missing="Video Folder Name is Required"
                               class="form-control"
                               name="video_course_folder_name" 
                               id="video_course_folder_name"
                               oninput="checkVideoFolderName(this.value,'<?php echo base_url() . 'user/check-video-folder-name'; ?>','<?php echo $person_info->person_id ?>')"
                               value="<?php echo set_value('video_course_folder_name') ?>"
                               placeholder="Please Type Folder Name.." aria-describedby="basic-addon1">
                        <span class="input-group-addon" id="basic-addon1" title="Please Type Folder Name"><i class="fa fa-folder"></i></span>
                    </div>
                    <input type="hidden" id="video_name_exixts" value="">
                    <span id="video_course_folder_name_error" style="color:red;"><?php echo form_error('video_course_folder_name'); ?></span>
                </div>
                <div class="col-sm-12"><br></div>




                <div class="form-group col-sm-12" >
                    <div class="input-group text-left">
                        <label>Video Training Objective</label>
                        <textarea class="form-control  resoulation1280" 
                                  name="video_course_objectives"
                                  id="video_training_objectives"  
                                  placeholder="Video Training Objective" ><?php echo set_value('video_training_objectives'); ?></textarea>
                    </div>
                    <div class="text-left" id="video_course_objectives_error" style="color: red"><?php echo form_error('video_training_objectives'); ?></div>
                </div>
                <div class="col-sm-12"><br></div>




                <div class="form-group col-sm-12">
                    <div class="input-group text-left">
                        <label>Video Training Outline</label>
                        <textarea class="form-control  resoulation1280 "  
                                  name="video_course_outline"
                                  placeholder="Video Training Outline" ><?php echo set_value('video_training_outline'); ?></textarea>
                    </div>
                </div>




                <div class="col-sm-12"><br></div>
                <div class="form-group col-sm-6">
                    <select data-errormessage-value-missing="Course Language is Required!" 
                            class="form-control"   
                            name="video_course_language" 
                            id="video_course_language" 
                            title="Video Language">
                        <option value="">Select Language</option>
                        <option value="1">English</option>
                        <option value="2">বাংলা(Bengali)</option>
                    </select>
                    <span id="video_language_error" style="color:red;"><?php echo form_error('video_course_language'); ?></span>
                    <script>
                        document.forms['videoForm'].elements['video_course_language'].value = '<?php echo set_value('video_course_language'); ?>';
                    </script>
                </div>



                <div class="form-group col-sm-6">
                    <select data-errormessage-value-missing="Access Level is Required!" 
                            class="form-control"   
                            name="video_course_access_level" 
                            id="video_course_access_level" 
                            title="Video Course Access Level">
                        <option value="">Select Access Level</option>
                        <option value="1">Public</option>
                        <option value="2">TalhaTraining User</option>
                    </select>
                    <script>
                        document.forms['videoForm'].elements['video_course_access_level'].value = '<?php echo set_value('video_course_access_level'); ?>';
                    </script>
                    <div class="col-sm-12" id="video_course_access_level_error" style="color: red"><?php echo form_error('video_course_access_level'); ?></div>
                </div>
                <div class="col-sm-12"><br></div>



                <div class="col-sm-12"><br></div>
                <div class="col-sm-12" 
                     id="feature_error_message" 
                     style="color: red"></div>
                <div class="col-sm-12"><br></div>
                <div class="form-group col-sm-2 col-sm-offset-5">
                    <input type="submit" class="green-btn btn btn-default" value="Add"><br/><br/>
                </div>

                <?php echo form_close(); ?>
            </div>
        </div>
        <!--</div>-->
    </div>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>front_end_resource/video_course/video_course.js">
</script>
<script>
    otherCategory();
    getVideoCourseType('<?php echo set_value('video_course_type'); ?>');
    getUploadVideoType('<?php echo set_value('video_course_upload_video_type'); ?>');
    document.forms['videoForm'].elements['video_course_access_level'].value = '<?php echo set_value('video_course_access_level'); ?>';
    getAccessLevel('<?php echo set_value('video_course_access_level'); ?>');

</script>