<%@page import="project.ConnectionProvider"%>
<%@page import="java.sql.*"%>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">

<html>
    <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <script src='https://kit.fontawesome.com/a076d05399.js'></script>
        <link rel="stylesheet" href="css/addNewProduct-style.css">
        <title>View Leave Details</title>
        <style>
            .back
            {
                color: navy;
                margin-left: 2.5%
            }
            h3{
                color: navy;
                text-align: left;
                padding-left: 50px;
            }
            .Heading{
                background-color: lightsalmon;
                padding: 2px;
            }
            .block {
                align-self: center;
                width: 100%;
                padding: 30px 30px;
                background-color: whitesmoke;
                border-radius: 5px;
           
            }

        </style>
    </head>
    <body>
        <div class="modal-content animate">
            <%
                String msg = request.getParameter("msg");
                if ("done".equals(msg)) {
            %>
            <div class="alert"> 
                <button class="closebtn"><i class="fa fa-close"></i></button>
                <h3 class="alert">Leave Application Submitted Successfully!</h3>
            </div>
            <%}%>
            <%
                if ("wrong".equals(msg)) {
            %> 
            <div class="alert"> 
                <button class="closebtn"><i class="fa fa-close"></i></button>
                <h3 class="alert">Some thing went wrong! Try again!</h3>
            </div>
            <%}%>
            <%
                if ("statusUpdated".equals(msg)) {
            %> 
            <div class="alert"> 
                <button class="closebtn"><i class="fa fa-close"></i></button>
                <h3 class="alert">Leave Application status is updated</h3>
            </div>
            <%}%>
        </div>
        <h2><a class="back" href="adminHome.jsp"><i class='fas fa-arrow-circle-left'> Back</i></a></h2>
        <%
            String vid = request.getParameter("req_id");
          
            try {
                Class.forName("com.mysql.jdbc.Driver");
                Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/CLINIHR", "root", "Clinica123");
                Statement st = con.createStatement();
                ResultSet rs = st.executeQuery("select * from leave_app inner join users where leave_app.emp_code=users.emp_code and leave_app.req_id='" + vid + "'");
                while (rs.next()) {
        %>
        
           
                <form action="HRLeaveAppStatusUpdate.jsp?req_id=<%=rs.getString(1)%>" method="post">
                    <input type="hidden" name="id" value="<%out.println(vid);%>">

                    <div class="Heading">   
                        <h3>Leave Details</h3>
                        
                    </div>
                    <table class="block">
                        <tr>
                        <td> 
                        <h3>Employee Name</h3>
                        <input class="input-style" type="text" name="name"  value="<%=rs.getString(16)%> <%=rs.getString(18)%>" disabled>
                        </td>
                        <td> 
                        <h3>Employee Code</h3>
                        <input class="input-style" type="text" name="name"  value="<%=rs.getString(2)%>" disabled>
                        </td>
                        <td> 
                        <h3>Nature Of Leave</h3>
                        <input class="input-style" type="text" name="nature_of_leave"  value="<%=rs.getString(4)%>" disabled>
                        </td>
                        </tr>
                        <tr>
                        <td> 
                        <h3>Days Applied</h3>
                        <input class="input-style" type="text" name="days_applied"  value="<%=rs.getString(5)%>" disabled>
                        </td>
                        <td> 
                        <h3>From date</h3>
                        <input class="input-style" type="date" name="date_from" value="<%=rs.getString(6)%>" disabled> 
                        </td>
                        <td> 
                        <h3>To Date</h3>
                        <input class="input-style" type="date" name="date_to"  value="<%=rs.getString(7)%>" disabled>
                        </td>
                        </tr>
                        <tr>
                        <td> 
                        <h3>If half Day</h3>
                        <input class="input-style" type="text" name="half_day"  value="<%=rs.getString(8)%>" disabled >
                        </td>
                        <td> 
                        <h3>Reason For Taking Leave</h3>
                        <input class="input-style" type="text" name="reason"  value="<%=rs.getString(9)%>" disabled>
                        </td>                        
                        <td> 
                        <h3>Contact Number During Leave</h3>
                        <input class="input-style" type="text" name="contact_number"  value="<%=rs.getString(10)%>" disabled>
                        </td>
                        </tr>
                        <tr>
                        <td> 
                        <h3>Contact Address</h3>
                        <input class="input-style" type="text" name="contact_address"  value="<%=rs.getString(11)%>" disabled>
                        </td>
          
                            <td> 
                        <h3>Allocated Person</h3>
                        <input class="input-style" type="text" name="allocated_person"  value="<%=rs.getString(12)%>" disabled >
                        </td>
                       
                            <td>
                        <h3>Status</h3>
                        <select name="status" class="input-style" required>
                            <option value="<%=rs.getString(14)%>" disabled selected><%=rs.getString(14)%></option>
                                <option value="Approved">Approve</option>
                                <option value="Rejected">Reject</option>
                                <option value="Discussion">Let's Discuss</option>
                            </select></td>
                    </tr>
                       </table>              
                    <button class="button">Update Status <i class='far fa-arrow-alt-circle-right'></i></button>
                </form>
            </div>
            <%
                    }
                } catch (Exception e) {
                    out.println(e);
                }
            %>
  
    <br><br><br>
</body>
</html>