1 17 package org.openbravo.erpCommon.ad_process; 18 19 import org.openbravo.erpCommon.ad_actionButton.*; 20 import org.openbravo.erpCommon.utility.Utility; 21 import org.openbravo.utils.FormatUtilities; 22 import org.openbravo.base.secureApp.HttpSecureAppServlet; 23 import org.openbravo.base.secureApp.VariablesSecureApp; 24 import org.openbravo.xmlEngine.XmlDocument; 25 import java.io.*; 26 import javax.servlet.*; 27 import javax.servlet.http.*; 28 29 30 public class ImportOrderServlet extends HttpSecureAppServlet { 31 32 33 public void init (ServletConfig config) { 34 super.init(config); 35 boolHist = false; 36 } 37 38 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 39 VariablesSecureApp vars = new VariablesSecureApp(request); 40 41 if (log4j.isDebugEnabled()) log4j.debug("role: " + vars.getRole()); 42 if (!Utility.hasProcessAccess(this, vars, "", "ImportOrderServlet")) { 43 bdError(response, "AccessTableNoView", vars.getLanguage()); 44 return; 45 } 46 String process = ImportData.processId(this, "ImportOrderServlet"); 47 if (vars.commandIn("DEFAULT")) { 48 String strTabId = vars.getGlobalVariable("inpTabId", "ImportOrderServlet|tabId"); 49 String strWindowId = vars.getGlobalVariable("inpwindowId", "ImportOrderServlet|windowId"); 50 String strKey = "00"; 52 String strDeleteOld = vars.getStringParameter("inpDeleteOld", "N"); 53 printPage(response, vars, process, strWindowId, strTabId, strKey, strDeleteOld); 54 } else if (vars.commandIn("SAVE")) { 55 String strDeleteOld = vars.getStringParameter("inpDeleteOld", "N"); 56 String strRecord = vars.getGlobalVariable("inpKey", "ImportOrderServlet|key"); 57 String strTabId = vars.getRequestGlobalVariable("inpTabId", "ImportOrderServlet|tabId"); 58 String strWindowId = vars.getRequestGlobalVariable("inpwindowId", "ImportOrderServlet|windowId"); 59 60 ActionButtonDefaultData[] tab = ActionButtonDefaultData.windowName(this, strTabId); 61 String strWindowPath=""; 62 String strTabName=""; 63 if (tab!=null && tab.length!=0) { 64 strTabName = FormatUtilities.replace(tab[0].name); 65 if (tab[0].help.equals("Y")) strWindowPath="../utility/WindowTree_FS.html?inpTabId=" + strTabId; 66 else strWindowPath = "../" + FormatUtilities.replace(tab[0].description) + "/" + strTabName + "_Relation.html"; 67 } else strWindowPath = strDefaultServlet; 68 69 ImportOrder io = new ImportOrder(this, process, strRecord, strDeleteOld.equals("Y")); 70 io.startProcess(vars); 71 String strMessage = io.getLog(); 72 if (!strMessage.equals("")) vars.setSessionValue(strWindowId + "|" + strTabName + ".message", strMessage); 73 printPageClosePopUp(response, vars, strWindowPath); 74 } else pageErrorPopUp(response); 75 } 76 77 78 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strProcessId, String strWindowId, String strTabId, String strRecordId, String strDeleteOld) throws IOException, ServletException { 79 if (log4j.isDebugEnabled()) log4j.debug("Output: process ImportOrderServlet"); 80 ActionButtonDefaultData[] data = null; 81 String strHelp="", strDescription=""; 82 if (vars.getLanguage().equals("en_US")) data = ActionButtonDefaultData.select(this, strProcessId); 83 else data = ActionButtonDefaultData.selectLanguage(this, vars.getLanguage(), strProcessId); 84 if (data!=null && data.length!=0) { 85 strDescription = data[0].description; 86 strHelp = data[0].help; 87 } 88 String [] discard = {""}; 89 if (strHelp.equals("")) discard[0] = new String ("helpDiscard"); 90 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_process/ImportOrderServlet").createXmlDocument(); 91 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 92 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 93 xmlDocument.setParameter("question", Utility.messageBD(this, "StartProcess?", vars.getLanguage())); 94 xmlDocument.setParameter("description", strDescription); 95 xmlDocument.setParameter("help", strHelp); 96 xmlDocument.setParameter("windowId", strWindowId); 97 xmlDocument.setParameter("tabId", strTabId); 98 xmlDocument.setParameter("recordId", strRecordId); 99 xmlDocument.setParameter("deleteOld", strDeleteOld); 100 101 response.setContentType("text/html; charset=UTF-8"); 102 PrintWriter out = response.getWriter(); 103 out.println(xmlDocument.print()); 104 out.close(); 105 } 106 107 public String getServletInfo() { 108 return "Servlet ImportOrderServlet"; 109 } } 111
| Popular Tags
|