diff --git a/migration/i3.1/oracle/201511271630_IDEMPIERE-2973_1005382.sql b/migration/i3.1/oracle/201511271630_IDEMPIERE-2973_1005382.sql new file mode 100644 index 0000000000..f157ad4c29 --- /dev/null +++ b/migration/i3.1/oracle/201511271630_IDEMPIERE-2973_1005382.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Ticket #1005382: Requests are showing up on the wrong person's calendar +-- Nov 27, 2015 4:26:07 PM SGT +INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200074,0,0,TO_DATE('2015-11-27 16:26:05','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2015-11-27 16:26:05','YYYY-MM-DD HH24:MI:SS'),100,100,'Y','ZK_DASHBOARD_CALENDAR_REQUEST_DISPLAY_MODE','CSU','C - Created by of the request is the logged in user; S - Sales Rep of the request is the logged in user; U - User/Contact of the request is the logged in user','D','C','f134d1ed-4101-4582-a3b3-0d2bf5c3577c') +; + +SELECT register_migration_script('201511271630_IDEMPIERE-2973_1005382.sql') FROM dual +; diff --git a/migration/i3.1/postgresql/201511271630_IDEMPIERE-2973_1005382.sql b/migration/i3.1/postgresql/201511271630_IDEMPIERE-2973_1005382.sql new file mode 100644 index 0000000000..6524cf6b17 --- /dev/null +++ b/migration/i3.1/postgresql/201511271630_IDEMPIERE-2973_1005382.sql @@ -0,0 +1,7 @@ +-- Ticket #1005382: Requests are showing up on the wrong person's calendar +-- Nov 27, 2015 4:26:07 PM SGT +INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200074,0,0,TO_TIMESTAMP('2015-11-27 16:26:05','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2015-11-27 16:26:05','YYYY-MM-DD HH24:MI:SS'),100,100,'Y','ZK_DASHBOARD_CALENDAR_REQUEST_DISPLAY_MODE','CSU','C - Created by of the request is the logged in user; S - Sales Rep of the request is the logged in user; U - User/Contact of the request is the logged in user','D','C','f134d1ed-4101-4582-a3b3-0d2bf5c3577c') +; + +SELECT register_migration_script('201511271630_IDEMPIERE-2973_1005382.sql') FROM dual +; diff --git a/org.adempiere.base/src/org/compiere/model/MSysConfig.java b/org.adempiere.base/src/org/compiere/model/MSysConfig.java index f454192b09..510205cbb7 100644 --- a/org.adempiere.base/src/org/compiere/model/MSysConfig.java +++ b/org.adempiere.base/src/org/compiere/model/MSysConfig.java @@ -42,7 +42,7 @@ public class MSysConfig extends X_AD_SysConfig /** * */ - private static final long serialVersionUID = 2300170888492939423L; + private static final long serialVersionUID = -5124493725187310483L; public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION"; public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS"; @@ -142,6 +142,7 @@ public class MSysConfig extends X_AD_SysConfig public static final String ZK_BROWSER_ICON = "ZK_BROWSER_ICON"; public static final String ZK_BROWSER_TITLE = "ZK_BROWSER_TITLE"; public static final String ZK_BUTTON_STYLE = "ZK_BUTTON_STYLE"; + public static final String ZK_DASHBOARD_CALENDAR_REQUEST_DISPLAY_MODE = "ZK_DASHBOARD_CALENDAR_REQUEST_DISPLAY_MODE"; public static final String ZK_DASHBOARD_PERFORMANCE_TIMEOUT = "ZK_DASHBOARD_PERFORMANCE_TIMEOUT"; public static final String ZK_DASHBOARD_REFRESH_INTERVAL = "ZK_DASHBOARD_REFRESH_INTERVAL"; public static final String ZK_DECIMALBOX_PROCESS_DOTKEYPAD = "ZK_DECIMALBOX_PROCESS_DOTKEYPAD"; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPCalendar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPCalendar.java index 44bc423668..d53baee448 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPCalendar.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPCalendar.java @@ -34,6 +34,7 @@ import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ServerPushTemplate; import org.compiere.model.I_R_Request; +import org.compiere.model.MSysConfig; import org.compiere.model.PO; import org.compiere.model.X_R_RequestType; import org.compiere.util.CLogger; @@ -200,13 +201,31 @@ public class DPCalendar extends DashboardPanel implements EventListener, } public static ArrayList getEvents(int RequestTypeID, Properties ctx) { + String mode = MSysConfig.getValue(MSysConfig.ZK_DASHBOARD_CALENDAR_REQUEST_DISPLAY_MODE, "CSU", Env.getAD_Client_ID(ctx)); + + String modeCondition = ""; + if (mode.indexOf('C') >= 0) + modeCondition += "r.CreatedBy = ?"; + if (mode.indexOf('S') >= 0) + { + if (modeCondition.length() > 0) + modeCondition += " OR "; + modeCondition += "r.SalesRep_ID = ?"; + } + if (mode.indexOf('U') >= 0) + { + if (modeCondition.length() > 0) + modeCondition += " OR "; + modeCondition += "r.AD_User_ID = ?"; + } + ArrayList events = new ArrayList(); String sql = "SELECT DISTINCT r.R_Request_ID, r.DateNextAction, " + "r.DateStartPlan, r.DateCompletePlan, r.StartTime, r.EndTime, " + "r.Summary, rt.HeaderColor, rt.ContentColor, rt.R_RequestType_ID " + "FROM R_Request r, R_RequestType rt " + "WHERE r.R_RequestType_ID = rt.R_RequestType_ID " - + "AND (r.SalesRep_ID = ? OR r.AD_User_ID = ? OR r.CreatedBy = ?) " + + "AND (" + modeCondition + ") " + "AND r.AD_Client_ID = ? AND r.IsActive = 'Y' " + "AND (r.R_Status_ID IS NULL OR r.R_Status_ID IN (SELECT R_Status_ID FROM R_Status WHERE IsClosed='N')) "; if(RequestTypeID > 0) @@ -214,16 +233,21 @@ public class DPCalendar extends DashboardPanel implements EventListener, PreparedStatement ps = null; ResultSet rs = null; + int count = 1; try { ps = DB.prepareStatement(sql, null); - ps.setInt(1, Env.getAD_User_ID(ctx)); - ps.setInt(2, Env.getAD_User_ID(ctx)); - ps.setInt(3, Env.getAD_User_ID(ctx)); - ps.setInt(4, Env.getAD_Client_ID(ctx)); + if (mode.indexOf('C') >= 0) + ps.setInt(count++, Env.getAD_User_ID(ctx)); + if (mode.indexOf('S') >= 0) + ps.setInt(count++, Env.getAD_User_ID(ctx)); + if (mode.indexOf('U') >= 0) + ps.setInt(count++, Env.getAD_User_ID(ctx)); + + ps.setInt(count++, Env.getAD_Client_ID(ctx)); if(RequestTypeID > 0) - ps.setInt(5, RequestTypeID); + ps.setInt(count++, RequestTypeID); rs = ps.executeQuery();