<!DOCTYPE html>
<html>
<head>
	<?php include('include/head.php'); ?>
	<!-- <title>Add City</title> -->
</head>
<body>
	<?php include('include/header.php'); ?>
	<?php include('include/sidebar.php'); ?>
	<div class="main-container">
		<div class="pd-ltr-20 customscroll customscroll-10-p height-100-p xs-pd-20-10">
			<div class="min-height-200px">
				<div class="page-header">
					<div class="row">
						<div class="col-md-6 col-sm-12">
							<div class="title">
								<h4>Add Course Details</h4>
							</div>
							<nav aria-label="breadcrumb" role="navigation">
								<ol class="breadcrumb">
									<li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
									<!-- <li class="breadcrumb-item"><a href="#">Gallery</a></li> -->
									<li class="breadcrumb-item"><a href="view_course_details.php">Course Details</a></li>
									<li class="breadcrumb-item active" aria-current="page">Add Course Details</li>
								</ol>
							</nav>
						</div>
						<div class="col-md-6 col-sm-12 text-right">
							<div class="dropdown">
								<a class="btn btn-primary" href="view_course_details.php" role="button">
									View Course Details
								</a>
							</div>
						</div>
					</div>
				</div>


				
<div class="pd-20 bg-white border-radius-4 box-shadow mb-30">
					<div class="clearfix">
						<div class="pull-left">
							<!-- <h4 class="text-blue">Add Image Title</h4> -->
						</div>
						
					</div><br> 

								<?php
                                    
                                    if (isset($_POST['submit'])) 
                                    {
                                        
                                        extract($_POST);
                                        
                                        $date=$_POST['fld_session_date'];
                                        $new_date= date("Y-m-d",strtotime($date));
                                        $abc=mysqli_query($connect,"select * from tbl_course_details where fld_course_id='".$course_name."' and fld_batch_time_from='".$fld_batch_time_from."' and fld_batch_time_to='".$fld_batch_time_to."' and fld_session_date='".$new_date."' and fld_fee_of_course='".$fld_fee_of_course."'");

                                        if(mysqli_num_rows($abc)==1)
                                         {
                                        	    echo "<script>";
	                                            echo "alert('Course Details Alrady Exist');";
	                                            //echo "window.location.href='view_course_details.php';";
	                                            echo "</script>";
                                         }
                                         else
                                         {
	                                        $query="INSERT INTO tbl_course_details(fld_course_id,fld_batch_time_from,	fld_batch_time_to,fld_session_date,fld_fee_of_course) VALUES ('$course_name','$fld_batch_time_from','$fld_batch_time_to','$new_date','$fld_fee_of_course')";
	                                        //echo $query."<br>";
	                                        $row=mysqli_query($connect,$query) or die(mysqli_error($connect));
	                                        if ($row) 
	                                        {
	                                            echo "<script>";
	                                            echo "alert('Course Details Added Successfully');";
	                                            echo "window.location.href='view_course_details.php';";
	                                            echo "</script>";                 
	                                        }
	                                        else
	                                        {
	                                            echo "<script>";
	                                            echo "alert('Error');";
	                                            echo "</script>";
	                                        }
	                                    }
                                    }
                                ?>						
					<form method="post">
						<div class="form-group row">
							<label class="col-sm-12 col-md-2 col-form-label">Course Name <span class="text-danger">*</span> : </label>
							<div class="col-sm-12 col-md-10">
								<select class="form-control" name="course_name" required="">
									<option value="">Select Course</option>
									<?php 
				                        $query= mysqli_query($connect,"select distinct fld_course_name,fld_course_id from tbl_course where fld_course_delete='0'");

				                        while ($row=mysqli_fetch_assoc($query)) {
				                          extract($row);

				                    ?>
				                          <option value="<?php echo $row['fld_course_id']?>"><?php echo $row['fld_course_name']?></option>
				                        <?php } ?>
								</select>
							</div>
						</div>
							<div class="form-group row">
								<label class="col-sm-12 col-md-2 col-form-label">Batch Time From <span class="text-danger">*</span> : </label>
								<div class="col-sm-12 col-md-10">
									<input class="form-control time-picker" placeholder="Select time" type="text" name="fld_batch_time_from" required="">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-sm-12 col-md-2 col-form-label">Batch Time To <span class="text-danger">*</span> : </label>
								<div class="col-sm-12 col-md-10">
									<input class="form-control time-picker" placeholder="Select time" type="text" name="fld_batch_time_to" required="">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-sm-12 col-md-2 col-form-label">Session Date<span class="text-danger">*</span> : </label>
								<div class="col-sm-12 col-md-10">
									<input class="form-control date-picker" placeholder="Select Date" type="text" name="fld_session_date" required="">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-sm-12 col-md-2 col-form-label">Fee Of Course<span class="text-danger">*</span> : </label>
								<div class="col-sm-12 col-md-10">
									<input class="form-control" placeholder="Enter Fee of Course" type="text" name="fld_fee_of_course" required="" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
								</div>
							</div>
						<div class="form-group row">
							<div class="col-sm-12 col-md-10">
							<center><input class="btn btn-success" value="Submit" type="submit" name="submit">&nbsp;
								<input class="btn btn-danger" value="Reset" type="reset">&nbsp;
								<a href="view_course_details.php" class="btn btn-warning">Back</a></center>
							</div>
						</div>
					</form>

					 
	</div>
			<?php include('include/footer.php'); ?>
		</div>
	</div>
	<?php include('include/script.php'); ?>
</body>
</html>