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 public class ReportShipper extends HttpSecureAppServlet { 31 32 33 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 34 VariablesSecureApp vars = new VariablesSecureApp(request); 35 36 if (vars.commandIn("DEFAULT")) { 37 String strFrom = vars.getGlobalVariable("inpFrom", "ReportShipper|From", ""); 38 String strTo = vars.getGlobalVariable("inpTo", "ReportShipper|To", ""); 39 String strShipper = vars.getGlobalVariable("inpShipper", "ReportShipper|Shipper", ""); 40 String strSale = vars.getGlobalVariable("inpSale", "ReportShipper|Sale", "N"); 41 String strPurchase = vars.getGlobalVariable("inpPurchase", "ReportShipper|Purchase", "N"); 42 String strDetail = vars.getGlobalVariable("inpDetail", "ReportShipper|Detail", "N"); 43 printPageDataSheet(response, vars, strFrom, strTo, strShipper, strSale, strPurchase, strDetail); 44 } else if (vars.commandIn("FIND")) { 45 String strFrom = vars.getRequestGlobalVariable("inpFrom", "ReportShipper|From"); 46 String strTo = vars.getRequestGlobalVariable("inpTo", "ReportShipper|To"); 47 String strShipper = vars.getRequestGlobalVariable("inpShipper", "ReportShipper|Shipper"); 48 String strSale = vars.getRequestGlobalVariable("inpSale", "ReportShipper|Sale"); 49 String strPurchase = vars.getRequestGlobalVariable("inpPurchase", "ReportShipper|Purchase"); 50 String strDetail = vars.getRequestGlobalVariable("inpDetail", "ReportShipper|Detail"); 51 printPageDataSheet(response, vars, strFrom, strTo, strShipper, strSale, strPurchase, strDetail); 52 } else pageError(response); 53 } 54 55 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strFrom, String strTo, String strShipper, String strSale, String strPurchase, String strDetail) 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 ReportShipperData[] data=null; 62 63 String discard[]= {""}; 64 if (!strDetail.equals("Y")) discard[0] = "reportLine"; 65 if (vars.commandIn("DEFAULT")) discard[0] = "selEliminar"; 66 67 68 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportShipper", discard).createXmlDocument(); 69 70 String strIsSOTrx = ""; 71 if (strSale.equals("Y") && !strPurchase.equals("Y")) strIsSOTrx = "Y"; 72 else if (!strSale.equals("Y") && strPurchase.equals("Y")) strIsSOTrx = "N"; 73 else if (!strSale.equals("Y") && !strPurchase.equals("Y")) strIsSOTrx = "D"; 74 75 if (log4j.isDebugEnabled()) log4j.debug("****data passed from: " + strFrom + " to: " +strTo + " shiper: " + strShipper + " isso " + strIsSOTrx + " det " + strDetail); 76 data = ReportShipperData.select(this, vars.getLanguage(), strFrom, strTo, strShipper, strIsSOTrx); 77 78 ReportShipperData[][] dataLine = new ReportShipperData[0][0]; 79 if (data != null && data.length > 0) { 80 dataLine = new ReportShipperData[data.length][]; 81 82 for (int i=0; i<data.length ; i++) { 83 if (log4j.isDebugEnabled()) log4j.debug("shipment " + data[i].shipmentid); 84 dataLine[i] = ReportShipperData.selectLine(this, vars.getLanguage(), data[i].shipmentid); 85 } 87 } 89 90 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportShipper", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 91 toolbar.prepareSimpleToolBarTemplate(); 92 xmlDocument.setParameter("toolbar", toolbar.toString()); 93 94 try { 95 KeyMap key = new KeyMap(this, vars, "ReportShipper.html"); 96 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 97 } catch (Exception ex) { 98 throw new ServletException(ex); 99 } 100 try { 101 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportShipper"); 102 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 103 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 104 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 105 xmlDocument.setParameter("theme", vars.getTheme()); 106 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportShipper.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 107 xmlDocument.setParameter("navigationBar", nav.toString()); 108 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportShipper.html", strReplaceWith); 109 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 110 } catch (Exception ex) { 111 throw new ServletException(ex); 112 } 113 { 114 OBError myMessage = vars.getMessage("ReportShipper"); 115 vars.removeMessage("ReportShipper"); 116 if (myMessage!=null) { 117 xmlDocument.setParameter("messageType", myMessage.getType()); 118 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 119 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 120 } 121 } 122 123 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 124 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 125 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 126 xmlDocument.setParameter("paramFrom", strFrom); 127 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 128 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 129 xmlDocument.setParameter("paramTo", strTo); 130 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 131 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 132 xmlDocument.setParameter("paramSale", strSale); 133 xmlDocument.setParameter("paramPurchase", strPurchase); 134 xmlDocument.setParameter("paramDetalle", strDetail); 135 136 xmlDocument.setParameter("paramShipper", strShipper); 137 try { 138 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Shipper_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportShipper"), Utility.getContext(this, vars, "#User_Client", "ReportShipper"), 0); 139 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportShipper", strShipper); 140 xmlDocument.setData("reportShipper","liststructure", comboTableData.select(false)); 141 comboTableData = null; 142 } catch (Exception ex) { 143 throw new ServletException(ex); 144 } 145 146 147 xmlDocument.setData("structure", data); 148 xmlDocument.setDataArray("reportLine","structureLine", dataLine); 149 out.println(xmlDocument.print()); 150 out.close(); 151 } 152 153 public String getServletInfo() { 154 return "Servlet ReportShipper."; 155 } } 157 158 | Popular Tags |