String id = request.getParameter("txtId");
String cek = request.getParameter("txtCek");
String idkaryawan = request.getParameter("txtIdKaryawan");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("SisInfPengambilanCutiPU");
EntityManager em = emf.createEntityManager();
HistoryCutiDAO daoPending = new HistoryCutiDAOImpl(em);
if (cek.equalsIgnoreCase("true")) {
KaryawanDAO kdao = new KaryawanDAOImpl(em);
Karyawan k = new Karyawan();
k = kdao.get(Long.parseLong(idkaryawan));
if (Integer.parseInt(k.getSisacuti()) > 0) {
daoPending.approveCuti(Long.parseLong(id), "Accept");
kdao.updateSisaCuti(Long.parseLong(idkaryawan), Integer.parseInt(k.getSisacuti()) - 1 + "");
} else {
out.print("Sisa Cuti Tidak Memenuhi");
}
} else if (cek.equalsIgnoreCase("false")) {
daoPending.approveCuti(Long.parseLong(id), "Denied");
}
KaryawanDAO kDao = new KaryawanDAOImpl(em);
kDao.updateNotifikasi(Long.parseLong(idkaryawan), "true");
RequestDispatcher req = request.getRequestDispatcher("administrator/home.jsp");
response.sendRedirect("administrator/home.jsp");