<?php include_once('header.php'); 

if(!empty($_GET['course_id']))
$course_id = $_GET['course_id'];
elseif(!empty($_POST['course_id']))
$course_id = $_POST['course_id'];
else
$course_id = '';

$limit=9;
$latest_news=get_courses_display($course_id,'','',1,$limit);
$cart_ids=get_cart_details();
?>
<style>



	.product{
		background:#fff;
		width:260px;
		margin:15px;
		padding:20px;
		text-align:center;
		border-radius:15px;
		box-shadow:0 10px 25px rgba(0,0,0,0.1);
		transition:0.3s;
	}

	.product:hover{
		transform:translateY(-5px);
	}

	button{
		padding:10px 20px;
		background:#4f46e5;
		color:#fff;
		border:none;
		border-radius:25px;
		cursor:pointer;
	}

	/* Cart badge */
	.cart-box{
		position:fixed;
		top:20px;
		right:20px;
		background:#111;
		color:#fff;
		padding:10px 15px;
		border-radius:30px;
		font-weight:bold;
	}

	/* ===== CENTER POPUP ===== */
	#cartModal{
		position:fixed;
		top:0;
		left:0;
		width:100%;
		height:100%;
		background:rgba(0,0,0,0.5);
		z-index:9999;

		display:flex;
		align-items:center;
		justify-content:center;

		opacity:0;
		visibility:hidden;
		transition:0.3s ease;
	}

	.popup-box{
		background:#fff;
		padding:35px;
		border-radius:15px;
		text-align:center;
		width:300px;
		box-shadow:0 15px 40px rgba(0,0,0,0.2);

		transform:scale(0.7);
		transition:0.3s ease;
	}

	.checkmark{
		font-size:60px;
		color:#22c55e;
	}

	/* ACTIVE STATE */
	#cartModal.active{
		opacity:1;
		visibility:visible;
	}

	#cartModal.active .popup-box{
		transform:scale(1);
	}
	</style>
