<?php
wp_enqueue_script( 'ulp_ckeditor', ULP_URL . 'assets/js/ckeditor/ckeditor.js', [], false, false);
wp_enqueue_style('ulp_jquery_ui', ULP_URL . 'assets/css/jquery-ui.min.css', array(), null);
wp_enqueue_script('jquery-ui-datepicker');

///croppic
wp_register_script('ulp_uploadFeatureImage', ULP_URL . 'assets/js/uploadFeatureImage.js', [], null);
wp_localize_script('ulp_uploadFeatureImage', 'ulp_plugin_url', ULP_URL);
wp_enqueue_script('ulp_mouse_wheel', ULP_URL . 'assets/js/jquery.mousewheel.min.js', array(), null);
wp_enqueue_script('ulp_croppic', ULP_URL . 'assets/js/croppic.js', array(), null);
wp_enqueue_script('ulp_uploadFeatureImage');
wp_enqueue_style('ulp_croppic', ULP_URL . 'assets/css/croppic.css', array(), null);
?>

<style>
#js_ulp_upload_image_trigger {
    width: 100%;
    height: 300px;
    position: relative;
}
</style>

<script>

  var CKEDITOR_BASEPATH = '<?php echo ULP_URL . 'assets/js/ckeditor/';?>';
  jQuery(document).ready(function(){
      CKEDITOR.replace( 'post_content' )
  })

</script>

<div class="ulp-instructor-edit ulp-instructor-edit-lesson">
<h2><?php _e('Add/Edit Lesson', 'ulp');?></h2>

