<?php include("header.php"); ?>
<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" charset="utf-8">
jQuery(function($){
$(".date").datepicker({

    showOn: "both",
    buttonImage: "images/calendar.png",
    buttonImageOnly: true,
    yearRange: '2012:2050',
    changeYear: true
});
});
</script>


<script type="text/javascript">
jQuery(document).ready( function () {

	/*  
	var activity = jQuery('.activity').val();
	//var transact_to = jQuery('.transact_to').val();
				
	
	if(activity){
	*/





$("#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
jQuery('.remove_this').live('click', function() {
    jQuery(this).parent().remove();
    return false;
});
	


jQuery('#save_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:  'save_sched.php',
        data: formData,
        success: function(msg){
            showNotification({
message: "Event Successfully Added",
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>


<title>Add Schedule</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>Schedules</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>Add Schedule</h2>
	<form id="save_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']; ?>" />		
	<div class="field"><label>Activity Name </label> <input class="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" ></div>
	<div class="field"><label>Time </label> <input class="time" name="time" size="10" value="12.00 PM" type="text" class="medium" /></div>
	<div class="field"><label>Street </label> <input class="street" name="street" size="30" type="text" class="medium" /></div>
	<div class="field"><label>City </label> <input class="city" name="city" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Province </label> <input class="province" name="province" size="30" type="text" class="medium" /></div>
	<div class="inc">
	<div class="field"><label>Employees Involved</label> <select class="persons" name="persons[]" ><?php persons(); ?>
	</select><button type="submit" id="append" name="append">Add Employee</button></div>
	</div>
	<div class="inc2">
	<div class="field"><label>Clients Involved</label> <select class="clients" name="clients[]" ><?php clients(); ?>
	</select><button type="submit" id="append_client" name="append">Add Client</button></div>
	</div>
	<div class="field"><button id="save" 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('');
     }

});

});
</script>