1 19 package org.openbravo.erpCommon.ad_process; 20 21 import org.openbravo.erpCommon.utility.ToolBar; 22 import org.openbravo.erpCommon.utility.SequenceIdData; 23 import org.openbravo.erpCommon.utility.KeyMap; 24 import org.openbravo.erpCommon.utility.OBError; 25 import org.openbravo.erpCommon.utility.LeftTabsBar; 26 import org.openbravo.erpCommon.utility.NavigationBar; 27 import org.openbravo.erpCommon.businessUtility.WindowTabs; 28 import org.openbravo.erpCommon.reference.*; 29 import org.openbravo.erpCommon.ad_actionButton.*; 30 import org.openbravo.erpCommon.ad_combos.ClientComboData; 31 import org.openbravo.erpCommon.utility.Utility; 32 import org.openbravo.base.secureApp.HttpSecureAppServlet; 33 import org.openbravo.base.secureApp.VariablesSecureApp; 34 import org.openbravo.xmlEngine.XmlDocument; 35 import java.io.*; 36 import javax.servlet.*; 37 import javax.servlet.http.*; 38 39 40 public class DeleteClient extends HttpSecureAppServlet { 41 42 43 public void init (ServletConfig config) { 44 super.init(config); 45 boolHist = false; 46 } 47 48 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 49 VariablesSecureApp vars = new VariablesSecureApp(request); 50 51 if (vars.commandIn("DEFAULT")) { 52 String strClient = vars.getRequestGlobalVariable("inpClientId", "DeleteClient|inpClientId"); 53 printPage(response, vars, strClient); 55 } else if (vars.commandIn("SAVE")) { 56 String strKey = ""; String strClient = vars.getRequestGlobalVariable("inpClientId", "DeleteClient|inpClientId"); 58 String messageResult = processButton(vars, strClient); 59 vars.setSessionValue("DeleteClient.message", messageResult); 60 response.sendRedirect(strDireccion + request.getServletPath()); 61 } else pageErrorPopUp(response); 62 } 63 64 String processButton(VariablesSecureApp vars, String strClient) throws ServletException { 65 String pinstance = SequenceIdData.getSequence(this, "AD_PInstance", vars.getClient()); 66 68 PInstanceProcessData.insertPInstance(this, pinstance, "800147", strClient, "N", vars.getUser(), vars.getClient(), vars.getOrg()); 69 PInstanceProcessData.insertPInstanceParamNumber(this, pinstance, "10", "AD_Client_ID", strClient, vars.getClient(), vars.getOrg(), vars.getUser()); 70 71 DeleteClientData.adDeleteClient( this, pinstance); 72 73 PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance); 74 String messageResult=""; 75 if (pinstanceData!=null && pinstanceData.length>0) { 76 if (log4j.isDebugEnabled()) log4j.debug("msg: "+pinstanceData[0].errormsg.equals("")); 77 if (!pinstanceData[0].errormsg.equals("")) { 78 String message = pinstanceData[0].errormsg; 79 if (message.startsWith("@") && message.endsWith("@")) { 81 message = message.substring(1, message.length()-1); 82 if (message.indexOf("@")==-1) messageResult = Utility.messageBD(this, message, vars.getLanguage()); 83 else messageResult = Utility.parseTranslation(this, vars, vars.getLanguage(), "@" + message + "@"); 84 } else { 85 messageResult = Utility.parseTranslation(this, vars, vars.getLanguage(), message); 86 } 87 } else if (pinstanceData[0].pMsg.equals("")) { 88 91 messageResult = Utility.messageBD(this, "Success", vars.getLanguage()); 92 } else { 93 messageResult = Utility.messageBD(this, "Error", vars.getLanguage())+pinstanceData[0].pMsg; 94 } 95 } 96 return messageResult; 97 } 98 99 100 101 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strClient) throws IOException, ServletException { 102 if (log4j.isDebugEnabled()) log4j.debug("Output: Delete Client"); 103 104 ActionButtonDefaultData[] data = null; 105 String strMessage = vars.getSessionValue("DeleteClient.message"); 106 vars.removeSessionValue("DeleteClient.message"); 107 String strHelp="", strDescription="", strProcessId="800147"; 108 if (vars.getLanguage().equals("en_US")) data = ActionButtonDefaultData.select(this, strProcessId); 109 else data = ActionButtonDefaultData.selectLanguage(this, vars.getLanguage(), strProcessId); 110 111 if (data!=null && data.length!=0) { 112 strDescription = data[0].description; 113 strHelp = data[0].help; 114 } 115 String [] discard = {""}; 116 if (strHelp.equals("")) discard[0] = new String ("helpDiscard"); 117 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_process/DeleteClient", discard).createXmlDocument(); 118 119 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "DeleteClient", false, "", "", "",false, "ad_process", strReplaceWith, false, true); 120 toolbar.prepareSimpleToolBarTemplate(); 121 xmlDocument.setParameter("toolbar", toolbar.toString()); 122 123 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 124 xmlDocument.setParameter("alertMsg", "ALERT_MSG=\"" + Utility.messageBD(this, "GoingToDeleteClient", vars.getLanguage()) + "\";"); 125 xmlDocument.setParameter("question", Utility.messageBD(this, "StartProcess?", vars.getLanguage())); 126 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 127 xmlDocument.setParameter("description", strDescription); 128 xmlDocument.setParameter("help", strHelp); 129 xmlDocument.setParameter("Client", strClient); 130 try { 131 KeyMap key = new KeyMap(this, vars, "DeleteClient.html"); 132 xmlDocument.setParameter("keyMap", key.getActionButtonKeyMaps()); 133 } catch (Exception ex) { 134 throw new ServletException(ex); 135 } 136 try { 137 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_process.DeleteClient"); 138 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 139 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 140 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 141 xmlDocument.setParameter("theme", vars.getTheme()); 142 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "DeleteClient.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 143 xmlDocument.setParameter("navigationBar", nav.toString()); 144 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "DeleteClient.html", strReplaceWith); 145 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 146 } catch (Exception ex) { 147 throw new ServletException(ex); 148 } 149 { 150 OBError myMessage = vars.getMessage("DeleteClient"); 151 vars.removeMessage("DeleteClient"); 152 if (myMessage!=null) { 153 xmlDocument.setParameter("messageType", myMessage.getType()); 154 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 155 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 156 } 157 } 158 xmlDocument.setData("reportClientId","liststructure",ClientComboData.selectAllClients1(this)); 159 if (!strMessage.equals("")) strMessage = "alert('" + strMessage + "');"; 160 xmlDocument.setParameter("message", strMessage); 161 162 response.setContentType("text/html; charset=UTF-8"); 163 PrintWriter out = response.getWriter(); 164 out.println(xmlDocument.print()); 165 out.close(); 166 } 167 168 169 } 170
| Popular Tags
|