<!DOCTYPE html>
<%@page import="java.sql.*"%>
<%@include file="adminHeader.jsp" %>
<html>
    <head>

        <link rel="stylesheet" href="css/home-style.css">
        <link rel="stylesheet" href="css/alerts.css"> 
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
        <title>Register New Employee</title>
                    <style> 
 
.block {
  align-self: center;
  width: 100%;
  padding: 30px 30px;
  background-color: white;
  text-align: center;
  border-radius: 5px 0 0 5px;
}
[type=text],[type=email],[type=date],[type=file], [type=password],select,option {
  display: block;
  margin: 0 auto;
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(0,0,0,.2);
  height: 45px;
  line-height: 45px;  
  margin-bottom: 10px;
  font-size: 1em;
  color: black;
}

[type=submit] {
     align-self: center;
     
  margin-top: 25px;
 width: 100%;
  border: 0;
  background-color: #0080FF;
  border-radius: 5px;
  height: 50px;
  color: white;
  font-weight: 400;
  font-size: 1em;
}

[type='text']:focus {
  outline: none;
  border-color: #53CACE;
}
    </style>
    </head>
    <body style="background-color: #f2f2f2">
        <!--<h2><a class="back" href="adminHome.jsp"><i class='fas fa-arrow-circle-left'> Back</i></a></h2>-->
        <div class='modal-content animate'>
            <%
                String msg = request.getParameter("msg");
                if ("valid".equals(msg)) {
            %>
            <div class="alert">
                <button class="closebtn"><i class="fa fa-close"></i></button>
                <strong>New Employee Successfully Registered !</strong>
            </div>
            <% } %>

            <%
                if ("invalid".equals(msg)) {
            %>
            <div class="alert">
                <button class="closebtn"><i class="fa fa-close"></i></button>
                <strong>Something Went Wrong! Please Try Again !</strong>
            </div>
            <% }%>
            <%
                if ("invalidEmail".equals(msg)) {
            %>
            <div class="alert">
                <button class="closebtn"><i class="fa fa-close"></i></button>
                <strong>Invalid Email ID! Please Try Again !</strong>
            </div>
            <% }%>
            <%
                if ("invalidPassword".equals(msg)) {
            %>
            <div class="alert">
                <button class="closebtn"><i class="fa fa-close"></i></button>
                <strong>Invalid Password! Please Try Again!</strong>
            </div>
            <% }%>
        </div>
        
        <script>
            var close = document.getElementsByClassName("closebtn");
            var i;

            for (i = 0; i < close.length; i++) {
                close[i].onclick = function () {
                    var div = this.parentElement;
                    div.style.opacity = "0";
                    setTimeout(function () {
                        div.style.display = "none";
                    }, 600);
                }
            }
        </script>
        
        
<%
        int id =1;
        try {
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/CLINIHR", "root", "Clinica123");
        Statement ps = con.createStatement();                    
        ResultSet rs = ps.executeQuery("SELECT max(id) from users");
        while(rs.next()){
             id=rs.getInt(1);
             id=id+1;
        }
        }
        catch(Exception e){
        out.println(e);
        } 
%>
        <div style="text-align: center"><b><h3>Register New Employee</h3></b></div>
            <div>
                <form action="ImgUpload" method="post" enctype="multipart/form-data">
                    <input type="hidden" name="id" value="<%out.println(id);%>">
                    <table class="block">
                        
                    <tr>
                        <td colspan="2">
                            <h3 style="float: left">Upload Image</h3>
                        <input type="file" name="file" placeholder="Name" required>
                        </td>
                    </tr>
                    
                    <tr>
                        <td><input type="text" placeholder="First Name" name="first_name"  required></td>
                        <td><input type="text" placeholder="Last Name" name="last_name"  required></td>
                    </tr>                   

                    <tr>
                    <td><input type="text" placeholder="Employee Code" name="emp_code"  required></td>
                    <td><input type="date" placeholder="Joining Date" name="joining_date"  required></td>
                    </tr>
                    <tr>
                        <td><input type="text" placeholder="Department Name" name="department"  required></td>
                        <td><input type="text" placeholder="Designation" name="designation"  required></td>
                    </tr>
                    
                    <tr>
                        <td>
                            <input type="text" placeholder="Line Manager Name" name="line_manager"  required>
                        </td>
                        <td>
                            <input type="text" placeholder="Line Manager email ID" name="LMemail"  required>
                        </td>
                    </tr>
                    

                    <tr>
                        <td>
                    <h3>Status</h3>
                    <select class="input-style" name="status">
                        <option value="Select" selected disabled>Select Status</option>
                        <option value="Working">Working</option>
                        <option value="Resigned">Resigned</option>
                        <option value="Terminated">Terminated</option>
                    </select>
                    </td>
                    <td>
                    <h3>role</h3>
                    <select class="input-style" name="role">
                        <option value="Select" selected disabled>Select Role</option>
                        <option value="Admin">Admin</option>
                        <option value="Employee">Employee</option>
                        <option value="Line Manager">Line Manager</option>
                        <option value="Terminated">Senior Management</option>
                    </select>
                    </td>
                    </tr>
                    <tr>
                        <td><input type="email" placeholder="Email Id of employee" name="email"  required></td>
                        <td><input type="password" placeholder="Password ex:Pass@123" name="password" required></td>
                    </tr>
                    </table>
                    <div style="padding: 0px 30px 0px 30px; ">                   
                    <button style="background-color: navy; color: white; width: 100%; height: 50px; border-radius: 25px; border-style: none"> Register <i class='far fa-arrow-alt-circle-right'></i> </button>
                    </div>
                </form>
                
            </div> 
        

    </body>
</html>