1 19 package org.openbravo.erpCommon.ad_reports; 20 21 import org.openbravo.erpCommon.utility.*; 22 import org.openbravo.erpCommon.businessUtility.WindowTabs; 23 import org.openbravo.base.secureApp.HttpSecureAppServlet; 24 import org.openbravo.base.secureApp.VariablesSecureApp; 25 import org.openbravo.xmlEngine.XmlDocument; 26 import java.io.*; 27 import javax.servlet.*; 28 import javax.servlet.http.*; 29 30 import org.openbravo.erpCommon.ad_combos.AccountNumberComboData; 31 32 import org.openbravo.erpCommon.utility.DateTimeData; 33 34 public class ReportDebtPayment extends HttpSecureAppServlet { 35 36 37 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 38 VariablesSecureApp vars = new VariablesSecureApp(request); 39 40 if (!Utility.hasProcessAccess(this, vars, "", "RV_ReportDebtPayment")) { 41 bdError(response, "AccessTableNoView", vars.getLanguage()); 42 return; 43 } 44 45 if (vars.commandIn("DEFAULT", "DIRECT")) { 46 String strcbankaccount = vars.getGlobalVariable("inpmProductId", "ReportDebtPayment|C_Bankaccount_ID", ""); 47 String strC_BPartner_ID = vars.getGlobalVariable("inpBpartnerId", "ReportDebtPayment|C_BPartner_ID", ""); 48 String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportDebtPayment|DateFrom", ""); 49 String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportDebtPayment|DateTo", ""); 50 String strCal1 = vars.getGlobalVariable("inpCal1", "ReportDebtPayment|Cal1", ""); 51 String strCalc2 = vars.getGlobalVariable("inpCalc2", "ReportDebtPayment|Cal2", ""); 52 String strPaymentRule = vars.getGlobalVariable("inpCPaymentRuleId", "ReportDebtPayment|PaymentRule", ""); 53 String strSettle = vars.getGlobalVariable("inpSettle", "ReportDebtPayment|Settle", ""); 54 String strConciliate = vars.getGlobalVariable("inpConciliate", "ReportDebtPayment|Conciliate", ""); 55 String strStatus = vars.getGlobalVariable("inpStatus", "ReportDebtPayment|Status", ""); 56 String strGroup = vars.getGlobalVariable("inpGroup", "ReportDebtPayment|Group", "isGroup"); 57 String strPending = ""; 58 String strReceipt = ""; 59 if (vars.commandIn("DIRECT")) { 60 strReceipt = vars.getGlobalVariable("inpReceipt", "ReportDebtPayment|Receipt", "N"); 61 strPending = vars.getGlobalVariable("inpPending", "ReportDebtPayment|Pending", ""); 62 } 63 else { 64 strReceipt = vars.getGlobalVariable("inpReceipt", "ReportDebtPayment|Receipt", "Y"); 65 strPending = vars.getGlobalVariable("inpPending", "ReportDebtPayment|Pending", "isPending"); 66 } 67 setHistoryCommand(request, "DIRECT"); 69 printPageDataSheet(response, vars, strC_BPartner_ID, strDateFrom, strDateTo, strCal1, strCalc2, strPaymentRule, strSettle, strConciliate, strReceipt, strPending, strcbankaccount, strStatus, strGroup); 70 } else if (vars.commandIn("FIND")) { 71 String strcbankaccount = vars.getRequestGlobalVariable("inpcBankAccountId", "ReportDebtPayment|C_Bankaccount_ID"); 72 String strC_BPartner_ID = vars.getRequestGlobalVariable("inpBpartnerId", "ReportDebtPayment|C_BPartner_ID"); 73 String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportDebtPayment|DateFrom"); 74 String strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportDebtPayment|DateTo"); 75 String strCal1 = vars.getRequestGlobalVariable("inpCal1", "ReportDebtPayment|Cal1"); 76 String strCalc2 = vars.getRequestGlobalVariable("inpCal2", "ReportDebtPayment|Cal2"); 77 String strPaymentRule = vars.getRequestGlobalVariable("inpCPaymentRuleId", "ReportDebtPayment|PaymentRule"); 78 String strSettle = vars.getRequestGlobalVariable("inpSettle", "ReportDebtPayment|Settle"); 79 String strConciliate = vars.getRequestGlobalVariable("inpConciliate", "ReportDebtPayment|Conciliate"); 80 String strPending = vars.getRequestGlobalVariable("inpPending", "ReportDebtPayment|Pending"); 81 String strGroup = vars.getRequestGlobalVariable("inpGroup", "ReportDebtPayment|Group"); 82 String strStatus = vars.getRequestGlobalVariable("inpStatus", "ReportDebtPayment|Status"); 83 String strReceipt = vars.getStringParameter("inpReceipt").equals("")?"N":vars.getStringParameter("inpReceipt"); 85 vars.setSessionValue("ReportDebtPayment|Receipt", strReceipt); 86 setHistoryCommand(request, "DIRECT"); 88 printPageDataSheet(response, vars, strC_BPartner_ID, strDateFrom, strDateTo, strCal1, strCalc2, strPaymentRule, strSettle, strConciliate, strReceipt, strPending, strcbankaccount, strStatus, strGroup); 89 } else pageError(response); 90 } 91 92 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strC_BPartner_ID, String strDateFrom, String strDateTo, String strCal1, String strCalc2, String strPaymentRule, String strSettle, String strConciliate, String strReceipt, String strPending , String strcbankaccount, String strStatus, String strGroup) 93 throws IOException, ServletException { 94 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 95 response.setContentType("text/html; charset=UTF-8"); 96 PrintWriter out = response.getWriter(); 97 String discard[]={"discard", "discard2", "discard3"}; 98 String strAux = ""; 99 if (log4j.isDebugEnabled()) log4j.debug("strGroup = " + strGroup); 100 if (strPending.equals("") && strConciliate.equals("") && strSettle.equals("")) { 101 strAux = ""; 102 } else { 103 if (strPending.equals("isPending")) { 104 strAux = "'Pendientes'"; 105 } 106 if (strConciliate.equals("isConciliate")) { 107 if (!strAux.equals("")) { 108 strAux = strAux + ","; 109 } 110 strAux = strAux + "'Conciliados'"; 111 } 112 if (strSettle.equals("isSettle")) { 113 if (!strAux.equals("")) { 114 strAux = strAux + ","; 115 } 116 strAux = strAux + "'Saldados'"; 117 } 118 strAux = "(" + strAux + ")"; 119 } 120 XmlDocument xmlDocument; 121 ReportDebtPaymentData[] data = null; 122 if(!strGroup.equals("")) data= ReportDebtPaymentData.select(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", "ReportDebtPayment"), Utility.getContext(this, vars, "#User_Org", "ReportDebtPayment"), strC_BPartner_ID, strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strCal1, strCalc2, strPaymentRule, strReceipt, strStatus, strAux, strcbankaccount); 123 else data= ReportDebtPaymentData.selectNoBpartner(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", "ReportDebtPayment"), Utility.getContext(this, vars, "#User_Org", "ReportDebtPayment"), strC_BPartner_ID, strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strCal1, strCalc2, strPaymentRule, strReceipt, strStatus, strAux, strcbankaccount); 124 if (data == null || data.length == 0) { 125 data = ReportDebtPaymentData.set(); 126 discard[0] = "sectionBpartner"; 127 discard[1] = "sectionStatus2"; 128 discard[2] = "sectionTotal2"; 129 } 130 131 if(!strGroup.equals("")){ 132 discard[0] = "sectionDetail2"; 133 discard[1] = "sectionStatus2"; 134 discard[2] = "sectionTotal2"; 135 } else { 136 discard[0] = "sectionBpartner"; 137 discard[1] = "sectionTotal"; 138 } 139 if (vars.commandIn("DEFAULT")) { 140 discard[0] = "sectionBpartner"; 141 discard[1] = "sectionStatus2"; 142 discard[2] = "sectionTotal2"; 143 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportDebtPayment", discard).createXmlDocument(); 144 data = ReportDebtPaymentData.set(); 145 } else { 146 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportDebtPayment", discard).createXmlDocument(); 147 } 148 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportDebtPayment", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 149 toolbar.prepareSimpleToolBarTemplate(); 150 xmlDocument.setParameter("toolbar", toolbar.toString()); 151 152 try { 153 KeyMap key = new KeyMap(this, vars, "ReportDebtPayment.html"); 154 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 155 } catch (Exception ex) { 156 throw new ServletException(ex); 157 } 158 try { 159 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportDebtPayment"); 160 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 161 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 162 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 163 xmlDocument.setParameter("theme", vars.getTheme()); 164 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportDebtPayment.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 165 xmlDocument.setParameter("navigationBar", nav.toString()); 166 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportDebtPayment.html", strReplaceWith); 167 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 168 } catch (Exception ex) { 169 throw new ServletException(ex); 170 } 171 { 172 OBError myMessage = vars.getMessage("ReportDebtPayment"); 173 vars.removeMessage("ReportDebtPayment"); 174 if (myMessage!=null) { 175 xmlDocument.setParameter("messageType", myMessage.getType()); 176 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 177 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 178 } 179 } 180 181 182 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 183 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 184 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 185 xmlDocument.setParameter("cBankAccount", strcbankaccount); 186 xmlDocument.setData("reportC_ACCOUNTNUMBER","liststructure",AccountNumberComboData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportDebtPayment"), Utility.getContext(this, vars, "#User_Org", "ReportDebtPayment"))); 187 xmlDocument.setParameter("paramBPartnerId", strC_BPartner_ID); 188 xmlDocument.setParameter("dateFrom", strDateFrom); 189 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 190 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 191 xmlDocument.setParameter("dateTo", strDateTo); 192 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 193 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 194 xmlDocument.setParameter("amountFrom", strCal1); 195 xmlDocument.setParameter("amountTo", strCalc2); 196 xmlDocument.setParameter("paymentRule", strPaymentRule); 197 xmlDocument.setParameter("settle", strSettle); 198 xmlDocument.setParameter("conciliate", strConciliate); 199 xmlDocument.setParameter("pending", strPending); 200 xmlDocument.setParameter("receipt", strReceipt); 201 xmlDocument.setParameter("payable", strReceipt); 202 xmlDocument.setParameter("status", strStatus); 203 xmlDocument.setParameter("group", strGroup); 204 if (log4j.isDebugEnabled()) log4j.debug("diacard = " + discard[0] + " - " + discard[1] + " - " + discard[2]); 205 xmlDocument.setParameter("paramBPartnerDescription", ReportDebtPaymentData.bPartnerDescription(this, strC_BPartner_ID)); 206 if (log4j.isDebugEnabled()) log4j.debug("ListData.select PaymentRule:"+strPaymentRule); 207 try { 208 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "All_Payment Rule", "", Utility.getContext(this, vars, "#User_Org", "ReportDebtPayment"), Utility.getContext(this, vars, "#User_Client", "ReportDebtPayment"), 0); 209 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportDebtPayment", strPaymentRule); 210 xmlDocument.setData("reportPaymentRule","liststructure", comboTableData.select(false)); 211 comboTableData = null; 212 } catch (Exception ex) { 213 throw new ServletException(ex); 214 } 215 if (log4j.isDebugEnabled()) log4j.debug("ListData.select Status:"+strPaymentRule); 216 try { 217 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "C_DP_Management_Status", "", Utility.getContext(this, vars, "#User_Org", "ReportDebtPayment"), Utility.getContext(this, vars, "#User_Client", "ReportDebtPayment"), 0); 218 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportDebtPayment", strStatus); 219 xmlDocument.setData("reportStatus","liststructure", comboTableData.select(false)); 220 comboTableData = null; 221 } catch (Exception ex) { 222 throw new ServletException(ex); 223 } 224 xmlDocument.setData(!strGroup.equals("")?"structure1":"structure2", data); 225 out.println(xmlDocument.print()); 226 out.close(); 227 } 228 229 public String getServletInfo() { 230 return "Servlet ReportDebtPayment. This Servlet was made by Pablo Sarobe"; 231 } } 233 234 | Popular Tags |