
<div class="container">
	<div class="col-sm-12 info"><center>

    <?php if($saved){
     if($success>0){ ?>
      <center>&#9432; Schedule added</center>
     <?php }else{ ?>
     <center>&#xf071; Failed.Try again!  </center>
    <?php }} ?>

    </center>
	</div>
		<h3>Schedule a Course </h3>
		<form method="post" action="addschedule" class="validate" enctype="multipart/form-data" data-success="Schedule Added successifully" data-toastr-position="top-center">
			<div class="row gtr-uniform">

				<div class="col-md-8">
					<select name="course" id="demo-category" class="form-control" required>
						<option value="">- Select Course -</option>
						<?php foreach($courses as $course):?>
						<option value="<?php  echo $course['courseID'];?>"><?php echo $course['courseName'] ;     ?></option>
					<?php endforeach; ?>
					</select>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-4">
					From:<br>
					<input type="date" name="datefrom" id="datefrom" value=""  class="form-control" placeholder="&#xf133; From Date " required/>
				</div>
				<div class="col-sm-4">
					To:<br>
					<input type="date" name="dateto" id="dateto" value=""  class="form-control" placeholder="&#xf133; To Date " required />
				</div>
			</div>
			<div class="row">
				<div class="form-group">
				<div class="col-sm-4">
					<select name="center" id="demo-category"  class="form-control" required>
						<option value="">- Select Center -</option>
							<?php foreach($centers as $center): ?>
						<option value="<?php  echo $center['centerID'];?>"><?php echo $center['centerName'] ;?></option>
					<?php endforeach; ?>
					</select>
				</div>
				<div class="col-sm-4">
					<select name="trainer" id="demo-category" class="form-control" >
						<option value="0">- Select Trainer -</option>
						<?php foreach($trainers as $trainer):                        ?>

						<option value="<?php  echo $trainer['userID'];?>"><?php echo $trainer['firstName'].' '.$trainer['secondName'].' '.$trainer['surName'] ;?></option>
					<?php endforeach; ?>
					</select>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-4 form-group">
				<select id="2" name="location"  class="form-control" required>
			       <option value="">- Select Center -</option>
							<?php foreach($centers as $center): ?>
						<option value="<?php  echo $center['centerName'];?>"><?php echo $center['centerName'] ;?></option>
					<?php endforeach; ?>
			    </select>
			    <!--<select  id="2" disabled>-->
			    <!--    <option selected = "selected" ></option>-->
			    <!--</select>-->
			</div>
			<div class="col-sm-4 form-group">
				<input type="text" name="fees" class="form-control" placeholder="Fees($)" value="fees" required>
			</div>
		</div>
			</div>

				<!-- Break -->
				<div class="col-sm-3">
					<button type="submit" class="btn btn-3d btn-teal btn-xlg btn-block margin-top-30">Add Schedule</button>
				</div>
			</div>
		</form>
	</div>

	<script type="text/javascript">
		var Nairobi = ["Nairobi"];
		var Mombasa = ["Mombasa"];
		var Dubai = ["Dubai"];
		var Kigali = ["Kigali"];


document.getElementById("1").addEventListener("change", function(e){
        var select2 = document.getElementById("2");
        select2.innerHTML = "";
        var aItems = [];
    if(this.value == "2"){
        aItems = Mombasa;
    } else if (this.value == "3") {
        aItems = Dubai;
    } else if(this.value == "1") {
        aItems = Nairobi;
    }
    else if(this.value == "4"){
    	aItems = Kigali;
    }
    for(var i=0,len=aItems.length; i<len;i++) {
        var option = document.createElement("option");
        option.value= (i+1);
        var textNode = document.createTextNode(aItems[i]);
        option.appendChild(textNode);
        select2.appendChild(option);
    }
    
}, false);
	</script>