Examples of VariablesSecureApp


Examples of org.openbravo.base.secureApp.VariablesSecureApp

  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 strhrmComLocationId = request.getParameter("inphrmComLocationId");
         String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strhrmComLocationId.equals(""))
              total = saveRecord(vars, myError, 'U', strPHRM_Genralinfo_ID);
          else
              total = saveRecord(vars, myError, 'I', strPHRM_Genralinfo_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 strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID", "");

      String strHRM_Com_Location_ID = vars.getGlobalVariable("inphrmComLocationId", windowId + "|HRM_Com_Location_ID", "");
            if (strPHRM_Genralinfo_ID.equals("")) {
        strPHRM_Genralinfo_ID = getParentID(vars, strHRM_Com_Location_ID);
        if (strPHRM_Genralinfo_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|HRM_Genralinfo_ID");
        vars.setSessionValue(windowId + "|HRM_Genralinfo_ID", strPHRM_Genralinfo_ID);

        refreshParentSession(vars, strPHRM_Genralinfo_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strHRM_Com_Location_ID, strPHRM_Genralinfo_ID, tableSQL);

      else printPageDataSheet(response, vars, strPHRM_Genralinfo_ID, strHRM_Com_Location_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Com_Location_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Com_Location_ID.equals("")) strHRM_Com_Location_ID = vars.getRequiredGlobalVariable("inphrmComLocationId", windowId + "|HRM_Com_Location_ID");
      else vars.setSessionValue(windowId + "|HRM_Com_Location_ID", strHRM_Com_Location_ID);
     
     
      String strPHRM_Genralinfo_ID = getParentID(vars, strHRM_Com_Location_ID);
     
      vars.setSessionValue(windowId + "|HRM_Genralinfo_ID", strPHRM_Genralinfo_ID);
      vars.setSessionValue("D0F5E2F283E94052946B2FDA67393F9B|General.view", "EDIT");

      refreshParentSession(vars, strPHRM_Genralinfo_ID);

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

      printPageEdit(response, request, vars, false, strHRM_Com_Location_ID, strPHRM_Genralinfo_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|HRM_Com_Location_ID");
      refreshParentSession(vars, strPHRM_Genralinfo_ID);


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

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

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

            String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");

     
      vars.removeSessionValue(windowId + "|HRM_Com_Location_ID");
      String strHRM_Com_Location_ID="";

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

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

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strHRM_Com_Location_ID, strPHRM_Genralinfo_ID, tableSQL);

      else printPageDataSheet(response, vars, strPHRM_Genralinfo_ID, strHRM_Com_Location_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");
     

      String strHRM_Com_Location_ID = vars.getGlobalVariable("inphrmComLocationId", windowId + "|HRM_Com_Location_ID", "");
      vars.setSessionValue(tabId + "|Locations.view", "RELATION");
      printPageDataSheet(response, vars, strPHRM_Genralinfo_ID, strHRM_Com_Location_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");
      String strHRM_Com_Location_ID = vars.getRequiredStringParameter("inphrmComLocationId");
     
      String strNext = nextElement(vars, strHRM_Com_Location_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPHRM_Genralinfo_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");
      String strHRM_Com_Location_ID = vars.getRequiredStringParameter("inphrmComLocationId");
     
      String strPrevious = previousElement(vars, strHRM_Com_Location_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPHRM_Genralinfo_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");

      vars.setSessionValue(tabId + "|Locations.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");

      String strInitRecord = vars.getSessionValue(tabId + "|Locations.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 + "|Locations.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|Locations.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|HRM_Com_Location_ID");
      vars.setSessionValue(windowId + "|HRM_Genralinfo_ID", strPHRM_Genralinfo_ID);
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("NEXT_RELATION")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");

      String strInitRecord = vars.getSessionValue(tabId + "|Locations.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 + "|Locations.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|HRM_Com_Location_ID");
      vars.setSessionValue(windowId + "|HRM_Genralinfo_ID", strPHRM_Genralinfo_ID);
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("FIRST")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");
     
      String strFirst = firstElement(vars, tableSQL);

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

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

      printPageEdit(response, request, vars, false, strLast, strPHRM_Genralinfo_ID, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");
      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I', strPHRM_Genralinfo_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 strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");
      String strHRM_Com_Location_ID = vars.getRequiredGlobalVariable("inphrmComLocationId", windowId + "|HRM_Com_Location_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U', strPHRM_Genralinfo_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, strHRM_Com_Location_ID, tableSQL);
          vars.setSessionValue(windowId + "|HRM_Com_Location_ID", strNext);
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        } else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
/*    } else if (vars.commandIn("DELETE_RELATION")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");

      String strHRM_Com_Location_ID = vars.getRequiredInStringParameter("inphrmComLocationId");
      String message = deleteRelation(vars, strHRM_Com_Location_ID, strPHRM_Genralinfo_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|hrmComLocationId");
        vars.setSessionValue(tabId + "|Locations.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPHRM_Genralinfo_ID = vars.getGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");

      String strHRM_Com_Location_ID = vars.getRequiredStringParameter("inphrmComLocationId");
      //LocationsData data = getEditVariables(vars, strPHRM_Genralinfo_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 = LocationsData.delete(this, strHRM_Com_Location_ID, strPHRM_Genralinfo_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 + "|hrmComLocationId");
        vars.setSessionValue(tabId + "|Locations.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

Examples of org.openbravo.base.secureApp.VariablesSecureApp

  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 strmaSequenceIcId = request.getParameter("inpmaSequenceIcId");
         String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strmaSequenceIcId.equals(""))
              total = saveRecord(vars, myError, 'U', strPMA_Sequence_ID);
          else
              total = saveRecord(vars, myError, 'I', strPMA_Sequence_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 strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID", "");

      String strMA_Sequence_Ic_ID = vars.getGlobalVariable("inpmaSequenceIcId", windowId + "|MA_Sequence_Ic_ID", "");
            if (strPMA_Sequence_ID.equals("")) {
        strPMA_Sequence_ID = getParentID(vars, strMA_Sequence_Ic_ID);
        if (strPMA_Sequence_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|MA_Sequence_ID");
        vars.setSessionValue(windowId + "|MA_Sequence_ID", strPMA_Sequence_ID);
      vars.removeSessionValue(windowId + "|MA_Processplan_Version_ID");
        refreshParentSession(vars, strPMA_Sequence_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strMA_Sequence_Ic_ID, strPMA_Sequence_ID, tableSQL);

      else printPageDataSheet(response, vars, strPMA_Sequence_ID, strMA_Sequence_Ic_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strMA_Sequence_Ic_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strMA_Sequence_Ic_ID.equals("")) strMA_Sequence_Ic_ID = vars.getRequiredGlobalVariable("inpmaSequenceIcId", windowId + "|MA_Sequence_Ic_ID");
      else vars.setSessionValue(windowId + "|MA_Sequence_Ic_ID", strMA_Sequence_Ic_ID);
     
     
      String strPMA_Sequence_ID = getParentID(vars, strMA_Sequence_Ic_ID);
     
      vars.setSessionValue(windowId + "|MA_Sequence_ID", strPMA_Sequence_ID);
      vars.setSessionValue("800109|Operation.view", "EDIT");
      vars.removeSessionValue(windowId + "|MA_Processplan_Version_ID");
      refreshParentSession(vars, strPMA_Sequence_ID);

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

      printPageEdit(response, request, vars, false, strMA_Sequence_Ic_ID, strPMA_Sequence_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|MA_Sequence_Ic_ID");
      refreshParentSession(vars, strPMA_Sequence_ID);


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

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

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

            String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");

     
      vars.removeSessionValue(windowId + "|MA_Sequence_Ic_ID");
      String strMA_Sequence_Ic_ID="";

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

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

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strMA_Sequence_Ic_ID, strPMA_Sequence_ID, tableSQL);

      else printPageDataSheet(response, vars, strPMA_Sequence_ID, strMA_Sequence_Ic_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");
     

      String strMA_Sequence_Ic_ID = vars.getGlobalVariable("inpmaSequenceIcId", windowId + "|MA_Sequence_Ic_ID", "");
      vars.setSessionValue(tabId + "|IndirectCost.view", "RELATION");
      printPageDataSheet(response, vars, strPMA_Sequence_ID, strMA_Sequence_Ic_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");
      String strMA_Sequence_Ic_ID = vars.getRequiredStringParameter("inpmaSequenceIcId");
     
      String strNext = nextElement(vars, strMA_Sequence_Ic_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPMA_Sequence_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");
      String strMA_Sequence_Ic_ID = vars.getRequiredStringParameter("inpmaSequenceIcId");
     
      String strPrevious = previousElement(vars, strMA_Sequence_Ic_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPMA_Sequence_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");

      vars.setSessionValue(tabId + "|IndirectCost.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");

      String strInitRecord = vars.getSessionValue(tabId + "|IndirectCost.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 + "|IndirectCost.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|IndirectCost.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|MA_Sequence_Ic_ID");
      vars.setSessionValue(windowId + "|MA_Sequence_ID", strPMA_Sequence_ID);
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("NEXT_RELATION")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");

      String strInitRecord = vars.getSessionValue(tabId + "|IndirectCost.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 + "|IndirectCost.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|MA_Sequence_Ic_ID");
      vars.setSessionValue(windowId + "|MA_Sequence_ID", strPMA_Sequence_ID);
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("FIRST")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");
     
      String strFirst = firstElement(vars, tableSQL);

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

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

      printPageEdit(response, request, vars, false, strLast, strPMA_Sequence_ID, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");
      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I', strPMA_Sequence_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 strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");
      String strMA_Sequence_Ic_ID = vars.getRequiredGlobalVariable("inpmaSequenceIcId", windowId + "|MA_Sequence_Ic_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U', strPMA_Sequence_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, strMA_Sequence_Ic_ID, tableSQL);
          vars.setSessionValue(windowId + "|MA_Sequence_Ic_ID", strNext);
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        } else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
/*    } else if (vars.commandIn("DELETE_RELATION")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");

      String strMA_Sequence_Ic_ID = vars.getRequiredInStringParameter("inpmaSequenceIcId");
      String message = deleteRelation(vars, strMA_Sequence_Ic_ID, strPMA_Sequence_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|maSequenceIcId");
        vars.setSessionValue(tabId + "|IndirectCost.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");

      String strMA_Sequence_Ic_ID = vars.getRequiredStringParameter("inpmaSequenceIcId");
      //IndirectCostData data = getEditVariables(vars, strPMA_Sequence_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 = IndirectCostData.delete(this, strMA_Sequence_Ic_ID, strPMA_Sequence_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 + "|maSequenceIcId");
        vars.setSessionValue(tabId + "|IndirectCost.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

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 strChanged = vars.getStringParameter("inpLastFieldChanged");
      if (log4j.isDebugEnabled())
        log4j.debug("CHANGED: " + strChanged);
      String strBPartner = vars.getStringParameter("inpcBpartnerId");
      String strDocTypeTarget = vars.getStringParameter("inpcDoctypetargetId");
      String strDocType = vars.getStringParameter("inpcDoctypeId");
      String docNo = vars.getStringParameter("inpdocumentno");
      String strOrder = vars.getStringParameter("inpcOrderId");
      String strDescription = vars.getStringParameter("inpdescription");
      String strTabId = vars.getStringParameter("inpTabId");

      try {
        printPage(response, vars, strBPartner, strDocTypeTarget, strDocType, docNo, strOrder,
            strDescription, strTabId);
      } catch (ServletException ex) {
View Full Code Here

Examples of org.openbravo.base.secureApp.VariablesSecureApp

  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 strmSernoctlId = request.getParameter("inpmSernoctlId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strmSernoctlId.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_SerNoCtl_ID = vars.getGlobalVariable("inpmSernoctlId", windowId + "|M_SerNoCtl_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strM_SerNoCtl_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strM_SerNoCtl_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strM_SerNoCtl_ID.equals("")) strM_SerNoCtl_ID = vars.getRequiredGlobalVariable("inpmSernoctlId", windowId + "|M_SerNoCtl_ID");
      else vars.setSessionValue(windowId + "|M_SerNoCtl_ID", strM_SerNoCtl_ID);
     
      vars.setSessionValue(tabId + "|NumberControl.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|M_SerNoCtl_ID");
      String strM_SerNoCtl_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strM_SerNoCtl_ID = vars.getGlobalVariable("inpmSernoctlId", windowId + "|M_SerNoCtl_ID", "");
      vars.setSessionValue(tabId + "|NumberControl.view", "RELATION");
      printPageDataSheet(response, vars, strM_SerNoCtl_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_SerNoCtl_ID = vars.getGlobalVariable("inpmSernoctlId", windowId + "|M_SerNoCtl_ID", "");
      vars.setSessionValue(tabId + "|NumberControl.view", "EDIT");

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

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

      String strM_SerNoCtl_ID = vars.getRequiredStringParameter("inpmSernoctlId");
     
      String strNext = nextElement(vars, strM_SerNoCtl_ID, tableSQL);

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

      String strM_SerNoCtl_ID = vars.getRequiredStringParameter("inpmSernoctlId");
     
      String strPrevious = previousElement(vars, strM_SerNoCtl_ID, tableSQL);

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

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

      String strInitRecord = vars.getSessionValue(tabId + "|NumberControl.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 + "|NumberControl.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|NumberControl.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|M_SerNoCtl_ID");

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

      String strInitRecord = vars.getSessionValue(tabId + "|NumberControl.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 + "|NumberControl.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|M_SerNoCtl_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_SerNoCtl_ID = vars.getRequiredGlobalVariable("inpmSernoctlId", windowId + "|M_SerNoCtl_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_SerNoCtl_ID, tableSQL);
          vars.setSessionValue(windowId + "|M_SerNoCtl_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_SerNoCtl_ID = vars.getRequiredInStringParameter("inpmSernoctlId");
      String message = deleteRelation(vars, strM_SerNoCtl_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|mSernoctlId");
        vars.setSessionValue(tabId + "|NumberControl.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {

      String strM_SerNoCtl_ID = vars.getRequiredStringParameter("inpmSernoctlId");
      //NumberControlData 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 = NumberControlData.delete(this, strM_SerNoCtl_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 + "|mSernoctlId");
        vars.setSessionValue(tabId + "|NumberControl.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

Examples of org.openbravo.base.secureApp.VariablesSecureApp

  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 strvmVehicleInsuranceId = request.getParameter("inpvmVehicleInsuranceId");
         String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strvmVehicleInsuranceId.equals(""))
              total = saveRecord(vars, myError, 'U', strPVM_Vehicle_Info_ID);
          else
              total = saveRecord(vars, myError, 'I', strPVM_Vehicle_Info_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 strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID", "");

      String strVM_Vehicle_Insurance_ID = vars.getGlobalVariable("inpvmVehicleInsuranceId", windowId + "|VM_Vehicle_Insurance_ID", "");
            if (strPVM_Vehicle_Info_ID.equals("")) {
        strPVM_Vehicle_Info_ID = getParentID(vars, strVM_Vehicle_Insurance_ID);
        if (strPVM_Vehicle_Info_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|VM_Vehicle_Info_ID");
        vars.setSessionValue(windowId + "|VM_Vehicle_Info_ID", strPVM_Vehicle_Info_ID);

        refreshParentSession(vars, strPVM_Vehicle_Info_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strVM_Vehicle_Insurance_ID, strPVM_Vehicle_Info_ID, tableSQL);

      else printPageDataSheet(response, vars, strPVM_Vehicle_Info_ID, strVM_Vehicle_Insurance_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strVM_Vehicle_Insurance_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strVM_Vehicle_Insurance_ID.equals("")) strVM_Vehicle_Insurance_ID = vars.getRequiredGlobalVariable("inpvmVehicleInsuranceId", windowId + "|VM_Vehicle_Insurance_ID");
      else vars.setSessionValue(windowId + "|VM_Vehicle_Insurance_ID", strVM_Vehicle_Insurance_ID);
     
     
      String strPVM_Vehicle_Info_ID = getParentID(vars, strVM_Vehicle_Insurance_ID);
     
      vars.setSessionValue(windowId + "|VM_Vehicle_Info_ID", strPVM_Vehicle_Info_ID);
      vars.setSessionValue("0A6DACAA46CE46618B83C9FC8134913B|Vehicle Information.view", "EDIT");

      refreshParentSession(vars, strPVM_Vehicle_Info_ID);

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

      printPageEdit(response, request, vars, false, strVM_Vehicle_Insurance_ID, strPVM_Vehicle_Info_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|VM_Vehicle_Insurance_ID");
      refreshParentSession(vars, strPVM_Vehicle_Info_ID);


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

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

      } else printPageDataSheet(response, vars, strPVM_Vehicle_Info_ID, "", tableSQL);

    } else if (vars.commandIn("RELATION")) {
            String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");
     

      String strVM_Vehicle_Insurance_ID = vars.getGlobalVariable("inpvmVehicleInsuranceId", windowId + "|VM_Vehicle_Insurance_ID", "");
      vars.setSessionValue(tabId + "|Insurance.view", "RELATION");
      printPageDataSheet(response, vars, strPVM_Vehicle_Info_ID, strVM_Vehicle_Insurance_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");
      String strVM_Vehicle_Insurance_ID = vars.getRequiredStringParameter("inpvmVehicleInsuranceId");
     
      String strNext = nextElement(vars, strVM_Vehicle_Insurance_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPVM_Vehicle_Info_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");
      String strVM_Vehicle_Insurance_ID = vars.getRequiredStringParameter("inpvmVehicleInsuranceId");
     
      String strPrevious = previousElement(vars, strVM_Vehicle_Insurance_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPVM_Vehicle_Info_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");

      vars.setSessionValue(tabId + "|Insurance.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");

      String strInitRecord = vars.getSessionValue(tabId + "|Insurance.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 + "|Insurance.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|Insurance.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|VM_Vehicle_Insurance_ID");
      vars.setSessionValue(windowId + "|VM_Vehicle_Info_ID", strPVM_Vehicle_Info_ID);
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("NEXT_RELATION")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");

      String strInitRecord = vars.getSessionValue(tabId + "|Insurance.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 + "|Insurance.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|VM_Vehicle_Insurance_ID");
      vars.setSessionValue(windowId + "|VM_Vehicle_Info_ID", strPVM_Vehicle_Info_ID);
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("FIRST")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");
     
      String strFirst = firstElement(vars, tableSQL);

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

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

      printPageEdit(response, request, vars, false, strLast, strPVM_Vehicle_Info_ID, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");
      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I', strPVM_Vehicle_Info_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 strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");
      String strVM_Vehicle_Insurance_ID = vars.getRequiredGlobalVariable("inpvmVehicleInsuranceId", windowId + "|VM_Vehicle_Insurance_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U', strPVM_Vehicle_Info_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, strVM_Vehicle_Insurance_ID, tableSQL);
          vars.setSessionValue(windowId + "|VM_Vehicle_Insurance_ID", strNext);
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        } else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
/*    } else if (vars.commandIn("DELETE_RELATION")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");

      String strVM_Vehicle_Insurance_ID = vars.getRequiredInStringParameter("inpvmVehicleInsuranceId");
      String message = deleteRelation(vars, strVM_Vehicle_Insurance_ID, strPVM_Vehicle_Info_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|vmVehicleInsuranceId");
        vars.setSessionValue(tabId + "|Insurance.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");

      String strVM_Vehicle_Insurance_ID = vars.getRequiredStringParameter("inpvmVehicleInsuranceId");
      //InsuranceData data = getEditVariables(vars, strPVM_Vehicle_Info_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 = InsuranceData.delete(this, strVM_Vehicle_Insurance_ID, strPVM_Vehicle_Info_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 + "|vmVehicleInsuranceId");
        vars.setSessionValue(tabId + "|Insurance.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.commandIn("BUTTONProcessed2F5C41CF6C534D069100D083BA0EA8E9")) {
        vars.setSessionValue("button2F5C41CF6C534D069100D083BA0EA8E9.strprocessed", vars.getStringParameter("inpprocessed"));
        vars.setSessionValue("button2F5C41CF6C534D069100D083BA0EA8E9.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("button2F5C41CF6C534D069100D083BA0EA8E9.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("button2F5C41CF6C534D069100D083BA0EA8E9.strClient", vars.getStringParameter("inpadClientId"));
       
       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("button2F5C41CF6C534D069100D083BA0EA8E9.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "2F5C41CF6C534D069100D083BA0EA8E9", request.getServletPath());   
     } else if (vars.commandIn("BUTTON2F5C41CF6C534D069100D083BA0EA8E9")) {
        String strVM_Vehicle_Insurance_ID = vars.getGlobalVariable("inpvmVehicleInsuranceId", windowId + "|VM_Vehicle_Insurance_ID", "");
        String strprocessed = vars.getSessionValue("button2F5C41CF6C534D069100D083BA0EA8E9.strprocessed");
        String strProcessing = vars.getSessionValue("button2F5C41CF6C534D069100D083BA0EA8E9.strProcessing");
        String strOrg = vars.getSessionValue("button2F5C41CF6C534D069100D083BA0EA8E9.strOrg");
        String strClient = vars.getSessionValue("button2F5C41CF6C534D069100D083BA0EA8E9.strClient");
       
       
        if ((org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) || !(Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),strClient&& Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),strOrg))){
          OBError myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
          vars.setMessage(tabId, myError);
          printPageClosePopUp(response, vars);
        }else{      
          printPageButtonProcessed2F5C41CF6C534D069100D083BA0EA8E9(response, vars, strVM_Vehicle_Insurance_ID, strprocessed, strProcessing);
        }


    } else if (vars.commandIn("SAVE_BUTTONProcessed2F5C41CF6C534D069100D083BA0EA8E9")) {
        String strVM_Vehicle_Insurance_ID = vars.getGlobalVariable("inpKey", windowId + "|VM_Vehicle_Insurance_ID", "");
        @SuppressWarnings("unused")
        String strprocessed = vars.getStringParameter("inpprocessed");
        String strProcessing = vars.getStringParameter("inpprocessing");
        OBError myMessage = null;
        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "2F5C41CF6C534D069100D083BA0EA8E9", (("VM_Vehicle_Insurance_ID".equalsIgnoreCase("AD_Language"))?"0":strVM_Vehicle_Insurance_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
         
         
          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myMessage.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myMessage);
        }
        //close popup
        if (myMessage!=null) {
          if (log4j.isDebugEnabled()) log4j.debug(myMessage.getMessage());
          vars.setMessage(tabId, myMessage);
        }
        printPageClosePopUp(response, vars);



    } else if (vars.commandIn("BUTTONPosted")) {
        String strVM_Vehicle_Insurance_ID = vars.getGlobalVariable("inpvmVehicleInsuranceId", windowId + "|VM_Vehicle_Insurance_ID", "");
        String strTableId = "8FFF199603724C6C9B433812E71EFE93";
        String strPosted = vars.getStringParameter("inpposted");
        String strProcessId = "";
        log4j.debug("Loading Posted button in table: " + strTableId);
        String strOrg = vars.getStringParameter("inpadOrgId");
        String strClient = vars.getStringParameter("inpadClientId");
        if ((org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) || !(Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),strClient&& Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),strOrg))){
          OBError myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
          vars.setMessage(tabId, myError);
          printPageClosePopUp(response, vars);
        }else{
          vars.setSessionValue("Posted|key", strVM_Vehicle_Insurance_ID);
          vars.setSessionValue("Posted|tableId", strTableId);
          vars.setSessionValue("Posted|tabId", tabId);
          vars.setSessionValue("Posted|posted", strPosted);
          vars.setSessionValue("Posted|processId", strProcessId);
          vars.setSessionValue("Posted|path", strDireccion + request.getServletPath());
          vars.setSessionValue("Posted|windowId", windowId);
          vars.setSessionValue("Posted|tabName", "Insurance");
          response.sendRedirect(strDireccion + "/ad_actionButton/Posted.html");
        }



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

Examples of org.openbravo.base.secureApp.VariablesSecureApp

  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 strhrmJobSpecId = request.getParameter("inphrmJobSpecId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strhrmJobSpecId.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_Spec_ID = vars.getGlobalVariable("inphrmJobSpecId", windowId + "|HRM_Job_Spec_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strHRM_Job_Spec_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Job_Spec_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Job_Spec_ID.equals("")) strHRM_Job_Spec_ID = vars.getRequiredGlobalVariable("inphrmJobSpecId", windowId + "|HRM_Job_Spec_ID");
      else vars.setSessionValue(windowId + "|HRM_Job_Spec_ID", strHRM_Job_Spec_ID);
     
      vars.setSessionValue(tabId + "|JobSpecifications.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|HRM_Job_Spec_ID");
      String strHRM_Job_Spec_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strHRM_Job_Spec_ID = vars.getGlobalVariable("inphrmJobSpecId", windowId + "|HRM_Job_Spec_ID", "");
      vars.setSessionValue(tabId + "|JobSpecifications.view", "RELATION");
      printPageDataSheet(response, vars, strHRM_Job_Spec_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_Spec_ID = vars.getGlobalVariable("inphrmJobSpecId", windowId + "|HRM_Job_Spec_ID", "");
      vars.setSessionValue(tabId + "|JobSpecifications.view", "EDIT");

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

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

      String strHRM_Job_Spec_ID = vars.getRequiredStringParameter("inphrmJobSpecId");
     
      String strNext = nextElement(vars, strHRM_Job_Spec_ID, tableSQL);

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

      String strHRM_Job_Spec_ID = vars.getRequiredStringParameter("inphrmJobSpecId");
     
      String strPrevious = previousElement(vars, strHRM_Job_Spec_ID, tableSQL);

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

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

      String strInitRecord = vars.getSessionValue(tabId + "|JobSpecifications.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 + "|JobSpecifications.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|JobSpecifications.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|HRM_Job_Spec_ID");

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

      String strInitRecord = vars.getSessionValue(tabId + "|JobSpecifications.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 + "|JobSpecifications.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|HRM_Job_Spec_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_Spec_ID = vars.getRequiredGlobalVariable("inphrmJobSpecId", windowId + "|HRM_Job_Spec_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_Spec_ID, tableSQL);
          vars.setSessionValue(windowId + "|HRM_Job_Spec_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_Spec_ID = vars.getRequiredInStringParameter("inphrmJobSpecId");
      String message = deleteRelation(vars, strHRM_Job_Spec_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|hrmJobSpecId");
        vars.setSessionValue(tabId + "|JobSpecifications.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {

      String strHRM_Job_Spec_ID = vars.getRequiredStringParameter("inphrmJobSpecId");
      //JobSpecificationsData 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 = JobSpecificationsData.delete(this, strHRM_Job_Spec_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 + "|hrmJobSpecId");
        vars.setSessionValue(tabId + "|JobSpecifications.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

Examples of org.openbravo.base.secureApp.VariablesSecureApp

  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 strhrmTmPunchId = request.getParameter("inphrmTmPunchId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strhrmTmPunchId.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_Tm_Punch_ID = vars.getGlobalVariable("inphrmTmPunchId", windowId + "|HRM_Tm_Punch_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strHRM_Tm_Punch_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Tm_Punch_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Tm_Punch_ID.equals("")) strHRM_Tm_Punch_ID = vars.getRequiredGlobalVariable("inphrmTmPunchId", windowId + "|HRM_Tm_Punch_ID");
      else vars.setSessionValue(windowId + "|HRM_Tm_Punch_ID", strHRM_Tm_Punch_ID);
     
      vars.setSessionValue(tabId + "|PunchInOut.view", "EDIT");

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

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


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

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

      } else printPageDataSheet(response, vars, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamTimein", tabId + "|paramTimein");
vars.getRequestGlobalVariable("inpParamTimein_f", tabId + "|paramTimein_f");

     
     
      vars.removeSessionValue(windowId + "|HRM_Tm_Punch_ID");
      String strHRM_Tm_Punch_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strHRM_Tm_Punch_ID = vars.getGlobalVariable("inphrmTmPunchId", windowId + "|HRM_Tm_Punch_ID", "");
      vars.setSessionValue(tabId + "|PunchInOut.view", "RELATION");
      printPageDataSheet(response, vars, strHRM_Tm_Punch_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_Tm_Punch_ID = vars.getGlobalVariable("inphrmTmPunchId", windowId + "|HRM_Tm_Punch_ID", "");
      vars.setSessionValue(tabId + "|PunchInOut.view", "EDIT");

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

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

      String strHRM_Tm_Punch_ID = vars.getRequiredStringParameter("inphrmTmPunchId");
     
      String strNext = nextElement(vars, strHRM_Tm_Punch_ID, tableSQL);

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

      String strHRM_Tm_Punch_ID = vars.getRequiredStringParameter("inphrmTmPunchId");
     
      String strPrevious = previousElement(vars, strHRM_Tm_Punch_ID, tableSQL);

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

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

      String strInitRecord = vars.getSessionValue(tabId + "|PunchInOut.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 + "|PunchInOut.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|PunchInOut.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|HRM_Tm_Punch_ID");

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

      String strInitRecord = vars.getSessionValue(tabId + "|PunchInOut.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 + "|PunchInOut.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|HRM_Tm_Punch_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_Tm_Punch_ID = vars.getRequiredGlobalVariable("inphrmTmPunchId", windowId + "|HRM_Tm_Punch_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_Tm_Punch_ID, tableSQL);
          vars.setSessionValue(windowId + "|HRM_Tm_Punch_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_Tm_Punch_ID = vars.getRequiredInStringParameter("inphrmTmPunchId");
      String message = deleteRelation(vars, strHRM_Tm_Punch_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|hrmTmPunchId");
        vars.setSessionValue(tabId + "|PunchInOut.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {

      String strHRM_Tm_Punch_ID = vars.getRequiredStringParameter("inphrmTmPunchId");
      //PunchInOutData 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 = PunchInOutData.delete(this, strHRM_Tm_Punch_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 + "|hrmTmPunchId");
        vars.setSessionValue(tabId + "|PunchInOut.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

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 strChanged = vars.getStringParameter("inpLastFieldChanged");
      if (log4j.isDebugEnabled())
        log4j.debug("CHANGED: " + strChanged);
      String strBPartner = vars.getStringParameter("inpcBpartnerId");
      String strOrderType = vars.getStringParameter("inpordertype");
      String strLocation = vars.getStringParameter("inpcBpartnerId_LOC");
      String strContact = vars.getStringParameter("inpcBpartnerId_CON");
      String strWindowId = vars.getStringParameter("inpwindowId");
      String strProjectId = vars.getStringParameter("inpcProjectId");
      String strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId);
      String strTabId = vars.getStringParameter("inpTabId");
      String strDeliveryRule = vars.getStringParameter("inpdeliveryrule");
      String strUserRep = vars.getStringParameter("inpsalesrepId");
      String strPaymentrule = vars.getStringParameter("inppaymentrule");
      String strPaymentterm = vars.getStringParameter("inpcPaymenttermId");
      String strInvoiceRule = vars.getStringParameter("inpinvoicerule");
      String strPriceList = vars.getStringParameter("inpmPricelistId");

      try {
        printPage(response, vars, strBPartner, strOrderType, strIsSOTrx, strWindowId, strLocation,
            strContact, strProjectId, strTabId, strDeliveryRule, strUserRep, strPaymentrule,
            strPaymentterm, strInvoiceRule, strPriceList);
View Full Code Here

Examples of org.openbravo.base.secureApp.VariablesSecureApp

  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 strcWithholdingId = request.getParameter("inpcWithholdingId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strcWithholdingId.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 strC_Withholding_ID = vars.getGlobalVariable("inpcWithholdingId", windowId + "|C_Withholding_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strC_Withholding_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strC_Withholding_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strC_Withholding_ID.equals("")) strC_Withholding_ID = vars.getRequiredGlobalVariable("inpcWithholdingId", windowId + "|C_Withholding_ID");
      else vars.setSessionValue(windowId + "|C_Withholding_ID", strC_Withholding_ID);
     
      vars.setSessionValue(tabId + "|Withholding.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|C_Withholding_ID");
      String strC_Withholding_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strC_Withholding_ID = vars.getGlobalVariable("inpcWithholdingId", windowId + "|C_Withholding_ID", "");
      vars.setSessionValue(tabId + "|Withholding.view", "RELATION");
      printPageDataSheet(response, vars, strC_Withholding_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 strC_Withholding_ID = vars.getGlobalVariable("inpcWithholdingId", windowId + "|C_Withholding_ID", "");
      vars.setSessionValue(tabId + "|Withholding.view", "EDIT");

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

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

      String strC_Withholding_ID = vars.getRequiredStringParameter("inpcWithholdingId");
     
      String strNext = nextElement(vars, strC_Withholding_ID, tableSQL);

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

      String strC_Withholding_ID = vars.getRequiredStringParameter("inpcWithholdingId");
     
      String strPrevious = previousElement(vars, strC_Withholding_ID, tableSQL);

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

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

      String strInitRecord = vars.getSessionValue(tabId + "|Withholding.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 + "|Withholding.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|Withholding.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|C_Withholding_ID");

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

      String strInitRecord = vars.getSessionValue(tabId + "|Withholding.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 + "|Withholding.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|C_Withholding_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 strC_Withholding_ID = vars.getRequiredGlobalVariable("inpcWithholdingId", windowId + "|C_Withholding_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, strC_Withholding_ID, tableSQL);
          vars.setSessionValue(windowId + "|C_Withholding_ID", strNext);
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        } else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
/*    } else if (vars.commandIn("DELETE_RELATION")) {

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

      String strC_Withholding_ID = vars.getRequiredStringParameter("inpcWithholdingId");
      //WithholdingData 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 = WithholdingData.delete(this, strC_Withholding_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 + "|cWithholdingId");
        vars.setSessionValue(tabId + "|Withholding.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

Examples of org.openbravo.base.secureApp.VariablesSecureApp

  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 strvmVehiclePartId = request.getParameter("inpvmVehiclePartId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strvmVehiclePartId.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 strVM_Vehicle_Part_ID = vars.getGlobalVariable("inpvmVehiclePartId", windowId + "|VM_Vehicle_Part_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strVM_Vehicle_Part_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strVM_Vehicle_Part_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strVM_Vehicle_Part_ID.equals("")) strVM_Vehicle_Part_ID = vars.getRequiredGlobalVariable("inpvmVehiclePartId", windowId + "|VM_Vehicle_Part_ID");
      else vars.setSessionValue(windowId + "|VM_Vehicle_Part_ID", strVM_Vehicle_Part_ID);
     
      vars.setSessionValue(tabId + "|VehiclePart.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|VM_Vehicle_Part_ID");
      String strVM_Vehicle_Part_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strVM_Vehicle_Part_ID = vars.getGlobalVariable("inpvmVehiclePartId", windowId + "|VM_Vehicle_Part_ID", "");
      vars.setSessionValue(tabId + "|VehiclePart.view", "RELATION");
      printPageDataSheet(response, vars, strVM_Vehicle_Part_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 strVM_Vehicle_Part_ID = vars.getGlobalVariable("inpvmVehiclePartId", windowId + "|VM_Vehicle_Part_ID", "");
      vars.setSessionValue(tabId + "|VehiclePart.view", "EDIT");

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

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

      String strVM_Vehicle_Part_ID = vars.getRequiredStringParameter("inpvmVehiclePartId");
     
      String strNext = nextElement(vars, strVM_Vehicle_Part_ID, tableSQL);

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

      String strVM_Vehicle_Part_ID = vars.getRequiredStringParameter("inpvmVehiclePartId");
     
      String strPrevious = previousElement(vars, strVM_Vehicle_Part_ID, tableSQL);

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

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

      String strInitRecord = vars.getSessionValue(tabId + "|VehiclePart.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 + "|VehiclePart.initRecordNumber", "0");
      } else {
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
        initRecord -= intRecordRange;
        strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
        vars.setSessionValue(tabId + "|VehiclePart.initRecordNumber", strInitRecord);
      }
      vars.removeSessionValue(windowId + "|VM_Vehicle_Part_ID");

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

      String strInitRecord = vars.getSessionValue(tabId + "|VehiclePart.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 + "|VehiclePart.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|VM_Vehicle_Part_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 strVM_Vehicle_Part_ID = vars.getRequiredGlobalVariable("inpvmVehiclePartId", windowId + "|VM_Vehicle_Part_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, strVM_Vehicle_Part_ID, tableSQL);
          vars.setSessionValue(windowId + "|VM_Vehicle_Part_ID", strNext);
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
        } else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
      }
/*    } else if (vars.commandIn("DELETE_RELATION")) {

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

      String strVM_Vehicle_Part_ID = vars.getRequiredStringParameter("inpvmVehiclePartId");
      //VehiclePartData 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 = VehiclePartData.delete(this, strVM_Vehicle_Part_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 + "|vmVehiclePartId");
        vars.setSessionValue(tabId + "|VehiclePart.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
TOP
Copyright © 2018 www.massapi.com. 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.