<?php
include('../adminlogin/include/session.php');
include('include/config.php');
date_default_timezone_set('Asia/Kolkata');// change according timezone
$currentTime = date( 'd-m-Y h:i:s A', time () );
if(isset($_POST['submit']))
{
if(! get_magic_quotes_gpc())
{
$uid=$_SESSION['id'];	
$title=strtoupper($_POST['title']);
$department=strtoupper($_POST['department']);
$start=($_POST['start']);
//$end=($_POST['end']);
$hall=strtoupper($_POST['hall']);
$session =strtoupper($_POST['session']);
}
else
{
$uid=$_SESSION['id'];	
$title=strtoupper($_POST['title']);
$department=strtoupper($_POST['department']);
$start=($_POST['start']);
//$end=($_POST['end']);
$hall=strtoupper($_POST['hall']);
$session = ($_POST['session']);
			 }
$date=date("d/m/Y");
$start_date_timestamp = strtotime($start);
//$end_date_timestamp = strtotime($end);
$new_start = date('Y-m-d H:i:s', $start_date_timestamp);   	
//$new_end = date('Y-m-d H:i:s', $end_date_timestamp);
	
$query1= "SELECT * from users WHERE id='$uid'";
$result= mysqli_query($conn,$query1);
while($row = mysqli_fetch_array($result))
{
	$uname= $row['fullName'];
	$uemail= $row['userEmail'];
}
	
$query2 = "SELECT * FROM `eventbooking`";
$result2 = mysqli_query($conn, $query2) or die(mysqli_error($conn));
while($row2 = mysqli_fetch_array($result2))
{
	$dbstart= $row2['Start'];
	//$dbend= $row2['End'];
	$dbhall= $row2['Hall'];
	$dbsession= $row2['session'];
	
	}
	
	if($session=="FULLDAY") 
	{
		if( $new_start == $dbstart && $dbhall == $hall  && ($dbsession == "AFTERNOON" || $dbsession == "FORENOON" || $dbsession == "FULLDAY")) 
		{
		echo"<script>alert('Event Booked Already. Try Some other date.');</script>";
		}
		else {
	
   
//Insert Query of SQL
$query="INSERT INTO eventbooking ". "(ebNo,title,Department,Start,session,Hall,userId,userName,userEmail,Date)". " values('1','$title','$department','$new_start','$session','$hall','$uid','$uname','$uemail','$date')";
if (mysqli_query($conn , $query)) 
{
    $last_id = mysqli_insert_id($conn);
    $in="EB-" . $last_id;
	$sql1="UPDATE eventbooking SET ebNo='$in' WHERE id='$last_id'";
	$retval=mysqli_query($conn, $sql1);
	echo"<script>alert('Hall Booking is Successful. Thank You !');</script>";

}
	else
	{
		echo"<script>alert('Error Try after Sometime or Contact Admin 111');</script>";
	}
}
	}
	
	if($session=="FORENOON") 
	{
		if( $new_start == $dbstart && $dbhall == $hall  && ($dbsession == "FULLDAY" || $dbsession == "FORENOON")) 
		{
		echo"<script>alert('Event Booked Already. Try Some other date.');</script>";
		}
		else {
	
   
//Insert Query of SQL
$query="INSERT INTO eventbooking ". "(ebNo,title,Department,Start,session,Hall,userId,userName,userEmail,Date)". " values('1','$title','$department','$new_start','$session','$hall','$uid','$uname','$uemail','$date')";
if (mysqli_query($conn , $query)) 
{
    $last_id = mysqli_insert_id($conn);
    $in="EB-" . $last_id;
	$sql1="UPDATE eventbooking SET ebNo='$in' WHERE id='$last_id'";
	$retval=mysqli_query($conn, $sql1);
	echo"<script>alert('Hall Booking is Successful. Thank You !');</script>";

}
	else{
		echo"<script>alert('Error Try after Sometime or Contact Admin');</script>";
	}
}
	}
	
	if($session=="AFTERNOON") 
	{
		if( $new_start == $dbstart && $dbhall == $hall  && ($dbsession == "FULLDAY" || $dbsession == "AFTERNOON")) 
		{
		echo"<script>alert('Event Booked Already. Try Some other date.');</script>";
		}
		else {
	
   
//Insert Query of SQL
$query="INSERT INTO eventbooking ". "(ebNo,title,Department,Start,session,Hall,userId,userName,userEmail,Date)". " values('1','$title','$department','$new_start','$session','$hall','$uid','$uname','$uemail','$date')";
if (mysqli_query($conn , $query)) 
{
    $last_id = mysqli_insert_id($conn);
    $in="EB-" . $last_id;
	$sql1="UPDATE eventbooking SET ebNo='$in' WHERE id='$last_id'";
	$retval=mysqli_query($conn, $sql1);
	echo"<script>alert('Hall Booking is Successful. Thank You !');</script>";
	echo "<script>  window.location.href = 'https://vinayakamissions.com/vmcc-ticket/admin/event-book.php';</script>";

}
	else{
		echo"<script>alert('Error Try after Sometime or Contact Admin');</script>";
		echo "<script>  window.location.href = 'https://vinayakamissions.com/vmcc-ticket/admin/event-book.php';</script>";
	}
}
	} 
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Admin| Change Password</title>
	     <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" rel="stylesheet">
	<link type="text/css" href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!--	<link type="text/css" href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">-->
	<link type="text/css" href="css/theme.css" rel="stylesheet">
	<link type="text/css" href="images/icons/css/font-awesome.css" rel="stylesheet">
	<link type="text/css" href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600' rel='stylesheet'>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<!--
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/locale/nl.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
-->

		<link rel="stylesheet" href="https://vinayakamissions.com/vmcc-ticket/css/jquery-ui-datepicker.css">
  <script>
  $( function() {
    $( ".datepicker" ).datepicker({
		dateFormat: "dd-mm-yy",
		changeMonth: true,
        changeYear: true,
		showAnim: "drop"
	});
  });
	  
  </script>
	
		  <script>
//		  var defaults = {
//	calendarWeeks: true,
//	showClear: true,
//	showClose: true,
//	allowInputToggle: true,
//	useCurrent: true,
//	ignoreReadonly: true,
//	minDate: new Date(),
//	toolbarPlacement: 'top',
//	locale: 'en',
//	icons: {
//		time: 'fa fa-clock-o',
//		date: 'fa fa-calendar',
//		up: 'fa fa-angle-up',
//		down: 'fa fa-angle-down',
//		previous: 'fa fa-angle-left',
//		next: 'fa fa-angle-right',
//		today: 'fa fa-dot-circle-o',
//		clear: 'fa fa-trash',
//		close: 'fa fa-times'
//	}
//};
//
//$(function() {
//	var optionsDatetime = $.extend({}, defaults, {format:'DD-MM-YYYY HH:mm'});
//	var optionsDate = $.extend({}, defaults, {format:'DD-MM-YYYY'});
//	var optionsTime = $.extend({}, defaults, {format:'HH:mm'});
//	
//	$('.datepicker').datetimepicker(optionsDate);
//	$('.timepicker').datetimepicker(optionsTime);
//	$('.datetimepicker').datetimepicker(optionsDate);
//	//$('.datetimepicker').datetimepicker(optionsDatetime);
//});
			  
			  
	  </script>
	    <script type="text/javascript"> 
	 function ajaxCall() {
    $.ajax({
        url: "eventbook/ajax.php", 
        success: (function (result) {
            $("#div1").html(result);
        })
    })
    
    
};



ajaxCall(); // To output when the page loads
setInterval(ajaxCall, (1000)); 
</script>
<style>
/*
	.form-control {
    display: block;
    width: 100%;
    height: 32px;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.42857143;
    color: #555;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    -webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
}
*/
		#tabledesign {
/*	font-family: 'Montserrat', sans-serif;*/
  border-collapse: collapse;
  width: 100%;
}
	input{
/*		height: 32px !important;*/
	}
