1 19 package org.openbravo.erpCommon.ad_actionButton; 20 21 import org.openbravo.erpCommon.utility.Utility; 23 import org.openbravo.utils.FormatUtilities; 24 import org.openbravo.base.secureApp.HttpSecureAppServlet; 25 import org.openbravo.base.secureApp.VariablesSecureApp; 26 import org.openbravo.xmlEngine.XmlDocument; 27 import java.io.*; 28 import javax.servlet.*; 29 import javax.servlet.http.*; 30 31 32 public class ProjectClose extends HttpSecureAppServlet { 33 34 35 public void init (ServletConfig config) { 36 super.init(config); 37 boolHist = false; 38 } 39 40 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 41 VariablesSecureApp vars = new VariablesSecureApp(request); 42 43 if (vars.commandIn("DEFAULT")) { 44 String strProcessId = vars.getStringParameter("inpProcessId"); 45 String strWindow = vars.getStringParameter("inpwindowId"); 46 String strTab = vars.getStringParameter("inpTabId"); 47 String strKey = vars.getRequiredGlobalVariable("inpcProjectId", strWindow + "|C_Project_ID"); 48 printPage(response, vars, strKey, strWindow, strTab, strProcessId); 49 } else if (vars.commandIn("SAVE")) { 50 String strWindow = vars.getStringParameter("inpwindowId"); 51 String strKey = vars.getRequestGlobalVariable("inpcProjectId", strWindow + "|C_Project_ID"); 52 String strTab = vars.getStringParameter("inpTabId"); 53 ActionButtonDefaultData[] tab = ActionButtonDefaultData.windowName(this, strTab); 54 String strWindowPath="", strTabName=""; 55 if (tab!=null && tab.length!=0) { 56 strTabName = FormatUtilities.replace(tab[0].name); 57 strWindowPath = "../" + FormatUtilities.replace(tab[0].description) + "/" + strTabName + "_Relation.html"; 58 } else strWindowPath = strDefaultServlet; 59 String messageResult = processButton(vars, strKey, strWindow); 60 vars.setSessionValue(strWindow + "|" + strTabName + ".message", messageResult); 61 printPageClosePopUp(response, vars, strWindowPath); 62 } else pageErrorPopUp(response); 63 } 64 65 66 String processButton(VariablesSecureApp vars, String strKey, String windowId) { 67 try { 68 if(ProjectCloseData.update(this, strKey)!=1)return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 69 ProjectCloseData.updateLines(this, strKey); 70 return Utility.messageBD(this, "ProcessOK", vars.getLanguage()); 71 } catch (ServletException e) { 72 log4j.warn(e); 73 return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 74 } 75 } 76 77 78 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strKey, String windowId, String strTab, String strProcessId) 79 throws IOException, ServletException { 80 if (log4j.isDebugEnabled()) log4j.debug("Output: Button process Project Close"); 81 82 ActionButtonDefaultData[] data = null; 83 String strHelp="", strDescription=""; 84 if (vars.getLanguage().equals("en_US")) data = ActionButtonDefaultData.select(this, strProcessId); 85 else data = ActionButtonDefaultData.selectLanguage(this, vars.getLanguage(), strProcessId); 86 87 if (data!=null && data.length!=0) { 88 strDescription = data[0].description; 89 strHelp = data[0].help; 90 } 91 String [] discard = {""}; 92 if (strHelp.equals("")) discard[0] = new String ("helpDiscard"); 93 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/ProjectClose", discard).createXmlDocument(); 94 xmlDocument.setParameter("key", strKey); 95 xmlDocument.setParameter("window", windowId); 96 xmlDocument.setParameter("tab", strTab); 97 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 98 xmlDocument.setParameter("question", Utility.messageBD(this, "StartProcess?", vars.getLanguage())); 99 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 100 xmlDocument.setParameter("description", strDescription); 101 xmlDocument.setParameter("help", strHelp); 102 103 response.setContentType("text/html; charset=UTF-8"); 104 PrintWriter out = response.getWriter(); 105 out.println(xmlDocument.print()); 106 out.close(); 107 } 108 109 public String getServletInfo() { 110 return "Servlet Project set Type"; 111 } } 113 114 | Popular Tags |