Skip to content

Commit

Permalink
Signed-off-by: Thiwanka Madushan <[email protected]>
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiwanka570 committed Apr 18, 2024
1 parent 7dc9314 commit 41f54d0
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 16 deletions.
23 changes: 19 additions & 4 deletions src/main/java/com/divudi/bean/common/NotificationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public class NotificationController implements Serializable {
private NotificationFacade ejbFacade;
private Notification current;
private List<Notification> items = null;



public void save(Notification notification) {
if (notification == null) {
Expand Down Expand Up @@ -107,11 +105,14 @@ public void createNotification(Bill bill) {
case OPD_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION:
//No Notification is necessary
break;
case PHARMACY_DIRECT_ISSUE:
createPharmacyDirectIssueNotifications(bill);
break;
default:
throw new AssertionError();
}
}

private void createPharmacyTransferRequestNotifications(Bill bill) {
Date date = new Date();
for (TriggerType tt : TriggerType.getTriggersByParent(TriggerTypeParent.TRANSFER_REQUEST)) {
Expand All @@ -125,6 +126,20 @@ private void createPharmacyTransferRequestNotifications(Bill bill) {
userNotificationController.createUserNotifications(nn);
}
}

private void createPharmacyDirectIssueNotifications(Bill bill) {
Date date = new Date();
for (TriggerType tt : TriggerType.getTriggersByParent(TriggerTypeParent.TRANSFER_ISSUE)) {
Notification nn = new Notification();
nn.setCreatedAt(date);
nn.setBill(bill);
nn.setTriggerType(tt);
nn.setCreater(sessionController.getLoggedUser());
nn.setMessage(createTemplateForNotificationMessage(bill.getBillTypeAtomic()));
getFacade().create(nn);
userNotificationController.createUserNotifications(nn);
}
}

private String createTemplateForNotificationMessage(BillTypeAtomic bt) {
String message = null;
Expand Down Expand Up @@ -152,7 +167,7 @@ private String createTemplateForNotificationMessage(BillTypeAtomic bt) {
message = configOptionController.getLongTextValueByKey("Message Template for OPD Bill Cancellation During Batch Bill Cancellation Notification", OptionScope.APPLICATION, null, null, null);
}

if (message == null || message=="" || message.isEmpty()) {
if (message == null || message == "" || message.isEmpty()) {
message = "New Request from ";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,20 @@ public String navigateToSentNotification() {
}

public void clearCanceledRequestsNotification(){
fillLoggedUserNotifications();
if (items==null) {
return;
}

}

public void cancelRequestNotification(Notification notification){
if (notification != null) {
Bill b=notification.getBill();
if (b.isCancelled()) {

for (UserNotification item : items) {
if (item.getNotification()==null) {
return;
}
if (item.getNotification().getBill().isCancelled()) {
items.remove(item);
}
}

}

public void save(UserNotification userNotification) {
Expand Down Expand Up @@ -176,11 +180,16 @@ public List<UserNotification> fillLoggedUserNotifications() {
return items;
}

public String navigateToCurrentNotificationRequest(UserNotification cu) {
if (cu.getNotification().getBill() == null) {
public String navigateToCurrentNotificationRequest(UserNotification un) {
Department toDepartmentFromNotification=un.getNotification().getBill().getToDepartment();
if (!toDepartmentFromNotification.equals(sessionController.getLoggedUser().getDepartment())) {
JsfUtil.addErrorMessage("You can't Access On Current Department !");
return "";
}
if (un.getNotification().getBill() == null) {
return "";
}
Bill bill = cu.getNotification().getBill();
Bill bill = un.getNotification().getBill();
BillTypeAtomic type = bill.getBillTypeAtomic();
switch (type) {
case PHARMACY_ORDER:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.divudi.data.BillClassType;
import com.divudi.data.BillNumberSuffix;
import com.divudi.data.BillType;
import com.divudi.data.BillTypeAtomic;
import com.divudi.data.StockQty;
import com.divudi.data.inward.InwardChargeType;
import com.divudi.ejb.BillNumberGenerator;
Expand Down Expand Up @@ -462,7 +463,7 @@ public void settleDirectIssue() {
getIssuedBill().setNetTotal(calTotal());

getIssuedBill().setBackwardReferenceBill(getRequestedBill());

getIssuedBill().setBillTypeAtomic(BillTypeAtomic.PHARMACY_DIRECT_ISSUE);
getBillFacade().edit(getIssuedBill());

//Update ReferenceBill
Expand All @@ -474,6 +475,7 @@ public void settleDirectIssue() {
userStockController.retiredAllUserStockContainer(getSessionController().getLoggedUser());
issuedBill = null;
issuedBill = b;

notificationController.createNotification(issuedBill);
printPreview = true;

Expand Down
20 changes: 19 additions & 1 deletion src/main/webapp/Notification/user_notifications.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@
<ui:define name="content">
<h:form >
<h:panelGroup id="userNoti" >
<div class="d-flex justify-content-end align-items-center">
<p:commandButton
class="m-2 ui-button-warning"
ajax="false"
icon="fas fa-trash"
value="Clear Cancelled Request"
action="#{userNotificationController.clearCanceledRequestsNotification()}"/>
</div>
<p:repeat value="#{userNotificationController.items}" var="un">
<div class="row mt-2 shadow-lg ">
<div class="row mt-2 shadow-lg" style="#{un.notification.bill.cancelled ? 'background-color: red;' : ''}">
<h:panelGroup rendered="#{un.notification.bill.billTypeAtomic eq 'PHARMACY_ORDER'}">
<div class="col-4 bg-success p-2 ">
<div class="d-flex align-items-center justify-content-between">
Expand All @@ -30,13 +38,23 @@
</div>
</div>
</h:panelGroup>
<h:panelGroup rendered="#{un.notification.bill.billTypeAtomic eq 'PHARMACY_DIRECT_ISSUE'}">
<div class="col-4 bg-warning p-2 ">
<div class="d-flex align-items-center justify-content-between">
<h:outputText styleClass="fa-solid fa-comments mx-4 text-white" />
<h5 class="text-white">New Notification from</h5>
<h6 style="box-sizing: border-box;border: 1px solid white;padding: 10px;color: white;font-weight: bold;margin-right: 10px"> #{un.notification.bill.department.name}</h6>
</div>
</div>
</h:panelGroup>
<div class="col-8 text-black">
<div class="d-flex justify-content-between align-items-center">
<div >
<p:outputLabel class="mx-2" value="#{un.notification.message}"/>
<p:outputLabel class="mx-4" value="#{un.notification.createdAt}">
<f:convertDateTime pattern="#{sessionController.applicationPreference.longDateFormat} / HH:mm" ></f:convertDateTime>
</p:outputLabel>
<p:outputLabel class="mx-2" value="#{un.notification.bill.cancelled}"/>
</div>

<div class="d-flex align-items-center mt-2">
Expand Down

0 comments on commit 41f54d0

Please sign in to comment.