<?php

 include("../../../dbconnection/dbconnection.php");$name='';if(isset($_SESSION["id"])){  $user=strtolower($_SESSION['type']); if($user==="admin"){$id=$_SESSION['id'];include("../../../steam_functions/steam_functions.php");$team=(staff_team($connect));$loggedin=staff_loggedin($id,$connect);$students=few_students($connect);}else if($user=="staff"){header("location:../../../pages/staff_login.php");}else{ header("location:../../../pages/staff_login.php"); }}else{header("location:.../../../pages/staff_login.php");}

include("../../header.php");

?>      


 <div class="content-wrapper"  style='min-height:auto'>
      <section class="content-header">
      <h1>
        <small></small>
      </h1>
       <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
        <li class="active">Staff</li>
      </ol>
    </section>
    <!-- Main content -->
		
		<div class="col-md-12" style='padding:3px'>
          <div class="box">
            <div class="box-header bg-blue">
              <h3 class="box-title">Staff Members</h3>
			<button type="button" name="add" id="add_button" class="btn btn-success btn-xs pull-right ">Add</button>    	
										
            </div>
            <!-- /.box-header -->
            
            <div class=" panel-body  table-responsive">
						<table id="staff-members" class="table  table-bordered table-striped ">

						
										<thead>
											<tr>
												<th>National ID</th>
												<th>Name</th>
												<th>Email</th>
												<th>Phone</th>
												<th>Rank</th>
												<th>Status</th>
												<th></th>
												<th></th>
												<th></th>
											</tr>
										</thead>
										<tbody>
										 <!---->
                						
											<?php
											 
										$team=staff_team($connect);
										foreach($team as $row){
											$emp_no=$row["emp_no"];
											$id=$row["national_id"];
											$name=$row["fname"]." ".$row["other_names"];
											$acc=$row["account"];
											$status=$row["status"];
											$email=$row["email"];
											$tel=$row["phone"];
											$rank=$row["rank"];
											if($status==="1")
											{
												$status = '<span class="label label-success">Active</span>'; 
												$btn='<button type="button" name="disable" id="'.$row["emp_no"].'" class="btn btn-danger btn-xs delete" data-status="'.$row["status"].'">Disable</button>';
											}
											else
											{
												$status = '<span class="label label-danger">Disabled</span>';
												$btn='<button type="button" name="disable" id="'.$row["emp_no"].'" class="btn btn-success btn-xs delete" data-status="'.$row["status"].'">Enable</button>';
											}
											$view='<a href="view_order.php?pdf=1&order_id='.$row["emp_no"].'" class="btn btn-info btn-xs">View</a>';
											
										?>
										<tr>
										  <td><?php echo $id;?></td>
										  <td><?php echo $name;?></td>
										  <td><?php echo $email;?></td>
										  <td><?php echo $tel;?></td>
										  <td><?php echo $rank;?></td>
										  <td><?php echo $status;?></td>
										  <td><?php echo $view;?></td>
										  <td><?php echo '<button type="button" name="update" id="'.$row["emp_no"].'" class="btn btn-warning btn-xs update">Edit</button>';?></td>
										  <td><?php echo $btn;?></td>
										</tr>
										<?php 
										}
										?>
               <!-- // -->
										</tbody>
										
									<tfoot>
										<tr>
												<th>National ID</th>
												<th>Name</th>
												<th>Email</th>
												<th>Phone</th>
												<th>Rank</th>
												<th>Status</th>
									</tfoot>
						</table>
            </div>
            <!-- /.box-body -->
        </div>
        <!-- /.col -->
		</div>
        <!-- /.col -->
		
		
	
		
