IDEMPIERE-2973 / 1005382 Requests are showing up on the wrong person's calendar

This commit is contained in:
Elaine Tan 2015-12-12 19:38:11 -05:00
parent d615ba6591
commit 04dfeff84c
4 changed files with 49 additions and 7 deletions

View File

@ -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
;

View File

@ -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
;

View File

@ -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";

View File

@ -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<Event>,
}
public static ArrayList<ADCalendarEvent> 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<ADCalendarEvent> events = new ArrayList<ADCalendarEvent>();
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<Event>,
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();