<?php 

include('../dbconnect.php');
ob_start();
session_start();

if( !isset($_SESSION['user']) ) {
 header("Location: ../index.php");
 exit;
}

$salarycode = $_GET['salarycode'];

$comp = "SELECT * FROM salarypackage WHERE salarycode='$salarycode' ";
$result= mysqli_query($conn, $comp);
$row = mysqli_fetch_assoc($result);

$level = $row['level'];


?>
<!DOCTYPE html>
<html lang="en">

  <head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Super Admin | View Salary Package</title>

    <!-- Bootstrap core CSS-->
    <link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom fonts for this template-->
    <link href="../vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">

    <!-- Page level plugin CSS-->
    <link href="../vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">

    <!-- Custom styles for this template-->
        <link href="../css/sb-admin.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">
    <link rel="icon" href="../images/logo.jpg" type="image/gif" sizes="16x16">

  </head>

   <body id="page-top">
	<div id="preloader">
   		<img src="../images/loaderS.gif" alt="processing..." height="150px" width="200px"/>
	</div>

  <div id="pageloader">
   <img src="../images/loaderS.gif" alt="processing..." height="150px" width="200px"/>
</div>


    <nav class="navbar navbar-expand navbar-dark bg-dark static-top">

      <a class="navbar-brand mr-1" href="index.html">Super Admin</a>

      <button class="btn btn-link btn-sm text-white order-1 order-sm-0" id="sidebarToggle" href="#">
        <i class="fas fa-bars"></i>
      </button>

      <!-- Navbar Search -->
    

      <!-- Navbar -->
      <ul class="navbar-nav ml-auto ml-md-0">
       

    </nav>

      <!-- Sidebar -->
      
      <?php 
      $salarypack ="active";
      $admintools ="active";
      include('sidebar.php');
      ?>
      <div id="content-wrapper">

        <div class="container-fluid">

          <!-- Breadcrumbs-->
          <ol class="breadcrumb">
            <li class="breadcrumb-item">
              <a href="salarypackage.php">Salary Package</a>
            </li>
            <li class="breadcrumb-item active">View Salary</li>
          </ol>
          <div class="row justify-content-lg-center p-3">
                    <div class="col-sm-12 form-group required">
                        <h4> <?php echo $salarycode.' <br/> '.$level?></h4>
                    </div>
            
            <table class="table table-hover">
              <thead class="thead-dark">
                
                <tr>
                
            
                    <?php 
                    
                    $sql = "SELECT * FROM compensation JOIN monetary ON compensation.monetaryid = monetary.monetaryid WHERE salarycode='$salarycode' ORDER BY compensation.monetaryid";
                    $result = mysqli_query($conn, $sql);
    
                    
    
                    if (mysqli_num_rows($result) > 0) {
                
                        while($row = mysqli_fetch_assoc($result)) {
                            echo'
                            
                            
                            <th>'.$row['name'].'</th>
            
                            
                            </td>
                            ';
    
                        }
                    } else {
                        echo "0 results";
                    }
                    echo '<th>TOTAL </th>';
                    ?>
                </tr>
                </thead>
                <tbody>
                <tr>
                <?php 
                    
                    $sql1 = "SELECT * FROM compensation WHERE salarycode='$salarycode'  ORDER BY monetaryid";
                    $result1 = mysqli_query($conn, $sql1);
    
                    
    
                    if (mysqli_num_rows($result1) > 0) {
                
                        while($row1 = mysqli_fetch_assoc($result1)) {
                            echo'
                            
                            
                            <th>₱ '.$row1['amount'].'</th>
            
                            
                            
                            ';
                            $amount = $row1['amount'];
                            $amounts = str_replace(',','',$amount);


                     

                                      $total += $amounts;
    
                        }
                    } 
                   
                    else {
                        echo "0 results";

                    }
                    echo '<td> <b> &#8369 &nbsp'.number_format($total,2).' </b></td>';
                    mysqli_close($conn);
                    ?>
    
    
                </tr>

            
                </tbody>
                </table>
                <div class="col-sm-12 content-end">
                    <a href="salarypackage.php" class="btn btn-danger"> <i class="fa fa-angle-left"></i>  Back </a>
                        <a href="updatesalary.php?salarycode=<?php echo $salarycode?>" class="btn btn-success"> <i class="fa fa-edit"></i>  Update </a>
                        
                </div>
               

            </div>

          <!-- Icon Cards-->
      
        <!-- /.container-fluid -->

        <!-- Sticky Footer -->


      </div>
      <!-- /.content-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
      <i class="fas fa-angle-up"></i>
    </a>

    <!-- Logout Modal-->
    <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>
          </div>
          <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
          <div class="modal-footer">
            <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
            <a class="btn btn-primary" href="login.html">Logout</a>
          </div>
        </div>
      </div>
    </div>

    <!-- Bootstrap core JavaScript-->
    <script src="../vendor/jquery/jquery.min.js"></script>
    <script src="../vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="../vendor/jquery-easing/jquery.easing.min.js"></script>

    <!-- Page level plugin JavaScript-->
    <script src="../vendor/chart.js/Chart.min.js"></script>
    <script src="../vendor/datatables/jquery.dataTables.js"></script>
    <script src="../vendor/datatables/dataTables.bootstrap4.js"></script>

    <!-- Custom scripts for all pages-->
    <script src="../js/sb-admin.min.js"></script>

    <!-- Demo scripts for this page-->
    <script src="../js/demo/datatables-demo.js"></script>
    <script src="../js/demo/chart-area-demo.js"></script>

          <script language="javascript" type="text/javascript">
            $(document).ready(function(){
            $("form").on("submit", function(){
                $("#pageloader").fadeIn();
            });//submit

             $('#preloader').fadeOut();
            });//document ready



        </script>
</body>

</html>
