<?php //dump($courses,"course");
$document = JFactory::getDocument();
$document->addStyleSheet('/modules/mod_moojlacourseslider/assets/css/static.css');
$document->addScript('/modules/mod_moojlacourseslider/assets/js/static.js');
$course_details_button = $params->get('course_details_button');

JFactory::getDocument()->addScriptOptions('width_static', $params->get('width_static', 360));


    $price_color = [
        'color :' . $params->get('price_color')   
    ];
    $price_color = implode(';', $price_color);


    $text_color = [
        'color :' . $params->get('text_color')   
    ];
    $text_color = implode(';', $text_color);
?>


<div class="lmskaran_static_flexible">
	<?php foreach ($courses as $course) : ?>
		<div class="lmskaran_static_card">
			<div class="lmskaran_static_card_blog">

				<!-- card image -->
				<div class="lmskaran_static_card_image">
					<div class="lmskaran_static_rotating_card">
						<div class="lmskaran_static_cord_rotate">
							<?php if (!$course->summary_files) : ?>
								<a href="<?php echo JRoute::_('index.php?option=com_moojla&view=coursedetail&id=' . $course->remoteid); ?>"><img src="https://www.w3schools.com/w3css/img_lights.jpg" alt="" class="lmskaran_static_card_front_background"></img></a>
							<?php else : ?>
								<a href="<?php echo JRoute::_('index.php?option=com_moojla&view=coursedetail&id=' . $course->remoteid); ?>"><img src="<?php echo $course->summary_files; ?>" alt="" class="lmskaran_static_card_front_background"></img></a>
							<?php endif; ?>
						</div>
					</div>
				</div>
				<div class="lmskaran_lay-static-favorite">
				<?php echo JLayoutHelper::render('favorite', ['course'=>$course, 'favorite'=>$favorite, 'params'=>$params],JPATH_SITE.'/components/com_moojla/layouts'); ?>
				</div>

				<!-- card content -->
				<div class="lmskaran_static_card_content">
					<div class="lmskaran_static_card_category">
						نام دوره : &nbsp
						<a href="<?php echo JRoute::_('index.php?option=com_moojla&view=coursedetail&id=' . $course->remoteid); ?>">
							<h2>
								<span style="<?php echo $text_color;?>"><?php echo $course->shortname; ?></span>
								<span></span>
							</h2>
						</a>
					</div>


          
					<div class="lmskaran_static_card_button_group">
						<a id=<?php echo $module->id . '-' . $course->id; ?> href="<?php echo JRoute::_('index.php?option=com_moojla&view=coursedetail&id=' . $course->remoteid); ?>" class="lmskaran_static_button_course_violet">
							<i class="fa fa-info-circle"></i>
							<span><?php echo $course_details_button; ?></span>
						</a>

						<?php JLoader::register('MoojlaHelper', JPATH_ADMINISTRATOR . '/components/com_moojla/helpers/moojla.php');
						echo MoojlaHelper::newActionButton($course, $course->is_enrolled, $module); ?>


					</div>
					
				  <?php if($course_selector_type == 2):?>
					<div class="lmskaran_progress_name">درصد پیشرفت</div>
					<div class="lmskaran_progress_in_card">
						<div class="progress lmskaran_progress">
							<div class="progress-bar lmskaran_navar_progress_bar" role="progressbar" aria-valuenow="70"
								aria-valuemin="0" aria-valuemax="100" style="width:<?php echo round($course->percentage) != -1? round($course->percentage) : 100; ?>%;">
								<?php //dump($course->percentage); ?>
							</div>
						</div>
						<div class="lmskaran_amount_progress_bar"><?php echo round($course->percentage) != -1? round($course->percentage).'%' : '<div class="lmskaran_progress_no_criteria">بدون معیار</div>'; ?></div>
					</div>
				  <?php endif;?>


					<div class="lmskaran_static_card_description">
						<h5 style="<?php echo $price_color; ?>" class="lmskaran_static_cost_corse">
							<?php if ($course->cost > 0) : ?>
								<span class="lmskaran_static_txt_cost">قیمت : </span>
								<?php echo $course->cost; ?>
								<span class="lmskaran_static_toman"></span>
							<?php else : ?>
								<?php echo 'رایگان'; ?>
							<?php endif; ?>
						</h5>
					</div>

					<div class="lmskaran_static_card_footer">
						<div class="lmskaran_static_author">
							<i class="fas fa-chalkboard-teacher"></i>
							<?php if (count($course->teachers) == 0) : ?>
								<span style="color:red;">بدون استاد</span>
							<?php else : ?>
								<a href="<?php echo JRoute::_('index.php?option=com_moojla&view=teacherdetail&id=' . $course->teachers[0]->mid); ?>"><?php echo $course->teachers[0]->name; ?></a>
							<?php endif; ?>
						</div>
						<div class="lmskaran_static_stats">
							<i class="fas fa-list-alt"></i>
							<?php echo $course->cat_name; ?>
						</div>
					</div>
				</div>

			</div>
		</div>
	<?php endforeach; ?>
</div>