diff --git a/src/main/java/controller/homeTherapistServlet.java b/src/main/java/controller/homeTherapistServlet.java index 277b1b1..5631a26 100644 --- a/src/main/java/controller/homeTherapistServlet.java +++ b/src/main/java/controller/homeTherapistServlet.java @@ -9,8 +9,9 @@ import java.util.ArrayList; import javax.servlet.http.HttpSession; import javax.servlet.RequestDispatcher; -import model.entity.PersonalInfo; + import model.entity.*; +import model.service.personalinfo.PersonalInfo; @WebServlet("/homeTherapistServlet") public class homeTherapistServlet extends HttpServlet { @@ -25,6 +26,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t HttpSession session = request.getSession(); model.service.user.UserData userService = new model.service.user.UserData(); + model.service.personalinfo.PersonalInfo piService= new PersonalInfo(); ArrayList list_user=new ArrayList<>(); //String tipo=request.getParameter("type"); @@ -33,8 +35,10 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t session.setAttribute("list_user",list_user); + model.entity.PersonalInfo InfoLogged=piService.getPersonalInfoById(logged.getId()); + session.setAttribute("NameSurnameLogged",InfoLogged.getFirstname()+" "+InfoLogged.getLastname()); - response.sendRedirect("JSP/testTable.jsp"); + response.sendRedirect("JSP/homeTherapist.jsp"); } diff --git a/src/main/java/model/DAO/DAOPersonalInfo.java b/src/main/java/model/DAO/DAOPersonalInfo.java index 7a0d6f3..4eafbc7 100644 --- a/src/main/java/model/DAO/DAOPersonalInfo.java +++ b/src/main/java/model/DAO/DAOPersonalInfo.java @@ -1,10 +1,28 @@ package model.DAO; +import model.entity.PersonalInfo; +import model.entity.User; + import java.sql.Connection; import java.sql.PreparedStatement; +import java.sql.ResultSet; import java.sql.SQLException; public class DAOPersonalInfo { + + private PersonalInfo getPersonalInfoFromResultSet(ResultSet resultSet) throws SQLException { + PersonalInfo pi = new PersonalInfo(); + + pi.setIdUser(resultSet.getInt("ID_user")); + pi.setFirstname(resultSet.getString("Firstname")); + pi.setLastname(resultSet.getString("Lastname")); + pi.setDateOfBirth(resultSet.getDate("DateOfBirth")); + pi.setGender(resultSet.getString("Gender")); + pi.setAddress(resultSet.getString("Address")); + pi.setSsn(resultSet.getString("SSN")); + pi.setPhone(resultSet.getString("Phone")); + return pi; + } public boolean createRegistry(int id, String name, String surname) { Connection connection = null; PreparedStatement preparedStatementPersonalInfo = null; @@ -46,5 +64,47 @@ public boolean createRegistry(int id, String name, String surname) { return false; // Default to false if an exception occurs } + + public PersonalInfo getPersonalInfoById(int id) { + Connection connection = null; + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + + try { + + connection = DAOConnection.getConnection(); + String query = null; + + + query = "SELECT * FROM personal_info WHERE ID_user = ?"; + + + preparedStatement = connection.prepareStatement(query); + preparedStatement.setObject(1, id); + + resultSet = preparedStatement.executeQuery(); + + if (resultSet.next()) { + return getPersonalInfoFromResultSet(resultSet); + } + + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } finally { + try { + if (resultSet != null) resultSet.close(); + if (preparedStatement != null) preparedStatement.close(); + DAOConnection.releaseConnection(connection); + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } + } + + return null; // or you may throw an exception here + } + + } diff --git a/src/main/java/model/service/personalinfo/PersonalInfo.java b/src/main/java/model/service/personalinfo/PersonalInfo.java index 1b0e203..9ce4362 100644 --- a/src/main/java/model/service/personalinfo/PersonalInfo.java +++ b/src/main/java/model/service/personalinfo/PersonalInfo.java @@ -5,4 +5,5 @@ public class PersonalInfo { DAOPersonalInfo personalInfoDAO = new DAOPersonalInfo(); public boolean createRegistry(int id, String name, String surname) {return personalInfoDAO.createRegistry(id, name, surname);} + public model.entity.PersonalInfo getPersonalInfoById(int id) {return personalInfoDAO.getPersonalInfoById(id); } } diff --git a/src/main/webapp/CSS/homeTherapist.css b/src/main/webapp/CSS/homeTherapist.css index 04c2d2d..ed19b9b 100644 --- a/src/main/webapp/CSS/homeTherapist.css +++ b/src/main/webapp/CSS/homeTherapist.css @@ -1,3 +1,30 @@ +.table-container { + max-height: 350px; /* Altezza massima della tabella */ + overflow-y: auto; /* Rendi scorrevole solo l'asse Y quando necessario */ +} + +table { + width: 100%; + border-collapse: collapse; + border-spacing: 0 35px; /* Imposta uno spazio vuoto tra le righe */ +} + +tr { + + text-align: center; /* Centra il testo orizzontalmente */ + vertical-align: middle; /* Centra verticalmente */ +} + +td { + + text-align: center; /* Centra il testo orizzontalmente */ + vertical-align: middle; /* Centra verticalmente */ +} + + + +/*----*/ + html { margin: 0px; height: 100%; @@ -93,7 +120,7 @@ a { .element-home-logopedista .overlap-group { position: absolute; - width: 499px; + width: 600px; height: 61px; top: 54px; left: 76px; @@ -175,10 +202,8 @@ a { } .element-home-logopedista .element { - position: absolute; - width: 41px; + position: relative; top: 8px; - left: 2px; font-family: "Poppins", Helvetica; font-weight: 600; color: #199a8e; @@ -431,12 +456,13 @@ a { position: absolute; width: 102px; top: 467px; - left: 14px; + left: 0px; font-family: "Poppins", Helvetica; font-weight: 600; color: #221f1f; - font-size: 7px; + font-size: 10px; letter-spacing: 0; + text-align: center; /* Allinea il testo al centro orizzontalmente */ line-height: normal; } diff --git a/src/main/webapp/JSP/homeTherapist.jsp b/src/main/webapp/JSP/homeTherapist.jsp index e0d8420..4e55779 100644 --- a/src/main/webapp/JSP/homeTherapist.jsp +++ b/src/main/webapp/JSP/homeTherapist.jsp @@ -1,9 +1,14 @@ +<%@ page import="model.entity.*"%> +<%@ page import="java.util.ArrayList"%> +<%@ page import="java.text.SimpleDateFormat" %> +<%@ page import="java.util.Date" %> +
@@ -12,91 +17,85 @@
+
PAZIENTI
-
-
-
-
-
Inizio Terapia:  gg/mm/yyy
-
Nome Cognome
-
-
-
-
-
-
72%
-
-
-
-
-
-
-
-
-
Inizio Terapia:  gg/mm/yyy
-
Nome Cognome
-
-
-
-
-
-
-
-
Inizio Terapia:  gg/mm/yyy
-
Nome Cognome
-
-
-
-
-
-
-
-
-
Inizio Terapia:  gg/mm/yyy
-
Nome Cognome
-
-
-
-
-
-
-
-
-
Inizio Terapia:  gg/mm/yyy
-
Nome Cognome
-
-
-
-
-
-
-
72%
-
-
-
72%
-
-
-
72%
-
-
-
72%
-
+
+ + + + + + + + + + + + <% + if(session.getAttribute("list_user")!=null) { + @SuppressWarnings("unchecked") + ArrayList list_user=(ArrayList) session.getAttribute("list_user"); + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + for(UserInfo u: list_user){ + %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
- -
- -
- -
- -
-
-
-
+ <% + } + } + %> + +
Inizio Terapia Progressi
<%=u.getFirstname()%> <%=u.getLastname()%><%= sdf.format(u.getActivationDate()) %> +
72%
+
<%=u.getFirstname()%> <%=u.getLastname()%><%= sdf.format(u.getActivationDate()) %> +
72%
+
<%=u.getFirstname()%> <%=u.getLastname()%><%= sdf.format(u.getActivationDate()) %> +
72%
+
<%=u.getFirstname()%> <%=u.getLastname()%><%= sdf.format(u.getActivationDate()) %> +
72%
+
<%=u.getFirstname()%> <%=u.getLastname()%><%= sdf.format(u.getActivationDate()) %> +
72%
+
<%=u.getFirstname()%> <%=u.getLastname()%><%= sdf.format(u.getActivationDate()) %> +
72%
+
-
PAZIENTI
+
@@ -109,7 +108,7 @@ -
Dr Nome Cognome
+
Dr.
<%=session.getAttribute("NameSurnameLogged")%>
@@ -119,4 +118,4 @@
- + \ No newline at end of file