/** * 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; }