<?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>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Staff Dashboard
        <small>Bowen University Iwo</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="dashboard.php"><i class="fa fa-dashboard"></i> Main Page</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

echo "<h2>Please upload digital signature
<br></h2>";
 $dbc = connect();
$img  = getsignature($username);

if($img == Null){
	echo "
	<form action='uploadsignature.php' method='post' enctype='multipart/form-data'>
	<b>Please Choose Digital Signature</b> 
	<br>
	<br>
	<input type='file' name='signature' id='signature' onchange='fileValidation()'>
	<br>
	<br>
	<button type='submit' id='submit' class='btn btn-primary'>Submit</button>
	
	<div id='imagePreview'></div>
	
	
	</form>
	";
}else{
	header('Location:memo.php');
}

?>







    </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>
  function fileValidation(){
    var fileInput = document.getElementById('signature');
    var filePath = fileInput.value;
    var allowedExtensions = /(\.jpg|\.jpeg|\.png)$/i;
    if(!allowedExtensions.exec(filePath)){
        alert('Please upload file having extensions .jpeg/.jpg/.png only.');
        fileInput.value = '';
        $("#submit").attr("disabled", true);
        return false;
        
    }else{
        //Image preview
        if (fileInput.files && fileInput.files[0]) {
            var reader = new FileReader();
            reader.onload = function(e) {
                document.getElementById('imagePreview').innerHTML = '<img width="50px" src="'+e.target.result+'"/>';
            };
            reader.readAsDataURL(fileInput.files[0]);
            $("#submit").attr("disabled", false);
        }
    }
}
</script>
</body>
</html>