#tabledesign td, #tabledesign th {
  border: 1px solid #ddd;
  padding: 8px;
	font-size: 10px;
	font-weight: bold;
}

#tabledesign tr:nth-child(even){background-color: none;}

#tabledesign tr:hover {background-color: #ddd;}

#tabledesign th {
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: left;
  background-color: #081F3F !important;
  color: white !important;
}
	#tabledesign td {
  color: black !important;
}
	</style>
</head>
<body>
<?php include('include/header.php');?>

	<div class="wrapper">
		<div class="container-full">
			
			<div class="row">
<?php include('include/sidebar.php');?>				
			<div class="span9">		
			
				<h3 align="center">Event Hall Booking portal and Status - Admin</h3>
<div class="span3">
	<h5 align="center">Event Booking</h5>
			<form class="form-horizontal row-fluid" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
	<div class="form-group col-sm-12">
		<label>Event Title <span style="color:#F00;"> *</span></label>
		<input type="text" name="title" placeholder="Enter Event" reqiured class="form-control">
	</div>
	<div class="form-group col-sm-12">
<label>Department <span style="color:#F00;"> *</span></label>
<select class="form-control" name="department" required>
<option value="">Select Department</option>
<option value="AUTOMOBILE">AUTOMOBILE</option>
<option value="ECE">ECE</option>
<option value="CIVIL">CIVIL</option>
<option value="BIO-MEDICAL">BIO-MEDICAL</option>
<option value="BIOTECHNOLOGY">BIOTECHNOLOGY</option>
<option value="CSE">CSE</option>
<option value="EEE">EEE</option>
<option value="MECHANICAL">MECHANICAL</option>
<option value="MECHATRONICS">MECHATRONICS</option>
<option value="TAMIL">TAMIL</option>
<option value="ENGLISH">ENGLISH</option>
<option value="PHYSICS">PHYSICS</option>
<option value="MATHEMATICS">MATHEMATICS</option>
<option value="CHEMISTRY">CHEMISTRY</option>
<option value="COMPUTER SCIENCE & APPLICATIONS">COMPUTER SCIENCE & APPLICATIONS</option>
<option value="DIRECTOR">DIRECTOR</option>
<option value="BBA">BBA</option>
<option value="MBA">MBA</option>
<option value="MCA">MCA</option>
<option value="COMMERCE">COMMERCE</option>
<option value="AV CAMPUS">AV CAMPUS</option>
<option value="ARCHITECTURE">ARCHITECTURE</option>
<option value="ADMIN">ADMIN</option>
<option value="ACCOUNTS">ACCOUNTS</option>
<option value="ADMISSION CELL">ADMISSION CELL</option>
<option value="FAHS">FAHS</option>
<option value="SAS">SAS</option>
<option value="DoM">DoM</option>
<option value="SAP">SAP</option>
<option value="PLACEMENT">PLACEMENT</option>
<option value="ROTARACT CLUB">ROTARACT CLUB</option>
	</select>
