<?php 

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

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




?>
<!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>Tools</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">


  </head>

  <body id="page-top" onload=display_ct();>

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




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

        <div class="container-fluid">

          <!-- Breadcrumbs-->
          <ol class="breadcrumb">

            <li class="breadcrumb-item active">Employee Tools</li>
          </ol>
            <div class="row">
                <div class="col-sm-12">
                <h5>Employee Tools</h5>
                <?php 
                $id= $_GET['id'];
                 $sql = "SELECT * FROM empinfo WHERE empid='$id' ";
                $res= $conn->query($sql);
                $row = $res->fetch_assoc();
                
                ?>
                
                <form action="" method="post">
                    <div class="row">
                        <div class="col-lg-1"><input type="text" class="form-control" value="<?php echo $_GET['id']?>" readOnly></div>
                        <div class="col-lg-3"><input type="text" class="form-control" value="<?php echo $row['firstname'].' '.$row['surname']?>" readOnly></div>
                        <div class="col-lg-4">
                            <select name="type" id="type" class="form-control">
                                <option value="Individual">Individual</option>
                                <option value="Shared">Shared</option>
                            </select>


                        </div>
                        <div class="col-lg-4">
                      
                            <button type="button" id="modalb" class="btn btn-success" data-toggle="modal" data-target="#indimodal"> <i class="fa fa-plus"></i> Add</button>
                        </div>
                    </div>

                </form>
                <table class="table table-striped" id="emptable">
                    <thead class="thead-dark">
                        <th>Tools Name </th>
                        <th>Username </th>
                        <th>Password </th>
                        <th> Description </th>
                        <th> Type </th>
                        <th> Action </th>
                    </thead>
                    <tbody>
                    
                        <?php  $toolslist = '1'; 
                        include('tbldata.php'); ?>
                    </tbody>

                </table>

            


                
            
            </div>


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

        <!-- Sticky Footer -->

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

    </div>
    <!-- MODAL -->
    <div class="modal fade" id="indimodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
        <form method='POST' action='form.php'>    
            <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Add Employee Individual Tools</h5>
                        <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <input type="hidden" name="empid" value="<?php echo $_GET['id']?>">
                        <div class="row">
                            <div class="col-sm-6">
                                <label for="toolsusername" >Tools</label>
                               <!--  <input type="text" class="form-control" name="toolsname" id="toolsname" value="<?php echo $toolsname?>" placeholder="Tools" readonly required> -->
                                <input type="hidden" id="toolsid" name="toolsid">
                                <select name="toolsname" class="form-control" id="toolsname">
                                <?php
                                $sql =  "SELECT * FROM individualshared WHERE type='Individual'";
                                $res = $conn->query($sql);
                                
                                while($row = $res->fetch_assoc()){
                                    echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';

                                }
                                ?>
                            </select>
                            </div>
                            <div class="col-sm-6">
                                <label for="toolsusername" >Type</label>
                                <input type="text" class="form-control" name="toolstype" value="Individual" placeholder="Password" required readonly>
                                <?php ?>
                            </div>
                            <div class="col-sm-6">
                                <label for="toolsusername" >Username</label>
                                <input type="text" class="form-control" name="toolusername" placeholder="Username" required>
                            </div>
                            <div class="col-sm-6">
                                <label for="toolpassword" >Password</label>
                                <input type="text" class="form-control" name="toolpassword" placeholder="Password" required>
                            </div>
                            <div class="col-sm-12">
                                <label for="toolsdesc" >Description</label>
                                <textarea name="toolsdesc" class="form-control"   cols="30" rows="5" placeholder="Description" required></textarea>
                            </div>
                        </div>



                    </div>
               
                    <div class="modal-footer">
                        <input type="submit" name="indibutton" class="btn btn-success" name="addindi" value="✓ Yes" style="margin-right: 5px;" >
                        <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>
                                    
                    </div>
                </div>
                
            </div>
        </form>
    </div>

    <div class="modal fade" id="shrdmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <form method="POST" action="form.php">
            <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Add Employee Shared Tools</h5>
                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                    </button>
                </div>
                    <div class="modal-body">
                    <div class="row">
                        <div class="col-sm-6">
                            <input type="hidden" name="empid" value="<?php echo $_GET['id']?>">
                            <label for="toolsusername" >Tools</label>
                           <!--  <input type="text" class="form-control" name="sharedname"  id="sharedname"placeholder="Tools" readonly required> -->
                            <input type="hidden"  name="sharedid" id="sharedid">
                            <select name="sharedname" class="form-control" id="sharedname">
                                <?php
                                $sql =  "SELECT * FROM individualshared WHERE type='Shared'";
                                $res = $conn->query($sql);
                                
                                while($row = $res->fetch_assoc()){
                                    echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';

                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-sm-6">
                            <label for="toolsusername" >Type</label>
                            <input type="text" class="form-control" name="sharedtype" value="Shared" placeholder="Password" readonly>
                        </div>
                        <div class="col-sm-6">
                            <label for="toolsusername" >Username</label>
                            <input type="text" class="form-control" name="sharedusername" placeholder="Username">
                        </div>
                        <div class="col-sm-6">
                            <label for="toolpassword" >Password</label>
                            <input type="text" class="form-control" name="sharedpassword" placeholder="Password">
                        </div>
                        <div class="col-sm-12">
                            <label for="toolsdesc" >Description</label>
                            <textarea name="shareddesc" class="form-control" rows="4" cols="50" placeholder="Description"></textarea>
                        </div>

                
                    </div>
                        <div class="modal-footer"> 
                        <input type="submit" name="sharedbutton" class="btn btn-success" name="addshrd" value="✓ Yes" style="margin-right: 5px;" >
                            <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>

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

            $(document).ready( function () {
                $('#emptable').DataTable();

                $('#type').on('change', function(){

                    if($(this).val() == 'Individual'){
                     
                        $('#modalb').attr('data-target', '#indimodal');

                    }else{

                        $('#modalb').attr('data-target', '#shrdmodal');

                    }

                    

                });
            } );



    </script>
</body>

</html>
