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