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 public class SL_Project_Planned extends HttpSecureAppServlet { 31 32 static final BigDecimal ZERO = new BigDecimal (0.0); 33 34 public void init (ServletConfig config) { 35 super.init(config); 36 boolHist = false; 37 } 38 39 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 40 VariablesSecureApp vars = new VariablesSecureApp(request); 41 if (vars.commandIn("DEFAULT")) { 42 String strcProjectLineId = vars.getStringParameter("inpcProjectlineId"); 43 String strPlannedQty = vars.getStringParameter("inpplannedqty", "1"); 44 String strPlannedPrice = vars.getStringParameter("inpplannedprice", "0"); 45 String strTabId = vars.getStringParameter("inpTabId"); 46 try { 47 printPage(response, vars, strPlannedQty, strPlannedPrice, strcProjectLineId, strTabId); 48 } catch (ServletException ex) { 49 pageErrorCallOut(response); 50 } 51 } else pageError(response); 52 } 53 54 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strPlannedQty, String strPlannedPrice, String strcProjectLineId, String strTabId) throws IOException, ServletException { 55 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 56 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument(); 57 SLProjectPlannedAmtData[] data = SLProjectPlannedAmtData.select(this, strcProjectLineId); 58 String strPrecision = "0", strPricePrecision="0"; 59 boolean enforcedLimit=false; 60 if (data!=null && data.length>0) { 61 strPrecision = data[0].stdprecision; 62 strPricePrecision = data[0].priceprecision; 63 } 64 int StdPrecision = Integer.valueOf(strPrecision).intValue(); 65 int PricePrecision = Integer.valueOf(strPricePrecision).intValue(); 66 67 BigDecimal plannedAmt, plannedQty, plannedPrice; 68 plannedQty = new BigDecimal (strPlannedQty); 69 plannedPrice = (new BigDecimal (strPlannedPrice)); 71 plannedAmt = plannedQty.multiply(plannedPrice); 72 73 if (plannedAmt.scale() > StdPrecision) 74 plannedAmt = plannedAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); 75 76 StringBuffer resultado = new StringBuffer (); 77 resultado.append("var calloutName='SL_Project_Planned';\n\n"); 78 resultado.append("var respuesta = new Array("); 79 resultado.append("new Array(\"inpplannedamt\", " + plannedAmt.toString() + ")"); 80 resultado.append(");"); 81 xmlDocument.setParameter("array", resultado.toString()); 82 xmlDocument.setParameter("frameName", "frameAplicacion"); 83 response.setContentType("text/html; charset=UTF-8"); 84 PrintWriter out = response.getWriter(); 85 out.println(xmlDocument.print()); 86 out.close(); 87 } 88 } 89 | Popular Tags |