<!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();
	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>

<link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">


 <link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="bower_components/jquery/dist/jquery.min.js"></script>
  <script src="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script> 
  <link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote.css" rel="stylesheet">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote.js"></script>
  <!-- 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">
        <?php  $url = htmlspecialchars($_SERVER['HTTP_REFERER']); echo " <li><a href='$url'><i class='fa fa-arrow'></i>Back</a></li>";?>
        <li class="active">View Memo</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content container-fluid" style="background-color: #fff; ">
	    	<?php 
	if(isset($_POST['send'])){
		$memoid = $_POST['memoid'];
		$com = $_POST['comm'];
		$reveiver = $_POST['to'];
		$memo = $_POST['memo'];
		$receiver = $_POST['to'];
	    $ref = getmemo($memoid);
		$title = $_POST['title'];
		memocomment($memoid, $com, $username, $ref[7]);
		savememo($username, $receiver, $memo, $title, $ref[7]);
		 $staffmail = aboutstaff($username);
		
		$to = $receiver;
     $from = "$staffmail[8]";
    $name = 'Bowen University Internal Memo';
    $subj = "Bowen University Internal Memo";
   // smtpmailer($to,$from, $name ,$subj, $msg);
  
    
	echo "<script type='text/javascript'>
		alert('Memo Sent Successfully');
		location.replace('sentmemo.php');
	</script>";


		
		
	}
	
	?>
	
	
		<?php 
		if(isset($_POST['memoid'])){
			$id = $_POST['memoid'];
		$memo = getmemo($id);
		
		
	
		echo $memo[3];
	
		changememostatus($id);
		}else{
			header('Location:memo.php');
		}
		
				echo "<form action='viewmemo.php' method='POST'>";
echo "<input type='hidden' name='memoid' value='$id'>";
echo "<input type='hidden' name='title' value='$memo[5]'>";
echo "<input type='hidden' name='memo' value='$memo[3]'>";

 echo "<div class='modal modal-info fade' id='modal-info'>
          <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'>Foward Memo To?</h4>
              </div>
              <div class='modal-body'>
                <select class='form-control select2' style='width: 100%;' name='to'>
				<option value='$memo[1]'>Sender -$memo[1] </option>
				<option value='BUI/ACAD/SS/427'>Deputy Vice Chancellor </option>
				<option value='BUI/ACAD/SS/427'>Registrar</option>
				<option value='BUI/ACAD/SS/427'>Bursar</option>
				<option value='BUI/ACAD/SS/427'>Libraian</option>
				<option value='BUI/ACAD/SS/427'>University Chaplin</option>
				<option value='BUI/ACAD/SS/427'>Dean of Student Affairs</option>
				<option value='BUI/ACAD/SS/427'>All Provosts List</option>
				</select>
              </div>
              <div class='modal-footer'>
                <button type='button' class='btn btn-outline pull-left' data-dismiss='modal'>Close</button>
                <button  class='btn btn-outline' type='submit' name='send'>Send</button>
              </div>
             
            </div>
            <!-- /.modal-content -->
          </div>
          <!-- /.modal-dialog -->
        </div>
		";
		
		
		
		$comments = getmemocomments($memo[7]);
	   if(count($comments) > 0){
	   $init = date("d M. Y", $comments[0][3]);
	  echo   "
      <div class='row'>
        <div class='col-md-12'>
         
          <ul class='timeline'>
            
            <li class='time-label'>
                  <span class='bg-red'>
                    $init
                  </span>
            </li>
            ";
	   
	   
	   
	    foreach($comments as $comment){
	        $comdate = date("d M. Y", $comment[3]);
	        if($comdate != $init){
	           echo" <li class='time-label'>
                  <span class='bg-red'>
                    $comdate
                  </span>
            </li> ";
	        }
	        $time = date("h:i:s", $comment[3]);
	        echo " <li>
              <i class='fa fa-envelope bg-blue'></i>

              <div class='timeline-item'>
                <span class='time'><i class='fa fa-clock-o'></i>$time</span>

                <h3 class='timeline-header'><a href='#'>Post(name of staff)</a> Commented</h3>

                <div class='timeline-body'>
                  $comment[2]
                </div>
               
              </div>
            </li>
           
            ";
	        
	        
	        
	        
	        
	    }
	    echo " <li>
              <i class='fa fa-clock-o bg-gray'></i>
            </li>
          </ul>
        </div>
        <!-- /.col -->
      </div>";
	    
	   }
		
?>

  
           
            
           
           
           
           
            


<br>
<br>
<br>
<h4>Comments</h4>
<textarea id="summernote"  name="comm" required>
    <?php 
        if($role[0] == 5){
            echo "<font color='red'>";
        }else{
            echo "<font color='black'>";
        }
    ?>
<br>
<font face="Times New Roman"  size="3">Best regards,
<?php
$dbc = connect();
$img  = getsignature($username);

echo "<br><img src='$img' width='10%' >";

echo "<br>
";

$name = aboutstaff( $username);
echo "$name[0] $name[1] $name[2] $name[3]";
?>
</font>
</textarea>
</form>
<button class="btn btn-info" data-toggle="modal" data-target="#modal-info">Send To</button>






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




<!-- REQUIRED JS SCRIPTS -->
 <script>
    $(document).ready(function() {
        $('#summernote').summernote({
  height: 200,                 // set editor height
  minHeight: null,             // set minimum height of editor
  maxHeight: null,             // set maximum height of editor
  focus: true                  // set focus to editable area after initializing summernote
});
		$('#summernote2').summernote({
  height: 200,                 // set editor height
  minHeight: null,             // set minimum height of editor
  maxHeight: null,             // set maximum height of editor
  focus: true                  // set focus to editable area after initializing summernote
});
    });
      $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()
      })
  </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>
<script src="bower_components/select2/dist/js/select2.full.min.js"></script>
<script>
  function setit(){
	  var title = $('#title').val();
	
	  $('#mtitle').text(title);
	  
  }
</script>
</body>
</html>
</body>
</html>