<?php include("header.php"); ?>

<script type="text/javascript" charset="utf-8">
jQuery(function($){
$(".date").datepicker();
});
</script>
<style type="text/css" media="all">@import "css/timepicker/timePicker.css"</style>
 <script type="text/javascript" src="js/timepicker/jquery.timePicker.js"></script>
   <script type="text/javascript">
  jQuery(function() {
    // 02.00 AM - 03.30 PM, 15 minutes steps.
    $(".time").timePicker({
  startTime: "02.00",  // Using string. Can take string or Date object.
  endTime: new Date(0, 0, 0, 15, 30, 0),  // Using Date object.
  show24Hours: false,
  separator:'.',
  step: 15});
    
    
    
  });
  </script>

<script type="text/javascript">
$(document).ready( function () {
$("#append").click( function() {
		$(".inc").append('<div class="field"><label>&nbsp;</label><select class="persons" name="persons[]"><?php  persons(); ?></select><a href="#" class="remove_this">remove</a></div>');
		return false;
	});
$("#append_client").click( function() {
		$(".inc2").append('<div class="field"><label>&nbsp;</label><select class="clients" name="clients[]"><?php  clients(); ?></select><a href="#" class="remove_this">remove</a></div>');
		return false;
	});
	
// using live() will bind the event to all future
// elements as well as the existing ones
$('.remove_this').live('click', function() {
    $(this).parent().remove();
    return false;
});
	
jQuery('#update_sched').submit(function(e){
var activity = jQuery('.activity').val();
var date = jQuery('.date').val();
var time = jQuery('.time').val();
var street = jQuery('.street').val();
var city = jQuery('.city').val();
var province = jQuery('.province').val();
var persons = jQuery('.persons').val();
var clients = jQuery('.clients').val();

    e.preventDefault();
if (activity && date && time && street && city && province && persons && clients){		
    var formData = jQuery(this).serialize();
    jQuery.ajax({
        type: 'POST',
        url:  'update_sched.php',
        data: formData,
        success: function(msg){
            showNotification({
message: "Event Successfully Updated",
type: "success", // type of notification is error/success/warning/information,
autoClose: true, // auto close to true
duration: 5 // message display duration
});
<!--redirection -->
		 var delay = 3000;
		setTimeout(function(){ window.location = 'calendar_view.php';}, delay);  
<!--redirection end -->	
        }
    });
} else {
alert('All fields are required!');
return false;
}	
});
});

</script>

<?php
$sched_id = $_POST['id'];

?>

<?php $users = mysql_query("SELECT * FROM schedules where sched_id = '$sched_id'") or die(mysql_error());  ?>

			<?php $sched = mysql_fetch_array($users);
				$id = $sched['sched_id'];
				$activity = $sched['activity'];
				$date = $sched['date'];
				$time = $sched['time'];
				$street = $sched['street'];
				$city = $sched['city'];
				$province = $sched['province'];
				$persons = $sched['persons'];
				$clients = $sched['clients'];
			?>
<title>Modify Event</title>
</head>
<body class="modify_user standard">
<div class="wrapper">

	<div class="header">
	<h1>Lifeguard Archangels Security Corporation</h1>
	</div>
<?php include("main_menu.php"); ?>
	<div class="right_nav">
	<h1>Profiles</h1>
<?php include("sched_sidebar.php"); ?>
	</div>
	<div class="content">
	<div class="title_page">
	</div>
	
	<div class="actions">

	<div class="form label-inline uniform" id="shadow" style="width: 700px; margin:0 auto;" >
	<h2>Modify</h2>
<form id="update_sched">
		<input type="hidden" class="pc_date" name="pc_date"/>
		<input type="hidden" class="pc_time" name="pc_time" />
		<input type="hidden" class="user" name="user" value="<?php echo $_SESSION['user_name']; ?>" />							
	<input class="id" value="<?php echo $id; ?>"  name="id" size="30" type="hidden"/>
	<div class="field"><label>Activity</label> <input class="activity" value="<?php echo $activity; ?>" name="activity" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Date</label> <input type="text" class="date" name="date" size="30" type="text" class="medium" ><img src="images/calendar.png"></div>
	<div class="field"><label>Time</label> <input class="time" value="<?php echo $time; ?>" name="time" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Street</label> <input class="street" value="<?php echo $street; ?>" name="street" size="30" type="text" class="medium" /></div>
	<div class="field"><label>City</label> <input class="city" value="<?php echo $city; ?>" name="city" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Province</label> <input class="province" value="<?php echo $province; ?>" name="province" size="30" type="text" class="medium" /></div>
	<div class="inc">
	<div class="field"><label>Employees Involved</label><button type="submit" id="append" name="append">Add Employee</button></div>
	<?php $wordChunks = explode(",", $persons);
	for($i = 0; $i < count($wordChunks); $i++){
	echo "<div class='field'><label>&nbsp;</label><select class='persons' name='persons[]'><option value ='$wordChunks[$i]'>$wordChunks[$i]</option>"; persons(); echo "</select><a href='#' class='remove_this' border='2'>remove</a></div>";
	}
	?>
	</div>
	<div  class="inc2">
	<div class="field"><label>Clients Involved</label><button type="submit" id="append_client" name="append">Add Client</button></div>
	<?php $wordChunks = explode(",", $clients);
	for($i = 0; $i < count($wordChunks); $i++){
	echo "<div class='field'><label>&nbsp;</label><select class='clients' name='clients[]'><option value ='$wordChunks[$i]'>$wordChunks[$i]</option>"; clients(); echo "</select><a href='#' class='remove_this' border='2'>remove</a></div>";
	}
	?>
	</div>
	
	<div class="field"><button id="update_sched" name="SubmitOne">Save Changes</button></div>
	</form>
	</div>
	
	</div>

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

<script type="text/javascript">
jQuery(document).ready( function () {
/* amo ni*/
var myDate = new Date();
var pc_date = (myDate.getMonth()+1) + '/' + (myDate.getDate()) + '/' + myDate.getFullYear();
var pc_time = myDate.getHours()+':'+myDate.getMinutes()+':'+myDate.getSeconds();
jQuery(".pc_date").val(pc_date);
jQuery(".pc_time").val(pc_time);
/*asta d*/

jQuery('.date').change( function(){
	var input = jQuery(this).val();
	today = new Date();
	
    expo = new Date(input);
    var one_day=1000*60*60*24
    var daysLeft = Math.ceil((expo.getTime()-today.getTime())/(one_day));
     if(daysLeft === 0){
         // today
         alert("today");
     }else if(daysLeft < 0){
         alert('passed');
		 jQuery(this).val('');
     }

});

/* jQuery('#updateuser').click( function(){
	
		var id = $(".id").val();
		var activity = $(".activity").val();
		var date = $(".date").val();
		var time = $(".time").val();
		var street = $(".street").val();
		var city = $(".city").val();
		var province = $(".province").val();
		var persons = $(".persons").val();
		var clients = $(".clients").val();
		var pc_time = $(".pc_time").val();
		var pc_date = $(".pc_date").val();
		jQuery.ajax({
		type: "POST",
		data: ({id:id,activity: activity,date: date,time: time, street: street,city: city, province: province, persons: persons, clients: clients,pc_date:pc_date,pc_time:pc_time}),
		url:"update_sched.php",
		success: function(msg) {
		showNotification({
message: "Event Successfully Updated",
type: "success", // type of notification is error/success/warning/information,
autoClose: true, // auto close to true
duration: 5 // message display duration
});
}
});

}); */

});

</script>	