</div>
<div class="col-sm-12">
	<label>Date <span style="color:#F00;"> *</span></label>
	<input class="form-control datepicker" autocomplete="off" placeholder="Date" name="start"  type="text"/>
<!--
			<div class="form-group">
				<div class="input-group datetimepicker">
					<input type="text" name="start" reqiured class="form-control">
					<span class="input-group-addon">
						<span class="fa fa-calendar"></span>
					</span>
				</div>
			</div>
-->
		</div>	
		<div class="form-group col-sm-12">
<label>Hall <span style="color:#F00;"> *</span></label>
<select class="form-control" name="hall" required>
<option value="">Select Hall</option>
<option value="Indoor Auditorium">Indoor Auditorium</option>
<option value="Outdoor Auditorium">Outdoor Auditorium</option>
<!--
<option value="Digital Room 1">Digital Room 1</option>
<option value="Digital Room 2">Digital Room 2</option>
<option value="Digital Room 3">Digital Room 3</option>
<option value="Digital Room 4">Digital Room 4</option>
<option value="Digital Room 5">Digital Room 5</option>
<option value="Digital Room 6">Digital Room 6</option>
-->
<option value="Board Room">Board Room</option>
	</select>
</div>

		<div class="form-group col-sm-12">
<label>Session <span style="color:#F00;"> *</span></label>
<select class="form-control" name="session" required>
<option value="">Select Session</option>
<option value="FORENOON">Forenoon</option>
<option value="AFTERNOON">Afternoon</option>
<option value="FULLDAY">Fullday</option>
	</select><br/>
</div><br/>

<div class="form-group col-sm-12">
<center>
<button type="submit" name="submit" id="submit" class="btn btn-success">Submit</button>
<button type="reset" class="btn btn-warning" style="margin-left: 10px;">Reset</button>
	</center>
</div>
									</form>
								</div>
								<div class="alert alert-info col-sm-9">
								<div id="div1" height="530px" style="height: 530px  !important; overflow: auto; "></div>
								</div>
							</div>
						</div>
		</div><!--/.container-->
	</div><!--/.wrapper-->

<?php include('include/footer.php');?>

	<script src="scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
	<script src="scripts/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
	<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
	<script src="scripts/flot/jquery.flot.js" type="text/javascript"></script>
<!--	<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>-->
</body>