<div id="staff-Modall" class="modal  fade">

    	<div class="modal-dialog "  style='margin-top:0px;margin-bottom:0px'>
    		<form method='POST' id='form-staff_reg'  >
    			<div class="modal-content " style='padding:0px'>
    				<div class="modal-header ">
    					<button type="button" class="close" data-dismiss="modal">&times;</button>
						<h4 class="modal-title"><i class="fa fa-plus"></i> New Staff</h4>
    				</div>
    				<div class="modal-body"  style='padding:0px'>

								<!-- /.box-header -->
								<div class="box-body" style='padding:0px'>

								<h4 class='col-md-12'>Personal Details</h4>
										  <!-- First Name -->
								  <div class="form-group col-md-6">
										<label>First Name</label>
									<div class="input-group">
									  <div class="input-group-addon">
										<i class="fa fa-user-o"></i>
									  </div>
									  <input  class="form-control" type="text" name='fname' placeholder='First Name' required>
									</div>
									<!-- /.input group -->
								  </div>
								  <!-- /.form group -->
								
								
													  <!-- other Name -->
								  <div class="form-group col-md-6">
										<label>Other Name</label>
									<div class="input-group">
									  <div class="input-group-addon">
										<i class="fa fa-user-o"></i>
									  </div>
									  <input  class="form-control" type="text" name='lname' placeholder='Other Name' required>
									</div>
									<!-- /.input group -->
								  </div>
								  <!-- /.form group -->
								
										
													  <!-- other Name -->
								  <div class="form-group col-md-6">
										<label>National ID</label>
									<div class="input-group">
									  <div class="input-group-addon">
										<i class="fa fa-credit-card"></i>
									  </div>
									  <input  class="form-control" type="number" name='idno' placeholder='Nationa ID' required>
									</div>
									<!-- /.input group -->
								  </div>
								  <!-- /.form group -->
								
								
												
													  <!-- other Name -->
								  <div class="form-group col-md-6">
										<label>Date of Birth</label>
									<div class="input-group">
									  <div class="input-group-addon" >
										<i class="fa fa-calendar"></i>
									  </div>
									  <input  class="form-control"  type="textarea" name='dob' id='dob' placeholder='dd/mm/yyyy' autocomplete=off required>
									</div>
									<!-- /.input group -->
								  </div>
								  <!-- /.form group -->
								
								
											
													  <!-- Gender -->
										
								  <div class="form-group col-md-4">
										<label>Gender</label><br>
									<div class="input-group">
									  <div class="input-group-addon">
										<input class="w3-radio" type="radio" name="gender" value="male" checked>
									  </div> <div class=" form-control">Male</div>
									</div>               
								   </div> 
									
									<div class="form-group col-md-4">
									<label></label>
									<div class="input-group">
									  <div class="input-group-addon">
										<input class="w3-radio" type="radio" name="gender" value="Female" >
									  </div> <div class=" form-control">Female</div>
									</div>
									<!-- /.input group -->
								  </div>
								  <!-- /.form group -->
								
								
								
								<br>
								<h4 class='col-md-12'>Contact Details</h4>
								
										  <!-- phone number -->
								  <div class="form-group col-md-6">
									<label>Phone Number</label>
									<div class="input-group">
									  <div class="input-group-addon">
										<i class="fa fa-phone"></i>
									  </div>
									  <input  class="form-control" type="number" name='pno' placeholder='Phone Number' required>
									</div>
									<!-- /.input group -->
								  </div>
								  <!-- /.form group -->
									
									<!-- email -->
								  <div class="form-group col-md-6">
									<label>Email:</label>

									<div class="input-group">
									  <div class="input-group-addon">
										<i class="fa fa-envelope-o"></i>
									  </div>
									  <input  class="form-control" type="email" name='user_email' placeholder='Email' required>
									</div>
									<!-- /.input group -->
								  </div>
								  <!-- /.form group -->
								<br>
								
								<h4 class='col-md-12'>Education Details</h4>			
								  <div class="form-group col-md-6">
									<label>Education level</label>
									<select class="form-control select2" name='edulevel' required style="width: 100%;">
									  <option value=""  selected disabled="disabled" >Select Level</option>
									  <option value="Doctorate">Doctorate</option>
									  <option value="Masters">Masters</option>
									  <option value="Degree">Degree</option>
									  <option value="Diploma">Diploma</option>
									  <option value="Certificate">Certificate</option>
									</select>
								</div>

								 <div class="form-group col-md-6">
								  <label>Course</label>
									<input class="form-control" placeholder="Course" type="text" name='course'>
								  </div>
								
								<h4 class='col-md-12'>Employment Details </h4>
								
								
								 <div class="form-group col-md-6">
								 <label>Job Position</label>
									<input class="form-control" placeholder="Job Description" type="text" name='jobpos' required>
								  </div>
								  
								<hr class='' style='display:table;width:100%'>
								
								<!-- /.box-body -->
								<div class="box-footer">
								 
								</div>

							

								  </div>
								  <!-- /.form-group -->
								  
						
						
    				</div>
    				<div class="modal-footer"> 
					<button type="reset" class="btn btn-default pull-left " data-dismiss="modal"><i class="fa fa-times"></i> Discard</button>
							<div class="pull-right">
									<input type="hidden" name="btn_action" value='Add-Staff' id="btn_action" />
									<button type="submit" class="btn btn-primary"><i class="fa fa-paper-plane"></i> Send</button>
								 </div>
							
    				</div>
    			</div>
    		</form>
    	</div>

    </div>
    </div>
 

	
	<!-- jQuery 2.2.3 -->
<script src="../../plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="../../bootstrap/js/bootstrap.min.js"></script>
	<!-- DataTables -->
<script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../../plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="../../plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="../../plugins/fastclick/fastclick.js"></script>

<!-- Bootstrap WYSIHTML5 -->
<script src="../../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>

<script src="../../plugins/select2/select2.full.min.js"></script>


<!-- InputMask -->
<!-- Page Script -->
<script>
  $(function () {
    //Add text editor
    $("#compose-textarea").wysihtml5();
	//Initialize Select2 Elements
    $(".select2").select2();
	
	    $("#staff-members").DataTable();
    $('#id').DataTable({
		"processing":true,
      "paging": true,
      "lengthChange": false,
	  "ordering": true,
      "searching": false,
      "info": true,
      "autoWidth": false
	  
		
    });

	
  });
  $(document).ready(function(){
	  
	  		$('#add_button').click(function(){
			
			$('#staff-Modall').modal('show');
			$('#form-staff_reg')[0].reset();
			$('#btn_action').val('Add');
			// $('#span_product_details').html('');
			// add_product_row();
		});
		
		$(document).on('submit', '#form-staff_reg', function(event){
			event.preventDefault();
			// $('#action').attr('disabled', 'disabled');
			// alert();
			var form_data = $(this).serialize();alert(form_data);
			$.ajax({
				url:"user_action.php",
				method:"POST",
				data:form_data,
				success:function(data){
					alert(data);
				}
			});
		});
		
  })
  
</script>
<?php include("../../footer.php");?>
