Search in sources :

Example 1 with MChat

use of org.compiere.model.MChat in project adempiere by adempiere.

the class WChat method CreateChatPage.

//	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 (//	No Key
    record_ID == -1) {
        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;
}
Also used : org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) org.apache.ecs.xhtml.form(org.apache.ecs.xhtml.form) MChat(org.compiere.model.MChat) GridField(org.compiere.model.GridField) org.apache.ecs.xhtml.table(org.apache.ecs.xhtml.table) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr)

Example 2 with MChat

use of org.compiere.model.MChat in project adempiere by adempiere.

the class WChat method doPost.

//  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.saveEx();
        }
        MChatEntry entry = new MChatEntry(m_chat, data);
        entry.saveEx();
    }
    //	data to be saved
    doc = CreateChatPage(ws, wsc, doc, m_chat.getCM_Chat_ID());
    WebUtil.createResponse(request, response, this, null, doc, false);
}
Also used : MChatEntry(org.compiere.model.MChatEntry) WebDoc(org.compiere.util.WebDoc) MChat(org.compiere.model.MChat) WebSessionCtx(org.compiere.util.WebSessionCtx)

Aggregations

MChat (org.compiere.model.MChat)2 org.apache.ecs.xhtml.form (org.apache.ecs.xhtml.form)1 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)1 org.apache.ecs.xhtml.table (org.apache.ecs.xhtml.table)1 org.apache.ecs.xhtml.td (org.apache.ecs.xhtml.td)1 org.apache.ecs.xhtml.tr (org.apache.ecs.xhtml.tr)1 GridField (org.compiere.model.GridField)1 MChatEntry (org.compiere.model.MChatEntry)1 WebDoc (org.compiere.util.WebDoc)1 WebSessionCtx (org.compiere.util.WebSessionCtx)1