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.base.secureApp.HttpSecureAppServlet; 25 import org.openbravo.base.secureApp.VariablesSecureApp; 26 import org.openbravo.xmlEngine.XmlDocument; 27 import java.io.*; 28 import javax.servlet.*; 29 import javax.servlet.http.*; 30 31 33 public class ReportInventory extends HttpSecureAppServlet { 34 35 36 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 37 VariablesSecureApp vars = new VariablesSecureApp(request); 38 39 if (!Utility.hasProcessAccess(this, vars, "", "ReportInventory")) { 40 bdError(response, "AccessTableNoView", vars.getLanguage()); 41 return; 42 } 43 44 if (vars.commandIn("DEFAULT")) { 45 String strmWarehouseId = vars.getStringParameter("inpmWarehouseId", vars.getWarehouse()); 46 String strDetalle = vars.getStringParameter("inpDetalle", ""); 47 printPageDataSheet(response, vars, strmWarehouseId, strDetalle); 48 } else if (vars.commandIn("FIND")) { 49 String strDetalle = vars.getStringParameter("inpDetalle"); 50 String strmWarehouseId = vars.getStringParameter("inpmWarehouseId"); 51 printPageDataHtml(response, vars, strmWarehouseId, strDetalle); 52 } else pageError(response); 53 } 54 55 void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars, String strmWarehouseId, String strDetalle) 56 throws IOException, ServletException { 57 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 58 response.setContentType("text/html; charset=UTF-8"); 59 PrintWriter out = response.getWriter(); 60 XmlDocument xmlDocument=null; 61 ReportInventoryData [] data = ReportInventoryData.selectSinDetalle(this, strmWarehouseId, Utility.getContext(this, vars, "#User_Client", "ReportInventory"), Utility.getContext(this, vars, "#User_Org", "ReportInventory")); 62 63 64 if (data.length == 0) { 65 String [] discard = {"sectionLocator"}; 66 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInventoryEdit", discard).createXmlDocument(); 67 xmlDocument.setData("structure1", ReportInventoryData.set()); 68 } else if(!strDetalle.equals("-1")){ 69 String [] discard = {"reportDetalle"}; 70 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInventoryEdit", discard).createXmlDocument(); 71 xmlDocument.setData("structure1", data); 72 } else{ 73 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInventoryEdit").createXmlDocument(); 74 75 76 ReportInventoryData [] [] subreport = new ReportInventoryData [data.length] []; 77 78 String strWarehouse = ""; 79 String strProduct = ""; 80 String strUom = ""; 81 int j = 0; 82 boolean existsAtt = false; 83 for (int i=0;i<data.length ;i++){ 84 existsAtt = false; 85 if (!(strWarehouse.equals(data[i].mLocatorId))||!(strProduct.equals(data[i].mProductId))||!(strUom.equals(data[i].productUom))) { 86 strWarehouse = data[i].mLocatorId; 87 strProduct = data[i].mProductId; 88 strUom = data[i].productUom; 89 ReportInventoryData [] data2 = ReportInventoryData.select(this, data[i].mProductId, data[i].cUomId, data[i].mLocatorId, Utility.getContext(this, vars, "#User_Client", "ReportInventory"), Utility.getContext(this, vars, "#User_Org", "ReportInventory")); 90 for (int k=0;k<data2.length ;k++ ){ 91 if (!data2[k].lot.equals("")){ 92 subreport[j] = data2; 93 existsAtt = true; 94 break; 95 } 96 } 97 if (!existsAtt) { 98 subreport[j] = new ReportInventoryData [0]; 99 } 100 j++; 101 } 102 } 103 104 xmlDocument.setDataArray("reportDetalle","structure4",subreport); 105 xmlDocument.setData("structure1", data); 106 } 107 108 109 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 110 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 111 112 out.println(xmlDocument.print()); 113 out.close(); 114 } 115 116 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strmWarehouseId, String strDetalle) 117 throws IOException, ServletException { 118 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 119 response.setContentType("text/html; charset=UTF-8"); 120 PrintWriter out = response.getWriter(); 121 XmlDocument xmlDocument=null; 122 123 124 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInventory").createXmlDocument(); 125 126 127 128 129 String strWarehouse = ""; 130 String strProduct = ""; 131 String strUom = ""; 132 int j = 0; 133 boolean existsAtt = false; 134 135 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInventory", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 136 toolbar.prepareSimpleToolBarTemplate(); 137 xmlDocument.setParameter("toolbar", toolbar.toString()); 138 try { 139 KeyMap key = new KeyMap(this, vars, "ReportInventory.html"); 140 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 141 } catch (Exception ex) { 142 throw new ServletException(ex); 143 } 144 try { 145 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInventory"); 146 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 147 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 148 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 149 xmlDocument.setParameter("theme", vars.getTheme()); 150 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInventory.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 151 xmlDocument.setParameter("navigationBar", nav.toString()); 152 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInventory.html", strReplaceWith); 153 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 154 } catch (Exception ex) { 155 throw new ServletException(ex); 156 } 157 { 158 OBError myMessage = vars.getMessage("ReportInventory"); 159 vars.removeMessage("ReportInventory"); 160 if (myMessage!=null) { 161 xmlDocument.setParameter("messageType", myMessage.getType()); 162 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 163 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 164 } 165 } 166 167 168 169 171 xmlDocument.setParameter("mWarehouseId", strmWarehouseId); 172 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 173 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 174 xmlDocument.setParameter("Detalle", strDetalle); 175 try { 176 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Warehouse_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportInventory"), Utility.getContext(this, vars, "#User_Client", "ReportInventory"), 0); 177 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInventory", strmWarehouseId); 178 xmlDocument.setData("reportM_WAREHOUSEID","liststructure", comboTableData.select(false)); 179 comboTableData = null; 180 } catch (Exception ex) { 181 throw new ServletException(ex); 182 } 183 out.println(xmlDocument.print()); 184 out.close(); 185 } 186 187 282 283 public String getServletInfo() { 284 return "Servlet ReportInventory. This Servlet was made by Eduardo Argal"; 285 } } 287 288 | Popular Tags |