<?php
/**
 * Template Course
 */
get_header();
global $post;
$course = new UlpCourse($post->ID);
$ModuleItems = new UlpModuleItems($post->ID);
?>
<div class="page-content ulp-course-wrapp">
	<?php do_action('ulp_before_single_course');?>
		<h1><?php the_title();?></h1>
        <div class="ulp-top-section">
        <?php if( $course->IsFeatured()): ?>
            <span class="ulp-sale"><span class="ulp-text-sale"><?_e('NEW', 'ulp');?></span></span>
        <?php endif;?>
		<?php if ($course->FeatureImage()):?>
				<div class="ulp-feat-img-wrapp">
                	<div class="ultp-feat-img-single-course" style="min-width:<?php echo Ulp_Global_Settings::get('ulp_singlecourse_imagesize_width');?>px; height:<?php echo Ulp_Global_Settings::get('ulp_singlecourse_imagesize_height');?>px; background-image:url('<?php echo $course->FeatureImage();?>');">
                    </div>
				</div>
		<?php endif;?>
        </div>
		<div class="ulp-main-section">
			<div class="ulp-left-content">
              <ul class="ulp-top-details">
                  <li>
                    
                      <label><?php echo __('Instructor ', 'ulp'); ?></label>
                      <strong>Arizona DUI Services</strong>
                  </li>
                  <!--<li>
                      <label><?php echo __('Students ', 'ulp'); ?></label>
                      <strong><?php  echo $course->TotalStudents() . '/'.$course->MaxEnrolledStudents().' '. __('Students ', 'ulp');?></strong>
                  </li>-->
                  <li>
                      <label><?php echo __('Category ', 'ulp'); ?></label>
                      <strong><?php  echo  $course->Categories(TRUE);?></strong>
                  </li>
                  <li>
                      <label><?php echo $course->TotalModules() .__(' Modules ', 'ulp') ;?></label>
                      <strong><?php echo $course->TotalLessons(). __(' Lessons ', 'ulp') . '/'. $course->TotalQuizes() . __(' Quizzes ', 'ulp');?></strong>
                  </li>
                                    <li>
                      <label>Class Access</label>
                      <strong>Registered Users Only</strong>
                  </li>
                  <div class="ulp-clear"></div>
              </ul>
			  <div class="ulp-short-description"><?php  echo $course->Excerpt();?></div>

			  <?php while (have_posts()):?>
                  <?php the_post();?>
                  <?php the_content();?>
              <?php endwhile;?>
    		</div>
            <div class="ulp-right-sidebar">
            	<div class="price-box"><?php echo $course->Price();?></div>
            	<div class="ulp-course-enroll-section">
									<?php echo do_shortcode("[ulp-enroll-course id={$post->ID}]");?>
							</div>
                <div class="ulp-wishlist-wrapper">
  					 <?php echo do_shortcode("[ulp_watch_list_bttn course_id={$post->ID} show='button']");?>
                </div>
                <div class="sub-content-details">
                	<h3><?php _e('Additional Details', 'ulp');?></h3>
                    <ul class="ulp-right-details">
					  <?php if($course->Difficulty() != ''): ?>
                      <li>
                      <label><?php echo __('Difficulty ', 'ulp'); ?></label>
                      <strong><?php  echo  $course->Difficulty();?></strong>
                      </li>
                      <?php endif; ?>
                        <?php if($course->CourseTimePeriod() != ''): ?>
                      <li>
                      <label><?php echo __('Estimated Time ', 'ulp'); ?></label>
                      <strong><?php  echo  $course->CourseTimePeriod();?></strong>
                      </li>
                      <?php endif; ?>

                      <?php if($course->RewardPoints()): ?>
                      <!--<li>
                      <label><?php echo __('Reward Points', 'ulp'); ?></label>
                      <strong><?php  echo  $course->RewardPoints(). __(' points', 'ulp');?></strong>
                      </li>-->
                      <?php endif; ?>
                      <li>
                      <label><?php echo __('Release Time', 'ulp'); ?></label>
                      <strong><?php  echo   $course->CreateDate(TRUE);?></strong>
                      </li>
                    </ul>

                </div>
            </div>
		</div>
	<!-- LIST OF MODULES -->
	<?php if ($ModuleItems->has_modules()):?>
    	<div class="ulp-public-the-modules-wrapper">
        	<div class="ulp-h3-title"><?php _e('Course Curriculum', 'ulp');?></div>
		<?php while ($ModuleItems->have_modules()):?>
			<div class="ulp-public-the-module">
					<?php if ($ModuleItems->has_children()):?>
                    	<div class="ulp-public-the-module-title">
               				<h3><?php echo $ModuleItems->Name();?></h3>
                			<span class="ulp-module-details"> <span><?php echo $ModuleItems->countLessons();?></span><?php _e(' Lessons', 'ulp');?> / <span><?php echo $ModuleItems->countQuizes();?></span><?php _e(' Quizes', 'ulp');?></span>
               			</div>
                        <div class="ulp-public-the-module-content">
						<?php while ($ModuleItems->have_children()):?>
							<div  class="ulp-public-the-module-content-element">
								<?php if ($ModuleItems->ChildType()=='ulp_lesson'):?>
									<!-- LESSON -->
									<!-- Title + Permalink -->
									<?php $lesson = new UlpLesson($ModuleItems->ChildId(), true, $post->ID);?>
                                   <?php if ($course->IsEntrolled()):?>
									<?php if (!$course->can_access_any_item() && !$lesson->is_completed() && $ModuleItems->ChildId()!=$ModuleItems->FirstChildId()):?>
											<span title="<?php echo __(' (Not available yet)', 'ulp');?>"><i class="fa-ulp fa-curr_lesson"></i> <?php echo $quiz->Title();?></span>
									<?php else:?>
											<a href="<?php echo $lesson->Permalink();?>"><i class="fa-ulp fa-curr_lesson"></i><?php echo $lesson->Title();?></a>
									<?php endif;?>
									<!-- /Title + Permalink -->
									<?php if ($lesson->is_completed()):?>
                                            <span class="ulp-lesson-status-completed">
													<i class="fa-ulp fa-curr_lesson_completed"></i>
                                            </span>
									<?php endif;?>
                                  <?php else:?>
											<!-- NON ENROLLED USERS -->
											<?php if ($lesson->hasPreview()):?>
													<a href="<?php echo $lesson->Permalink();?>">
														<?php if ( $lesson->isVideo() ):?>
			                         <i class="fa-ulp fa-video-ulp"></i>
			                      <?php else :?>
			                      <i class="fa-ulp fa-curr_lesson"></i>
			                      <?php endif;?>
														<?php echo $lesson->Title();?></a><span class="ulp-lesson-preview"><?php echo __(' Preview', 'ulp');?></span>
											<?php else:?>
													<span title="<?php echo __(' (Not available yet)', 'ulp');?>">
														<?php if ( $lesson->isVideo() ):?>
			                         <i class="fa-ulp fa-video-ulp"></i>
			                      <?php else :?>
			                      <i class="fa-ulp fa-curr_lesson"></i>
			                      <?php endif;?>
														<?php echo $lesson->Title(); ?></span>
											<?php endif;?>
									<?php endif;?>
                                    <span class="ulp-public-the-module-content-element-rightside">
                                 <?php if($lesson->RewardPoints()): ?>
                               	 	<span class="ulp-module-content-points"><?php echo $lesson->RewardPoints(). ' '.__('points','ulp');?></span>
                                <?php endif; ?>
                                <?php if($lesson->Duration()): ?>
                                	<span class="ulp-module-content-time"><?php echo $lesson->Duration().$lesson->DurationType();?></span>
                                <?php endif; ?>
                                </span>
								<div class="ulp-clear"></div>
									<!-- / LESSON -->
								<?php else:?>
									<!--QUIZ-->
									<?php $quiz = new UlpQuiz($ModuleItems->ChildId(), true, $post->ID);?>
                                    <?php if ($course->IsEntrolled()):?>
									<!-- Title + Permalink -->
									<?php if (!$course->can_access_any_item() && !$quiz->has_grade() && $ModuleItems->ChildId()!=$ModuleItems->FirstChildId()):?>
											<span title="<?php echo __(' (Not available yet)', 'ulp');?>"><i class="fa-ulp fa-curr_quiz"></i><?php echo $quiz->Title();?></span>
									<?php else:?>
											<a href="<?php echo $quiz->Permalink();?>"><i class="fa-ulp fa-curr_quiz"></i><?php echo $quiz->Title();?></a>
									<?php endif;?>
									<!-- /Title + Permalink -->
                                    <?php else:?>
											<span title="<?php echo __(' (Not available yet)', 'ulp');?>"><i class="fa-ulp fa-curr_quiz"></i><?php echo $quiz->Title();?></span>
									<?php endif;?>
										<?php if ($quiz->has_grade()):?>
												<?php if ($quiz->is_passed()):?>
													<span class="ulp-quiz-status-passed"><?php _e("Passed ", 'ulp'); echo '(' . $quiz->Grade() . ')';?></span>
												<?php else:?>
													<span class="ulp-quiz-status-failed"><?php _e("Failed ", 'ulp'); echo '(' . $quiz->Grade() . ')';?></span>
												<?php endif;?>
										<?php endif;?>

                                        <span class="ulp-public-the-module-content-element-rightside">
										   <?php if($quiz->RewardPoints()): ?>
                                              <span class="ulp-module-content-points"><?php echo $quiz->RewardPoints(). ' '.__('points','ulp');?></span>
                                          <?php endif; ?>
                                          <?php if($quiz->Duration()): ?>
                                              <span class="ulp-module-content-time"><?php echo $quiz->Duration().'m';?></span>
                                          <?php endif; ?>
                                          </span>
                                          <div class="ulp-clear"></div>
										<!--/QUIZ-->
								<?php endif;?>
							</div>
						<?php endwhile;?>
                      </div>
					<?php endif;?>
			</div>
		<?php endwhile;?>
	<?php if ($ModuleItems->hasPagination()):?>
			<?php echo $ModuleItems->Pagination();?>
	<?php endif;?>
      </div>
	<?php endif;?>
	<!-- LIST OF MODULES -->

	<div class="ulp-course ulp-course-the-rating-wrapp">
		<div class="<?php echo 'ulp-rating-' . $course->Rating();?>"></div>
	</div>
	<div>
			<?php //echo $course->Difficulty();?>
	</div>
	<div>
			<?php //echo $course->CourseTimePeriod();?>
	</div>
	<?php echo do_shortcode("[ulp_students_also_bought course_id='{$post->ID}']");?>
	<?php echo do_shortcode("[ulp_about_the_instructor instructor_id='{$course->AuthorID()}']");?>
	<?php echo do_shortcode("[ulp_reviews_awesome_box course_id={$post->ID}]");?>
	<?php echo do_shortcode("[ulp_list_reviews course_id={$post->ID}]");?>
	<?php echo do_shortcode("[ulp-course-list-tags course_id={$post->ID}]");?>
	<?php echo do_shortcode("[ulp-more-courses-by course_id={$post->ID} limit=3]");?>


	<?php do_action('ulp_after_single_course', '', true);?>

</div>
<?php //do_action('ulp_sidebars', $post->ID);?>
<?php get_footer();?>