<form action="<?php echo $data['saveLink'];?>" method="post">
    <input type="hidden" name="ID" value="<?php echo $data['post_data']['ID'];?>" />
  <div class="ulp-instructor-edit-row">
  	<div class="ulp-inst-col-12">
    <div class="ulp-form-section">
        <h4><?php _e('Lesson Title', 'ulp');?></h4>
        <input type="text" name="post_title" class="ulp-form-control" value="<?php echo $data['post_data']['post_title'];?>" />
    </div>
   </div>
 </div>
 <div class="ulp-instructor-edit-line-break"></div>
  <div class="ulp-instructor-edit-row">
  	<div class="ulp-inst-col-4">
    <div class="ulp-form-section">
        <h4><?php _e('Privacy', 'ulp');?></h4>
        <select name="post_status" class="ulp-form-control">
            <?php if ($data['is_senior'] || $data['post_data']['post_status']=='publish'):?>
            <option value="publish" <?php echo $data['post_data']['post_status']=='publish' ? 'selected' : '';?> ><?php _e('Publish', 'ulp');?></option>
            <?php endif;?>
            <option value="pending" <?php echo $data['post_data']['post_status']=='pending' ? 'selected' : '';?> ><?php _e('Pending', 'ulp');?></option>
            <option value="draft" <?php echo $data['post_data']['post_status']=='draft' ? 'selected' : '';?> ><?php _e('Draft', 'ulp');?></option>
        </select>
    </div>
   </div>
 </div>
 <div class="ulp-instructor-edit-line-break"></div>
 <div class="ulp-instructor-edit-row">
  	<div class="ulp-inst-col-12">
    <div class="ulp-form-section">
        <h4><?php _e('Lesson Content', 'ulp');?></h4>
        <textarea name="post_content" id="post_content" class="ulp-form-control" style="width: 70%;height: 200px"><?php echo $data['post_data']['post_content'];?></textarea>
    </div>
   </div>
 </div>

 <div class="ulp-instructor-edit-line-break"></div>

 <div class="ulp-instructor-edit-row">
  	<div class="ulp-inst-col-12">
    <div class="ulp-form-section">
        <h3  class="ulp-instructor-edit-top-title"><?php _e('Feature image', 'ulp');?></h3>
          <?php if (!empty($data['featureImage'])):?>
          		<div id="js_ulp_upload_image_trigger" class="ulp-upload-feat-image-wrapp ulp-edit-image">
              <img src="<?php echo $data['featureImage'];?>" class="ulp-feat-img-old-pic"/>
              </div>
           <?php else:?>
            <div id="js_ulp_upload_image_trigger" class="ulp-upload-feat-image-wrapp ulp-add-image"></div>
		<?php endif;?>
        <input type="hidden" id="ulp_feat_image_input" name="ulp_feat_image_input" value="<?php echo $data['featureImage'];?>" />
    </div>
   </div>
 </div>


  <div class="ulp-instructor-edit-line-break"></div>
 <div class="ulp-instructor-edit-row">
  	<div class="ulp-inst-col-12">
    <div class="ulp-form-section">
    <?php if ($data['categories']):?>
				<div>
						<h4><?php _e('Categories', 'ulp');?></h4>
						<div>
								<?php foreach ($data['categories'] as $category):?>
										<?php $checked = in_array($category->term_id, $data['post_cats']) ? 'checked' : '';?>
										<div class="ulp-instructor-multiple-choice">
												<input type="checkbox" name="categories[]" value="<?php echo $category->term_id;?>" <?php echo $checked;?> /> <?php echo $category->name;?>
										</div>
								<?php endforeach;?>
						</div>
				</div>
		<?php endif;?>
    </div>
   </div>
 </div>
 <div class="ulp-instructor-edit-line-break"></div>
 <div class="ulp-instructor-edit-row">
  	<div class="ulp-inst-col-12">
    <div class="ulp-form-section">
    <?php include ULP_PATH . 'views/templates/instructor_dashboard/lesson_drip_content.php';?>
    </div>
   </div>
 </div>
 <div class="ulp-instructor-edit-line-break"></div>

 <div class="ulp-inst-col-12">
     <div class="ulp-form-section">
         <h4><?php _e( 'Enable', 'ulp' );?></h4>
         <?php $checked = ($data['video_lesson_settings']['ulp_lesson_is_video']) ? 'checked' : '';?>
         <input type="checkbox" class="ulp-switch" onClick="ulpCheckAndH(this, '#ulp_lesson_is_video');" <?php echo $checked;?> />
         <input type="hidden" name="ulp_lesson_is_video" value="<?php echo $data['video_lesson_settings']['ulp_lesson_is_video'];?>" id="ulp_lesson_is_video" />
     </div>
     <div class="ulp-form-section">
         <h4><?php _e( 'Video URL', 'ulp' );?></h4>
         <input type="text" name="ulp_lesson_video_target" value="<?php echo $data['video_lesson_settings']['ulp_lesson_video_target'];?>" />
     </div>
     <div class="ulp-form-section">
         <h4><?php _e( 'Autoplay', 'ulp' );?></h4>
         <?php $checked = ($data['video_lesson_settings']['ulp_lesson_video_autoplay']) ? 'checked' : '';?>
         <input type="checkbox" class="ulp-switch" onClick="ulpCheckAndH(this, '#ulp_lesson_video_autoplay');" <?php echo $checked;?> />
         <input type="hidden" name="ulp_lesson_video_autoplay" value="<?php echo $data['video_lesson_settings']['ulp_lesson_video_autoplay'];?>" id="ulp_lesson_video_autoplay" />
     </div>
     <div class="ulp-form-section">
         <h4><?php _e( 'Autocomplete lesson when video is ended', 'ulp' );?></h4>
         <?php $checked = ($data['video_lesson_settings']['ulp_lesson_video_autocomplete']) ? 'checked' : '';?>
         <input type="checkbox" class="ulp-switch" onClick="ulpCheckAndH(this, '#ulp_lesson_video_autocomplete');" <?php echo $checked;?> />
         <input type="hidden" name="ulp_lesson_video_autocomplete" value="<?php echo $data['video_lesson_settings']['ulp_lesson_video_autocomplete'];?>" id="ulp_lesson_video_autocomplete" />
     </div>
 </div>


 <div class="ulp-instructor-edit-line-break"></div>
 <div class="ulp-instructor-edit-row">
  	<div class="ulp-inst-col-12">
    <div class="ulp-form-section">
        <input type="submit" name="submit" value="<?php _e('Save Changes', 'ulp');?>" class="btn btn-primary pointer ulp-submit-button" />
    </div>
   </div>
 </div>
</form>
</div>
