diff --git a/src/main/java/com/divudi/bean/common/NotificationController.java b/src/main/java/com/divudi/bean/common/NotificationController.java index e0f618f22a..d5959316bc 100644 --- a/src/main/java/com/divudi/bean/common/NotificationController.java +++ b/src/main/java/com/divudi/bean/common/NotificationController.java @@ -60,8 +60,6 @@ public class NotificationController implements Serializable { private NotificationFacade ejbFacade; private Notification current; private List items = null; - - public void save(Notification notification) { if (notification == null) { @@ -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)) { @@ -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; @@ -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 "; } diff --git a/src/main/java/com/divudi/bean/common/UserNotificationController.java b/src/main/java/com/divudi/bean/common/UserNotificationController.java index 8a0b19c45f..3bd2a5f193 100644 --- a/src/main/java/com/divudi/bean/common/UserNotificationController.java +++ b/src/main/java/com/divudi/bean/common/UserNotificationController.java @@ -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) { @@ -176,11 +180,16 @@ public List 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: diff --git a/src/main/java/com/divudi/bean/pharmacy/TransferIssueController.java b/src/main/java/com/divudi/bean/pharmacy/TransferIssueController.java index 53976b4620..d6b95dea4a 100644 --- a/src/main/java/com/divudi/bean/pharmacy/TransferIssueController.java +++ b/src/main/java/com/divudi/bean/pharmacy/TransferIssueController.java @@ -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; @@ -462,7 +463,7 @@ public void settleDirectIssue() { getIssuedBill().setNetTotal(calTotal()); getIssuedBill().setBackwardReferenceBill(getRequestedBill()); - + getIssuedBill().setBillTypeAtomic(BillTypeAtomic.PHARMACY_DIRECT_ISSUE); getBillFacade().edit(getIssuedBill()); //Update ReferenceBill @@ -474,6 +475,7 @@ public void settleDirectIssue() { userStockController.retiredAllUserStockContainer(getSessionController().getLoggedUser()); issuedBill = null; issuedBill = b; + notificationController.createNotification(issuedBill); printPreview = true; diff --git a/src/main/webapp/Notification/user_notifications.xhtml b/src/main/webapp/Notification/user_notifications.xhtml index 96bc428315..233df24791 100644 --- a/src/main/webapp/Notification/user_notifications.xhtml +++ b/src/main/webapp/Notification/user_notifications.xhtml @@ -10,8 +10,16 @@ +
+ +
-
+
@@ -30,6 +38,15 @@
+ +
+
+ +
New Notification from
+
#{un.notification.bill.department.name}
+
+
+
@@ -37,6 +54,7 @@ +