<?php
	// dump ($courses,"course");
	$document = JFactory::getDocument();
	$document->addStyleSheet('/modules/mod_moojlacourseslider/assets/uikit/css/uikit.min.css');
	$document->addStyleSheet('/modules/mod_moojlacourseslider/assets/css/gridview_filter.css');
	$displayfilter=$params->get('displayfilter');
	$display_grid_view=$params->get('display_grid_view');
	$display_title_filter=$params->get('display_title_filter');
	$category_name=$params->get('category_name');
	$teacher_name=$params->get('teacher_name');


    $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_grid_view_filter" uk-filter="target: .js-filter">

<div class="lmskaran_toolbar_card">
      <?php
         $categories = [];
         $categories_id = [];
         foreach($courses as $course){
         	$cat = str_replace(' ', '_', $course->cat_name);
         	$categories[$cat] = $course->cat_name; 
         	$categories_id[$course->cat_id] = $cat; 
         }
         
         $categories = array_unique($categories);

         $exeption_ids = $display_title_filter;
         $exeption_ids = explode(',', $exeption_ids);
         foreach($exeption_ids as $ex) {
           unset($categories[@$categories_id[$ex]]);
         }
         ?>
<?php if($displayfilter == 1):?>
   <ul class="uk-subnav uk-subnav-pill">
      <li uk-filter-control="[data-tags*='all']" class="uk-active"><a class="reHeight" href="#">همه</a></li>
      
		<?php foreach($categories as $catindex => $category):?>
		  <?php if($category == null):?>
		  
		  <?php else: ?>
			<li uk-filter-control="[data-tags*='<?php echo $catindex; ?>']">
			  <a href="#">
				<?php echo $category; ?>
			  </a>
			</li>
		  <?php endif; ?>
		<?php endforeach; ?>
   </ul>
   <?php endif; ?>
   
   <?php if($display_grid_view == 3) :?>
   <div id="btnContainer">
      <button id="listView" class="lmskaran_button_grid_view active_button_gridView" ><i style="margin-left:5px" class="fa fa-bars"></i> نمای لیست</button> 
      <button id="gridView" class="lmskaran_button_grid_view" ><i style="margin-left:5px" class="fa fa-th-large"></i>نمای شبکه</button>
   </div>
   <?php endif; ?>
   
</div>

<div id="soton">
<div class="lmskaran_course_pack owl-carousel-joomdlecourses-m<?php echo $module->id; ?> owl-theme joomdlecourses<?php echo $moduleclass_sfx; ?> ">
   <ul id="lmskaran_pack_card" class="js-filter uk-child-width-1-2 uk-child-width-1-3@m uk-text-center" uk-grid>
   <?php foreach($courses as $course): ?>
      <li class="lmskaran_item_card" data-tags="all <?php echo str_replace(' ', '_', $course->cat_name); ?>">
         <div class="lmskaran_uk_card uk-card uk-card-default uk-card-body">
            <div class="lmskaran_front">
               <a class="lmskaran_image_course" href="<?php echo JRoute::_('index.php?option=com_moojla&view=coursedetail&id='.$course->remoteid); ?>" >
								<?php if(!$course->summary_files):?>
									<img src="https://www.w3schools.com/w3css/img_lights.jpg">
								<?php else:?>
									<img src="<?php echo $course->summary_files; ?>">
								<?php endif;?>
               </a>
               <div style="<?php echo $text_color; ?>" class="lmskaran_content">
                  <div class="lmskaran_pack_title">
					<div class="lmskaran_lay-gridViewFilter_head-content-box">
						 <h3 class="lmskaran_course_title">
							<a style="width:100%;<?php echo $text_color; ?>" href="<?php echo JRoute::_('index.php?option=com_moojla&view=coursedetail&id='.$course->remoteid); ?>" ><?php echo $course->fullname; ?></a>
						 </h3>
						 
						<div class="button_cost_pack">
							<?php if($course->cost == 0):?>
							<div class="button_cost">
								<a style="<?php echo $price_color;?>" class="button_cost_link" href="<?php echo JRoute::_('index.php?option=com_moojla&view=coursedetail&id='.$course->remoteid); ?>">رایگان</a>
							</div>
							<?php else: ?>
							<div class="button_cost" style="width: 80px;text-align:center;">
								<a style="<?php echo $price_color;?>" class="button_cost_link" href="<?php echo JRoute::_('index.php?option=com_moojla&view=coursedetail&id='.$course->remoteid); ?>">
							<?php echo $course->cost; ?></a>
							</div>
							<?php endif; ?>

						 </div>
					</div>
					 <?php if(!$course->summary):?>
						<div class="lmskaran_lay-gridViewFilter_summary-course"><p style="color: #bcbcbd;">این درس بدون توضیحات میباشد !</p></div>
					 <?php else:?>
						<div class="lmskaran_lay-gridViewFilter_summary-course"><?php echo ModMoojlaCourseSliderHelper::escape($params,$course->summary); ?></div>
					 <?php endif; ?>
                  </div>
                  <div class="lmskaran_information_course">

                     <div class="lmskaran_teacher_category">

                        <div class="lmskaran_cat_taech_name_pack">
                        <span><?php echo $teacher_name; ?></span>
                        <p class="lmskaran_teacher_name">
						

						 <?php if($course->teachers == null):?>
						 <span style="color:red;">این درس استاد ندارد !</span>
						 <?php else:?>
						 <?php 
						 $fullname = $course->teachers[0]->name;
						 echo $fullname; ?>
						 <?php endif;?>
                        </p>
                         </div>

                         <div class="lmskaran_cat_taech_name_pack">
                         <span><?php echo $category_name; ?></span>
                        <p class="lmskaran_category_name">
						 <?php if($course->cat_name == null):?>
						 <span style="color:red;">طبقه درسی ندارد !</span>
						 <?php else:?>
						 <?php echo $course->cat_name; ?>
						 <?php endif;?>
                        </p>
                         </div>
                     </div>
                  </div>
               </div>
            </div>
      </li>
	<?php endforeach; ?>
   </ul>
   </div>
   </div>
</div>





<script src="/modules/mod_moojlacourseslider/assets/js/gridview_filter.js"></script>
<script src="/modules/mod_moojlacourseslider/assets/uikit/js/uikit.min.js"></script>

