Refactor custom form - ID: 2787613
This commit is contained in:
parent
a5bb19faa6
commit
b2e69c349f
|
@ -0,0 +1,211 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (C) 2009 Low Heng Sin *
|
||||||
|
* Copyright (C) 2009 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.compiere.apps.form;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
import org.compiere.model.MArchive;
|
||||||
|
import org.compiere.model.MBPartner;
|
||||||
|
import org.compiere.model.MRole;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.TimeUtil;
|
||||||
|
|
||||||
|
public class Archive {
|
||||||
|
|
||||||
|
/** Window No */
|
||||||
|
public int m_WindowNo = 0;
|
||||||
|
/** The Archives */
|
||||||
|
public MArchive[] m_archives = new MArchive[0];
|
||||||
|
/** Archive Index */
|
||||||
|
public int m_index = 0;
|
||||||
|
/** Table direct */
|
||||||
|
public int m_AD_Table_ID = 0;
|
||||||
|
/** Record direct */
|
||||||
|
public int m_Record_ID = 0;
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
public static CLogger log = CLogger.getCLogger(Archive.class);
|
||||||
|
|
||||||
|
public KeyNamePair[] getProcessData()
|
||||||
|
{
|
||||||
|
// Processes
|
||||||
|
int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx());
|
||||||
|
|
||||||
|
boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Process");
|
||||||
|
String lang = Env.getAD_Language(Env.getCtx());
|
||||||
|
// TODO: ASP - implement process and window access ASP control
|
||||||
|
String sql = "SELECT DISTINCT p.AD_Process_ID,"
|
||||||
|
+ (trl ? "trl.Name" : "p.Name ")
|
||||||
|
+ " FROM AD_Process p INNER JOIN AD_Process_Access pa ON (p.AD_Process_ID=pa.AD_Process_ID) "
|
||||||
|
+ (trl ? "LEFT JOIN AD_Process_Trl trl on (trl.AD_Process_ID=p.AD_Process_ID and trl.AD_Language=" + DB.TO_STRING(lang) + ")" : "")
|
||||||
|
+ " WHERE pa.AD_Role_ID=" + AD_Role_ID
|
||||||
|
+ " AND p.IsReport='Y' AND p.IsActive='Y' AND pa.IsActive='Y' "
|
||||||
|
+ "ORDER BY 2";
|
||||||
|
return DB.getKeyNamePairs(sql, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyNamePair[] getTableData()
|
||||||
|
{
|
||||||
|
// Tables
|
||||||
|
int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx());
|
||||||
|
boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Table");
|
||||||
|
String lang = Env.getAD_Language(Env.getCtx());
|
||||||
|
String sql = "SELECT DISTINCT t.AD_Table_ID,"
|
||||||
|
+ (trl ? "trl.Name" : "t.Name")
|
||||||
|
+ " FROM AD_Table t INNER JOIN AD_Tab tab ON (tab.AD_Table_ID=t.AD_Table_ID)"
|
||||||
|
+ " INNER JOIN AD_Window_Access wa ON (tab.AD_Window_ID=wa.AD_Window_ID) "
|
||||||
|
+ (trl ? "LEFT JOIN AD_Table_Trl trl on (trl.AD_Table_ID=t.AD_Table_ID and trl.AD_Language=" + DB.TO_STRING(lang) + ")" : "")
|
||||||
|
+ " WHERE wa.AD_Role_ID=" + AD_Role_ID
|
||||||
|
+ " AND t.IsActive='Y' AND tab.IsActive='Y' "
|
||||||
|
+ "ORDER BY 2";
|
||||||
|
return DB.getKeyNamePairs(sql, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyNamePair[] getUserData()
|
||||||
|
{
|
||||||
|
// Internal Users
|
||||||
|
String sql = "SELECT AD_User_ID, Name "
|
||||||
|
+ "FROM AD_User u WHERE EXISTS "
|
||||||
|
+"(SELECT * FROM AD_User_Roles ur WHERE u.AD_User_ID=ur.AD_User_ID) "
|
||||||
|
+ "ORDER BY 2";
|
||||||
|
return DB.getKeyNamePairs(sql, true);
|
||||||
|
} // dynInit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is it the same
|
||||||
|
* @param s1 s1
|
||||||
|
* @param s2 s1
|
||||||
|
* @return true if the same
|
||||||
|
*/
|
||||||
|
public boolean isSame(String s1, String s2)
|
||||||
|
{
|
||||||
|
if (s1 == null)
|
||||||
|
return s2 == null;
|
||||||
|
else if (s2 == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return s1.equals(s2);
|
||||||
|
} // isSame
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Create Query
|
||||||
|
*/
|
||||||
|
public void cmd_query(boolean reports, KeyNamePair process, KeyNamePair table, Integer C_BPartner_ID,
|
||||||
|
String name, String description, String help, KeyNamePair createdBy,
|
||||||
|
Timestamp createdFrom, Timestamp createdTo)
|
||||||
|
{
|
||||||
|
StringBuffer sql = new StringBuffer();
|
||||||
|
MRole role = MRole.getDefault();
|
||||||
|
if (!role.isCanReport())
|
||||||
|
{
|
||||||
|
log.warning("User/Role cannot Report AD_User_ID=" + Env.getAD_User_ID(Env.getCtx()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sql.append(" AND IsReport=").append(reports ? "'Y'" : "'N'");
|
||||||
|
|
||||||
|
// Process
|
||||||
|
if (reports)
|
||||||
|
{
|
||||||
|
if (process != null && process.getKey() > 0)
|
||||||
|
sql.append(" AND AD_Process_ID=").append(process.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table
|
||||||
|
if (m_AD_Table_ID > 0)
|
||||||
|
{
|
||||||
|
sql.append(" AND ((AD_Table_ID=").append(m_AD_Table_ID);
|
||||||
|
if (m_Record_ID > 0)
|
||||||
|
sql.append(" AND Record_ID=").append(m_Record_ID);
|
||||||
|
sql.append(")");
|
||||||
|
if (m_AD_Table_ID == MBPartner.Table_ID && m_Record_ID > 0)
|
||||||
|
sql.append(" OR C_BPartner_ID=").append(m_Record_ID);
|
||||||
|
sql.append(")");
|
||||||
|
// Reset for query
|
||||||
|
m_AD_Table_ID = 0;
|
||||||
|
m_Record_ID = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (table != null && table.getKey() > 0)
|
||||||
|
sql.append(" AND AD_Table_ID=").append(table.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Business Partner
|
||||||
|
if (!reports)
|
||||||
|
{
|
||||||
|
if (C_BPartner_ID != null)
|
||||||
|
sql.append(" AND C_BPartner_ID=").append(C_BPartner_ID);
|
||||||
|
else
|
||||||
|
sql.append(" AND C_BPartner_ID IS NOT NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name
|
||||||
|
if (name != null && name.length() > 0)
|
||||||
|
{
|
||||||
|
if (name.indexOf('%') != -1 || name.indexOf('_') != -1)
|
||||||
|
sql.append(" AND Name LIKE ").append(DB.TO_STRING(name));
|
||||||
|
else
|
||||||
|
sql.append(" AND Name=").append(DB.TO_STRING(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Description
|
||||||
|
if (description != null && description.length() > 0)
|
||||||
|
{
|
||||||
|
if (description.indexOf('%') != -1 || description.indexOf('_') != -1)
|
||||||
|
sql.append(" AND Description LIKE ").append(DB.TO_STRING(description));
|
||||||
|
else
|
||||||
|
sql.append(" AND Description=").append(DB.TO_STRING(description));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Help
|
||||||
|
if (help != null && help.length() > 0)
|
||||||
|
{
|
||||||
|
if (help.indexOf('%') != -1 || help.indexOf('_') != -1)
|
||||||
|
sql.append(" AND Help LIKE ").append(DB.TO_STRING(help));
|
||||||
|
else
|
||||||
|
sql.append(" AND Help=").append(DB.TO_STRING(help));
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedBy
|
||||||
|
if (createdBy != null && createdBy.getKey() > 0)
|
||||||
|
sql.append(" AND CreatedBy=").append(createdBy.getKey());
|
||||||
|
|
||||||
|
// Created
|
||||||
|
if (createdFrom != null)
|
||||||
|
sql.append(" AND Created>=").append(DB.TO_DATE(createdFrom, true));
|
||||||
|
if (createdTo != null)
|
||||||
|
sql.append(" AND Created<").append(DB.TO_DATE(TimeUtil.addDays(createdTo,1), true));
|
||||||
|
|
||||||
|
log.fine(sql.toString());
|
||||||
|
|
||||||
|
// Process Access
|
||||||
|
sql.append(" AND (AD_Process_ID IS NULL OR AD_Process_ID IN "
|
||||||
|
+ "(SELECT AD_Process_ID FROM AD_Process_Access WHERE AD_Role_ID=")
|
||||||
|
.append(role.getAD_Role_ID()).append("))");
|
||||||
|
// Table Access
|
||||||
|
sql.append(" AND (AD_Table_ID IS NULL "
|
||||||
|
+ "OR (AD_Table_ID IS NOT NULL AND AD_Process_ID IS NOT NULL) " // Menu Reports
|
||||||
|
+ "OR AD_Table_ID IN "
|
||||||
|
+ "(SELECT t.AD_Table_ID FROM AD_Tab t"
|
||||||
|
+ " INNER JOIN AD_Window_Access wa ON (t.AD_Window_ID=wa.AD_Window_ID) "
|
||||||
|
+ "WHERE wa.AD_Role_ID=").append(role.getAD_Role_ID()).append("))");
|
||||||
|
log.finest(sql.toString());
|
||||||
|
//
|
||||||
|
m_archives = MArchive.get(Env.getCtx(), sql.toString());
|
||||||
|
log.info("Length=" + m_archives.length);
|
||||||
|
} // cmd_query
|
||||||
|
}
|
|
@ -40,8 +40,6 @@ import org.compiere.grid.ed.VLookup;
|
||||||
import org.compiere.grid.ed.VString;
|
import org.compiere.grid.ed.VString;
|
||||||
import org.compiere.grid.ed.VText;
|
import org.compiere.grid.ed.VText;
|
||||||
import org.compiere.model.MArchive;
|
import org.compiere.model.MArchive;
|
||||||
import org.compiere.model.MBPartner;
|
|
||||||
import org.compiere.model.MRole;
|
|
||||||
import org.compiere.swing.CButton;
|
import org.compiere.swing.CButton;
|
||||||
import org.compiere.swing.CCheckBox;
|
import org.compiere.swing.CCheckBox;
|
||||||
import org.compiere.swing.CComboBox;
|
import org.compiere.swing.CComboBox;
|
||||||
|
@ -49,12 +47,9 @@ import org.compiere.swing.CLabel;
|
||||||
import org.compiere.swing.CPanel;
|
import org.compiere.swing.CPanel;
|
||||||
import org.compiere.swing.CTabbedPane;
|
import org.compiere.swing.CTabbedPane;
|
||||||
import org.compiere.swing.CTextField;
|
import org.compiere.swing.CTextField;
|
||||||
import org.compiere.util.CLogger;
|
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.compiere.util.TimeUtil;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +63,7 @@ import org.compiere.util.TimeUtil;
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: ArchiveViewer.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
* @version $Id: ArchiveViewer.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class ArchiveViewer extends CTabbedPane
|
public class ArchiveViewer extends Archive
|
||||||
implements FormPanel, ActionListener, VetoableChangeListener
|
implements FormPanel, ActionListener, VetoableChangeListener
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -77,6 +72,8 @@ public class ArchiveViewer extends CTabbedPane
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 876677286190292132L;
|
private static final long serialVersionUID = 876677286190292132L;
|
||||||
|
|
||||||
|
private CTabbedPane panel = new CTabbedPane();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize Panel
|
* Initialize Panel
|
||||||
|
@ -92,7 +89,7 @@ public class ArchiveViewer extends CTabbedPane
|
||||||
{
|
{
|
||||||
dynInit();
|
dynInit();
|
||||||
jbInit();
|
jbInit();
|
||||||
frame.getContentPane().add(this, BorderLayout.CENTER);
|
frame.getContentPane().add(panel, BorderLayout.CENTER);
|
||||||
frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH);
|
frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH);
|
||||||
//
|
//
|
||||||
m_frame.setIconImage(Env.getImage("Archive16.gif"));
|
m_frame.setIconImage(Env.getImage("Archive16.gif"));
|
||||||
|
@ -103,23 +100,8 @@ public class ArchiveViewer extends CTabbedPane
|
||||||
}
|
}
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
|
|
||||||
/** Window No */
|
|
||||||
private int m_WindowNo = 0;
|
|
||||||
/** FormFrame */
|
/** FormFrame */
|
||||||
private FormFrame m_frame;
|
private FormFrame m_frame;
|
||||||
/** The Archives */
|
|
||||||
private MArchive[] m_archives = new MArchive[0];
|
|
||||||
/** Archive Index */
|
|
||||||
private int m_index = 0;
|
|
||||||
/** Table direct */
|
|
||||||
private int m_AD_Table_ID = 0;
|
|
||||||
/** Record direct */
|
|
||||||
private int m_Record_ID = 0;
|
|
||||||
|
|
||||||
/** Logger */
|
|
||||||
private static CLogger log = CLogger.getCLogger(ArchiveViewer.class);
|
|
||||||
|
|
||||||
|
|
||||||
private CPanel queryPanel = new CPanel(new GridBagLayout());
|
private CPanel queryPanel = new CPanel(new GridBagLayout());
|
||||||
private CCheckBox reportField = new CCheckBox(Msg.translate(Env.getCtx(), "IsReport"));
|
private CCheckBox reportField = new CCheckBox(Msg.translate(Env.getCtx(), "IsReport"));
|
||||||
|
@ -168,36 +150,9 @@ public class ArchiveViewer extends CTabbedPane
|
||||||
*/
|
*/
|
||||||
private void dynInit()
|
private void dynInit()
|
||||||
{
|
{
|
||||||
int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx());
|
processField = new CComboBox(getProcessData());
|
||||||
// Processes
|
tableField = new CComboBox(getTableData());
|
||||||
boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Process");
|
createdByQField = new CComboBox(getUserData());
|
||||||
String lang = Env.getAD_Language(Env.getCtx());
|
|
||||||
// TODO: ASP - implement process and window access ASP control
|
|
||||||
String sql = "SELECT DISTINCT p.AD_Process_ID,"
|
|
||||||
+ (trl ? "trl.Name" : "p.Name ")
|
|
||||||
+ " FROM AD_Process p INNER JOIN AD_Process_Access pa ON (p.AD_Process_ID=pa.AD_Process_ID) "
|
|
||||||
+ (trl ? "LEFT JOIN AD_Process_Trl trl on (trl.AD_Process_ID=p.AD_Process_ID and trl.AD_Language=" + DB.TO_STRING(lang) + ")" : "")
|
|
||||||
+ " WHERE pa.AD_Role_ID=" + AD_Role_ID
|
|
||||||
+ " AND p.IsReport='Y' AND p.IsActive='Y' AND pa.IsActive='Y' "
|
|
||||||
+ "ORDER BY 2";
|
|
||||||
processField = new CComboBox(DB.getKeyNamePairs(sql, true));
|
|
||||||
// Tables
|
|
||||||
trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Table");
|
|
||||||
sql = "SELECT DISTINCT t.AD_Table_ID,"
|
|
||||||
+ (trl ? "trl.Name" : "t.Name")
|
|
||||||
+ " FROM AD_Table t INNER JOIN AD_Tab tab ON (tab.AD_Table_ID=t.AD_Table_ID)"
|
|
||||||
+ " INNER JOIN AD_Window_Access wa ON (tab.AD_Window_ID=wa.AD_Window_ID) "
|
|
||||||
+ (trl ? "LEFT JOIN AD_Table_Trl trl on (trl.AD_Table_ID=t.AD_Table_ID and trl.AD_Language=" + DB.TO_STRING(lang) + ")" : "")
|
|
||||||
+ " WHERE wa.AD_Role_ID=" + AD_Role_ID
|
|
||||||
+ " AND t.IsActive='Y' AND tab.IsActive='Y' "
|
|
||||||
+ "ORDER BY 2";
|
|
||||||
tableField = new CComboBox(DB.getKeyNamePairs(sql, true));
|
|
||||||
// Internal Users
|
|
||||||
sql = "SELECT AD_User_ID, Name "
|
|
||||||
+ "FROM AD_User u WHERE EXISTS "
|
|
||||||
+"(SELECT * FROM AD_User_Roles ur WHERE u.AD_User_ID=ur.AD_User_ID) "
|
|
||||||
+ "ORDER BY 2";
|
|
||||||
createdByQField = new CComboBox(DB.getKeyNamePairs(sql, true));
|
|
||||||
//
|
//
|
||||||
bPartnerField = VLookup.createBPartner(m_WindowNo);
|
bPartnerField = VLookup.createBPartner(m_WindowNo);
|
||||||
} // dynInit
|
} // dynInit
|
||||||
|
@ -249,7 +204,7 @@ public class ArchiveViewer extends CTabbedPane
|
||||||
1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,0,0,0), 0, 0));
|
1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,0,0,0), 0, 0));
|
||||||
queryPanel.add(createdQTo, new GridBagConstraints(2, line,
|
queryPanel.add(createdQTo, new GridBagConstraints(2, line,
|
||||||
1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,0,0,0), 0, 0));
|
1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,0,0,0), 0, 0));
|
||||||
this.add(queryPanel, "Query");
|
panel.add(queryPanel, "Query");
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
line = 0;
|
line = 0;
|
||||||
|
@ -301,12 +256,12 @@ public class ArchiveViewer extends CTabbedPane
|
||||||
viewEnterPanel.setPreferredSize(new Dimension(220,500));
|
viewEnterPanel.setPreferredSize(new Dimension(220,500));
|
||||||
updateArchive.addActionListener(this);
|
updateArchive.addActionListener(this);
|
||||||
viewPanelSplit.setRightComponent(viewEnterPanel);
|
viewPanelSplit.setRightComponent(viewEnterPanel);
|
||||||
this.add(viewPanel, "View");
|
panel.add(viewPanel, "View");
|
||||||
//
|
//
|
||||||
confirmPanel.addActionListener(this);
|
confirmPanel.addActionListener(this);
|
||||||
updateQDisplay();
|
updateQDisplay();
|
||||||
//
|
//
|
||||||
this.setPreferredSize(new Dimension (720,500));
|
panel.setPreferredSize(new Dimension (720,500));
|
||||||
} // jbInit
|
} // jbInit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -333,7 +288,7 @@ public class ArchiveViewer extends CTabbedPane
|
||||||
dispose();
|
dispose();
|
||||||
else if (e.getActionCommand().equals(ConfirmPanel.A_OK))
|
else if (e.getActionCommand().equals(ConfirmPanel.A_OK))
|
||||||
{
|
{
|
||||||
if (getSelectedIndex() == 1)
|
if (panel.getSelectedIndex() == 1)
|
||||||
dispose();
|
dispose();
|
||||||
else
|
else
|
||||||
cmd_query();
|
cmd_query();
|
||||||
|
@ -463,22 +418,6 @@ public class ArchiveViewer extends CTabbedPane
|
||||||
updateVDisplay(false);
|
updateVDisplay(false);
|
||||||
} // cmd_updateArchive
|
} // cmd_updateArchive
|
||||||
|
|
||||||
/**
|
|
||||||
* Is it the same
|
|
||||||
* @param s1 s1
|
|
||||||
* @param s2 s1
|
|
||||||
* @return true if the same
|
|
||||||
*/
|
|
||||||
private boolean isSame (String s1, String s2)
|
|
||||||
{
|
|
||||||
if (s1 == null)
|
|
||||||
return s2 == null;
|
|
||||||
else if (s2 == null)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return s1.equals(s2);
|
|
||||||
} // isSame
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query Directly
|
* Query Directly
|
||||||
* @param isReport report
|
* @param isReport report
|
||||||
|
@ -500,117 +439,22 @@ public class ArchiveViewer extends CTabbedPane
|
||||||
*/
|
*/
|
||||||
private void cmd_query()
|
private void cmd_query()
|
||||||
{
|
{
|
||||||
StringBuffer sql = new StringBuffer();
|
|
||||||
boolean reports = reportField.isSelected();
|
boolean reports = reportField.isSelected();
|
||||||
MRole role = MRole.getDefault();
|
KeyNamePair process = (KeyNamePair)processField.getSelectedItem();
|
||||||
if (!role.isCanReport())
|
KeyNamePair table = (KeyNamePair)tableField.getSelectedItem();
|
||||||
{
|
Integer C_BPartner_ID = (Integer)bPartnerField.getValue();
|
||||||
log.warning("User/Role cannot Report AD_User_ID=" + Env.getAD_User_ID(Env.getCtx()));
|
String name = nameQField.getText();
|
||||||
return;
|
String description = descriptionQField.getText();
|
||||||
}
|
String help = helpQField.getText();
|
||||||
sql.append(" AND IsReport=").append(reports ? "'Y'" : "'N'");
|
KeyNamePair createdBy = (KeyNamePair)createdByQField.getSelectedItem();
|
||||||
|
Timestamp createdFrom = createdQFrom.getTimestamp();
|
||||||
|
Timestamp createdTo = createdQTo.getTimestamp();
|
||||||
|
|
||||||
// Process
|
cmd_query(reports, process, table, C_BPartner_ID, name, description, help,
|
||||||
if (reports)
|
createdBy, createdFrom, createdTo);
|
||||||
{
|
|
||||||
KeyNamePair nn = (KeyNamePair)processField.getSelectedItem();
|
|
||||||
if (nn != null && nn.getKey() > 0)
|
|
||||||
sql.append(" AND AD_Process_ID=").append(nn.getKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Table
|
|
||||||
if (m_AD_Table_ID > 0)
|
|
||||||
{
|
|
||||||
sql.append(" AND ((AD_Table_ID=").append(m_AD_Table_ID);
|
|
||||||
if (m_Record_ID > 0)
|
|
||||||
sql.append(" AND Record_ID=").append(m_Record_ID);
|
|
||||||
sql.append(")");
|
|
||||||
if (m_AD_Table_ID == MBPartner.Table_ID && m_Record_ID > 0)
|
|
||||||
sql.append(" OR C_BPartner_ID=").append(m_Record_ID);
|
|
||||||
sql.append(")");
|
|
||||||
// Reset for query
|
|
||||||
m_AD_Table_ID = 0;
|
|
||||||
m_Record_ID = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
KeyNamePair nn = (KeyNamePair)tableField.getSelectedItem();
|
|
||||||
if (nn != null && nn.getKey() > 0)
|
|
||||||
sql.append(" AND AD_Table_ID=").append(nn.getKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Business Partner
|
|
||||||
if (!reports)
|
|
||||||
{
|
|
||||||
Integer ii = (Integer)bPartnerField.getValue();
|
|
||||||
if (ii != null)
|
|
||||||
sql.append(" AND C_BPartner_ID=").append(ii);
|
|
||||||
else
|
|
||||||
sql.append(" AND C_BPartner_ID IS NOT NULL");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Name
|
|
||||||
String ss = nameQField.getText();
|
|
||||||
if (ss != null && ss.length() > 0)
|
|
||||||
{
|
|
||||||
if (ss.indexOf('%') != -1 || ss.indexOf('_') != -1)
|
|
||||||
sql.append(" AND Name LIKE ").append(DB.TO_STRING(ss));
|
|
||||||
else
|
|
||||||
sql.append(" AND Name=").append(DB.TO_STRING(ss));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Description
|
|
||||||
ss = descriptionQField.getText();
|
|
||||||
if (ss != null && ss.length() > 0)
|
|
||||||
{
|
|
||||||
if (ss.indexOf('%') != -1 || ss.indexOf('_') != -1)
|
|
||||||
sql.append(" AND Description LIKE ").append(DB.TO_STRING(ss));
|
|
||||||
else
|
|
||||||
sql.append(" AND Description=").append(DB.TO_STRING(ss));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Help
|
|
||||||
ss = helpQField.getText();
|
|
||||||
if (ss != null && ss.length() > 0)
|
|
||||||
{
|
|
||||||
if (ss.indexOf('%') != -1 || ss.indexOf('_') != -1)
|
|
||||||
sql.append(" AND Help LIKE ").append(DB.TO_STRING(ss));
|
|
||||||
else
|
|
||||||
sql.append(" AND Help=").append(DB.TO_STRING(ss));
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreatedBy
|
|
||||||
KeyNamePair nn = (KeyNamePair)createdByQField.getSelectedItem();
|
|
||||||
if (nn != null && nn.getKey() > 0)
|
|
||||||
sql.append(" AND CreatedBy=").append(nn.getKey());
|
|
||||||
|
|
||||||
// Created
|
|
||||||
Timestamp tt = createdQFrom.getTimestamp();
|
|
||||||
if (tt != null)
|
|
||||||
sql.append(" AND Created>=").append(DB.TO_DATE(tt, true));
|
|
||||||
tt = createdQTo.getTimestamp();
|
|
||||||
if (tt != null)
|
|
||||||
sql.append(" AND Created<").append(DB.TO_DATE(TimeUtil.addDays(tt,1), true));
|
|
||||||
|
|
||||||
log.fine(sql.toString());
|
|
||||||
|
|
||||||
// Process Access
|
|
||||||
sql.append(" AND (AD_Process_ID IS NULL OR AD_Process_ID IN "
|
|
||||||
+ "(SELECT AD_Process_ID FROM AD_Process_Access WHERE AD_Role_ID=")
|
|
||||||
.append(role.getAD_Role_ID()).append("))");
|
|
||||||
// Table Access
|
|
||||||
sql.append(" AND (AD_Table_ID IS NULL "
|
|
||||||
+ "OR (AD_Table_ID IS NOT NULL AND AD_Process_ID IS NOT NULL) " // Menu Reports
|
|
||||||
+ "OR AD_Table_ID IN "
|
|
||||||
+ "(SELECT t.AD_Table_ID FROM AD_Tab t"
|
|
||||||
+ " INNER JOIN AD_Window_Access wa ON (t.AD_Window_ID=wa.AD_Window_ID) "
|
|
||||||
+ "WHERE wa.AD_Role_ID=").append(role.getAD_Role_ID()).append("))");
|
|
||||||
log.finest(sql.toString());
|
|
||||||
//
|
|
||||||
m_archives = MArchive.get(Env.getCtx(), sql.toString());
|
|
||||||
log.info("Length=" + m_archives.length);
|
|
||||||
// Display
|
// Display
|
||||||
this.setSelectedIndex(1);
|
panel.setSelectedIndex(1);
|
||||||
m_index = 1;
|
m_index = 1;
|
||||||
updateVDisplay(false);
|
updateVDisplay(false);
|
||||||
} // cmd_query
|
} // cmd_query
|
||||||
|
|
|
@ -154,9 +154,9 @@ public class WArchive implements EventListener
|
||||||
if (e.getTarget() instanceof Menuitem)
|
if (e.getTarget() instanceof Menuitem)
|
||||||
{
|
{
|
||||||
int AD_Form_ID = 118; // ArchiveViewer
|
int AD_Form_ID = 118; // ArchiveViewer
|
||||||
Window form = ADForm.openForm(AD_Form_ID);
|
ADForm form = ADForm.openForm(AD_Form_ID);
|
||||||
|
|
||||||
WArchiveViewer av = (WArchiveViewer) form;
|
WArchiveViewer av = (WArchiveViewer) form.getICustomForm();
|
||||||
if (e.getTarget() == m_documents)
|
if (e.getTarget() == m_documents)
|
||||||
av.query(false, m_AD_Table_ID, m_Record_ID);
|
av.query(false, m_AD_Table_ID, m_Record_ID);
|
||||||
else if (e.getTarget() == m_reports)
|
else if (e.getTarget() == m_reports)
|
||||||
|
|
|
@ -43,22 +43,18 @@ import org.adempiere.webui.component.Tabpanels;
|
||||||
import org.adempiere.webui.component.Tabs;
|
import org.adempiere.webui.component.Tabs;
|
||||||
import org.adempiere.webui.component.Textbox;
|
import org.adempiere.webui.component.Textbox;
|
||||||
import org.adempiere.webui.editor.WSearchEditor;
|
import org.adempiere.webui.editor.WSearchEditor;
|
||||||
import org.adempiere.webui.event.ValueChangeEvent;
|
|
||||||
import org.adempiere.webui.event.ValueChangeListener;
|
|
||||||
import org.adempiere.webui.panel.ADForm;
|
import org.adempiere.webui.panel.ADForm;
|
||||||
|
import org.adempiere.webui.panel.CustomForm;
|
||||||
|
import org.adempiere.webui.panel.ICustomForm;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
|
import org.compiere.apps.form.Archive;
|
||||||
import org.compiere.model.MArchive;
|
import org.compiere.model.MArchive;
|
||||||
import org.compiere.model.MBPartner;
|
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.model.MLookup;
|
||||||
import org.compiere.model.MLookupFactory;
|
import org.compiere.model.MLookupFactory;
|
||||||
import org.compiere.model.MRole;
|
|
||||||
import org.compiere.util.CLogger;
|
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.compiere.util.TimeUtil;
|
|
||||||
import org.zkoss.util.media.AMedia;
|
import org.zkoss.util.media.AMedia;
|
||||||
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;
|
||||||
|
@ -74,28 +70,14 @@ import org.zkoss.zul.Iframe;
|
||||||
* @date September 28, 2007
|
* @date September 28, 2007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class WArchiveViewer extends ADForm implements EventListener, ValueChangeListener
|
public class WArchiveViewer extends Archive implements ICustomForm, EventListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1861963456140146011L;
|
private static final long serialVersionUID = 1861963456140146011L;
|
||||||
|
|
||||||
/** The Archives */
|
private CustomForm form = new CustomForm();
|
||||||
private MArchive[] m_archives = new MArchive[0];
|
|
||||||
|
|
||||||
/** Archive Index */
|
|
||||||
private int m_index = 0;
|
|
||||||
|
|
||||||
/** Table direct */
|
|
||||||
private int m_AD_Table_ID = 0;
|
|
||||||
|
|
||||||
/** Record direct */
|
|
||||||
private int m_Record_ID = 0;
|
|
||||||
|
|
||||||
/** Logger */
|
|
||||||
private static CLogger log = CLogger.getCLogger(WArchiveViewer.class);
|
|
||||||
|
|
||||||
|
|
||||||
// private Vbox queryPanel = new Vbox();
|
// private Vbox queryPanel = new Vbox();
|
||||||
private Checkbox reportField = new Checkbox();
|
private Checkbox reportField = new Checkbox();
|
||||||
|
@ -142,15 +124,6 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange
|
||||||
private Button bRefresh = new Button();
|
private Button bRefresh = new Button();
|
||||||
|
|
||||||
public WArchiveViewer()
|
public WArchiveViewer()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize Panel
|
|
||||||
* @param WindowNo window
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected void initForm()
|
|
||||||
{
|
{
|
||||||
log.info("");
|
log.info("");
|
||||||
|
|
||||||
|
@ -171,70 +144,25 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange
|
||||||
|
|
||||||
private void dynInit()
|
private void dynInit()
|
||||||
{
|
{
|
||||||
int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx());
|
|
||||||
|
|
||||||
//Processes
|
|
||||||
boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Process");
|
|
||||||
String lang = Env.getAD_Language(Env.getCtx());
|
|
||||||
// TODO: ASP - implement process and window access ASP control
|
|
||||||
String sql = "SELECT DISTINCT p.AD_Process_ID,"
|
|
||||||
+ (trl ? "trl.Name" : "p.Name ")
|
|
||||||
+ " FROM AD_Process p INNER JOIN AD_Process_Access pa ON (p.AD_Process_ID=pa.AD_Process_ID) "
|
|
||||||
+ (trl ? "LEFT JOIN AD_Process_Trl trl on (trl.AD_Process_ID=p.AD_Process_ID and trl.AD_Language=" + DB.TO_STRING(lang) + ")" : "")
|
|
||||||
+ " WHERE pa.AD_Role_ID=" + AD_Role_ID
|
|
||||||
+ " AND p.IsReport='Y' AND p.IsActive='Y' AND pa.IsActive='Y' "
|
|
||||||
+ "ORDER BY 2";
|
|
||||||
|
|
||||||
processField = new Listbox();
|
processField = new Listbox();
|
||||||
|
KeyNamePair[] keyNamePair = getProcessData();
|
||||||
KeyNamePair[] keyNamePair = DB.getKeyNamePairs(sql, true);
|
|
||||||
|
|
||||||
for (int i = 0; i < keyNamePair.length; i++)
|
for (int i = 0; i < keyNamePair.length; i++)
|
||||||
{
|
|
||||||
processField.appendItem(keyNamePair[i].getName(), keyNamePair[i]);
|
processField.appendItem(keyNamePair[i].getName(), keyNamePair[i]);
|
||||||
}
|
|
||||||
|
|
||||||
// Tables
|
|
||||||
trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Table");
|
|
||||||
sql = "SELECT DISTINCT t.AD_Table_ID,"
|
|
||||||
+ (trl ? "trl.Name" : "t.Name")
|
|
||||||
+ " FROM AD_Table t INNER JOIN AD_Tab tab ON (tab.AD_Table_ID=t.AD_Table_ID)"
|
|
||||||
+ " INNER JOIN AD_Window_Access wa ON (tab.AD_Window_ID=wa.AD_Window_ID) "
|
|
||||||
+ (trl ? "LEFT JOIN AD_Table_Trl trl on (trl.AD_Table_ID=t.AD_Table_ID and trl.AD_Language=" + DB.TO_STRING(lang) + ")" : "")
|
|
||||||
+ " WHERE wa.AD_Role_ID=" + AD_Role_ID
|
|
||||||
+ " AND t.IsActive='Y' AND tab.IsActive='Y' "
|
|
||||||
+ "ORDER BY 2";
|
|
||||||
|
|
||||||
tableField = new Listbox();
|
tableField = new Listbox();
|
||||||
|
keyNamePair = getTableData();
|
||||||
keyNamePair = DB.getKeyNamePairs(sql, true);
|
|
||||||
|
|
||||||
for (int i = 0; i < keyNamePair.length; i++)
|
for (int i = 0; i < keyNamePair.length; i++)
|
||||||
{
|
|
||||||
tableField.appendItem(keyNamePair[i].getName(), keyNamePair[i]);
|
tableField.appendItem(keyNamePair[i].getName(), keyNamePair[i]);
|
||||||
}
|
|
||||||
|
|
||||||
// Internal Users
|
|
||||||
sql = "SELECT AD_User_ID, Name "
|
|
||||||
+ "FROM AD_User u WHERE EXISTS "
|
|
||||||
+"(SELECT * FROM AD_User_Roles ur WHERE u.AD_User_ID=ur.AD_User_ID) "
|
|
||||||
+ "ORDER BY 2";
|
|
||||||
|
|
||||||
createdByQField = new Listbox();
|
createdByQField = new Listbox();
|
||||||
|
keyNamePair = getUserData();
|
||||||
keyNamePair = DB.getKeyNamePairs(sql, true);
|
|
||||||
|
|
||||||
for (int i = 0; i < keyNamePair.length; i++)
|
for (int i = 0; i < keyNamePair.length; i++)
|
||||||
{
|
|
||||||
createdByQField.appendItem(keyNamePair[i].getName(), keyNamePair[i]);
|
createdByQField.appendItem(keyNamePair[i].getName(), keyNamePair[i]);
|
||||||
}
|
|
||||||
|
|
||||||
MLookup lookup = MLookupFactory.get(Env.getCtx(), m_WindowNo,
|
MLookup lookup = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 2762, DisplayType.Search);
|
||||||
0, 2762, DisplayType.Search);
|
|
||||||
|
|
||||||
bPartnerField = new WSearchEditor(lookup, Msg.translate(
|
bPartnerField = new WSearchEditor(lookup, Msg.translate(
|
||||||
Env.getCtx(), "C_BPartner_ID"), "", true, false, true);
|
Env.getCtx(), "C_BPartner_ID"), "", true, false, true);
|
||||||
bPartnerField.addValueChangeListener(this);
|
|
||||||
} // dynInit
|
} // dynInit
|
||||||
|
|
||||||
private void reportViewer(byte[] data)
|
private void reportViewer(byte[] data)
|
||||||
|
@ -283,11 +211,11 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange
|
||||||
bNext.addEventListener(Events.ON_CLICK, this);
|
bNext.addEventListener(Events.ON_CLICK, this);
|
||||||
|
|
||||||
nameField.addEventListener(Events.ON_CHANGE, this);
|
nameField.addEventListener(Events.ON_CHANGE, this);
|
||||||
descriptionField.addEventListener(Events.ON_SELECT, this);
|
descriptionField.addEventListener(Events.ON_CHANGE, this);
|
||||||
helpField.addEventListener(Events.ON_SELECT, this);
|
helpField.addEventListener(Events.ON_CHANGE, this);
|
||||||
|
|
||||||
reportField.setLabel(Msg.translate(Env.getCtx(), "IsReport"));
|
reportField.setLabel(Msg.translate(Env.getCtx(), "IsReport"));
|
||||||
reportField.addEventListener(Events.ON_CLICK, this);
|
reportField.addEventListener(Events.ON_CHECK, this);
|
||||||
|
|
||||||
Grid gridQuery = new Grid();
|
Grid gridQuery = new Grid();
|
||||||
gridQuery.setWidth("500px");
|
gridQuery.setWidth("500px");
|
||||||
|
@ -514,10 +442,10 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange
|
||||||
iframe.setWidth("100%");
|
iframe.setWidth("100%");
|
||||||
iframe.setAutohide(true);
|
iframe.setAutohide(true);
|
||||||
|
|
||||||
this.setWidth("100%");
|
form.setWidth("100%");
|
||||||
this.setHeight("100%");
|
form.setHeight("100%");
|
||||||
this.appendChild(tabbox);
|
form.appendChild(tabbox);
|
||||||
this.appendChild(confirmPanel);
|
form.appendChild(confirmPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEvent(Event e) throws Exception
|
public void onEvent(Event e) throws Exception
|
||||||
|
@ -548,14 +476,20 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange
|
||||||
if(tabbox.getSelectedIndex() == 1)
|
if(tabbox.getSelectedIndex() == 1)
|
||||||
iframe.invalidate();
|
iframe.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(e.getName().equals(Events.ON_CHANGE))
|
||||||
|
{
|
||||||
|
if (m_archives.length > 0)
|
||||||
|
updateArchive.setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void valueChange(ValueChangeEvent evt)
|
/* public void valueChange(ValueChangeEvent evt)
|
||||||
{
|
{
|
||||||
if (m_archives.length > 0)
|
if (m_archives.length > 0)
|
||||||
updateArchive.setEnabled(true);
|
updateArchive.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* Update Query Display
|
* Update Query Display
|
||||||
*/
|
*/
|
||||||
|
@ -678,23 +612,6 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange
|
||||||
updateVDisplay(false);
|
updateVDisplay(false);
|
||||||
} // cmd_updateArchive
|
} // cmd_updateArchive
|
||||||
|
|
||||||
/**
|
|
||||||
* Is it the same
|
|
||||||
* @param s1 s1
|
|
||||||
* @param s2 s1
|
|
||||||
* @return true if the same
|
|
||||||
*/
|
|
||||||
|
|
||||||
private boolean isSame (String s1, String s2)
|
|
||||||
{
|
|
||||||
if (s1 == null)
|
|
||||||
return s2 == null;
|
|
||||||
else if (s2 == null)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return s1.equals(s2);
|
|
||||||
} // isSame
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query Directly
|
* Query Directly
|
||||||
* @param isReport report
|
* @param isReport report
|
||||||
|
@ -717,153 +634,45 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange
|
||||||
|
|
||||||
private void cmd_query()
|
private void cmd_query()
|
||||||
{
|
{
|
||||||
StringBuffer sql = new StringBuffer();
|
|
||||||
boolean reports = reportField.isChecked();
|
boolean reports = reportField.isChecked();
|
||||||
MRole role = MRole.getDefault();
|
|
||||||
|
|
||||||
if (!role.isCanReport())
|
|
||||||
{
|
|
||||||
log.warning("User/Role cannot Report AD_User_ID=" + Env.getAD_User_ID(Env.getCtx()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sql.append(" AND IsReport=").append(reports ? "'Y'" : "'N'");
|
|
||||||
|
|
||||||
// Process
|
|
||||||
if (reports)
|
|
||||||
{
|
|
||||||
ListItem listitem = processField.getSelectedItem();
|
|
||||||
|
|
||||||
KeyNamePair nn = null;
|
|
||||||
|
|
||||||
if (listitem != null)
|
|
||||||
nn = (KeyNamePair)listitem.getValue();
|
|
||||||
|
|
||||||
if (nn != null && nn.getKey() > 0)
|
|
||||||
sql.append(" AND AD_Process_ID=").append(nn.getKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Table
|
|
||||||
if (m_AD_Table_ID > 0)
|
|
||||||
{
|
|
||||||
sql.append(" AND ((AD_Table_ID=").append(m_AD_Table_ID);
|
|
||||||
|
|
||||||
if (m_Record_ID > 0)
|
|
||||||
sql.append(" AND Record_ID=").append(m_Record_ID);
|
|
||||||
sql.append(")");
|
|
||||||
|
|
||||||
if (m_AD_Table_ID == MBPartner.Table_ID && m_Record_ID > 0)
|
|
||||||
sql.append(" OR C_BPartner_ID=").append(m_Record_ID);
|
|
||||||
sql.append(")");
|
|
||||||
|
|
||||||
// Reset for query
|
|
||||||
m_AD_Table_ID = 0;
|
|
||||||
m_Record_ID = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ListItem listitem = tableField.getSelectedItem();
|
|
||||||
|
|
||||||
KeyNamePair nn = null;
|
|
||||||
|
|
||||||
if (listitem != null)
|
|
||||||
nn = (KeyNamePair)listitem.getValue();
|
|
||||||
|
|
||||||
if (nn != null && nn.getKey() > 0)
|
|
||||||
sql.append(" AND AD_Table_ID=").append(nn.getKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Business Partner
|
|
||||||
if (!reports)
|
|
||||||
{
|
|
||||||
Integer ii = (Integer)bPartnerField.getValue();
|
|
||||||
if (ii != null)
|
|
||||||
sql.append(" AND C_BPartner_ID=").append(ii);
|
|
||||||
else
|
|
||||||
sql.append(" AND C_BPartner_ID IS NOT NULL");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Name
|
|
||||||
String ss = nameQField.getText();
|
|
||||||
if (ss != null && ss.length() > 0)
|
|
||||||
{
|
|
||||||
if (ss.indexOf('%') != -1 || ss.indexOf('_') != -1)
|
|
||||||
sql.append(" AND Name LIKE ").append(DB.TO_STRING(ss));
|
|
||||||
else
|
|
||||||
sql.append(" AND Name=").append(DB.TO_STRING(ss));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Description
|
|
||||||
ss = descriptionQField.getText();
|
|
||||||
if (ss != null && ss.length() > 0)
|
|
||||||
{
|
|
||||||
if (ss.indexOf('%') != -1 || ss.indexOf('_') != -1)
|
|
||||||
sql.append(" AND Description LIKE ").append(DB.TO_STRING(ss));
|
|
||||||
else
|
|
||||||
sql.append(" AND Description=").append(DB.TO_STRING(ss));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Help
|
|
||||||
ss = helpQField.getText();
|
|
||||||
if (ss != null && ss.length() > 0)
|
|
||||||
{
|
|
||||||
if (ss.indexOf('%') != -1 || ss.indexOf('_') != -1)
|
|
||||||
sql.append(" AND Help LIKE ").append(DB.TO_STRING(ss));
|
|
||||||
else
|
|
||||||
sql.append(" AND Help=").append(DB.TO_STRING(ss));
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreatedBy
|
|
||||||
ListItem listitem = createdByQField.getSelectedItem();
|
|
||||||
|
|
||||||
KeyNamePair nn = null;
|
|
||||||
|
|
||||||
|
ListItem listitem = processField.getSelectedItem();
|
||||||
|
KeyNamePair process = null;
|
||||||
if (listitem != null)
|
if (listitem != null)
|
||||||
nn = (KeyNamePair)listitem.getValue();
|
process = (KeyNamePair)listitem.getValue();
|
||||||
|
|
||||||
if (nn != null && nn.getKey() > 0)
|
listitem = tableField.getSelectedItem();
|
||||||
sql.append(" AND CreatedBy=").append(nn.getKey());
|
KeyNamePair table = null;
|
||||||
|
if (listitem != null)
|
||||||
|
table = (KeyNamePair)listitem.getValue();
|
||||||
|
|
||||||
|
Integer C_BPartner_ID = (Integer)bPartnerField.getValue();
|
||||||
|
String name = nameQField.getText();
|
||||||
|
String description = descriptionQField.getText();
|
||||||
|
String help = helpQField.getText();
|
||||||
|
|
||||||
|
listitem = createdByQField.getSelectedItem();
|
||||||
|
KeyNamePair createdBy = null;
|
||||||
|
if (listitem != null)
|
||||||
|
createdBy = (KeyNamePair)listitem.getValue();
|
||||||
|
|
||||||
// Created
|
|
||||||
Date date = null;
|
Date date = null;
|
||||||
Timestamp tt =null;
|
Timestamp createdFrom = null;
|
||||||
|
|
||||||
if (createdQFrom.getValue() != null)
|
if (createdQFrom.getValue() != null)
|
||||||
{
|
{
|
||||||
date = createdQFrom.getValue();
|
date = createdQFrom.getValue();
|
||||||
tt = new Timestamp(date.getTime());
|
createdFrom = new Timestamp(date.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tt != null)
|
Timestamp createdTo = null;
|
||||||
sql.append(" AND Created>=").append(DB.TO_DATE(tt, true));
|
|
||||||
|
|
||||||
if (createdQTo.getValue() != null)
|
if (createdQTo.getValue() != null)
|
||||||
{
|
{
|
||||||
date = createdQTo.getValue();
|
date = createdQTo.getValue();
|
||||||
tt = new Timestamp(date.getTime());
|
createdTo = new Timestamp(date.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tt != null)
|
cmd_query(reports, process, table, C_BPartner_ID, name, description, help,
|
||||||
sql.append(" AND Created<").append(DB.TO_DATE(TimeUtil.addDays(tt,1), true));
|
createdBy, createdFrom, createdTo);
|
||||||
|
|
||||||
log.fine(sql.toString());
|
|
||||||
|
|
||||||
// Process Access
|
|
||||||
sql.append(" AND (AD_Process_ID IS NULL OR AD_Process_ID IN "
|
|
||||||
+ "(SELECT AD_Process_ID FROM AD_Process_Access WHERE AD_Role_ID=")
|
|
||||||
.append(role.getAD_Role_ID()).append("))");
|
|
||||||
|
|
||||||
// Table Access
|
|
||||||
sql.append(" AND (AD_Table_ID IS NULL "
|
|
||||||
+ "OR (AD_Table_ID IS NOT NULL AND AD_Process_ID IS NOT NULL) " // Menu Reports
|
|
||||||
+ "OR AD_Table_ID IN "
|
|
||||||
+ "(SELECT t.AD_Table_ID FROM AD_Tab t"
|
|
||||||
+ " INNER JOIN AD_Window_Access wa ON (t.AD_Window_ID=wa.AD_Window_ID) "
|
|
||||||
+ "WHERE wa.AD_Role_ID=").append(role.getAD_Role_ID()).append("))");
|
|
||||||
|
|
||||||
log.finest(sql.toString());
|
|
||||||
|
|
||||||
m_archives = MArchive.get(Env.getCtx(), sql.toString());
|
|
||||||
log.info("Length=" + m_archives.length);
|
|
||||||
|
|
||||||
// Display
|
// Display
|
||||||
tabbox.setSelectedIndex(1);
|
tabbox.setSelectedIndex(1);
|
||||||
|
@ -871,4 +680,8 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange
|
||||||
m_index = 1;
|
m_index = 1;
|
||||||
updateVDisplay(false);
|
updateVDisplay(false);
|
||||||
} // cmd_query
|
} // cmd_query
|
||||||
|
|
||||||
|
public ADForm getForm() {
|
||||||
|
return form;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue