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