<!-- START SECTION TOP -->
	<section class="section-top">
		<div class="container">
			<div class="col-lg-10 offset-lg-1 text-center">
				<div class="section-top-title wow fadeInRight" data-wow-duration="2s" data-wow-delay="0.6s" data-wow-offset="0">
					<h1>Available Courses</h1>
					<ul>
						<li><a href="index.php">Home</a></li>
						<li> / Course</li>
					</ul>
				</div><!-- //.HERO-TEXT -->
			</div><!--- END COL -->
		</div><!--- END CONTAINER -->
	</section>	
	<!-- END SECTION TOP -->

	<!--START COURSE -->
	<div class="best-cpurse section-padding">
		<div class="container">			
			<div class="row">					
				<div class="col-lg-8">					
					<div class="row">
                    	<?php
					  for($i=0;$i<count($latest_news);$i++)
					  {
					  
						  $sela=executework("SELECT * FROM  lms_cart_list,lms_cart_course where lms_cart_course.cart_id=lms_cart_list.cart_id and lms_cart_list.purchage_course_id='".$latest_news[$i]['id']."' and lms_cart_course.user_type='Student'");
						$cnta=@mysqli_num_rows($sela);
						$rowa=@mysqli_fetch_array($sela); 
						if(in_array($latest_news[$i]['id'],$cart_ids))
						$add=1;
						else
						$add=0;
    			?>
                
                 <div class="col-lg-4 col-md-4 col-sm-6 mix sale wow fadeInDown" data-wow-duration="2s" data-wow-delay="0.<?php echo $i; ?>s" data-wow-offset="<?php echo $i; ?>">
							<div class="product-grid">
								<div class="product-image">
									
                                    <?php
									 if(!empty($latest_news[$i]['course_img'])){ ?>
                                        <img class="pic-1" src="../instructor/courses_upload/<?php echo $latest_news[$i]['course_img']; ?>" alt="">
                                        <img class="pic-2" src="../instructor/courses_upload/<?php echo $latest_news[$i]['course_img']; ?>" alt="">
                                    <?php } else{ ?>
                                         <img class="pic-1" src="assets/images/banner/course-bg-p2.png" alt="">
                                         <img class="pic-2" src="assets/images/banner/course-bg-p2.png" alt="">
                                    <?php } ?>
                                   
									<ul class="social">
										<li> 
                                            <a href="view_course.php?course_id=<?php echo $latest_news[$i]['id']; ?>" ><i class="ti-zoom-in"></i></a>
                                        </li>
										<li><a href="" data-tip="Add to Wishlist"><i class="ti-bag"></i></a></li>
										
                                        <li><a class="cart_main_add<?php echo $latest_news[$i]['id']; ?>" onclick="add_to_cart('<?php echo $latest_news[$i]['id']; ?>','<?php echo $_SESSION['login_id']; ?>','add')" data-tip="Add to Cart"><i class="ti-shopping-cart"></i></a></li>
                                        
                                        <li><a style="background-color:#2eca7f" class="cart_main_remove<?php echo $latest_news[$i]['id']; ?>" onclick="add_to_cart('<?php echo $latest_news[$i]['id']; ?>','<?php echo $_SESSION['login_id']; ?>','remove')" data-tip="Remove From Cart"><i class="ti-close text-light"></i></a></li>
                                        
                                        <?php /*?><li class="cart_main_add<?php echo $latest_news[$i]['id']; ?>"><a onclick="add_to_cart('<?php echo $latest_news[$i]['id']; ?>','<?php echo $_SESSION['login_id']; ?>','add')"><i class="ti-shopping-cart"></i></a></li><?php */?>
                                        
                                        <?php /*?><li class="cart_main_remove<?php echo $latest_news[$i]['id']; ?>"><a onclick="add_to_cart('<?php echo $latest_news[$i]['id']; ?>','<?php echo $_SESSION['login_id']; ?>','remove')"><i class="ti-shopping-cart"></i></a></li><?php */?>
                                        
                                        
									</ul>
									<span class="product-new-label"><?php $result = str_replace("_", " ", $latest_news[$i]['course_type']); echo mb_strtoupper($result); ?></span>
								</div>
								<ul class="rating">
									<li class="fa fa-star"></li>
									<li class="fa fa-star"></li>
									<li class="fa fa-star"></li>
									<li class="fa fa-star"></li>
									<li class="fa fa-star"></li>
								</ul>
								<div class="product-content">
									<h3 class="title"><a href="view_course.php?course_id=<?php echo $latest_news[$i]['id']; ?>">
									<?php 
                                        $text = $latest_news[$i]['course_title'];
										$text = trim($text);
										
										if (mb_strlen($text) > 26) {
											echo mb_substr($text, 0, 26) . '...';
										} else {
											echo $text;
										}
                                    ?></a></h3>
									<div class="price">$<?php echo $latest_news[$i]['course_price']/100*$latest_news[$i]['course_discount']; ?>
										<span>$<?php echo $latest_news[$i]['course_price']; ?></span>
									</div>
									<a class="add-to-cart" href="">+ Add To Cart</a>
								</div>
							</div>
						</div><!-- End Col -->	
                        <script>toggle_cart('<?php echo $latest_news[$i]['id']; ?>','<?php echo $add; ?>');</script>
                
               <?php } 
			    if(count($latest_news)==0)
				{
			   ?> 
              		 <div> <center> <strong style="color:red"> No Data Found </strong> </center> </div>
               <?php }  ?>				
					</div><!--END ROW -->				
				</div><!--END COL -->
				<div class="col-lg-4">	
					<div class="sidebar-post">
						<div class="blog_search">
							<input type="text" class="form-control" placeholder="Type & Press Enter">
						</div>				
					</div><!-- END SINGLE POST -->
					<div class="rs-slider">
						<h4>Price Filter</h4>
						<div class="range-slider">
							<input type="range" value="500" min="0" max="500" range="true">
							<span class="range-value">500</span>
						</div>				
					</div><!-- END SINGLE POST -->
					<div class="sidebar-post">
						<div class="sidebar_title"><h4>Follow us</h4></div>
						<div class="single_social">
							<ul>
								<li><div class="social_item b_facebook"><a href="#" title="facebook"><i class="fa fa-facebook"></i><span class="item-list">150K Likes</span></a></div></li>
								
								<li><div class="social_item b_twitter"><a href="#" title="twitter"><i class="fa fa-twitter"></i><span class="item-list">138K Followers</span></a></div></li>
								
								<li><div class="social_item b_youtube"><a href="#" title="youtube"><i class="fa fa-youtube"></i><span class="item-list">90K Subscribers</span></a></div></li>
								
								<li><div class="social_item b_pinterest"><a href="#" title="pinterest"><i class="fa fa-pinterest"></i><span class="item-list">350K Followers</span></a></div></li>
								
								<li><div class="social_item b_tumblr"><a href="#" title="rss"><i class="fa fa-tumblr"></i><span class="item-list">901 Followers</span></a></div></li>
								
								<li><div class="social_item b_rss"><a href="#" title="rss"><i class="fa fa-rss"></i><span class="item-list">411 Followers</span></a></div></li>
							</ul>
						</div><!-- END SOCIAL MEDIA POST -->
					</div><!-- END SIDEBAR POST -->							
					<div class="sidebar-post">
						<div class="sidebar_title"><h4>CATEGORIES</h4></div>
						<div class="single_category">
							<ul>
                            <?php 
								$cat=get_course_master('');
								 for($i=0;$i<count($cat);$i++)
					  			 {
							?>
								<li> <a href="#" style="text-decoration:none"> <i class="fa fa-arrow-right text-danger"></i> &nbsp;<?php echo $cat[$i]['title']; ?></a></li>
                             <?php } ?>
							</ul>
						</div><!-- END SOCIAL MEDIA POST -->
					</div><!-- END SIDEBAR POST -->						
								
					<div class="sidebar-post">
						<div class="sidebar_title"><h4>Skill Level</h4></div>
						<div class="single_langu">
							<i class="fa fa-arrow-right text-danger"></i>
							<span>All Levels</a></span>
						</div><!-- END SINGLE LANGU -->
						<div class="single_langu">
							<i class="fa fa-arrow-right text-danger"></i>
							<span>Beginner Levels</span>
						</div><!-- END SINGLE LANGU -->
						<div class="single_langu">
							<i class="fa fa-arrow-right text-danger"></i>
							<span>Intermediate Level</span>
						</div><!-- END SINGLE LANGU -->
						<div class="single_langu">
							<i class="fa fa-arrow-right text-danger"></i>
							<span>Expert Level</span>
						</div><!-- END SINGLE LANGU -->
					</div><!-- END SIDEBAR POST -->				
									
				</div><!--END COL -->				
			</div><!--END ROW -->		
		</div><!--END CONTAINER -->
	</div>
	<!--END COURSE -->	
    
  <div id="cartModal">
	<div class="popup-box">
		<div class="checkmark mb-4">✔</div>
		<h3>Cart Updated Successfully</h3>
	</div>
</div> 


<?php include_once('footer.php'); ?>
