<?php
wp_register_script('ulp_courses_modules', ULP_URL . 'assets/js/courses_modules.js', array(), null);
wp_localize_script('ulp_courses_modules', 'ulp_url', get_site_url());
wp_localize_script('ulp_courses_modules', 'ulp_plugin_url', ULP_URL);
wp_enqueue_script('ulp_courses_modules');
wp_enqueue_script('ulp_ui_multiselect_js', ULP_URL . 'assets/js/ui.multiselect.js', array(), null);
wp_enqueue_style('ulp_course_modules', ULP_URL . 'assets/css/course_modules.css', array(), null);
wp_enqueue_script('ulp_ckeditor', ULP_URL . 'assets/js/ckeditor/ckeditor.js', [], false, false);

///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>
.ulp-move-module-box:hover{
		cursor: move;
}

#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-course">
<h2><?php _e('Add/Edit Course', '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('Course Title', 'ulp');?></h4>
        <input type="text" name="post_title" class="ulp-form-control"  value="<?php echo $data['post_data']['post_title'];?>" />
				<?php if ($data['post_id']):?>
						<div><?php echo __('Post ID: ', 'ulp') . $data['post_id'];?></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-6">
    <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('Course Description', 'ulp');?></h4>
        <textarea name="post_content" class="ulp-js-summernote ulp-form-control" id="post_content" ><?php echo $data['post_data']['post_content'];?></textarea>
    </div>
 </div>
</div>
<div class="ulp-instructor-edit-line-break"></div>

<?php if ($data['tags']):?>
<div class="ulp-instructor-edit-row">
  <div class="ulp-inst-col-12">
    <div class="ulp-form-section">
		<h4><?php _e('Course Tags', 'ulp');?></h4>
						<div class="ulp-instructor-tags-wrapper">
								<?php foreach ($data['tags'] as $tag):?>
										<?php $checked = in_array($tag->term_id, $data['post_tags']) ? 'checked' : '';?>
										<div class="ulp-instructor-multiple-choice ulp-instructor-tags">
												<input type="checkbox" name="tags[]" value="<?php echo $tag->term_id;?>" <?php echo $checked;?> /> <?php echo $tag->name;?>
										</div>
								<?php endforeach;?>
						</div>
    </div>
 </div>
</div>
<div class="ulp-instructor-edit-line-break"></div>
<?php endif;?>

<?php if ($data['categories']):?>
<div class="ulp-instructor-edit-row">
  <div class="ulp-inst-col-12">
    <div class="ulp-form-section">
						<h4><?php _e('Categories', 'ulp');?></h4>
						<div class="ulp-instructor-categories-wrapper">
								<?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>
 </div>
</div>
<div class="ulp-instructor-edit-line-break"></div>
<?php endif;?>

<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 id="modulesMetaBox">
	<div class="ulp-instructor-edit-row">
	  <div class="ulp-inst-col-12">
	  <h3  class="ulp-instructor-edit-top-title"><?php _e('Course Curriculum', 'ulp');?></h3>
	    <div class="ulp-instructor-modules">
	        		<div class="" id="ulp_course_modules" data-post_id="<?php echo $data['post_id'];?>"></div>
	        		<button type="button" class="ulp-add-module-button" id="ulp_add_module_button" ><i title="<?php _e('Add Module', 'ulp');?>" class="fa-ulp fa-add_module-ulp"></i></button>
			</div>
	 </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">
        <input type="submit" name="submit" value="<?php _e('Save Changes', 'ulp');?>" class="btn btn-primary pointer ulp-submit-button" />
    </div>
 </div>
</div>
</form>
</div>
