1 19 package org.openbravo.erpCommon.ad_callouts; 20 21 import org.openbravo.base.secureApp.HttpSecureAppServlet; 22 import org.openbravo.base.secureApp.VariablesSecureApp; 23 import org.openbravo.xmlEngine.XmlDocument; 24 import java.io.*; 25 import java.math.BigDecimal ; 26 import javax.servlet.*; 27 import javax.servlet.http.*; 28 29 30 31 public class SL_WorkRequirement_Conversion extends HttpSecureAppServlet { 32 33 static final BigDecimal ZERO = new BigDecimal (0.0); 34 35 public void init (ServletConfig config) { 36 super.init(config); 37 boolHist = false; 38 } 39 40 41 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 42 VariablesSecureApp vars = new VariablesSecureApp(request); 43 if (vars.commandIn("DEFAULT")) { 44 String strChanged = vars.getStringParameter("inpLastFieldChanged"); 45 if (log4j.isDebugEnabled()) log4j.debug("CHANGED: " + strChanged); 46 String strSecQty = vars.getStringParameter("inpsecondaryqty"); 47 String strConvRate = vars.getStringParameter("inpconversionrate"); 48 String strTabId = vars.getStringParameter("inpTabId"); 49 try { 50 printPage(response, vars, strSecQty, strConvRate, strTabId); 51 } catch (ServletException ex) { 52 pageErrorCallOut(response); 53 } 54 } else pageError(response); 55 } 56 57 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strSecQty, String strConvRate, String strTabId) throws IOException, ServletException { 58 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 59 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument(); 60 int stdPrecision = 0; 61 62 BigDecimal secondaryQty, quantity, convRate; 63 64 65 StringBuffer resultado = new StringBuffer (); 66 resultado.append("var calloutName='SL_WorkRequirement_Conversion';\n\n"); 67 resultado.append("var respuesta = new Array("); 68 if (!strSecQty.equals("")&&!strConvRate.equals("")) { 69 convRate = new BigDecimal (strConvRate); 70 secondaryQty = new BigDecimal (strSecQty); 71 quantity = secondaryQty.divide(convRate, 0, BigDecimal.ROUND_HALF_UP); 72 resultado.append("new Array(\"inpquantity\", " + quantity.toString() + ")"); 73 } 74 resultado.append(");"); 75 xmlDocument.setParameter("array", resultado.toString()); 76 xmlDocument.setParameter("frameName", "frameAplicacion"); 77 response.setContentType("text/html; charset=UTF-8"); 78 PrintWriter out = response.getWriter(); 79 out.println(xmlDocument.print()); 80 out.close(); 81 } 82 } 83 | Popular Tags |