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.erpCommon.businessUtility.Tree; 24 import org.openbravo.erpCommon.businessUtility.TreeData; 25 import org.openbravo.base.secureApp.HttpSecureAppServlet; 26 import org.openbravo.base.secureApp.VariablesSecureApp; 27 import org.openbravo.xmlEngine.XmlDocument; 28 import java.io.*; 29 import java.util.*; 30 import javax.servlet.*; 31 import javax.servlet.http.*; 32 33 import org.openbravo.utils.Replace; 34 import org.openbravo.erpCommon.ad_combos.OrganizationComboData; 35 36 37 import org.openbravo.erpCommon.utility.DateTimeData; 38 39 public class ReportInvoiceCustomerDimensionalAnalyses extends HttpSecureAppServlet { 40 41 42 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 43 VariablesSecureApp vars = new VariablesSecureApp(request); 44 45 if (!Utility.hasProcessAccess(this, vars, "", "RV_ReportInvoiceCustomerDimensionalAnaly")) { 46 bdError(response, "AccessTableNoView", vars.getLanguage()); 47 return; 48 } 49 50 if (vars.commandIn("DEFAULT", "DEFAULT_COMPARATIVE")){ 51 String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportInvoiceCustomerDimensionalAnalyses|dateFrom", ""); 52 String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportInvoiceCustomerDimensionalAnalyses|dateTo", ""); 53 String strDateFromRef = vars.getGlobalVariable("inpDateFromRef", "ReportInvoiceCustomerDimensionalAnalyses|dateFromRef", ""); 54 String strDateToRef = vars.getGlobalVariable("inpDateToRef", "ReportInvoiceCustomerDimensionalAnalyses|dateToRef", ""); 55 String strPartnerGroup = vars.getGlobalVariable("inpPartnerGroup", "ReportInvoiceCustomerDimensionalAnalyses|partnerGroup", ""); 56 String strcBpartnerId = vars.getInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceCustomerDimensionalAnalyses|partner", ""); 57 String strProductCategory = vars.getGlobalVariable("inpProductCategory", "ReportInvoiceCustomerDimensionalAnalyses|productCategory", ""); 58 String strmProductId = vars.getInGlobalVariable("inpmProductId_IN", "ReportInvoiceCustomerDimensionalAnalyses|product", ""); 59 String strNotShown = vars.getInGlobalVariable("inpNotShown", "ReportInvoiceCustomerDimensionalAnalyses|notShown", ""); 60 String strShown = vars.getInGlobalVariable("inpShown", "ReportInvoiceCustomerDimensionalAnalyses|shown", ""); 61 String strOrg = vars.getGlobalVariable("inpOrg", "ReportInvoiceCustomerDimensionalAnalyses|org", "0"); 62 String strsalesrepId = vars.getGlobalVariable("inpSalesrepId", "ReportInvoiceCustomerDimensionalAnalyses|salesrep", ""); 63 String strcProjectId = vars.getGlobalVariable("inpcProjectId", "ReportInvoiceCustomerDimensionalAnalyses|project", ""); 64 String strProducttype = vars.getGlobalVariable("inpProducttype", "ReportInvoiceVendorDimensionalAnalyses|producttype", ""); 65 String strOrder = vars.getGlobalVariable("inpOrder","ReportInvoiceCustomerDimensionalAnalyze|order","Normal"); 66 String strMayor = vars.getGlobalVariable("inpMayor", "ReportInvoiceCustomerSalesDimensionalAnalyze|mayor", ""); 67 String strMenor = vars.getGlobalVariable("inpMenor", "ReportInvoiceCustomerDimensionalAnalyze|menor", ""); 68 String strPartnerSalesRepId = vars.getGlobalVariable("inpPartnerSalesrepId", "ReportInvoiceCustomerDimensionalAnalyses|partnersalesrep", ""); 69 String strComparative = ""; 70 if (vars.commandIn("DEFAULT_COMPARATIVE")) strComparative = vars.getRequestGlobalVariable("inpComparative", "ReportInvoiceCustomerDimensionalAnalyses|comparative"); 71 else strComparative = vars.getGlobalVariable("inpComparative", "ReportInvoiceCustomerDimensionalAnalyses|comparative", "N"); 72 printPageDataSheet(response, vars, strComparative, strDateFrom, strDateTo, strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strNotShown, strShown, 73 strDateFromRef, strDateToRef, strOrg, strsalesrepId, strcProjectId, strProducttype, strOrder, strMayor, strMenor, strPartnerSalesRepId); 74 }else if (vars.commandIn("EDIT_HTML", "EDIT_HTML_COMPARATIVE")) { 75 String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportInvoiceCustomerDimensionalAnalyses|dateFrom"); 76 String strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportSInvoiceCustomerDimensionalAnalyses|dateTo"); 77 String strDateFromRef = vars.getRequestGlobalVariable("inpDateFromRef", "ReportInvoiceCustomerDimensionalAnalyses|dateFromRef"); 78 String strDateToRef = vars.getRequestGlobalVariable("inpDateToRef", "ReportSInvoiceCustomerDimensionalAnalyses|dateToRef"); 79 String strPartnerGroup = vars.getRequestGlobalVariable("inpPartnerGroup", "ReportInvoiceCustomerDimensionalAnalyses|partnerGroup"); 80 String strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceCustomerDimensionalAnalyses|partner"); 81 String strProductCategory = vars.getRequestGlobalVariable("inpProductCategory", "ReportInvoiceCustomerDimensionalAnalyses|productCategory"); 82 String strmProductId = vars.getRequestInGlobalVariable("inpmProductId_IN", "ReportInvoiceCustomerDimensionalAnalyses|product"); 83 String strNotShown = vars.getInStringParameter("inpNotShown"); 84 String strShown = vars.getInStringParameter("inpShown"); 85 String strOrg = vars.getGlobalVariable("inpOrg", "ReportInvoiceCustomerDimensionalAnalyses|org", "0"); 86 String strsalesrepId = vars.getRequestGlobalVariable("inpSalesrepId", "ReportInvoiceCustomerDimensionalAnalyses|salesrep"); 87 String strcProjectId = vars.getRequestGlobalVariable("inpcProjectId", "ReportInvoiceCustomerDimensionalAnalyses|project"); 88 String strProducttype = vars.getRequestGlobalVariable("inpProducttype", "ReportInvoiceVendorDimensionalAnalyses|producttype"); 89 String strOrder = vars.getRequestGlobalVariable("inpOrder","ReportSalesDimensionalAnalyze|order"); 90 String strMayor = vars.getStringParameter("inpMayor", ""); 91 String strMenor = vars.getStringParameter("inpMenor", ""); 92 String strComparative = vars.getStringParameter("inpComparative", "N"); 93 String strPartnerSalesrepId = vars.getRequestGlobalVariable("inpPartnerSalesrepId", "ReportInvoiceCustomerDimensionalAnalyses|partnersalesrep"); 94 printPageHtml(response, vars, strComparative, strDateFrom, strDateTo, strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strNotShown, strShown, 95 strDateFromRef, strDateToRef, strOrg, strsalesrepId, strcProjectId, strProducttype, strOrder, strMayor, strMenor, strPartnerSalesrepId); 96 } else pageErrorPopUp(response); 97 } 98 99 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strComparative, String strDateFrom, String strDateTo, String strPartnerGroup, String strcBpartnerId, String strProductCategory, String strmProductId, String strNotShown, String strShown, String strDateFromRef, String strDateToRef, String strOrg, String strsalesrepId, String strcProjectId, String strProducttype, String strOrder, String strMayor, String strMenor, String strPartnerSalesrepId) throws IOException, ServletException { 100 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 101 String discard[]={"selEliminarHeader1"}; 102 if (strComparative.equals("Y")) { 103 discard[0] = "selEliminarHeader2"; 104 } 105 XmlDocument xmlDocument=null; 106 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesFilter", discard).createXmlDocument(); 107 108 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoiceCustomerDimensionalAnalysesFilter", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 109 toolbar.prepareSimpleToolBarTemplate(); 110 xmlDocument.setParameter("toolbar", toolbar.toString()); 111 try { 112 KeyMap key = new KeyMap(this, vars, "ReportInvoiceCustomerDimensionalAnalyses.html"); 113 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 114 } catch (Exception ex) { 115 throw new ServletException(ex); 116 } 117 try { 118 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoiceCustomerDimensionalAnalyses"); 119 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 120 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 121 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 122 xmlDocument.setParameter("theme", vars.getTheme()); 123 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoiceCustomerDimensionalAnalyses.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 124 xmlDocument.setParameter("navigationBar", nav.toString()); 125 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoiceCustomerDimensionalAnalyses.html", strReplaceWith); 126 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 127 } catch (Exception ex) { 128 throw new ServletException(ex); 129 } 130 { 131 OBError myMessage = vars.getMessage("ReportInvoiceCustomerDimensionalAnalyses"); 132 vars.removeMessage("ReportInvoiceCustomerDimensionalAnalyses"); 133 if (myMessage!=null) { 134 xmlDocument.setParameter("messageType", myMessage.getType()); 135 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 136 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 137 } 138 } 139 140 141 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 142 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 143 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 144 xmlDocument.setParameter("dateFrom", strDateFrom); 145 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 146 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 147 xmlDocument.setParameter("dateTo", strDateTo); 148 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 149 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 150 xmlDocument.setParameter("dateFromRef", strDateFromRef); 151 xmlDocument.setParameter("dateFromRefdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 152 xmlDocument.setParameter("dateFromRefsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 153 xmlDocument.setParameter("dateToRef", strDateToRef); 154 xmlDocument.setParameter("dateToRefdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 155 xmlDocument.setParameter("dateToRefsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 156 160 xmlDocument.setParameter("cBpGroupId", strPartnerGroup); 161 xmlDocument.setParameter("mProductCategoryId", strProductCategory); 162 xmlDocument.setParameter("adOrgId", strOrg); 163 xmlDocument.setParameter("salesRepId", strsalesrepId); 164 xmlDocument.setParameter("normal", strOrder); 165 xmlDocument.setParameter("amountasc", strOrder); 166 xmlDocument.setParameter("amountdesc", strOrder); 167 xmlDocument.setParameter("mayor", strMayor); 168 xmlDocument.setParameter("menor", strMenor); 169 xmlDocument.setParameter("comparative", strComparative); 170 xmlDocument.setParameter("cProjectId", strcProjectId); 171 xmlDocument.setParameter("producttype", strProducttype); 172 xmlDocument.setParameter("partnerSalesRepId", strPartnerSalesrepId); 173 xmlDocument.setParameter("projectName", ReportInvoiceCustomerDimensionalAnalysesData.selectProject(this, strcProjectId)); 174 try { 175 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "C_BP_Group_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerDimensionalAnalyses"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalyses"), 0); 176 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerDimensionalAnalyses", strPartnerGroup); 177 xmlDocument.setData("reportC_BP_GROUPID","liststructure", comboTableData.select(false)); 178 comboTableData = null; 179 } catch (Exception ex) { 180 throw new ServletException(ex); 181 } 182 183 184 try { 185 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Product_Category_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerDimensionalAnalyses"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalyses"), 0); 186 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerDimensionalAnalyses", strProductCategory); 187 xmlDocument.setData("reportM_PRODUCT_CATEGORYID","liststructure", comboTableData.select(false)); 188 comboTableData = null; 189 } catch (Exception ex) { 190 throw new ServletException(ex); 191 } 192 193 xmlDocument.setData("reportAD_ORGID", "liststructure", OrganizationComboData.selectCombo(this, vars.getRole())); 194 try { 195 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLE", "SalesRep_ID", "AD_User SalesRep", "", Utility.getContext(this, vars, "#User_Org", "ReportSalesDimensionalAnalyze"), Utility.getContext(this, vars, "#User_Client", "ReportSalesDimensionalAnalyze"), 0); 196 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportSalesDimensionalAnalyze", strsalesrepId); 197 xmlDocument.setData("reportSalesRep_ID","liststructure", comboTableData.select(false)); 198 comboTableData = null; 199 } catch (Exception ex) { 200 throw new ServletException(ex); 201 } 202 203 xmlDocument.setData("reportCBPartnerId_IN", "liststructure", ReportRefundInvoiceCustomerDimensionalAnalysesData.selectBpartner(this, Utility.getContext(this, vars, "#User_Org", ""), Utility.getContext(this, vars, "#User_Client", ""), strcBpartnerId)); 204 xmlDocument.setData("reportMProductId_IN", "liststructure", ReportRefundInvoiceCustomerDimensionalAnalysesData.selectMproduct(this, Utility.getContext(this, vars, "#User_Org", ""), Utility.getContext(this, vars, "#User_Client", ""), strmProductId)); 205 206 try { 207 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "M_Product_ProductType", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerDimensionalAnalyses"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalyses"), 0); 208 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerDimensionalAnalyses", ""); 209 xmlDocument.setData("reportProductType","liststructure", comboTableData.select(false)); 210 comboTableData = null; 211 } catch (Exception ex) { 212 throw new ServletException(ex); 213 } 214 215 try { 216 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLE", "", "C_BPartner SalesRep", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerDimensionalAnalyses"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalyses"), 0); 217 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerDimensionalAnalyses", strPartnerSalesrepId); 218 xmlDocument.setData("reportPartnerSalesRep_ID","liststructure", comboTableData.select(false)); 219 comboTableData = null; 220 } catch (Exception ex) { 221 throw new ServletException(ex); 222 } 223 224 225 if (vars.getLanguage().equals("en_US")) { 226 xmlDocument.setData("structure1", ReportInvoiceCustomerDimensionalAnalysesData.selectNotShown(this, strShown)); 227 xmlDocument.setData("structure2", strShown.equals("")?new ReportInvoiceCustomerDimensionalAnalysesData[0]:ReportInvoiceCustomerDimensionalAnalysesData.selectShown(this, strShown)); 228 } else { 229 xmlDocument.setData("structure1", ReportInvoiceCustomerDimensionalAnalysesData.selectNotShownTrl(this, vars.getLanguage(), strShown)); 230 xmlDocument.setData("structure2", strShown.equals("")?new ReportInvoiceCustomerDimensionalAnalysesData[0]:ReportInvoiceCustomerDimensionalAnalysesData.selectShownTrl(this, vars.getLanguage(), strShown)); 231 } 232 233 response.setContentType("text/html; charset=UTF-8"); 234 PrintWriter out = response.getWriter(); 235 out.println(xmlDocument.print()); 236 out.close(); 237 } 238 239 void printPageHtml(HttpServletResponse response, VariablesSecureApp vars, String strComparative, String strDateFrom, String strDateTo, String strPartnerGroup, String strcBpartnerId, String strProductCategory, String strmProductId, String strNotShown, String strShown, String strDateFromRef, String strDateToRef, String strOrg, String strsalesrepId, String strcProjectId, String strProducttype, String strOrder, String strMayor, String strMenor, String strPartnerSalesrepId) throws IOException, ServletException{ 240 if (log4j.isDebugEnabled()) log4j.debug("Output: print html"); 241 XmlDocument xmlDocument=null; 242 String strOrderby = ""; 243 String [] discard = {"", "", "", "", "","", "", "", "", ""}; 244 String [] discard1={"selEliminarBody1", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard", "discard"}; 245 if (strComparative.equals("Y")) discard1[0] = "selEliminarBody2"; 246 String strTitle = ""; 247 strTitle = Utility.messageBD(this, "From", vars.getLanguage()) + " "+strDateFrom+" " + Utility.messageBD(this, "To", vars.getLanguage()) + " "+strDateTo; 248 if (!strPartnerGroup.equals("")) strTitle = strTitle + ", " + Utility.messageBD(this, "ForBPartnerGroup", vars.getLanguage()) + " "+ReportInvoiceCustomerDimensionalAnalysesData.selectBpgroup(this, strPartnerGroup); 249 250 if (!strProductCategory.equals("")) strTitle = strTitle+", " + Utility.messageBD(this, "ProductCategory", vars.getLanguage()) + " "+ReportInvoiceCustomerDimensionalAnalysesData.selectProductCategory(this, strProductCategory); 251 if (!strcProjectId.equals("")) strTitle = strTitle+", " + Utility.messageBD(this, "Project", vars.getLanguage()) + " "+ReportInvoiceCustomerDimensionalAnalysesData.selectProject(this, strcProjectId); 252 if (!strProducttype.equals("")) strTitle = strTitle+", " + Utility.messageBD(this, "PRODUCTTYPE", vars.getLanguage()) + " "+ReportInvoiceCustomerDimensionalAnalysesData.selectProducttype(this, "270", vars.getLanguage(), strProducttype); 253 if (!strsalesrepId.equals("")) strTitle = strTitle+", " + Utility.messageBD(this, "TheClientSalesRep", vars.getLanguage()) + " "+ReportInvoiceCustomerDimensionalAnalysesData.selectSalesrep(this, strsalesrepId); 254 if (!strPartnerSalesrepId.equals("")) strTitle = strTitle+" " + Utility.messageBD(this, "And", vars.getLanguage()) + " " + Utility.messageBD(this, "TheClientSalesRep", vars.getLanguage()) + " "+ReportInvoiceCustomerDimensionalAnalysesData.selectSalesrep(this, strPartnerSalesrepId); 255 256 ReportInvoiceCustomerDimensionalAnalysesData[] data = null; 257 String [] strShownArray = {"", "", "", "", "", "", "", "", "", ""}; 258 if (strShown.startsWith("(")) strShown = strShown.substring(1, strShown.length()-1); 259 if (!strShown.equals("")) { 260 strShown = Replace.replace(strShown, "'", ""); 261 strShown = Replace.replace(strShown, " ", ""); 262 StringTokenizer st = new StringTokenizer(strShown, ",", false); 263 int intContador = 0; 264 while (st.hasMoreTokens()){ 265 strShownArray[intContador] = st.nextToken(); 266 intContador++; 267 } 268 269 } 270 String [] strTextShow = {"", "", "", "", "","", "", "", "", ""}; 271 int intDiscard = 0; 272 int intOrder = 0; 273 int intAuxDiscard = -1; 274 for (int i = 0; i<10; i++){ 275 if (strShownArray[i].equals("1")) { 276 strTextShow[i] = "C_BP_GROUP.NAME"; 277 intDiscard++; 278 intOrder++; 279 } 280 else if (strShownArray[i].equals("2")) { 281 strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('C_Bpartner'), to_char( C_BPARTNER.C_BPARTNER_ID), to_char( 'es_ES'))"; 282 intDiscard++; 283 intOrder++; 284 } 285 else if (strShownArray[i].equals("3")) { 286 strTextShow[i] = "M_PRODUCT_CATEGORY.NAME"; 287 intDiscard++; 288 intOrder++; 289 } 290 else if (strShownArray[i].equals("4")) { 291 strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('M_Product'), to_char( M_PRODUCT.M_PRODUCT_ID), to_char( 'es_ES'))||' ('||UOMSYMBOL||')'"; 292 intAuxDiscard = i; 293 intOrder++; 294 } 295 else if (strShownArray[i].equals("5")) { 296 strTextShow[i] = "C_INVOICE.DOCUMENTNO"; 297 intDiscard++; 298 intOrder++; 299 } 300 else if (strShownArray[i].equals("6")) { 301 strTextShow[i] = "AD_USER.FIRSTNAME||' '||' '||AD_USER.LASTNAME"; 302 intDiscard++; 303 intOrder++; 304 } 305 else if (strShownArray[i].equals("8")) { 306 strTextShow[i] = "AD_ORG.NAME"; 307 intDiscard++; 308 intOrder++; 309 } 310 else if (strShownArray[i].equals("9")) { 311 strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('C_Bpartner'), to_char( CB.C_BPARTNER_ID), to_char( 'es_ES'))"; 312 intDiscard++; 313 intOrder++; 314 } 315 else if (strShownArray[i].equals("10")) { 316 strTextShow[i] = "C_PROJECT.NAME"; 317 intDiscard++; 318 intOrder++; 319 } 320 else if (strShownArray[i].equals("11")) { 321 strTextShow[i] = "AD_COLUMN_IDENTIFIER(to_char('C_Bpartner_Location'), to_char( M_INOUT.C_BPARTNER_LOCATION_ID), to_char( 'es_ES'))"; 322 intDiscard++; 323 intOrder++; 324 } 325 else { 326 strTextShow[i] = "''"; 327 discard[i] = "display:none;"; 328 } 329 } 330 if (intOrder != 0 || intAuxDiscard != -1){ 331 int k=1; 332 strOrderby = " ORDER BY NIVEL"+k+","; 333 while (k<intOrder){ 334 strOrderby = strOrderby+"NIVEL"+k+","; 335 k++; 336 } 337 if (k==1){ 338 if (strOrder.equals("Normal")){ 339 strOrderby = " ORDER BY NIVEL"+k; 340 } else if (strOrder.equals("Amountasc")){ 341 strOrderby = " ORDER BY LINENETAMT ASC"; 342 } else if (strOrder.equals("Amountdesc")){ 343 strOrderby = " ORDER BY LINENETAMT DESC"; 344 } else{ 345 strOrderby = "1"; 346 } 347 } else{ 348 if (strOrder.equals("Normal")){ 349 strOrderby += "NIVEL"+k; 350 } else if (strOrder.equals("Amountasc")){ 351 strOrderby += "LINENETAMT ASC"; 352 } else if (strOrder.equals("Amountdesc")){ 353 strOrderby += "LINENETAMT DESC"; 354 } else{ 355 strOrderby = "1"; 356 } 357 } 358 359 } else{ 360 strOrderby = " ORDER BY 1"; 361 } 362 String strHaving = ""; 363 if (!strMayor.equals("") && !strMenor.equals("")) {strHaving = " HAVING SUM(LINENETAMT) > "+strMayor+" AND SUM(LINENETAMT) < "+strMenor;} 364 else if (!strMayor.equals("") && strMenor.equals("")) {strHaving = " HAVING SUM(LINENETAMT) > "+strMayor;} 365 else if (strMayor.equals("") && !strMenor.equals("")) {strHaving = " HAVING SUM(LINENETAMT) < "+strMenor;} 366 else{ strHaving = " HAVING SUM(LINENETAMT) <> 0 OR SUM(LINENETREF) <> 0";} 367 strOrderby = strHaving + strOrderby; 368 if (strComparative.equals("Y")){ 369 data = ReportInvoiceCustomerDimensionalAnalysesData.select(this, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], strTextShow[5], strTextShow[6], strTextShow[7], strTextShow[8], strTextShow[9], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalyses"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strsalesrepId, strPartnerSalesrepId, strcProjectId, strProducttype, strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef,"1"), strOrderby); 370 } else { 371 data = ReportInvoiceCustomerDimensionalAnalysesData.selectNoComparative(this, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], strTextShow[5], strTextShow[6], strTextShow[7], strTextShow[8], strTextShow[9], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalyses"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strsalesrepId, strPartnerSalesrepId, strcProjectId, strProducttype, strOrderby); 372 } 373 if (data.length == 0 || data == null){ 374 data = ReportInvoiceCustomerDimensionalAnalysesData.set(); 376 } else { 377 int contador = intDiscard; 378 if (intAuxDiscard != -1) contador = intAuxDiscard; 379 int k = 1; 380 if (strComparative.equals("Y")){ 381 for (int j = contador; j>0; j--){ 382 discard1[k] = "fieldTotalQtyNivel"+String.valueOf(j); 383 discard1[k+10] = "fieldTotalRefQtyNivel"+String.valueOf(j); 384 discard1[k+20] = "fieldTotalQty"+String.valueOf(j); 385 k++; 389 } 390 } else { 391 for (int j = contador; j>0; j--){ 392 discard1[k] = "fieldNoncomparativeTotalQtyNivel"+String.valueOf(j); 393 discard1[k+20] = "fieldNoncomparativeTotalQty"+String.valueOf(j); 394 k++; 397 } 398 } 399 400 } 401 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesEdition", discard1).createXmlDocument(); 402 xmlDocument.setParameter("eliminar2", discard[1]); 403 xmlDocument.setParameter("eliminar3", discard[2]); 404 xmlDocument.setParameter("eliminar4", discard[3]); 405 xmlDocument.setParameter("eliminar5", discard[4]); 406 xmlDocument.setParameter("eliminar6", discard[5]); 407 xmlDocument.setParameter("eliminar7", discard[6]); 408 xmlDocument.setParameter("eliminar8", discard[7]); 409 xmlDocument.setParameter("eliminar9", discard[8]); 410 xmlDocument.setParameter("eliminar10", discard[9]); 411 xmlDocument.setParameter("total", ReportInvoiceCustomerDimensionalAnalysesData.selectTotal(this,Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerDimensionalAnalyses"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strsalesrepId, strPartnerSalesrepId, strcProjectId, strProducttype)); 412 xmlDocument.setParameter("title", strTitle); 413 xmlDocument.setParameter("constante", "100"); 414 if (strComparative.equals("Y")){ 415 xmlDocument.setData("structure1", data); 416 } else { 417 xmlDocument.setData("structure2", data); 418 } 419 420 response.setContentType("text/html; charset=UTF-8"); 421 PrintWriter out = response.getWriter(); 422 out.println(xmlDocument.print()); 423 out.close(); 424 } 425 426 public String getServletInfo() { 427 return "Servlet ReportInvoiceCustomerDimensionalAnalyses. This Servlet was made by Jon AlegrÃa"; 428 } } 430 431 | Popular Tags |