src/org/openbravo/erpCommon/ad_reports/ReportWorkRequirementDailyEnv.java
changeset 35444 9feac3af1d2f
parent 35443 f4bdb985e356
child 35445 3358f7883c08
equal deleted inserted replaced
35443:f4bdb985e356 35444:9feac3af1d2f
     1 /*
       
     2  *************************************************************************
       
     3  * The contents of this file are subject to the Openbravo  Public  License
       
     4  * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
       
     5  * Version 1.1  with a permitted attribution clause; you may not  use this
       
     6  * file except in compliance with the License. You  may  obtain  a copy of
       
     7  * the License at http://www.openbravo.com/legal/license.html 
       
     8  * Software distributed under the License  is  distributed  on  an "AS IS"
       
     9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
       
    10  * License for the specific  language  governing  rights  and  limitations
       
    11  * under the License. 
       
    12  * The Original Code is Openbravo ERP. 
       
    13  * The Initial Developer of the Original Code is Openbravo SLU 
       
    14  * All portions are Copyright (C) 2001-2010 Openbravo SLU 
       
    15  * All Rights Reserved.
       
    16  * Contributor(s):  ______________________________________.
       
    17  ************************************************************************
       
    18  */
       
    19 package org.openbravo.erpCommon.ad_reports;
       
    20 
       
    21 import java.io.IOException;
       
    22 import java.io.PrintWriter;
       
    23 
       
    24 import javax.servlet.ServletException;
       
    25 import javax.servlet.http.HttpServletRequest;
       
    26 import javax.servlet.http.HttpServletResponse;
       
    27 
       
    28 import org.openbravo.base.secureApp.HttpSecureAppServlet;
       
    29 import org.openbravo.base.secureApp.VariablesSecureApp;
       
    30 import org.openbravo.erpCommon.businessUtility.WindowTabs;
       
    31 import org.openbravo.erpCommon.utility.DateTimeData;
       
    32 import org.openbravo.erpCommon.utility.LeftTabsBar;
       
    33 import org.openbravo.erpCommon.utility.NavigationBar;
       
    34 import org.openbravo.erpCommon.utility.OBError;
       
    35 import org.openbravo.erpCommon.utility.ToolBar;
       
    36 import org.openbravo.erpCommon.utility.Utility;
       
    37 import org.openbravo.xmlEngine.XmlDocument;
       
    38 
       
    39 public class ReportWorkRequirementDailyEnv extends HttpSecureAppServlet {
       
    40   private static final long serialVersionUID = 1L;
       
    41 
       
    42   @Override
       
    43   public void doPost(HttpServletRequest request, HttpServletResponse response)
       
    44       throws IOException, ServletException {
       
    45     VariablesSecureApp vars = new VariablesSecureApp(request);
       
    46 
       
    47     if (vars.commandIn("DEFAULT")) {
       
    48       String strStartDateFrom = vars.getGlobalVariable("inpStartDateFrom",
       
    49           "ReportWorkRequirementDailyEnv|StartDateFrom", "");
       
    50       String strStartDateTo = vars.getGlobalVariable("inpStartDateTo",
       
    51           "ReportWorkRequirementDailyEnv|StartDateTo", "");
       
    52       String strmaProcessPlan = vars.getGlobalVariable("inpmaProcessPlanId",
       
    53           "ReportWorkRequirementDailyEnv|MA_ProcessPlan_ID", "");
       
    54       strStartDateTo = DateTimeData.today(this);
       
    55       strStartDateFrom = DateTimeData.today(this);
       
    56       printPageDataSheet(response, vars, strStartDateFrom, strStartDateTo, strmaProcessPlan);
       
    57     } else if (vars.commandIn("FIND")) {
       
    58       String strStartDateFrom = vars.getRequestGlobalVariable("inpStartDateFrom",
       
    59           "ReportWorkRequirementDailyEnv|StartDateFrom");
       
    60       String strStartDateTo = vars.getRequestGlobalVariable("inpStartDateTo",
       
    61           "ReportWorkRequirementDailyEnv|StartDateTo");
       
    62       String strmaProcessPlan = vars.getRequestGlobalVariable("inpmaProcessPlanId",
       
    63           "ReportWorkRequirementDailyEnv|MA_ProcessPlan_ID");
       
    64       printPageDataHtml(response, vars, strStartDateFrom, strStartDateTo, strmaProcessPlan);
       
    65     } else {
       
    66       pageError(response);
       
    67     }
       
    68   }
       
    69 
       
    70   private void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars,
       
    71       String strStartDateFrom, String strStartDateTo, String strmaProcessPlan)
       
    72       throws IOException, ServletException {
       
    73     if (log4j.isDebugEnabled()) {
       
    74       log4j.debug("Output: dataSheet");
       
    75     }
       
    76     response.setContentType("text/html; charset=UTF-8");
       
    77     PrintWriter out = response.getWriter();
       
    78     XmlDocument xmlDocument = null;
       
    79     ReportWorkRequirementDailyEnvData[] data = null;
       
    80     xmlDocument = xmlEngine
       
    81         .readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportWorkRequirementDailyEnvEdit")
       
    82         .createXmlDocument();
       
    83     data = ReportWorkRequirementDailyEnvData.select(this, vars.getLanguage(),
       
    84         Utility.getContext(this, vars, "#User_Client", "ReportWorkRequirementDailyEnv"),
       
    85         Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportWorkRequirementDailyEnv"),
       
    86         strStartDateFrom, strStartDateTo, strmaProcessPlan);
       
    87 
       
    88     xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
       
    89     xmlDocument.setParameter("paramLanguage", "defaultLang=\"" + vars.getLanguage() + "\";");
       
    90     xmlDocument.setParameter("theme", vars.getTheme());
       
    91     xmlDocument.setData("structure1", data);
       
    92     out.println(xmlDocument.print());
       
    93     out.close();
       
    94   }
       
    95 
       
    96   private void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars,
       
    97       String strStartDateFrom, String strStartDateTo, String strmaProcessPlan)
       
    98       throws IOException, ServletException {
       
    99     if (log4j.isDebugEnabled()) {
       
   100       log4j.debug("Output: dataSheet");
       
   101     }
       
   102     response.setContentType("text/html; charset=UTF-8");
       
   103     PrintWriter out = response.getWriter();
       
   104     XmlDocument xmlDocument = null;
       
   105     xmlDocument = xmlEngine
       
   106         .readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportWorkRequirementDailyEnv")
       
   107         .createXmlDocument();
       
   108 
       
   109     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportWorkRequirementDailyEnv", false,
       
   110         "", "", "", false, "ad_reports", strReplaceWith, false, true);
       
   111     toolbar.prepareSimpleToolBarTemplate();
       
   112     xmlDocument.setParameter("toolbar", toolbar.toString());
       
   113 
       
   114     try {
       
   115       WindowTabs tabs = new WindowTabs(this, vars,
       
   116           "org.openbravo.erpCommon.ad_reports.ReportWorkRequirementDailyEnv");
       
   117       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
       
   118       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
       
   119       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
       
   120       xmlDocument.setParameter("theme", vars.getTheme());
       
   121       NavigationBar nav = new NavigationBar(this, vars.getLanguage(),
       
   122           "ReportWorkRequirementDailyEnv.html", classInfo.id, classInfo.type, strReplaceWith,
       
   123           tabs.breadcrumb());
       
   124       xmlDocument.setParameter("navigationBar", nav.toString());
       
   125       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(),
       
   126           "ReportWorkRequirementDailyEnv.html", strReplaceWith);
       
   127       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
       
   128     } catch (Exception ex) {
       
   129       throw new ServletException(ex);
       
   130     }
       
   131     {
       
   132       OBError myMessage = vars.getMessage("ReportWorkRequirementDailyEnv");
       
   133       vars.removeMessage("ReportWorkRequirementDailyEnv");
       
   134       if (myMessage != null) {
       
   135         xmlDocument.setParameter("messageType", myMessage.getType());
       
   136         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
       
   137         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
       
   138       }
       
   139     }
       
   140 
       
   141     xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
       
   142     xmlDocument.setParameter("paramLanguage", "defaultLang=\"" + vars.getLanguage() + "\";");
       
   143     xmlDocument.setParameter("maProcessPlan", strmaProcessPlan);
       
   144     xmlDocument.setParameter("dateFrom", strStartDateFrom);
       
   145     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
       
   146     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
       
   147     xmlDocument.setParameter("dateTo", strStartDateTo);
       
   148     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
       
   149     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
       
   150     xmlDocument.setData("reportMA_PROCESSPLAN", "liststructure",
       
   151         ProcessPlanComboData.select(this,
       
   152             Utility.getContext(this, vars, "#User_Client", "ReportWorkRequirementDailyEnv"),
       
   153             Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportWorkRequirementDailyEnv")));
       
   154 
       
   155     out.println(xmlDocument.print());
       
   156     out.close();
       
   157   }
       
   158 
       
   159   /*
       
   160    * void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String
       
   161    * strStartDateFrom, String strStartDateTo, String strmaProcessPlan) throws IOException,
       
   162    * ServletException { if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
       
   163    * response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter();
       
   164    * XmlDocument xmlDocument=null; ReportWorkRequirementDailyEnvData[] data=null; xmlDocument =
       
   165    * xmlEngine.readXmlTemplate ("org/openbravo/erpCommon/ad_reports/ReportWorkRequirementDailyEnv"
       
   166    * ).createXmlDocument(); data = ReportWorkRequirementDailyEnvData.select(this,
       
   167    * vars.getLanguage(), Utility.getContext(this, vars, "#User_Client",
       
   168    * "ReportWorkRequirementDailyEnv"), Utility.getContext(this, vars, "#AccessibleOrgTree",
       
   169    * "ReportWorkRequirementDailyEnv"), strStartDateFrom, strStartDateTo, strmaProcessPlan);
       
   170    * 
       
   171    * ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportWorkRequirementDailyEnv", false,
       
   172    * "", "", "",false, "ad_reports", strReplaceWith, false, true);
       
   173    * toolbar.prepareSimpleToolBarTemplate(); xmlDocument.setParameter("toolbar",
       
   174    * toolbar.toString());
       
   175    * 
       
   176    * try { WindowTabs tabs = new WindowTabs(this, vars,
       
   177    * "org.openbravo.erpCommon.ad_reports.ReportWorkRequirementDailyEnv");
       
   178    * xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
       
   179    * xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
       
   180    * xmlDocument.setParameter("childTabContainer", tabs.childTabs());
       
   181    * xmlDocument.setParameter("theme", vars.getTheme()); NavigationBar nav = new NavigationBar(this,
       
   182    * vars.getLanguage(), "ReportWorkRequirementDailyEnv.html", classInfo.id, classInfo.type,
       
   183    * strReplaceWith, tabs.breadcrumb()); xmlDocument.setParameter("navigationBar", nav.toString());
       
   184    * LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(),
       
   185    * "ReportWorkRequirementDailyEnv.html", strReplaceWith); xmlDocument.setParameter("leftTabs",
       
   186    * lBar.manualTemplate()); } catch (Exception ex) { throw new ServletException(ex); } { OBError
       
   187    * myMessage = vars.getMessage("ReportWorkRequirementDailyEnv");
       
   188    * vars.removeMessage("ReportWorkRequirementDailyEnv"); if (myMessage!=null) {
       
   189    * xmlDocument.setParameter("messageType", myMessage.getType());
       
   190    * xmlDocument.setParameter("messageTitle", myMessage.getTitle());
       
   191    * xmlDocument.setParameter("messageMessage", myMessage.getMessage()); } }
       
   192    * 
       
   193    * xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
       
   194    * xmlDocument.setParameter("paramLanguage", "defaultLang=\"" + vars.getLanguage() + "\";");
       
   195    * xmlDocument.setParameter("maProcessPlan", strmaProcessPlan);
       
   196    * xmlDocument.setParameter("startDateFrom", strStartDateFrom);
       
   197    * xmlDocument.setParameter("startDateTo", strStartDateTo);
       
   198    * xmlDocument.setData("reportMA_PROCESSPLAN", "liststructure", ProcessPlanComboData.select(this,
       
   199    * Utility.getContext(this, vars, "#User_Client", "ReportWorkRequirementDailyEnv"),
       
   200    * Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportWorkRequirementDailyEnv")));
       
   201    * xmlDocument.setData("structure1", data); out.println(xmlDocument.print()); out.close(); }
       
   202    */
       
   203 
       
   204   @Override
       
   205   public String getServletInfo() {
       
   206     return "Servlet ReportWorkRequirementDailyEnv.";
       
   207   } // end of getServletInfo() method
       
   208 }