<div class="container">
	<header id="page-header">
		<h1>Students</h1>
		<ol class="breadcrumb">
			<li><a href="#">Pages</a></li>
			<li class="active">All Students</li>
		</ol>
	</header>
	<div class="container">
		<div class="col-md-12">
		<form method="post" action="students">
			<div class="row ">
				<div class="form-group">
					<div class="col-sm-9">
						<select name="course" id="demo-category" class="form-control" required>
							<option value="10000">All Courses </option>
							<?php foreach($courses as $course):  ?>

							<option value="<?php  echo $course['courseID'];     ?>"

								<?php
								if($courseid && $course['courseID']==$courseid){ echo 'SELECTED';}

								?>
								><?php echo $course['courseName'] ;?></option>

						<?php endforeach; ?>
						</select>
					</div>
				</div>
			</div>
				<div class="row">
					<div class="form-group">
						<div class="col-sm-3 col-sm-12">

							From: <input type="date" class="form-control" name="datefrom" id="datefrom"
							<?php
							if($courseid){?>  value="<?php echo $datefrom; ?>"
						<?php } ?>

							 placeholder=" From " />
						</div>
						<div class="col-sm-3 col-sm-12">

							To: <input type="date"  class="form-control" name="dateto" id="dateto"
							<?php   if($courseid){ ?>  value="<?php echo $dateto; ?>"      <?php } ?>
							 placeholder="&#xf133; To"  />
						</div>
						<div class="col-sm-3 col-sm-12">
							Status: <select name="status" id="demo-category"  class="form-control" required>
								<option value="0">- Status -</option>
								<option value="1"  <?php  if($courseid && $status==1){echo 'SELECTED' ;}     ?> >New Applicants</option>
								<option value="2" <?php  if($courseid && $status==2){echo 'SELECTED' ;}     ?>>Continuing </option>
								<option value="3" <?php  if($courseid && $status==3){echo 'SELECTED' ;}     ?>>Completed</option>

							</select>
						</div>
					</div>

				</div>
				<div class="row ">
					<div class="form-group">
						<div class="col-sm-9">
							<input type="text" name="name" class="form-control" <?php
								if($userID){?> value="<?php echo $student->firstName.' '.$student->secondName.' '.$student->surName;?>">
								<?php } ?>
						</div>
					</div>
				</div>

					<!-- Break -->
					<div class="row">
						<div class="col-sm-6">
							<input type="submit" value="Search Students" class="btn btn-primary" />
								<!--<li><input type="reset" value="Reset" /></li>-->
						</div>
					</div>
			</div>
		</form>
	</div>
</div>

		<div class="table-wrapper">
			<table class="table table-striped table-bordered table-condensed" id="datatable_sample">
				<thead>
					<tr>
						<th>Date</th>
						<th>Name</th>
						<th>Phone</th>
						<th>Course</th>
						<th>Class Type</th>
						<!--th>Status</th-->
						<th colspan="2" style="text-align: center">Action</th>
					</tr>
				</thead>
				<tbody>

		<?php
		if($students){
		$i=0;
		  foreach($students as $student):
		// foreach($courses as $course):
// 		foreach (array_combine($students, $courses) as $student => $course):
						      if(is_array($student) ){
								$student= (object)$student;
							 }
							 $i++;
						  $status ="";
							if($student->appStatus==1){
								$status ="New Applicant";
							}else if($student->appStatus==2){
								$status ="Continuing";
							}else{
								$status ="Completed";
							}
						 ?>
					<tr>
						<td><?php echo $student->dateCreated;?></td>
						<td><?php echo $student->firstName.' '.$student->secondName.' '.$student->surName;?></td>
						<td><?php echo $student->phone;  ?></td>
						<td><?php echo $student->courseName;?></td>
						<td><?php echo $student->classType;  ?></td>
						<!--td><?php echo $status;  ?></td-->
						<td><a class="btn btn-xs btn-success" href="<?php echo base_url('student/'.$student->userID) ; ?>"><i class="fa fa-eye"></i>View</a></td>
						<!--<td><a class="btn-xs btn btn-danger" href="deletestudent/<?php echo $student->userID;?>"><i class="fa fa-trash"></i>Delete</a></td>-->

					</tr>
				<?php endforeach;
			  }  ?>
				<?php
					 if($students){ ?>
				<tr><td colspan ="4"><b>Total:</b></td><td class="label label-success"><b><?php echo $i.' Students';?></b></td></tr>
			   <?php } ?>


				</tbody>
				<tfoot>

				</tfoot>
			</table>
		</div>
	</div>
