<?php
if(isset($_GET['id']) && $_GET['id'] > 0){
    $qry = $conn->query("SELECT * from `class_list` where id = '{$_GET['id']}' and delete_flag = 0 ");
    if($qry->num_rows > 0){
        foreach($qry->fetch_assoc() as $k => $v){
            $$k=$v;
        }
    }else{
		echo '<script>alert("class ID is not valid."); location.replace("./?page=classes")</script>';
	}
}else{
	echo '<script>alert("class ID is Required."); location.replace("./?page=classes")</script>';
}
?>
<style>
	#class-img{
		max-width:100%;
		max-height:35em;
		object-fit:scale-down;
		object-position:center center;
	}
</style>
<section class="py-3">
	<div class="container">
		<div class="content py-5 px-3 bg-gradient-primary">
			<h2 class="text-center"><b>Class Details</b></h2>
		</div>
		<div class="row mt-lg-n4 mt-md-n4 justify-content-center">
			<div class="col-lg-10 col-md-10 col-sm-12 col-xs-12">
				<div class="card rounded-0">
					<div class="card-body">
						<div class="container-fluid">
							<center>
								<img src="<?= validate_image(isset($image_path) ? $image_path : '') ?>" alt="<?= isset($name) ? $name : '' ?>" class="img-thumbnail p-0 border" id="class-img">
							</center>
							<dl>
								<dt class="text-muted">Name</dt>
								<dd class="pl-4"><?= isset($name) ? $name : "" ?></dd>
								<dt class="text-muted">Description</dt>
								<dd class="pl-4"><?= isset($description) ? str_replace(["\n\r", "\n", "\r"],"<br>", htmlspecialchars_decode($description)) : '' ?></dd>
								<dt class="text-muted">Fee</dt>
								<dd class="pl-4"><?= isset($fee) ? format_num($fee,2) : "" ?></dd>
								
							</dl>
						</div>
					</div>
					<div class="card-footer py-1 text-center">
						<button class="btn btn-primary btn-sm bg-gradient-primary rounded-0" type="button" id="enroll"><i class="fa fa-pen-alt"></i> Enroll</button>
						<a class="btn btn-light btn-sm bg-gradient-light border rounded-0 text-dark" href="./?p=class"><i class="fa fa-angle-left"></i> Back to List</a>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>
<script>
    $(function(){
		$('#enroll').click(function(){
			uni_modal("<i class='fa fa-pen-alt'></i> Enroll to <b><?= isset($name) ? $name : '' ?></b>", "enroll.php?cid=<?= isset($id)? $id : '' ?>", 'modal-xl')
		})
    })
   
</script>