From 3c1ef5e07bdbeb034a97ded6805c188de130100b Mon Sep 17 00:00:00 2001 From: Lawan Samarasekara Date: Tue, 13 Aug 2024 15:49:27 +0530 Subject: [PATCH 1/8] Signed-off-by: Lawan Samarasekara --- .../channel/ChannelReportTemplateController.java | 5 +++++ .../channel/reports/daily_session_counts.xhtml | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/divudi/bean/channel/ChannelReportTemplateController.java b/src/main/java/com/divudi/bean/channel/ChannelReportTemplateController.java index de2641879c..01ed9d96f1 100644 --- a/src/main/java/com/divudi/bean/channel/ChannelReportTemplateController.java +++ b/src/main/java/com/divudi/bean/channel/ChannelReportTemplateController.java @@ -713,7 +713,12 @@ public void processAndfillDailySessionCounts() { m.put("ins", institution); j += " and si.institution=:ins "; } + + m.put("fd", fromDate); + m.put("td", toDate); + sessionInstances = sessionInstanceFacade.findByJpql(j, m); + System.out.println("sessionInstance = " + sessionInstances); for (SessionInstance si : sessionInstances) { fillBillSessions(si); } diff --git a/src/main/webapp/channel/reports/daily_session_counts.xhtml b/src/main/webapp/channel/reports/daily_session_counts.xhtml index 7903adde2a..e226d53f77 100644 --- a/src/main/webapp/channel/reports/daily_session_counts.xhtml +++ b/src/main/webapp/channel/reports/daily_session_counts.xhtml @@ -134,7 +134,7 @@ - + @@ -143,7 +143,7 @@ - + @@ -152,7 +152,7 @@ - + @@ -161,7 +161,7 @@ - + @@ -170,7 +170,7 @@ - + @@ -179,7 +179,7 @@ - + From d344bd55f317fd2f58eb350b9b6f2cdf4e2a7057 Mon Sep 17 00:00:00 2001 From: Lawan Samarasekara Date: Tue, 13 Aug 2024 16:57:34 +0530 Subject: [PATCH 2/8] Signed-off-by: Lawan Samarasekara --- .../reports/daily_session_counts.xhtml | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/main/webapp/channel/reports/daily_session_counts.xhtml b/src/main/webapp/channel/reports/daily_session_counts.xhtml index e226d53f77..39d26a79c4 100644 --- a/src/main/webapp/channel/reports/daily_session_counts.xhtml +++ b/src/main/webapp/channel/reports/daily_session_counts.xhtml @@ -67,7 +67,7 @@ - - @@ -114,7 +113,6 @@ - r @@ -133,54 +131,36 @@ - - - - - - - + - - - - - + + - - - - - - - - - From 8448c77cb394263f9bf48d2d88cb4cfec411f39b Mon Sep 17 00:00:00 2001 From: Lahiru Jayakody Date: Tue, 13 Aug 2024 17:07:54 +0530 Subject: [PATCH 3/8] Refactor booking session reschedule handling. Updated booking controller and UI to correctly handle properties related to rescheduled sessions. Replaced references to `referenceBillSession` with `rescheduledFromBillSession` and `rescheduledToBillSession` for clarity and consistency. Added conditional logic for payment handling in `BookingControllerViewScopeMonth`. --- .../channel/BookingControllerViewScope.java | 58 ++++++------ .../BookingControllerViewScopeMonth.java | 6 +- .../com/divudi/bean/web/NoCacheFilter.java | 36 ++++++++ .../java/com/divudi/entity/BillSession.java | 25 ++++- src/main/webapp/channel/manage_booking.xhtml | 90 +++++++++--------- .../channel/manage_booking_by_date.xhtml | 92 +++++++++---------- 6 files changed, 182 insertions(+), 125 deletions(-) create mode 100644 src/main/java/com/divudi/bean/web/NoCacheFilter.java diff --git a/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java b/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java index f9c9083075..03c89d8e8f 100644 --- a/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java +++ b/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java @@ -371,7 +371,7 @@ public void sessionReschedule() { JsfUtil.addErrorMessage("Cannot reschedule: This bill session has been Alrady Recheduled To Another Session !"); } - if (selectedBillSession.getReferenceBillSession() == null) { + if (selectedBillSession.getReferenceBillSession() == null) { // TODO: can remove after ReferenceBillSession is deprecated createBillSessionForReschedule(selectedBillSession, getSelectedSessionInstanceForRechedule()); JsfUtil.addSuccessMessage("Reschedule Successfully"); sendSmsOnChannelBookingReschedule(); @@ -439,7 +439,7 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si) newBillSession.copy(bs); newBillSession.setBill(printingBill); newBillSession.setBillItem(savingBillItem); - newBillSession.setReferenceBillSession(bs); + newBillSession.setRescheduledFromBillSession(bs); newBillSession.setCreatedAt(new Date()); newBillSession.setCreater(getSessionController().getLoggedUser()); newBillSession.setSessionInstance(getSelectedSessionInstanceForRechedule()); @@ -468,7 +468,6 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si) savingBillItem.setHospitalFee(billBeanController.calFeeValue(FeeType.OwnInstitution, savingBillItem)); savingBillItem.setStaffFee(billBeanController.calFeeValue(FeeType.Staff, savingBillItem)); savingBillItem.setBillSession(newBillSession); - getBillSessionFacade().edit(newBillSession); printingBill.setHospitalFee(billBeanController.calFeeValue(FeeType.OwnInstitution, printingBill)); printingBill.setStaffFee(billBeanController.calFeeValue(FeeType.Staff, printingBill)); printingBill.setSingleBillItem(savingBillItem); @@ -511,7 +510,7 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si) } getBillSessionFacade().create(newBillSession); bs.setRecheduledSession(true); - bs.setReferenceBillSession(newBillSession); + bs.setRescheduledToBillSession(newBillSession); getBillSessionFacade().edit(bs); newBillSessionForSMS = newBillSession; System.out.println("newBillSessionForSMS = " + newBillSessionForSMS); @@ -591,8 +590,10 @@ private Bill createBillForChannelReshedule(BillSession bs) { bill.setDeptId(deptId); bill.setInsId(deptId); - bill.setPaidAmount(bs.getBill().getPaidAmount()); - bill.setPaidAt(new Date()); + if (bill.getBillTypeAtomic() == BillTypeAtomic.CHANNEL_RESHEDULE_WITH_PAYMENT) { + bill.setPaidAmount(getSelectedSessionInstanceForRechedule().getOriginatingSession().getTotal()); + bill.setPaidAt(new Date()); + } bill.setBillDate(new Date()); bill.setBillTime(new Date()); @@ -1046,14 +1047,14 @@ public void addSingleDateToToDate() { cal.setTime(getFromDate()); cal.add(Calendar.DATE, 1); toDate = cal.getTime(); - listAllSesionInstances(); - filterSessionInstances(); + listAndFilterSessionInstances(); +// filterSessionInstances(); } public void addToDayToToDate() { toDate = new Date(); - listAllSesionInstances(); - filterSessionInstances(); + listAndFilterSessionInstances(); +// filterSessionInstances(); } public void addTwoDays() { @@ -1061,8 +1062,8 @@ public void addTwoDays() { cal.setTime(getFromDate()); cal.add(Calendar.DATE, 2); toDate = cal.getTime(); - listAllSesionInstances(); - filterSessionInstances(); + listAndFilterSessionInstances(); +// filterSessionInstances(); } public void addSevenDays() { @@ -1070,8 +1071,8 @@ public void addSevenDays() { cal.setTime(getFromDate()); cal.add(Calendar.DATE, 7); toDate = cal.getTime(); - listAllSesionInstances(); - filterSessionInstances(); + listAndFilterSessionInstances(); +// filterSessionInstances(); } public void addMonth() { @@ -1079,8 +1080,8 @@ public void addMonth() { cal.setTime(getFromDate()); cal.add(Calendar.MONTH, 1); toDate = cal.getTime(); - listAllSesionInstances(); - filterSessionInstances(); + listAndFilterSessionInstances(); +// filterSessionInstances(); } public void addMonthNew() { @@ -1171,6 +1172,15 @@ public void listCompleted() { listAndFilterSessionInstances(); } + public void listCancelled() { + listAll = false; + listPending = false; + listCancelled = true; + listOngoing = false; + listCompleted = false; + listAndFilterSessionInstances(); + } + public void addBillSessionData() { if (configOptionApplicationController.getBooleanValueByKey("Calculate All Patient Count When Loading Channel Booking By Dates")) { if (sessionInstances != null) { @@ -1582,7 +1592,7 @@ public void init() { needToFillSessionInstances = viewScopeDataTransferController.getNeedToFillSessionInstances(); if (needToFillSessionInstances == null || needToFillSessionInstances != false) { - listAllSesionInstances(); + listAndFilterSessionInstances(); } selectedSessionInstance = viewScopeDataTransferController.getSelectedSessionInstance(); @@ -1632,7 +1642,7 @@ public String navigateToChannelBookingFromMenuByDate() { if (financialTransactionController.getNonClosedShiftStartFundBill() != null) { fromDate = new Date(); toDate = new Date(); -// listAllSesionInstances(); +// listAndFilterSessionInstances(); prepareForNewChannellingBill(); return "/channel/channel_booking_by_date?faces-redirect=true"; } else { @@ -1642,7 +1652,7 @@ public String navigateToChannelBookingFromMenuByDate() { } else { fromDate = new Date(); toDate = new Date(); -// listAllSesionInstances(); +// listAndFilterSessionInstances(); // prepareForNewChannellingBill(); return "/channel/channel_booking_by_date?faces-redirect=true"; } @@ -1748,16 +1758,6 @@ public String navigateToChannelQueueFromConsultantRoom() { return "/channel/channel_queue?faces-redirect=true"; } - public void listAllSesionInstances() { - sessionInstances = channelBean.listSessionInstances(fromDate, toDate, null, null, null); - if (configOptionApplicationController.getBooleanValueByKey("Calculate All Patient Count When Loading Channel Booking By Dates")) { - for (SessionInstance s : sessionInstances) { - fillBillSessions(s); - } - } - filterSessionInstances(); - } - public void listOngoingSesionInstances() { sessionInstances = channelBean.listSessionInstances(fromDate, toDate, true, null, null); filterSessionInstances(); diff --git a/src/main/java/com/divudi/bean/channel/BookingControllerViewScopeMonth.java b/src/main/java/com/divudi/bean/channel/BookingControllerViewScopeMonth.java index bade30a0b3..6d7d3dfb37 100644 --- a/src/main/java/com/divudi/bean/channel/BookingControllerViewScopeMonth.java +++ b/src/main/java/com/divudi/bean/channel/BookingControllerViewScopeMonth.java @@ -585,8 +585,10 @@ private Bill createBillForChannelReshedule(BillSession bs) { bill.setDeptId(deptId); bill.setInsId(deptId); - bill.setPaidAmount(getSelectedSessionInstanceForRechedule().getOriginatingSession().getTotal()); - bill.setPaidAt(new Date()); + if (bill.getBillTypeAtomic() == BillTypeAtomic.CHANNEL_RESHEDULE_WITH_PAYMENT) { + bill.setPaidAmount(getSelectedSessionInstanceForRechedule().getOriginatingSession().getTotal()); + bill.setPaidAt(new Date()); + } bill.setBillDate(new Date()); bill.setBillTime(new Date()); diff --git a/src/main/java/com/divudi/bean/web/NoCacheFilter.java b/src/main/java/com/divudi/bean/web/NoCacheFilter.java new file mode 100644 index 0000000000..97bdf67112 --- /dev/null +++ b/src/main/java/com/divudi/bean/web/NoCacheFilter.java @@ -0,0 +1,36 @@ +package com.divudi.bean.web; + +import javax.faces.application.ResourceHandler; +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@WebFilter(servletNames={"Faces Servlet"}) // Must match of your FacesServlet. +public class NoCacheFilter implements Filter { + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + HttpServletRequest req = (HttpServletRequest) request; + HttpServletResponse res = (HttpServletResponse) response; + + if (!req.getRequestURI().startsWith(req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { // Skip JSF resources (CSS/JS/Images/etc) + res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. + res.setHeader("Pragma", "no-cache"); // HTTP 1.0. + res.setDateHeader("Expires", 0); // Proxies. + } + + chain.doFilter(request, response); + } + + @Override + public void destroy() { + + } +} \ No newline at end of file diff --git a/src/main/java/com/divudi/entity/BillSession.java b/src/main/java/com/divudi/entity/BillSession.java index d93111537e..e69eb9ef82 100644 --- a/src/main/java/com/divudi/entity/BillSession.java +++ b/src/main/java/com/divudi/entity/BillSession.java @@ -124,6 +124,11 @@ public class BillSession implements Serializable { ChannelFee hospitalFee; @Transient ChannelFee agentFee; + @OneToOne(fetch = FetchType.LAZY) + BillSession rescheduledFromBillSession; + @OneToOne(fetch = FetchType.LAZY) + BillSession rescheduledToBillSession; + private boolean reservedBooking=false; private boolean recheduledSession=false; @@ -554,8 +559,22 @@ public boolean isRecheduledSession() { public void setRecheduledSession(boolean recheduledSession) { this.recheduledSession = recheduledSession; } - - - + public BillSession getRescheduledFromBillSession() { + return rescheduledFromBillSession; + } + + public BillSession setRescheduledFromBillSession(BillSession rescheduledFromBillSession) { + this.rescheduledFromBillSession = rescheduledFromBillSession; + return this; + } + + public BillSession getRescheduledToBillSession() { + return rescheduledToBillSession; + } + + public BillSession setRescheduledToBillSession(BillSession rescheduledToBillSession) { + this.rescheduledToBillSession = rescheduledToBillSession; + return this; + } } diff --git a/src/main/webapp/channel/manage_booking.xhtml b/src/main/webapp/channel/manage_booking.xhtml index 0e70056471..83e3febcb9 100644 --- a/src/main/webapp/channel/manage_booking.xhtml +++ b/src/main/webapp/channel/manage_booking.xhtml @@ -276,129 +276,129 @@ - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - - + + - - + + - + - - + + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - - + + - - + + - + - - + + diff --git a/src/main/webapp/channel/manage_booking_by_date.xhtml b/src/main/webapp/channel/manage_booking_by_date.xhtml index 117fcdb9fd..682a4032ed 100644 --- a/src/main/webapp/channel/manage_booking_by_date.xhtml +++ b/src/main/webapp/channel/manage_booking_by_date.xhtml @@ -942,131 +942,131 @@ - + - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - - + + - - + + - + - - + + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - - + + - - + + - + - - + + From b7c8ab765424fc5d71c338b227197304600e0667 Mon Sep 17 00:00:00 2001 From: Lawan Samarasekara Date: Tue, 13 Aug 2024 20:59:11 +0530 Subject: [PATCH 4/8] Signed-off-by: Lawan Samarasekara --- src/main/resources/META-INF/persistence.xml | 41 +++++++++++---------- src/main/webapp/WEB-INF/glassfish-web.xml | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 62cef15d50..0c8461f4d5 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -1,23 +1,24 @@ - - org.eclipse.persistence.jpa.PersistenceProvider - jdbc/hims - false - - - - - - - - jdbc/himsAduit - com.divudi.entity.AuditEvent - true - - - - - + + org.eclipse.persistence.jpa.PersistenceProvider + jdbc/sethma + false + + + + + + + + + + jdbc/sethmaAudit + false + + + + + + - diff --git a/src/main/webapp/WEB-INF/glassfish-web.xml b/src/main/webapp/WEB-INF/glassfish-web.xml index a2b2472a01..d92795745e 100644 --- a/src/main/webapp/WEB-INF/glassfish-web.xml +++ b/src/main/webapp/WEB-INF/glassfish-web.xml @@ -1,7 +1,7 @@ - /sethmareports + /sethmademo From 9754c0107970bac1aa6dab84e13cf06ac1e80b93 Mon Sep 17 00:00:00 2001 From: Lahiru Jayakody Date: Tue, 13 Aug 2024 22:17:29 +0530 Subject: [PATCH 5/8] duplicated bill session fix --- .../com/divudi/bean/channel/BookingControllerViewScope.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java b/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java index ce50930586..a73f241223 100644 --- a/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java +++ b/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java @@ -448,6 +448,8 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si) newBillSession.setSessionDate(getSelectedSessionInstanceForRechedule().getSessionDate()); newBillSession.setSessionTime(getSelectedSessionInstanceForRechedule().getSessionTime()); newBillSession.setStaff(getSelectedSessionInstanceForRechedule().getStaff()); + newBillSession.setSerialNo(0); + getBillSessionFacade().create(newBillSession); printingBill.setSingleBillSession(newBillSession); printingBill.setSingleBillItem(savingBillItem); @@ -470,6 +472,7 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si) savingBillItem.setHospitalFee(billBeanController.calFeeValue(FeeType.OwnInstitution, savingBillItem)); savingBillItem.setStaffFee(billBeanController.calFeeValue(FeeType.Staff, savingBillItem)); savingBillItem.setBillSession(newBillSession); + getBillItemFacade().edit(savingBillItem); printingBill.setHospitalFee(billBeanController.calFeeValue(FeeType.OwnInstitution, printingBill)); printingBill.setStaffFee(billBeanController.calFeeValue(FeeType.Staff, printingBill)); printingBill.setSingleBillItem(savingBillItem); @@ -510,7 +513,7 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si) newBillSession.setSerialNo(1); System.out.println("count serial number= " + bs.getSerialNo()); } - getBillSessionFacade().create(newBillSession); + getBillSessionFacade().edit(newBillSession); bs.setRecheduledSession(true); bs.setRescheduledToBillSession(newBillSession); getBillSessionFacade().edit(bs); From 07e5c1c1e1983d797f2590b141c7ea45208831a2 Mon Sep 17 00:00:00 2001 From: Dr M H B Ariyaratne Date: Tue, 13 Aug 2024 23:21:58 +0530 Subject: [PATCH 6/8] Closese #6854 Signed-off-by: Dr M H B Ariyaratne --- .../com/divudi/bean/hr/StaffController.java | 134 +++-- .../java/com/divudi/entity/Consultant.java | 5 +- src/main/java/com/divudi/entity/Doctor.java | 5 +- src/main/java/com/divudi/entity/Staff.java | 24 +- src/main/resources/META-INF/persistence.xml | 4 +- .../hr_staff_without_doctors_admin.xhtml | 554 ++++-------------- .../webapp/analytics/audit_event_list.xhtml | 1 - 7 files changed, 226 insertions(+), 501 deletions(-) diff --git a/src/main/java/com/divudi/bean/hr/StaffController.java b/src/main/java/com/divudi/bean/hr/StaffController.java index 1e54ea98fb..aca7ea3d94 100644 --- a/src/main/java/com/divudi/bean/hr/StaffController.java +++ b/src/main/java/com/divudi/bean/hr/StaffController.java @@ -90,15 +90,7 @@ public class StaffController implements Serializable { CommonController commonController; @Inject PersonController personController; - - - - - - - - - + //// @EJB private StaffEmploymentFacade staffEmploymentFacade; @@ -129,7 +121,6 @@ public class StaffController implements Serializable { List itemsToRemove; Date tempRetireDate = null; boolean removeResign = false; - public void removeSelectedItems() { for (Staff s : itemsToRemove) { @@ -1144,64 +1135,111 @@ public void saveSelected() { current.setDateLeft(tempRetireDate); } - ////System.out.println("current.getId() = " + current.getId()); - ////System.out.println("current.getPerson().getId() = " + current.getPerson().getId()); -// if (current.getPerson().getId() == null || current.getPerson().getId() == 0) { -// getPersonFacade().create(current.getPerson()); -// } else { -// getPersonFacade().edit(current.getPerson()); -// } + getCurrent().chageCodeToInteger(); - if (getCurrent().getPerson().getDob() != null && getCurrent().getPerson().getSex() != null) { - Calendar dob = Calendar.getInstance(); - dob.setTime(getCurrent().getPerson().getDob()); - Calendar dor = Calendar.getInstance(); - dor.setTime(getCurrent().getPerson().getDob()); - if (getCurrent().getPerson().getSex() == Sex.Female) { - dor.set(Calendar.YEAR, (dob.get(Calendar.YEAR) + 50)); - } - if (getCurrent().getPerson().getSex() == Sex.Male) { - dor.set(Calendar.YEAR, (dob.get(Calendar.YEAR) + 55)); - } - if (getCurrent().getPerson().getSex() == Sex.Male || getCurrent().getPerson().getSex() == Sex.Female) { - if (getCurrent().getDateRetired() != null) { -// if (dor.getTime().after(getCurrent().getDateRetired())) { -// getCurrent().setDateRetired(dor.getTime()); -// } - getCurrent().setDateRetired(dor.getTime()); - } else { - getCurrent().setDateRetired(dor.getTime()); - } + - } - } - if (getCurrent().isWithOutNotice()) { - getCurrent().setDateWithOutNotice(null); + current.getName(); + current.getPerson().getName(); + current.getPerson().getFullName(); + current.getPerson().getNameWithInitials(); + + System.out.println(" current.getName() = " + current.getName()); + System.out.println(" current.getPerson().getName() = " + current.getPerson().getName()); + System.out.println("current.getPerson().getFullName() = " + current.getPerson().getFullName()); + System.out.println("current.getPerson().getNameWithInitials() = " + current.getPerson().getNameWithInitials()); + + if (current.getPerson().getId() == null) { + current.getPerson().setCreatedAt(new Date()); + current.getPerson().setCreater(getSessionController().getLoggedUser()); + getPersonFacade().createAndFlush(current.getPerson()); + JsfUtil.addSuccessMessage("New Person Created"); + } else { + getPersonFacade().editAndFlush(current.getPerson()); + JsfUtil.addSuccessMessage("Person Updated"); } - if (getCurrent().getId() != null && getCurrent().getId() > 0) { -// current.getPerson().setEditer(getSessionController().getLoggedUser()); -// current.getPerson().setEditedAt(new Date()); + if (getCurrent().getId() != null) { getPersonFacade().edit(current.getPerson()); - getFacade().edit(current); + getFacade().editAndFlush(current); JsfUtil.addSuccessMessage("Staff Details Updated"); } else { current.getPerson().setCreatedAt(new Date()); current.getPerson().setCreater(getSessionController().getLoggedUser()); - getPersonFacade().create(current.getPerson()); + getPersonFacade().createAndFlush(current.getPerson()); current.setCreatedAt(new Date()); current.setCreater(getSessionController().getLoggedUser()); - getFacade().create(current); + getFacade().createAndFlush(current); JsfUtil.addSuccessMessage("New Staff Created"); } + System.out.println(" current.getName() = " + current.getName()); + System.out.println(" current.getPerson().getName() = " + current.getPerson().getName()); + System.out.println("current.getPerson().getFullName() = " + current.getPerson().getFullName()); + System.out.println("current.getPerson().getNameWithInitials() = " + current.getPerson().getNameWithInitials()); + updateStaffEmployment(); recreateModel(); getItems(); } + + + public void saveStaff() { + if (current == null) { + JsfUtil.addErrorMessage("Nothing to save"); + return; + } + if (current.getPerson() == null) { + JsfUtil.addErrorMessage("Nothing to save"); + return; + } + + current.getName(); + current.getPerson().getName(); + current.getPerson().getFullName(); + current.getPerson().getNameWithInitials(); + + System.out.println(" current.getName() = " + current.getName()); + System.out.println(" current.getPerson().getName() = " + current.getPerson().getName()); + System.out.println("current.getPerson().getFullName() = " + current.getPerson().getFullName()); + System.out.println("current.getPerson().getNameWithInitials() = " + current.getPerson().getNameWithInitials()); + + if (current.getPerson().getId() == null) { + current.getPerson().setCreatedAt(new Date()); + current.getPerson().setCreater(getSessionController().getLoggedUser()); + getPersonFacade().createAndFlush(current.getPerson()); + JsfUtil.addSuccessMessage("New Person Created"); + } else { + getPersonFacade().editAndFlush(current.getPerson()); + JsfUtil.addSuccessMessage("Person Updated"); + } + + if (getCurrent().getId() != null) { + getPersonFacade().edit(current.getPerson()); + getFacade().editAndFlush(current); + JsfUtil.addSuccessMessage("Staff Details Updated"); + } else { + current.getPerson().setCreatedAt(new Date()); + current.getPerson().setCreater(getSessionController().getLoggedUser()); + getPersonFacade().createAndFlush(current.getPerson()); + + current.setCreatedAt(new Date()); + current.setCreater(getSessionController().getLoggedUser()); + getFacade().createAndFlush(current); + JsfUtil.addSuccessMessage("New Staff Created"); + } + + System.out.println(" current.getName() = " + current.getName()); + System.out.println(" current.getPerson().getName() = " + current.getPerson().getName()); + System.out.println("current.getPerson().getFullName() = " + current.getPerson().getFullName()); + System.out.println("current.getPerson().getNameWithInitials() = " + current.getPerson().getNameWithInitials()); + + recreateModel(); + getItems(); + } public void updateFormItem(FormItemValue fi) { if (fi == null) { @@ -1425,7 +1463,7 @@ public void fillItems() { } public Staff findStaffByName(String name) { - if(name==null){ + if (name == null) { return null; } name = name.trim(); diff --git a/src/main/java/com/divudi/entity/Consultant.java b/src/main/java/com/divudi/entity/Consultant.java index 4be30818f5..c17dd8ab6e 100644 --- a/src/main/java/com/divudi/entity/Consultant.java +++ b/src/main/java/com/divudi/entity/Consultant.java @@ -4,7 +4,6 @@ */ package com.divudi.entity; -import java.io.Serializable; import javax.persistence.Entity; /** @@ -12,6 +11,8 @@ * @author buddhika */ @Entity -public class Consultant extends Doctor implements Serializable { +public class Consultant extends Doctor { + + } diff --git a/src/main/java/com/divudi/entity/Doctor.java b/src/main/java/com/divudi/entity/Doctor.java index 0e3ac30229..eeaa2a8b5c 100644 --- a/src/main/java/com/divudi/entity/Doctor.java +++ b/src/main/java/com/divudi/entity/Doctor.java @@ -4,7 +4,6 @@ */ package com.divudi.entity; -import java.io.Serializable; import javax.persistence.Entity; /** @@ -12,5 +11,7 @@ * @author buddhika */ @Entity -public class Doctor extends Staff implements Serializable { +public class Doctor extends Staff { + + } diff --git a/src/main/java/com/divudi/entity/Staff.java b/src/main/java/com/divudi/entity/Staff.java index a558dd5915..149deef94e 100644 --- a/src/main/java/com/divudi/entity/Staff.java +++ b/src/main/java/com/divudi/entity/Staff.java @@ -21,6 +21,7 @@ import java.io.Serializable; import java.util.Date; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; @@ -28,6 +29,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; + import javax.persistence.Inheritance; import javax.persistence.Lob; import javax.persistence.ManyToOne; @@ -39,20 +41,21 @@ * * @author buddhika */ -@Entity @Inheritance +@Entity public class Staff implements Serializable, IdentifiableWithNameOrCode { - - static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) Long id; + + static final long serialVersionUID = 1L; + String registration; @Lob String qualification; String code = ""; - + @ManyToOne Roster roster; @@ -72,7 +75,7 @@ public class Staff implements Serializable, IdentifiableWithNameOrCode { @Lob private String description; - @ManyToOne + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) Person person; @ManyToOne Speciality speciality; @@ -148,7 +151,7 @@ public class Staff implements Serializable, IdentifiableWithNameOrCode { boolean withOutNotice; @Temporal(javax.persistence.TemporalType.DATE) Date dateWithOutNotice; - + @Enumerated private StaffWelfarePeriod staffWelfarePeriod; @@ -721,11 +724,10 @@ public void setDateWithOutNotice(Date dateWithOutNotice) { this.dateWithOutNotice = dateWithOutNotice; } - @Transient public String getName() { - if (getPerson() != null) { - name = getPerson().getNameWithTitle(); - } +// if (getPerson() != null) { +// name = getPerson().getNameWithTitle(); +// } return name; } @@ -760,7 +762,5 @@ public double getCurrentCreditValue() { public void setCurrentCreditValue(double currentCreditValue) { this.currentCreditValue = currentCreditValue; } - - } diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 0cf973df0f..755636ee5e 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -2,7 +2,7 @@ org.eclipse.persistence.jpa.PersistenceProvider - jdbc/sethma + jdbc/ruhunu false @@ -13,7 +13,7 @@ - jdbc/sethmaAudit + jdbc/ruhunuaudit false diff --git a/src/main/webapp/admin/staff/hr_staff_without_doctors_admin.xhtml b/src/main/webapp/admin/staff/hr_staff_without_doctors_admin.xhtml index ffada3b690..e45888cef4 100644 --- a/src/main/webapp/admin/staff/hr_staff_without_doctors_admin.xhtml +++ b/src/main/webapp/admin/staff/hr_staff_without_doctors_admin.xhtml @@ -4,17 +4,12 @@ xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:p="http://primefaces.org/ui" - xmlns:f="http://xmlns.jcp.org/jsf/core" - xmlns:autocomplete="http://xmlns.jcp.org/jsf/composite/autocomplete"> - + xmlns:f="http://xmlns.jcp.org/jsf/core"> - - - - + @@ -48,454 +43,145 @@ - + - - - - - -
- +
+ + + +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
-
- - -
- - - - - - - - - - - - - - - - -
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- - - - - -
-
-
- + -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - + + - - - + + - + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ diff --git a/src/main/webapp/analytics/audit_event_list.xhtml b/src/main/webapp/analytics/audit_event_list.xhtml index daaf926152..8ba55a7b75 100644 --- a/src/main/webapp/analytics/audit_event_list.xhtml +++ b/src/main/webapp/analytics/audit_event_list.xhtml @@ -62,7 +62,6 @@ - From e3c93fe9ba7dd71e873262ad5555ab899c30fb42 Mon Sep 17 00:00:00 2001 From: Dr M H B Ariyaratne Date: Wed, 14 Aug 2024 01:12:37 +0530 Subject: [PATCH 7/8] Closes #6854 Signed-off-by: Dr M H B Ariyaratne --- .../com/divudi/bean/hr/GradeController.java | 5 +- .../com/divudi/bean/hr/StaffController.java | 71 +++++- .../com/divudi/bean/web/NoCacheFilter.java | 36 ---- src/main/java/com/divudi/entity/Person.java | 15 +- src/main/java/com/divudi/entity/hr/Grade.java | 22 -- .../staff/admin_manage_staff_index.xhtml | 10 + .../hr_staff_without_doctors_admin.xhtml | 2 +- src/main/webapp/admin/staff/staff.xhtml | 203 ++++++++++++++++++ src/main/webapp/admin/staff/staff_list.xhtml | 42 ++++ 9 files changed, 331 insertions(+), 75 deletions(-) delete mode 100644 src/main/java/com/divudi/bean/web/NoCacheFilter.java create mode 100644 src/main/webapp/admin/staff/staff.xhtml create mode 100644 src/main/webapp/admin/staff/staff_list.xhtml diff --git a/src/main/java/com/divudi/bean/hr/GradeController.java b/src/main/java/com/divudi/bean/hr/GradeController.java index a894a40f95..0b9760073b 100644 --- a/src/main/java/com/divudi/bean/hr/GradeController.java +++ b/src/main/java/com/divudi/bean/hr/GradeController.java @@ -44,10 +44,7 @@ public class GradeController implements Serializable { private List items = null; String selectText = ""; - public List getSelectedItems() { - selectedItems = getFacade().findByJpql("select c from Grade c where c.retired=false and (c.name) like '%" + getSelectText().toUpperCase() + "%' order by c.name"); - return selectedItems; - } + public List completeGrade(String qry) { List a = null; diff --git a/src/main/java/com/divudi/bean/hr/StaffController.java b/src/main/java/com/divudi/bean/hr/StaffController.java index 7b5fc603a1..d094b194cd 100644 --- a/src/main/java/com/divudi/bean/hr/StaffController.java +++ b/src/main/java/com/divudi/bean/hr/StaffController.java @@ -108,6 +108,7 @@ public class StaffController implements Serializable { private List filteredStaff; private Staff selectedStaff; private Staff current; + private Person currentPerson; List staffWithCode; private List items = null; String selectText = ""; @@ -133,6 +134,60 @@ public void removeSelectedItems() { items = null; } + public String navigateToListStaff() { + fillItems(); + return "/admin/staff/staff_list?faces-redirect=true;"; + } + + public String navigateToManageStaff(Staff staff) { + if (staff == null) { + JsfUtil.addErrorMessage("Nothing Selected"); + return ""; + } + current = staff; + if (current.getPerson() == null) { + JsfUtil.addErrorMessage("No Person. New Person Added"); + currentPerson = new Person(); + current.setPerson(currentPerson); + } + return "/admin/staff/staff?faces-redirect=true;"; + } + + public String navigateToAddNewStaff() { + current = new Staff(); + currentPerson = new Person(); + current.setPerson(currentPerson); + return "/admin/staff/staff?faces-redirect=true;"; + } + + public void saveCurrentStaff(){ + if(current==null){ + JsfUtil.addErrorMessage("No Staff"); + return ; + } + if(current.getPerson()==null){ + JsfUtil.addErrorMessage("No Person"); + return ; + } + if(current.getPerson().getId()!=null){ + personFacade.edit(current.getPerson()); + }else{ + current.getPerson().setCreatedAt(new Date()); + current.getPerson().setCreater(sessionController.getLoggedUser()); + personFacade.edit(current.getPerson()); + } + if(current.getId()!=null){ + ejbFacade.edit(current); + JsfUtil.addSuccessMessage("Updated"); + }else{ + current.setCreater(sessionController.getLoggedUser()); + current.setCreatedAt(new Date()); + ejbFacade.create(current); + JsfUtil.addSuccessMessage("Saved"); + } + + } + public void deleteStaff() { if (current == null) { JsfUtil.addErrorMessage("Nothing selected"); @@ -1135,11 +1190,8 @@ public void saveSelected() { current.setDateLeft(tempRetireDate); } - getCurrent().chageCodeToInteger(); - - current.getName(); current.getPerson().getName(); current.getPerson().getFullName(); @@ -1186,9 +1238,8 @@ public void saveSelected() { getItems(); fillSelectedItemsWithAllStaff(); } - - - public void saveStaff() { + + public void saveStaff() { if (current == null) { JsfUtil.addErrorMessage("Nothing to save"); return; @@ -1582,6 +1633,14 @@ public void setStaff(List staff) { this.staff = staff; } + public Person getCurrentPerson() { + return currentPerson; + } + + public void setCurrentPerson(Person currentPerson) { + this.currentPerson = currentPerson; + } + /** * Converters */ diff --git a/src/main/java/com/divudi/bean/web/NoCacheFilter.java b/src/main/java/com/divudi/bean/web/NoCacheFilter.java deleted file mode 100644 index 97bdf67112..0000000000 --- a/src/main/java/com/divudi/bean/web/NoCacheFilter.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.divudi.bean.web; - -import javax.faces.application.ResourceHandler; -import javax.servlet.*; -import javax.servlet.annotation.WebFilter; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -@WebFilter(servletNames={"Faces Servlet"}) // Must match of your FacesServlet. -public class NoCacheFilter implements Filter { - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - - } - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - HttpServletRequest req = (HttpServletRequest) request; - HttpServletResponse res = (HttpServletResponse) response; - - if (!req.getRequestURI().startsWith(req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { // Skip JSF resources (CSS/JS/Images/etc) - res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. - res.setHeader("Pragma", "no-cache"); // HTTP 1.0. - res.setDateHeader("Expires", 0); // Proxies. - } - - chain.doFilter(request, response); - } - - @Override - public void destroy() { - - } -} \ No newline at end of file diff --git a/src/main/java/com/divudi/entity/Person.java b/src/main/java/com/divudi/entity/Person.java index 9a7be972a0..40a8305bc5 100644 --- a/src/main/java/com/divudi/entity/Person.java +++ b/src/main/java/com/divudi/entity/Person.java @@ -58,12 +58,7 @@ public class Person implements Serializable { @Column(name = "SNAME") String nameWithInitials; - @OneToOne(mappedBy = "webUserPerson", cascade = CascadeType.ALL) - private WebUser webUser; - - @Transient - boolean ageCalculated = false; - + String initials; String surName; String lastName; @@ -72,6 +67,14 @@ public class Person implements Serializable { @Temporal(javax.persistence.TemporalType.TIMESTAMP) Date dob; + + + @OneToOne(mappedBy = "webUserPerson", cascade = CascadeType.ALL) + private WebUser webUser; + + @Transient + boolean ageCalculated = false; + // Created Properties @ManyToOne WebUser creater; diff --git a/src/main/java/com/divudi/entity/hr/Grade.java b/src/main/java/com/divudi/entity/hr/Grade.java index 80e2523a90..0fabb155c3 100644 --- a/src/main/java/com/divudi/entity/hr/Grade.java +++ b/src/main/java/com/divudi/entity/hr/Grade.java @@ -5,37 +5,15 @@ package com.divudi.entity.hr; import com.divudi.entity.Category; -import com.divudi.entity.Staff; import java.io.Serializable; -import java.util.List; import javax.persistence.Entity; -import javax.persistence.OneToMany; -import javax.xml.bind.annotation.XmlTransient; /** * * @author buddhika */ @Entity - public class Grade extends Category implements Serializable { - - private static final long serialVersionUID = 1L; - @OneToMany(mappedBy = "grade") - private List staffs; - - - - @XmlTransient - public List getStaffs() { - return staffs; - } - - public void setStaffs(List staffs) { - this.staffs = staffs; - } - - } diff --git a/src/main/webapp/admin/staff/admin_manage_staff_index.xhtml b/src/main/webapp/admin/staff/admin_manage_staff_index.xhtml index f635936570..1e4cd26807 100644 --- a/src/main/webapp/admin/staff/admin_manage_staff_index.xhtml +++ b/src/main/webapp/admin/staff/admin_manage_staff_index.xhtml @@ -25,6 +25,16 @@
+ + diff --git a/src/main/webapp/admin/staff/hr_staff_without_doctors_admin.xhtml b/src/main/webapp/admin/staff/hr_staff_without_doctors_admin.xhtml index e45888cef4..3cdb30a986 100644 --- a/src/main/webapp/admin/staff/hr_staff_without_doctors_admin.xhtml +++ b/src/main/webapp/admin/staff/hr_staff_without_doctors_admin.xhtml @@ -16,7 +16,7 @@ - +
diff --git a/src/main/webapp/admin/staff/staff.xhtml b/src/main/webapp/admin/staff/staff.xhtml new file mode 100644 index 0000000000..907fa21fcc --- /dev/null +++ b/src/main/webapp/admin/staff/staff.xhtml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + +
+ + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ +
+ + + diff --git a/src/main/webapp/admin/staff/staff_list.xhtml b/src/main/webapp/admin/staff/staff_list.xhtml new file mode 100644 index 0000000000..b95229e1d6 --- /dev/null +++ b/src/main/webapp/admin/staff/staff_list.xhtml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 33064498afc4dfab518bdfa3d4acb30369fdaeb4 Mon Sep 17 00:00:00 2001 From: Dr M H B Ariyaratne Date: Wed, 14 Aug 2024 01:29:50 +0530 Subject: [PATCH 8/8] Signed-off-by: Dr M H B Ariyaratne --- .../staff/admin_manage_staff_index.xhtml | 2 +- src/main/webapp/admin/staff/staff.xhtml | 77 +++++++++++-------- src/main/webapp/admin/staff/staff_list.xhtml | 42 +++++++--- 3 files changed, 78 insertions(+), 43 deletions(-) diff --git a/src/main/webapp/admin/staff/admin_manage_staff_index.xhtml b/src/main/webapp/admin/staff/admin_manage_staff_index.xhtml index 1e4cd26807..ef09fddfaa 100644 --- a/src/main/webapp/admin/staff/admin_manage_staff_index.xhtml +++ b/src/main/webapp/admin/staff/admin_manage_staff_index.xhtml @@ -39,7 +39,7 @@ - + diff --git a/src/main/webapp/admin/staff/staff.xhtml b/src/main/webapp/admin/staff/staff.xhtml index 907fa21fcc..4725dff1e9 100644 --- a/src/main/webapp/admin/staff/staff.xhtml +++ b/src/main/webapp/admin/staff/staff.xhtml @@ -89,17 +89,16 @@ - - + - + - + - + - + - - - + + + + - - + + + - + - - - + + + - - - - - + - + - + - + - + - + - + - + - + - + diff --git a/src/main/webapp/admin/staff/staff_list.xhtml b/src/main/webapp/admin/staff/staff_list.xhtml index b95229e1d6..341d266756 100644 --- a/src/main/webapp/admin/staff/staff_list.xhtml +++ b/src/main/webapp/admin/staff/staff_list.xhtml @@ -11,27 +11,47 @@ - - - + + + + + + + + + - - + + + + - - + + + + - - + + + + - + + + + action="#{staffController.navigateToManageStaff(s)}" + icon="fa fa-pencil" /> +