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