Examples of VariablesSecureApp


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 strQtyOrdered = vars.getNumericParameter("inpqtyordered");
      String strPriceActual = vars.getNumericParameter("inppriceactual");
      String strDiscount = vars.getNumericParameter("inpdiscount");
      String strPriceLimit = vars.getNumericParameter("inppricelimit");
      String strPriceList = vars.getNumericParameter("inppricelist");
      String strPriceStd = vars.getNumericParameter("inppricestd");
      String strCOrderId = vars.getStringParameter("inpcOrderId");
      String strProduct = vars.getStringParameter("inpmProductId");
      String strUOM = vars.getStringParameter("inpcUomId");
      String strAttribute = vars.getStringParameter("inpmAttributesetinstanceId");
      String strTabId = vars.getStringParameter("inpTabId");
      String strQty = vars.getNumericParameter("inpqtyordered");
      String cancelPriceAd = vars.getNumericParameter("inpcancelpricead");

      try {
        printPage(response, vars, strChanged, strQtyOrdered, strPriceActual, strDiscount,
            strPriceLimit, strPriceList, strCOrderId, strProduct, strUOM, strAttribute, strTabId,
            strQty, strPriceStd, cancelPriceAd);
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 strvmPartId = request.getParameter("inpvmPartId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strvmPartId.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_Part_ID = vars.getGlobalVariable("inpvmPartId", windowId + "|VM_Part_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strVM_Part_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strVM_Part_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strVM_Part_ID.equals("")) strVM_Part_ID = vars.getRequiredGlobalVariable("inpvmPartId", windowId + "|VM_Part_ID");
      else vars.setSessionValue(windowId + "|VM_Part_ID", strVM_Part_ID);
     
      vars.setSessionValue(tabId + "|Part.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|VM_Part_ID");
      String strVM_Part_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strVM_Part_ID = vars.getGlobalVariable("inpvmPartId", windowId + "|VM_Part_ID", "");
      vars.setSessionValue(tabId + "|Part.view", "RELATION");
      printPageDataSheet(response, vars, strVM_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_Part_ID = vars.getGlobalVariable("inpvmPartId", windowId + "|VM_Part_ID", "");
      vars.setSessionValue(tabId + "|Part.view", "EDIT");

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

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

      String strVM_Part_ID = vars.getRequiredStringParameter("inpvmPartId");
     
      String strNext = nextElement(vars, strVM_Part_ID, tableSQL);

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

      String strVM_Part_ID = vars.getRequiredStringParameter("inpvmPartId");
     
      String strPrevious = previousElement(vars, strVM_Part_ID, tableSQL);

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

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

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

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

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

      String strVM_Part_ID = vars.getRequiredStringParameter("inpvmPartId");
      //PartData 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 = PartData.delete(this, strVM_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 + "|vmPartId");
        vars.setSessionValue(tabId + "|Part.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 strmaSequenceId = request.getParameter("inpmaSequenceId");
         String strPMA_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strmaSequenceId.equals(""))
              total = saveRecord(vars, myError, 'U', strPMA_Processplan_Version_ID);
          else
              total = saveRecord(vars, myError, 'I', strPMA_Processplan_Version_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_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID", "");

      String strMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID", "");
            if (strPMA_Processplan_Version_ID.equals("")) {
        strPMA_Processplan_Version_ID = getParentID(vars, strMA_Sequence_ID);
        if (strPMA_Processplan_Version_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|MA_Processplan_Version_ID");
        vars.setSessionValue(windowId + "|MA_Processplan_Version_ID", strPMA_Processplan_Version_ID);
      vars.removeSessionValue(windowId + "|MA_Processplan_ID");
        refreshParentSession(vars, strPMA_Processplan_Version_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strMA_Sequence_ID, strPMA_Processplan_Version_ID, tableSQL);

      else printPageDataSheet(response, vars, strPMA_Processplan_Version_ID, strMA_Sequence_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strMA_Sequence_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strMA_Sequence_ID.equals("")) strMA_Sequence_ID = vars.getRequiredGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");
      else vars.setSessionValue(windowId + "|MA_Sequence_ID", strMA_Sequence_ID);
     
     
      String strPMA_Processplan_Version_ID = getParentID(vars, strMA_Sequence_ID);
     
      vars.setSessionValue(windowId + "|MA_Processplan_Version_ID", strPMA_Processplan_Version_ID);
      vars.setSessionValue("800146|Version.view", "EDIT");
      vars.removeSessionValue(windowId + "|MA_Processplan_ID");
      refreshParentSession(vars, strPMA_Processplan_Version_ID);

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

      printPageEdit(response, request, vars, false, strMA_Sequence_ID, strPMA_Processplan_Version_ID, tableSQL);

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


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

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

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

            String strPMA_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");

     
      vars.removeSessionValue(windowId + "|MA_Sequence_ID");
      String strMA_Sequence_ID="";

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

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

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strMA_Sequence_ID, strPMA_Processplan_Version_ID, tableSQL);

      else printPageDataSheet(response, vars, strPMA_Processplan_Version_ID, strMA_Sequence_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPMA_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");
     

      String strMA_Sequence_ID = vars.getGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID", "");
      vars.setSessionValue(tabId + "|Operation.view", "RELATION");
      printPageDataSheet(response, vars, strPMA_Processplan_Version_ID, strMA_Sequence_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPMA_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPMA_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPMA_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");
      String strMA_Sequence_ID = vars.getRequiredStringParameter("inpmaSequenceId");
     
      String strNext = nextElement(vars, strMA_Sequence_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPMA_Processplan_Version_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPMA_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");
      String strMA_Sequence_ID = vars.getRequiredStringParameter("inpmaSequenceId");
     
      String strPrevious = previousElement(vars, strMA_Sequence_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPMA_Processplan_Version_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");

      vars.setSessionValue(tabId + "|Operation.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPMA_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");

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

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

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

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

      printPageEdit(response, request, vars, false, strLast, strPMA_Processplan_Version_ID, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {
      String strPMA_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");
      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I', strPMA_Processplan_Version_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_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");
      String strMA_Sequence_ID = vars.getRequiredGlobalVariable("inpmaSequenceId", windowId + "|MA_Sequence_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U', strPMA_Processplan_Version_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_ID, tableSQL);
          vars.setSessionValue(windowId + "|MA_Sequence_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_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");

      String strMA_Sequence_ID = vars.getRequiredInStringParameter("inpmaSequenceId");
      String message = deleteRelation(vars, strMA_Sequence_ID, strPMA_Processplan_Version_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|maSequenceId");
        vars.setSessionValue(tabId + "|Operation.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPMA_Processplan_Version_ID = vars.getGlobalVariable("inpmaProcessplanVersionId", windowId + "|MA_Processplan_Version_ID");

      String strMA_Sequence_ID = vars.getRequiredStringParameter("inpmaSequenceId");
      //OperationData data = getEditVariables(vars, strPMA_Processplan_Version_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 = OperationData.delete(this, strMA_Sequence_ID, strPMA_Processplan_Version_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 + "|maSequenceId");
        vars.setSessionValue(tabId + "|Operation.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 = 6;
  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 stradWfNodeId = request.getParameter("inpadWfNodeId");
         String strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID");
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !stradWfNodeId.equals(""))
              total = saveRecord(vars, myError, 'U', strPAD_Workflow_ID);
          else
              total = saveRecord(vars, myError, 'I', strPAD_Workflow_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 strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID", "");

      String strAD_WF_Node_ID = vars.getGlobalVariable("inpadWfNodeId", windowId + "|AD_WF_Node_ID", "");
            if (strPAD_Workflow_ID.equals("")) {
        strPAD_Workflow_ID = getParentID(vars, strAD_WF_Node_ID);
        if (strPAD_Workflow_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|AD_Workflow_ID");
        vars.setSessionValue(windowId + "|AD_Workflow_ID", strPAD_Workflow_ID);

        refreshParentSession(vars, strPAD_Workflow_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strAD_WF_Node_ID, strPAD_Workflow_ID, tableSQL);

      else printPageDataSheet(response, vars, strPAD_Workflow_ID, strAD_WF_Node_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strAD_WF_Node_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strAD_WF_Node_ID.equals("")) strAD_WF_Node_ID = vars.getRequiredGlobalVariable("inpadWfNodeId", windowId + "|AD_WF_Node_ID");
      else vars.setSessionValue(windowId + "|AD_WF_Node_ID", strAD_WF_Node_ID);
     
     
      String strPAD_Workflow_ID = getParentID(vars, strAD_WF_Node_ID);
     
      vars.setSessionValue(windowId + "|AD_Workflow_ID", strPAD_Workflow_ID);
      vars.setSessionValue("148|Workflow.view", "EDIT");

      refreshParentSession(vars, strPAD_Workflow_ID);

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

      printPageEdit(response, request, vars, false, strAD_WF_Node_ID, strPAD_Workflow_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|AD_WF_Node_ID");
      refreshParentSession(vars, strPAD_Workflow_ID);


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

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

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

            String strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID");

     
      vars.removeSessionValue(windowId + "|AD_WF_Node_ID");
      String strAD_WF_Node_ID="";

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

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

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strAD_WF_Node_ID, strPAD_Workflow_ID, tableSQL);

      else printPageDataSheet(response, vars, strPAD_Workflow_ID, strAD_WF_Node_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID");
     

      String strAD_WF_Node_ID = vars.getGlobalVariable("inpadWfNodeId", windowId + "|AD_WF_Node_ID", "");
      vars.setSessionValue(tabId + "|Node.view", "RELATION");
      printPageDataSheet(response, vars, strPAD_Workflow_ID, strAD_WF_Node_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID");
      String strAD_WF_Node_ID = vars.getRequiredStringParameter("inpadWfNodeId");
     
      String strNext = nextElement(vars, strAD_WF_Node_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPAD_Workflow_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID");
      String strAD_WF_Node_ID = vars.getRequiredStringParameter("inpadWfNodeId");
     
      String strPrevious = previousElement(vars, strAD_WF_Node_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPAD_Workflow_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID");

      vars.setSessionValue(tabId + "|Node.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID");

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

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

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

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

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

      String strAD_WF_Node_ID = vars.getRequiredInStringParameter("inpadWfNodeId");
      String message = deleteRelation(vars, strAD_WF_Node_ID, strPAD_Workflow_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|adWfNodeId");
        vars.setSessionValue(tabId + "|Node.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPAD_Workflow_ID = vars.getGlobalVariable("inpadWorkflowId", windowId + "|AD_Workflow_ID");

      String strAD_WF_Node_ID = vars.getRequiredStringParameter("inpadWfNodeId");
      //NodeData data = getEditVariables(vars, strPAD_Workflow_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 = NodeData.delete(this, strAD_WF_Node_ID, strPAD_Workflow_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 + "|adWfNodeId");
        vars.setSessionValue(tabId + "|Node.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 = 1;
  private static final double SUBTABS_COL_SIZE = 15;

  public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
    TableSQLData tableSQL = null;
    VariablesSecureApp vars = new VariablesSecureApp(request);
    Boolean saveRequest = (Boolean) request.getAttribute("autosave");
   
    if(saveRequest != null && saveRequest){
      String currentOrg = vars.getStringParameter("inpadOrgId");
      String currentClient = vars.getStringParameter("inpadClientId");
      boolean editableTab = (!org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)
                            && (currentOrg.equals("") || Utility.isElementInList(Utility.getContext(this, vars,"#User_Org", windowId, accesslevel), currentOrg))
                            && (currentClient.equals("") || Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),currentClient)));
   
        OBError myError = new OBError();
        String commandType = request.getParameter("inpCommandType");
        String strcRemittanceId = request.getParameter("inpcRemittanceId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strcRemittanceId.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_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strC_Remittance_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strC_Remittance_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strC_Remittance_ID.equals("")) strC_Remittance_ID = vars.getRequiredGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");
      else vars.setSessionValue(windowId + "|C_Remittance_ID", strC_Remittance_ID);
     
      vars.setSessionValue(tabId + "|Header.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|C_Remittance_ID");
      String strC_Remittance_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID", "");
      vars.setSessionValue(tabId + "|Header.view", "RELATION");
      printPageDataSheet(response, vars, strC_Remittance_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_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID", "");
      vars.setSessionValue(tabId + "|Header.view", "EDIT");

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

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

      String strC_Remittance_ID = vars.getRequiredStringParameter("inpcRemittanceId");
     
      String strNext = nextElement(vars, strC_Remittance_ID, tableSQL);

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

      String strC_Remittance_ID = vars.getRequiredStringParameter("inpcRemittanceId");
     
      String strPrevious = previousElement(vars, strC_Remittance_ID, tableSQL);

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

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

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

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

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

      String strC_Remittance_ID = vars.getRequiredStringParameter("inpcRemittanceId");
      //HeaderData 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 = HeaderData.delete(this, strC_Remittance_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 + "|cRemittanceId");
        vars.setSessionValue(tabId + "|Header.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("BUTTONProcessed800142")) {
        vars.setSessionValue("button800142.strprocessed", vars.getStringParameter("inpprocessed"));
        vars.setSessionValue("button800142.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("button800142.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("button800142.strClient", vars.getStringParameter("inpadClientId"));
       
       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("button800142.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "800142", request.getServletPath());   
     } else if (vars.commandIn("BUTTON800142")) {
        String strC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID", "");
        String strprocessed = vars.getSessionValue("button800142.strprocessed");
        String strProcessing = vars.getSessionValue("button800142.strProcessing");
        String strOrg = vars.getSessionValue("button800142.strOrg");
        String strClient = vars.getSessionValue("button800142.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{      
          printPageButtonProcessed800142(response, vars, strC_Remittance_ID, strprocessed, strProcessing);
        }


    } else if (vars.commandIn("SAVE_BUTTONProcessed800142")) {
        String strC_Remittance_ID = vars.getGlobalVariable("inpKey", windowId + "|C_Remittance_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, "800142", (("C_Remittance_ID".equalsIgnoreCase("AD_Language"))?"0":strC_Remittance_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("BUTTONCreateFrom")) {
        String strC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID", "");
        String strTableId = "800179";
        String strProcessId = "";
        String strDateInvoiced = vars.getStringParameter("inpdateinvoiced", "");
        String strBPartnerLocation = vars.getStringParameter("inpcBpartnerLocationId", "");
        String strPriceList = vars.getStringParameter("inpmPricelistId", "");
        String strBPartner = vars.getStringParameter("inpcBpartnerId", "");
        String strBankAccount = vars.getStringParameter("inpcBankaccountId");
        String strStatementDate = vars.getStringParameter("inpstatementdate");
        String strOrg = vars.getStringParameter("inpadOrgId");
        String strClient = vars.getStringParameter("inpadClientId");
        String strIsreceipt = vars.getStringParameter("inpisreceipt");
        log4j.debug("Loading CreateFrom button in table: " + strTableId);
        vars.setSessionValue("CreateFrom|key", strC_Remittance_ID);
        vars.setSessionValue("CreateFrom|tableId", strTableId);
        vars.setSessionValue("CreateFrom|tabId", tabId);
        vars.setSessionValue("CreateFrom|processId", strProcessId);
        vars.setSessionValue("CreateFrom|path", strDireccion + request.getServletPath());
        vars.setSessionValue("CreateFrom|bpartnerLocation", strBPartnerLocation);
        vars.setSessionValue("CreateFrom|dateInvoiced", strDateInvoiced);
        vars.setSessionValue("CreateFrom|pricelist", strPriceList);
        vars.setSessionValue("CreateFrom|bpartner", strBPartner);
        vars.setSessionValue("CreateFrom|windowId", windowId);
        vars.setSessionValue("CreateFrom|bankAccount", strBankAccount);
        vars.setSessionValue("CreateFrom|statementDate", strStatementDate);
        vars.setSessionValue("CreateFrom|adOrgId", strOrg);
        vars.setSessionValue("CreateFrom|isreceipt", strIsreceipt);
        vars.setSessionValue("CreateFrom|tabName", "Header");
        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{      
          response.sendRedirect(strDireccion + "/ad_actionButton/CreateFrom.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 = 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 strcBpTaxcategoryId = request.getParameter("inpcBpTaxcategoryId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strcBpTaxcategoryId.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_BP_TaxCategory_ID = vars.getGlobalVariable("inpcBpTaxcategoryId", windowId + "|C_BP_TaxCategory_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strC_BP_TaxCategory_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strC_BP_TaxCategory_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strC_BP_TaxCategory_ID.equals("")) strC_BP_TaxCategory_ID = vars.getRequiredGlobalVariable("inpcBpTaxcategoryId", windowId + "|C_BP_TaxCategory_ID");
      else vars.setSessionValue(windowId + "|C_BP_TaxCategory_ID", strC_BP_TaxCategory_ID);
     
      vars.setSessionValue(tabId + "|BusinessPartnerTaxCategory.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|C_BP_TaxCategory_ID");
      String strC_BP_TaxCategory_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strC_BP_TaxCategory_ID = vars.getGlobalVariable("inpcBpTaxcategoryId", windowId + "|C_BP_TaxCategory_ID", "");
      vars.setSessionValue(tabId + "|BusinessPartnerTaxCategory.view", "RELATION");
      printPageDataSheet(response, vars, strC_BP_TaxCategory_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_BP_TaxCategory_ID = vars.getGlobalVariable("inpcBpTaxcategoryId", windowId + "|C_BP_TaxCategory_ID", "");
      vars.setSessionValue(tabId + "|BusinessPartnerTaxCategory.view", "EDIT");

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

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

      String strC_BP_TaxCategory_ID = vars.getRequiredStringParameter("inpcBpTaxcategoryId");
     
      String strNext = nextElement(vars, strC_BP_TaxCategory_ID, tableSQL);

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

      String strC_BP_TaxCategory_ID = vars.getRequiredStringParameter("inpcBpTaxcategoryId");
     
      String strPrevious = previousElement(vars, strC_BP_TaxCategory_ID, tableSQL);

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

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

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

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

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

      String strC_BP_TaxCategory_ID = vars.getRequiredStringParameter("inpcBpTaxcategoryId");
      //BusinessPartnerTaxCategoryData 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 = BusinessPartnerTaxCategoryData.delete(this, strC_BP_TaxCategory_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 + "|cBpTaxcategoryId");
        vars.setSessionValue(tabId + "|BusinessPartnerTaxCategory.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 strvmVehicleInfoId = request.getParameter("inpvmVehicleInfoId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strvmVehicleInfoId.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_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strVM_Vehicle_Info_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strVM_Vehicle_Info_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strVM_Vehicle_Info_ID.equals("")) strVM_Vehicle_Info_ID = vars.getRequiredGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");
      else vars.setSessionValue(windowId + "|VM_Vehicle_Info_ID", strVM_Vehicle_Info_ID);
     
      vars.setSessionValue(tabId + "|VehicleInformation.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|VM_Vehicle_Info_ID");
      String strVM_Vehicle_Info_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID", "");
      vars.setSessionValue(tabId + "|VehicleInformation.view", "RELATION");
      printPageDataSheet(response, vars, strVM_Vehicle_Info_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_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID", "");
      vars.setSessionValue(tabId + "|VehicleInformation.view", "EDIT");

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

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

      String strVM_Vehicle_Info_ID = vars.getRequiredStringParameter("inpvmVehicleInfoId");
     
      String strNext = nextElement(vars, strVM_Vehicle_Info_ID, tableSQL);

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

      String strVM_Vehicle_Info_ID = vars.getRequiredStringParameter("inpvmVehicleInfoId");
     
      String strPrevious = previousElement(vars, strVM_Vehicle_Info_ID, tableSQL);

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

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

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

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

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

      String strVM_Vehicle_Info_ID = vars.getRequiredStringParameter("inpvmVehicleInfoId");
      //VehicleInformationData 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 = VehicleInformationData.delete(this, strVM_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 + "|vmVehicleInfoId");
        vars.setSessionValue(tabId + "|VehicleInformation.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 strhrmHrEducationId = request.getParameter("inphrmHrEducationId");
         String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strhrmHrEducationId.equals(""))
              total = saveRecord(vars, myError, 'U', strPHRM_Hr_Employee_ID);
          else
              total = saveRecord(vars, myError, 'I', strPHRM_Hr_Employee_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_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID", "");

      String strHRM_Hr_Education_ID = vars.getGlobalVariable("inphrmHrEducationId", windowId + "|HRM_Hr_Education_ID", "");
            if (strPHRM_Hr_Employee_ID.equals("")) {
        strPHRM_Hr_Employee_ID = getParentID(vars, strHRM_Hr_Education_ID);
        if (strPHRM_Hr_Employee_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|HRM_Hr_Employee_ID");
        vars.setSessionValue(windowId + "|HRM_Hr_Employee_ID", strPHRM_Hr_Employee_ID);

        refreshParentSession(vars, strPHRM_Hr_Employee_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strHRM_Hr_Education_ID, strPHRM_Hr_Employee_ID, tableSQL);

      else printPageDataSheet(response, vars, strPHRM_Hr_Employee_ID, strHRM_Hr_Education_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Hr_Education_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Hr_Education_ID.equals("")) strHRM_Hr_Education_ID = vars.getRequiredGlobalVariable("inphrmHrEducationId", windowId + "|HRM_Hr_Education_ID");
      else vars.setSessionValue(windowId + "|HRM_Hr_Education_ID", strHRM_Hr_Education_ID);
     
     
      String strPHRM_Hr_Employee_ID = getParentID(vars, strHRM_Hr_Education_ID);
     
      vars.setSessionValue(windowId + "|HRM_Hr_Employee_ID", strPHRM_Hr_Employee_ID);
      vars.setSessionValue("378CCA24821B4F16967BB80479E951D4|Employee Information.view", "EDIT");

      refreshParentSession(vars, strPHRM_Hr_Employee_ID);

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

      printPageEdit(response, request, vars, false, strHRM_Hr_Education_ID, strPHRM_Hr_Employee_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|HRM_Hr_Education_ID");
      refreshParentSession(vars, strPHRM_Hr_Employee_ID);


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

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

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

            String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");

     
      vars.removeSessionValue(windowId + "|HRM_Hr_Education_ID");
      String strHRM_Hr_Education_ID="";

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

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

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strHRM_Hr_Education_ID, strPHRM_Hr_Employee_ID, tableSQL);

      else printPageDataSheet(response, vars, strPHRM_Hr_Employee_ID, strHRM_Hr_Education_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");
     

      String strHRM_Hr_Education_ID = vars.getGlobalVariable("inphrmHrEducationId", windowId + "|HRM_Hr_Education_ID", "");
      vars.setSessionValue(tabId + "|Education.view", "RELATION");
      printPageDataSheet(response, vars, strPHRM_Hr_Employee_ID, strHRM_Hr_Education_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");
      String strHRM_Hr_Education_ID = vars.getRequiredStringParameter("inphrmHrEducationId");
     
      String strNext = nextElement(vars, strHRM_Hr_Education_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPHRM_Hr_Employee_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");
      String strHRM_Hr_Education_ID = vars.getRequiredStringParameter("inphrmHrEducationId");
     
      String strPrevious = previousElement(vars, strHRM_Hr_Education_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPHRM_Hr_Employee_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");

      vars.setSessionValue(tabId + "|Education.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");

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

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

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

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

      printPageEdit(response, request, vars, false, strLast, strPHRM_Hr_Employee_ID, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {
      String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");
      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I', strPHRM_Hr_Employee_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_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");
      String strHRM_Hr_Education_ID = vars.getRequiredGlobalVariable("inphrmHrEducationId", windowId + "|HRM_Hr_Education_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U', strPHRM_Hr_Employee_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_Hr_Education_ID, tableSQL);
          vars.setSessionValue(windowId + "|HRM_Hr_Education_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_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");

      String strHRM_Hr_Education_ID = vars.getRequiredInStringParameter("inphrmHrEducationId");
      String message = deleteRelation(vars, strHRM_Hr_Education_ID, strPHRM_Hr_Employee_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|hrmHrEducationId");
        vars.setSessionValue(tabId + "|Education.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPHRM_Hr_Employee_ID = vars.getGlobalVariable("inphrmHrEmployeeId", windowId + "|HRM_Hr_Employee_ID");

      String strHRM_Hr_Education_ID = vars.getRequiredStringParameter("inphrmHrEducationId");
      //EducationData data = getEditVariables(vars, strPHRM_Hr_Employee_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 = EducationData.delete(this, strHRM_Hr_Education_ID, strPHRM_Hr_Employee_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 + "|hrmHrEducationId");
        vars.setSessionValue(tabId + "|Education.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 stradProcessSchedulingId = request.getParameter("inpadProcessSchedulingId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !stradProcessSchedulingId.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 strAD_Process_Scheduling_ID = vars.getGlobalVariable("inpadProcessSchedulingId", windowId + "|AD_Process_Scheduling_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strAD_Process_Scheduling_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strAD_Process_Scheduling_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strAD_Process_Scheduling_ID.equals("")) strAD_Process_Scheduling_ID = vars.getRequiredGlobalVariable("inpadProcessSchedulingId", windowId + "|AD_Process_Scheduling_ID");
      else vars.setSessionValue(windowId + "|AD_Process_Scheduling_ID", strAD_Process_Scheduling_ID);
     
      vars.setSessionValue(tabId + "|ProcessScheduling.view", "EDIT");

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

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


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

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

      } else printPageDataSheet(response, vars, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamAD_Process_ID", tabId + "|paramAD_Process_ID");
vars.getRequestGlobalVariable("inpParamWeekDay", tabId + "|paramWeekDay");
vars.getRequestGlobalVariable("inpParamTimeFrom", tabId + "|paramTimeFrom");
vars.getRequestGlobalVariable("inpParamTimeTo", tabId + "|paramTimeTo");
vars.getRequestGlobalVariable("inpParamTimeFrom_f", tabId + "|paramTimeFrom_f");
vars.getRequestGlobalVariable("inpParamTimeTo_f", tabId + "|paramTimeTo_f");

     
     
      vars.removeSessionValue(windowId + "|AD_Process_Scheduling_ID");
      String strAD_Process_Scheduling_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strAD_Process_Scheduling_ID = vars.getGlobalVariable("inpadProcessSchedulingId", windowId + "|AD_Process_Scheduling_ID", "");
      vars.setSessionValue(tabId + "|ProcessScheduling.view", "RELATION");
      printPageDataSheet(response, vars, strAD_Process_Scheduling_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 strAD_Process_Scheduling_ID = vars.getGlobalVariable("inpadProcessSchedulingId", windowId + "|AD_Process_Scheduling_ID", "");
      vars.setSessionValue(tabId + "|ProcessScheduling.view", "EDIT");

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

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

      String strAD_Process_Scheduling_ID = vars.getRequiredStringParameter("inpadProcessSchedulingId");
     
      String strNext = nextElement(vars, strAD_Process_Scheduling_ID, tableSQL);

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

      String strAD_Process_Scheduling_ID = vars.getRequiredStringParameter("inpadProcessSchedulingId");
     
      String strPrevious = previousElement(vars, strAD_Process_Scheduling_ID, tableSQL);

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

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

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

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

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

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

      String strAD_Process_Scheduling_ID = vars.getRequiredStringParameter("inpadProcessSchedulingId");
      //ProcessSchedulingData 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 = ProcessSchedulingData.delete(this, strAD_Process_Scheduling_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 + "|adProcessSchedulingId");
        vars.setSessionValue(tabId + "|ProcessScheduling.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

    super.init(config);
    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 strrentalamount = vars.getStringParameter("inprentalamount")
    String strdriveramount = vars.getStringParameter("inpdriveramount")
    String strpetrolamount = vars.getStringParameter("inppetrolamount");
      String strsalikamount = vars.getStringParameter("inpsalikamount");
      String strfineamount = vars.getStringParameter("inpfineamount");  
      String strdamageamount = vars.getStringParameter("inpdamageamount");  
    String strdepositamount = vars.getStringParameter("inpdepositamount");
    String strtotalamount = vars.getStringParameter("inptotalamount");
    String strextraamount = vars.getStringParameter("inpextraamount");
      String strTabId = vars.getStringParameter("inpTabId");
      try {
        printPage(response, vars, strChanged, strrentalamount, strdriveramount, strpetrolamount, strsalikamount, strfineamount, strdamageamount, strdepositamount, strtotalamount, strextraamount, strTabId);
      } catch (ServletException ex) {
        pageErrorCallOut(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.