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.utils.FormatUtilities; 25 import org.openbravo.erpCommon.utility.*; 26 import java.io.*; 27 import java.math.BigDecimal ; 28 import javax.servlet.*; 29 import javax.servlet.http.*; 30 31 import org.openbravo.erpCommon.businessUtility.Tax; 32 33 public class SL_Payment_No_Verify extends HttpSecureAppServlet { 34 35 static final BigDecimal ZERO = new BigDecimal (0.0); 36 37 public void init (ServletConfig config) { 38 super.init(config); 39 boolHist = false; 40 } 41 42 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 43 VariablesSecureApp vars = new VariablesSecureApp(request); 44 if (vars.commandIn("DEFAULT")) { 45 String strChanged = vars.getStringParameter("inpLastFieldChanged"); 46 if (log4j.isDebugEnabled()) log4j.debug("CHANGED: " + strChanged); 47 String strcCreditCard = vars.getStringParameter("inpcreditcardnumber"); 48 String strcCreditCardType = vars.getStringParameter("inpcreditcardtype"); 49 String strcRoutingNo = vars.getStringParameter("inproutingno"); 50 String strTabId = vars.getStringParameter("inpTabId"); 51 52 try { 53 printPage(response, vars, strChanged, strcCreditCard, strcCreditCardType, strcRoutingNo, strTabId); 54 } catch (ServletException ex) { 55 pageErrorCallOut(response); 56 } 57 } else pageError(response); 58 } 59 60 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strChanged, String strcCreditCard, String strcCreditCardType, String strcRoutingNo, String strTabId) throws IOException, ServletException { 61 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 62 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument(); 63 StringBuffer resultado = new StringBuffer (); 64 resultado.append("var calloutName='SL_Payment_DocType';\n\n"); 65 resultado.append("var respuesta = new Array("); 66 67 if (strChanged.equals("inpcreditcardnumber")){ 68 if (strcCreditCard.equals(null) || strcCreditCard.length() == 0){} 69 else{ 70 String strcvalidateCc = Tax.validateCreditCardNumber(strcCreditCard, strcCreditCardType); 71 resultado.append("new Array('MESSAGE', \"" + FormatUtilities.replaceJS(Utility.messageBD(this, strcvalidateCc, vars.getLanguage())) + "\")"); 72 } 73 } 74 else if (strChanged.equals("inproutingno")){ 75 if (strcRoutingNo.equals(null) || strcRoutingNo.length() == 0){ 76 } 77 else { 78 String strcvalidateRo = Tax.validateRoutingNo(strcRoutingNo); 79 resultado.append("new Array('MESSAGE', \"" + FormatUtilities.replaceJS(Utility.messageBD(this, strcvalidateRo, vars.getLanguage())) + "\")"); 80 } 81 } 82 resultado.append(");"); 83 xmlDocument.setParameter("array", resultado.toString()); 84 xmlDocument.setParameter("frameName", "frameAplicacion"); 85 response.setContentType("text/html; charset=UTF-8"); 86 PrintWriter out = response.getWriter(); 87 out.println(xmlDocument.print()); 88 out.close(); 89 90 } 91 } 92 | Popular Tags |