IDEMPIERE-724 Zk: Make iDempiere theme more easily customizable. Make build in dashboard widget customizable by theme. Improve appearence and customizability of the performance indicator widget.

This commit is contained in:
Heng Sin Low 2013-05-30 16:30:55 +08:00
parent 091e5b333d
commit 73bd4af866
34 changed files with 455 additions and 3016 deletions

View File

@ -1,5 +1,6 @@
package org.adempiere.webui.apps.graph; package org.adempiere.webui.apps.graph;
import org.adempiere.webui.apps.graph.WPerformanceIndicator.Options;
import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Row;
@ -10,6 +11,8 @@ import org.compiere.util.Env;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Div;
import org.zkoss.zul.Label;
public class WPAPanel extends Panel implements EventListener<Event> public class WPAPanel extends Panel implements EventListener<Event>
{ {
@ -18,28 +21,34 @@ public class WPAPanel extends Panel implements EventListener<Event>
*/ */
private static final long serialVersionUID = -6491684272848160726L; private static final long serialVersionUID = -6491684272848160726L;
public static WPAPanel get()
{
return get((WPerformanceIndicator.Options)null);
}
/** /**
* Get Panel if User has Performance Goals * Get Panel if User has Performance Goals
* @return panel pr null * @return panel pr null
*/ */
public static WPAPanel get() public static WPAPanel get(WPerformanceIndicator.Options options)
{ {
int AD_User_ID = Env.getAD_User_ID(Env.getCtx()); int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
MGoal[] goals = MGoal.getUserGoals(Env.getCtx(), AD_User_ID); MGoal[] goals = MGoal.getUserGoals(Env.getCtx(), AD_User_ID);
if (goals.length == 0) if (goals.length == 0)
return null; return null;
return new WPAPanel(goals); return new WPAPanel(goals, options);
} }
/************************************************************************** /**************************************************************************
* Constructor * Constructor
* @param goals * @param goals
* @param options
*/ */
private WPAPanel (MGoal[] goals) private WPAPanel (MGoal[] goals, Options options)
{ {
super (); super ();
m_goals = goals; m_goals = goals;
init(); init(options);
} }
/** Goals */ /** Goals */
@ -50,27 +59,40 @@ public class WPAPanel extends Panel implements EventListener<Event>
/** /**
* Static/Dynamic Init * Static/Dynamic Init
* @param options
*/ */
private void init() private void init(Options options)
{ {
setSclass("performance-panel");
Grid grid = new Grid(); Grid grid = new Grid();
appendChild(grid); appendChild(grid);
grid.setWidth("100%"); int gh = options != null && options.chartHeight > 0 ? options.chartHeight+60 : 180;
grid.setHeight((m_goals.length * 132) + "px"); grid.setHeight(m_goals.length * gh / 2 + "px");
grid.setStyle("margin:0; padding:0; position: absolute;");
grid.makeNoStrip(); grid.makeNoStrip();
Rows rows = new Rows(); Rows rows = new Rows();
grid.appendChild(rows); grid.appendChild(rows);
Row row = null;
for (int i = 0; i < m_goals.length; i++) for (int i = 0; i < m_goals.length; i++)
{ {
Row row = new Row(); if (row == null || i % 2 == 0)
{
row = new Row();
rows.appendChild(row); rows.appendChild(row);
}
WPerformanceIndicator pi = new WPerformanceIndicator(m_goals[i]); Div div = new Div();
row.appendChild(pi); row.appendChild(div);
div.setSclass("performance-indicator-box");
WPerformanceIndicator pi = new WPerformanceIndicator(m_goals[i], options);
div.appendChild(pi);
pi.addEventListener(Events.ON_CLICK, this); pi.addEventListener(Events.ON_CLICK, this);
Div titleDiv = new Div();
titleDiv.setSclass("performance-indicator-title");
Label label = new Label(pi.getTitle());
div.appendChild(titleDiv);
titleDiv.appendChild(label);
} }
} // init } // init

View File

@ -16,8 +16,11 @@ package org.adempiere.webui.apps.graph;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.LinearGradientPaint;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Map;
import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Panel;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
@ -35,7 +38,6 @@ import org.jfree.chart.plot.MeterInterval;
import org.jfree.chart.plot.MeterPlot; import org.jfree.chart.plot.MeterPlot;
import org.jfree.data.Range; import org.jfree.data.Range;
import org.jfree.data.general.DefaultValueDataset; import org.jfree.data.general.DefaultValueDataset;
import org.jfree.ui.RectangleInsets;
import org.zkoss.image.AImage; import org.zkoss.image.AImage;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
@ -51,18 +53,48 @@ import org.zkoss.zul.Menupopup;
*/ */
public class WPerformanceIndicator extends Panel implements EventListener<Event> public class WPerformanceIndicator extends Panel implements EventListener<Event>
{ {
public static final String TICK_COLOR = "tickColor";
public static final String NEEDLE_COLOR = "needleColor";
public static final String DIAL_BACKGROUND = "dialBackground";
public static final String CHART_BACKGROUND = "chartBackground";
/** /**
* *
*/ */
private static final long serialVersionUID = 3580494126343850939L; private static final long serialVersionUID = 3580494126343850939L;
public WPerformanceIndicator(MGoal goal)
{
this(goal, null);
}
/** /**
* Constructor * Constructor
* @param goal goal model * @param goal goal model
*/ */
public WPerformanceIndicator(MGoal goal) public WPerformanceIndicator(MGoal goal, Options options)
{ {
super(); if (options != null) {
if (options.chartHeight > 0)
chartHeight = options.chartHeight;
if (options.chartWidth > 0)
chartWidth = options.chartWidth;
if (options.colorMap != null) {
Color color = options.colorMap.get(CHART_BACKGROUND);
if (color != null)
chartBackground = color;
color = options.colorMap.get(DIAL_BACKGROUND);
if (color != null)
dialBackground = color;
color = options.colorMap.get(NEEDLE_COLOR);
if (color != null)
needleColor = color;
color = options.colorMap.get(TICK_COLOR);
if (color != null)
dialBackground = color;
}
}
setSclass("performance-indicator");
m_goal = goal; m_goal = goal;
@ -85,6 +117,13 @@ public class WPerformanceIndicator extends Panel implements EventListener<Event>
Menupopup popupMenu = new Menupopup(); Menupopup popupMenu = new Menupopup();
private Menuitem mRefresh = new Menuitem(Msg.getMsg(Env.getCtx(), "Refresh"), ThemeManager.getThemeResource("images/Refresh16.png")); private Menuitem mRefresh = new Menuitem(Msg.getMsg(Env.getCtx(), "Refresh"), ThemeManager.getThemeResource("images/Refresh16.png"));
private Color chartBackground = new Color(0.0f, 0.0f, 0.0f, 0.0f);
private int chartWidth = 120;
private int chartHeight = 120;
private Color dialBackground = Color.white;
private Color needleColor = Color.darkGray;
private Color tickColor = Color.darkGray;
ChartPanel chartPanel; ChartPanel chartPanel;
/** /**
@ -124,6 +163,9 @@ public class WPerformanceIndicator extends Panel implements EventListener<Event>
MColorSchema colorSchema = m_goal.getColorSchema(); MColorSchema colorSchema = m_goal.getColorSchema();
int rangeLo = 0; int rangeHi=0; int rangeLo = 0; int rangeHi=0;
Point2D start = new Point2D.Float(0, 0);
Point2D end = new Point2D.Float(50, 50);
float[] dist = {0.0f, 0.2f, 0.45f, 0.75f, 1.0f};
for (int i=1; i<=4; i++){ for (int i=1; i<=4; i++){
switch (i) { switch (i) {
case 1: rangeHi = colorSchema.getMark1Percent(); break; case 1: rangeHi = colorSchema.getMark1Percent(); break;
@ -134,29 +176,35 @@ public class WPerformanceIndicator extends Panel implements EventListener<Event>
if (rangeHi==9999) if (rangeHi==9999)
rangeHi = (int) Math.floor(rangeLo*1.5); rangeHi = (int) Math.floor(rangeLo*1.5);
if (rangeLo < rangeHi) { if (rangeLo < rangeHi) {
Color[] colors = {colorSchema.getColor(rangeHi).brighter().brighter(),
colorSchema.getColor(rangeHi).brighter(), colorSchema.getColor(rangeHi),
colorSchema.getColor(rangeHi).darker(), colorSchema.getColor(rangeHi).darker().darker()};
LinearGradientPaint p =
new LinearGradientPaint(start, end, dist, colors);
plot.addInterval(new MeterInterval("Normal", //label plot.addInterval(new MeterInterval("Normal", //label
new Range(rangeLo, rangeHi), //range new Range(rangeLo, rangeHi), //range
colorSchema.getColor(rangeHi), p,
new BasicStroke(7.0f), new BasicStroke(7.0f),
new Color(-13091716) dialBackground
)); ));
rangeLo = rangeHi; rangeLo = rangeHi;
} }
} }
plot.setRange(new Range(0,rangeLo)); plot.setRange(new Range(0,rangeLo));
plot.setDialBackgroundPaint(dialBackground);
plot.setDialBackgroundPaint(new Color(-13091716));
plot.setUnits(""); plot.setUnits("");
plot.setDialShape(DialShape.CHORD);//CIRCLE); plot.setDialShape(DialShape.CHORD);
plot.setNeedlePaint(Color.white); plot.setNeedlePaint(needleColor);
plot.setTickSize(2000); plot.setTickSize(2000);
plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8)); plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8));
plot.setValueFont(new Font("SansSerif", Font.BOLD, 8)); plot.setValueFont(new Font("SansSerif", Font.BOLD, 8));
plot.setNoDataMessageFont(new Font("SansSerif", Font.BOLD, 8)); plot.setNoDataMessageFont(new Font("SansSerif", Font.BOLD, 8));
plot.setTickLabelPaint(Color.white); plot.setTickLabelPaint(tickColor);
plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); plot.setValuePaint(new Color(0.0f, 0.0f, 0.0f, 0.0f));
plot.setTickPaint(tickColor);
chart = new JFreeChart( m_text, new Font("SansSerif", Font.BOLD, 9), plot,false); //
chart = new JFreeChart( "", new Font("SansSerif", Font.BOLD, 9), plot,false);
return chart; return chart;
} }
@ -168,11 +216,9 @@ public class WPerformanceIndicator extends Panel implements EventListener<Event>
private void init() private void init()
{ {
JFreeChart chart = createChart(); JFreeChart chart = createChart();
chart.setBackgroundPaint(Color.WHITE); chart.setBackgroundPaint(chartBackground);
chart.setBorderVisible(true);
chart.setBorderPaint(Color.LIGHT_GRAY);
chart.setAntiAlias(true); chart.setAntiAlias(true);
BufferedImage bi = chart.createBufferedImage(200, 120, BufferedImage.TRANSLUCENT , null); BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT , null);
try { try {
byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
@ -183,7 +229,7 @@ public class WPerformanceIndicator extends Panel implements EventListener<Event>
} }
catch (Exception e) catch (Exception e)
{ {
// TODO: handle exception e.printStackTrace();
} }
invalidate(); invalidate();
@ -202,4 +248,15 @@ public class WPerformanceIndicator extends Panel implements EventListener<Event>
public void onEvent(Event event) throws Exception public void onEvent(Event event) throws Exception
{ {
} }
public String getTitle()
{
return m_text;
}
public static class Options {
public Map<String, Color> colorMap;
public int chartWidth;
public int chartHeight;
}
} }

View File

@ -11,7 +11,11 @@ public class WViewPI extends ADForm {
@Override @Override
protected void initForm() { protected void initForm() {
WPAPanel paPanel = WPAPanel.get(); this.setSclass("window-view-pi");
WPerformanceIndicator.Options options = new WPerformanceIndicator.Options();
options.chartHeight = 180;
options.chartWidth = 180;
WPAPanel paPanel = WPAPanel.get(options);
appendChild(paPanel); appendChild(paPanel);
} }

View File

@ -32,6 +32,7 @@ import java.util.TimeZone;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager;
import org.compiere.model.MSysConfig; import org.compiere.model.MSysConfig;
import org.compiere.model.X_R_RequestType; import org.compiere.model.X_R_RequestType;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -103,7 +104,7 @@ public class CalendarWindow extends Window implements EventListener<Event> {
setTitle(Msg.getMsg(ctx,"Calendar")); setTitle(Msg.getMsg(ctx,"Calendar"));
setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED); setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
Component component = Executions.createComponents("calendar.zul", this, null); Component component = Executions.createComponents(ThemeManager.getThemeResource("/zul/calendar/calendar.zul"), this, null);
Borderlayout borderlayout = (Borderlayout) component.getFellow("main"); Borderlayout borderlayout = (Borderlayout) component.getFellow("main");
borderlayout.setStyle("position: absolute"); borderlayout.setStyle("position: absolute");

View File

@ -13,18 +13,14 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.webui.dashboard; package org.adempiere.webui.dashboard;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.desktop.IDesktop; import org.adempiere.webui.desktop.IDesktop;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ServerPushTemplate; import org.adempiere.webui.util.ServerPushTemplate;
import org.compiere.model.MRole;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -57,6 +53,7 @@ public class DPActivities extends DashboardPanel implements EventListener<Event>
*/ */
private static final long serialVersionUID = 3787249181565314148L; private static final long serialVersionUID = 3787249181565314148L;
@SuppressWarnings("unused")
private static final CLogger logger = CLogger.getCLogger(DPActivities.class); private static final CLogger logger = CLogger.getCLogger(DPActivities.class);
private Button btnNotice, btnRequest, btnWorkflow, btnUnprocessed; private Button btnNotice, btnRequest, btnWorkflow, btnUnprocessed;
@ -106,7 +103,7 @@ public class DPActivities extends DashboardPanel implements EventListener<Event>
btnWorkflow.setName(String.valueOf(AD_Menu_ID)); btnWorkflow.setName(String.valueOf(AD_Menu_ID));
btnWorkflow.addEventListener(Events.ON_CLICK, this); btnWorkflow.addEventListener(Events.ON_CLICK, this);
if (isShowUnprocessed()) { if (DPActivitiesModel.isShowUnprocessed()) {
btnUnprocessed = new Button(); btnUnprocessed = new Button();
vbox.appendChild(btnUnprocessed); vbox.appendChild(btnUnprocessed);
labelU = Util.cleanAmp(Msg.translate(Env.getCtx(), "UnprocessedDocs")); labelU = Util.cleanAmp(Msg.translate(Env.getCtx(), "UnprocessedDocs"));
@ -121,116 +118,15 @@ public class DPActivities extends DashboardPanel implements EventListener<Event>
return vbox; return vbox;
} }
private static boolean isShowUnprocessed() {
return (Env.getAD_Client_ID(Env.getCtx()) > 0);
}
/**
* Get notice count
* @return number of notice
*/
public static int getNoticeCount()
{
String sql = "SELECT COUNT(1) FROM AD_Note "
+ "WHERE AD_Client_ID=? AND AD_User_ID IN (0,?)"
+ " AND Processed='N' AND AD_BroadcastMessage_ID IS NULL";
int retValue = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx()), Env.getAD_User_ID(Env.getCtx()));
return retValue;
}
/**
* Get request count
* @return number of request
*/
public static int getRequestCount()
{
String sql = MRole.getDefault().addAccessSQL ("SELECT COUNT(1) FROM R_Request "
+ "WHERE (SalesRep_ID=? OR AD_Role_ID=?) AND Processed='N'"
+ " AND (DateNextAction IS NULL OR TRUNC(DateNextAction) <= TRUNC(SysDate))"
+ " AND (R_Status_ID IS NULL OR R_Status_ID IN (SELECT R_Status_ID FROM R_Status WHERE IsClosed='N'))",
"R_Request", false, true); // not qualified - RW
int retValue = DB.getSQLValue(null, sql, Env.getAD_User_ID(Env.getCtx()), Env.getAD_Role_ID(Env.getCtx()));
return retValue;
}
/**
* Get workflow activity count
* @return number of workflow activity
*/
public static int getWorkflowCount()
{
int count = 0;
String sql = "SELECT count(*) FROM AD_WF_Activity a "
+ "WHERE "
+ "a.Processed='N' AND a.WFState='OS' AND ("
// Owner of Activity
+ " a.AD_User_ID=?" // #1
// Invoker (if no invoker = all)
+ " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID"
+ " AND r.ResponsibleType='H' AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" // #2
// Responsible User
+ " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID"
+ " AND r.ResponsibleType='H' AND r.AD_User_ID=?)" // #3
// Responsible Role
+ " OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)"
+ " WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND r.ResponsibleType='R' AND ur.AD_User_ID=?)" // #4
//
+ ") AND a.AD_Client_ID=?"; // #5
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, AD_User_ID);
pstmt.setInt (2, AD_User_ID);
pstmt.setInt (3, AD_User_ID);
pstmt.setInt (4, AD_User_ID);
pstmt.setInt (5, AD_Client_ID);
rs = pstmt.executeQuery ();
if (rs.next ()) {
count = rs.getInt(1);
}
}
catch (Exception e)
{
logger.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return count;
}
/**
* Get unprocessed count
* @return number of unprocessed
*/
public static int getUnprocessedCount()
{
if (! isShowUnprocessed())
return 0;
String sql = "SELECT COUNT(1) FROM RV_Unprocessed "
+ "WHERE AD_Client_ID=? AND CreatedBy=?";
int retValue = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx()), Env.getAD_User_ID(Env.getCtx()));
return retValue;
}
@Override @Override
public void refresh(ServerPushTemplate template) public void refresh(ServerPushTemplate template)
{ {
int notice = getNoticeCount(); int notice = DPActivitiesModel.getNoticeCount();
int request = getRequestCount(); int request = DPActivitiesModel.getRequestCount();
int workflow = getWorkflowCount(); int workflow = DPActivitiesModel.getWorkflowCount();
int unprocessed = getUnprocessedCount(); int unprocessed = DPActivitiesModel.getUnprocessedCount();
if (noOfNotice != notice || noOfRequest != request if (noOfNotice != notice || noOfRequest != request
|| noOfWorkflow != workflow || noOfUnprocessed != unprocessed ) || noOfWorkflow != workflow || noOfUnprocessed != unprocessed )
{ {
@ -247,7 +143,8 @@ public class DPActivities extends DashboardPanel implements EventListener<Event>
btnNotice.setLabel(labelN + " : " + noOfNotice); btnNotice.setLabel(labelN + " : " + noOfNotice);
btnRequest.setLabel(labelR + " : " + noOfRequest); btnRequest.setLabel(labelR + " : " + noOfRequest);
btnWorkflow.setLabel(labelW + " : " + noOfWorkflow); btnWorkflow.setLabel(labelW + " : " + noOfWorkflow);
if (isShowUnprocessed()) btnUnprocessed.setLabel(labelU + " : " + noOfUnprocessed); if (DPActivitiesModel.isShowUnprocessed())
btnUnprocessed.setLabel(labelU + " : " + noOfUnprocessed);
EventQueue<Event> queue = EventQueues.lookup(IDesktop.ACTIVITIES_EVENT_QUEUE, true); EventQueue<Event> queue = EventQueues.lookup(IDesktop.ACTIVITIES_EVENT_QUEUE, true);
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();

View File

@ -0,0 +1,143 @@
/******************************************************************************
* Copyright (C) 2008 Elaine Tan *
* Copyright (C) 2008 Idalica Corporation *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.webui.dashboard;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level;
import org.compiere.model.MRole;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
/**
* Dashboard item: Workflow activities, notices and requests
* @author Elaine
* @date November 20, 2008
*
* Contributors:
* CarlosRuiz - globalqss - Add unprocessed button to iDempiere
*
*
* Contributors:
* Deepak Pansheriya - showing only notes message
*/
public class DPActivitiesModel {
private static final CLogger logger = CLogger.getCLogger(DPActivitiesModel.class);
public static boolean isShowUnprocessed() {
return (Env.getAD_Client_ID(Env.getCtx()) > 0);
}
/**
* Get notice count
* @return number of notice
*/
public static int getNoticeCount()
{
String sql = "SELECT COUNT(1) FROM AD_Note "
+ "WHERE AD_Client_ID=? AND AD_User_ID IN (0,?)"
+ " AND Processed='N' AND AD_BroadcastMessage_ID IS NULL";
int retValue = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx()), Env.getAD_User_ID(Env.getCtx()));
return retValue;
}
/**
* Get request count
* @return number of request
*/
public static int getRequestCount()
{
String sql = MRole.getDefault().addAccessSQL ("SELECT COUNT(1) FROM R_Request "
+ "WHERE (SalesRep_ID=? OR AD_Role_ID=?) AND Processed='N'"
+ " AND (DateNextAction IS NULL OR TRUNC(DateNextAction) <= TRUNC(SysDate))"
+ " AND (R_Status_ID IS NULL OR R_Status_ID IN (SELECT R_Status_ID FROM R_Status WHERE IsClosed='N'))",
"R_Request", false, true); // not qualified - RW
int retValue = DB.getSQLValue(null, sql, Env.getAD_User_ID(Env.getCtx()), Env.getAD_Role_ID(Env.getCtx()));
return retValue;
}
/**
* Get workflow activity count
* @return number of workflow activity
*/
public static int getWorkflowCount()
{
int count = 0;
String sql = "SELECT count(*) FROM AD_WF_Activity a "
+ "WHERE "
+ "a.Processed='N' AND a.WFState='OS' AND ("
// Owner of Activity
+ " a.AD_User_ID=?" // #1
// Invoker (if no invoker = all)
+ " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID"
+ " AND r.ResponsibleType='H' AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" // #2
// Responsible User
+ " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID"
+ " AND r.ResponsibleType='H' AND r.AD_User_ID=?)" // #3
// Responsible Role
+ " OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)"
+ " WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND r.ResponsibleType='R' AND ur.AD_User_ID=?)" // #4
//
+ ") AND a.AD_Client_ID=?"; // #5
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, AD_User_ID);
pstmt.setInt (2, AD_User_ID);
pstmt.setInt (3, AD_User_ID);
pstmt.setInt (4, AD_User_ID);
pstmt.setInt (5, AD_Client_ID);
rs = pstmt.executeQuery ();
if (rs.next ()) {
count = rs.getInt(1);
}
}
catch (Exception e)
{
logger.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return count;
}
/**
* Get unprocessed count
* @return number of unprocessed
*/
public static int getUnprocessedCount()
{
if (! isShowUnprocessed())
return 0;
String sql = "SELECT COUNT(1) FROM RV_Unprocessed "
+ "WHERE AD_Client_ID=? AND CreatedBy=?";
int retValue = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx()), Env.getAD_User_ID(Env.getCtx()));
return retValue;
}
}

View File

@ -30,6 +30,7 @@ import org.adempiere.base.event.AbstractEventHandler;
import org.adempiere.base.event.EventManager; import org.adempiere.base.event.EventManager;
import org.adempiere.base.event.IEventTopics; import org.adempiere.base.event.IEventTopics;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ServerPushTemplate; import org.adempiere.webui.util.ServerPushTemplate;
import org.compiere.model.I_R_Request; import org.compiere.model.I_R_Request;
import org.compiere.model.PO; import org.compiere.model.PO;
@ -55,9 +56,8 @@ import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Button;
import org.zkoss.zul.Label; import org.zkoss.zul.Label;
import org.zkoss.zul.Toolbarbutton; import org.zkoss.zul.impl.LabelImageElement;
/** /**
* Dashboard item: ZK calendar * Dashboard item: ZK calendar
@ -74,9 +74,9 @@ public class DPCalendar extends DashboardPanel implements EventListener<Event>,
private static final long serialVersionUID = -224914882522997787L; private static final long serialVersionUID = -224914882522997787L;
private Calendars calendars; private Calendars calendars;
private SimpleCalendarModel scm; private SimpleCalendarModel scm;
private Toolbarbutton btnCal, btnRefresh; private LabelImageElement btnCal, btnRefresh;
private Button btnCurrentDate; private LabelImageElement btnCurrentDate;
private Label lblDate; private Label lblDate;
private Component divArrowLeft, divArrowRight; private Component divArrowLeft, divArrowRight;
@ -98,17 +98,17 @@ public class DPCalendar extends DashboardPanel implements EventListener<Event>,
ctx = new Properties(); ctx = new Properties();
ctx.putAll(Env.getCtx()); ctx.putAll(Env.getCtx());
Component component = Executions.createComponents("calendar_mini.zul", this, null); Component component = Executions.createComponents(ThemeManager.getThemeResource("zul/calendar/calendar_mini.zul"), this, null);
calendars = (Calendars) component.getFellow("cal"); calendars = (Calendars) component.getFellow("cal");
btnCal = (Toolbarbutton) component.getFellow("btnCal"); btnCal = (LabelImageElement) component.getFellow("btnCal");
btnCal.addEventListener(Events.ON_CLICK, this); btnCal.addEventListener(Events.ON_CLICK, this);
btnRefresh = (Toolbarbutton) component.getFellow("btnRefresh"); btnRefresh = (LabelImageElement) component.getFellow("btnRefresh");
btnRefresh.addEventListener(Events.ON_CLICK, this); btnRefresh.addEventListener(Events.ON_CLICK, this);
btnCurrentDate = (Button) component.getFellow("btnCurrentDate"); btnCurrentDate = (LabelImageElement) component.getFellow("btnCurrentDate");
btnCurrentDate.addEventListener(Events.ON_CLICK, this); btnCurrentDate.addEventListener(Events.ON_CLICK, this);
lblDate = (Label) component.getFellow("lblDate"); lblDate = (Label) component.getFellow("lblDate");

View File

@ -159,7 +159,7 @@ public class DPFavourites extends DashboardPanel implements EventListener<Event>
if (addNewBtn) if (addNewBtn)
{ {
Toolbarbutton newBtn = new Toolbarbutton(null, ThemeManager.getThemeResource("images/New10.png")); Toolbarbutton newBtn = new Toolbarbutton(null, ThemeManager.getThemeResource("images/New16.png"));
newBtn.setAttribute(NODE_ID_ATTR, String.valueOf(nodeId)); newBtn.setAttribute(NODE_ID_ATTR, String.valueOf(nodeId));
hbox.appendChild(newBtn); hbox.appendChild(newBtn);
newBtn.addEventListener(Events.ON_CLICK, this); newBtn.addEventListener(Events.ON_CLICK, this);

View File

@ -37,14 +37,20 @@ public class DPPerformance extends DashboardPanel {
public DPPerformance() public DPPerformance()
{ {
super(); super();
setSclass("performance-widget");
WPAPanel paPanel = WPAPanel.get(); WPAPanel paPanel = createPAPanel();
if (paPanel != null) if (paPanel != null)
{ {
this.appendChild(paPanel); this.appendChild(paPanel);
} }
} }
protected WPAPanel createPAPanel() {
WPAPanel paPanel = WPAPanel.get();
return paPanel;
}
public void refresh(ServerPushTemplate template) { public void refresh(ServerPushTemplate template) {
super.refresh(template); super.refresh(template);
if (Executions.getCurrent() != null) if (Executions.getCurrent() != null)
@ -62,6 +68,8 @@ public class DPPerformance extends DashboardPanel {
//adjust window height to match grid height //adjust window height to match grid height
public void onPostRender() public void onPostRender()
{
if (this.getFirstChild() != null)
{ {
Component grid = this.getFirstChild().getFirstChild(); Component grid = this.getFirstChild().getFirstChild();
String script = "setTimeout(function() { var grid = jq('#" + grid.getUuid() + "');"; String script = "setTimeout(function() { var grid = jq('#" + grid.getUuid() + "');";
@ -69,4 +77,5 @@ public class DPPerformance extends DashboardPanel {
if (Executions.getCurrent() != null) if (Executions.getCurrent() != null)
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
} }
}
} }

View File

@ -67,6 +67,7 @@ import org.zkoss.zul.Anchorchildren;
import org.zkoss.zul.Anchorlayout; import org.zkoss.zul.Anchorlayout;
import org.zkoss.zul.Html; import org.zkoss.zul.Html;
import org.zkoss.zul.Iframe; import org.zkoss.zul.Iframe;
import org.zkoss.zul.Include;
import org.zkoss.zul.Panel; import org.zkoss.zul.Panel;
import org.zkoss.zul.Panelchildren; import org.zkoss.zul.Panelchildren;
import org.zkoss.zul.Separator; import org.zkoss.zul.Separator;
@ -313,6 +314,9 @@ public class DashboardController implements EventListener<Event> {
Component component = Executions.createComponents(url, content, null); Component component = Executions.createComponents(url, content, null);
if(component != null) if(component != null)
{ {
if (component instanceof Include)
component = component.getFirstChild();
if (component instanceof DashboardPanel) if (component instanceof DashboardPanel)
{ {
DashboardPanel dashboardPanel = (DashboardPanel) component; DashboardPanel dashboardPanel = (DashboardPanel) component;

View File

@ -96,9 +96,9 @@ import org.zkoss.zul.West;
*/ */
public class DefaultDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener<Event>, EventHandler, DesktopCleanup public class DefaultDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener<Event>, EventHandler, DesktopCleanup
{ {
private static final String IMAGES_UPARROW_PNG = "images/uparrow.png"; private static final String IMAGES_UPARROW_PNG = "images/collapse-header.png";
private static final String IMAGES_DOWNARROW_PNG = "images/downarrow.png"; private static final String IMAGES_DOWNARROW_PNG = "images/expand-header.png";
/** /**
* generated serial version ID * generated serial version ID
@ -267,6 +267,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
toolbar.appendChild(max); toolbar.appendChild(max);
max.setImage(ThemeManager.getThemeResource(IMAGES_UPARROW_PNG)); max.setImage(ThemeManager.getThemeResource(IMAGES_UPARROW_PNG));
max.addEventListener(Events.ON_CLICK, this); max.addEventListener(Events.ON_CLICK, this);
max.setStyle("cursor: pointer; border: 1px solid transparent; padding: 2px;");
return layout; return layout;
} }

View File

@ -28,6 +28,7 @@ import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.component.ZkCssHelper; import org.adempiere.webui.component.ZkCssHelper;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.window.InfoSchedule; import org.adempiere.webui.window.InfoSchedule;
import org.compiere.model.MAssignmentSlot; import org.compiere.model.MAssignmentSlot;
import org.compiere.model.ScheduleUtil; import org.compiere.model.ScheduleUtil;
@ -136,7 +137,7 @@ public class WSchedule extends Window implements EventListener<Event>
{ {
this.getChildren().clear(); this.getChildren().clear();
calendarContainer = Executions.createComponents("calendar.zul", this, null); calendarContainer = Executions.createComponents(ThemeManager.getThemeResource("/zul/calendar/calendar.zul"), this, null);
borderlayout = (Borderlayout) calendarContainer.getFellow("main"); borderlayout = (Borderlayout) calendarContainer.getFellow("main");
borderlayout.setStyle("position: absolute; width: 98%; margin: auto;"); borderlayout.setStyle("position: absolute; width: 98%; margin: auto;");

View File

@ -10,11 +10,11 @@ bin.includes = META-INF/,\
zul/,\ zul/,\
timeout.zul,\ timeout.zul,\
plugin.xml,\ plugin.xml,\
calendar.css,\ theme/default/zul/calendar/calendar.css,\
calendar.zul,\ theme/default/zul/calendar/calendar.zul,\
calendar_mini.zul,\ theme/default/zul/calendar/calendar_mini.zul,\
divarrow.zul,\ theme/default/zul/calendar/divarrow.zul,\
divtab.zul,\ theme/default/zul/calendar/divtab.zul,\
OSGI-INF/,\ OSGI-INF/,\
OSGI-INF/reportviewerprovider.xml,\ OSGI-INF/reportviewerprovider.xml,\
OSGI-INF/defaultinfofactory.xml,\ OSGI-INF/defaultinfofactory.xml,\
@ -43,11 +43,11 @@ src.includes = WEB-INF/classes/,\
theme/,\ theme/,\
theme.zs,\ theme.zs,\
zul/,\ zul/,\
calendar.css,\ theme/default/zul/calendar/calendar.css,\
calendar.zul,\ theme/default/zul/calendar/calendar.zul,\
calendar_mini.zul,\ theme/default/zul/calendar/calendar_mini.zul,\
divarrow.zul,\ theme/default/zul/calendar/divarrow.zul,\
divtab.zul theme/default/zul/calendar/divtab.zul
source.. = WEB-INF/src/ source.. = WEB-INF/src/
bin.excludes = WEB-INF/src/,\ bin.excludes = WEB-INF/src/,\
WEB-INF/web-2.5.xml,\ WEB-INF/web-2.5.xml,\

View File

@ -140,8 +140,7 @@ html,body {
} }
.fav-new-btn { .fav-new-btn {
margin-top: 4px; margin-left: 4px;
margin-left: 2px;
} }
.disableFilter img { .disableFilter img {
@ -458,8 +457,33 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
margin-left: 4px !important; margin-left: 4px !important;
} }
.desktop-tabbox .z-toolbar-tabs-body { .desktop-tabbox .z-tabs .z-toolbar-tabs-body {
padding-top: 10px !important; padding: 0px !important;
margin: 0px !important;
}
.desktop-tabbox .z-tabs .z-toolbar-tabs-body .z-toolbarbutton {
padding: 0px !important;
border: 1px solid transparent !important;
margin: 0px !important;
}
.desktop-tabbox .z-tabs .z-toolbar-tabs .z-toolbarbutton-over .z-toolbarbutton-body {
border: none !important;
padding: 0px !important;
margin: 0px !important;
}
.desktop-tabbox .z-tabs .z-toolbar-tabs .z-toolbarbutton-over .z-toolbarbutton-cnt {
background-image: none !important;
background-color:#DDD !important;
padding: 0px !important;
margin: 0px !important;
-webkit-box-shadow:inset 0px 0px 3px #CCC;
-moz-box-shadow:inset 0px 0px 3px #CCC;
-o-box-shadow:inset 0px 0px 3px #CCC;
-ms-box-shadow:inset 0px 0px 3px #CCC;
box-shadow:inset 0px 0px 3px #CCC;
} }
.desktop-menu-popup { .desktop-menu-popup {
@ -1509,3 +1533,37 @@ font-size: 0;
table.z-vbox > tbody > tr > td > table { table.z-vbox > tbody > tr > td > table {
width: 100%; width: 100%;
} }
<%-- performance indicator --%>
.performance-indicator {
margin: auto;
position: relative;
width: 120px !important;
}
.window-view-pi .performance-indicator {
width: 180px !important;
}
.performance-indicator-box {
background-color: #eee;
border: 1px solid #d8d8d8;
border-radius: 5px;
cursor: pointer;
}
.performance-indicator-title {
text-align: center;
background-color: #c8c8c8;
border: 1px solid #c8c8c8;
padding-top: 4px;
padding-bottom: 4px;
}
.performance-panel .z-grid {
border: none;
margin:0;
padding:0;
position: relative;
width: 100%;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?component name="divtab" macro-uri="divtab.zul"?> <?component name="divtab" macro-uri="/theme/default/zul/calendar/divtab.zul"?>
<?component name="divarrow" macro-uri="divarrow.zul"?> <?component name="divarrow" macro-uri="/theme/default/zul/calendar/divarrow.zul"?>
<zk> <zk>
<zscript><![CDATA[ <zscript><![CDATA[
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -18,10 +18,10 @@
var RequestType = Msg.getElement(Env.getCtx(),"RequestType"); var RequestType = Msg.getElement(Env.getCtx(),"RequestType");
]]></zscript> ]]></zscript>
<style src="calendar.css"/> <style src="/theme/default/zul/calendar/calendar.css"/>
<borderlayout id="main"> <borderlayout id="main">
<center border="none"> <center border="none">
<calendars firstDayOfWeek="Monday" model="${cm}" mold="month" id="cal"> <calendars firstDayOfWeek="Monday" mold="month" id="cal">
<toolbar sclass="calendar-toolbar"> <toolbar sclass="calendar-toolbar">
<div class="float-left"> <div class="float-left">
<hbox> <hbox>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?component name="divarrow" macro-uri="divarrow.zul"?> <?component name="divarrow" macro-uri="/theme/default/zul/calendar/divarrow.zul"?>
<zk> <zk>
<zscript><![CDATA[ <zscript><![CDATA[
var calendarIcon = org.adempiere.webui.theme.ThemeManager.getThemeResource("images/Calendar16.png"); var calendarIcon = org.adempiere.webui.theme.ThemeManager.getThemeResource("images/Calendar16.png");
@ -9,8 +9,8 @@
var today = Msg.getMsg(Env.getCtx(),"Today"); var today = Msg.getMsg(Env.getCtx(),"Today");
var refresh = Util.cleanAmp(Msg.getMsg(Env.getCtx(),"Refresh")); var refresh = Util.cleanAmp(Msg.getMsg(Env.getCtx(),"Refresh"));
]]></zscript> ]]></zscript>
<style src="calendar.css"/> <style src="/theme/default/zul/calendar/calendar.css"/>
<calendars firstDayOfWeek="Monday" model="${cm}" mold="month" id="cal"> <calendars firstDayOfWeek="Monday" mold="month" id="cal">
<toolbar sclass="calendar-toolbar"> <toolbar sclass="calendar-toolbar">
<div class="float-left"> <div class="float-left">
<hbox> <hbox>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPActivities"/>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPCalendar"/>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPFavourites"/>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPPerformance"/>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPRecentItems"/>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPViews"/>

View File

@ -1,2 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPActivities"/> <zk>
<zscript>
<![CDATA[
import org.adempiere.webui.theme.ThemeManager;
var path = ThemeManager.getThemeResource("zul/dashboard/activities.zul");
]]>
</zscript>
<include src="${path}"/>
</zk>

View File

@ -1,2 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPCalendar"/> <zk>
<zscript>
<![CDATA[
import org.adempiere.webui.theme.ThemeManager;
var path = ThemeManager.getThemeResource("zul/dashboard/calendar.zul");
]]>
</zscript>
<include src="${path}"/>
</zk>

View File

@ -1,2 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPFavourites"/> <zk>
<zscript>
<![CDATA[
import org.adempiere.webui.theme.ThemeManager;
var path = ThemeManager.getThemeResource("zul/dashboard/favourites.zul");
]]>
</zscript>
<include src="${path}"/>
</zk>

View File

@ -1,2 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPPerformance"/> <zk>
<zscript>
<![CDATA[
import org.adempiere.webui.theme.ThemeManager;
var path = ThemeManager.getThemeResource("zul/dashboard/performance.zul");
]]>
</zscript>
<include src="${path}" />
</zk>

View File

@ -1,2 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPRecentItems"/> <zk>
<zscript>
<![CDATA[
import org.adempiere.webui.theme.ThemeManager;
var path = ThemeManager.getThemeResource("zul/dashboard/recentItems.zul");
]]>
</zscript>
<include src="${path}"/>
</zk>

View File

@ -1,2 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<window use="org.adempiere.webui.dashboard.DPViews"/> <zk>
<zscript>
<![CDATA[
import org.adempiere.webui.theme.ThemeManager;
var path = ThemeManager.getThemeResource("zul/dashboard/views.zul");
]]>
</zscript>
<include src="${path}"/>
</zk>