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

if(!empty($_GET['sid']))
$upd=add_to_cart($_GET['sid'],$_GET['child_id'],$_GET['action']);

if(!empty($_GET['sid']))
$upd=checkout_status($_GET['sid']);

$seltotal=executework("select * from lms_cart_course where user_id='".$_SESSION['login_id']."' and order_status NOT IN('completed','cancelled')");
$cnttotal=@mysqli_num_rows($seltotal);
$rowtotal=@mysqli_fetch_array($seltotal);
?>

	<!-- 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="1s" data-wow-delay="0.3s" data-wow-offset="0">
					<h1>Cart</h1>
					<ul>
						<li><a href="dashboard.php">Dashboard</a></li>
						<li> / Cart </li>
					</ul>
				</div><!-- //.HERO-TEXT -->
			</div><!--- END COL -->
		</div><!--- END CONTAINER -->
	</section>	
	<!-- END SECTION TOP -->
    
    
	
		<!-- Shopping Cart -->
	<div class="shopping-cart section">
		<div class="container">
     
			<div class="row">
				<div class="col-12">
					<!-- Shopping Summery -->
					<table class="table shopping-summery">
						<thead>
							<tr class="main-hading">
								<th>PRODUCT</th>
								<th>NAME</th>
								<th>Original PRICE</th>
								<th>Discount</th>
								<th class="text-center">TOTAL</th> 
								<th class="text-center"><i class="ti-trash remove-icon"></i></th>
							</tr>
						</thead>
						<tbody>
                        <?php 
						$original_total=0;
						$dis_total=0;
						$ttota=0;
						$sql=executework("select *,(lms_cart_list.id) AS main_id from lms_cart_list,lms_instructor_courses,lms_cart_course where lms_instructor_courses.id=lms_cart_list.purchage_course_id and lms_cart_course.cart_id=lms_cart_list.cart_id and lms_cart_course.user_type='Student' and lms_cart_list.parent_id='".$_SESSION['login_id']."' and lms_cart_course.order_status NOT IN('completed','cancelled')");
							$cat_total_cnt=@mysqli_num_rows($sql);
							if(mysqli_num_rows($sql)>0)
							{
								$sno=1;
								while($row=mysqli_fetch_assoc($sql))
								{
						?>
							<tr>
								<td class="image" data-title="No">
                                	<?php if(!empty($row['course_img'])){ ?>
                                        <img src="../instructor/courses_upload/<?php echo $row['course_img']; ?>" alt="">
                                    <?php } else{ ?>
                                         <img src="assets/images/banner/course-bg-p2.png" alt="">
                                    <?php } ?>
                                </td>
								<td class="product-des" data-title="Description">
									<p class="product-name"><a>
									<?php 
                                        $text = $row['course_title'];
                                        $words = explode(" ", $text);
                            
                                        echo $words[0];
                                        if (isset($words[1])) {
                                            echo " " . $words[1];
                                        }
                                    ?></a></p>
									<p class="product-des"><?php echo $row['course_type']; ?></p>
								</td>
								<td class="price" data-title="Price"><span>$<?php $original_total+=$row['course_price']; echo $row['course_price']; ?> </span></td>
								<td class="price" data-title="Price"><span>$<?php echo $row['course_discount']; ?> </span></td>
                                
								<td class="total-amount" data-title="Total"><span>
                                	$<?php $total=$row['course_price']/100*$row['course_discount'];  
										$dis_total+=$total;
										$final_amount=$row['course_price']-$total;
										$ttota+=$final_amount;
									echo $final_amount; ?></span></td>
								<td class="action" data-title="Remove"><a href="#"><i class="ti-trash remove-icon" onClick="purchage_status('<?php echo $row['purchage_course_id']; ?>','<?php echo $_SESSION['login_id']; ?>','cart.php','remove');" ></i></a></td>
							</tr>
							<?php } }if($cat_total_cnt==0){  ?>
                            <tr>
                            	<td colspan="6"> <center class="text-danger">  <strong> No Courses/Items Added To Your Cart </strong> </center></td>
                            </tr>
                            <?php }  ?>
						</tbody>
					</table>
					<!--/ End Shopping Summery -->
				</div>
			</div>
            <?php if($original_total!=0){ ?>
			<div class="row">
				<div class="col-12">
					<!-- Total Amount -->
					<div class="total-amount">
						<div class="row">
							<div class="col-lg-8 col-md-5 col-12">
								<div class="left" style="display:none">
									<div class="coupon">
										<form action="#" target="_blank">
											<input name="Coupon" placeholder="Enter Your Coupon">
											<button class="btn">Apply</button>
										</form>
									</div>
									<div class="checkbox">
										<label class="checkbox-inline" for="2"><input name="news" id="2" type="checkbox"> Shipping (+10$)</label>
									</div>
								</div>
							</div>
							<div class="col-lg-4 col-md-7 col-12">
								<div class="right">
									<ul>
										<li>Cart Subtotal<span>$<?php echo $original_total; ?></span></li>
										<li>Shipping<span>Free</span></li>
										<li>You Save<span>$<?php echo $dis_total; ?></span></li>
										<li class="last">You Pay<span>$<?php echo $ttota; ?></span></li>
									</ul>
									<div class="button5">
										<a href="#" class="btn" onClick="validate_status('<?php echo $rowtotal['id']; ?>','','cart.php');">Checkout</a>
										<a href="course.php" class="btn">Continue shopping</a>
									</div>
								</div>
							</div>
						</div>
					</div>
					<!--/ End Total Amount -->
				</div>
			</div>
            <?php } ?>
		</div>
	</div>
	<!--/ End Shopping Cart -->
			
	<!-- Start Shop Services Area  -->
	<section class="shop-services section" style="margin-bottom:60px;">
		<div class="container">
			<div class="row">
				<div class="col-lg-3 col-md-6 col-12">
					<!-- Start Single Service -->
					<div class="single-service">
						<i class="ti-rocket"></i>
						<h4>Free shiping</h4>
						<p>Orders over $100</p>
					</div>
					<!-- End Single Service -->
				</div>
				<div class="col-lg-3 col-md-6 col-12">
					<!-- Start Single Service -->
					<div class="single-service">
						<i class="ti-reload"></i>
						<h4>Free Return</h4>
						<p>Within 30 days returns</p>
					</div>
					<!-- End Single Service -->
				</div>
				<div class="col-lg-3 col-md-6 col-12">
					<!-- Start Single Service -->
					<div class="single-service">
						<i class="ti-lock"></i>
						<h4>Sucure Payment</h4>
						<p>100% secure payment</p>
					</div>
					<!-- End Single Service -->
				</div>
				<div class="col-lg-3 col-md-6 col-12">
					<!-- Start Single Service -->
					<div class="single-service">
						<i class="ti-tag"></i>
						<h4>Best Peice</h4>
						<p>Guaranteed price</p>
					</div>
					<!-- End Single Service -->
				</div>
			</div>
		</div>
	</section>
	<!-- End Shop Newsletter -->
											
<?php include('footer.php'); ?>