<!DOCTYPE html>
<?php

include('buiapp/partials/header.php');
include ('buiapp/phpClasses/functions.php');
if (isset($_SESSION['staff_session'])) {
    $username = $_SESSION['staff_session'];
	$csession =  currentSession();
		$role = getrole($username, $csession);
	

} else {
    header('Location: index.php');
    exit();
}
$csession =  currentSession();
	//			$role = getrole($username, $csession);
include('header.php');
?>
<style type="text/css">
table.table-bordered{
    border:1px solid black;
    margin-top:20px;
  }
table.table-bordered > thead > tr > th{
    border:1px solid black;
	background-color: black;
	color: white;
}
table.table-bordered > tbody > tr > td{
    border:1px solid black;
}
table.table-bordered > tfoot > tr > td{
    border:1px solid black;
}

</style>
  <style>
	input[type=submit].link { border: none; background: none; display: inline; color: #3c8dbc; text-decoration: none; }
  </style>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
         <?php
	    $curs = currentSession();
	  $rid = getunit($username);
	  
		
		    echo "$rid's Dashboard";
	  ?>
        <small>Bowen University Iwo</small>
      </h1>
      <ol class="breadcrumb">
        	 <?php  $url = htmlspecialchars($_SERVER['HTTP_REFERER']); echo " <li><a href='$url'><i class='fa fa-arrow'></i>Back</a></li>";?>
        <li class="active">Dashboard</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content container-fluid" style="background-image: url('images/logo2.png'); background-repeat: no-repeat; background-attachment: fixed; background-position: center; ">
	<?php 
	$staff = aboutstaff($username);
	
	
	if(isset($_POST['changepassword'])){
		$password = $_POST['password'];
		$dbc = connect();
		$query = "UPDATE nonacadstaffs SET password='$password' WHERE staffsId='$username'";
		$run = mysqli_query($dbc, $query);
		echo "<script type='text/javascript'>alert('Update Successful')</script>";
	}
	
	if(isset($_POST['certificate'])){
		$dbc = connect();
		$typ = $_POST['doctype'];
		$pre = "http://".$_SERVER['SERVER_NAME'];
				 $newfilename = strtotime("now");
	
	    $file_name = $_FILES['cert']['name'];
      $file_size =$_FILES['cert']['size'];
     
      $file_type=$_FILES['cert']['type'];
      
      

$tmp = explode('.', $file_name);
$ext = end($tmp);
      $dir = "certificates/$newfilename.$ext";
     
      
      
     
       
		 if(move_uploaded_file($_FILES["cert"]["tmp_name"], $dir)){
        
      $ndr = $pre."/certificates/$newfilename.$ext";
	  $query = "INSERT INTO `qualification`( `staffid`, `type`, `file`) VALUES ('$username', '$typ', '$ndr')";
	  $run = mysqli_query($dbc, $query);
	  echo "<script type='text/javascript'>alert('File upload Successful')</script>";
		     
		 }
	}
	if(isset($_POST['candp'])){
	    $dbc = connect();
	    	
	$pre = "http://".$_SERVER['SERVER_NAME'];
	$newfilename = strtotime("now");
	$file_name = $_FILES['dp']['name'];
    $tmp = explode('.', $file_name);
    $ext = end($tmp);
    $dir = "profilepictures/$newfilename.$ext";
    
    
    
    if(move_uploaded_file($_FILES["dp"]["tmp_name"], $dir)){
        $ndr = $pre."/profilepictures/$newfilename.$ext";
        $query  ="UPDATE nonacadstaffs SET picture='$ndr' WHERE staffsId='$username'";
    mysqli_query($dbc, $query);
    header('Location:profile.php');
       
    }
    
    
 
    
	}
	
	?>
	
	 <div class="modal fade" id="changedp">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">Change Profile Picture</h4>
              </div>
              <div class="modal-body">
                <p>
                    <form action="profile.php" method="POST" enctype="multipart/form-data">
                    Profile Picture: <input type="file" id="passport" name="dp" placeholder="Profile Image" required>
        
         <div id="error_image"><font color="red">File is not a picture</font></div>
                </p>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
                <button type="submit" name="candp" class="btn btn-primary">Make Changes</button>
              </div>
              
              </form>
            </div>
            <!-- /.modal-content -->
          </div>
          <!-- /.modal-dialog -->
        </div>
		    <div class="row">
        <div class="col-md-3">

          <!-- Profile Image -->
          <div class="box box-primary">
            <div class="box-body box-profile">
              <img class="profile-user-img img-responsive img-circle" src="<?php echo $staff[12];?>" alt="User profile picture">
              
              <br>
              <button type="button" class="btn btn-default" data-toggle="modal" data-target="#changedp">
                Change Profile Picture
              </button>

              <h3 class="profile-username text-center"><?php echo "$staff[1] $staff[2] $staff[3] ";?></h3>

              <p class="text-muted text-center"><?php echo $staff[9];?></p>

              <ul class="list-group list-group-unbordered">
                <li class="list-group-item">
                  <b>Directorate</b> <a class="pull-right"><?php echo $staff[11];?></a>
                </li>
				<?php echo $rid;?>
				<br>
				<br>
				<li class="list-group-item">
                 <a class="pull-right"></a>
                </li>
                
                
              </ul>

             
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->

         
          <!-- /.box -->
        </div>
        <!-- /.col -->
        <div class="col-md-9">
          <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#activity" data-toggle="tab">About Me</a></li>
              <li><a href="#timeline" data-toggle="tab">Education</a></li>
              <li><a href="#settings" data-toggle="tab">Settings</a></li>
            </ul>
            <div class="tab-content">
              <div class="active tab-pane" id="activity">
					
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">Bio Data</h3>
			  <form>
            </div>
            <!-- /.box-header -->
            <div class="box-body no-padding">
              <table class="table table-striped">
               
                <tr>
                  <td>Title</td>
                  <td><?php echo $staff[0];?></td>
                </tr>
                <tr>
                  <td>Firstname</td>
                  <td><?php echo $staff[1];?></td>
                 
                </tr>
                <tr>
                  <td>Middlename</td>
                  <td><?php echo $staff[3];?></td>
                 
                </tr>
                <tr>
                  <td>Lastname</td>
                  <td><?php echo $staff[2];?></td>
                  
                </tr> <tr>
                  <td>Sex</td>
                  <td><?php echo $staff[4];?></td>
                  
                </tr> <tr>
                  <td>Date of Birth</td>
                  <td><?php echo $staff[5];?></td>
                  
                </tr> <tr>
                  <td>Phonenumber</td>
                  <td><?php echo $staff[7];?></td>
                  
                </tr>
				 <tr>
                  <td>Email</td>
                  <td><?php echo $staff[8];?></td>
                  
                </tr>
				 <tr>
                  <td>Salary Level</td>
                  <td><?php
					if($staff[13]== NULL){
						echo "<select class='form-control'>
						<option>Level 8</option>
						<option>Level 9</option>
						<option>Level 10</option>
						</select>
						";
					}else{
				  echo $staff[13];
					}
				  ?></td>
                  
                </tr>
				<tr>
                  <td>Denomination</td>
                  <td><?php
					if($staff[14]== NULL){
						echo "<select class='form-control'>
						<option>Baptist</option>
						<option>Winners</option>
						<option>Pentecostal</option>
						</select>
						";
					}else{
				  echo $staff[14];
					}
				  ?></td>
                  
                </tr>
				<tr>
                  <td>State of Origin</td>
                  <td><?php
					if($staff[15]== NULL){
						echo "<select class='form-control'>
						 <option value='' selected='selected'>- Select -</option>
              <option value='Abuja FCT'>Abuja FCT</option>
              <option value='Abia'>Abia</option>
              <option value='Adamawa'>Adamawa</option>
              <option value='Akwa Ibom'>Akwa Ibom</option>
              <option value='Anambra'>Anambra</option>
              <option value='Bauchi'>Bauchi</option>
              <option value='Bayelsa'>Bayelsa</option>
              <option value='Benue'>Benue</option>
              <option value='Borno'>Borno</option>
              <option value='Cross River'>Cross River</option>
              <option value='Delta'>Delta</option>
              <option value='Ebonyi'>Ebonyi</option>
              <option value='Edo'>Edo</option>
              <option value='Ekiti'>Ekiti</option>
              <option value='Enugu'>Enugu</option>
              <option value='Gombe'>Gombe</option>
              <option value='Imo'>Imo</option>
              <option value='Jigawa'>Jigawa</option>
              <option value='Kaduna'>Kaduna</option>
              <option value='Kano'>Kano</option>
              <option value='Katsina'>Katsina</option>
              <option value='Kebbi'>Kebbi</option>
              <option value='Kogi'>Kogi</option>
              <option value='Kwara'>Kwara</option>
              <option value='Lagos'>Lagos</option>
              <option value='Nassarawa'>Nassarawa</option>
              <option value='Niger'>Niger</option>
              <option value='Ogun'>Ogun</option>
              <option value='Ondo'>Ondo</option>
              <option value='Osun'>Osun</option>
              <option value='Oyo'>Oyo</option>
              <option value='Plateau'>Plateau</option>
              <option value='Rivers'>Rivers</option>
              <option value='Sokoto'>Sokoto</option>
              <option value='Taraba'>Taraba</option>
              <option value='Yobe'>Yobe</option>
              <option value='Zamfara'>Zamfara</option>
						</select>
						";
					}else{
				  echo $staff[15];
					}
				  ?></td>
                  
                </tr>
              </table>
			  
                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <button type="submit" name="certificate" class="btn btn-danger">Submit</button>
                    </div>
                  </div>
			  </form>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
			   
			   
			   
			   
			   
			   
              </div>
            
              <div class="tab-pane" id="timeline">
			  
			  
			  <div class="box">
            <div class="box-header">
              <h3 class="box-title">Credentials</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body no-padding">
              <table class="table table-striped">
               <?php 
				$dbc = connect();
				$query = "SELECT * FROM `qualification` WHERE `staffid`='$username'";
				$run = mysqli_query($dbc, $query);
				while($row = mysqli_fetch_row($run)){
					echo " <tr>
                  <td>$row[2]</td>
                  <td><a href='$row[3]' class='btn btn-basic'>Download</a></td>
                </tr>";
                
				}
			   
			   ?>
               
				</table>
				</div>
				</div>
			  
			  
			  
			  
			  
			  
			  
			  
			  
			  
			  
			  
			  
			  
			  
			  
			  
               <form class="form-horizontal"  method="post" action="profile.php" enctype="multipart/form-data">
                  <div class="form-group">
                    <label for="inputName" class="col-sm-2 control-label">Document Type</label>

                    <div class="col-sm-10">
                    <select class="form-control" name="doctype" >
					<option>O Level Certificate </option>
					<option>NYSC Certificate </option>
					<option>Birth Certificate </option>
					<option>Degree </option>
					<option>Masters</option>
					<option>Ph.D</option>
					<option>Others</option>
					
					</select>
					
					<input type="file" name="cert">
                    </div>
                  </div>
                  
                  
                  
                 
                 
                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <button type="submit" name="certificate" class="btn btn-danger">Submit</button>
                    </div>
                  </div>
                </form>
			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
              </div>
              <!-- /.tab-pane -->

              <div class="tab-pane" id="settings">
			  <h4>Change Password</h4>
                <form class="form-horizontal"  method="post" action="profile.php">
                  <div class="form-group">
                    <label for="inputName" class="col-sm-2 control-label"> New Password</label>

                    <div class="col-sm-10">
                      <input type="password" class="form-control" id="password" name="password" required placeholder="Password">
                    </div>
                  </div>
                  
                  
                  
                 
                 
                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <button type="submit" name="changepassword" class="btn btn-danger">Submit</button>
                    </div>
                  </div>
                </form>
              </div>
              <!-- /.tab-pane -->
            </div>
            <!-- /.tab-content -->
          </div>
          <!-- /.nav-tabs-custom -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <!-- Main Footer -->
  <footer class="main-footer">
    <!-- To the right -->
    <div class="pull-right hidden-xs">
      
    </div>
    <!-- Default to the left -->
    <strong>Copyright &copy; 2019 <a href="#">Bowen University</a>.</strong> All rights reserved.
  </footer>


  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
  immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->

<!-- jQuery 3 -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="bower_components/jquery-ui/jquery-ui.min.js"></script>
<!-- Slimscroll -->
<script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- fullCalendar -->
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/fullcalendar/dist/fullcalendar.min.js"></script>
<!-- Page specific script -->
<script>
 $("#error_image").hide(); 
    $('#passport').on('change', function() {
  Object.values(this.files).forEach(function(file) {
   // console.log(`Type: ${file.type}`);
    var vidtype = ['image/gif', 'image/jpeg', 'image/png'];
    var len = vidtype.length;
    for(var i = 0; i < len; i++){
        
        if(file.type == vidtype[i]){
           // alert("Am here");
             $("#error_image").hide();
		  $("#register").attr("disabled", false);
		  return false;
        }else{
             $("#error_image").show();
		  $("#register").attr("disabled", true);
        }
    }
  })
})
</script>


</body>
</html>