This commit is contained in:
parent
aa5a2787ff
commit
3e784b198f
|
|
@ -48,7 +48,7 @@ public class Test extends HttpServlet
|
||||||
{
|
{
|
||||||
WebDoc doc = WebDoc.create ("Get Request Test");
|
WebDoc doc = WebDoc.create ("Get Request Test");
|
||||||
//
|
//
|
||||||
WebUtil.createResponse(request, response, this, null, doc, true);
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
} // doGet
|
} // doGet
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class Test extends HttpServlet
|
||||||
{
|
{
|
||||||
WebDoc doc = WebDoc.create ("Post Request Test");
|
WebDoc doc = WebDoc.create ("Post Request Test");
|
||||||
//
|
//
|
||||||
WebUtil.createResponse(request, response, this, null, doc, true);
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
} // doPost
|
} // doPost
|
||||||
|
|
||||||
} // Test
|
} // Test
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class Test2 extends HttpServlet
|
||||||
{
|
{
|
||||||
WebDoc doc = WebDoc.create ("Get Request Test2");
|
WebDoc doc = WebDoc.create ("Get Request Test2");
|
||||||
//
|
//
|
||||||
WebUtil.createResponse(request, response, this, null, doc, true);
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
} // doPost
|
} // doPost
|
||||||
|
|
||||||
} // Test2
|
} // Test2
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,9 @@ public class WAccount extends HttpServlet
|
||||||
String columnName = WebUtil.getParameter (request, "ColumnName");
|
String columnName = WebUtil.getParameter (request, "ColumnName");
|
||||||
//
|
//
|
||||||
GridField mField = ws.curTab.getField(columnName);
|
GridField mField = ws.curTab.getField(columnName);
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
log.config("FormName=" + formName + ", ColumnName=" + columnName + ", MField=" + mField.toString());
|
log.config("FormName=" + formName + ", ColumnName=" + columnName + ", MField=" + mField.toString());
|
||||||
if (mField == null || formName == null || columnName == null || formName.equals("") || columnName.equals(""))
|
if (mField == null || columnName == null || columnName.equals(""))
|
||||||
{
|
{
|
||||||
WebUtil.createTimeoutPage(request, response, this,
|
WebUtil.createTimeoutPage(request, response, this,
|
||||||
Msg.getMsg(wsc.ctx, "ParameterMissing"));
|
Msg.getMsg(wsc.ctx, "ParameterMissing"));
|
||||||
|
|
@ -93,20 +94,21 @@ public class WAccount extends HttpServlet
|
||||||
}
|
}
|
||||||
// Object value = ws.curTab.getValue(columnName);
|
// Object value = ws.curTab.getValue(columnName);
|
||||||
String target = "opener.document." + formName + "." + columnName;
|
String target = "opener.document." + formName + "." + columnName;
|
||||||
|
String targetBase = "'" + columnName;
|
||||||
|
//Modifeid by Rob Klein 4/229/07
|
||||||
// Create Document
|
// Create Document
|
||||||
WebDoc doc = WebDoc.create (mField.getHeader());
|
WebDoc doc = WebDoc.createPopup (mField.getHeader());
|
||||||
body body = doc.getBody();
|
body body = doc.getBody();
|
||||||
body.setOnBlur("self.focus();");
|
body.setOnBlur("self.focus();");
|
||||||
body.addElement(fillTable(ws, mField, target));
|
body.addElement(fillTable(ws, mField, targetBase));
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
// Reset, Cancel
|
// Reset, Cancel
|
||||||
button reset = new button();
|
button reset = new button();
|
||||||
reset.addElement("Reset"); // translate
|
reset.addElement("Reset"); // translate
|
||||||
reset.setOnClick(target + ".value='';" + target + "_D.value='';window.close();");
|
reset.setOnClick(targetBase + "F.value='';" + targetBase + "D.value='';self.close();");
|
||||||
button cancel = new button();
|
button cancel = new button();
|
||||||
cancel.addElement("Cancel"); // translate
|
cancel.addElement("Cancel"); // translate
|
||||||
cancel.setOnClick("window.close();");
|
cancel.setOnClick("self.close();return false;");
|
||||||
body.addElement(new p(AlignType.RIGHT)
|
body.addElement(new p(AlignType.RIGHT)
|
||||||
.addElement(reset)
|
.addElement(reset)
|
||||||
.addElement(" ")
|
.addElement(" ")
|
||||||
|
|
@ -144,9 +146,14 @@ public class WAccount extends HttpServlet
|
||||||
private table fillTable (WWindowStatus ws, GridField mField, String target)
|
private table fillTable (WWindowStatus ws, GridField mField, String target)
|
||||||
{
|
{
|
||||||
table table = new table("1");
|
table table = new table("1");
|
||||||
|
//Modified by Rob klein 4/29/07
|
||||||
|
table.setClass("table-autosort table-autostripe table-stripeclass:alternate");
|
||||||
|
table.addElement("<thead>");
|
||||||
tr line = new tr();
|
tr line = new tr();
|
||||||
line.addElement(new th(" ")).addElement(new th(Msg.translate(ws.ctx, "Name")));
|
line.addElement(new th(" ")).addElement(new th(Msg.translate(ws.ctx, "Name")).setClass("table-sortable:default"));
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
|
table.addElement("</thead>");
|
||||||
|
table.addElement("<tbody>");
|
||||||
|
|
||||||
// Fill & list options
|
// Fill & list options
|
||||||
Lookup lookup = mField.getLookup();
|
Lookup lookup = mField.getLookup();
|
||||||
|
|
@ -162,9 +169,14 @@ public class WAccount extends HttpServlet
|
||||||
KeyNamePair np = (KeyNamePair)lValue;
|
KeyNamePair np = (KeyNamePair)lValue;
|
||||||
button button = new button();
|
button button = new button();
|
||||||
button.addElement(">");
|
button.addElement(">");
|
||||||
StringBuffer script = new StringBuffer(target);
|
//Modified by Rob Klein 4/29/07
|
||||||
script.append(".value='").append(np.getKey()).append("';")
|
StringBuffer script = new StringBuffer();
|
||||||
.append(target).append("_D.value='").append(np.getName()).append("';window.close();");
|
script
|
||||||
|
//.append("';closePopup();")
|
||||||
|
.append("startUpdate(").append(target).append("F',")
|
||||||
|
.append(target).append("D','").append(np.getKey()).append("',")
|
||||||
|
.append(target).append("F','").append(np.getName())
|
||||||
|
.append("');return false;");
|
||||||
button.setOnClick(script.toString());
|
button.setOnClick(script.toString());
|
||||||
//
|
//
|
||||||
line = new tr();
|
line = new tr();
|
||||||
|
|
@ -177,6 +189,7 @@ public class WAccount extends HttpServlet
|
||||||
}
|
}
|
||||||
// Restore
|
// Restore
|
||||||
lookup.fillComboBox(true);
|
lookup.fillComboBox(true);
|
||||||
|
table.addElement("</tbody>");
|
||||||
return table;
|
return table;
|
||||||
} // fillTable
|
} // fillTable
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,8 @@ public class WAttachment extends HttpServlet
|
||||||
if (session == null || ws == null)
|
if (session == null || ws == null)
|
||||||
{
|
{
|
||||||
doc = WebDoc.createPopup ("No Context");
|
doc = WebDoc.createPopup ("No Context");
|
||||||
doc.addPopupClose();
|
//Modified by Rob Klein 4/29/07
|
||||||
|
doc.addPopupClose(ws.ctx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -192,7 +193,8 @@ public class WAttachment extends HttpServlet
|
||||||
table.addElement(tr);
|
table.addElement(tr);
|
||||||
|
|
||||||
// Footer
|
// Footer
|
||||||
doc.addPopupClose();
|
//Modified by Rob Klein 4/29/07
|
||||||
|
doc.addPopupClose(ctx);
|
||||||
//
|
//
|
||||||
// System.out.println(doc);
|
// System.out.println(doc);
|
||||||
return doc;
|
return doc;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,289 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* 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. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.www;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.servlet.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
|
||||||
|
import org.apache.ecs.AlignType;
|
||||||
|
import org.apache.ecs.Element;
|
||||||
|
import org.apache.ecs.xhtml.b;
|
||||||
|
import org.apache.ecs.xhtml.form;
|
||||||
|
import org.apache.ecs.xhtml.hr;
|
||||||
|
import org.apache.ecs.xhtml.input;
|
||||||
|
import org.apache.ecs.xhtml.p;
|
||||||
|
import org.apache.ecs.xhtml.table;
|
||||||
|
import org.apache.ecs.xhtml.td;
|
||||||
|
import org.apache.ecs.xhtml.textarea;
|
||||||
|
import org.apache.ecs.xhtml.tr;
|
||||||
|
import org.compiere.apps.AChat;
|
||||||
|
import org.compiere.model.GridField;
|
||||||
|
import org.compiere.model.MChat;
|
||||||
|
import org.compiere.model.MChatEntry;
|
||||||
|
import org.compiere.model.MUser;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web (window) Chat
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: WChat.java $
|
||||||
|
*/
|
||||||
|
public class WChat extends HttpServlet
|
||||||
|
{
|
||||||
|
/** Logger */
|
||||||
|
protected CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
private MChat m_chat;
|
||||||
|
private boolean m_readOnly;
|
||||||
|
private boolean m_hasDependents;
|
||||||
|
private boolean m_hasCallout;
|
||||||
|
private int m_displayLength;
|
||||||
|
private String m_columnName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize global variables
|
||||||
|
*/
|
||||||
|
public void init(ServletConfig config)
|
||||||
|
throws ServletException
|
||||||
|
{
|
||||||
|
super.init(config);
|
||||||
|
if (!WebEnv.initWeb(config))
|
||||||
|
throw new ServletException("WChat.init");
|
||||||
|
} // init
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the HTTP Get request
|
||||||
|
*/
|
||||||
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException
|
||||||
|
{
|
||||||
|
log.fine("doGet");
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
|
//
|
||||||
|
WebDoc doc = null;
|
||||||
|
if (ws == null)
|
||||||
|
{
|
||||||
|
doc = WebDoc.createPopup("No Context");
|
||||||
|
doc.addPopupClose(wsc.ctx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
doc = CreateChatPage (ws, wsc, doc, 0 );
|
||||||
|
}
|
||||||
|
//
|
||||||
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
|
} // doGet
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the HTTP Post request
|
||||||
|
*/
|
||||||
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException
|
||||||
|
{
|
||||||
|
WebDoc doc = null;
|
||||||
|
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
|
|
||||||
|
String data = WebUtil.getParameter(request, "chatinput");
|
||||||
|
int CM_ChatID = WebUtil.getParameterAsInt(request, "CM_ChatID");
|
||||||
|
int AD_Table_ID = WebUtil.getParameterAsInt(request, "AD_Table_ID");
|
||||||
|
int record_ID = WebUtil.getParameterAsInt(request, "record_ID");
|
||||||
|
String description = WebUtil.getParameter(request, "description");
|
||||||
|
|
||||||
|
if (data != null && data.length() > 0)
|
||||||
|
{
|
||||||
|
if (CM_ChatID == 0){
|
||||||
|
m_chat = new MChat (wsc.ctx, AD_Table_ID, record_ID, description, null);
|
||||||
|
m_chat.save();
|
||||||
|
}
|
||||||
|
MChatEntry entry = new MChatEntry(m_chat, data);
|
||||||
|
entry.save();
|
||||||
|
|
||||||
|
} // data to be saved
|
||||||
|
|
||||||
|
doc = CreateChatPage (ws, wsc, doc, m_chat.getCM_Chat_ID());
|
||||||
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
|
} // doPost
|
||||||
|
/**
|
||||||
|
* Create Text Field
|
||||||
|
* @param data initial value
|
||||||
|
* @param rows no of rows
|
||||||
|
* @return td
|
||||||
|
*/
|
||||||
|
private td getTextField (String data, int rows)
|
||||||
|
{
|
||||||
|
textarea text = new textarea (m_columnName, rows, m_displayLength)
|
||||||
|
.addElement(Util.maskHTML(data));
|
||||||
|
text.setID(m_columnName + "F");
|
||||||
|
text.setName(m_columnName);
|
||||||
|
text.setDisabled(m_readOnly);
|
||||||
|
//
|
||||||
|
if (m_hasDependents || m_hasCallout)
|
||||||
|
text.setOnChange("startUpdate(this);");
|
||||||
|
|
||||||
|
return createTD(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Left Top aligned TD
|
||||||
|
* @param element element
|
||||||
|
* @return td table data
|
||||||
|
*/
|
||||||
|
private td createTD (Element element)
|
||||||
|
{
|
||||||
|
td td = new td()
|
||||||
|
.addElement(element)
|
||||||
|
.setAlign(AlignType.LEFT)
|
||||||
|
.setVAlign(AlignType.TOP);
|
||||||
|
td.setColSpan(3);
|
||||||
|
return td;
|
||||||
|
} // createTD
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Left Top aligned TD
|
||||||
|
* @param element element
|
||||||
|
* @return td table data
|
||||||
|
*/
|
||||||
|
private WebDoc CreateChatPage (WWindowStatus ws, WebSessionCtx wsc, WebDoc doc, int CM_Chat_ID)
|
||||||
|
|
||||||
|
{
|
||||||
|
doc = WebDoc.createPopup ("Chat ");
|
||||||
|
|
||||||
|
td center = doc.addWindowCenter(false);
|
||||||
|
int record_ID = ws.curTab.getRecord_ID();
|
||||||
|
log.info("Record_ID=" + record_ID);
|
||||||
|
if (record_ID == -1) // No Key
|
||||||
|
{
|
||||||
|
log.info("Record does not exist");
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
// Find display
|
||||||
|
String infoName = null;
|
||||||
|
String infoDisplay = null;
|
||||||
|
for (int i = 0; i < ws.curTab.getFieldCount(); i++)
|
||||||
|
{
|
||||||
|
GridField field = ws.curTab.getField(i);
|
||||||
|
if (field.isKey())
|
||||||
|
infoName = field.getHeader();
|
||||||
|
if ((field.getColumnName().equals("Name") || field.getColumnName().equals("DocumentNo") )
|
||||||
|
&& field.getValue() != null)
|
||||||
|
infoDisplay = field.getValue().toString();
|
||||||
|
if (infoName != null && infoDisplay != null)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String description = infoName + ": " + infoDisplay;
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
if (ws.curTab.getCM_ChatID() > 0)
|
||||||
|
m_chat = new MChat (wsc.ctx, ws.curTab.getCM_ChatID(), null);
|
||||||
|
else if (CM_Chat_ID > 0)
|
||||||
|
m_chat = new MChat (wsc.ctx, CM_Chat_ID, null);
|
||||||
|
else
|
||||||
|
m_chat = new MChat (wsc.ctx, ws.curTab.getAD_Table_ID(), record_ID, description, null);
|
||||||
|
|
||||||
|
String text = m_chat.getHistory(MChat.CONFIDENTIALTYPE_Internal).toString();
|
||||||
|
|
||||||
|
|
||||||
|
form myForm = new form ("WChat")
|
||||||
|
.setName("chat");
|
||||||
|
myForm.setOnSubmit("this.Submit.disabled=true;return true;");
|
||||||
|
if (CM_Chat_ID==0)
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "CM_ChatID", ws.curTab.getCM_ChatID()));
|
||||||
|
else
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "CM_ChatID", CM_Chat_ID));
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", ws.curTab.getAD_Table_ID()));
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "record_ID", record_ID));
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "description", description));
|
||||||
|
|
||||||
|
table myTable = new table("0", "0", "5", "100%", null);
|
||||||
|
myTable.setID("WChatParameter");
|
||||||
|
m_displayLength = 80;
|
||||||
|
|
||||||
|
//history field
|
||||||
|
myTable.addElement(new tr()
|
||||||
|
.addElement( new td("History")));
|
||||||
|
m_readOnly = true;
|
||||||
|
table HistoryTable = new table("1", "0", "5", "100%", null);
|
||||||
|
HistoryTable.addElement(new tr()
|
||||||
|
.addElement( new td(text)
|
||||||
|
.setRowSpan(10)
|
||||||
|
.setAlign(AlignType.LEFT)
|
||||||
|
.setVAlign(AlignType.TOP)
|
||||||
|
.setColSpan(4)));
|
||||||
|
myTable.addElement(HistoryTable);
|
||||||
|
|
||||||
|
//input field
|
||||||
|
myTable.addElement(new tr()
|
||||||
|
.addElement( new td("Input")));
|
||||||
|
m_readOnly = false;
|
||||||
|
m_columnName = "chatinput";
|
||||||
|
myTable.addElement(new tr()
|
||||||
|
.addElement(getTextField ("", 10)));
|
||||||
|
|
||||||
|
// Reset
|
||||||
|
String textbtn = "Reset";
|
||||||
|
if (wsc.ctx != null)
|
||||||
|
text = Msg.getMsg (wsc.ctx, "Reset");
|
||||||
|
input restbtn = new input(input.TYPE_RESET, textbtn, " "+text);
|
||||||
|
restbtn.setID(text);
|
||||||
|
restbtn.setClass("resetbtn");
|
||||||
|
|
||||||
|
// Submit
|
||||||
|
textbtn = "Submit";
|
||||||
|
if (wsc.ctx != null)
|
||||||
|
text = Msg.getMsg (wsc.ctx, "Submit");
|
||||||
|
input submitbtn = new input(input.TYPE_SUBMIT, textbtn, " "+text);
|
||||||
|
submitbtn.setID(text);
|
||||||
|
submitbtn.setClass("submitbtn");
|
||||||
|
|
||||||
|
// Close
|
||||||
|
textbtn = "Close";
|
||||||
|
if (wsc.ctx != null)
|
||||||
|
text = Msg.getMsg (wsc.ctx, "Close");
|
||||||
|
input closebtn = new input(input.TYPE_SUBMIT, textbtn, " "+text);
|
||||||
|
closebtn.setID(text);
|
||||||
|
closebtn.setClass("closebtn");
|
||||||
|
closebtn.setOnClick ("self.close();return false;");
|
||||||
|
|
||||||
|
|
||||||
|
myTable.addElement(new tr()
|
||||||
|
.addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false,
|
||||||
|
restbtn))
|
||||||
|
.addElement(new td(null, AlignType.CENTER, AlignType.MIDDLE, false,
|
||||||
|
submitbtn ))
|
||||||
|
.addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false,
|
||||||
|
closebtn)));
|
||||||
|
myForm.addElement(myTable);
|
||||||
|
center.addElement(myForm);
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // WReport
|
||||||
|
|
@ -57,7 +57,8 @@ public class WHelp extends HttpServlet
|
||||||
if (ws == null)
|
if (ws == null)
|
||||||
{
|
{
|
||||||
doc = WebDoc.createPopup("No Context");
|
doc = WebDoc.createPopup("No Context");
|
||||||
doc.addPopupClose();
|
//Modified by Rob Klein 4/29/07
|
||||||
|
doc.addPopupClose(Env.getCtx());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
doc = ws.mWindow.getHelpDoc(false);
|
doc = ws.mWindow.getHelpDoc(false);
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,8 @@ public class WLocation extends HttpServlet
|
||||||
String action = request.getRequestURI();
|
String action = request.getRequestURI();
|
||||||
// Create Document
|
// Create Document
|
||||||
WebDoc doc = WebDoc.createPopup (mField.getHeader());
|
WebDoc doc = WebDoc.createPopup (mField.getHeader());
|
||||||
doc.addPopupClose();
|
//Modified by Rob klein 4/29/07
|
||||||
|
doc.addPopupClose(ws.ctx);
|
||||||
boolean hasDependents = ws.curTab.hasDependants(columnName);
|
boolean hasDependents = ws.curTab.hasDependants(columnName);
|
||||||
boolean hasCallout = mField.getCallout().length() > 0;
|
boolean hasCallout = mField.getCallout().length() > 0;
|
||||||
|
|
||||||
|
|
@ -128,8 +129,8 @@ public class WLocation extends HttpServlet
|
||||||
doc.getTable().addElement(new tr()
|
doc.getTable().addElement(new tr()
|
||||||
.addElement(fillForm(ws, action, location, targetBase, hasDependents || hasCallout))
|
.addElement(fillForm(ws, action, location, targetBase, hasDependents || hasCallout))
|
||||||
.addElement(reset));
|
.addElement(reset));
|
||||||
//
|
//Modified by Rob Klein 4/29/07
|
||||||
doc.addPopupClose();
|
doc.addPopupClose(ws.ctx);
|
||||||
// log.trace(log.l6_Database, doc.toString());
|
// log.trace(log.l6_Database, doc.toString());
|
||||||
WebUtil.createResponse (request, response, this, null, doc, false);
|
WebUtil.createResponse (request, response, this, null, doc, false);
|
||||||
} // doGet
|
} // doGet
|
||||||
|
|
@ -170,7 +171,8 @@ public class WLocation extends HttpServlet
|
||||||
|
|
||||||
// Document
|
// Document
|
||||||
WebDoc doc = WebDoc.createPopup ("WLocation");
|
WebDoc doc = WebDoc.createPopup ("WLocation");
|
||||||
doc.addPopupClose();
|
//Modified by Rob Klein 4/29/07
|
||||||
|
doc.addPopupClose(ws.ctx);
|
||||||
|
|
||||||
// Save Location
|
// Save Location
|
||||||
location.save();
|
location.save();
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ public class WLogin extends HttpServlet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WebUtil.createResponse (request, response, this, cProp, doc, true);
|
WebUtil.createResponse (request, response, this, cProp, doc, false);
|
||||||
} // doPost
|
} // doPost
|
||||||
|
|
||||||
// Variable Names
|
// Variable Names
|
||||||
|
|
@ -234,11 +234,15 @@ public class WLogin extends HttpServlet
|
||||||
String action = request.getRequestURI();
|
String action = request.getRequestURI();
|
||||||
form myForm = null;
|
form myForm = null;
|
||||||
myForm = new form(action).setName("Login1");
|
myForm = new form(action).setName("Login1");
|
||||||
table table = new table().setAlign(AlignType.CENTER);
|
table table = new table().setAlign(AlignType.CENTER).setWidth("25%");
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
// Blank Line
|
||||||
|
tr line = new tr();
|
||||||
|
line.addElement(new td().addElement(" "));
|
||||||
|
|
||||||
// Username
|
// Username
|
||||||
String userData = cProp.getProperty(P_USERNAME, "");
|
String userData = cProp.getProperty(P_USERNAME, "");
|
||||||
tr line = new tr();
|
line = new tr();
|
||||||
label usrLabel = new label().setFor(P_USERNAME + "F").addElement(usrText);
|
label usrLabel = new label().setFor(P_USERNAME + "F").addElement(usrText);
|
||||||
usrLabel.setID(P_USERNAME + "L");
|
usrLabel.setID(P_USERNAME + "L");
|
||||||
line.addElement(new td().addElement(usrLabel).setAlign(AlignType.RIGHT));
|
line.addElement(new td().addElement(usrLabel).setAlign(AlignType.RIGHT));
|
||||||
|
|
@ -276,7 +280,7 @@ public class WLogin extends HttpServlet
|
||||||
options[i].setSelected(false);
|
options[i].setSelected(false);
|
||||||
}
|
}
|
||||||
line.addElement(new td().addElement(new select(Env.LANGUAGE, options)
|
line.addElement(new td().addElement(new select(Env.LANGUAGE, options)
|
||||||
.setID(Env.LANGUAGE + "F") ));
|
.setID(Env.LANGUAGE + "F")));
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
|
|
||||||
// Store Cookie
|
// Store Cookie
|
||||||
|
|
@ -300,18 +304,32 @@ public class WLogin extends HttpServlet
|
||||||
|
|
||||||
// Finish
|
// Finish
|
||||||
line = new tr();
|
line = new tr();
|
||||||
input cancel = new input(input.TYPE_RESET, "Reset", cancelText);
|
//Modified by Rob Klein 4/29/07
|
||||||
line.addElement(new td().addElement(cancel ));
|
table tablebutton = new table().setAlign(AlignType.CENTER).setWidth("25%");
|
||||||
line.addElement(new td().addElement(new input(input.TYPE_SUBMIT, P_SUBMIT, okText) ));
|
input cancel = new input(input.TYPE_RESET, "Reset", " "+"Cancel");
|
||||||
table.addElement(line);
|
cancel.setClass("cancelbtn");
|
||||||
|
line.addElement(new td().addElement(cancel).setWidth("50%")).setAlign(AlignType.CENTER);
|
||||||
|
input submit = new input(input.TYPE_SUBMIT, P_SUBMIT, " "+"OK");
|
||||||
|
submit.setClass("loginbtn");
|
||||||
|
line.addElement(new td().addElement(submit).setWidth("50%").setAlign(AlignType.CENTER));
|
||||||
|
tablebutton.addElement(line);
|
||||||
|
table.addElement(tablebutton);
|
||||||
//
|
//
|
||||||
myForm.addElement(table);
|
myForm.addElement(table);
|
||||||
|
|
||||||
// Document
|
// Document
|
||||||
WebDoc doc = WebDoc.createWindow (windowTitle);
|
WebDoc doc = WebDoc.createWindow (windowTitle);
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
img img = new img (WebEnv.getImageDirectory("Logo.gif"), "logo");
|
||||||
doc.addWindowCenter(true)
|
doc.addWindowCenter(true)
|
||||||
.addElement(new h3("The HTML UI is Beta Functionality!"))
|
.addElement(img)
|
||||||
.addElement(myForm);
|
.addElement(new p())
|
||||||
|
.addElement(new p())
|
||||||
|
//.addElement(new h3("The HTML UI is Beta Functionality!"))
|
||||||
|
//.addElement(myForm)
|
||||||
|
.addElement(myForm)
|
||||||
|
.addElement(new p())
|
||||||
|
.addElement(new p());
|
||||||
// Clear Menu Frame
|
// Clear Menu Frame
|
||||||
doc.getBody()
|
doc.getBody()
|
||||||
.addElement(WebUtil.getClearFrame(WebEnv.TARGET_MENU))
|
.addElement(WebUtil.getClearFrame(WebEnv.TARGET_MENU))
|
||||||
|
|
@ -344,6 +362,10 @@ public class WLogin extends HttpServlet
|
||||||
|
|
||||||
// Role Pick
|
// Role Pick
|
||||||
tr line = new tr();
|
tr line = new tr();
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
line.addElement(new td().addElement(" "));
|
||||||
|
table.addElement(line);
|
||||||
|
line = new tr();
|
||||||
label roleLabel = new label().setFor(P_ROLE + "F").addElement(Msg.translate(wsc.language, "AD_Role_ID"));
|
label roleLabel = new label().setFor(P_ROLE + "F").addElement(Msg.translate(wsc.language, "AD_Role_ID"));
|
||||||
roleLabel.setID(P_ROLE + "L");
|
roleLabel.setID(P_ROLE + "L");
|
||||||
line.addElement(new td().addElement(roleLabel).setAlign(AlignType.RIGHT));
|
line.addElement(new td().addElement(roleLabel).setAlign(AlignType.RIGHT));
|
||||||
|
|
@ -403,23 +425,37 @@ public class WLogin extends HttpServlet
|
||||||
line.addElement(new td().addElement(new strong(errorMessage)).setColSpan(2).setAlign(AlignType.CENTER));
|
line.addElement(new td().addElement(new strong(errorMessage)).setColSpan(2).setAlign(AlignType.CENTER));
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
}
|
}
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
// Finish
|
// Finish
|
||||||
|
table tablebutton = new table().setAlign(AlignType.CENTER).setWidth("25%");
|
||||||
line = new tr();
|
line = new tr();
|
||||||
input cancel = new input(input.TYPE_RESET, "Reset", Msg.getMsg(wsc.language, "Cancel"));
|
//Modified by Rob Klein 4/29/07
|
||||||
line.addElement(new td().addElement(cancel ));
|
//input cancel = new input(input.TYPE_RESET, "Reset", Msg.getMsg(wsc.language, "Cancel"));
|
||||||
input submit = new input(input.TYPE_SUBMIT, "Submit", Msg.getMsg(wsc.language, "OK"));
|
input cancel = new input(input.TYPE_RESET, "Reset", " "+ "Cancel");
|
||||||
|
cancel.setOnClick("window.top.location.replace('/adempiere/index.html');");
|
||||||
|
cancel.setClass("cancelbtn");
|
||||||
|
line.addElement(new td().addElement(cancel).setWidth("50%").setAlign(AlignType.CENTER));
|
||||||
|
input submit = new input(input.TYPE_SUBMIT, "Submit", " "+ "OK");
|
||||||
submit.setOnClick("showLoadingMenu('" + WebEnv.getBaseDirectory("") + "');");
|
submit.setOnClick("showLoadingMenu('" + WebEnv.getBaseDirectory("") + "');");
|
||||||
line.addElement(new td().addElement(submit));
|
//Modified by Rob Klein 4/29/07
|
||||||
table.addElement(line);
|
submit.setClass("loginbtn");
|
||||||
|
line.addElement(new td().addElement(submit).setWidth("50%").setAlign(AlignType.CENTER));
|
||||||
|
tablebutton.addElement(line);
|
||||||
|
table.addElement(tablebutton);
|
||||||
//
|
//
|
||||||
myForm.addElement(table);
|
myForm.addElement(table);
|
||||||
|
|
||||||
// Create Document
|
// Create Document
|
||||||
WebDoc doc = WebDoc.createWindow (windowTitle);
|
WebDoc doc = WebDoc.createWindow (windowTitle);
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
img img = new img (WebEnv.getImageDirectory("Logo.gif"), "logo");
|
||||||
doc.addWindowCenter(true)
|
doc.addWindowCenter(true)
|
||||||
.addElement(new h3("The HTML UI is Beta Functionality!"))
|
.addElement(img)
|
||||||
.addElement(myForm);
|
.addElement(new p())
|
||||||
|
//.addElement(new h3("The HTML UI is Beta Functionality!"))
|
||||||
|
.addElement(myForm)
|
||||||
|
.addElement(new p())
|
||||||
|
.addElement(new p());
|
||||||
//
|
//
|
||||||
String script = "fieldUpdate(document.Login2." + P_ROLE + ");"; // init dependency updates
|
String script = "fieldUpdate(document.Login2." + P_ROLE + ");"; // init dependency updates
|
||||||
doc.getBody()
|
doc.getBody()
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,18 @@
|
||||||
package org.compiere.www;
|
package org.compiere.www;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.servlet.*;
|
import javax.servlet.*;
|
||||||
import javax.servlet.http.*;
|
import javax.servlet.http.*;
|
||||||
|
|
||||||
|
import org.apache.ecs.AlignType;
|
||||||
import org.apache.ecs.xhtml.*;
|
import org.apache.ecs.xhtml.*;
|
||||||
|
import org.compiere.grid.ed.VLookup;
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
|
@ -45,6 +54,12 @@ public class WLookup extends HttpServlet
|
||||||
/** Logger */
|
/** Logger */
|
||||||
protected static CLogger log = CLogger.getCLogger(WLookup.class);
|
protected static CLogger log = CLogger.getCLogger(WLookup.class);
|
||||||
|
|
||||||
|
/** The Data List */
|
||||||
|
protected volatile ArrayList<Object> p_data = new ArrayList<Object>();
|
||||||
|
|
||||||
|
|
||||||
|
private StringBuffer HeaderSelect = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize global variables
|
* Initialize global variables
|
||||||
*
|
*
|
||||||
|
|
@ -72,8 +87,11 @@ public class WLookup extends HttpServlet
|
||||||
{
|
{
|
||||||
WebEnv.dump(request);
|
WebEnv.dump(request);
|
||||||
WebEnv.dump(request.getSession());
|
WebEnv.dump(request.getSession());
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
//
|
//
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
WWindowStatus ws = WWindowStatus.get(request);
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
|
|
||||||
if (ws == null)
|
if (ws == null)
|
||||||
{
|
{
|
||||||
WebUtil.createTimeoutPage(request, response, this, null);
|
WebUtil.createTimeoutPage(request, response, this, null);
|
||||||
|
|
@ -81,9 +99,64 @@ public class WLookup extends HttpServlet
|
||||||
}
|
}
|
||||||
// Get Mandatory Parameters
|
// Get Mandatory Parameters
|
||||||
String columnName = WebUtil.getParameter (request, "ColumnName");
|
String columnName = WebUtil.getParameter (request, "ColumnName");
|
||||||
log.info ("ColumnName=" + columnName + " - " + ws.toString());
|
|
||||||
//
|
|
||||||
GridField mField = ws.curTab.getField(columnName);
|
GridField mField = ws.curTab.getField(columnName);
|
||||||
|
//Lookup called from a process
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
int AD_Process_ID = WebUtil.getParameterAsInt(request, "AD_Process_ID");
|
||||||
|
|
||||||
|
if (mField == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
AD_Process_ID = WebUtil.getParameterAsInt(request, "AD_Process_ID");
|
||||||
|
if (AD_Process_ID < 1 || columnName == null
|
||||||
|
|| columnName.equals(""))
|
||||||
|
{
|
||||||
|
WebUtil.createErrorPage(request, response, this,
|
||||||
|
Msg.getMsg(ws.ctx, "ParameterMissing"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String targetBase = "'" + columnName;
|
||||||
|
|
||||||
|
MProcess process = MProcess.get(wsc.ctx, AD_Process_ID);
|
||||||
|
|
||||||
|
MProcessPara para = null;
|
||||||
|
|
||||||
|
MProcessPara[] parameter = process.getParameters();
|
||||||
|
|
||||||
|
for (int i = 0; i < parameter.length; i++)
|
||||||
|
{
|
||||||
|
para = parameter[i];
|
||||||
|
|
||||||
|
if (para.getColumnName().equals(columnName))
|
||||||
|
i=parameter.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create Document
|
||||||
|
WebDoc doc = WebDoc.createPopup (para.getColumnName());
|
||||||
|
|
||||||
|
// Reset
|
||||||
|
String text = "Reset";
|
||||||
|
if (wsc.ctx != null)
|
||||||
|
text = Msg.getMsg (wsc.ctx, "Reset");
|
||||||
|
|
||||||
|
input button = new input("button", text, " "+text);
|
||||||
|
button.setID(text);
|
||||||
|
button.setClass("resetbtn");
|
||||||
|
String script = targetBase + "F.value='';" + targetBase + "D.value='';closePopup();";
|
||||||
|
button.setOnClick(script);
|
||||||
|
//
|
||||||
|
|
||||||
|
doc.getTable().addElement(new tr()
|
||||||
|
.addElement(fillTable(wsc, ws, para.getColumnName(), para.getAD_Reference_Value_ID(), request.getRequestURI(),targetBase,false))
|
||||||
|
.addElement(button));
|
||||||
|
//
|
||||||
|
doc.addPopupClose(ws.ctx);
|
||||||
|
// log.trace(log.l6_Database, doc.toString());
|
||||||
|
WebUtil.createResponse (request, response, this, null, doc, false);
|
||||||
|
}
|
||||||
|
//Lookup called from a window
|
||||||
|
else{
|
||||||
|
|
||||||
log.config("ColumnName=" + columnName
|
log.config("ColumnName=" + columnName
|
||||||
+ ", MField=" + mField);
|
+ ", MField=" + mField);
|
||||||
if (mField == null || columnName == null
|
if (mField == null || columnName == null
|
||||||
|
|
@ -95,31 +168,37 @@ public class WLookup extends HttpServlet
|
||||||
}
|
}
|
||||||
// parent = framesetWindow
|
// parent = framesetWindow
|
||||||
// Label - Dtata - Field - Button
|
// Label - Dtata - Field - Button
|
||||||
String targetBase = "parent.WWindow." + WWindow.FORM_NAME + "." + columnName;
|
String targetBase = "'" + columnName;
|
||||||
// Object value = ws.curTab.getValue(columnName);
|
|
||||||
|
|
||||||
// Create Document
|
// Create Document
|
||||||
WebDoc doc = WebDoc.createPopup (mField.getHeader());
|
WebDoc doc = WebDoc.createPopup (mField.getHeader());
|
||||||
doc.addPopupClose();
|
|
||||||
|
|
||||||
boolean hasDependents = ws.curTab.hasDependants(columnName);
|
boolean hasDependents = ws.curTab.hasDependants(columnName);
|
||||||
boolean hasCallout = mField.getCallout().length() > 0;
|
boolean hasCallout = mField.getCallout().length() > 0;
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
button reset = new button();
|
// Reset
|
||||||
reset.addElement("Reset"); // translate
|
String text = "Reset";
|
||||||
String script = targetBase + "F.value='';" + targetBase + "D.value='';closePopup();";
|
if (wsc.ctx != null)
|
||||||
|
text = Msg.getMsg (wsc.ctx, "Reset");
|
||||||
|
input restbtn = new input(input.TYPE_RESET, text, " "+text);
|
||||||
|
restbtn.setID(text);
|
||||||
|
restbtn.setClass("resetbtn");
|
||||||
|
|
||||||
|
String script = targetBase + "F.value='';" + targetBase + "D.value='';self.close();";
|
||||||
if (hasDependents || hasCallout)
|
if (hasDependents || hasCallout)
|
||||||
script += "startUpdate(" + targetBase + "F);";
|
script += "startUpdate(" + targetBase + "F);";
|
||||||
reset.setOnClick(script);
|
restbtn.setOnClick(script);
|
||||||
//
|
//
|
||||||
|
|
||||||
doc.getTable().addElement(new tr()
|
doc.getTable().addElement(new tr()
|
||||||
.addElement(fillTable(ws, mField, targetBase, hasDependents || hasCallout))
|
.addElement(fillTable(wsc, ws, mField.getColumnName(), mField.getAD_Reference_Value_ID(), request.getRequestURI(),targetBase, hasDependents || hasCallout))
|
||||||
.addElement(reset));
|
.addElement(restbtn));
|
||||||
//
|
//
|
||||||
doc.addPopupClose();
|
doc.addPopupClose(ws.ctx);
|
||||||
// log.trace(log.l6_Database, doc.toString());
|
// log.trace(log.l6_Database, doc.toString());
|
||||||
WebUtil.createResponse (request, response, this, null, doc, false);
|
WebUtil.createResponse (request, response, this, null, doc, false);
|
||||||
|
}
|
||||||
} // doGet
|
} // doGet
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -137,7 +216,7 @@ public class WLookup extends HttpServlet
|
||||||
doGet(request, response);
|
doGet(request, response);
|
||||||
} // doPost
|
} // doPost
|
||||||
|
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Fill Table (Generic)
|
* Fill Table (Generic)
|
||||||
*
|
*
|
||||||
|
|
@ -147,8 +226,8 @@ public class WLookup extends HttpServlet
|
||||||
* @param addStart add startUpdate
|
* @param addStart add startUpdate
|
||||||
* @return Table with selection
|
* @return Table with selection
|
||||||
*/
|
*/
|
||||||
private table fillTable (WWindowStatus ws, GridField mField,
|
private table fillTable (WebSessionCtx wsc, WWindowStatus ws, String columnName, int fieldRefId,
|
||||||
String targetBase, boolean addStart)
|
String action,String targetBase, boolean addStart)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
if (mField.getColumnName().equals("C_BPartner_ID"))
|
if (mField.getColumnName().equals("C_BPartner_ID"))
|
||||||
|
|
@ -156,63 +235,217 @@ public class WLookup extends HttpServlet
|
||||||
else if (mField.getColumnName().equals("M_Product_ID"))
|
else if (mField.getColumnName().equals("M_Product_ID"))
|
||||||
return fillTable_Product (ws, mField, target);
|
return fillTable_Product (ws, mField, target);
|
||||||
**/
|
**/
|
||||||
//
|
|
||||||
table table = new table("1"); // Border 1
|
table table = new table("1"); // Border 1
|
||||||
table.setID("WLookup");
|
table.setID("WLookup");
|
||||||
|
table.setClass("MultiRow table-autofilter table-filterable table-autosort table-autostripe table-stripeclass:alternate");
|
||||||
|
table.addElement("<thead>");
|
||||||
tr line = new tr();
|
tr line = new tr();
|
||||||
line.addElement(new th(" ")).addElement(new th(Msg.translate(ws.ctx, "Name")));
|
|
||||||
table.addElement(line);
|
|
||||||
|
|
||||||
Lookup lookup = mField.getLookup();
|
|
||||||
log.info(mField.getColumnName());
|
|
||||||
|
|
||||||
// Fill & list options
|
// Set Headers
|
||||||
lookup.fillComboBox(mField.isMandatory(false), true, true, true); // no context check
|
line.addElement(new th(" ")).
|
||||||
int size = lookup.getSize();
|
addElement(new th(Msg.translate(ws.ctx, "Key Name")).setClass("table-filterable table-filtered table-sortable:default"));
|
||||||
for (int i = 0; i < size; i++)
|
line = fillTable_Lookup_Headers(ws, columnName, fieldRefId, line, targetBase, true, true, true, false, true);
|
||||||
{
|
|
||||||
Object lValue = lookup.getElementAt(i);
|
|
||||||
if (!(lValue != null && lValue instanceof KeyNamePair))
|
|
||||||
continue;
|
|
||||||
//
|
|
||||||
// log.trace(log.l6_Database, lValue.toString());
|
|
||||||
KeyNamePair np = (KeyNamePair)lValue;
|
|
||||||
button button = new button();
|
|
||||||
button.addElement(">");
|
|
||||||
StringBuffer script = new StringBuffer();
|
|
||||||
script.append(targetBase).append("D.value='").append(np.getKey()).append("';")
|
|
||||||
.append(targetBase).append("F.value='").append(np.getName())
|
|
||||||
.append("';closePopup();");
|
|
||||||
if (addStart)
|
|
||||||
script.append("startUpdate(").append(targetBase).append("F);");
|
|
||||||
button.setOnClick(script.toString());
|
|
||||||
//
|
|
||||||
line = new tr();
|
|
||||||
line.addElement(new td(button));
|
|
||||||
String name = np.getName();
|
|
||||||
if (name == null || name.length() == 0)
|
|
||||||
name = " ";
|
|
||||||
line.addElement(new td(name));
|
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
}
|
tr line2 = new tr();
|
||||||
|
line2.addElement(new th(" ")).addElement(new th(" "));
|
||||||
|
line2 = fillTable_Lookup_Headers(ws, columnName, fieldRefId, line2, targetBase, true, true, true, false, false);
|
||||||
|
table.addElement(line2);
|
||||||
|
table.addElement("</thead>");
|
||||||
|
table.addElement("<tbody>");
|
||||||
|
|
||||||
|
// Fillout rows
|
||||||
|
table = fillTable_Lookup_Rows(ws, columnName, fieldRefId, table, targetBase, true, true, true, false);
|
||||||
|
|
||||||
|
table.addElement("</tbody>");
|
||||||
// Restore
|
// Restore
|
||||||
lookup.fillComboBox(true);
|
|
||||||
return table;
|
return table;
|
||||||
} // fillTable
|
} // fillTable
|
||||||
|
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Fill Table BPartner
|
* Fill Table Lookup
|
||||||
*
|
*
|
||||||
* @param ws WindowStatus
|
* @param ws WindowStatus
|
||||||
* @param mField the Field
|
* @param mField the Field
|
||||||
* @param targetBase target field string
|
* @param targetBase target field string
|
||||||
* @return Table with selection
|
* @return Lookup Rows in List Format
|
||||||
*/
|
*/
|
||||||
private table fillTable_BPartner (WWindowStatus ws, GridField mField, String targetBase)
|
private table fillTable_Lookup_Rows (WWindowStatus ws, String columnName, int fieldRefId,
|
||||||
|
table table1, String targetBase, boolean mandatory, boolean onlyValidated, boolean onlyActive,
|
||||||
|
boolean temporary)
|
||||||
{
|
{
|
||||||
return null;
|
ArrayList<Object> list = new ArrayList<Object>();
|
||||||
} // fillTable_BPartner
|
StringBuffer sqlSelect = null;
|
||||||
|
StringBuffer sqlSelectDetail = null;
|
||||||
|
|
||||||
|
int size = 0;
|
||||||
|
int colCount = 0;
|
||||||
|
|
||||||
|
if (!mandatory)
|
||||||
|
list.add(new KeyNamePair (-1, ""));
|
||||||
|
|
||||||
|
StringBuffer sql = null;
|
||||||
|
|
||||||
|
if (fieldRefId > 0){
|
||||||
|
sql = new StringBuffer ("SELECT AD_Display, AD_Key, AD_Table_ID, WhereClause, OrderByClause "
|
||||||
|
+ "FROM AD_Ref_Table WHERE AD_Reference_ID = "+fieldRefId);
|
||||||
|
|
||||||
|
int nameID = 0;
|
||||||
|
int keyID = 0;
|
||||||
|
int tableID = 0;
|
||||||
|
String whereClause = null;
|
||||||
|
String orderBy = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
size=2;
|
||||||
|
|
||||||
|
while (rs.next()){
|
||||||
|
nameID = rs.getInt(1);
|
||||||
|
keyID = rs.getInt(2);
|
||||||
|
tableID = rs.getInt(3);
|
||||||
|
whereClause = rs.getString(4);
|
||||||
|
orderBy = rs.getString(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
String sql1 = "Select ColumnName FROM AD_Column Where AD_Column_ID = ? AND AD_Table_ID = "+tableID;
|
||||||
|
sql = new StringBuffer ("SELECT count(Name) FROM AD_Column WHERE AD_TABLE_ID="+tableID);
|
||||||
|
colCount = DB.getSQLValue(null, sql.toString());
|
||||||
|
|
||||||
|
String name = DB.getSQLValueString(null, sql1 , nameID);
|
||||||
|
String key = DB.getSQLValueString(null, sql1 , keyID);
|
||||||
|
sqlSelect = new StringBuffer ("SELECT "+key+", "+name);
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sqlSelect.toString(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
String sql1 = "Select TableName FROM AD_Table Where AD_Table_ID = ?";
|
||||||
|
String tableName = DB.getSQLValueString(null, sql1 , tableID);
|
||||||
|
sqlSelect.append(" FROM " + tableName + " WHERE AD_Client_ID=?");
|
||||||
|
sqlSelectDetail = HeaderSelect.append(" FROM " + tableName + " WHERE "+columnName+" = ?");
|
||||||
|
|
||||||
|
if (whereClause != null){
|
||||||
|
sqlSelect.append(" AND " + whereClause);
|
||||||
|
sqlSelectDetail.append(" AND " + whereClause);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orderBy != null){
|
||||||
|
sqlSelect.append(" ORDER BY " + orderBy);
|
||||||
|
sqlSelectDetail.append(" ORDER BY " + orderBy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
//direct select as indicated below
|
||||||
|
sql = new StringBuffer ("SELECT AD_Table_ID "
|
||||||
|
+ "FROM AD_Table WHERE TableName = '"+columnName.replace("_ID", "")+"'");
|
||||||
|
int tableID = DB.getSQLValue(null, sql.toString());
|
||||||
|
|
||||||
|
sql = new StringBuffer ("SELECT count(Name) FROM AD_Column WHERE AD_TABLE_ID="+tableID);
|
||||||
|
colCount = DB.getSQLValue(null, sql.toString());
|
||||||
|
|
||||||
|
sql = new StringBuffer ("SELECT ColumnName "
|
||||||
|
+ "FROM AD_Column WHERE IsIdentifier = 'Y' AND "
|
||||||
|
+ "AD_Table_ID= "+tableID
|
||||||
|
+ " ORDER BY SeqNo");
|
||||||
|
|
||||||
|
sqlSelect = new StringBuffer ("SELECT "+columnName+", ");
|
||||||
|
size=1;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()){
|
||||||
|
if (size>1)
|
||||||
|
sqlSelect.append(", ");
|
||||||
|
sqlSelect.append(rs.getObject(1));
|
||||||
|
size++;
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sqlSelect.toString(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlSelect.append(" FROM " + columnName.replace("_ID", "") + " WHERE AD_Client_ID=?");
|
||||||
|
sqlSelectDetail = HeaderSelect.append(" FROM " + columnName.replace("_ID", "") + " WHERE "+columnName+" = ?");
|
||||||
|
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sqlSelect.toString(), null);
|
||||||
|
pstmt.setInt(1, Env.getAD_Client_ID(ws.ctx));
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()){
|
||||||
|
StringBuffer name = new StringBuffer ("");
|
||||||
|
for (int i = 2; i <= size; i++)
|
||||||
|
{
|
||||||
|
if (i>2)
|
||||||
|
name.append("_");
|
||||||
|
name.append(rs.getObject(i));
|
||||||
|
}
|
||||||
|
button button = new button();
|
||||||
|
button.addElement(">");
|
||||||
|
StringBuffer script = new StringBuffer();
|
||||||
|
script
|
||||||
|
.append("startLookUpdate(").append(targetBase).append("F',")
|
||||||
|
.append(targetBase).append("D','").append(rs.getObject(1).toString()).append("',")
|
||||||
|
.append(targetBase).append("F','").append(name.toString())
|
||||||
|
.append("');startUpdate(").append(targetBase).append("');return false;");
|
||||||
|
button.setOnClick(script.toString());
|
||||||
|
//
|
||||||
|
tr line = new tr();
|
||||||
|
line.addElement(new td(button));
|
||||||
|
line.addElement(new td(name.toString()));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt1 = DB.prepareStatement(sqlSelectDetail.toString(), null);
|
||||||
|
pstmt1.setInt(1, rs.getInt(1));
|
||||||
|
ResultSet rs1 = pstmt1.executeQuery();
|
||||||
|
while (rs1.next()){
|
||||||
|
for (int i = 1; i <= colCount; i++)
|
||||||
|
{
|
||||||
|
Object fieldRS = rs1.getObject(i);
|
||||||
|
if (fieldRS == null)
|
||||||
|
line.addElement(new td(" "));
|
||||||
|
else
|
||||||
|
line.addElement(new td(rs1.getObject(i).toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rs1.close();
|
||||||
|
pstmt1.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
|
}
|
||||||
|
table1.addElement(line);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
|
}
|
||||||
|
return table1;
|
||||||
|
} // fillTable_Lookup_Rows
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill Table Product
|
* Fill Table Product
|
||||||
|
|
@ -222,9 +455,74 @@ public class WLookup extends HttpServlet
|
||||||
* @param targetBase target field string
|
* @param targetBase target field string
|
||||||
* @return Table with selection
|
* @return Table with selection
|
||||||
*/
|
*/
|
||||||
private table fillTable_Product (WWindowStatus ws, GridField mField, String targetBase)
|
private tr fillTable_Lookup_Headers (WWindowStatus ws, String columnName, int fieldRefId,
|
||||||
|
tr line, String targetBase, boolean mandatory, boolean onlyValidated, boolean onlyActive,
|
||||||
|
boolean temporary, boolean firstHeaderLine)
|
||||||
{
|
{
|
||||||
return null;
|
|
||||||
|
StringBuffer sqlSelect = null;
|
||||||
|
int size = 0;
|
||||||
|
StringBuffer sql = null;
|
||||||
|
int colCount = 0;
|
||||||
|
if (fieldRefId > 0){
|
||||||
|
|
||||||
|
sql = new StringBuffer ("SELECT AD_Table_ID "
|
||||||
|
+ "FROM AD_Ref_Table WHERE AD_Reference_ID = "+fieldRefId);
|
||||||
|
int tableID = DB.getSQLValue(null, sql.toString());
|
||||||
|
|
||||||
|
sql = new StringBuffer ("SELECT count(Name) FROM AD_Column WHERE AD_TABLE_ID="+tableID);
|
||||||
|
colCount = DB.getSQLValue(null, sql.toString());
|
||||||
|
sqlSelect = new StringBuffer ("SELECT ColumnName, Name FROM AD_Column WHERE AD_Table_ID="+tableID+" ORDER BY AD_Column_ID");
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//direct select as indicated below
|
||||||
|
|
||||||
|
sql = new StringBuffer ("SELECT AD_Table_ID "
|
||||||
|
+ "FROM AD_Table WHERE TableName = '"+columnName.replace("_ID", "")+"'");
|
||||||
|
int tableID = DB.getSQLValue(null, sql.toString());
|
||||||
|
sql = new StringBuffer ("SELECT count(Name) FROM AD_Column WHERE AD_TABLE_ID="+tableID);
|
||||||
|
colCount = DB.getSQLValue(null, sql.toString());
|
||||||
|
sqlSelect = new StringBuffer ("SELECT ColumnName, Name FROM AD_Column WHERE AD_TABLE_ID="+tableID+" ORDER BY AD_Column_ID");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(firstHeaderLine)
|
||||||
|
HeaderSelect = new StringBuffer ("Select ");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sqlSelect.toString(), null);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
|
||||||
|
input filter = null;
|
||||||
|
while (rs.next()){
|
||||||
|
if(firstHeaderLine){
|
||||||
|
line.addElement(new th(rs.getString(2)).setClass("table-filterable table-filtered table-sortable:default"));
|
||||||
|
HeaderSelect.append(rs.getString(1)+",");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
th th = new th();
|
||||||
|
filter = new input (input.TYPE_TEXT, rs.getString(2)+"filter", "");
|
||||||
|
filter.setOnKeyUp("Table.filter(this,this)");
|
||||||
|
th.addElement(filter);
|
||||||
|
line.addElement(th);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(firstHeaderLine)
|
||||||
|
HeaderSelect.setLength(HeaderSelect.length()-1);
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
|
}
|
||||||
|
return line;
|
||||||
|
|
||||||
} // fillTable_Product
|
} // fillTable_Product
|
||||||
|
|
||||||
} // WLookup
|
} // WLookup
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,7 @@ public class WMenu extends HttpServlet
|
||||||
throws ServletException, IOException
|
throws ServletException, IOException
|
||||||
{
|
{
|
||||||
log.fine("doPost - Create Menu");
|
log.fine("doPost - Create Menu");
|
||||||
|
|
||||||
// Get Session attributes
|
// Get Session attributes
|
||||||
WebSessionCtx wsc = WebSessionCtx.get(request);
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
if (wsc == null)
|
if (wsc == null)
|
||||||
|
|
@ -146,6 +147,10 @@ public class WMenu extends HttpServlet
|
||||||
WebUtil.createTimeoutPage(request, response, this, null);
|
WebUtil.createTimeoutPage(request, response, this, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//Added by Rob Klein 4/29/07
|
||||||
|
|
||||||
|
//Reset WWindow
|
||||||
|
WebUtil.getClearFrame(WebEnv.TARGET_WINDOW);
|
||||||
|
|
||||||
// Get Parameters: Role, Client, Org, Warehouse, Date
|
// Get Parameters: Role, Client, Org, Warehouse, Date
|
||||||
String role = WebUtil.getParameter (request, WLogin.P_ROLE);
|
String role = WebUtil.getParameter (request, WLogin.P_ROLE);
|
||||||
|
|
@ -246,8 +251,12 @@ public class WMenu extends HttpServlet
|
||||||
if (!cProp.getProperty(WLogin.P_STORE, "N").equals("Y"))
|
if (!cProp.getProperty(WLogin.P_STORE, "N").equals("Y"))
|
||||||
cProp.clear();
|
cProp.clear();
|
||||||
|
|
||||||
WebDoc doc = createPage (request, wsc, AD_Role_ID);
|
WebDoc doc = createPage (request, wsc, AD_Role_ID, AD_User_ID, AD_Client_ID, AD_Org_ID);
|
||||||
WebUtil.createResponse (request, response, this, cProp, doc, true);
|
//Added by Rob Klein 4/29/07
|
||||||
|
doc.getBody()
|
||||||
|
.addElement(WebUtil.getClearFrame(WebEnv.TARGET_WINDOW));
|
||||||
|
WebUtil.createResponse (request, response, this, cProp, doc, false);
|
||||||
|
//WebUtil.createResponse (request, response, this, cProp, doc, true);
|
||||||
} // doPost
|
} // doPost
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -307,9 +316,12 @@ public class WMenu extends HttpServlet
|
||||||
String printer = null;
|
String printer = null;
|
||||||
Login login = new Login(ctx);
|
Login login = new Login(ctx);
|
||||||
login.loadPreferences(org, wh, date, printer);
|
login.loadPreferences(org, wh, date, printer);
|
||||||
|
//Modified by Rob Klein to Show Accounting Tabs 04/29/2007
|
||||||
// Don't Show Acct/Trl Tabs on HTML UI
|
// Don't Show Acct/Trl Tabs on HTML UI
|
||||||
Env.setContext(ctx, "#ShowAcct", "N");
|
//Env.setContext(ctx, "#ShowAcct", "N");
|
||||||
Env.setContext(ctx, "#ShowTrl", "N");
|
//Env.setContext(ctx, "#ShowTrl", "N");
|
||||||
|
//Env.setContext(ctx, "#ShowAcct", "Y");
|
||||||
|
//Env.setContext(ctx, "#ShowTrl", "Y");
|
||||||
//
|
//
|
||||||
return loginInfo;
|
return loginInfo;
|
||||||
} // checkLogin
|
} // checkLogin
|
||||||
|
|
@ -322,33 +334,39 @@ public class WMenu extends HttpServlet
|
||||||
* @return document
|
* @return document
|
||||||
*/
|
*/
|
||||||
private WebDoc createPage (HttpServletRequest request,
|
private WebDoc createPage (HttpServletRequest request,
|
||||||
WebSessionCtx wsc, int AD_Role_ID)
|
WebSessionCtx wsc, int AD_Role_ID, int AD_User_ID, int AD_Client_ID, int AD_Org_ID)
|
||||||
{
|
{
|
||||||
// Document
|
// Document
|
||||||
String windowTitle = Msg.getMsg(wsc.ctx, "Menu");
|
//Modified by Rob Klein 4/29/07
|
||||||
|
//String windowTitle = Msg.getMsg(wsc.ctx, "Menu");
|
||||||
|
String windowTitle = "";
|
||||||
WebDoc doc = WebDoc.create (windowTitle);
|
WebDoc doc = WebDoc.create (windowTitle);
|
||||||
head head = doc.getHead();
|
head head = doc.getHead();
|
||||||
// Target
|
// Target
|
||||||
head.addElement(new base().setTarget(WebEnv.TARGET_WINDOW));
|
head.addElement(new base().setTarget(WebEnv.TARGET_WINDOW));
|
||||||
// Specific Menu Script/Stylesheet
|
// Specific Menu Script/Stylesheet
|
||||||
head.addElement(new link(WebEnv.getBaseDirectory("menu.css"), link.REL_STYLESHEET, link.TYPE_CSS));
|
head.addElement(new link(WebEnv.getBaseDirectory("/css/menu.css"), link.REL_STYLESHEET, link.TYPE_CSS));
|
||||||
head.addElement(new script((Element)null, WebEnv.getBaseDirectory("menu.js")));
|
head.addElement(new script((Element)null, WebEnv.getBaseDirectory("/js/menu.js")));
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
//head.addElement(new script((Element)null, WebEnv.getBaseDirectory("/js/mktree.js")));
|
||||||
|
//head.addElement(new link(WebEnv.getBaseDirectory("/css/mktree.css"), link.REL_STYLESHEET, link.TYPE_CSS));
|
||||||
// Scripts
|
// Scripts
|
||||||
String statusMessage = Msg.getMsg(wsc.ctx, "SelectMenuItem");
|
String statusMessage = Msg.getMsg(wsc.ctx, "SelectMenuItem");
|
||||||
String scriptTxt = "top.document.title='" + windowTitle + " - " + wsc.loginInfo + "'; "
|
String scriptTxt = "top.document.title='" + windowTitle + " - " + wsc.loginInfo + "'; "
|
||||||
+ "var defaultStatus='" + statusMessage + "';";
|
+ "var defaultStatus='" + statusMessage + "';";
|
||||||
head.addElement(new script(scriptTxt));
|
//Rob 12-16-2006 head.addElement(new script(scriptTxt));
|
||||||
|
|
||||||
// Body
|
// Body
|
||||||
body body = doc.getBody();
|
body body = doc.getBody();
|
||||||
body.setTitle(statusMessage);
|
body.setTitle(statusMessage);
|
||||||
// Clear Window Frame
|
// Clear Window Frame
|
||||||
body.addElement(WebUtil.getClearFrame(WebEnv.TARGET_WINDOW));
|
//Rob 12-16-2006 body.addElement(WebUtil.getClearFrame(WebEnv.TARGET_WINDOW));
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
table table = doc.getTable();
|
table table = doc.getTable();
|
||||||
doc.setClasses ("menuTable", "menuHeader");
|
doc.setClasses ("menuTable", "menuHeader");
|
||||||
doc.getTopLeft().addElement(new cite(wsc.loginInfo));
|
//Rob 12-16-2006 doc.getTopLeft().addElement(new cite(wsc.loginInfo));
|
||||||
|
doc.getTopLeft().addElement(new cite(""));
|
||||||
|
|
||||||
// Load Menu Structure ----------------------
|
// Load Menu Structure ----------------------
|
||||||
int AD_Tree_ID = DB.getSQLValue(null,
|
int AD_Tree_ID = DB.getSQLValue(null,
|
||||||
|
|
@ -380,6 +398,7 @@ public class WMenu extends HttpServlet
|
||||||
|
|
||||||
// Print tree
|
// Print tree
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
|
StringBuffer buffav = new StringBuffer();
|
||||||
en = root.preorderEnumeration();
|
en = root.preorderEnumeration();
|
||||||
int oldLevel = 0;
|
int oldLevel = 0;
|
||||||
while (en.hasMoreElements())
|
while (en.hasMoreElements())
|
||||||
|
|
@ -394,7 +413,7 @@ public class WMenu extends HttpServlet
|
||||||
while (oldLevel < level)
|
while (oldLevel < level)
|
||||||
{
|
{
|
||||||
if (level == 1)
|
if (level == 1)
|
||||||
buf.append("<ul id=\"main\">\n"); // start first level
|
buf.append("<ul class=\"mktree\" id=\"main\">\n"); // start first level
|
||||||
else
|
else
|
||||||
buf.append("<ul style=\"display:none\">\n");// start next level
|
buf.append("<ul style=\"display:none\">\n");// start next level
|
||||||
oldLevel++;
|
oldLevel++;
|
||||||
|
|
@ -410,6 +429,9 @@ public class WMenu extends HttpServlet
|
||||||
|
|
||||||
// Print Node
|
// Print Node
|
||||||
buf.append(printNode(nd, wsc.ctx));
|
buf.append(printNode(nd, wsc.ctx));
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
if (nd.isOnBar())
|
||||||
|
buffav.append(printNode(nd, wsc.ctx));
|
||||||
}
|
}
|
||||||
// Final
|
// Final
|
||||||
while (oldLevel > 0)
|
while (oldLevel > 0)
|
||||||
|
|
@ -420,11 +442,30 @@ public class WMenu extends HttpServlet
|
||||||
else
|
else
|
||||||
buf.append("</ul></li>\n"); // finish next level
|
buf.append("</ul></li>\n"); // finish next level
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
// Set Favorites
|
||||||
|
buf.append("<ul><li class=\"menuSummary\" id=\"218\" onClick=\"changeMenu(event);\">Favorites<ul style=\"display:none\">\n");
|
||||||
|
buf.append(buffav);
|
||||||
|
buf.append("</ul></li></ul>\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
td td = new td().setColSpan(2).setNoWrap(true);
|
td td = new td().setColSpan(2).setNoWrap(true);
|
||||||
td.setClass("menuCenter");
|
td.setClass("menuCenter");
|
||||||
td.addElement(buf.toString());
|
td.addElement(buf.toString());
|
||||||
table.addElement(new tr().addElement(td));
|
table.addElement(new tr().addElement(td));
|
||||||
|
|
||||||
|
// Expand/Collapse Info
|
||||||
|
td = new td().setColSpan(2);
|
||||||
|
td.setClass("menuFooter");
|
||||||
|
// Modified by Rob Klein 4/29/07
|
||||||
|
/**td.addElement(new a("javascript:expandTree('main');", "Expand Menu"));
|
||||||
|
td.addElement(" | ");
|
||||||
|
td.addElement( new a("javascript:collapseTree('main');", "Contract Menu"));
|
||||||
|
table.addElement(new tr().addElement(td));
|
||||||
|
**/
|
||||||
|
|
||||||
// Exit Info
|
// Exit Info
|
||||||
td = new td().setColSpan(2);
|
td = new td().setColSpan(2);
|
||||||
td.setClass("menuFooter");
|
td.setClass("menuFooter");
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,23 @@ import java.io.*;
|
||||||
import java.math.*;
|
import java.math.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
import javax.servlet.*;
|
import javax.servlet.*;
|
||||||
import javax.servlet.http.*;
|
import javax.servlet.http.*;
|
||||||
import org.apache.ecs.*;
|
import org.apache.ecs.*;
|
||||||
import org.apache.ecs.xhtml.*;
|
import org.apache.ecs.xhtml.*;
|
||||||
|
import org.compiere.apps.ADialog;
|
||||||
|
//import org.compiere.apps.WProcessCtl;
|
||||||
|
import org.compiere.grid.ed.VDocAction;
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
import org.compiere.print.*;
|
import org.compiere.print.*;
|
||||||
import org.compiere.process.*;
|
import org.compiere.process.*;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
import org.compiere.wf.MWFActivity;
|
||||||
|
import org.compiere.wf.MWFResponsible;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTML Process and Report UI
|
* HTML Process and Report UI
|
||||||
|
|
@ -40,6 +48,11 @@ public class WProcess extends HttpServlet
|
||||||
{
|
{
|
||||||
/** Logger */
|
/** Logger */
|
||||||
protected CLogger log = CLogger.getCLogger(getClass());
|
protected CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
private String errorMessage = null;
|
||||||
|
private static String[] s_value = null;
|
||||||
|
private static String[] s_name;
|
||||||
|
private static String[] s_description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize global variables
|
* Initialize global variables
|
||||||
|
|
@ -66,31 +79,59 @@ public class WProcess extends HttpServlet
|
||||||
throws ServletException, IOException
|
throws ServletException, IOException
|
||||||
{
|
{
|
||||||
// Get Session attributes
|
// Get Session attributes
|
||||||
|
|
||||||
WebSessionCtx wsc = WebSessionCtx.get(request);
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
if (wsc == null)
|
if (wsc == null)
|
||||||
{
|
{
|
||||||
WebUtil.createTimeoutPage(request, response, this, null);
|
WebUtil.createTimeoutPage(request, response, this, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
if (ws == null)
|
||||||
|
{
|
||||||
|
WebUtil.createTimeoutPage(request, response, this, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
WebDoc doc = null;
|
WebDoc doc = null;
|
||||||
// Get Parameter: Menu_ID
|
// Get Parameter: Menu_ID
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
int AD_Menu_ID = WebUtil.getParameterAsInt(request, "AD_Menu_ID");
|
int AD_Menu_ID = WebUtil.getParameterAsInt(request, "AD_Menu_ID");
|
||||||
|
String fileName = WebUtil.getParameter(request, "File");
|
||||||
if (AD_Menu_ID > 0)
|
if (AD_Menu_ID > 0)
|
||||||
{
|
{
|
||||||
log.info("doGet - AD_Menu_ID=" + AD_Menu_ID);
|
|
||||||
doc = createParameterPage(wsc, AD_Menu_ID);
|
doc = createParameterPage(wsc, AD_Menu_ID,0,0,0,0,null,null);
|
||||||
}
|
}
|
||||||
|
//else if (fileName!=null)
|
||||||
|
//{
|
||||||
|
// int AD_PInstance_ID = WebUtil.getParameterAsInt(request, "AD_PInstance_ID");
|
||||||
|
//
|
||||||
|
// String error = streamResult (request, response, AD_PInstance_ID, fileName);
|
||||||
|
// if (error == null)
|
||||||
|
// return;
|
||||||
|
// doc = WebDoc.createWindow(error);
|
||||||
|
//}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String fileName = WebUtil.getParameter(request, "File");
|
int AD_Process_ID = WebUtil.getParameterAsInt(request, "AD_Process_ID");
|
||||||
int AD_PInstance_ID = WebUtil.getParameterAsInt(request, "AD_PInstance_ID");
|
int AD_Window_ID = WebUtil.getParameterAsInt(request, "AD_Window_ID");
|
||||||
log.info("doGet - AD_PInstance_ID=" + AD_PInstance_ID
|
int AD_Table_ID = WebUtil.getParameterAsInt(request, "AD_Table_ID");
|
||||||
+ ", File=" + fileName);
|
int AD_Record_ID = WebUtil.getParameterAsInt(request, "AD_Record_ID");
|
||||||
String error = streamResult (request, response, AD_PInstance_ID, fileName);
|
String columnName = WebUtil.getParameter(request, "columnName");
|
||||||
if (error == null)
|
int AD_Tab_ID = WebUtil.getParameterAsInt(request, "AD_Tab_ID");
|
||||||
|
if (AD_Process_ID == 0)
|
||||||
|
{
|
||||||
|
WebUtil.createErrorPage(request, response, this, "No Process");
|
||||||
return;
|
return;
|
||||||
doc = WebDoc.createWindow(error);
|
}
|
||||||
|
|
||||||
|
doc = createParameterPage(wsc, AD_Process_ID,AD_Window_ID,AD_Table_ID,AD_Record_ID,1,
|
||||||
|
columnName,ws.curTab);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (doc == null)
|
if (doc == null)
|
||||||
doc = WebDoc.createWindow("Process Not Found");
|
doc = WebDoc.createWindow("Process Not Found");
|
||||||
|
|
@ -119,36 +160,118 @@ public class WProcess extends HttpServlet
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int AD_Process_ID = WebUtil.getParameterAsInt(request, "AD_Process_ID");
|
int AD_Process_ID = WebUtil.getParameterAsInt(request, "AD_Process_ID");
|
||||||
log.info("doGet - AD_Process_ID=" + AD_Process_ID);
|
//Modified by Rob Klein 4/29/07
|
||||||
|
int AD_Window_ID = WebUtil.getParameterAsInt(request, "AD_Window_ID");
|
||||||
|
int AD_Table_ID = WebUtil.getParameterAsInt(request, "AD_Table_ID");
|
||||||
|
int AD_Record_ID = WebUtil.getParameterAsInt(request, "AD_Record_ID");
|
||||||
|
|
||||||
|
|
||||||
if (AD_Process_ID == 0)
|
if (AD_Process_ID == 0)
|
||||||
{
|
{
|
||||||
WebUtil.createErrorPage(request, response, this, "No Process");
|
WebUtil.createErrorPage(request, response, this, "No Process");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//Modified by Rob Klein 6/01/07
|
||||||
WebDoc doc = createProcessPage(request, AD_Process_ID);
|
//WebDoc doc = createProcessPage(request, AD_Process_ID, AD_Window_ID);
|
||||||
|
createProcessPage(request, response, AD_Process_ID, AD_Window_ID);
|
||||||
//
|
//
|
||||||
WebUtil.createResponse(request, response, this, null, doc, false);
|
|
||||||
} // doPost
|
} // doPost
|
||||||
|
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Create Parameter Page
|
* Create Parameter Page
|
||||||
* @param wsc web session context
|
* @param wsc web session context
|
||||||
* @param AD_Menu_ID Menu
|
* @param AD_Menu_ID Menu
|
||||||
* @return Page
|
* @return Page
|
||||||
*/
|
*/
|
||||||
private WebDoc createParameterPage (WebSessionCtx wsc, int AD_Menu_ID)
|
private WebDoc createParameterPage (WebSessionCtx wsc, int processId, int windowID,int tableID,int recordID,int Type,
|
||||||
|
String columnName, GridTab mTab)
|
||||||
{
|
{
|
||||||
MProcess process = MProcess.getFromMenu (wsc.ctx, AD_Menu_ID);
|
MProcess process = null;
|
||||||
|
if (Type == 0)
|
||||||
|
process = MProcess.getFromMenu (wsc.ctx, processId);
|
||||||
|
else
|
||||||
|
process = MProcess.get(wsc.ctx, processId);
|
||||||
|
|
||||||
// need to check if Role can access
|
// need to check if Role can access
|
||||||
if (process == null)
|
if (process == null)
|
||||||
{
|
{
|
||||||
WebDoc doc = WebDoc.createWindow("Process Not Found");
|
WebDoc doc = WebDoc.createWindow("Process Not Found");
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
WebDoc doc = WebDoc.createWindow(process.getName());
|
WebDoc doc = WebDoc.createWindow(process.getName());
|
||||||
|
if (process.isWorkflow())
|
||||||
|
{
|
||||||
|
// Pop up Document Action (Workflow)
|
||||||
|
if (columnName.toString().equals("DocAction")) {
|
||||||
|
|
||||||
|
readReference();
|
||||||
|
|
||||||
|
option[] Options = dynInit( windowID, tableID, recordID,
|
||||||
|
columnName, mTab);
|
||||||
|
|
||||||
|
td center = doc.addWindowCenter(false);
|
||||||
|
|
||||||
|
WebField wField = new WebField (wsc,
|
||||||
|
columnName, columnName, columnName,
|
||||||
|
// no display length
|
||||||
|
17, 22, 22, false,
|
||||||
|
// not r/o, ., not error, not dependent
|
||||||
|
false, false, false, false, false, processId,
|
||||||
|
0,0,0,0, null,null, null,null);
|
||||||
|
|
||||||
|
if (process.getDescription() != null)
|
||||||
|
center.addElement(new p(new i(process.getDescription())));
|
||||||
|
if (process.getHelp() != null)
|
||||||
|
center.addElement(new p(process.getHelp(), AlignType.LEFT));
|
||||||
|
form myForm = new form ("WProcess")
|
||||||
|
.setName("process" + process.getAD_Process_ID());
|
||||||
|
myForm.setOnSubmit("this.Submit.disabled=true;return true;");
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Process_ID", process.getAD_Process_ID()));
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Window_ID", windowID));
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", tableID));
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Record_ID", recordID));
|
||||||
|
table myTable = new table("0", "0", "5", "100%", null);
|
||||||
|
myTable.setID("WProcessParameter");
|
||||||
|
|
||||||
|
myTable.addElement(new tr()
|
||||||
|
.addElement(wField.getLabel())
|
||||||
|
.addElement(createSelectField(columnName,Options)));
|
||||||
|
|
||||||
|
|
||||||
|
// Reset
|
||||||
|
String text = "Reset";
|
||||||
|
if (wsc.ctx != null)
|
||||||
|
text = Msg.getMsg (wsc.ctx, "Reset");
|
||||||
|
input restbtn = new input(input.TYPE_RESET, text, " "+text);
|
||||||
|
restbtn.setID(text);
|
||||||
|
restbtn.setClass("resetbtn");
|
||||||
|
|
||||||
|
// Submit
|
||||||
|
text = "Submit";
|
||||||
|
if (wsc.ctx != null)
|
||||||
|
text = Msg.getMsg (wsc.ctx, "Submit");
|
||||||
|
input submitbtn = new input(input.TYPE_SUBMIT, text, " "+text);
|
||||||
|
submitbtn.setID(text);
|
||||||
|
submitbtn.setClass("submitbtn");
|
||||||
|
|
||||||
|
myTable.addElement(new tr()
|
||||||
|
.addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false,
|
||||||
|
restbtn))
|
||||||
|
.addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false,
|
||||||
|
submitbtn ))
|
||||||
|
.addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false,
|
||||||
|
null)));
|
||||||
|
myForm.addElement(myTable);
|
||||||
|
center.addElement(myForm);
|
||||||
|
|
||||||
|
} // DocAction
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
td center = doc.addWindowCenter(false);
|
td center = doc.addWindowCenter(false);
|
||||||
if (process.getDescription() != null)
|
if (process.getDescription() != null)
|
||||||
center.addElement(new p(new i(process.getDescription())));
|
center.addElement(new p(new i(process.getDescription())));
|
||||||
|
|
@ -159,22 +282,36 @@ public class WProcess extends HttpServlet
|
||||||
.setName("process" + process.getAD_Process_ID());
|
.setName("process" + process.getAD_Process_ID());
|
||||||
myForm.setOnSubmit("this.Submit.disabled=true;return true;");
|
myForm.setOnSubmit("this.Submit.disabled=true;return true;");
|
||||||
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Process_ID", process.getAD_Process_ID()));
|
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Process_ID", process.getAD_Process_ID()));
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Window_ID", windowID));
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", tableID));
|
||||||
|
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Record_ID", recordID));
|
||||||
table myTable = new table("0", "0", "5", "100%", null);
|
table myTable = new table("0", "0", "5", "100%", null);
|
||||||
myTable.setID("WProcessParameter");
|
myTable.setID("WProcessParameter");
|
||||||
MProcessPara[] parameter = process.getParameters();
|
MProcessPara[] parameter = process.getParameters();
|
||||||
|
|
||||||
for (int i = 0; i < parameter.length; i++)
|
for (int i = 0; i < parameter.length; i++)
|
||||||
{
|
{
|
||||||
MProcessPara para = parameter[i];
|
MProcessPara para = parameter[i];
|
||||||
//
|
|
||||||
WebField wField = new WebField (wsc,
|
WebField wField = new WebField (wsc,
|
||||||
para.getColumnName(), para.getName(), para.getDescription(),
|
para.getColumnName(), para.getName(), para.getDescription(),
|
||||||
// no display length
|
// no display length
|
||||||
para.getAD_Reference_ID(), para.getFieldLength(), para.getFieldLength(), false,
|
para.getAD_Reference_ID(), para.getFieldLength(), para.getFieldLength(), false,
|
||||||
// not r/o, ., not error, not dependent
|
// not r/o, ., not error, not dependent
|
||||||
false, para.isMandatory(), false, false, false);
|
false, para.isMandatory(), false, false, false, para.getAD_Process_ID(),
|
||||||
|
0,0,0,i, null,null, null,null);
|
||||||
|
|
||||||
|
WebField wFieldforRange = null;
|
||||||
|
|
||||||
|
if(para.isRange())
|
||||||
|
wFieldforRange = new WebField (wsc,
|
||||||
|
para.getColumnName(), para.getName(), para.getDescription(),
|
||||||
|
// no display length
|
||||||
|
para.getAD_Reference_ID(), para.getFieldLength(), para.getFieldLength(), false,
|
||||||
|
// not r/o, ., not error, not dependent
|
||||||
|
false, para.isMandatory(), false, false, false, para.getAD_Process_ID(),0,0,0,i+1, null,null, null,null);
|
||||||
|
|
||||||
td toField = para.isRange()
|
td toField = para.isRange()
|
||||||
? wField.getField(para.getLookup(), para.getDefaultValue2())
|
? wFieldforRange.getField(para.getLookup(), para.getDefaultValue2())
|
||||||
: new td(WebEnv.NBSP);
|
: new td(WebEnv.NBSP);
|
||||||
|
|
||||||
// Add to Table
|
// Add to Table
|
||||||
|
|
@ -183,38 +320,57 @@ public class WProcess extends HttpServlet
|
||||||
.addElement(wField.getField(para.getLookup(), para.getDefaultValue()))
|
.addElement(wField.getField(para.getLookup(), para.getDefaultValue()))
|
||||||
.addElement(toField));
|
.addElement(toField));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset
|
||||||
|
String text = "Reset";
|
||||||
|
if (wsc.ctx != null)
|
||||||
|
text = Msg.getMsg (wsc.ctx, "Reset");
|
||||||
|
input restbtn = new input(input.TYPE_RESET, text, " "+text);
|
||||||
|
restbtn.setID(text);
|
||||||
|
restbtn.setClass("resetbtn");
|
||||||
|
|
||||||
// Submit
|
// Submit
|
||||||
|
text = "Submit";
|
||||||
|
if (wsc.ctx != null)
|
||||||
|
text = Msg.getMsg (wsc.ctx, "Submit");
|
||||||
|
input submitbtn = new input(input.TYPE_SUBMIT, text, " "+text);
|
||||||
|
submitbtn.setID(text);
|
||||||
|
submitbtn.setClass("submitbtn");
|
||||||
|
|
||||||
|
|
||||||
myTable.addElement(new tr()
|
myTable.addElement(new tr()
|
||||||
.addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false,
|
|
||||||
new input(input.TYPE_RESET, "Reset", "Reset") ))
|
|
||||||
.addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false,
|
|
||||||
null ))
|
|
||||||
.addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false,
|
.addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false,
|
||||||
new input(input.TYPE_SUBMIT, "Submit", "Submit") )));
|
restbtn))
|
||||||
|
.addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false,
|
||||||
|
submitbtn ))
|
||||||
|
.addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false,
|
||||||
|
null)));
|
||||||
myForm.addElement(myTable);
|
myForm.addElement(myTable);
|
||||||
center.addElement(myForm);
|
center.addElement(myForm);
|
||||||
|
}
|
||||||
return doc;
|
return doc;
|
||||||
} // createParameterPage
|
} // createParameterPage
|
||||||
|
|
||||||
|
//Modified by Rob klein 4/29/07
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Create Parocess Page
|
* Create Parocess Page
|
||||||
* @param request request
|
* @param request request
|
||||||
* @param AD_Process_ID Process
|
* @param AD_Process_ID Process
|
||||||
* @return Page
|
* @return Page
|
||||||
*/
|
*/
|
||||||
private WebDoc createProcessPage (HttpServletRequest request, int AD_Process_ID)
|
public void createProcessPage (HttpServletRequest request, HttpServletResponse response, int AD_Process_ID, int AD_Window_ID)
|
||||||
{
|
{
|
||||||
WebSessionCtx wsc = WebSessionCtx.get (request);
|
WebSessionCtx wsc = WebSessionCtx.get (request);
|
||||||
MProcess process = MProcess.get (wsc.ctx, AD_Process_ID);
|
MProcess process = MProcess.get (wsc.ctx, AD_Process_ID);
|
||||||
// need to check if Role can access
|
// need to check if Role can access
|
||||||
|
WebDoc doc = null;
|
||||||
if (process == null)
|
if (process == null)
|
||||||
{
|
{
|
||||||
WebDoc doc = WebDoc.createWindow("Process Not Found");
|
doc = WebDoc.createWindow("Process Not Found");
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebDoc doc = WebDoc.createWindow(process.getName());
|
}
|
||||||
|
else{
|
||||||
|
doc = WebDoc.createWindow(process.getName());
|
||||||
td center = doc.addWindowCenter(false);
|
td center = doc.addWindowCenter(false);
|
||||||
if (process.getDescription() != null)
|
if (process.getDescription() != null)
|
||||||
center.addElement(new p(new i(process.getDescription())));
|
center.addElement(new p(new i(process.getDescription())));
|
||||||
|
|
@ -224,9 +380,15 @@ public class WProcess extends HttpServlet
|
||||||
// Create Process Instance
|
// Create Process Instance
|
||||||
MPInstance pInstance = fillParameter (request, process);
|
MPInstance pInstance = fillParameter (request, process);
|
||||||
//
|
//
|
||||||
ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID());
|
|
||||||
|
int AD_Table_ID = WebUtil.getParameterAsInt(request, "AD_Table_ID");
|
||||||
|
int AD_Record_ID = WebUtil.getParameterAsInt(request, "AD_Record_ID");
|
||||||
|
|
||||||
|
|
||||||
|
ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(), AD_Table_ID, AD_Record_ID);
|
||||||
pi.setAD_User_ID(Env.getAD_User_ID(wsc.ctx));
|
pi.setAD_User_ID(Env.getAD_User_ID(wsc.ctx));
|
||||||
pi.setAD_Client_ID(Env.getAD_Client_ID(wsc.ctx));
|
pi.setAD_Client_ID(Env.getAD_Client_ID(wsc.ctx));
|
||||||
|
log.info("PI client id "+pi.getAD_Client_ID());
|
||||||
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
|
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
|
|
@ -236,13 +398,44 @@ public class WProcess extends HttpServlet
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
boolean processOK = false;
|
boolean processOK = false;
|
||||||
|
if (process.isWorkflow())
|
||||||
|
{
|
||||||
|
Trx trx = Trx.get(Trx.createTrxName("WebPrc"), true);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
WProcessCtl.process(this, AD_Window_ID, pi, trx, request);
|
||||||
|
//processOK = process.processIt(pi, trx);
|
||||||
|
trx.commit();
|
||||||
|
trx.close();
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
trx.rollback();
|
||||||
|
trx.close();
|
||||||
|
}
|
||||||
|
if ( pi.isError())
|
||||||
|
{
|
||||||
|
center.addElement(new p("Error:" + pi.getSummary(),
|
||||||
|
AlignType.LEFT).setClass("Cerror"));
|
||||||
|
processOK = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
center.addElement(new p("OK: Workflow Started",
|
||||||
|
AlignType.LEFT));
|
||||||
|
processOK = true;
|
||||||
|
}
|
||||||
|
center.addElement(new p().addElement(pi.getSummary()));
|
||||||
|
center.addElement(pi.getLogInfo(true));
|
||||||
|
}
|
||||||
|
|
||||||
if (process.isJavaProcess())
|
if (process.isJavaProcess())
|
||||||
{
|
{
|
||||||
Trx trx = Trx.get(Trx.createTrxName("WebPrc"), true);
|
Trx trx = Trx.get(Trx.createTrxName("WebPrc"), true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
processOK = process.processIt(pi, trx);
|
processOK = process.processIt(pi, trx);
|
||||||
trx.commit(true);
|
trx.commit();
|
||||||
trx.close();
|
trx.close();
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
|
|
@ -261,8 +454,11 @@ public class WProcess extends HttpServlet
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report
|
// Report
|
||||||
if (processOK && process.isReport())
|
if (process.isReport())
|
||||||
|
//if (processOK && process.isReport())
|
||||||
{
|
{
|
||||||
|
doc = null;
|
||||||
|
log.info(response.toString());
|
||||||
ReportEngine re = ReportEngine.get(wsc.ctx, pi);
|
ReportEngine re = ReportEngine.get(wsc.ctx, pi);
|
||||||
if (re == null)
|
if (re == null)
|
||||||
{
|
{
|
||||||
|
|
@ -277,6 +473,14 @@ public class WProcess extends HttpServlet
|
||||||
boolean ok = re.createPDF(file);
|
boolean ok = re.createPDF(file);
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
|
String error = WebUtil.streamFile(response, file);
|
||||||
|
//String error = streamResult (request, response, pInstance.getAD_PInstance_ID(), file);
|
||||||
|
if (error == null)
|
||||||
|
return;
|
||||||
|
doc = WebDoc.create(error);
|
||||||
|
|
||||||
|
//Modified by Rob Klein 6/1/07
|
||||||
|
/**
|
||||||
String url = "WProcess?AD_PInstance_ID="
|
String url = "WProcess?AD_PInstance_ID="
|
||||||
+ pInstance.getAD_PInstance_ID()
|
+ pInstance.getAD_PInstance_ID()
|
||||||
+ "&File="
|
+ "&File="
|
||||||
|
|
@ -287,7 +491,9 @@ public class WProcess extends HttpServlet
|
||||||
.addElement("Report created: ")
|
.addElement("Report created: ")
|
||||||
.addElement(link));
|
.addElement(link));
|
||||||
// Marker that Process is OK
|
// Marker that Process is OK
|
||||||
|
* */
|
||||||
wsc.ctx.put("AD_PInstance_ID=" + pInstance.getAD_PInstance_ID(), "ok");
|
wsc.ctx.put("AD_PInstance_ID=" + pInstance.getAD_PInstance_ID(), "ok");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
center.addElement(new p("Could not create Report",
|
center.addElement(new p("Could not create Report",
|
||||||
|
|
@ -301,9 +507,21 @@ public class WProcess extends HttpServlet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return doc;
|
}
|
||||||
|
doc.addPopupClose(wsc.ctx);
|
||||||
|
|
||||||
|
try {
|
||||||
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
}
|
||||||
} // createProcessPage
|
} // createProcessPage
|
||||||
|
|
||||||
|
private ASyncProcess ASyncProcess(WProcess process) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill Parameter
|
* Fill Parameter
|
||||||
* @param request request
|
* @param request request
|
||||||
|
|
@ -397,7 +615,7 @@ public class WProcess extends HttpServlet
|
||||||
* @return message
|
* @return message
|
||||||
*/
|
*/
|
||||||
private String streamResult (HttpServletRequest request, HttpServletResponse response,
|
private String streamResult (HttpServletRequest request, HttpServletResponse response,
|
||||||
int AD_PInstance_ID, String fileName)
|
int AD_PInstance_ID, File file)
|
||||||
{
|
{
|
||||||
if (AD_PInstance_ID == 0)
|
if (AD_PInstance_ID == 0)
|
||||||
return "Your process not found";
|
return "Your process not found";
|
||||||
|
|
@ -406,13 +624,393 @@ public class WProcess extends HttpServlet
|
||||||
if (value == null || !value.equals("ok"))
|
if (value == null || !value.equals("ok"))
|
||||||
return "Process Instance not found";
|
return "Process Instance not found";
|
||||||
//
|
//
|
||||||
if (fileName == null || fileName.length() == 0)
|
if (file == null || file.length() == 0)
|
||||||
return "No Process Result";
|
return "No Process Result";
|
||||||
File file = new File (fileName);
|
//File file = new File (fileName);
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
return "Process Result not found: " + file;
|
return "Process Result not found: " + file;
|
||||||
// OK
|
// OK
|
||||||
return WebUtil.streamFile(response, file);
|
return WebUtil.streamFile(response, file);
|
||||||
} // streamResult
|
} // streamResult
|
||||||
|
|
||||||
|
//Modidifed by Rob Klein 4/29/07
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamic Init - determine valid DocActions based on DocStatus for the different documents.
|
||||||
|
* <pre>
|
||||||
|
* DocStatus (131)
|
||||||
|
?? Unknown
|
||||||
|
AP * Approved
|
||||||
|
CH Changed
|
||||||
|
CL * Closed
|
||||||
|
CO * Completed
|
||||||
|
DR Drafted
|
||||||
|
IN Inactive
|
||||||
|
NA Not Approved
|
||||||
|
PE Posting Error
|
||||||
|
PO * Posted
|
||||||
|
PR * Printed
|
||||||
|
RE Reversed
|
||||||
|
TE Transfer Error
|
||||||
|
TR * Transferred
|
||||||
|
VO * Voided
|
||||||
|
XX Being Processed
|
||||||
|
*
|
||||||
|
* DocAction (135)
|
||||||
|
-- <None>
|
||||||
|
AP * Approve
|
||||||
|
CL * Close
|
||||||
|
CO * Complete
|
||||||
|
PO * Post
|
||||||
|
PR * Print
|
||||||
|
RA Reverse - Accrual
|
||||||
|
RC Reverse - Correction
|
||||||
|
RE RE-activate
|
||||||
|
RJ Reject
|
||||||
|
TR * Transfer
|
||||||
|
VO * Void
|
||||||
|
XL Unlock
|
||||||
|
* </pre>
|
||||||
|
* @param Record_ID id
|
||||||
|
*/
|
||||||
|
private option[] dynInit(int m_WindowNo,int m_AD_Table_ID,int Record_ID,
|
||||||
|
String columnName, GridTab m_mTab)
|
||||||
|
{
|
||||||
|
String DocStatus = (String)m_mTab.getValue("DocStatus");
|
||||||
|
String DocAction = (String)m_mTab.getValue("DocAction");
|
||||||
|
//
|
||||||
|
Object Processing = m_mTab.getValue("Processing");
|
||||||
|
String OrderType = Env.getContext(Env.getCtx(), m_WindowNo, "OrderType");
|
||||||
|
String IsSOTrx = Env.getContext(Env.getCtx(), m_WindowNo, "IsSOTrx");
|
||||||
|
|
||||||
|
option[] optionsret = new option[0];
|
||||||
|
String[] list = new String [s_value.length];
|
||||||
|
|
||||||
|
|
||||||
|
if (DocStatus == null)
|
||||||
|
{
|
||||||
|
errorMessage = "Document Status is Null";
|
||||||
|
return optionsret;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.fine("DocStatus=" + DocStatus
|
||||||
|
+ ", DocAction=" + DocAction + ", OrderType=" + OrderType
|
||||||
|
+ ", IsSOTrx=" + IsSOTrx + ", Processing=" + Processing
|
||||||
|
+ ", AD_Table_ID=" + m_AD_Table_ID + ", Record_ID=" + Record_ID);
|
||||||
|
//
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Existence of Workflow Acrivities
|
||||||
|
*/
|
||||||
|
String wfStatus = MWFActivity.getActiveInfo(Env.getCtx(), m_AD_Table_ID, Record_ID);
|
||||||
|
if (wfStatus != null)
|
||||||
|
{
|
||||||
|
errorMessage = wfStatus;
|
||||||
|
return optionsret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status Change
|
||||||
|
if (!checkStatus(m_mTab.getTableName(), Record_ID, DocStatus))
|
||||||
|
{
|
||||||
|
errorMessage = "DocumentStatusChanged";
|
||||||
|
return optionsret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************
|
||||||
|
* General Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Locked
|
||||||
|
if (Processing != null)
|
||||||
|
{
|
||||||
|
boolean locked = "Y".equals(Processing);
|
||||||
|
if (!locked && Processing instanceof Boolean)
|
||||||
|
locked = ((Boolean)Processing).booleanValue();
|
||||||
|
if (locked)
|
||||||
|
list[index++]= DocumentEngine.ACTION_Unlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Approval required .. NA
|
||||||
|
if (DocStatus.equals(DocumentEngine.STATUS_NotApproved))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Prepare);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Void);
|
||||||
|
}
|
||||||
|
// Draft/Invalid .. DR/IN
|
||||||
|
else if (DocStatus.equals(DocumentEngine.STATUS_Drafted)
|
||||||
|
|| DocStatus.equals(DocumentEngine.STATUS_Invalid))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Complete);
|
||||||
|
// options[index++] = (DocumentEngine.ACTION_Prepare);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Void);
|
||||||
|
}
|
||||||
|
// In Process .. IP
|
||||||
|
else if (DocStatus.equals(DocumentEngine.STATUS_InProgress)
|
||||||
|
|| DocStatus.equals(DocumentEngine.STATUS_Approved))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Complete);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Void);
|
||||||
|
}
|
||||||
|
// Complete .. CO
|
||||||
|
else if (DocStatus.equals(DocumentEngine.STATUS_Completed))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Close);
|
||||||
|
}
|
||||||
|
// Waiting Payment
|
||||||
|
else if (DocStatus.equals(DocumentEngine.STATUS_WaitingPayment)
|
||||||
|
|| DocStatus.equals(DocumentEngine.STATUS_WaitingConfirmation))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Void);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Prepare);
|
||||||
|
}
|
||||||
|
// Closed, Voided, REversed .. CL/VO/RE
|
||||||
|
else if (DocStatus.equals(DocumentEngine.STATUS_Closed)
|
||||||
|
|| DocStatus.equals(DocumentEngine.STATUS_Voided)
|
||||||
|
|| DocStatus.equals(DocumentEngine.STATUS_Reversed))
|
||||||
|
return optionsret;
|
||||||
|
|
||||||
|
/********************
|
||||||
|
* Order
|
||||||
|
*/
|
||||||
|
if (m_AD_Table_ID == MOrder.Table_ID)
|
||||||
|
{
|
||||||
|
// Draft .. DR/IP/IN
|
||||||
|
if (DocStatus.equals(DocumentEngine.STATUS_Drafted)
|
||||||
|
|| DocStatus.equals(DocumentEngine.STATUS_InProgress)
|
||||||
|
|| DocStatus.equals(DocumentEngine.STATUS_Invalid))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Prepare);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Close);
|
||||||
|
// Draft Sales Order Quote/Proposal - Process
|
||||||
|
if ("Y".equals(IsSOTrx)
|
||||||
|
&& ("OB".equals(OrderType) || "ON".equals(OrderType)))
|
||||||
|
DocAction = DocumentEngine.ACTION_Prepare;
|
||||||
|
}
|
||||||
|
// Complete .. CO
|
||||||
|
else if (DocStatus.equals(DocumentEngine.STATUS_Completed))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Void);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_ReActivate);
|
||||||
|
}
|
||||||
|
else if (DocStatus.equals(DocumentEngine.STATUS_WaitingPayment))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_ReActivate);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Close);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/********************
|
||||||
|
* Shipment
|
||||||
|
*/
|
||||||
|
else if (m_AD_Table_ID == MInOut.Table_ID)
|
||||||
|
{
|
||||||
|
// Complete .. CO
|
||||||
|
if (DocStatus.equals(DocumentEngine.STATUS_Completed))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Void);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Reverse_Correct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/********************
|
||||||
|
* Invoice
|
||||||
|
*/
|
||||||
|
else if (m_AD_Table_ID == MInvoice.Table_ID)
|
||||||
|
{
|
||||||
|
// Complete .. CO
|
||||||
|
if (DocStatus.equals(DocumentEngine.STATUS_Completed))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Void);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Reverse_Correct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/********************
|
||||||
|
* Payment
|
||||||
|
*/
|
||||||
|
else if (m_AD_Table_ID == MPayment.Table_ID)
|
||||||
|
{
|
||||||
|
// Complete .. CO
|
||||||
|
if (DocStatus.equals(DocumentEngine.STATUS_Completed))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Void);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Reverse_Correct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/********************
|
||||||
|
* GL Journal
|
||||||
|
*/
|
||||||
|
else if (m_AD_Table_ID == MJournal.Table_ID || m_AD_Table_ID == MJournalBatch.Table_ID)
|
||||||
|
{
|
||||||
|
// Complete .. CO
|
||||||
|
if (DocStatus.equals(DocumentEngine.STATUS_Completed))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Reverse_Correct);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Reverse_Accrual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/********************
|
||||||
|
* Allocation
|
||||||
|
*/
|
||||||
|
else if (m_AD_Table_ID == MAllocationHdr.Table_ID)
|
||||||
|
{
|
||||||
|
// Complete .. CO
|
||||||
|
if (DocStatus.equals(DocumentEngine.STATUS_Completed))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Void);
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Reverse_Correct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/********************
|
||||||
|
* Bank Statement
|
||||||
|
*/
|
||||||
|
else if (m_AD_Table_ID == MBankStatement.Table_ID)
|
||||||
|
{
|
||||||
|
// Complete .. CO
|
||||||
|
if (DocStatus.equals(DocumentEngine.STATUS_Completed))
|
||||||
|
{
|
||||||
|
list[index++]= (DocumentEngine.ACTION_Void);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/********************
|
||||||
|
* Inventory Movement, Physical Inventory
|
||||||
|
*/
|
||||||
|
else if (m_AD_Table_ID == MMovement.Table_ID
|
||||||
|
|| m_AD_Table_ID == MInventory.Table_ID)
|
||||||
|
{
|
||||||
|
// Complete .. CO
|
||||||
|
if (DocStatus.equals(DocumentEngine.STATUS_Completed))
|
||||||
|
{
|
||||||
|
list[index++] = (DocumentEngine.ACTION_Void);
|
||||||
|
list[index++] = (DocumentEngine.ACTION_Reverse_Correct);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
option[] options = new option[index];
|
||||||
|
/**
|
||||||
|
* Add Name to options
|
||||||
|
*/
|
||||||
|
for (int i = 0; i < index; i++)
|
||||||
|
{
|
||||||
|
// Serach for option and add it
|
||||||
|
boolean added = false;
|
||||||
|
for (int j = 0; j < s_value.length && !added; j++)
|
||||||
|
{
|
||||||
|
if (list[i].equals(s_value[j]))
|
||||||
|
{
|
||||||
|
options[i] = new option(list[i]).addElement(s_name[j]);
|
||||||
|
added = true;
|
||||||
|
if (DocAction.equals(s_value[i]))
|
||||||
|
options[i].setSelected(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
|
} // dynInit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill Vector with DocAction Ref_List(135) values
|
||||||
|
*/
|
||||||
|
private void readReference()
|
||||||
|
{
|
||||||
|
String sql;
|
||||||
|
if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List"))
|
||||||
|
sql = "SELECT Value, Name, Description FROM AD_Ref_List "
|
||||||
|
+ "WHERE AD_Reference_ID=135 ORDER BY Name";
|
||||||
|
else
|
||||||
|
sql = "SELECT l.Value, t.Name, t.Description "
|
||||||
|
+ "FROM AD_Ref_List l, AD_Ref_List_Trl t "
|
||||||
|
+ "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID"
|
||||||
|
+ " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'"
|
||||||
|
+ " AND l.AD_Reference_ID=135 ORDER BY t.Name";
|
||||||
|
|
||||||
|
ArrayList<String> v_value = new ArrayList<String>();
|
||||||
|
ArrayList<String> v_name = new ArrayList<String>();
|
||||||
|
ArrayList<String> v_description = new ArrayList<String>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
while (rs.next())
|
||||||
|
{
|
||||||
|
String value = rs.getString(1);
|
||||||
|
String name = rs.getString(2);
|
||||||
|
String description = rs.getString(3);
|
||||||
|
if (description == null)
|
||||||
|
description = "";
|
||||||
|
//
|
||||||
|
v_value.add(value);
|
||||||
|
v_name.add(name);
|
||||||
|
v_description.add(description);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert to arrays
|
||||||
|
int size = v_value.size();
|
||||||
|
s_value = new String[size];
|
||||||
|
s_name = new String[size];
|
||||||
|
s_description = new String[size];
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
s_value[i] = (String)v_value.get(i);
|
||||||
|
s_name[i] = (String)v_name.get(i);
|
||||||
|
s_description[i] = (String)v_description.get(i);
|
||||||
|
}
|
||||||
|
} // readReference
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Status Change
|
||||||
|
* @param TableName table name
|
||||||
|
* @param Record_ID record
|
||||||
|
* @param DocStatus current doc status
|
||||||
|
* @return true if status not changed
|
||||||
|
*/
|
||||||
|
private boolean checkStatus (String TableName, int Record_ID, String DocStatus)
|
||||||
|
{
|
||||||
|
String sql = "SELECT 2 FROM " + TableName
|
||||||
|
+ " WHERE " + TableName + "_ID=" + Record_ID
|
||||||
|
+ " AND DocStatus='" + DocStatus + "'";
|
||||||
|
int result = DB.getSQLValue(null, sql);
|
||||||
|
return result == 2;
|
||||||
|
} // checkStatusChange
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Select Field
|
||||||
|
* @param lookup lookup
|
||||||
|
* @param dataValue default value
|
||||||
|
* @return selction td
|
||||||
|
*/
|
||||||
|
private td createSelectField (String m_columnName, option[] options)
|
||||||
|
{
|
||||||
|
select sel = new select(m_columnName, options);
|
||||||
|
sel.setID(m_columnName);
|
||||||
|
sel.setDisabled(false);
|
||||||
|
sel.setClass("Cmandatory");
|
||||||
|
|
||||||
|
//
|
||||||
|
return createTD(sel);
|
||||||
|
|
||||||
|
} // getSelectField
|
||||||
|
/**
|
||||||
|
* Create Left Top aligned TD
|
||||||
|
* @param element element
|
||||||
|
* @return td table data
|
||||||
|
*/
|
||||||
|
private td createTD (Element element)
|
||||||
|
{
|
||||||
|
td td = new td()
|
||||||
|
.addElement(element)
|
||||||
|
.setAlign(AlignType.LEFT)
|
||||||
|
.setVAlign(AlignType.TOP);
|
||||||
|
return td;
|
||||||
|
} // createTD
|
||||||
|
|
||||||
} // WProcess
|
} // WProcess
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,515 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Compiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* 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. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.www;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.lang.reflect.*;
|
||||||
|
import java.rmi.*;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.logging.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
import org.compiere.apps.Waiting;
|
||||||
|
import org.compiere.db.*;
|
||||||
|
import org.compiere.interfaces.*;
|
||||||
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.print.*;
|
||||||
|
import org.compiere.process.*;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
import org.compiere.wf.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process Interface Controller.
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: ProcessCtl.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public class WProcessCtl extends Thread
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Async Process - Do it all.
|
||||||
|
* <code>
|
||||||
|
* - Get Instance ID
|
||||||
|
* - Get Parameters
|
||||||
|
* - execute (lock - start process - unlock)
|
||||||
|
* </code>
|
||||||
|
* Creates a ProcessCtl instance, which calls
|
||||||
|
* lockUI and unlockUI if parent is a ASyncProcess
|
||||||
|
* <br>
|
||||||
|
* Called from ProcessCtl.startProcess, ProcessDialog.actionPerformed,
|
||||||
|
* APanel.cmd_print, APanel.actionButton, VPaySelect.cmd_generate
|
||||||
|
*
|
||||||
|
* @param parent ASyncProcess & Container
|
||||||
|
* @param WindowNo window no
|
||||||
|
* @param pi ProcessInfo process info
|
||||||
|
* @param trx Transaction
|
||||||
|
* @return worker started ProcessCtl instance or null for workflow
|
||||||
|
*/
|
||||||
|
public static WProcessCtl process (Object parent, int WindowNo, ProcessInfo pi, Trx trx, HttpServletRequest request)
|
||||||
|
{
|
||||||
|
log.fine("WindowNo=" + WindowNo + " - " + pi);
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get (request);
|
||||||
|
MPInstance instance = new MPInstance(wsc.ctx, pi.getAD_Process_ID(), pi.getRecord_ID());
|
||||||
|
|
||||||
|
if (!instance.save())
|
||||||
|
{
|
||||||
|
pi.setSummary (Msg.getMsg(wsc.ctx, "ProcessNoInstance"));
|
||||||
|
pi.setError (true);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
pi.setAD_PInstance_ID (instance.getAD_PInstance_ID());
|
||||||
|
|
||||||
|
// Get Parameters (Dialog)
|
||||||
|
/**ProcessParameter para = new ProcessParameter (Env.getFrame((Container)parent), WindowNo, pi);
|
||||||
|
if (para.initDialog())
|
||||||
|
{
|
||||||
|
para.setVisible(true);
|
||||||
|
if (!para.isOK())
|
||||||
|
{
|
||||||
|
pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessCancelled"));
|
||||||
|
pi.setError (true);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
**/
|
||||||
|
// execute
|
||||||
|
WProcessCtl worker = new WProcessCtl(parent, pi, trx, wsc.ctx);
|
||||||
|
worker.start(); // MUST be start!
|
||||||
|
return worker;
|
||||||
|
} // execute
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Constructor
|
||||||
|
* @param parent Container & ASyncProcess
|
||||||
|
* @param pi Process info
|
||||||
|
* @param trx Transaction
|
||||||
|
* Created in process(), VInvoiceGen.generateInvoices
|
||||||
|
*/
|
||||||
|
public WProcessCtl (Object parent, ProcessInfo pi, Trx trx, Properties wscctx)
|
||||||
|
{
|
||||||
|
m_parent = parent;
|
||||||
|
m_pi = pi;
|
||||||
|
m_wscctx = wscctx;
|
||||||
|
m_trx = trx; // handeled correctly
|
||||||
|
} // ProcessCtl
|
||||||
|
|
||||||
|
private Object m_parent;
|
||||||
|
private Properties m_wscctx;
|
||||||
|
private ProcessInfo m_pi;
|
||||||
|
private Trx m_trx;
|
||||||
|
private Waiting m_waiting;
|
||||||
|
private boolean m_IsServerProcess = false;
|
||||||
|
|
||||||
|
/** Static Logger */
|
||||||
|
private static CLogger log = CLogger.getCLogger (WProcessCtl.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute Process Instance and Lock UI.
|
||||||
|
* Calls lockUI and unlockUI if parent is a ASyncProcess
|
||||||
|
* <pre>
|
||||||
|
* - Get Process Information
|
||||||
|
* - Call Class
|
||||||
|
* - Submit SQL Procedure
|
||||||
|
* - Run SQL Procedure
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public void run ()
|
||||||
|
{
|
||||||
|
log.fine("AD_PInstance_ID=" + m_pi.getAD_PInstance_ID()
|
||||||
|
+ ", Record_ID=" + m_pi.getRecord_ID());
|
||||||
|
|
||||||
|
// Lock
|
||||||
|
//lock();
|
||||||
|
// try {System.out.println(">> sleeping ..");sleep(20000);System.out.println(".. sleeping <<");} catch (Exception e) {}
|
||||||
|
|
||||||
|
// Get Process Information: Name, Procedure Name, ClassName, IsReport, IsDirectPrint
|
||||||
|
String ProcedureName = "";
|
||||||
|
int AD_ReportView_ID = 0;
|
||||||
|
int AD_Workflow_ID = 0;
|
||||||
|
boolean IsReport = false;
|
||||||
|
boolean IsDirectPrint = false;
|
||||||
|
//
|
||||||
|
String sql = "SELECT p.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4
|
||||||
|
+ " p.isReport,p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8
|
||||||
|
+ " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END CASE,"
|
||||||
|
+ " p.IsServerProcess "
|
||||||
|
+ "FROM AD_Process p"
|
||||||
|
+ " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) "
|
||||||
|
+ "WHERE p.IsActive='Y'"
|
||||||
|
+ " AND i.AD_PInstance_ID=?";
|
||||||
|
if (!Env.isBaseLanguage(m_wscctx, "AD_Process"))
|
||||||
|
sql = "SELECT t.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4
|
||||||
|
+ " p.isReport, p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8
|
||||||
|
+ " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END CASE,"
|
||||||
|
+ " p.IsServerProcess "
|
||||||
|
+ "FROM AD_Process p"
|
||||||
|
+ " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) "
|
||||||
|
+ " INNER JOIN AD_Process_Trl t ON (p.AD_Process_ID=t.AD_Process_ID"
|
||||||
|
+ " AND t.AD_Language='" + Env.getAD_Language(m_wscctx) + "') "
|
||||||
|
+ "WHERE p.IsActive='Y'"
|
||||||
|
+ " AND i.AD_PInstance_ID=?";
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sql,
|
||||||
|
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, null);
|
||||||
|
pstmt.setInt(1, m_pi.getAD_PInstance_ID());
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
{
|
||||||
|
m_pi.setTitle (rs.getString(1));
|
||||||
|
if (m_waiting != null)
|
||||||
|
m_waiting.setTitle(m_pi.getTitle());
|
||||||
|
ProcedureName = rs.getString(2);
|
||||||
|
m_pi.setClassName (rs.getString(3));
|
||||||
|
m_pi.setAD_Process_ID (rs.getInt(4));
|
||||||
|
// Report
|
||||||
|
if ("Y".equals(rs.getString(5)))
|
||||||
|
{
|
||||||
|
IsReport = true;
|
||||||
|
if ("Y".equals(rs.getString(6)) && !Ini.isPropertyBool(Ini.P_PRINTPREVIEW))
|
||||||
|
IsDirectPrint = true;
|
||||||
|
}
|
||||||
|
AD_ReportView_ID = rs.getInt(7);
|
||||||
|
AD_Workflow_ID = rs.getInt(8);
|
||||||
|
//
|
||||||
|
int estimate = rs.getInt(9);
|
||||||
|
if (estimate != 0)
|
||||||
|
{
|
||||||
|
m_pi.setEstSeconds (estimate + 1); // admin overhead
|
||||||
|
if (m_waiting != null)
|
||||||
|
m_waiting.setTimerEstimate(m_pi.getEstSeconds());
|
||||||
|
}
|
||||||
|
m_IsServerProcess = "Y".equals(rs.getString(10));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
log.log(Level.SEVERE, "No AD_PInstance_ID=" + m_pi.getAD_PInstance_ID());
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
m_pi.setSummary (Msg.getMsg(m_wscctx, "ProcessNoProcedure") + " " + e.getLocalizedMessage(), true);
|
||||||
|
//unlock();
|
||||||
|
log.log(Level.SEVERE, "run", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No PL/SQL Procedure
|
||||||
|
if (ProcedureName == null)
|
||||||
|
ProcedureName = "";
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Workflow
|
||||||
|
*/
|
||||||
|
if (AD_Workflow_ID > 0)
|
||||||
|
{
|
||||||
|
startWorkflow (AD_Workflow_ID);
|
||||||
|
//unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Start Optional Class
|
||||||
|
*/
|
||||||
|
if (m_pi.getClassName() != null)
|
||||||
|
{
|
||||||
|
// Run Class
|
||||||
|
if (!startProcess())
|
||||||
|
{
|
||||||
|
//unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No Optional SQL procedure ... done
|
||||||
|
if (!IsReport && ProcedureName.length() == 0)
|
||||||
|
{
|
||||||
|
//unlock ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// No Optional Report ... done
|
||||||
|
if (IsReport && AD_ReportView_ID == 0)
|
||||||
|
{
|
||||||
|
//unlock ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not a report, we need a prodedure name
|
||||||
|
if (!IsReport && ProcedureName.length() == 0)
|
||||||
|
{
|
||||||
|
m_pi.setSummary (Msg.getMsg(m_wscctx, "ProcessNoProcedure"), true);
|
||||||
|
//unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Report submission
|
||||||
|
*/
|
||||||
|
if (IsReport)
|
||||||
|
{
|
||||||
|
// Optional Pre-Report Process
|
||||||
|
if (ProcedureName.length() > 0)
|
||||||
|
{
|
||||||
|
if (!startDBProcess(ProcedureName))
|
||||||
|
{
|
||||||
|
//unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} // Pre-Report
|
||||||
|
|
||||||
|
// Start Report -----------------------------------------------
|
||||||
|
boolean ok = ReportCtl.start(m_pi, IsDirectPrint);
|
||||||
|
m_pi.setSummary("Report", !ok);
|
||||||
|
//unlock ();
|
||||||
|
}
|
||||||
|
/**********************************************************************
|
||||||
|
* Process submission
|
||||||
|
*/
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!startDBProcess (ProcedureName))
|
||||||
|
{
|
||||||
|
//unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Success - getResult
|
||||||
|
ProcessInfoUtil.setSummaryFromDB(m_pi);
|
||||||
|
//unlock();
|
||||||
|
} // *** Process submission ***
|
||||||
|
// log.fine(Log.l3_Util, "ProcessCtl.run - done");
|
||||||
|
} // run
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lock UI & show Waiting
|
||||||
|
*/
|
||||||
|
/** private void lock ()
|
||||||
|
{
|
||||||
|
// log.info("...");
|
||||||
|
JFrame frame = Env.getFrame((Container)m_parent);
|
||||||
|
if (frame instanceof AWindow)
|
||||||
|
((AWindow)frame).setBusyTimer(m_pi.getEstSeconds());
|
||||||
|
else
|
||||||
|
m_waiting = new Waiting (frame, Msg.getMsg(Env.getCtx(), "Processing"), false, m_pi.getEstSeconds());
|
||||||
|
SwingUtilities.invokeLater(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
log.finer("lock");
|
||||||
|
m_parent.lockUI(m_pi);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (m_waiting != null)
|
||||||
|
{
|
||||||
|
m_waiting.toFront();
|
||||||
|
m_waiting.setVisible(true);
|
||||||
|
}
|
||||||
|
} // lock
|
||||||
|
**/
|
||||||
|
/**
|
||||||
|
* Unlock UI & dispose Waiting.
|
||||||
|
* Called from run()
|
||||||
|
*/
|
||||||
|
/** private void unlock ()
|
||||||
|
{
|
||||||
|
// log.info("...");
|
||||||
|
if (m_pi.isBatch())
|
||||||
|
m_pi.setIsTimeout(true);
|
||||||
|
SwingUtilities.invokeLater(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
String summary = m_pi.getSummary();
|
||||||
|
log.finer("unlock - " + summary);
|
||||||
|
if (summary != null && summary.indexOf("@") != -1)
|
||||||
|
m_pi.setSummary(Msg.parseTranslation(Env.getCtx(), summary));
|
||||||
|
m_parent.unlockUI(m_pi);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Remove Waiting/Processing Indicator
|
||||||
|
if (m_waiting != null)
|
||||||
|
m_waiting.dispose();
|
||||||
|
m_waiting = null;
|
||||||
|
} // unlock
|
||||||
|
|
||||||
|
**/
|
||||||
|
/**************************************************************************
|
||||||
|
* Start Workflow.
|
||||||
|
*
|
||||||
|
* @param AD_Workflow_ID workflow
|
||||||
|
* @return true if started
|
||||||
|
*/
|
||||||
|
private boolean startWorkflow (int AD_Workflow_ID)
|
||||||
|
{
|
||||||
|
log.fine(AD_Workflow_ID + " - " + m_pi);
|
||||||
|
boolean started = false;
|
||||||
|
if (DB.isRemoteProcess())
|
||||||
|
{
|
||||||
|
log.info("trying to running on the server");
|
||||||
|
Server server = CConnection.get().getServer();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (server != null)
|
||||||
|
{ // See ServerBean
|
||||||
|
log.info("running on the server");
|
||||||
|
m_pi = server.workflow (m_wscctx, m_pi, AD_Workflow_ID);
|
||||||
|
log.finest("server => " + m_pi);
|
||||||
|
started = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (RemoteException ex)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "AppsServer error", ex);
|
||||||
|
started = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Run locally
|
||||||
|
if (!started && !m_IsServerProcess)
|
||||||
|
{
|
||||||
|
log.info("running locally");
|
||||||
|
MWorkflow wf = MWorkflow.get (m_wscctx, AD_Workflow_ID);
|
||||||
|
MWFProcess wfProcess = null;
|
||||||
|
if (m_pi.isBatch())
|
||||||
|
wfProcess = wf.start(m_pi); // may return null
|
||||||
|
else
|
||||||
|
wfProcess = wf.startWait(m_pi); // may return null
|
||||||
|
started = wfProcess != null;
|
||||||
|
}
|
||||||
|
return started;
|
||||||
|
} // startWorkflow
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Start Java Process Class.
|
||||||
|
* instanciate the class implementing the interface ProcessCall.
|
||||||
|
* The class can be a Server/Client class (when in Package
|
||||||
|
* org compiere.process or org.compiere.model) or a client only class
|
||||||
|
* (e.g. in org.compiere.report)
|
||||||
|
*
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
private boolean startProcess ()
|
||||||
|
{
|
||||||
|
log.fine(m_pi.toString());
|
||||||
|
boolean started = false;
|
||||||
|
if (DB.isRemoteProcess())
|
||||||
|
{
|
||||||
|
Server server = CConnection.get().getServer();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (server != null)
|
||||||
|
{ // See ServerBean
|
||||||
|
m_pi = server.process (m_wscctx, m_pi);
|
||||||
|
log.finest("server => " + m_pi);
|
||||||
|
started = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (UndeclaredThrowableException ex)
|
||||||
|
{
|
||||||
|
Throwable cause = ex.getCause();
|
||||||
|
if (cause != null)
|
||||||
|
{
|
||||||
|
if (cause instanceof InvalidClassException)
|
||||||
|
log.log(Level.SEVERE, "Version Server <> Client: "
|
||||||
|
+ cause.toString() + " - " + m_pi, ex);
|
||||||
|
else
|
||||||
|
log.log(Level.SEVERE, "AppsServer error(1b): "
|
||||||
|
+ cause.toString() + " - " + m_pi, ex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
log.log(Level.SEVERE, " AppsServer error(1) - "
|
||||||
|
+ m_pi, ex);
|
||||||
|
started = false;
|
||||||
|
}
|
||||||
|
catch (RemoteException ex)
|
||||||
|
{
|
||||||
|
Throwable cause = ex.getCause();
|
||||||
|
if (cause == null)
|
||||||
|
cause = ex;
|
||||||
|
log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause);
|
||||||
|
started = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Run locally
|
||||||
|
if (!started && !m_IsServerProcess)
|
||||||
|
{
|
||||||
|
ProcessCall myObject = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Class myClass = Class.forName(m_pi.getClassName());
|
||||||
|
myObject = (ProcessCall)myClass.newInstance();
|
||||||
|
if (myObject == null)
|
||||||
|
m_pi.setSummary("No Instance for " + m_pi.getClassName(), true);
|
||||||
|
else
|
||||||
|
myObject.startProcess(m_wscctx, m_pi, m_trx);
|
||||||
|
if (m_trx != null)
|
||||||
|
{
|
||||||
|
m_trx.commit();
|
||||||
|
m_trx.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (m_trx != null)
|
||||||
|
{
|
||||||
|
m_trx.rollback();
|
||||||
|
m_trx.close();
|
||||||
|
}
|
||||||
|
m_pi.setSummary("Error starting Class " + m_pi.getClassName(), true);
|
||||||
|
log.log(Level.SEVERE, m_pi.getClassName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !m_pi.isError();
|
||||||
|
} // startProcess
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Start Database Process
|
||||||
|
* @param ProcedureName PL/SQL procedure name
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
private boolean startDBProcess (String ProcedureName)
|
||||||
|
{
|
||||||
|
// execute on this thread/connection
|
||||||
|
log.fine(ProcedureName + "(" + m_pi.getAD_PInstance_ID() + ")");
|
||||||
|
String sql = "{call " + ProcedureName + "(?)}";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CallableStatement cstmt = DB.prepareCall(sql); // ro??
|
||||||
|
cstmt.setInt(1, m_pi.getAD_PInstance_ID());
|
||||||
|
cstmt.executeUpdate();
|
||||||
|
cstmt.close();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql, e);
|
||||||
|
m_pi.setSummary (Msg.getMsg(m_wscctx, "ProcessRunError") + " " + e.getLocalizedMessage());
|
||||||
|
m_pi.setError (true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// log.fine(Log.l4_Data, "ProcessCtl.startProcess - done");
|
||||||
|
return true;
|
||||||
|
} // startDBProcess
|
||||||
|
|
||||||
|
|
||||||
|
} // ProcessCtl
|
||||||
|
|
@ -0,0 +1,361 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* 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. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.www;
|
||||||
|
|
||||||
|
import java.awt.Cursor;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.servlet.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
|
import org.apache.ecs.AlignType;
|
||||||
|
import org.apache.ecs.xhtml.a;
|
||||||
|
import org.apache.ecs.xhtml.p;
|
||||||
|
import org.apache.ecs.xhtml.td;
|
||||||
|
import org.compiere.apps.ADialog;
|
||||||
|
import org.compiere.apps.AEnv;
|
||||||
|
import org.compiere.apps.ProcessCtl;
|
||||||
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.print.AReport;
|
||||||
|
import org.compiere.print.MPrintFormat;
|
||||||
|
import org.compiere.print.ReportEngine;
|
||||||
|
import org.compiere.print.Viewer;
|
||||||
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web (window) Report
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: WReport.java $
|
||||||
|
*/
|
||||||
|
public class WReport extends HttpServlet
|
||||||
|
{
|
||||||
|
/** Logger */
|
||||||
|
protected CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
/** Current MTab */
|
||||||
|
private GridTab m_curTab;
|
||||||
|
/** The Option List */
|
||||||
|
private ArrayList<KeyNamePair> m_list = new ArrayList<KeyNamePair>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize global variables
|
||||||
|
*/
|
||||||
|
public void init(ServletConfig config)
|
||||||
|
throws ServletException
|
||||||
|
{
|
||||||
|
super.init(config);
|
||||||
|
if (!WebEnv.initWeb(config))
|
||||||
|
throw new ServletException("WReport.init");
|
||||||
|
} // init
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the HTTP Get request
|
||||||
|
*/
|
||||||
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException
|
||||||
|
{
|
||||||
|
log.fine("doGet");
|
||||||
|
log.info(response.toString());
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
|
m_curTab = ws.curTab;
|
||||||
|
//
|
||||||
|
WebDoc doc = null;
|
||||||
|
File file = null;
|
||||||
|
if (ws == null)
|
||||||
|
{
|
||||||
|
doc = WebDoc.createPopup("No Context");
|
||||||
|
doc.addPopupClose(wsc.ctx);
|
||||||
|
}
|
||||||
|
/**else if (fileName!=null)
|
||||||
|
{
|
||||||
|
int AD_PInstance_ID = WebUtil.getParameterAsInt(request, "AD_PInstance_ID");
|
||||||
|
File file = new File (fileName);
|
||||||
|
String error = WebUtil.streamFile(response, file);
|
||||||
|
if (error == null)
|
||||||
|
return;
|
||||||
|
doc = WebDoc.createWindow(error);
|
||||||
|
}**/
|
||||||
|
else{
|
||||||
|
log.info("");
|
||||||
|
if (!MRole.getDefault().isCanReport(ws.curTab.getAD_Table_ID()))
|
||||||
|
{
|
||||||
|
doc = WebDoc.createPopup("Access Cannot Report");
|
||||||
|
doc.addPopupClose(wsc.ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Query
|
||||||
|
MQuery query = new MQuery(m_curTab.getTableName());
|
||||||
|
// Link for detail records
|
||||||
|
String queryColumn = m_curTab.getLinkColumnName();
|
||||||
|
// Current row otherwise
|
||||||
|
if (queryColumn.length() == 0)
|
||||||
|
queryColumn = m_curTab.getKeyColumnName();
|
||||||
|
// Find display
|
||||||
|
String infoName = null;
|
||||||
|
String infoDisplay = null;
|
||||||
|
for (int i = 0; i < m_curTab.getFieldCount(); i++)
|
||||||
|
{
|
||||||
|
GridField field = m_curTab.getField(i);
|
||||||
|
if (field.isKey())
|
||||||
|
infoName = field.getHeader();
|
||||||
|
if ((field.getColumnName().equals("Name") || field.getColumnName().equals("DocumentNo") )
|
||||||
|
&& field.getValue() != null)
|
||||||
|
infoDisplay = field.getValue().toString();
|
||||||
|
if (infoName != null && infoDisplay != null)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (queryColumn.length() != 0)
|
||||||
|
{
|
||||||
|
if (queryColumn.endsWith("_ID"))
|
||||||
|
query.addRestriction(queryColumn, MQuery.EQUAL,
|
||||||
|
new Integer(Env.getContextAsInt(wsc.ctx, m_curTab.getWindowNo(), queryColumn)),
|
||||||
|
infoName, infoDisplay);
|
||||||
|
else
|
||||||
|
query.addRestriction(queryColumn, MQuery.EQUAL,
|
||||||
|
Env.getContext(wsc.ctx, m_curTab.getWindowNo(), queryColumn),
|
||||||
|
infoName, infoDisplay);
|
||||||
|
}
|
||||||
|
|
||||||
|
file = getPrintFormats (m_curTab.getAD_Table_ID(), request, m_curTab, query);
|
||||||
|
String error = WebUtil.streamFile(response, file);
|
||||||
|
if (error == null)
|
||||||
|
return;
|
||||||
|
doc = WebDoc.createWindow(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
|
} // doGet
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the HTTP Post request
|
||||||
|
*/
|
||||||
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException
|
||||||
|
{
|
||||||
|
WebDoc doc = WebDoc.createPopup ("Report - Post - Not Implemented");
|
||||||
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
|
} // doPost
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Print Formats for the table.
|
||||||
|
* Fill the list and the popup menu
|
||||||
|
* @param AD_Table_ID table
|
||||||
|
* @param invoker component to display popup (optional)
|
||||||
|
*/
|
||||||
|
|
||||||
|
private File getPrintFormats (int AD_Table_ID,HttpServletRequest request, GridTab m_curTab, MQuery m_query )
|
||||||
|
{
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
|
int AD_Client_ID = Env.getAD_Client_ID(wsc.ctx);
|
||||||
|
File file = null;
|
||||||
|
m_list = new ArrayList<KeyNamePair>();
|
||||||
|
//
|
||||||
|
String sql = MRole.getDefault().addAccessSQL (
|
||||||
|
"SELECT AD_PrintFormat_ID, Name, AD_Client_ID "
|
||||||
|
+ "FROM AD_PrintFormat "
|
||||||
|
+ "WHERE AD_Table_ID=? AND IsTableBased='Y' "
|
||||||
|
+ "ORDER BY AD_Client_ID DESC, IsDefault DESC, Name", // Own First
|
||||||
|
"AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
|
||||||
|
KeyNamePair pp = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||||
|
pstmt.setInt(1, AD_Table_ID);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
while (rs.next())
|
||||||
|
{
|
||||||
|
pp = new KeyNamePair (rs.getInt(1), rs.getString(2));
|
||||||
|
if (rs.getInt(3) == AD_Client_ID)
|
||||||
|
{
|
||||||
|
m_list.add(pp);
|
||||||
|
//m_popup.add(pp.toString()).addActionListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No Format exists - create it
|
||||||
|
if (m_list.size() == 0)
|
||||||
|
{
|
||||||
|
if (pp == null)
|
||||||
|
file = createNewFormat (AD_Table_ID,request, m_curTab, m_query); // calls launch
|
||||||
|
else
|
||||||
|
file = copyFormat(pp.getKey(), AD_Client_ID,request, m_curTab, m_query);
|
||||||
|
}
|
||||||
|
// One Format exists or no invoker - show it
|
||||||
|
//else if (m_list.size() == 1 || invoker == null)
|
||||||
|
else
|
||||||
|
file = launchReport ((KeyNamePair)m_list.get(0),request, m_curTab, m_query);
|
||||||
|
//TODO Display Multiple Report List
|
||||||
|
// Multiple Formats exist - show selection
|
||||||
|
//else if (invoker.isShowing())
|
||||||
|
//m_popup.show(invoker, 0, invoker.getHeight()); // below button
|
||||||
|
return file;
|
||||||
|
} // getPrintFormats
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and Launch new Format for table
|
||||||
|
* @param AD_Table_ID table
|
||||||
|
*/
|
||||||
|
private File createNewFormat (int AD_Table_ID, HttpServletRequest request, GridTab m_curTab, MQuery m_query)
|
||||||
|
{
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
|
MPrintFormat pf = MPrintFormat.createFromTable(wsc.ctx, AD_Table_ID);
|
||||||
|
File file = launchReport (pf,request, m_curTab, m_query);
|
||||||
|
return file;
|
||||||
|
} // createNewFormat
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy existing Format
|
||||||
|
* @param AD_PrintFormat_ID print format
|
||||||
|
* @param To_Client_ID to client
|
||||||
|
*/
|
||||||
|
private File copyFormat (int AD_PrintFormat_ID, int To_Client_ID, HttpServletRequest request, GridTab m_curTab, MQuery m_query)
|
||||||
|
{
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
|
MPrintFormat pf = MPrintFormat.copyToClient(wsc.ctx, AD_PrintFormat_ID, To_Client_ID);
|
||||||
|
File file = launchReport (pf,request, m_curTab, m_query);
|
||||||
|
return file;
|
||||||
|
} // copyFormatFromClient
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch Report
|
||||||
|
* @param pp Key=AD_PrintFormat_ID
|
||||||
|
*/
|
||||||
|
private File launchReport (KeyNamePair pp, HttpServletRequest request, GridTab m_curTab,MQuery m_query)
|
||||||
|
{
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
|
MPrintFormat pf = MPrintFormat.get(wsc.ctx, pp.getKey(), false);
|
||||||
|
File file = launchReport (pf, request, m_curTab, m_query);
|
||||||
|
return file;
|
||||||
|
} // launchReport
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch Report
|
||||||
|
* @param pf print format
|
||||||
|
*/
|
||||||
|
private File launchReport (MPrintFormat pf, HttpServletRequest request, GridTab m_curTab, MQuery m_query)
|
||||||
|
{
|
||||||
|
int Record_ID = 0;
|
||||||
|
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
|
//Instance pInstance = new MPInstance (wsc.ctx, 0, 0);
|
||||||
|
|
||||||
|
File fileName = null;
|
||||||
|
|
||||||
|
|
||||||
|
if (m_query.getRestrictionCount()==1 && m_query.getCode(0) instanceof Integer){
|
||||||
|
Record_ID = ((Integer)m_query.getCode(0)).intValue();
|
||||||
|
}
|
||||||
|
PrintInfo info = new PrintInfo(
|
||||||
|
pf.getName(),
|
||||||
|
pf.getAD_Table_ID(),
|
||||||
|
Record_ID);
|
||||||
|
info.setDescription(m_query.getInfo());
|
||||||
|
if(pf != null && pf.getJasperProcess_ID() > 0)
|
||||||
|
{
|
||||||
|
// It's a report using the JasperReports engine
|
||||||
|
ProcessInfo pi = new ProcessInfo ("", pf.getJasperProcess_ID());
|
||||||
|
Trx trx = Trx.get(Trx.createTrxName("WebPrc"), true);
|
||||||
|
// Execute Process
|
||||||
|
WProcessCtl.process(this, m_curTab.getAD_Window_ID(), pi, trx, request);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// It's a default report using the standard printing engine
|
||||||
|
ReportEngine re = new ReportEngine (wsc.ctx, pf, m_query, info);
|
||||||
|
if (re == null)
|
||||||
|
{
|
||||||
|
log.info("Could not start ReportEngine");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File file = File.createTempFile("WProcess", ".pdf");
|
||||||
|
boolean ok = re.createPDF(file);
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
fileName = file;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
log.info("Could not create Report");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.info(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//doc.addPopupClose(wsc.ctx);
|
||||||
|
|
||||||
|
// if (m_popup.isVisible())
|
||||||
|
// m_popup.setVisible(false);
|
||||||
|
|
||||||
|
return fileName;
|
||||||
|
} // launchReport
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Get AD_Table_ID for Table Name
|
||||||
|
* @param TableName table name
|
||||||
|
* @return AD_Table_ID or 0
|
||||||
|
*/
|
||||||
|
static public int getAD_Table_ID (String TableName)
|
||||||
|
{
|
||||||
|
int AD_Table_ID = 0;
|
||||||
|
String sql = "SELECT AD_Table_ID FROM AD_Table WHERE TableName=?";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||||
|
pstmt.setString(1, TableName);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
AD_Table_ID = rs.getInt(1);
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
//log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
return AD_Table_ID;
|
||||||
|
} // getAD_Table_ID
|
||||||
|
|
||||||
|
} // WReport
|
||||||
|
|
@ -47,7 +47,7 @@ public class WStatus extends HttpServlet
|
||||||
{
|
{
|
||||||
WebDoc doc = WebDoc.create ("WStatus Get Request");
|
WebDoc doc = WebDoc.create ("WStatus Get Request");
|
||||||
//
|
//
|
||||||
WebUtil.createResponse(request, response, this, null, doc, true);
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
} // doGet
|
} // doGet
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ public class WStatus extends HttpServlet
|
||||||
{
|
{
|
||||||
WebDoc doc = WebDoc.create ("WStatus Post Request");
|
WebDoc doc = WebDoc.create ("WStatus Post Request");
|
||||||
//
|
//
|
||||||
WebUtil.createResponse(request, response, this, null, doc, true);
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
} // doPost
|
} // doPost
|
||||||
|
|
||||||
} // WStatus
|
} // WStatus
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* 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. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.www;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import javax.servlet.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.apache.ecs.*;
|
||||||
|
import org.apache.ecs.xhtml.*;
|
||||||
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web (window) Help
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: WHelp.java,v 1.2 2006/07/30 00:53:21 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public class WTest extends HttpServlet
|
||||||
|
{
|
||||||
|
/** Logger */
|
||||||
|
protected CLogger log = CLogger.getCLogger(WTest.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize global variables
|
||||||
|
*/
|
||||||
|
public void init(ServletConfig config)
|
||||||
|
throws ServletException
|
||||||
|
{
|
||||||
|
super.init(config);
|
||||||
|
if (!WebEnv.initWeb(config))
|
||||||
|
throw new ServletException("WTest.init");
|
||||||
|
} // init
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the HTTP Get request
|
||||||
|
*/
|
||||||
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException
|
||||||
|
{
|
||||||
|
log.fine("doGet");
|
||||||
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
|
//
|
||||||
|
WebDoc doc = null;
|
||||||
|
if (ws == null)
|
||||||
|
{
|
||||||
|
doc = WebDoc.createPopup("No Context");
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
doc.addPopupClose(Env.getCtx());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
doc = WebDoc.createPopup ("Test - Get - Not Implemented");
|
||||||
|
//
|
||||||
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
|
} // doGet
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the HTTP Post request
|
||||||
|
*/
|
||||||
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException
|
||||||
|
{
|
||||||
|
WebDoc doc = WebDoc.createPopup ("Test - Post - Not Implemented");
|
||||||
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
|
} // doPost
|
||||||
|
|
||||||
|
} // WHelp
|
||||||
|
|
@ -18,14 +18,20 @@ package org.compiere.www;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.math.*;
|
import java.math.*;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
import javax.servlet.*;
|
import javax.servlet.*;
|
||||||
import javax.servlet.http.*;
|
import javax.servlet.http.*;
|
||||||
|
|
||||||
import org.apache.ecs.*;
|
import org.apache.ecs.*;
|
||||||
import org.apache.ecs.xhtml.*;
|
import org.apache.ecs.xhtml.*;
|
||||||
|
import org.compiere.apps.ProcessCtl;
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.print.ReportEngine;
|
||||||
|
import org.compiere.process.ProcessInfo;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -57,7 +63,7 @@ public class WWindow extends HttpServlet
|
||||||
*/
|
*/
|
||||||
public String getServletInfo()
|
public String getServletInfo()
|
||||||
{
|
{
|
||||||
return "adempiere Web Window";
|
return "Adempiere Web Window";
|
||||||
} // getServletInfo
|
} // getServletInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,6 +78,9 @@ public class WWindow extends HttpServlet
|
||||||
private static int s_WindowNo = 1;
|
private static int s_WindowNo = 1;
|
||||||
/** Form Name */
|
/** Form Name */
|
||||||
protected static final String FORM_NAME = "WForm";
|
protected static final String FORM_NAME = "WForm";
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
|
||||||
|
protected static String sectionNameOld = null;
|
||||||
|
|
||||||
/** Hidden Parameter Command - Button */
|
/** Hidden Parameter Command - Button */
|
||||||
private static final String P_Command = "PCommand";
|
private static final String P_Command = "PCommand";
|
||||||
|
|
@ -83,7 +92,9 @@ public class WWindow extends HttpServlet
|
||||||
private static final String P_ChangedColumn = "ChangedColumn";
|
private static final String P_ChangedColumn = "ChangedColumn";
|
||||||
|
|
||||||
/** Multi Row Lines per Screen */
|
/** Multi Row Lines per Screen */
|
||||||
private static final int MAX_LINES = 12;
|
// Modified by Rob Klein 4/29/2007
|
||||||
|
//private static final int MAX_LINES = 12;
|
||||||
|
private static final int MAX_LINES = 1000;
|
||||||
/** Indicator for last line */
|
/** Indicator for last line */
|
||||||
private static final int LAST_LINE = 999999;
|
private static final int LAST_LINE = 999999;
|
||||||
|
|
||||||
|
|
@ -109,6 +120,7 @@ public class WWindow extends HttpServlet
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||||
{
|
{
|
||||||
// Get Session attributes
|
// Get Session attributes
|
||||||
|
WebDoc doc = null;
|
||||||
HttpSession sess = request.getSession();
|
HttpSession sess = request.getSession();
|
||||||
WebSessionCtx wsc = WebSessionCtx.get(request);
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
if (wsc == null)
|
if (wsc == null)
|
||||||
|
|
@ -125,6 +137,51 @@ public class WWindow extends HttpServlet
|
||||||
log.info("AD_Window_ID=" + AD_Window_ID
|
log.info("AD_Window_ID=" + AD_Window_ID
|
||||||
+ "; AD_Menu_ID=" + AD_Menu_ID);
|
+ "; AD_Menu_ID=" + AD_Menu_ID);
|
||||||
|
|
||||||
|
String TableName = null;
|
||||||
|
//Check to see if Zoom
|
||||||
|
int AD_Record_ID = WebUtil.getParameterAsInt(request, "AD_Record_ID");
|
||||||
|
int AD_Table_ID = WebUtil.getParameterAsInt(request, "AD_Table_ID");
|
||||||
|
if (AD_Record_ID != 0 || AD_Table_ID != 0){
|
||||||
|
|
||||||
|
AD_Window_ID = 0;
|
||||||
|
int PO_Window_ID = 0;
|
||||||
|
String sql = "SELECT TableName, AD_Window_ID, PO_Window_ID FROM AD_Table WHERE AD_Table_ID=?";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||||
|
pstmt.setInt(1, AD_Table_ID);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
{
|
||||||
|
TableName = rs.getString(1);
|
||||||
|
AD_Window_ID = rs.getInt(2);
|
||||||
|
PO_Window_ID = rs.getInt(3);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TableName == null || AD_Window_ID == 0){
|
||||||
|
doc = WebDoc.createPopup ("No Context");
|
||||||
|
doc.addPopupClose(wsc.ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
// PO Zoom ?
|
||||||
|
boolean isSOTrx = true;
|
||||||
|
if (PO_Window_ID != 0)
|
||||||
|
{
|
||||||
|
String whereClause = TableName + "_ID=" + AD_Record_ID;
|
||||||
|
isSOTrx = DB.isSOTrx(TableName, whereClause);
|
||||||
|
if (!isSOTrx)
|
||||||
|
AD_Window_ID = PO_Window_ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Clean up old Window
|
// Clean up old Window
|
||||||
WWindowStatus ws = WWindowStatus.get(request);
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
if (ws != null)
|
if (ws != null)
|
||||||
|
|
@ -151,15 +208,22 @@ public class WWindow extends HttpServlet
|
||||||
ws = new WWindowStatus(mWindowVO);
|
ws = new WWindowStatus(mWindowVO);
|
||||||
sess.setAttribute(WWindowStatus.NAME, ws);
|
sess.setAttribute(WWindowStatus.NAME, ws);
|
||||||
|
|
||||||
|
|
||||||
// Query
|
// Query
|
||||||
|
if (AD_Record_ID != 0 || AD_Table_ID != 0){ //If Zoom
|
||||||
|
ws.mWindow.initTab(ws.curTab.getTabNo());
|
||||||
|
ws.curTab.setQuery(MQuery.getEqualQuery(TableName + "_ID", AD_Record_ID));
|
||||||
|
ws.curTab.query(false);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ws.mWindow.initTab(ws.curTab.getTabNo());
|
||||||
ws.curTab.query(ws.mWindow.isTransaction());
|
ws.curTab.query(ws.mWindow.isTransaction());
|
||||||
ws.curTab.navigate(0);
|
ws.curTab.navigate(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build Page
|
* Build Page
|
||||||
*/
|
*/
|
||||||
WebDoc doc = null;
|
|
||||||
if (ws.curTab.isSingleRow())
|
if (ws.curTab.isSingleRow())
|
||||||
doc = getSR_Form (request.getRequestURI(), wsc, ws);
|
doc = getSR_Form (request.getRequestURI(), wsc, ws);
|
||||||
else
|
else
|
||||||
|
|
@ -168,7 +232,7 @@ public class WWindow extends HttpServlet
|
||||||
// fini
|
// fini
|
||||||
log.fine("Fini");
|
log.fine("Fini");
|
||||||
// log.trace(log.l6_Database, doc.toString());
|
// log.trace(log.l6_Database, doc.toString());
|
||||||
WebUtil.createResponse (request, response, this, null, doc, true);
|
WebUtil.createResponse (request, response, this, null, doc, false);
|
||||||
log.fine("Closed");
|
log.fine("Closed");
|
||||||
} // doGet
|
} // doGet
|
||||||
|
|
||||||
|
|
@ -233,7 +297,7 @@ public class WWindow extends HttpServlet
|
||||||
//
|
//
|
||||||
log.fine("Fini");
|
log.fine("Fini");
|
||||||
// log.trace(log.l6_Database, doc.toString());
|
// log.trace(log.l6_Database, doc.toString());
|
||||||
WebUtil.createResponse (request, response, this, null, doc, true);
|
WebUtil.createResponse (request, response, this, null, doc, false);
|
||||||
log.fine("Closed");
|
log.fine("Closed");
|
||||||
} // doPost
|
} // doPost
|
||||||
|
|
||||||
|
|
@ -288,9 +352,17 @@ public class WWindow extends HttpServlet
|
||||||
// move to detail
|
// move to detail
|
||||||
if (newTabNo > ws.curTab.getTabNo())
|
if (newTabNo > ws.curTab.getTabNo())
|
||||||
{
|
{
|
||||||
|
ws.mWindow.initTab(newTabNo);
|
||||||
ws.curTab = ws.mWindow.getTab(newTabNo);
|
ws.curTab = ws.mWindow.getTab(newTabNo);
|
||||||
ws.curTab.query(false);
|
ws.curTab.query(false);
|
||||||
ws.curTab.navigate(0);
|
ws.curTab.navigate(0);
|
||||||
|
|
||||||
|
//Modified by Rob Klein 6/01/07 create new record if no record exists
|
||||||
|
if (ws.curTab.getRowCount() < 1 ){
|
||||||
|
if (!ws.curTab.dataNew(false))
|
||||||
|
ws.curTab.dataIgnore();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// move back
|
// move back
|
||||||
else if (newTabNo < ws.curTab.getTabNo())
|
else if (newTabNo < ws.curTab.getTabNo())
|
||||||
|
|
@ -331,14 +403,12 @@ public class WWindow extends HttpServlet
|
||||||
{
|
{
|
||||||
ws.curTab.navigateRelative(999999);
|
ws.curTab.navigateRelative(999999);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find
|
* Find
|
||||||
*/
|
*/
|
||||||
else if (p_cmd.equals("Find"))
|
else if (p_cmd.equals("Test"))
|
||||||
{
|
{
|
||||||
/** @todo Find */
|
/** @todo Chat */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -357,16 +427,65 @@ public class WWindow extends HttpServlet
|
||||||
/** @todo Attachment */
|
/** @todo Attachment */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Favorite
|
||||||
|
*/
|
||||||
|
else if (p_cmd.equals("Favorite"))
|
||||||
|
{
|
||||||
|
int AD_Window_ID = ws.curTab.getAD_Window_ID();
|
||||||
|
String sqlNode = "SELECT AD_Menu_ID FROM AD_Menu WHERE"
|
||||||
|
+ " AD_Window_ID = "+AD_Window_ID;
|
||||||
|
int Node_ID = DB.getSQLValue(null,sqlNode);
|
||||||
|
|
||||||
|
|
||||||
|
int AD_User_ID = Env.getAD_User_ID(wsc.ctx);
|
||||||
|
int AD_Role_ID = Env.getAD_Role_ID(wsc.ctx);
|
||||||
|
int AD_Org_ID = Env.getAD_Org_ID(wsc.ctx);
|
||||||
|
int AD_Client_ID = Env.getAD_Client_ID(wsc.ctx);
|
||||||
|
int AD_Tree_ID = DB.getSQLValue(null,
|
||||||
|
"SELECT COALESCE(r.AD_Tree_Menu_ID, ci.AD_Tree_Menu_ID)"
|
||||||
|
+ "FROM AD_ClientInfo ci"
|
||||||
|
+ " INNER JOIN AD_Role r ON (ci.AD_Client_ID=r.AD_Client_ID) "
|
||||||
|
+ "WHERE AD_Role_ID=?", AD_Role_ID);
|
||||||
|
|
||||||
|
if (AD_Tree_ID <= 0)
|
||||||
|
AD_Tree_ID = 10; // Menu
|
||||||
|
|
||||||
|
String sql = "SELECT count(*) FROM AD_TreeBar WHERE"
|
||||||
|
+ " Node_ID = "+Node_ID
|
||||||
|
+ " AND CreatedBy = "+AD_User_ID
|
||||||
|
+ " AND AD_Tree_ID = "+AD_Tree_ID;
|
||||||
|
int Favorite = DB.getSQLValue(null,sql);
|
||||||
|
if (Favorite >0){
|
||||||
|
sql = "DELETE FROM AD_TreeBar WHERE"
|
||||||
|
+ " Node_ID = "+Node_ID
|
||||||
|
+ " AND CreatedBy = "+AD_User_ID
|
||||||
|
+ " AND AD_Tree_ID = "+AD_Tree_ID;
|
||||||
|
DB.executeUpdate(sql, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
sql = "INSERT INTO AD_TreeBar "
|
||||||
|
+ "( Node_ID, AD_User_ID, AD_Client_ID, AD_Org_ID,"
|
||||||
|
+ " IsActive, CreatedBy, AD_Tree_ID, UpdatedBy)"
|
||||||
|
+ "VALUES ( "+Node_ID+", "+AD_User_ID+", "+AD_Client_ID+", "+AD_Org_ID
|
||||||
|
+ ", 'Y', "+AD_User_ID+", "+AD_Tree_ID+", "+AD_User_ID+")";
|
||||||
|
DB.executeUpdate(sql, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* History
|
* History
|
||||||
*/
|
*/
|
||||||
else if (p_cmd.equals("History"))
|
else if (p_cmd.equals("History"))
|
||||||
{
|
{
|
||||||
if (ws.mWindow.isTransaction() && ws.curTab.getWindowNo() == 0)
|
//Modified by Rob Klein 4/29/07
|
||||||
{
|
//if (ws.mWindow.isTransaction() && ws.curTab.getWindowNo() == 0)
|
||||||
|
//{
|
||||||
|
ws.mWindow.initTab(ws.curTab.getTabNo());
|
||||||
ws.curTab.query( !ws.curTab.isOnlyCurrentRows() );
|
ws.curTab.query( !ws.curTab.isOnlyCurrentRows() );
|
||||||
ws.curTab.navigate(0);
|
ws.curTab.navigate(0);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -375,6 +494,7 @@ public class WWindow extends HttpServlet
|
||||||
else if (p_cmd.equals("Report"))
|
else if (p_cmd.equals("Report"))
|
||||||
{
|
{
|
||||||
/** @todo Report */
|
/** @todo Report */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -576,12 +696,23 @@ public class WWindow extends HttpServlet
|
||||||
*/
|
*/
|
||||||
private Object getFieldValue (WebSessionCtx wsc, GridField mField, String value)
|
private Object getFieldValue (WebSessionCtx wsc, GridField mField, String value)
|
||||||
{
|
{
|
||||||
if (value == null || value.length() == 0)
|
//Modified by Rob Klein 4/29/07
|
||||||
return null;
|
//if (value == null || value.length() == 0)
|
||||||
|
//return null;
|
||||||
|
|
||||||
|
Object defaultObject = null;
|
||||||
|
|
||||||
int dt = mField.getDisplayType();
|
int dt = mField.getDisplayType();
|
||||||
String columnName = mField.getColumnName();
|
String columnName = mField.getColumnName();
|
||||||
|
|
||||||
|
if (value == null || value.length() == 0){
|
||||||
|
defaultObject = mField.getDefault();
|
||||||
|
mField.setValue (defaultObject, true);
|
||||||
|
if (value == null || value.length() == 0 || mField.getValue() == null){
|
||||||
|
return null;}
|
||||||
|
else
|
||||||
|
value = mField.getValue().toString();
|
||||||
|
}
|
||||||
// BigDecimal
|
// BigDecimal
|
||||||
if (DisplayType.isNumeric(dt))
|
if (DisplayType.isNumeric(dt))
|
||||||
{
|
{
|
||||||
|
|
@ -674,19 +805,23 @@ public class WWindow extends HttpServlet
|
||||||
* @param ws window status
|
* @param ws window status
|
||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
private WebDoc getSR_Form (String action, WebSessionCtx wsc, WWindowStatus ws)
|
public WebDoc getSR_Form (String action, WebSessionCtx wsc, WWindowStatus ws)
|
||||||
{
|
{
|
||||||
log.fine("Tab=" + ws.curTab.getTabNo());
|
log.fine("Tab=" + ws.curTab.getTabNo());
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* For all Fields
|
* For all Fields
|
||||||
*/
|
*/
|
||||||
table table = new table()
|
//Modified by Rob Klein 4/29/07
|
||||||
.setAlign(AlignType.CENTER);
|
//table table = new table()
|
||||||
// table.setBorder(1).setBorderColor("#00FF00"); // debug field lines
|
// .setAlign(AlignType.CENTER);
|
||||||
|
table table = new table();
|
||||||
|
table.setClass("centerTable");
|
||||||
StringBuffer scriptSrc = new StringBuffer();
|
StringBuffer scriptSrc = new StringBuffer();
|
||||||
//
|
//
|
||||||
tr line = new tr();
|
tr line = new tr();
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
boolean isTabRO = ws.curTab.isReadOnly();
|
||||||
if (ws.curTab.isDisplayed())
|
if (ws.curTab.isDisplayed())
|
||||||
{
|
{
|
||||||
int noFields = ws.curTab.getFieldCount();
|
int noFields = ws.curTab.getFieldCount();
|
||||||
|
|
@ -699,6 +834,12 @@ public class WWindow extends HttpServlet
|
||||||
* Get Data and convert to String (singleRow)
|
* Get Data and convert to String (singleRow)
|
||||||
*/
|
*/
|
||||||
Object oData = ws.curTab.getValue(field);
|
Object oData = ws.curTab.getValue(field);
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
/**
|
||||||
|
* Get Record ID and Table ID for Processes
|
||||||
|
*/
|
||||||
|
int recordID = ws.curTab.getRecord_ID();
|
||||||
|
int tableID = ws.curTab.getAD_Table_ID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display field
|
* Display field
|
||||||
|
|
@ -709,7 +850,9 @@ public class WWindow extends HttpServlet
|
||||||
line = new tr();
|
line = new tr();
|
||||||
//
|
//
|
||||||
boolean hasDependents = ws.curTab.hasDependants(columnName);
|
boolean hasDependents = ws.curTab.hasDependants(columnName);
|
||||||
addField(wsc, line, field, oData, hasDependents);
|
//Modified by Rob Klein 4/29/07
|
||||||
|
addField(wsc, line, field, oData, hasDependents, recordID, tableID, isTabRO, i, ws.curTab);
|
||||||
|
//addField(wsc, line, field, oData, hasDependents);
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
// Additional Values
|
// Additional Values
|
||||||
String dispLogic = field.getDisplayLogic();
|
String dispLogic = field.getDisplayLogic();
|
||||||
|
|
@ -741,7 +884,7 @@ public class WWindow extends HttpServlet
|
||||||
* @param ws window status
|
* @param ws window status
|
||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
private WebDoc getMR_Form (String action, WebSessionCtx wsc, WWindowStatus ws)
|
public WebDoc getMR_Form (String action, WebSessionCtx wsc, WWindowStatus ws)
|
||||||
{
|
{
|
||||||
log.fine("Tab=" + ws.curTab.getTabNo());
|
log.fine("Tab=" + ws.curTab.getTabNo());
|
||||||
|
|
||||||
|
|
@ -751,11 +894,15 @@ public class WWindow extends HttpServlet
|
||||||
* Table Header
|
* Table Header
|
||||||
*/
|
*/
|
||||||
table table = new table().setAlign(AlignType.CENTER);
|
table table = new table().setAlign(AlignType.CENTER);
|
||||||
table.setClass("MultiRow");
|
//Modified by Rob Klein 4/29/07
|
||||||
|
table.setClass("MultiRow table-autofilter table-filterable table-autosort table-autostripe table-stripeclass:alternate");
|
||||||
|
//.setClass("MultiRow");
|
||||||
table.setBorder(1);
|
table.setBorder(1);
|
||||||
table.setCellSpacing(1);
|
table.setCellSpacing(1);
|
||||||
tr line = new tr();
|
tr line = new tr();
|
||||||
// First Column
|
// First Column
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
//line.addElement(new th().addElement(" "));
|
||||||
line.addElement(new th().addElement(" "));
|
line.addElement(new th().addElement(" "));
|
||||||
// Tab not displayed
|
// Tab not displayed
|
||||||
if (!ws.curTab.isDisplayed())
|
if (!ws.curTab.isDisplayed())
|
||||||
|
|
@ -769,13 +916,39 @@ public class WWindow extends HttpServlet
|
||||||
if (field.isDisplayed(false))
|
if (field.isDisplayed(false))
|
||||||
{
|
{
|
||||||
th th = new th();
|
th th = new th();
|
||||||
th.addElement(field.getHeader()); // Name
|
//Modified by Rob Klein 4/29/07 with Autofilter
|
||||||
th.setAbbr(field.getDescription()); // Description
|
th.addElement(field.getHeader()).setClass("table-filterable table-filtered table-sortable:default");
|
||||||
|
//th.addElement(field.getHeader());
|
||||||
|
th.setAbbr(field.getDescription());
|
||||||
line.addElement(th);
|
line.addElement(th);
|
||||||
}
|
}
|
||||||
} // for all columns
|
} // for all columns
|
||||||
table.addElement(new thead().addElement(line));
|
// Modified by Rob Klein Client Side Filter Manual Filter 6/1/07
|
||||||
|
tr line2 = new tr();
|
||||||
|
th th = new th();
|
||||||
|
//input filter = new input (input.TYPE_TEXT, " filter", "");
|
||||||
|
//filter.setOnKeyUp("Table.filter(this,this)");
|
||||||
|
th.addElement(" ");
|
||||||
|
line2.addElement(th);
|
||||||
|
input filter = null;
|
||||||
|
for (int colNo = 0; colNo < noFields; colNo++)
|
||||||
|
{
|
||||||
|
GridField field = ws.curTab.getField(colNo);
|
||||||
|
if (field.isDisplayed(false))
|
||||||
|
{
|
||||||
|
th = new th();
|
||||||
|
filter = new input (input.TYPE_TEXT, field.getHeader()+"filter", "");
|
||||||
|
filter.setOnKeyUp("Table.filter(this,this)");
|
||||||
|
th.addElement(filter);
|
||||||
|
line2.addElement(th);
|
||||||
|
//line.addElement(th);
|
||||||
|
}
|
||||||
|
} // for all columns
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
table.addElement(new thead().addElement(line).addElement(line2));
|
||||||
|
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
table.addElement("<TBODY>");
|
||||||
/**
|
/**
|
||||||
* Table Lines
|
* Table Lines
|
||||||
*/
|
*/
|
||||||
|
|
@ -858,8 +1031,10 @@ public class WWindow extends HttpServlet
|
||||||
line.addElement(td);
|
line.addElement(td);
|
||||||
} // for all columns
|
} // for all columns
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
} // for all table lines
|
|
||||||
|
|
||||||
|
} // for all table lines
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
table.addElement("</TBODY>");
|
||||||
// Status Line
|
// Status Line
|
||||||
String statusDB = String.valueOf(initRowNo+1) + "-" + String.valueOf(lastRow) + " # " + ws.curTab.getRowCount();
|
String statusDB = String.valueOf(initRowNo+1) + "-" + String.valueOf(lastRow) + " # " + ws.curTab.getRowCount();
|
||||||
|
|
||||||
|
|
@ -876,7 +1051,7 @@ public class WWindow extends HttpServlet
|
||||||
* @param statusDB status db info
|
* @param statusDB status db info
|
||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
private static WebDoc createLayout (String action, table contentTable,
|
private WebDoc createLayout (String action, table contentTable,
|
||||||
WebSessionCtx wsc, WWindowStatus ws, String statusInfo, String statusDB)
|
WebSessionCtx wsc, WWindowStatus ws, String statusInfo, String statusDB)
|
||||||
{
|
{
|
||||||
form myForm = null;
|
form myForm = null;
|
||||||
|
|
@ -893,43 +1068,43 @@ public class WWindow extends HttpServlet
|
||||||
// Set Title of main window
|
// Set Title of main window
|
||||||
String title = ws.mWindow.getName() + " - " + wsc.loginInfo;
|
String title = ws.mWindow.getName() + " - " + wsc.loginInfo;
|
||||||
myForm.addElement(new script("top.document.title='" + title + "';"));
|
myForm.addElement(new script("top.document.title='" + title + "';"));
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
// Buttons
|
// Buttons
|
||||||
td toolbar = new td(null, AlignType.LEFT, AlignType.MIDDLE, true);
|
td toolbar = new td("toolbar", AlignType.LEFT, AlignType.MIDDLE, true);
|
||||||
// Toolbar
|
// Toolbar
|
||||||
toolbar.addElement(createImage(AD_Language, "Ignore",
|
toolbar.addElement(createImageLink (AD_Language, "Menu",
|
||||||
"reset();", true, false));
|
"parent.resizeFrame('5,*')",
|
||||||
toolbar.addElement(" ");
|
|
||||||
toolbar.addElement(createImage(AD_Language, "Help",
|
|
||||||
"startPopup('WHelp?AD_Window_ID=" + ws.mWindow.getAD_Window_ID() + "');",
|
|
||||||
true, false));
|
true, false));
|
||||||
toolbar.addElement(createImage(AD_Language, "New"));
|
toolbar.addElement(createImageLink (AD_Language, "Ignore",
|
||||||
toolbar.addElement(createImage(AD_Language, "Delete",
|
"'reset'", true, false));
|
||||||
"if (confirm(deleteText)) submit();", true, false));
|
|
||||||
toolbar.addElement(createImage(AD_Language, "Save"));
|
|
||||||
toolbar.addElement(" ");
|
toolbar.addElement(" ");
|
||||||
toolbar.addElement(createImage(AD_Language, "Find"));
|
toolbar.addElement(createImageLink (AD_Language, "Help",
|
||||||
toolbar.addElement(createImage(AD_Language, "Refresh"));
|
"startPopup('WHelp?AD_Window_ID=" + ws.mWindow.getAD_Window_ID() + "')",
|
||||||
toolbar.addElement(createImage(AD_Language, "Attachment",
|
true, false));
|
||||||
"startPopup('WAttachment');",
|
toolbar.addElement(createImageLink (AD_Language, "New"));
|
||||||
ws.curTab.canHaveAttachment(), ws.curTab.hasAttachment()));
|
toolbar.addElement(createImageLink (AD_Language, "Delete","'if(confirm(deleteText))'", true, false));
|
||||||
toolbar.addElement(createImage(AD_Language, "Multi", null, true, !ws.curTab.isSingleRow()));
|
toolbar.addElement(createImageLink (AD_Language, "Save"));
|
||||||
toolbar.addElement(" ");
|
toolbar.addElement(" ");
|
||||||
toolbar.addElement(createImage(AD_Language, "History",
|
toolbar.addElement(createImageLink (AD_Language, "Chat","startPopup('WChat')", true, false));
|
||||||
|
toolbar.addElement(createImageLink (AD_Language, "Refresh"));
|
||||||
|
toolbar.addElement(createImageLink (AD_Language, "Attachment",
|
||||||
|
"startPopup('WAttachment')", ws.curTab.canHaveAttachment(), ws.curTab.hasAttachment()));
|
||||||
|
toolbar.addElement(createImageLink (AD_Language, "Multi", null, true, !ws.curTab.isSingleRow()));
|
||||||
|
toolbar.addElement(" ");
|
||||||
|
toolbar.addElement(createImageLink (AD_Language, "History",
|
||||||
null, ws.mWindow.isTransaction()&&ws.curTab.getTabNo()==0, !ws.curTab.isOnlyCurrentRows()));
|
null, ws.mWindow.isTransaction()&&ws.curTab.getTabNo()==0, !ws.curTab.isOnlyCurrentRows()));
|
||||||
toolbar.addElement(" ");
|
toolbar.addElement(" ");
|
||||||
boolean isFirst = ws.curTab.getCurrentRow() < 1;
|
boolean isFirst = ws.curTab.getCurrentRow() < 1;
|
||||||
toolbar.addElement(createImage(AD_Language, "First", null, !isFirst, false));
|
toolbar.addElement(createImageLink (AD_Language, "First", null, !isFirst, false));
|
||||||
toolbar.addElement(createImage(AD_Language, "Previous", null, !isFirst, false));
|
toolbar.addElement(createImageLink (AD_Language, "Previous", null, !isFirst, false));
|
||||||
boolean isLast = ws.curTab.getCurrentRow()+1 == ws.curTab.getRowCount();
|
boolean isLast = ws.curTab.getCurrentRow()+1 == ws.curTab.getRowCount();
|
||||||
toolbar.addElement(createImage(AD_Language, "Next", null, !isLast, false));
|
toolbar.addElement(createImageLink (AD_Language, "Next", null, !isLast, false));
|
||||||
toolbar.addElement(createImage(AD_Language, "Last", null, !isLast, false));
|
toolbar.addElement(createImageLink (AD_Language, "Last", null, !isLast, false));
|
||||||
toolbar.addElement(" ");
|
toolbar.addElement(" ");
|
||||||
toolbar.addElement(createImage(AD_Language, "Report"));
|
toolbar.addElement(createImageLink (AD_Language, "Report","startPopup('WReport')", true, false));
|
||||||
toolbar.addElement(createImage(AD_Language, "Print"));
|
|
||||||
toolbar.addElement(" ");
|
toolbar.addElement(" ");
|
||||||
toolbar.addElement(createImage(AD_Language, "Exit"));
|
toolbar.addElement(createImageLink (AD_Language, "Favorite"));
|
||||||
|
toolbar.addElement(createImageLink (AD_Language, "Exit"));
|
||||||
// Tabs
|
// Tabs
|
||||||
td tabbar = new td("windowCenter", AlignType.LEFT, AlignType.MIDDLE, false);
|
td tabbar = new td("windowCenter", AlignType.LEFT, AlignType.MIDDLE, false);
|
||||||
tabbar.addElement(new input(input.TYPE_HIDDEN, P_Tab, ""));
|
tabbar.addElement(new input(input.TYPE_HIDDEN, P_Tab, ""));
|
||||||
|
|
@ -938,23 +1113,26 @@ public class WWindow extends HttpServlet
|
||||||
GridTab tab = ws.mWindow.getTab(i);
|
GridTab tab = ws.mWindow.getTab(i);
|
||||||
if (tab.isSortTab())
|
if (tab.isSortTab())
|
||||||
continue;
|
continue;
|
||||||
big big = new big(tab.getName());
|
//Modified by Rob Klein 4/29/07
|
||||||
|
a big = new a("#",new span(tab.getName()));
|
||||||
if (ws.curTab.getTabNo() == i)
|
if (ws.curTab.getTabNo() == i)
|
||||||
big.setID("tabSelected"); // css
|
big.setID("tabSelected"); // css
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
big.setID("tab"); // css
|
big.setID("tab"); // css
|
||||||
big.setOnClick("alert('" + tab.getName() + "');");
|
big.setOnClick( "SubmitForm(" + i + ",'Submit','tab')");
|
||||||
big.setOnClick("document." + FORM_NAME + "." + P_Tab + ".value='" + i + "';submit();");
|
|
||||||
}
|
}
|
||||||
// Status: Description
|
// Status: Description
|
||||||
if (tab.getDescription().length() > 0)
|
if (tab.getDescription().length() > 0)
|
||||||
big.setOnMouseOver("status='" + tab.getDescription() + "';return true;");
|
big.setOnMouseOver("status='" + tab.getDescription() + "';return true;");
|
||||||
|
|
||||||
tabbar.addElement(big);
|
tabbar.addElement(big);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top Table
|
// Top Table
|
||||||
table topTable = new table ("0", "0", "5", "100%", null);
|
//Modified by Rob Klein 4/29/07
|
||||||
|
table topTable = new table ("0", "0", "0", "100%", null);
|
||||||
topTable.setID("WWindow.topTable");
|
topTable.setID("WWindow.topTable");
|
||||||
topTable.addElement(new tr(toolbar));
|
topTable.addElement(new tr(toolbar));
|
||||||
topTable.addElement(new tr(tabbar));
|
topTable.addElement(new tr(tabbar));
|
||||||
|
|
@ -972,10 +1150,18 @@ public class WWindow extends HttpServlet
|
||||||
statusLine.addElement(new td().setWidth("10%").setAlign(AlignType.RIGHT)
|
statusLine.addElement(new td().setWidth("10%").setAlign(AlignType.RIGHT)
|
||||||
.addElement(new small(statusDB)));
|
.addElement(new small(statusDB)));
|
||||||
statusLine.addElement(new td().setWidth("5%").setAlign(AlignType.RIGHT)
|
statusLine.addElement(new td().setWidth("5%").setAlign(AlignType.RIGHT)
|
||||||
.addElement(createImage(AD_Language, "Save")));
|
//Modified by Rob Klein 4/29/07
|
||||||
|
.addElement(createImageLink (AD_Language, "Save")));
|
||||||
statusTable.addElement(statusLine).setClass("windowCenter");
|
statusTable.addElement(statusLine).setClass("windowCenter");
|
||||||
myForm.addElement(statusTable);
|
myForm.addElement(statusTable);
|
||||||
|
|
||||||
|
//Beg Modified by Rob Klein
|
||||||
|
//div calpopdiv = new div();
|
||||||
|
//calpopdiv.setStyle("visibility:hidden;background-color:white;layer-background-color:white;");
|
||||||
|
//calpopdiv.setID("cal1div");
|
||||||
|
//myForm.addElement(calpopdiv);
|
||||||
|
//End Modified by Rob Klein
|
||||||
|
|
||||||
// fini
|
// fini
|
||||||
/** @todo Dynamic Display */
|
/** @todo Dynamic Display */
|
||||||
// myForm.addElement(new script("dynDisplay(); createWCmd();")); // initial Display & set Cmd Window
|
// myForm.addElement(new script("dynDisplay(); createWCmd();")); // initial Display & set Cmd Window
|
||||||
|
|
@ -1007,7 +1193,7 @@ public class WWindow extends HttpServlet
|
||||||
} // createPage
|
} // createPage
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Create Image with name, id of button_name and set P_Command onClick
|
* Create Image with name, id of button_name and set P_Command onClick
|
||||||
* @param AD_Language
|
* @param AD_Language
|
||||||
* @param name Name of the Image used also for Name24.gif
|
* @param name Name of the Image used also for Name24.gif
|
||||||
|
|
@ -1023,7 +1209,7 @@ public class WWindow extends HttpServlet
|
||||||
imgName.append("D");
|
imgName.append("D");
|
||||||
else if (pressed)
|
else if (pressed)
|
||||||
imgName.append("X");
|
imgName.append("X");
|
||||||
imgName.append("24.gif");
|
imgName.append("16.gif");
|
||||||
//
|
//
|
||||||
img img = new img (WebEnv.getImageDirectory(imgName.toString()), name);
|
img img = new img (WebEnv.getImageDirectory(imgName.toString()), name);
|
||||||
if (enabled)
|
if (enabled)
|
||||||
|
|
@ -1033,11 +1219,11 @@ public class WWindow extends HttpServlet
|
||||||
img.setID("imgButton"); // css
|
img.setID("imgButton"); // css
|
||||||
else
|
else
|
||||||
img.setID("imgButtonPressed"); // css
|
img.setID("imgButtonPressed"); // css
|
||||||
|
img.setHeight(16);
|
||||||
|
img.setWidth(16);
|
||||||
|
img.setBorder(0);
|
||||||
|
img.setTitle(name);
|
||||||
//
|
//
|
||||||
if (js_command == null)
|
|
||||||
js_command = "submit();";
|
|
||||||
if (js_command.length() > 0 && enabled)
|
|
||||||
img.setOnClick("document." + FORM_NAME + "." + P_Command + ".value='" + name + "';" + js_command);
|
|
||||||
//
|
//
|
||||||
return img;
|
return img;
|
||||||
} // createImage
|
} // createImage
|
||||||
|
|
@ -1054,6 +1240,50 @@ public class WWindow extends HttpServlet
|
||||||
} // createImage
|
} // createImage
|
||||||
|
|
||||||
|
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Create Image with name, id of button_name and set P_Command onClick
|
||||||
|
* @param AD_Language
|
||||||
|
* @param name Name of the Image used also for Name24.gif
|
||||||
|
* @param js_command Java script command, null results in 'submit();', an empty string disables OnClick
|
||||||
|
* @param enabled Enable the immage button, if not uses the "D" image
|
||||||
|
* @param pressed If true, use the "X" image
|
||||||
|
* @return Image
|
||||||
|
*/
|
||||||
|
private static a createImageLink (String AD_Language, String name, String js_command, boolean enabled, boolean pressed)
|
||||||
|
{
|
||||||
|
|
||||||
|
a img = new a ("#", createImage (AD_Language, name));
|
||||||
|
|
||||||
|
if (!pressed || !enabled)
|
||||||
|
img.setID("imgButtonLink"); // css
|
||||||
|
else
|
||||||
|
img.setID("imgButtonPressedLink"); // css
|
||||||
|
//
|
||||||
|
if (js_command == null)
|
||||||
|
js_command = "'Submit'";
|
||||||
|
if (js_command.length() > 0 && enabled)
|
||||||
|
img.setOnClick( "SubmitForm('" + name + "', " + js_command + ",'toolbar');return false;");
|
||||||
|
img.setClass("ToolbarButton");
|
||||||
|
img.setOnMouseOver("window.status='"+name+"';return true;");
|
||||||
|
img.setOnMouseOut("window.status='';return true;");
|
||||||
|
img.setOnBlur("this.hideFocus=false");
|
||||||
|
//
|
||||||
|
return img;
|
||||||
|
} // createImageLink
|
||||||
|
/**
|
||||||
|
* Create enabled Image with name, id of button_name and sumbit command
|
||||||
|
* @param AD_Language
|
||||||
|
* @param name Name of the Image used also for Name24.gif
|
||||||
|
* @return Image
|
||||||
|
*/
|
||||||
|
private static a createImageLink (String AD_Language, String name)
|
||||||
|
{
|
||||||
|
return createImageLink (AD_Language, name, null, true, false);
|
||||||
|
} // createImageLink
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Add Field to Line
|
* Add Field to Line
|
||||||
* @param wsc session context
|
* @param wsc session context
|
||||||
|
|
@ -1063,7 +1293,8 @@ public class WWindow extends HttpServlet
|
||||||
* @param hasDependents has Callout function(s)
|
* @param hasDependents has Callout function(s)
|
||||||
*/
|
*/
|
||||||
private void addField (WebSessionCtx wsc, tr line, GridField field,
|
private void addField (WebSessionCtx wsc, tr line, GridField field,
|
||||||
Object oData, boolean hasDependents)
|
Object oData, boolean hasDependents, int recordID, int tableID, boolean tabRO, int fieldNumber,
|
||||||
|
GridTab mTab)
|
||||||
{
|
{
|
||||||
String columnName = field.getColumnName();
|
String columnName = field.getColumnName();
|
||||||
// Any Error?
|
// Any Error?
|
||||||
|
|
@ -1072,6 +1303,30 @@ public class WWindow extends HttpServlet
|
||||||
oData = field.getErrorValue();
|
oData = field.getErrorValue();
|
||||||
int dt = field.getDisplayType();
|
int dt = field.getDisplayType();
|
||||||
boolean hasCallout = field.getCallout().length() > 0;
|
boolean hasCallout = field.getCallout().length() > 0;
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
if(!field.getFieldGroup().equals(sectionNameOld)&&!field.getFieldGroup().equals("")&&field.getFieldGroup()!=null)
|
||||||
|
{
|
||||||
|
log.fine("Fieldgroup=" + field.getFieldGroup()+".");
|
||||||
|
td td1 = new td();
|
||||||
|
td1.setClass("Fieldgroup");
|
||||||
|
td1.addElement(field.getFieldGroup());
|
||||||
|
td td2 = new td().setColSpan(4);
|
||||||
|
td2.setClass("Fieldgroup");
|
||||||
|
td2.addElement(new hr().setWidth("100%"));
|
||||||
|
line.addElement( new tr().addElement(td1));
|
||||||
|
line.addElement( new tr().addElement(td2));
|
||||||
|
|
||||||
|
sectionNameOld = field.getFieldGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set read only value
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
boolean fieldRO = true;
|
||||||
|
if (tabRO==true)
|
||||||
|
fieldRO = true;
|
||||||
|
else
|
||||||
|
fieldRO = !field.isEditable(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTML Label Element
|
* HTML Label Element
|
||||||
|
|
@ -1085,12 +1340,16 @@ public class WWindow extends HttpServlet
|
||||||
columnName, field.getHeader(), field.getDescription(),
|
columnName, field.getHeader(), field.getDescription(),
|
||||||
dt, field.getFieldLength(), field.getDisplayLength(), field.isLongField(),
|
dt, field.getFieldLength(), field.getDisplayLength(), field.isLongField(),
|
||||||
// readOnly context check, mandatory no context check,
|
// readOnly context check, mandatory no context check,
|
||||||
!field.isEditable(true), field.isMandatory(false), error,
|
//Modified by Rob Klein 4/29/07
|
||||||
hasDependents, hasCallout);
|
//!field.isEditable(true), field.isMandatory(false), error,
|
||||||
|
fieldRO, field.isMandatory(false), error,
|
||||||
|
hasDependents, hasCallout,field.getAD_Process_ID(),field.getAD_Window_ID(),
|
||||||
|
recordID, tableID, fieldNumber, field.getDefault(), field.getCallout(),
|
||||||
|
mTab, field );
|
||||||
line
|
line
|
||||||
.addElement(wField.getLabel())
|
.addElement(wField.getLabel())
|
||||||
.addElement(wField.getField(field.getLookup(), oData));
|
.addElement(wField.getField(field.getLookup(), oData));
|
||||||
} // addField
|
} // addField
|
||||||
|
|
||||||
|
|
||||||
} // WWindow
|
} // WWindow
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,227 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* 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. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.www;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.servlet.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
|
||||||
|
import org.apache.ecs.*;
|
||||||
|
import org.apache.ecs.xhtml.*;
|
||||||
|
import org.compiere.apps.AEnv;
|
||||||
|
import org.compiere.apps.AWindow;
|
||||||
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTML Zoom Window
|
||||||
|
*
|
||||||
|
* @author Rob Klein
|
||||||
|
* @version $Id: WZoom.java $
|
||||||
|
*/
|
||||||
|
public class WZoom extends HttpServlet
|
||||||
|
{
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger log = CLogger.getCLogger(WAttachment.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize global variables
|
||||||
|
*/
|
||||||
|
public void init(ServletConfig config)
|
||||||
|
throws ServletException
|
||||||
|
{
|
||||||
|
super.init(config);
|
||||||
|
if (!WebEnv.initWeb(config))
|
||||||
|
throw new ServletException("WZoom.init");
|
||||||
|
} // init
|
||||||
|
|
||||||
|
public static final String P_Record_ID = "AD_Record_ID";
|
||||||
|
public static final String P_Table_ID = "AD_Table_ID";
|
||||||
|
private static int s_WindowNo = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the HTTP Get request.
|
||||||
|
* Initial display and streaming
|
||||||
|
* @param request request
|
||||||
|
* @param response response
|
||||||
|
*/
|
||||||
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException
|
||||||
|
{
|
||||||
|
log.info("From " + request.getRemoteHost() + " - " + request.getRemoteAddr());
|
||||||
|
HttpSession session = request.getSession(false);
|
||||||
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
|
WebDoc doc = null;
|
||||||
|
if (session == null || ws == null)
|
||||||
|
{
|
||||||
|
doc = WebDoc.createPopup ("No Context");
|
||||||
|
doc.addPopupClose(ws.ctx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String error = null;
|
||||||
|
int AD_Record_ID = WebUtil.getParameterAsInt(request, P_Record_ID);
|
||||||
|
int AD_Table_ID = WebUtil.getParameterAsInt(request, P_Table_ID);
|
||||||
|
if (AD_Record_ID == 0 || AD_Table_ID == 0)
|
||||||
|
{
|
||||||
|
doc = WebDoc.createPopup ("Invalid Record ID or Table ID");
|
||||||
|
doc.addPopupClose(ws.ctx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
doc = createPage (ws.ctx, request,AD_Record_ID,
|
||||||
|
AD_Table_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
|
} // doGet
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the HTTP Post request.
|
||||||
|
* Update Attachment
|
||||||
|
* @param request request
|
||||||
|
* @parem response response
|
||||||
|
*/
|
||||||
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException
|
||||||
|
{
|
||||||
|
|
||||||
|
HttpSession sess = request.getSession(false);
|
||||||
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
|
WebDoc doc = null;
|
||||||
|
//
|
||||||
|
doc = WebDoc.create ("Help - Post Not Implemented");
|
||||||
|
//
|
||||||
|
WebUtil.createResponse(request, response, this, null, doc, false);
|
||||||
|
} // doPost
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Attachment Page
|
||||||
|
* @param ctx context
|
||||||
|
* @param AD_Attachment_ID id for existing attachment
|
||||||
|
* @param AD_Table_ID table for new attachment
|
||||||
|
* @param Record_ID record for new attachment
|
||||||
|
* @param error optional error message
|
||||||
|
* @return WebDoc
|
||||||
|
*/
|
||||||
|
public static WebDoc createPage (Properties ctx, HttpServletRequest request, int AD_Record_ID,
|
||||||
|
int AD_Table_ID)
|
||||||
|
{
|
||||||
|
|
||||||
|
//WebDoc doc = WebDoc.createPopup (Msg.translate(ctx, "AD_Attachment_ID"));
|
||||||
|
WebDoc doc = null;
|
||||||
|
String TableName = null;
|
||||||
|
int AD_Window_ID = 0;
|
||||||
|
int PO_Window_ID = 0;
|
||||||
|
String sql = "SELECT TableName, AD_Window_ID, PO_Window_ID FROM AD_Table WHERE AD_Table_ID=?";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||||
|
pstmt.setInt(1, AD_Table_ID);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
{
|
||||||
|
TableName = rs.getString(1);
|
||||||
|
AD_Window_ID = rs.getInt(2);
|
||||||
|
PO_Window_ID = rs.getInt(3);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TableName == null || AD_Window_ID == 0){
|
||||||
|
doc = WebDoc.createPopup ("No Context");
|
||||||
|
doc.addPopupClose(ctx);
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PO Zoom ?
|
||||||
|
boolean isSOTrx = true;
|
||||||
|
if (PO_Window_ID != 0)
|
||||||
|
{
|
||||||
|
String whereClause = TableName + "_ID=" + AD_Record_ID;
|
||||||
|
isSOTrx = DB.isSOTrx(TableName, whereClause);
|
||||||
|
if (!isSOTrx)
|
||||||
|
AD_Window_ID = PO_Window_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New Window data
|
||||||
|
*/
|
||||||
|
WWindowStatus ws = WWindowStatus.get(request);
|
||||||
|
HttpSession sess = request.getSession();
|
||||||
|
WebSessionCtx wsc = WebSessionCtx.get(request);
|
||||||
|
|
||||||
|
if (ws != null)
|
||||||
|
{
|
||||||
|
int WindowNo = ws.mWindow.getWindowNo();
|
||||||
|
log.fine("Disposing - WindowNo=" + WindowNo + ", ID=" + ws.mWindow.getAD_Window_ID());
|
||||||
|
ws.mWindow.dispose();
|
||||||
|
Env.clearWinContext(wsc.ctx, WindowNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
GridWindowVO mWindowVO = GridWindowVO.create (ctx, s_WindowNo++, AD_Window_ID, 0);
|
||||||
|
|
||||||
|
if (mWindowVO == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
String msg = Msg.translate(ctx, "AD_Window_ID") + " "
|
||||||
|
+ Msg.getMsg(ctx, "NotFound") + ", ID=" + AD_Window_ID + "/" + 0;
|
||||||
|
doc = WebDoc.createPopup (msg);
|
||||||
|
doc.addPopupClose(ctx);
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create New Window
|
||||||
|
ws = new WWindowStatus(mWindowVO);
|
||||||
|
sess.setAttribute(WWindowStatus.NAME, ws);
|
||||||
|
|
||||||
|
// Query
|
||||||
|
|
||||||
|
ws.mWindow.initTab(ws.curTab.getTabNo());
|
||||||
|
ws.curTab.setQuery(MQuery.getEqualQuery(TableName + "_ID", AD_Record_ID));
|
||||||
|
ws.curTab.query(false);
|
||||||
|
|
||||||
|
//ws.curTab.navigate(0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build Page
|
||||||
|
*/
|
||||||
|
|
||||||
|
//doc = WWindow.getSR_Form (request.getRequestURI(), wsc, ws);
|
||||||
|
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
} // createPage
|
||||||
|
|
||||||
|
|
||||||
|
} // WZoom
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.www;
|
package org.compiere.www;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.logging.*;
|
||||||
import org.apache.ecs.*;
|
import org.apache.ecs.*;
|
||||||
import org.apache.ecs.xhtml.*;
|
import org.apache.ecs.xhtml.*;
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
|
|
@ -29,6 +31,7 @@ import org.compiere.util.*;
|
||||||
*/
|
*/
|
||||||
public class WebField
|
public class WebField
|
||||||
{
|
{
|
||||||
|
protected static CLogger log = CLogger.getCLogger(WWindow.class);
|
||||||
/**
|
/**
|
||||||
* Web Field
|
* Web Field
|
||||||
* @param wsc session context
|
* @param wsc session context
|
||||||
|
|
@ -49,7 +52,9 @@ public class WebField
|
||||||
String columnName, String name, String description,
|
String columnName, String name, String description,
|
||||||
int displayType, int fieldLength, int displayLength, boolean longField,
|
int displayType, int fieldLength, int displayLength, boolean longField,
|
||||||
boolean readOnly, boolean mandatory, boolean error,
|
boolean readOnly, boolean mandatory, boolean error,
|
||||||
boolean hasDependents, boolean hasCallout)
|
boolean hasDependents, boolean hasCallout, int AD_Process_ID,
|
||||||
|
int AD_Window_ID, int AD_Record_ID, int AD_Table_ID, int fieldNumber, Object defaultvalue,
|
||||||
|
String callOut, GridTab mTab, GridField mField )
|
||||||
{
|
{
|
||||||
super ();
|
super ();
|
||||||
m_wsc = wsc;
|
m_wsc = wsc;
|
||||||
|
|
@ -61,7 +66,12 @@ public class WebField
|
||||||
if (description != null && description.length() > 0)
|
if (description != null && description.length() > 0)
|
||||||
m_description = description;
|
m_description = description;
|
||||||
//
|
//
|
||||||
|
m_defaultObject = defaultvalue;
|
||||||
m_displayType = displayType;
|
m_displayType = displayType;
|
||||||
|
m_processID = AD_Process_ID;
|
||||||
|
m_windowID = AD_Window_ID;
|
||||||
|
m_tableID = AD_Table_ID;
|
||||||
|
m_recordID = AD_Record_ID;
|
||||||
m_fieldLength = fieldLength;
|
m_fieldLength = fieldLength;
|
||||||
m_displayLength = displayLength;
|
m_displayLength = displayLength;
|
||||||
if (m_displayLength == 0)
|
if (m_displayLength == 0)
|
||||||
|
|
@ -73,6 +83,11 @@ public class WebField
|
||||||
m_error = error;
|
m_error = error;
|
||||||
m_hasDependents = hasDependents;
|
m_hasDependents = hasDependents;
|
||||||
m_hasCallout = hasCallout;
|
m_hasCallout = hasCallout;
|
||||||
|
m_callOut = callOut;
|
||||||
|
m_fieldNumber = fieldNumber;
|
||||||
|
m_Tab = mTab;
|
||||||
|
m_Field = mField;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
} // WebField
|
} // WebField
|
||||||
|
|
@ -88,8 +103,16 @@ public class WebField
|
||||||
private String m_columnName;
|
private String m_columnName;
|
||||||
private String m_name;
|
private String m_name;
|
||||||
private String m_description;
|
private String m_description;
|
||||||
|
private String m_callOut;
|
||||||
|
private GridTab m_Tab;
|
||||||
|
private GridField m_Field;
|
||||||
//
|
//
|
||||||
|
private Object m_defaultObject;
|
||||||
private int m_displayType;
|
private int m_displayType;
|
||||||
|
private int m_processID;
|
||||||
|
private int m_windowID;
|
||||||
|
private int m_tableID;
|
||||||
|
private int m_recordID;
|
||||||
private int m_fieldLength;
|
private int m_fieldLength;
|
||||||
private int m_displayLength;
|
private int m_displayLength;
|
||||||
private boolean m_longField;
|
private boolean m_longField;
|
||||||
|
|
@ -99,6 +122,8 @@ public class WebField
|
||||||
private boolean m_error;
|
private boolean m_error;
|
||||||
private boolean m_hasDependents;
|
private boolean m_hasDependents;
|
||||||
private boolean m_hasCallout;
|
private boolean m_hasCallout;
|
||||||
|
private int m_fieldNumber;
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the field Label
|
* Get the field Label
|
||||||
|
|
@ -106,7 +131,7 @@ public class WebField
|
||||||
*/
|
*/
|
||||||
public td getLabel()
|
public td getLabel()
|
||||||
{
|
{
|
||||||
if (m_displayType == DisplayType.YesNo)
|
if (m_displayType == DisplayType.YesNo||m_displayType == DisplayType.Button)
|
||||||
return new td(WebEnv.NBSP);
|
return new td(WebEnv.NBSP);
|
||||||
//
|
//
|
||||||
label myLabel = new label(m_columnName + "F", null, Util.maskHTML(m_name));
|
label myLabel = new label(m_columnName + "F", null, Util.maskHTML(m_name));
|
||||||
|
|
@ -146,11 +171,13 @@ public class WebField
|
||||||
*/
|
*/
|
||||||
public td getField (Lookup lookup, Object data)
|
public td getField (Lookup lookup, Object data)
|
||||||
{
|
{
|
||||||
|
|
||||||
String dataValue = (data == null) ? "" : data.toString();
|
String dataValue = (data == null) ? "" : data.toString();
|
||||||
//
|
//
|
||||||
if (m_displayType == DisplayType.Search
|
if (m_displayType == DisplayType.Search
|
||||||
|| m_displayType == DisplayType.Location
|
|| m_displayType == DisplayType.Location
|
||||||
|| m_displayType == DisplayType.Account)
|
|| m_displayType == DisplayType.Account
|
||||||
|
|| m_displayType == DisplayType.PAttribute)
|
||||||
{
|
{
|
||||||
String dataDisplay = "";
|
String dataDisplay = "";
|
||||||
if (lookup != null && data != null)
|
if (lookup != null && data != null)
|
||||||
|
|
@ -159,27 +186,41 @@ public class WebField
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DisplayType.isLookup(m_displayType)
|
if (DisplayType.isLookup(m_displayType)
|
||||||
|| m_displayType == DisplayType.Locator)
|
|| m_displayType == DisplayType.Locator){
|
||||||
return getSelectField(lookup, dataValue);
|
return getSelectField(lookup, dataValue);}
|
||||||
|
|
||||||
if (m_displayType == DisplayType.YesNo)
|
if (m_displayType == DisplayType.YesNo){
|
||||||
return getCheckField (dataValue);
|
return getCheckField (dataValue);}
|
||||||
|
|
||||||
if (m_displayType == DisplayType.Button)
|
if (m_displayType == DisplayType.Button){
|
||||||
return getButtonField ();
|
return getButtonField ();
|
||||||
|
}
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
if (DisplayType.isDate(m_displayType))
|
if (DisplayType.isDate(m_displayType))
|
||||||
return getDateField(data);
|
{
|
||||||
else if (DisplayType.isNumeric(m_displayType))
|
return getPopupDateField(data);
|
||||||
|
}
|
||||||
|
else if (DisplayType.isNumeric(m_displayType)){
|
||||||
return getNumberField(data);
|
return getNumberField(data);
|
||||||
|
}
|
||||||
|
|
||||||
// Strings
|
// Strings
|
||||||
if (m_displayType == DisplayType.Text)
|
if (m_displayType == DisplayType.Text){
|
||||||
return getTextField (dataValue, 3);
|
return getTextField (dataValue, 3);
|
||||||
else if (m_displayType == DisplayType.TextLong)
|
}
|
||||||
|
else if (m_displayType == DisplayType.TextLong){
|
||||||
return getTextField (dataValue, 10);
|
return getTextField (dataValue, 10);
|
||||||
else if (m_displayType == DisplayType.Memo)
|
}
|
||||||
|
else if (m_displayType == DisplayType.Memo){
|
||||||
return getTextField (dataValue, 15);
|
return getTextField (dataValue, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
//other
|
||||||
|
//if (m_displayType == DisplayType.PAttribute){
|
||||||
|
// return getPopupField(dataDisplay, dataValue);}
|
||||||
|
|
||||||
|
if (m_displayType == DisplayType.Assignment){
|
||||||
|
return getAssignmentField(data);}
|
||||||
return getStringField(dataValue);
|
return getStringField(dataValue);
|
||||||
} // getField
|
} // getField
|
||||||
|
|
||||||
|
|
@ -267,6 +308,30 @@ public class WebField
|
||||||
return createTD(string);
|
return createTD(string);
|
||||||
} // getDateField
|
} // getDateField
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Assignment Field
|
||||||
|
* @param data initial value
|
||||||
|
* @return td
|
||||||
|
*/
|
||||||
|
private td getAssignmentField (Object data)
|
||||||
|
{
|
||||||
|
|
||||||
|
input string = new input(input.TYPE_TEXT, m_columnName, Util.maskHTML(""));
|
||||||
|
if (m_fieldLength > 0)
|
||||||
|
string.setMaxlength(m_fieldLength);
|
||||||
|
//
|
||||||
|
string.setDisabled(true);
|
||||||
|
if (m_error)
|
||||||
|
string.setClass(C_ERROR);
|
||||||
|
else if (m_mandatory)
|
||||||
|
string.setClass(C_MANDATORY);
|
||||||
|
//
|
||||||
|
if (m_hasDependents || m_hasCallout)
|
||||||
|
string.setOnChange("startUpdate(this);");
|
||||||
|
return createTD(string).addElement("Not Yet Supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Number Field
|
* Create Number Field
|
||||||
* @param data initial value
|
* @param data initial value
|
||||||
|
|
@ -275,15 +340,24 @@ public class WebField
|
||||||
private td getNumberField (Object data)
|
private td getNumberField (Object data)
|
||||||
{
|
{
|
||||||
String formattedData = "";
|
String formattedData = "";
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
if (data == null)
|
if (data == null)
|
||||||
;
|
if (m_displayType == DisplayType.Amount )
|
||||||
|
formattedData = m_wsc.amountFormat.format(0.00);
|
||||||
|
else if (m_displayType == DisplayType.Number
|
||||||
|
|| m_displayType == DisplayType.CostPrice)
|
||||||
|
formattedData = m_wsc.numberFormat.format(0.00);
|
||||||
|
else if (m_displayType == DisplayType.Integer)
|
||||||
|
formattedData = m_wsc.integerFormat.format(0);
|
||||||
|
else
|
||||||
|
formattedData = "0";
|
||||||
else if (m_displayType == DisplayType.Amount)
|
else if (m_displayType == DisplayType.Amount)
|
||||||
formattedData = m_wsc.amountFormat.format(data);
|
formattedData = m_wsc.amountFormat.format(data);
|
||||||
else if (m_displayType == DisplayType.Number
|
else if (m_displayType == DisplayType.Number
|
||||||
|| m_displayType == DisplayType.CostPrice)
|
|| m_displayType == DisplayType.CostPrice)
|
||||||
formattedData = m_wsc.numberFormat.format(data);
|
formattedData = m_wsc.numberFormat.format(data);
|
||||||
else if (m_displayType == DisplayType.Quantity)
|
//else if (m_displayType == DisplayType.Quantity)
|
||||||
formattedData = m_wsc.quantityFormat.format(data);
|
// formattedData = m_wsc.quantityFormat.format(data);
|
||||||
else if (m_displayType == DisplayType.Integer)
|
else if (m_displayType == DisplayType.Integer)
|
||||||
formattedData = m_wsc.integerFormat.format(data);
|
formattedData = m_wsc.integerFormat.format(data);
|
||||||
else
|
else
|
||||||
|
|
@ -345,15 +419,16 @@ public class WebField
|
||||||
// The hidden data field Name=columnName
|
// The hidden data field Name=columnName
|
||||||
input hidden = new input (input.TYPE_HIDDEN, m_columnName, dataValue);
|
input hidden = new input (input.TYPE_HIDDEN, m_columnName, dataValue);
|
||||||
hidden.setID(m_columnName + "D");
|
hidden.setID(m_columnName + "D");
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
|
input display = null;
|
||||||
// The display field Name=columnName, ID=FcolumnName
|
// The display field Name=columnName, ID=FcolumnName
|
||||||
input display = new input(input.TYPE_TEXT, m_columnName, Util.maskHTML(dataDisplay));
|
display = new input(input.TYPE_TEXT, m_columnName, Util.maskHTML(dataDisplay));
|
||||||
// display.setSize(field.getDisplayLength()).setMaxlength(field.getFieldLength());
|
|
||||||
display.setID(m_columnName + "F");
|
display.setID(m_columnName + "F");
|
||||||
display.setReadOnly(true);
|
display.setReadOnly(true);
|
||||||
|
|
||||||
|
//Modified by Rob Klein 4/29/07
|
||||||
// The button Name=columnName, ID=BcolumnName
|
// The button Name=columnName, ID=BcolumnName
|
||||||
input button = new input (input.TYPE_IMAGE, m_columnName, "x");
|
input button = new input (input.TYPE_IMAGE, m_columnName+ "B", "x");
|
||||||
button.setID(m_columnName + "B");
|
button.setID(m_columnName + "B");
|
||||||
String gif = "PickOpen10.gif";
|
String gif = "PickOpen10.gif";
|
||||||
if (m_displayType == DisplayType.Location)
|
if (m_displayType == DisplayType.Location)
|
||||||
|
|
@ -364,14 +439,106 @@ public class WebField
|
||||||
gif = "BPartner10.gif";
|
gif = "BPartner10.gif";
|
||||||
else if (m_columnName.equals("M_Product_ID"))
|
else if (m_columnName.equals("M_Product_ID"))
|
||||||
gif = "Product10.gif";
|
gif = "Product10.gif";
|
||||||
|
//Set PopUp
|
||||||
button.setSrc(WebEnv.getImageDirectory(gif));
|
button.setSrc(WebEnv.getImageDirectory(gif));
|
||||||
button.setBorder(1);
|
button.setBorder(1);
|
||||||
if (m_displayType == DisplayType.Location)
|
if (m_displayType == DisplayType.Location)
|
||||||
button.setOnClick("startLocation('" + m_columnName + "');return false;");
|
button.setOnClick("startLocation('" + m_columnName + "');return false;");
|
||||||
else if (m_displayType == DisplayType.Account)
|
else if (m_displayType == DisplayType.Account)
|
||||||
button.setOnClick("startAccount('" + m_columnName + "');return false;");
|
// modified by rob klein 4/29/07
|
||||||
|
button.setOnClick("startLookup('" + m_columnName + "', "+m_processID+");return false;");
|
||||||
else
|
else
|
||||||
button.setOnClick("startLookup('" + m_columnName + "');return false;");
|
//modified by rob klein 4/29/07
|
||||||
|
button.setOnClick("startLookup('" + m_columnName + "', "+m_processID+");return false;");
|
||||||
|
|
||||||
|
//Set Zoom
|
||||||
|
//Add by Rob Klein 6/6/2007
|
||||||
|
input buttonZoom = null;
|
||||||
|
if(m_Field != null)
|
||||||
|
{
|
||||||
|
buttonZoom = new input (input.TYPE_IMAGE, m_columnName+ "Z", "x");
|
||||||
|
buttonZoom.setID(m_columnName + "Z");
|
||||||
|
buttonZoom.setSrc(WebEnv.getImageDirectory("Zoom10.gif"));
|
||||||
|
buttonZoom.setBorder(1);
|
||||||
|
StringBuffer sql = null;
|
||||||
|
int refID = m_Field.getAD_Reference_Value_ID();
|
||||||
|
if (refID > 0)
|
||||||
|
sql = new StringBuffer ("SELECT AD_Table_ID"
|
||||||
|
+ "FROM AD_Ref_Table WHERE AD_Reference_ID = "+refID);
|
||||||
|
else
|
||||||
|
sql = new StringBuffer ("SELECT AD_Table_ID "
|
||||||
|
+ "FROM AD_Table WHERE TableName = '"+m_columnName.replace("_ID", "")+"'");
|
||||||
|
int tableID = DB.getSQLValue(null, sql.toString());
|
||||||
|
buttonZoom.setOnClick("startZoom('" + tableID + "', "+m_Field.getValue()+");return false;");
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (m_error)
|
||||||
|
display.setClass(C_ERROR);
|
||||||
|
else if (m_mandatory)
|
||||||
|
display.setClass(C_MANDATORY);
|
||||||
|
//
|
||||||
|
if (m_hasDependents || m_hasCallout)
|
||||||
|
display.setOnChange("startUpdate(this);");
|
||||||
|
//
|
||||||
|
return createTD(hidden)
|
||||||
|
.addElement(display)
|
||||||
|
.addElement(button)
|
||||||
|
.addElement(buttonZoom);
|
||||||
|
} // getPopupField
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Popup Field (lookup, location, account, ..)
|
||||||
|
* @param dataDisplay data to be displayed
|
||||||
|
* @param dataValue data of value field
|
||||||
|
* @return td
|
||||||
|
*/
|
||||||
|
private td getPopupDateField ( Object data)
|
||||||
|
{
|
||||||
|
// The hidden data field Name=columnName
|
||||||
|
|
||||||
|
String dataValue = (data == null) ? "" : data.toString();
|
||||||
|
|
||||||
|
input hidden = new input (input.TYPE_HIDDEN, m_columnName+"D", dataValue);
|
||||||
|
hidden.setID(m_columnName + "D");
|
||||||
|
input display = null;
|
||||||
|
// The display field Name=columnName, ID=FcolumnName
|
||||||
|
String formattedData = "";
|
||||||
|
if (data == null)
|
||||||
|
;
|
||||||
|
else if (m_displayType == DisplayType.DateTime){
|
||||||
|
if (dataValue.equals("@#Date@"))
|
||||||
|
formattedData = m_wsc.dateTimeFormat.format(new java.util.Date());
|
||||||
|
else
|
||||||
|
formattedData = m_wsc.dateTimeFormat.format(data);
|
||||||
|
}
|
||||||
|
else if (m_displayType == DisplayType.Date){
|
||||||
|
if (dataValue.equals("@#Date@"))
|
||||||
|
formattedData = m_wsc.dateFormat.format(new java.util.Date());
|
||||||
|
else
|
||||||
|
formattedData = m_wsc.dateFormat.format(data);
|
||||||
|
}
|
||||||
|
display = new input(input.TYPE_TEXT, m_columnName, formattedData);
|
||||||
|
display.setID(m_columnName + "F"+m_fieldNumber);
|
||||||
|
display.setReadOnly(true);
|
||||||
|
// The button Name=columnName, ID=BcolumnName
|
||||||
|
input button = new input (input.TYPE_IMAGE, m_columnName+ "B", "x");
|
||||||
|
button.setID(m_columnName + "B");
|
||||||
|
String gif = "PickOpen10.gif";
|
||||||
|
if (m_displayType == DisplayType.Date)
|
||||||
|
gif = "Calendar10.gif";
|
||||||
|
else if (m_displayType == DisplayType.DateTime)
|
||||||
|
gif = "Calendar10.gif";
|
||||||
|
|
||||||
|
button.setSrc(WebEnv.getImageDirectory(gif));
|
||||||
|
button.setBorder(1);
|
||||||
|
|
||||||
|
if (m_displayType == DisplayType.Date){
|
||||||
|
button.setOnClick("showCalendar('"+m_columnName+ "F"+m_fieldNumber+"', '%m/%d/%Y');return false;");
|
||||||
|
}
|
||||||
|
else if (m_displayType == DisplayType.DateTime){
|
||||||
|
button.setOnClick("showCalendar('"+m_columnName+ "F"+m_fieldNumber+"', '%b %d, %Y %H:%M:%S %p', '24', true);return false;");
|
||||||
|
}
|
||||||
//
|
//
|
||||||
if (m_error)
|
if (m_error)
|
||||||
display.setClass(C_ERROR);
|
display.setClass(C_ERROR);
|
||||||
|
|
@ -379,7 +546,6 @@ public class WebField
|
||||||
display.setClass(C_MANDATORY);
|
display.setClass(C_MANDATORY);
|
||||||
//
|
//
|
||||||
if (m_hasDependents || m_hasCallout)
|
if (m_hasDependents || m_hasCallout)
|
||||||
// hidden.setOnChange("startUpdate(this);");
|
|
||||||
display.setOnChange("startUpdate(this);");
|
display.setOnChange("startUpdate(this);");
|
||||||
//
|
//
|
||||||
return createTD(hidden)
|
return createTD(hidden)
|
||||||
|
|
@ -395,18 +561,61 @@ public class WebField
|
||||||
*/
|
*/
|
||||||
private td getSelectField (Lookup lookup, String dataValue)
|
private td getSelectField (Lookup lookup, String dataValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (dataValue.length()<1 && m_defaultObject != null) {
|
||||||
|
dataValue = m_defaultObject.toString();
|
||||||
|
}
|
||||||
|
|
||||||
select sel = new select(m_columnName, getOptions(lookup, dataValue));
|
select sel = new select(m_columnName, getOptions(lookup, dataValue));
|
||||||
sel.setID(m_columnName);
|
sel.setID(m_columnName);
|
||||||
sel.setDisabled(m_readOnly);
|
sel.setDisabled(m_readOnly);
|
||||||
|
|
||||||
if (m_error)
|
if (m_error)
|
||||||
sel.setClass(C_ERROR);
|
sel.setClass(C_ERROR);
|
||||||
else if (m_mandatory)
|
else if (m_mandatory)
|
||||||
sel.setClass(C_MANDATORY);
|
sel.setClass(C_MANDATORY);
|
||||||
//
|
|
||||||
if (m_hasDependents || m_hasCallout)
|
if (m_hasDependents || m_hasCallout)
|
||||||
sel.setOnChange("startUpdate(this);");
|
sel.setOnChange("startUpdate(this);");
|
||||||
|
|
||||||
|
//Set Zoom
|
||||||
|
//Add by Rob Klein 6/6/2007
|
||||||
|
input buttonZoom = null;
|
||||||
|
int refID = 0;
|
||||||
|
Object recordID =0;
|
||||||
|
if(m_Field != null && !m_readOnly)
|
||||||
|
{
|
||||||
|
buttonZoom = new input (input.TYPE_IMAGE, m_columnName+ "Z", "x");
|
||||||
|
buttonZoom.setID(m_columnName + "Z");
|
||||||
|
buttonZoom.setSrc(WebEnv.getImageDirectory("Zoom10.gif"));
|
||||||
|
buttonZoom.setBorder(1);
|
||||||
|
StringBuffer sql = null;
|
||||||
|
refID = m_Field.getAD_Reference_Value_ID();
|
||||||
|
if (m_displayType == DisplayType.List ){
|
||||||
|
sql = new StringBuffer ("SELECT AD_Table_ID "
|
||||||
|
+ "FROM AD_Table WHERE TableName = 'AD_Reference'");
|
||||||
|
|
||||||
|
recordID = refID;
|
||||||
|
}
|
||||||
|
else if (refID > 0 ){
|
||||||
|
sql = new StringBuffer ("SELECT AD_Table_ID "
|
||||||
|
+ "FROM AD_Ref_Table WHERE AD_Reference_ID = "+refID);
|
||||||
|
recordID =m_Field.getValue();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
sql = new StringBuffer ("SELECT AD_Table_ID "
|
||||||
|
+ "FROM AD_Table WHERE TableName = '"+m_columnName.replace("_ID", "")+"'");
|
||||||
|
recordID =m_Field.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
int tableID = DB.getSQLValue(null, sql.toString());
|
||||||
|
|
||||||
|
buttonZoom.setOnClick("startZoom('" + tableID + "', '"+recordID+"');return false;");
|
||||||
|
|
||||||
|
}
|
||||||
//
|
//
|
||||||
return createTD(sel);
|
return createTD(sel).addElement(buttonZoom);
|
||||||
} // getSelectField
|
} // getSelectField
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -419,11 +628,33 @@ public class WebField
|
||||||
{
|
{
|
||||||
if (lookup == null)
|
if (lookup == null)
|
||||||
return new option[0];
|
return new option[0];
|
||||||
|
//boolean keyFound = false;
|
||||||
//
|
//
|
||||||
|
|
||||||
|
NamePair value = null;
|
||||||
Object[] list = lookup.getData (m_mandatory, true, !m_readOnly, false)
|
Object[] list = lookup.getData (m_mandatory, true, !m_readOnly, false)
|
||||||
.toArray(); // if r/o also inactive
|
.toArray(); // if r/o also inactive
|
||||||
int size = list.length;
|
int size = list.length;
|
||||||
option[] options = new option[size];
|
option[] options = new option[size];
|
||||||
|
|
||||||
|
if (size == 0 && dataValue.length()>0){
|
||||||
|
|
||||||
|
value = lookup.getDirect(dataValue, false, false);
|
||||||
|
if (value != null){
|
||||||
|
options = new option[2];
|
||||||
|
if (dataValue.length()<1){
|
||||||
|
options[0] = new option("-1").addElement(" ").setSelected(true);
|
||||||
|
options[1] = new option(value.getID()).addElement(value.getName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
options[0] = new option("-1").addElement(" ");
|
||||||
|
options[1] = new option(value.getID()).addElement(value.getName()).setSelected(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
boolean isNumber = list[0] instanceof KeyNamePair;
|
boolean isNumber = list[0] instanceof KeyNamePair;
|
||||||
|
|
@ -433,6 +664,9 @@ public class WebField
|
||||||
MLocator loc = (MLocator)list[i];
|
MLocator loc = (MLocator)list[i];
|
||||||
key = String.valueOf(loc.getM_Locator_ID());
|
key = String.valueOf(loc.getM_Locator_ID());
|
||||||
String name = Util.maskHTML(loc.getValue());
|
String name = Util.maskHTML(loc.getValue());
|
||||||
|
if (dataValue.equals(key))
|
||||||
|
options[i] = new option(key).addElement(name).setSelected(true);
|
||||||
|
else
|
||||||
options[i] = new option(key).addElement(name);
|
options[i] = new option(key).addElement(name);
|
||||||
}
|
}
|
||||||
else if (isNumber)
|
else if (isNumber)
|
||||||
|
|
@ -440,6 +674,9 @@ public class WebField
|
||||||
KeyNamePair p = (KeyNamePair)list[i];
|
KeyNamePair p = (KeyNamePair)list[i];
|
||||||
key = String.valueOf(p.getKey());
|
key = String.valueOf(p.getKey());
|
||||||
String name = Util.maskHTML(p.getName());
|
String name = Util.maskHTML(p.getName());
|
||||||
|
if (dataValue.equals(key))
|
||||||
|
options[i] = new option(key).addElement(name).setSelected(true);
|
||||||
|
else
|
||||||
options[i] = new option(key).addElement(name);
|
options[i] = new option(key).addElement(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -452,11 +689,15 @@ public class WebField
|
||||||
if (name == null || name.length() == 0)
|
if (name == null || name.length() == 0)
|
||||||
name = "???";
|
name = "???";
|
||||||
name = Util.maskHTML(name);
|
name = Util.maskHTML(name);
|
||||||
|
if (dataValue.equals(key))
|
||||||
|
options[i] = new option(key).addElement(name).setSelected(true);
|
||||||
|
else
|
||||||
options[i] = new option(key).addElement(name);
|
options[i] = new option(key).addElement(name);
|
||||||
}
|
}
|
||||||
if (dataValue.equals(key))
|
|
||||||
options[i].setSelected(true);
|
|
||||||
}
|
}
|
||||||
|
//If no key found then default to first value
|
||||||
|
//if (!keyFound && size>0)
|
||||||
|
//options[0].setSelected(true);
|
||||||
return options;
|
return options;
|
||||||
} // getOptions
|
} // getOptions
|
||||||
|
|
||||||
|
|
@ -467,10 +708,12 @@ public class WebField
|
||||||
*/
|
*/
|
||||||
private td getButtonField ()
|
private td getButtonField ()
|
||||||
{
|
{
|
||||||
input button = new input(input.TYPE_BUTTON, m_columnName, Util.maskHTML(m_name));
|
//Modified by Rob Klein 4/29/07
|
||||||
|
input button = new input("button", m_columnName, " "+Util.maskHTML(m_name));
|
||||||
button.setID(m_columnName);
|
button.setID(m_columnName);
|
||||||
|
button.setClass("processbtn");
|
||||||
button.setDisabled(m_readOnly);
|
button.setDisabled(m_readOnly);
|
||||||
button.setOnClick("startButton(this);");
|
button.setOnClick("startButton("+m_processID+", "+m_windowID+", "+m_recordID+", "+m_tableID+", '"+ m_columnName+"');");
|
||||||
return createTD(button)
|
return createTD(button)
|
||||||
.setAlign(AlignType.LEFT); // overwrite
|
.setAlign(AlignType.LEFT); // overwrite
|
||||||
} // getButtonField
|
} // getButtonField
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue