Package org.openbravo.base.secureApp

Examples of org.openbravo.base.secureApp.VariablesSecureApp


    boolHist = false;
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      String strTabId = vars.getStringParameter("inpTabId");
      String strcProjectId = vars.getStringParameter("inpcProjectId");
      String strChanged = vars.getStringParameter("inpLastFieldChanged");
      // Services
      String strServiceRevenue = vars.getNumericParameter("inpservrevenue", "0");
      String strServiceCost = vars.getNumericParameter("inpservcost", "0");
      String strServiceMargin = vars.getNumericParameter("inpservmargin", "0");
      // Expenses
      String strPlannedExpenses = vars.getNumericParameter("inpexpexpenses", "0");
      String strReinvoicedExpenses = vars.getNumericParameter("inpexpreinvoicing", "0");
      String strPlannedMargin = vars.getNumericParameter("inpexpmargin", "0");
      try {
        printPage(response, vars, strTabId, strcProjectId, strChanged, strServiceRevenue,
            strServiceCost, strServiceMargin, strPlannedExpenses, strReinvoicedExpenses,
            strPlannedMargin);
      } catch (ServletException ex) {
View Full Code Here


    boolHist = false;
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      String strChanged = vars.getStringParameter("inpLastFieldChanged");
      if (log4j.isDebugEnabled())
        log4j.debug("CHANGED: " + strChanged);
      String strSequence = vars.getStringParameter("inpmaSequenceId");
      String strWorkRequirement = vars.getStringParameter("inpmaWorkrequirementId");

      try {
        printPage(response, vars, strWorkRequirement, strSequence);
      } catch (ServletException ex) {
        pageErrorCallOut(response);
View Full Code Here

  private static final int accesslevel = 7;
  private static final double SUBTABS_COL_SIZE = 15;

  public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
    TableSQLData tableSQL = null;
    VariablesSecureApp vars = new VariablesSecureApp(request);
    Boolean saveRequest = (Boolean) request.getAttribute("autosave");
   
    if(saveRequest != null && saveRequest){
      String currentOrg = vars.getStringParameter("inpadOrgId");
      String currentClient = vars.getStringParameter("inpadClientId");
      boolean editableTab = (!org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)
                            && (currentOrg.equals("") || Utility.isElementInList(Utility.getContext(this, vars,"#User_Org", windowId, accesslevel), currentOrg))
                            && (currentClient.equals("") || Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),currentClient)));
   
        OBError myError = new OBError();
        String commandType = request.getParameter("inpCommandType");
        String strhrmSugarcrmAcId = request.getParameter("inphrmSugarcrmAcId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strhrmSugarcrmAcId.equals(""))
              total = saveRecord(vars, myError, 'U');
          else
              total = saveRecord(vars, myError, 'I');
         
          if (!myError.isEmpty() && total == 0)    
            throw new OBException(myError.getMessage());
        }
        vars.setSessionValue(request.getParameter("mappingName") +"|hash", vars.getPostDataHash());
        vars.setSessionValue(tabId + "|Header.view", "EDIT");
       
        return;
    }
   
    try {
      tableSQL = new TableSQLData(vars, this, tabId, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    String strOrderBy = vars.getSessionValue(tabId + "|orderby");
    if (!strOrderBy.equals("")) {
      vars.setSessionValue(tabId + "|newOrder", "1");
    }

    if (vars.commandIn("DEFAULT")) {

      String strHRM_Sugarcrm_Ac_ID = vars.getGlobalVariable("inphrmSugarcrmAcId", windowId + "|HRM_Sugarcrm_Ac_ID", "");
     

      String strView = vars.getSessionValue(tabId + "|SugarCRM.view");
      if (strView.equals("")) {
        strView = defaultTabView;

        if (strView.equals("EDIT")) {
          if (strHRM_Sugarcrm_Ac_ID.equals("")) strHRM_Sugarcrm_Ac_ID = firstElement(vars, tableSQL);
          if (strHRM_Sugarcrm_Ac_ID.equals("")) strView = "RELATION";
        }
      }
      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strHRM_Sugarcrm_Ac_ID, tableSQL);

      else printPageDataSheet(response, vars, strHRM_Sugarcrm_Ac_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Sugarcrm_Ac_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Sugarcrm_Ac_ID.equals("")) strHRM_Sugarcrm_Ac_ID = vars.getRequiredGlobalVariable("inphrmSugarcrmAcId", windowId + "|HRM_Sugarcrm_Ac_ID");
      else vars.setSessionValue(windowId + "|HRM_Sugarcrm_Ac_ID", strHRM_Sugarcrm_Ac_ID);
     
      vars.setSessionValue(tabId + "|SugarCRM.view", "EDIT");

      printPageEdit(response, request, vars, false, strHRM_Sugarcrm_Ac_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {


      String strView = vars.getSessionValue(tabId + "|SugarCRM.view");
      String strHRM_Sugarcrm_Ac_ID = "";
      if (strView.equals("")) {
        strView = defaultTabView;
        if (strView.equals("EDIT")) {
          strHRM_Sugarcrm_Ac_ID = firstElement(vars, tableSQL);
          if (strHRM_Sugarcrm_Ac_ID.equals("")) strView = "RELATION";
        }
      }
      if (strView.equals("EDIT")) {

        if (strHRM_Sugarcrm_Ac_ID.equals("")) strHRM_Sugarcrm_Ac_ID = firstElement(vars, tableSQL);
        printPageEdit(response, request, vars, false, strHRM_Sugarcrm_Ac_ID, tableSQL);

      } else printPageDataSheet(response, vars, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamName", tabId + "|paramName");

     
     
      vars.removeSessionValue(windowId + "|HRM_Sugarcrm_Ac_ID");
      String strHRM_Sugarcrm_Ac_ID="";

      String strView = vars.getSessionValue(tabId + "|SugarCRM.view");
      if (strView.equals("")) strView=defaultTabView;

      if (strView.equals("EDIT")) {
        strHRM_Sugarcrm_Ac_ID = firstElement(vars, tableSQL);
        if (strHRM_Sugarcrm_Ac_ID.equals("")) {
          // filter returns empty set
          strView = "RELATION";
          // switch to grid permanently until the user changes the view again
          vars.setSessionValue(tabId + "|SugarCRM.view", strView);
        }
      }

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strHRM_Sugarcrm_Ac_ID, tableSQL);

      else printPageDataSheet(response, vars, strHRM_Sugarcrm_Ac_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
     

      String strHRM_Sugarcrm_Ac_ID = vars.getGlobalVariable("inphrmSugarcrmAcId", windowId + "|HRM_Sugarcrm_Ac_ID", "");
      vars.setSessionValue(tabId + "|SugarCRM.view", "RELATION");
      printPageDataSheet(response, vars, strHRM_Sugarcrm_Ac_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {


      printPageEdit(response, request, vars, true, "", tableSQL);

    } else if (vars.commandIn("EDIT")) {

      @SuppressWarnings("unused") // In Expense Invoice tab this variable is not used, to be fixed
      String strHRM_Sugarcrm_Ac_ID = vars.getGlobalVariable("inphrmSugarcrmAcId", windowId + "|HRM_Sugarcrm_Ac_ID", "");
      vars.setSessionValue(tabId + "|SugarCRM.view", "EDIT");

      setHistoryCommand(request, "EDIT");
      printPageEdit(response, request, vars, false, strHRM_Sugarcrm_Ac_ID, tableSQL);

    } else if (vars.commandIn("NEXT")) {

      String strHRM_Sugarcrm_Ac_ID = vars.getRequiredStringParameter("inphrmSugarcrmAcId");
     
      String strNext = nextElement(vars, strHRM_Sugarcrm_Ac_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {

      String strHRM_Sugarcrm_Ac_ID = vars.getRequiredStringParameter("inphrmSugarcrmAcId");
     
      String strPrevious = previousElement(vars, strHRM_Sugarcrm_Ac_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {

      vars.setSessionValue(tabId + "|SugarCRM.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {

      String strInitRecord = vars.getSessionValue(tabId + "|SugarCRM.initRecordNumber");
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
      if (strInitRecord.equals("") || strInitRecord.equals("0")) {
        vars.setSessionValue(tabId + "|SugarCRM.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|SugarCRM.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|HRM_Sugarcrm_Ac_ID");

      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("NEXT_RELATION")) {

      String strInitRecord = vars.getSessionValue(tabId + "|SugarCRM.initRecordNumber");
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
      int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
      if (initRecord==0) initRecord=1;
      initRecord += intRecordRange;
      strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
      vars.setSessionValue(tabId + "|SugarCRM.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|HRM_Sugarcrm_Ac_ID");

      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("FIRST")) {

     
      String strFirst = firstElement(vars, tableSQL);

      printPageEdit(response, request, vars, false, strFirst, tableSQL);
    } else if (vars.commandIn("LAST_RELATION")) {

      String strLast = lastElement(vars, tableSQL);
      printPageDataSheet(response, vars, strLast, tableSQL);
    } else if (vars.commandIn("LAST")) {

     
      String strLast = lastElement(vars, tableSQL);

      printPageEdit(response, request, vars, false, strLast, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {

      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I');     
      if (!myError.isEmpty()) {       
        response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
      }
      else {
    if (myError.isEmpty()) {
      myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsInserted");
      myError.setMessage(total + " " + myError.getMessage());
      vars.setMessage(tabId, myError);
    }       
        if (vars.commandIn("SAVE_NEW_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
        else if (vars.commandIn("SAVE_NEW_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
    } else if (vars.commandIn("SAVE_EDIT_RELATION", "SAVE_EDIT_NEW", "SAVE_EDIT_EDIT", "SAVE_EDIT_NEXT")) {

      String strHRM_Sugarcrm_Ac_ID = vars.getRequiredGlobalVariable("inphrmSugarcrmAcId", windowId + "|HRM_Sugarcrm_Ac_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U');     
      if (!myError.isEmpty()) {
        response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
      }
      else {
        if (myError.isEmpty()) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsUpdated");
          myError.setMessage(total + " " + myError.getMessage());
          vars.setMessage(tabId, myError);
        }
        if (vars.commandIn("SAVE_EDIT_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
        else if (vars.commandIn("SAVE_EDIT_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        else if (vars.commandIn("SAVE_EDIT_NEXT")) {
          String strNext = nextElement(vars, strHRM_Sugarcrm_Ac_ID, tableSQL);
          vars.setSessionValue(windowId + "|HRM_Sugarcrm_Ac_ID", strNext);
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        } else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
/*    } else if (vars.commandIn("DELETE_RELATION")) {

      String strHRM_Sugarcrm_Ac_ID = vars.getRequiredInStringParameter("inphrmSugarcrmAcId");
      String message = deleteRelation(vars, strHRM_Sugarcrm_Ac_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|hrmSugarcrmAcId");
        vars.setSessionValue(tabId + "|SugarCRM.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {

      String strHRM_Sugarcrm_Ac_ID = vars.getRequiredStringParameter("inphrmSugarcrmAcId");
      //SugarCRMData data = getEditVariables(vars);
      int total = 0;
      OBError myError = null;
      if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
        vars.setMessage(tabId, myError);
      } else {
        try {
          total = SugarCRMData.delete(this, strHRM_Sugarcrm_Ac_ID, Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), Utility.getContext(this, vars, "#User_Org", windowId, accesslevel));
        } catch(ServletException ex) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myError.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myError);
        }
        if (myError==null && total==0) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
          vars.setMessage(tabId, myError);
        }
        vars.removeSessionValue(windowId + "|hrmSugarcrmAcId");
        vars.setSessionValue(tabId + "|SugarCRM.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());








    } else if (vars.getCommand().toUpperCase().startsWith("BUTTON") || vars.getCommand().toUpperCase().startsWith("SAVE_BUTTON")) {
      pageErrorPopUp(response);
    } else pageError(response);
  }
View Full Code Here

    boolHist = false;
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      String strChanged = vars.getStringParameter("inpLastFieldChanged");
      if (log4j.isDebugEnabled())
        log4j.debug("CHANGED: " + strChanged);
      String strWhSchedule = vars.getStringParameter("inpmWhScheduleId");
      String strTabId = vars.getStringParameter("inpTabId");

      try {
        printPage(response, vars, strWhSchedule, strTabId);
      } catch (ServletException ex) {
        pageErrorCallOut(response);
View Full Code Here

  private static final int accesslevel = 7;
  private static final double SUBTABS_COL_SIZE = 15;

  public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
    TableSQLData tableSQL = null;
    VariablesSecureApp vars = new VariablesSecureApp(request);
    Boolean saveRequest = (Boolean) request.getAttribute("autosave");
   
    if(saveRequest != null && saveRequest){
      String currentOrg = vars.getStringParameter("inpadOrgId");
      String currentClient = vars.getStringParameter("inpadClientId");
      boolean editableTab = (!org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)
                            && (currentOrg.equals("") || Utility.isElementInList(Utility.getContext(this, vars,"#User_Org", windowId, accesslevel), currentOrg))
                            && (currentClient.equals("") || Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),currentClient)));
   
        OBError myError = new OBError();
        String commandType = request.getParameter("inpCommandType");
        String strhrmJobEmpstatusId = request.getParameter("inphrmJobEmpstatusId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strhrmJobEmpstatusId.equals(""))
              total = saveRecord(vars, myError, 'U');
          else
              total = saveRecord(vars, myError, 'I');
         
          if (!myError.isEmpty() && total == 0)    
            throw new OBException(myError.getMessage());
        }
        vars.setSessionValue(request.getParameter("mappingName") +"|hash", vars.getPostDataHash());
        vars.setSessionValue(tabId + "|Header.view", "EDIT");
       
        return;
    }
   
    try {
      tableSQL = new TableSQLData(vars, this, tabId, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    String strOrderBy = vars.getSessionValue(tabId + "|orderby");
    if (!strOrderBy.equals("")) {
      vars.setSessionValue(tabId + "|newOrder", "1");
    }

    if (vars.commandIn("DEFAULT")) {

      String strHRM_Job_Empstatus_ID = vars.getGlobalVariable("inphrmJobEmpstatusId", windowId + "|HRM_Job_Empstatus_ID", "");
     

      String strView = vars.getSessionValue(tabId + "|EmploymentStatus.view");
      if (strView.equals("")) {
        strView = defaultTabView;

        if (strView.equals("EDIT")) {
          if (strHRM_Job_Empstatus_ID.equals("")) strHRM_Job_Empstatus_ID = firstElement(vars, tableSQL);
          if (strHRM_Job_Empstatus_ID.equals("")) strView = "RELATION";
        }
      }
      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strHRM_Job_Empstatus_ID, tableSQL);

      else printPageDataSheet(response, vars, strHRM_Job_Empstatus_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Job_Empstatus_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Job_Empstatus_ID.equals("")) strHRM_Job_Empstatus_ID = vars.getRequiredGlobalVariable("inphrmJobEmpstatusId", windowId + "|HRM_Job_Empstatus_ID");
      else vars.setSessionValue(windowId + "|HRM_Job_Empstatus_ID", strHRM_Job_Empstatus_ID);
     
      vars.setSessionValue(tabId + "|EmploymentStatus.view", "EDIT");

      printPageEdit(response, request, vars, false, strHRM_Job_Empstatus_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {


      String strView = vars.getSessionValue(tabId + "|EmploymentStatus.view");
      String strHRM_Job_Empstatus_ID = "";
      if (strView.equals("")) {
        strView = defaultTabView;
        if (strView.equals("EDIT")) {
          strHRM_Job_Empstatus_ID = firstElement(vars, tableSQL);
          if (strHRM_Job_Empstatus_ID.equals("")) strView = "RELATION";
        }
      }
      if (strView.equals("EDIT")) {

        if (strHRM_Job_Empstatus_ID.equals("")) strHRM_Job_Empstatus_ID = firstElement(vars, tableSQL);
        printPageEdit(response, request, vars, false, strHRM_Job_Empstatus_ID, tableSQL);

      } else printPageDataSheet(response, vars, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamName", tabId + "|paramName");

     
     
      vars.removeSessionValue(windowId + "|HRM_Job_Empstatus_ID");
      String strHRM_Job_Empstatus_ID="";

      String strView = vars.getSessionValue(tabId + "|EmploymentStatus.view");
      if (strView.equals("")) strView=defaultTabView;

      if (strView.equals("EDIT")) {
        strHRM_Job_Empstatus_ID = firstElement(vars, tableSQL);
        if (strHRM_Job_Empstatus_ID.equals("")) {
          // filter returns empty set
          strView = "RELATION";
          // switch to grid permanently until the user changes the view again
          vars.setSessionValue(tabId + "|EmploymentStatus.view", strView);
        }
      }

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strHRM_Job_Empstatus_ID, tableSQL);

      else printPageDataSheet(response, vars, strHRM_Job_Empstatus_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
     

      String strHRM_Job_Empstatus_ID = vars.getGlobalVariable("inphrmJobEmpstatusId", windowId + "|HRM_Job_Empstatus_ID", "");
      vars.setSessionValue(tabId + "|EmploymentStatus.view", "RELATION");
      printPageDataSheet(response, vars, strHRM_Job_Empstatus_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {


      printPageEdit(response, request, vars, true, "", tableSQL);

    } else if (vars.commandIn("EDIT")) {

      @SuppressWarnings("unused") // In Expense Invoice tab this variable is not used, to be fixed
      String strHRM_Job_Empstatus_ID = vars.getGlobalVariable("inphrmJobEmpstatusId", windowId + "|HRM_Job_Empstatus_ID", "");
      vars.setSessionValue(tabId + "|EmploymentStatus.view", "EDIT");

      setHistoryCommand(request, "EDIT");
      printPageEdit(response, request, vars, false, strHRM_Job_Empstatus_ID, tableSQL);

    } else if (vars.commandIn("NEXT")) {

      String strHRM_Job_Empstatus_ID = vars.getRequiredStringParameter("inphrmJobEmpstatusId");
     
      String strNext = nextElement(vars, strHRM_Job_Empstatus_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {

      String strHRM_Job_Empstatus_ID = vars.getRequiredStringParameter("inphrmJobEmpstatusId");
     
      String strPrevious = previousElement(vars, strHRM_Job_Empstatus_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {

      vars.setSessionValue(tabId + "|EmploymentStatus.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {

      String strInitRecord = vars.getSessionValue(tabId + "|EmploymentStatus.initRecordNumber");
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
      if (strInitRecord.equals("") || strInitRecord.equals("0")) {
        vars.setSessionValue(tabId + "|EmploymentStatus.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|EmploymentStatus.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|HRM_Job_Empstatus_ID");

      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("NEXT_RELATION")) {

      String strInitRecord = vars.getSessionValue(tabId + "|EmploymentStatus.initRecordNumber");
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
      int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
      if (initRecord==0) initRecord=1;
      initRecord += intRecordRange;
      strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
      vars.setSessionValue(tabId + "|EmploymentStatus.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|HRM_Job_Empstatus_ID");

      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("FIRST")) {

     
      String strFirst = firstElement(vars, tableSQL);

      printPageEdit(response, request, vars, false, strFirst, tableSQL);
    } else if (vars.commandIn("LAST_RELATION")) {

      String strLast = lastElement(vars, tableSQL);
      printPageDataSheet(response, vars, strLast, tableSQL);
    } else if (vars.commandIn("LAST")) {

     
      String strLast = lastElement(vars, tableSQL);

      printPageEdit(response, request, vars, false, strLast, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {

      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I');     
      if (!myError.isEmpty()) {       
        response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
      }
      else {
    if (myError.isEmpty()) {
      myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsInserted");
      myError.setMessage(total + " " + myError.getMessage());
      vars.setMessage(tabId, myError);
    }       
        if (vars.commandIn("SAVE_NEW_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
        else if (vars.commandIn("SAVE_NEW_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
    } else if (vars.commandIn("SAVE_EDIT_RELATION", "SAVE_EDIT_NEW", "SAVE_EDIT_EDIT", "SAVE_EDIT_NEXT")) {

      String strHRM_Job_Empstatus_ID = vars.getRequiredGlobalVariable("inphrmJobEmpstatusId", windowId + "|HRM_Job_Empstatus_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U');     
      if (!myError.isEmpty()) {
        response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
      }
      else {
        if (myError.isEmpty()) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsUpdated");
          myError.setMessage(total + " " + myError.getMessage());
          vars.setMessage(tabId, myError);
        }
        if (vars.commandIn("SAVE_EDIT_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
        else if (vars.commandIn("SAVE_EDIT_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        else if (vars.commandIn("SAVE_EDIT_NEXT")) {
          String strNext = nextElement(vars, strHRM_Job_Empstatus_ID, tableSQL);
          vars.setSessionValue(windowId + "|HRM_Job_Empstatus_ID", strNext);
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        } else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
/*    } else if (vars.commandIn("DELETE_RELATION")) {

      String strHRM_Job_Empstatus_ID = vars.getRequiredInStringParameter("inphrmJobEmpstatusId");
      String message = deleteRelation(vars, strHRM_Job_Empstatus_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|hrmJobEmpstatusId");
        vars.setSessionValue(tabId + "|EmploymentStatus.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {

      String strHRM_Job_Empstatus_ID = vars.getRequiredStringParameter("inphrmJobEmpstatusId");
      //EmploymentStatusData data = getEditVariables(vars);
      int total = 0;
      OBError myError = null;
      if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
        vars.setMessage(tabId, myError);
      } else {
        try {
          total = EmploymentStatusData.delete(this, strHRM_Job_Empstatus_ID, Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), Utility.getContext(this, vars, "#User_Org", windowId, accesslevel));
        } catch(ServletException ex) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myError.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myError);
        }
        if (myError==null && total==0) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
          vars.setMessage(tabId, myError);
        }
        vars.removeSessionValue(windowId + "|hrmJobEmpstatusId");
        vars.setSessionValue(tabId + "|EmploymentStatus.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());








    } else if (vars.getCommand().toUpperCase().startsWith("BUTTON") || vars.getCommand().toUpperCase().startsWith("SAVE_BUTTON")) {
      pageErrorPopUp(response);
    } else pageError(response);
  }
View Full Code Here

  private static final int accesslevel = 1;
  private static final double SUBTABS_COL_SIZE = 15;

  public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
    TableSQLData tableSQL = null;
    VariablesSecureApp vars = new VariablesSecureApp(request);
    Boolean saveRequest = (Boolean) request.getAttribute("autosave");
   
    if(saveRequest != null && saveRequest){
      String currentOrg = vars.getStringParameter("inpadOrgId");
      String currentClient = vars.getStringParameter("inpadClientId");
      boolean editableTab = (!org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)
                            && (currentOrg.equals("") || Utility.isElementInList(Utility.getContext(this, vars,"#User_Org", windowId, accesslevel), currentOrg))
                            && (currentClient.equals("") || Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),currentClient)));
   
        OBError myError = new OBError();
        String commandType = request.getParameter("inpCommandType");
        String strmInternalConsumptionlineId = request.getParameter("inpmInternalConsumptionlineId");
         String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strmInternalConsumptionlineId.equals(""))
              total = saveRecord(vars, myError, 'U', strPM_Internal_Consumption_ID);
          else
              total = saveRecord(vars, myError, 'I', strPM_Internal_Consumption_ID);
         
          if (!myError.isEmpty() && total == 0)    
            throw new OBException(myError.getMessage());
        }
        vars.setSessionValue(request.getParameter("mappingName") +"|hash", vars.getPostDataHash());
        vars.setSessionValue(tabId + "|Header.view", "EDIT");
       
        return;
    }
   
    try {
      tableSQL = new TableSQLData(vars, this, tabId, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    String strOrderBy = vars.getSessionValue(tabId + "|orderby");
    if (!strOrderBy.equals("")) {
      vars.setSessionValue(tabId + "|newOrder", "1");
    }

    if (vars.commandIn("DEFAULT")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID", "");

      String strM_Internal_Consumptionline_ID = vars.getGlobalVariable("inpmInternalConsumptionlineId", windowId + "|M_Internal_Consumptionline_ID", "");
            if (strPM_Internal_Consumption_ID.equals("")) {
        strPM_Internal_Consumption_ID = getParentID(vars, strM_Internal_Consumptionline_ID);
        if (strPM_Internal_Consumption_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|M_Internal_Consumption_ID");
        vars.setSessionValue(windowId + "|M_Internal_Consumption_ID", strPM_Internal_Consumption_ID);

        refreshParentSession(vars, strPM_Internal_Consumption_ID);
      }


      String strView = vars.getSessionValue(tabId + "|Lines.view");
      if (strView.equals("")) {
        strView = defaultTabView;

        if (strView.equals("EDIT")) {
          if (strM_Internal_Consumptionline_ID.equals("")) strM_Internal_Consumptionline_ID = firstElement(vars, tableSQL);
          if (strM_Internal_Consumptionline_ID.equals("")) strView = "RELATION";
        }
      }
      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strM_Internal_Consumptionline_ID, strPM_Internal_Consumption_ID, tableSQL);

      else printPageDataSheet(response, vars, strPM_Internal_Consumption_ID, strM_Internal_Consumptionline_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strM_Internal_Consumptionline_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strM_Internal_Consumptionline_ID.equals("")) strM_Internal_Consumptionline_ID = vars.getRequiredGlobalVariable("inpmInternalConsumptionlineId", windowId + "|M_Internal_Consumptionline_ID");
      else vars.setSessionValue(windowId + "|M_Internal_Consumptionline_ID", strM_Internal_Consumptionline_ID);
     
     
      String strPM_Internal_Consumption_ID = getParentID(vars, strM_Internal_Consumptionline_ID);
     
      vars.setSessionValue(windowId + "|M_Internal_Consumption_ID", strPM_Internal_Consumption_ID);
      vars.setSessionValue("800202|Header.view", "EDIT");

      refreshParentSession(vars, strPM_Internal_Consumption_ID);

      vars.setSessionValue(tabId + "|Lines.view", "EDIT");

      printPageEdit(response, request, vars, false, strM_Internal_Consumptionline_ID, strPM_Internal_Consumption_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|M_Internal_Consumptionline_ID");
      refreshParentSession(vars, strPM_Internal_Consumption_ID);


      String strView = vars.getSessionValue(tabId + "|Lines.view");
      String strM_Internal_Consumptionline_ID = "";
      if (strView.equals("")) {
        strView = defaultTabView;
        if (strView.equals("EDIT")) {
          strM_Internal_Consumptionline_ID = firstElement(vars, tableSQL);
          if (strM_Internal_Consumptionline_ID.equals("")) strView = "RELATION";
        }
      }
      if (strView.equals("EDIT")) {

        if (strM_Internal_Consumptionline_ID.equals("")) strM_Internal_Consumptionline_ID = firstElement(vars, tableSQL);
        printPageEdit(response, request, vars, false, strM_Internal_Consumptionline_ID, strPM_Internal_Consumption_ID, tableSQL);

      } else printPageDataSheet(response, vars, strPM_Internal_Consumption_ID, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamM_Internal_Consumption_ID", tabId + "|paramM_Internal_Consumption_ID");
vars.getRequestGlobalVariable("inpParamM_Product_ID", tabId + "|paramM_Product_ID");
vars.getRequestGlobalVariable("inpParamMovementQty", tabId + "|paramMovementQty");
vars.getRequestGlobalVariable("inpParamMovementQty_f", tabId + "|paramMovementQty_f");

            String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");

     
      vars.removeSessionValue(windowId + "|M_Internal_Consumptionline_ID");
      String strM_Internal_Consumptionline_ID="";

      String strView = vars.getSessionValue(tabId + "|Lines.view");
      if (strView.equals("")) strView=defaultTabView;

      if (strView.equals("EDIT")) {
        strM_Internal_Consumptionline_ID = firstElement(vars, tableSQL);
        if (strM_Internal_Consumptionline_ID.equals("")) {
          // filter returns empty set
          strView = "RELATION";
          // switch to grid permanently until the user changes the view again
          vars.setSessionValue(tabId + "|Lines.view", strView);
        }
      }

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strM_Internal_Consumptionline_ID, strPM_Internal_Consumption_ID, tableSQL);

      else printPageDataSheet(response, vars, strPM_Internal_Consumption_ID, strM_Internal_Consumptionline_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");
     

      String strM_Internal_Consumptionline_ID = vars.getGlobalVariable("inpmInternalConsumptionlineId", windowId + "|M_Internal_Consumptionline_ID", "");
      vars.setSessionValue(tabId + "|Lines.view", "RELATION");
      printPageDataSheet(response, vars, strPM_Internal_Consumption_ID, strM_Internal_Consumptionline_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");


      printPageEdit(response, request, vars, true, "", strPM_Internal_Consumption_ID, tableSQL);

    } else if (vars.commandIn("EDIT")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");

      @SuppressWarnings("unused") // In Expense Invoice tab this variable is not used, to be fixed
      String strM_Internal_Consumptionline_ID = vars.getGlobalVariable("inpmInternalConsumptionlineId", windowId + "|M_Internal_Consumptionline_ID", "");
      vars.setSessionValue(tabId + "|Lines.view", "EDIT");

      setHistoryCommand(request, "EDIT");
      printPageEdit(response, request, vars, false, strM_Internal_Consumptionline_ID, strPM_Internal_Consumption_ID, tableSQL);

    } else if (vars.commandIn("NEXT")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");
      String strM_Internal_Consumptionline_ID = vars.getRequiredStringParameter("inpmInternalConsumptionlineId");
     
      String strNext = nextElement(vars, strM_Internal_Consumptionline_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPM_Internal_Consumption_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");
      String strM_Internal_Consumptionline_ID = vars.getRequiredStringParameter("inpmInternalConsumptionlineId");
     
      String strPrevious = previousElement(vars, strM_Internal_Consumptionline_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPM_Internal_Consumption_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");

      vars.setSessionValue(tabId + "|Lines.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");

      String strInitRecord = vars.getSessionValue(tabId + "|Lines.initRecordNumber");
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
      if (strInitRecord.equals("") || strInitRecord.equals("0")) {
        vars.setSessionValue(tabId + "|Lines.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|Lines.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|M_Internal_Consumptionline_ID");
      vars.setSessionValue(windowId + "|M_Internal_Consumption_ID", strPM_Internal_Consumption_ID);
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("NEXT_RELATION")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");

      String strInitRecord = vars.getSessionValue(tabId + "|Lines.initRecordNumber");
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
      int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
      if (initRecord==0) initRecord=1;
      initRecord += intRecordRange;
      strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
      vars.setSessionValue(tabId + "|Lines.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|M_Internal_Consumptionline_ID");
      vars.setSessionValue(windowId + "|M_Internal_Consumption_ID", strPM_Internal_Consumption_ID);
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("FIRST")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");
     
      String strFirst = firstElement(vars, tableSQL);

      printPageEdit(response, request, vars, false, strFirst, strPM_Internal_Consumption_ID, tableSQL);
    } else if (vars.commandIn("LAST_RELATION")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");

      String strLast = lastElement(vars, tableSQL);
      printPageDataSheet(response, vars, strPM_Internal_Consumption_ID, strLast, tableSQL);
    } else if (vars.commandIn("LAST")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");
     
      String strLast = lastElement(vars, tableSQL);

      printPageEdit(response, request, vars, false, strLast, strPM_Internal_Consumption_ID, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");
      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I', strPM_Internal_Consumption_ID);     
      if (!myError.isEmpty()) {       
        response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
      }
      else {
    if (myError.isEmpty()) {
      myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsInserted");
      myError.setMessage(total + " " + myError.getMessage());
      vars.setMessage(tabId, myError);
    }       
        if (vars.commandIn("SAVE_NEW_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
        else if (vars.commandIn("SAVE_NEW_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
    } else if (vars.commandIn("SAVE_EDIT_RELATION", "SAVE_EDIT_NEW", "SAVE_EDIT_EDIT", "SAVE_EDIT_NEXT")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");
      String strM_Internal_Consumptionline_ID = vars.getRequiredGlobalVariable("inpmInternalConsumptionlineId", windowId + "|M_Internal_Consumptionline_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U', strPM_Internal_Consumption_ID);     
      if (!myError.isEmpty()) {
        response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
      }
      else {
        if (myError.isEmpty()) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsUpdated");
          myError.setMessage(total + " " + myError.getMessage());
          vars.setMessage(tabId, myError);
        }
        if (vars.commandIn("SAVE_EDIT_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
        else if (vars.commandIn("SAVE_EDIT_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        else if (vars.commandIn("SAVE_EDIT_NEXT")) {
          String strNext = nextElement(vars, strM_Internal_Consumptionline_ID, tableSQL);
          vars.setSessionValue(windowId + "|M_Internal_Consumptionline_ID", strNext);
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        } else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
/*    } else if (vars.commandIn("DELETE_RELATION")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");

      String strM_Internal_Consumptionline_ID = vars.getRequiredInStringParameter("inpmInternalConsumptionlineId");
      String message = deleteRelation(vars, strM_Internal_Consumptionline_ID, strPM_Internal_Consumption_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|mInternalConsumptionlineId");
        vars.setSessionValue(tabId + "|Lines.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID");

      String strM_Internal_Consumptionline_ID = vars.getRequiredStringParameter("inpmInternalConsumptionlineId");
      //LinesData data = getEditVariables(vars, strPM_Internal_Consumption_ID);
      int total = 0;
      OBError myError = null;
      if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
        vars.setMessage(tabId, myError);
      } else {
        try {
          total = LinesData.delete(this, strM_Internal_Consumptionline_ID, strPM_Internal_Consumption_ID, Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), Utility.getContext(this, vars, "#User_Org", windowId, accesslevel));
        } catch(ServletException ex) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myError.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myError);
        }
        if (myError==null && total==0) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
          vars.setMessage(tabId, myError);
        }
        vars.removeSessionValue(windowId + "|mInternalConsumptionlineId");
        vars.setSessionValue(tabId + "|Lines.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());








    } else if (vars.getCommand().toUpperCase().startsWith("BUTTON") || vars.getCommand().toUpperCase().startsWith("SAVE_BUTTON")) {
      pageErrorPopUp(response);
    } else pageError(response);
  }
View Full Code Here

    boolHist = false;
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      String strChanged = vars.getStringParameter("inpLastFieldChanged");
      if (log4j.isDebugEnabled())
        log4j.debug("CHANGED: " + strChanged);
      String strLocator = vars.getStringParameter("inpmProductId_LOC");
      String strQty = vars.getNumericParameter("inpmProductId_QTY");
      String strUOM = vars.getStringParameter("inpmProductId_UOM");
      String strAttribute = vars.getStringParameter("inpmProductId_ATR");
      String strQtyOrder = vars.getNumericParameter("inpmProductId_PQTY");
      String strPUOM = vars.getStringParameter("inpmProductId_PUOM");
      String strMProductID = vars.getStringParameter("inpmProductId");
      String strWindowId = vars.getStringParameter("inpwindowId");
      String strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId);
      String strWharehouse = Utility.getContext(this, vars, "#M_Warehouse_ID", strWindowId);
      String strTabId = vars.getStringParameter("inpTabId");
      String strmInoutlineId = vars.getStringParameter("inpmInoutlineId");

      try {
        printPage(response, vars, strLocator, strQty, strUOM, strAttribute, strQtyOrder, strPUOM,
            strMProductID, strIsSOTrx, strWharehouse, strTabId, strmInoutlineId);
      } catch (ServletException ex) {
View Full Code Here

  private static final int accesslevel = 3;
  private static final double SUBTABS_COL_SIZE = 15;

  public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
    TableSQLData tableSQL = null;
    VariablesSecureApp vars = new VariablesSecureApp(request);
    Boolean saveRequest = (Boolean) request.getAttribute("autosave");
   
    if(saveRequest != null && saveRequest){
      String currentOrg = vars.getStringParameter("inpadOrgId");
      String currentClient = vars.getStringParameter("inpadClientId");
      boolean editableTab = (!org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)
                            && (currentOrg.equals("") || Utility.isElementInList(Utility.getContext(this, vars,"#User_Org", windowId, accesslevel), currentOrg))
                            && (currentClient.equals("") || Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),currentClient)));
   
        OBError myError = new OBError();
        String commandType = request.getParameter("inpCommandType");
        String strmPricelistId = request.getParameter("inpmPricelistId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strmPricelistId.equals(""))
              total = saveRecord(vars, myError, 'U');
          else
              total = saveRecord(vars, myError, 'I');
         
          if (!myError.isEmpty() && total == 0)    
            throw new OBException(myError.getMessage());
        }
        vars.setSessionValue(request.getParameter("mappingName") +"|hash", vars.getPostDataHash());
        vars.setSessionValue(tabId + "|Header.view", "EDIT");
       
        return;
    }
   
    try {
      tableSQL = new TableSQLData(vars, this, tabId, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    String strOrderBy = vars.getSessionValue(tabId + "|orderby");
    if (!strOrderBy.equals("")) {
      vars.setSessionValue(tabId + "|newOrder", "1");
    }

    if (vars.commandIn("DEFAULT")) {

      String strM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID", "");
     

      String strView = vars.getSessionValue(tabId + "|PriceList.view");
      if (strView.equals("")) {
        strView = defaultTabView;

        if (strView.equals("EDIT")) {
          if (strM_PriceList_ID.equals("")) strM_PriceList_ID = firstElement(vars, tableSQL);
          if (strM_PriceList_ID.equals("")) strView = "RELATION";
        }
      }
      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strM_PriceList_ID, tableSQL);

      else printPageDataSheet(response, vars, strM_PriceList_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strM_PriceList_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strM_PriceList_ID.equals("")) strM_PriceList_ID = vars.getRequiredGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");
      else vars.setSessionValue(windowId + "|M_PriceList_ID", strM_PriceList_ID);
     
      vars.setSessionValue(tabId + "|PriceList.view", "EDIT");

      printPageEdit(response, request, vars, false, strM_PriceList_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {


      String strView = vars.getSessionValue(tabId + "|PriceList.view");
      String strM_PriceList_ID = "";
      if (strView.equals("")) {
        strView = defaultTabView;
        if (strView.equals("EDIT")) {
          strM_PriceList_ID = firstElement(vars, tableSQL);
          if (strM_PriceList_ID.equals("")) strView = "RELATION";
        }
      }
      if (strView.equals("EDIT")) {

        if (strM_PriceList_ID.equals("")) strM_PriceList_ID = firstElement(vars, tableSQL);
        printPageEdit(response, request, vars, false, strM_PriceList_ID, tableSQL);

      } else printPageDataSheet(response, vars, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamName", tabId + "|paramName");

     
     
      vars.removeSessionValue(windowId + "|M_PriceList_ID");
      String strM_PriceList_ID="";

      String strView = vars.getSessionValue(tabId + "|PriceList.view");
      if (strView.equals("")) strView=defaultTabView;

      if (strView.equals("EDIT")) {
        strM_PriceList_ID = firstElement(vars, tableSQL);
        if (strM_PriceList_ID.equals("")) {
          // filter returns empty set
          strView = "RELATION";
          // switch to grid permanently until the user changes the view again
          vars.setSessionValue(tabId + "|PriceList.view", strView);
        }
      }

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strM_PriceList_ID, tableSQL);

      else printPageDataSheet(response, vars, strM_PriceList_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
     

      String strM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID", "");
      vars.setSessionValue(tabId + "|PriceList.view", "RELATION");
      printPageDataSheet(response, vars, strM_PriceList_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {


      printPageEdit(response, request, vars, true, "", tableSQL);

    } else if (vars.commandIn("EDIT")) {

      @SuppressWarnings("unused") // In Expense Invoice tab this variable is not used, to be fixed
      String strM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID", "");
      vars.setSessionValue(tabId + "|PriceList.view", "EDIT");

      setHistoryCommand(request, "EDIT");
      printPageEdit(response, request, vars, false, strM_PriceList_ID, tableSQL);

    } else if (vars.commandIn("NEXT")) {

      String strM_PriceList_ID = vars.getRequiredStringParameter("inpmPricelistId");
     
      String strNext = nextElement(vars, strM_PriceList_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {

      String strM_PriceList_ID = vars.getRequiredStringParameter("inpmPricelistId");
     
      String strPrevious = previousElement(vars, strM_PriceList_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {

      vars.setSessionValue(tabId + "|PriceList.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {

      String strInitRecord = vars.getSessionValue(tabId + "|PriceList.initRecordNumber");
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
      if (strInitRecord.equals("") || strInitRecord.equals("0")) {
        vars.setSessionValue(tabId + "|PriceList.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|PriceList.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|M_PriceList_ID");

      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("NEXT_RELATION")) {

      String strInitRecord = vars.getSessionValue(tabId + "|PriceList.initRecordNumber");
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
      int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
      if (initRecord==0) initRecord=1;
      initRecord += intRecordRange;
      strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
      vars.setSessionValue(tabId + "|PriceList.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|M_PriceList_ID");

      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("FIRST")) {

     
      String strFirst = firstElement(vars, tableSQL);

      printPageEdit(response, request, vars, false, strFirst, tableSQL);
    } else if (vars.commandIn("LAST_RELATION")) {

      String strLast = lastElement(vars, tableSQL);
      printPageDataSheet(response, vars, strLast, tableSQL);
    } else if (vars.commandIn("LAST")) {

     
      String strLast = lastElement(vars, tableSQL);

      printPageEdit(response, request, vars, false, strLast, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {

      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I');     
      if (!myError.isEmpty()) {       
        response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
      }
      else {
    if (myError.isEmpty()) {
      myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsInserted");
      myError.setMessage(total + " " + myError.getMessage());
      vars.setMessage(tabId, myError);
    }       
        if (vars.commandIn("SAVE_NEW_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
        else if (vars.commandIn("SAVE_NEW_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
    } else if (vars.commandIn("SAVE_EDIT_RELATION", "SAVE_EDIT_NEW", "SAVE_EDIT_EDIT", "SAVE_EDIT_NEXT")) {

      String strM_PriceList_ID = vars.getRequiredGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U');     
      if (!myError.isEmpty()) {
        response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
      }
      else {
        if (myError.isEmpty()) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsUpdated");
          myError.setMessage(total + " " + myError.getMessage());
          vars.setMessage(tabId, myError);
        }
        if (vars.commandIn("SAVE_EDIT_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
        else if (vars.commandIn("SAVE_EDIT_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        else if (vars.commandIn("SAVE_EDIT_NEXT")) {
          String strNext = nextElement(vars, strM_PriceList_ID, tableSQL);
          vars.setSessionValue(windowId + "|M_PriceList_ID", strNext);
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        } else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
/*    } else if (vars.commandIn("DELETE_RELATION")) {

      String strM_PriceList_ID = vars.getRequiredInStringParameter("inpmPricelistId");
      String message = deleteRelation(vars, strM_PriceList_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|mPricelistId");
        vars.setSessionValue(tabId + "|PriceList.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {

      String strM_PriceList_ID = vars.getRequiredStringParameter("inpmPricelistId");
      //PriceListData data = getEditVariables(vars);
      int total = 0;
      OBError myError = null;
      if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
        vars.setMessage(tabId, myError);
      } else {
        try {
          total = PriceListData.delete(this, strM_PriceList_ID, Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), Utility.getContext(this, vars, "#User_Org", windowId, accesslevel));
        } catch(ServletException ex) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myError.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myError);
        }
        if (myError==null && total==0) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
          vars.setMessage(tabId, myError);
        }
        vars.removeSessionValue(windowId + "|mPricelistId");
        vars.setSessionValue(tabId + "|PriceList.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());








    } else if (vars.getCommand().toUpperCase().startsWith("BUTTON") || vars.getCommand().toUpperCase().startsWith("SAVE_BUTTON")) {
      pageErrorPopUp(response);
    } else pageError(response);
  }
View Full Code Here

    boolHist = false;
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      String strRMailTextId = vars.getStringParameter("inprMailtextId");
      String strTabId = vars.getStringParameter("inpTabId");

      try {
        printPage(response, vars, strRMailTextId, strTabId);
      } catch (ServletException ex) {
        pageErrorCallOut(response);
View Full Code Here

    boolHist = false;
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      String strChanged = vars.getStringParameter("inpLastFieldChanged");
      if (log4j.isDebugEnabled())
        log4j.debug("CHANGED: " + strChanged);
      String strMProductID = vars.getStringParameter("inpmProductId");
      String strADOrgID = vars.getStringParameter("inpadOrgId");
      String strCInvoiceID = vars.getStringParameter("inpcInvoiceId");
      String strWindowId = vars.getStringParameter("inpwindowId");
      String strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId);
      String strWharehouse = Utility.getContext(this, vars, "#M_Warehouse_ID", strWindowId);
      String strCChargeID = vars.getStringParameter("inpcChargeId");
      String strTabId = vars.getStringParameter("inpTabId");

      try {
        printPage(response, vars, strMProductID, strADOrgID, strCInvoiceID, strIsSOTrx,
            strWharehouse, strCChargeID, strTabId);
      } catch (ServletException ex) {
View Full Code Here

TOP

Related Classes of org.openbravo.base.secureApp.VariablesSecureApp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.