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 org.openbravo.erpCommon.utility.*; 25 import java.io.*; 26 import javax.servlet.*; 27 import javax.servlet.http.*; 28 import java.math.BigDecimal ; 29 30 public class SL_Requisition_Product 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 if (vars.commandIn("DEFAULT")) { 41 String strChanged = vars.getStringParameter("inpLastFieldChanged"); 42 if (log4j.isDebugEnabled()) log4j.debug("CHANGED: " + strChanged); 43 String strQty = vars.getStringParameter("inpqty"); 44 45 String strMProductID = vars.getStringParameter("inpmProductId"); 46 String strWindowId = vars.getStringParameter("inpwindowId"); 47 String strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 48 String strTabId = vars.getStringParameter("inpTabId"); 49 50 try { 51 printPage(response, vars, strMProductID, strWindowId, strIsSOTrx, strTabId, strQty, strChanged); 52 } catch (ServletException ex) { 53 pageErrorCallOut(response); 54 } 55 } else pageError(response); 56 } 57 58 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strMProductID, String strWindowId, String strIsSOTrx, String strTabId, String strQty, String strChanged) throws IOException, ServletException { 59 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 60 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument(); 61 62 String strPriceActual = ""; 63 String strPriceList = vars.getStringParameter("inpmProductId_PLIST"); 64 String strPriceStd = vars.getStringParameter("inpmProductId_PSTD"); 65 String strPriceLimit = vars.getStringParameter("inpmProductId_PLIM"); 66 67 if (strMProductID.equals("")) { 68 strPriceList = strPriceLimit = strPriceStd = ""; 69 } 70 if (!strChanged.equalsIgnoreCase("inpmProductId")) { 71 strPriceList = vars.getStringParameter("inppricelist"); 72 strPriceStd = vars.getStringParameter("inppricestd"); 73 strPriceLimit = vars.getStringParameter("inppricelimit"); 74 } 75 StringBuffer resultado = new StringBuffer (); 76 77 if (strPriceList.startsWith("\"")) strPriceList = strPriceList.substring(1, strPriceList.length() - 1); 79 if (strPriceStd.startsWith("\"")) strPriceStd = strPriceStd.substring(1, strPriceStd.length() - 1); 80 BigDecimal priceList = (strPriceList.equals("")?new BigDecimal (0.0):new BigDecimal (strPriceList)); 81 BigDecimal priceStd = (strPriceStd.equals("")?new BigDecimal (0.0):new BigDecimal (strPriceStd)); 82 BigDecimal qty = (strQty.equals("")?new BigDecimal (0.0):new BigDecimal (strQty)); 83 BigDecimal lineNet = new BigDecimal (0.0); 84 lineNet = new BigDecimal (priceStd.doubleValue() * qty.doubleValue()).setScale(2, BigDecimal.ROUND_HALF_UP); 85 86 resultado.append("var calloutName='SL_Requisition_Product';\n\n"); 87 resultado.append("var respuesta = new Array("); 88 resultado.append("new Array(\"inppricelist\", " + (strPriceList.equals("")?"\"0\"":strPriceList) + "),"); 89 resultado.append("new Array(\"inppricelimit\", " + (strPriceLimit.equals("")?"\"0\"":strPriceLimit) + "),"); 90 resultado.append("new Array(\"inppricestd\", " + (strPriceStd.equals("")?"\"0\"":strPriceStd) + "),"); 91 resultado.append("new Array(\"inplinenetamt\", " + lineNet.toString() + "),"); 92 resultado.append("new Array(\"EXECUTE\", \"displayLogic();\"),\n"); 93 resultado.append("new Array(\"CURSOR_FIELD\", \"inpqty\")\n"); 95 resultado.append(");"); 96 xmlDocument.setParameter("array", resultado.toString()); 97 xmlDocument.setParameter("frameName", "frameAplicacion"); 98 response.setContentType("text/html; charset=UTF-8"); 99 PrintWriter out = response.getWriter(); 100 out.println(xmlDocument.print()); 101 out.close(); 102 } 103 } 104 | Popular Tags |