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 import org.openbravo.erpCommon.utility.ToolBar; 31 32 public class ReportInvoiceCustomerEdition extends HttpSecureAppServlet { 33 34 35 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 36 VariablesSecureApp vars = new VariablesSecureApp(request); 37 38 if (!Utility.hasProcessAccess(this, vars, "", "RV_ReportInvoiceCustomer")) { 39 bdError(response, "AccessTableNoView", vars.getLanguage()); 40 return; 41 } 42 43 if (vars.commandIn("DEFAULT")){ 44 String strdateFrom = vars.getGlobalVariable("inpDateFrom", "ReportInvoiceCustomerEdition|DateFrom", ""); 45 String strdateTo = vars.getGlobalVariable("inpDateTo", "ReportInvoiceCustomerEdition|DateTo", ""); 46 String strcProjectId = vars.getGlobalVariable("inpcProjectId", "ReportInvoiceCustomerEdition|cProjectId", ""); 47 String strcBpartnerId = vars.getInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceCustomerEdition|cBPartnerId_IN", ""); 48 String strmCategoryId = vars.getInGlobalVariable("inpmProductCategoryId", "ReportInvoiceCustomerEdition|mCategoryId", ""); 49 String strProjectkind = vars.getInGlobalVariable("inpProjectkind", "ReportInvoiceCustomerEdition|Projectkind", ""); 50 String strProjectstatus = vars.getInGlobalVariable("inpProjectstatus", "ReportInvoiceCustomerEdition|Projectstatus", ""); 51 String strProjectphase = vars.getInGlobalVariable("inpProjectphase", "ReportInvoiceCustomerEdition|Projectphase", ""); 52 String strProduct = vars.getInGlobalVariable("inpmProductId_IN", "ReportInvoiceCustomerEdition|mProductId_IN", ""); 53 String strProjectpublic = vars.getGlobalVariable("inpProjectpublic", "ReportInvoiceCustomerEdition|Projectpublic", ""); 54 String strSalesRep = vars.getGlobalVariable("inpSalesRepId", "ReportInvoiceCustomerEdition|SalesRepId", ""); 55 String strcRegionId = vars.getInGlobalVariable("inpcRegionId", "ReportInvoiceCustomerEdition|cRegionId", ""); 56 printPageDataSheet(response, vars, strdateFrom, strdateTo, strcProjectId, strcBpartnerId, strmCategoryId, strProjectkind, strProjectstatus, strProjectphase, strProduct, strProjectpublic, strSalesRep, strcRegionId); 57 }else if (vars.commandIn("EDIT_HTML")) { 58 String strdateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportInvoiceCustomerEdition|DateFrom"); 59 String strdateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportInvoiceCustomerEdition|DateTo"); 60 String strcProjectId = vars.getRequestGlobalVariable("inpcProjectId", "ReportInvoiceCustomerEdition|cProjectId"); 61 String strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceCustomerEdition|cBPartnerId_IN"); 62 String strmCategoryId = vars.getRequestInGlobalVariable("inpmProductCategoryId", "ReportInvoiceCustomerEdition|mCategoryId"); 63 String strProjectkind = vars.getRequestInGlobalVariable("inpProjectkind", "ReportInvoiceCustomerEdition|Projectkind"); 64 String strProjectstatus = vars.getRequestInGlobalVariable("inpProjectstatus", "ReportInvoiceCustomerEdition|Projectstatus"); 65 String strProjectphase = vars.getRequestInGlobalVariable("inpProjectphase", "ReportInvoiceCustomerEdition|Projectphase"); 66 String strProduct = vars.getRequestInGlobalVariable("inpmProductId_IN", "ReportInvoiceCustomerEdition|mProductId_IN"); 67 String strProjectpublic = vars.getRequestGlobalVariable("inpProjectpublic", "ReportInvoiceCustomerEdition|Projectpublic"); 68 String strSalesRep = vars.getRequestGlobalVariable("inpSalesRepId", "ReportInvoiceCustomerEdition|SalesRepId"); 69 String strcRegionId = vars.getRequestInGlobalVariable("inpcRegionId", "ReportInvoiceCustomerEdition|cRegionId"); 70 printPageHtml(response, vars, strdateFrom, strdateTo, strcProjectId, strcBpartnerId, strmCategoryId, strProjectkind, strProjectstatus, strProjectphase, strProduct, strProjectpublic, strSalesRep, strcRegionId); 71 } else if (vars.commandIn("EDIT_PDF")) { 72 String strdateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportInvoiceCustomerEdition|DateFrom"); 73 String strdateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportInvoiceCustomerEdition|DateTo"); 74 String strcProjectId = vars.getRequestGlobalVariable("inpcProjectId", "ReportInvoiceCustomerEdition|cProjectId"); 75 String strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceCustomerEdition|cBPartnerId_IN"); 76 String strmCategoryId = vars.getRequestInGlobalVariable("inpmProductCategoryId", "ReportInvoiceCustomerEdition|mCategoryId"); 77 String strProjectkind = vars.getRequestInGlobalVariable("inpProjectkind", "ReportInvoiceCustomerEdition|Projectkind"); 78 String strProjectstatus = vars.getRequestInGlobalVariable("inpProjectstatus", "ReportInvoiceCustomerEdition|Projectstatus"); 79 String strProjectphase = vars.getRequestInGlobalVariable("inpProjectphase", "ReportInvoiceCustomerEdition|Projectphase"); 80 String strProduct = vars.getRequestInGlobalVariable("inpmProductId_IN", "ReportInvoiceCustomerEdition|mProductId_IN"); 81 String strProjectpublic = vars.getRequestGlobalVariable("inpProjectpublic", "ReportInvoiceCustomerEdition|Projectpublic"); 82 String strSalesRep = vars.getRequestGlobalVariable("inpSalesRepId", "ReportInvoiceCustomerEdition|SalesRepId"); 83 String strcRegionId = vars.getRequestInGlobalVariable("inpcRegionId", "ReportInvoiceCustomerEdition|cRegionId"); 84 printPagePdf(response, vars, strdateFrom, strdateTo, strcProjectId, strcBpartnerId, strmCategoryId, strProjectkind, strProjectstatus, strProjectphase, strProduct, strProjectpublic, strSalesRep, strcRegionId); 85 } else pageErrorPopUp(response); 86 } 87 88 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo, String strcProjectId, String strcBpartnerId, String strmCategoryId, String strProjectkind, String strProjectstatus, String strProjectphase, String strProduct, String strProjectpublic, String strSalesRep, String strcRegionId) throws IOException, ServletException { 89 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 90 91 92 String discard[]={"discard"}; 93 XmlDocument xmlDocument=null; 94 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerFilter").createXmlDocument(); 95 96 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoiceCustomerFilter", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 97 toolbar.prepareSimpleToolBarTemplate(); 98 xmlDocument.setParameter("toolbar", toolbar.toString()); 99 try { 100 KeyMap key = new KeyMap(this, vars, "ReportInvoiceCustomerEdition.html"); 101 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 102 } catch (Exception ex) { 103 throw new ServletException(ex); 104 } 105 try { 106 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoiceCustomerEdition"); 107 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 108 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 109 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 110 xmlDocument.setParameter("theme", vars.getTheme()); 111 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoiceCustomerEdition.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 112 xmlDocument.setParameter("navigationBar", nav.toString()); 113 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoiceCustomerEdition.html", strReplaceWith); 114 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 115 } catch (Exception ex) { 116 throw new ServletException(ex); 117 } 118 { 119 OBError myMessage = vars.getMessage("ReportInvoiceCustomerEdition"); 120 vars.removeMessage("ReportInvoiceCustomerEdition"); 121 if (myMessage!=null) { 122 xmlDocument.setParameter("messageType", myMessage.getType()); 123 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 124 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 125 } 126 } 127 128 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 129 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 130 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 131 xmlDocument.setParameter("dateFrom", strdateFrom); 132 xmlDocument.setParameter("dateTo", strdateTo); 133 xmlDocument.setParameter("paramBPartnerId", strcBpartnerId); 134 xmlDocument.setParameter("cProjectId", strcProjectId); 135 xmlDocument.setParameter("projectName", InvoiceCustomerEditionData.selectProject(this, strcProjectId)); 136 xmlDocument.setParameter("mProductCatId", strmCategoryId); 137 xmlDocument.setParameter("cProjectKind", strProjectkind); 138 xmlDocument.setParameter("cRegionId", strcRegionId); 139 xmlDocument.setParameter("cProjectPhase", strProjectphase); 140 xmlDocument.setParameter("cProjectStatus", strProjectstatus); 141 xmlDocument.setParameter("cProjectPublic", strProjectpublic); 142 xmlDocument.setParameter("salesRep", strSalesRep); 143 144 try { 145 ComboTableData comboTableData = new ComboTableData(this, "LIST", "", "Projectkind", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0); 146 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strProjectkind); 147 xmlDocument.setData("reportC_PROJECTKIND","liststructure", comboTableData.select(false)); 148 comboTableData = null; 149 } catch (Exception ex) { 150 throw new ServletException(ex); 151 } 152 153 try { 154 ComboTableData comboTableData = new ComboTableData(this, "LIST", "", "Projectphase", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0); 155 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strProjectphase); 156 xmlDocument.setData("reportC_PROJECTPHASE","liststructure", comboTableData.select(false)); 157 comboTableData = null; 158 } catch (Exception ex) { 159 throw new ServletException(ex); 160 } 161 162 try { 163 ComboTableData comboTableData = new ComboTableData(this, "LIST", "", "ProjectStatus", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0); 164 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strProjectstatus); 165 xmlDocument.setData("reportC_PROJECTSTATUS","liststructure", comboTableData.select(false)); 166 comboTableData = null; 167 } catch (Exception ex) { 168 throw new ServletException(ex); 169 } 170 171 try { 172 ComboTableData comboTableData = new ComboTableData(this, "LIST", "", "PublicPrivate", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0); 173 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strProjectpublic); 174 xmlDocument.setData("reportC_PROJECTPUBLIC","liststructure", comboTableData.select(false)); 175 comboTableData = null; 176 } catch (Exception ex) { 177 throw new ServletException(ex); 178 } 179 180 xmlDocument.setData("reportC_PRODUCTCATREGORY","liststructure",SubCategoryProductData.select(this)); 181 182 183 try { 184 ComboTableData comboTableData = new ComboTableData(this, "TABLEDIR", "C_REGION_ID", "", "C_Region of Country", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0); 185 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strcRegionId); 186 xmlDocument.setData("reportC_REGIONID","liststructure", comboTableData.select(false)); 187 comboTableData = null; 188 } catch (Exception ex) { 189 throw new ServletException(ex); 190 } 191 192 try { 193 ComboTableData comboTableData = new ComboTableData(this, "TABLE", "", "190", "AD_User SalesRep", Utility.getContext(this, vars, "#User_Org", "ReportInvoiceCustomerEdition"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceCustomerEdition"), 0); 194 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoiceCustomerEdition", strSalesRep); 195 xmlDocument.setData("reportSALESREP","liststructure", comboTableData.select(false)); 196 comboTableData = null; 197 } catch (Exception ex) { 198 throw new ServletException(ex); 199 } 200 201 xmlDocument.setData("reportCBPartnerId_IN", "liststructure", ReportProjectBuildingSiteData.selectBpartner(this, Utility.getContext(this, vars, "#User_Org", ""), Utility.getContext(this, vars, "#User_Client", ""), strcBpartnerId)); 202 xmlDocument.setData("reportMProductId_IN", "liststructure", ReportProjectBuildingSiteData.selectMproduct(this, Utility.getContext(this, vars, "#User_Org", ""), Utility.getContext(this, vars, "#User_Client", ""), strProduct)); 203 204 205 206 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 207 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 208 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 209 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 210 211 response.setContentType("text/html; charset=UTF-8"); 212 PrintWriter out = response.getWriter(); 213 out.println(xmlDocument.print()); 214 out.close(); 215 } 216 217 void printPageHtml(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo, String strcProjectId, String strcBpartnerId, String strmCategoryId, String strProjectkind, String strProjectstatus, String strProjectphase, String strProduct, String strProjectpublic, String strSalesRep, String strcRegionId) throws IOException, ServletException{ 218 if (log4j.isDebugEnabled()) log4j.debug("Output: print html"); 219 XmlDocument xmlDocument=null; 220 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerEdition").createXmlDocument(); 221 InvoiceCustomerEditionData[] data = null; 222 data = InvoiceCustomerEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "InvoiceCustomerFilter"), Utility.getContext(this, vars, "#User_Client", "InvoiceCustomerFilter"), strdateFrom, strdateTo, strcBpartnerId, strcProjectId, strmCategoryId, strProjectkind, strProjectphase, strProjectstatus, strProjectpublic, strcRegionId, strSalesRep, strProduct); 223 xmlDocument.setData("structure1", data); 224 225 226 227 response.setContentType("text/html; charset=UTF-8"); 228 PrintWriter out = response.getWriter(); 229 out.println(xmlDocument.print()); 230 out.close(); 231 } 232 233 void printPagePdf(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo, String strcProjectId, String strcBpartnerId, String strmCategoryId, String strProjectkind, String strProjectstatus, String strProjectphase, String strProduct, String strProjectpublic, String strSalesRep, String strcRegionId) throws IOException, ServletException{ 234 if (log4j.isDebugEnabled()) log4j.debug("Output: print pdf"); 235 XmlDocument xmlDocument=null; 236 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerEdition_Pdf").createXmlDocument(); 237 InvoiceCustomerEditionData[] data = null; 238 data = InvoiceCustomerEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "InvoiceCustomerFilter"), Utility.getContext(this, vars, "#User_Client", "InvoiceCustomerFilter"), strdateFrom, strdateTo, strcBpartnerId, strcProjectId, strmCategoryId, strProjectkind, strProjectphase, strProjectstatus, strProjectpublic, strcRegionId, strSalesRep, strProduct); 239 xmlDocument.setData("structure1", data); 240 String strResult = xmlDocument.print(); 241 if (log4j.isDebugEnabled()) log4j.debug(strResult); 242 renderFO(strResult, response); 243 } 244 245 public String getServletInfo() { 246 return "Servlet InvoiceCustomerFilter. This Servlet was made by Jon AlegrÃa"; 247 } } 249 | Popular Tags |