Package org.openbravo.base.secureApp

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 strhrmMNationalityId = request.getParameter("inphrmMNationalityId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strhrmMNationalityId.equals(""))
              total = saveRecord(vars, myError, 'U');
          else
              total = saveRecord(vars, myError, 'I');
         
          if (!myError.isEmpty() && total == 0)    
            throw new OBException(myError.getMessage());
        }
        vars.setSessionValue(request.getParameter("mappingName") +"|hash", vars.getPostDataHash());
        vars.setSessionValue(tabId + "|Header.view", "EDIT");
       
        return;
    }
   
    try {
      tableSQL = new TableSQLData(vars, this, tabId, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
    } catch (Exception ex) {
      ex.printStackTrace();
    }

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

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

      String strHRM_M_Nationality_ID = vars.getGlobalVariable("inphrmMNationalityId", windowId + "|HRM_M_Nationality_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strHRM_M_Nationality_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_M_Nationality_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_M_Nationality_ID.equals("")) strHRM_M_Nationality_ID = vars.getRequiredGlobalVariable("inphrmMNationalityId", windowId + "|HRM_M_Nationality_ID");
      else vars.setSessionValue(windowId + "|HRM_M_Nationality_ID", strHRM_M_Nationality_ID);
     
      vars.setSessionValue(tabId + "|Nationality.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|HRM_M_Nationality_ID");
      String strHRM_M_Nationality_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strHRM_M_Nationality_ID = vars.getGlobalVariable("inphrmMNationalityId", windowId + "|HRM_M_Nationality_ID", "");
      vars.setSessionValue(tabId + "|Nationality.view", "RELATION");
      printPageDataSheet(response, vars, strHRM_M_Nationality_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {


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

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

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

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

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

      String strHRM_M_Nationality_ID = vars.getRequiredStringParameter("inphrmMNationalityId");
     
      String strNext = nextElement(vars, strHRM_M_Nationality_ID, tableSQL);

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

      String strHRM_M_Nationality_ID = vars.getRequiredStringParameter("inphrmMNationalityId");
     
      String strPrevious = previousElement(vars, strHRM_M_Nationality_ID, tableSQL);

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

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

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

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

      String strInitRecord = vars.getSessionValue(tabId + "|Nationality.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 + "|Nationality.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|HRM_M_Nationality_ID");

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

     
      String strFirst = firstElement(vars, tableSQL);

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

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

     
      String strLast = lastElement(vars, tableSQL);

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

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

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

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

      String strHRM_M_Nationality_ID = vars.getRequiredStringParameter("inphrmMNationalityId");
      //NationalityData 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 = NationalityData.delete(this, strHRM_M_Nationality_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 + "|hrmMNationalityId");
        vars.setSessionValue(tabId + "|Nationality.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());








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


  private static final int accesslevel = 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 stradProcessRunId = request.getParameter("inpadProcessRunId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !stradProcessRunId.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_Run_ID = vars.getGlobalVariable("inpadProcessRunId", windowId + "|AD_Process_Run_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strAD_Process_Run_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strAD_Process_Run_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strAD_Process_Run_ID.equals("")) strAD_Process_Run_ID = vars.getRequiredGlobalVariable("inpadProcessRunId", windowId + "|AD_Process_Run_ID");
      else vars.setSessionValue(windowId + "|AD_Process_Run_ID", strAD_Process_Run_ID);
     
      vars.setSessionValue(tabId + "|ProcessExecution.view", "EDIT");

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

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


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

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

      } else printPageDataSheet(response, vars, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamStatus", tabId + "|paramStatus");
vars.getRequestGlobalVariable("inpParamStart_Time", tabId + "|paramStart_Time");
vars.getRequestGlobalVariable("inpParamAD_User_ID", tabId + "|paramAD_User_ID");
vars.getRequestGlobalVariable("inpParamAD_Process_ID", tabId + "|paramAD_Process_ID");
vars.getRequestGlobalVariable("inpParamEnd_Time", tabId + "|paramEnd_Time");
vars.getRequestGlobalVariable("inpParamStart_Time_f", tabId + "|paramStart_Time_f");
vars.getRequestGlobalVariable("inpParamEnd_Time_f", tabId + "|paramEnd_Time_f");

     
     
      vars.removeSessionValue(windowId + "|AD_Process_Run_ID");
      String strAD_Process_Run_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strAD_Process_Run_ID = vars.getGlobalVariable("inpadProcessRunId", windowId + "|AD_Process_Run_ID", "");
      vars.setSessionValue(tabId + "|ProcessExecution.view", "RELATION");
      printPageDataSheet(response, vars, strAD_Process_Run_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_Run_ID = vars.getGlobalVariable("inpadProcessRunId", windowId + "|AD_Process_Run_ID", "");
      vars.setSessionValue(tabId + "|ProcessExecution.view", "EDIT");

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

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

      String strAD_Process_Run_ID = vars.getRequiredStringParameter("inpadProcessRunId");
     
      String strNext = nextElement(vars, strAD_Process_Run_ID, tableSQL);

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

      String strAD_Process_Run_ID = vars.getRequiredStringParameter("inpadProcessRunId");
     
      String strPrevious = previousElement(vars, strAD_Process_Run_ID, tableSQL);

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

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

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

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

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

      String strAD_Process_Run_ID = vars.getRequiredStringParameter("inpadProcessRunId");
      //ProcessExecutionData 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 = ProcessExecutionData.delete(this, strAD_Process_Run_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 + "|adProcessRunId");
        vars.setSessionValue(tabId + "|ProcessExecution.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());








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

    boolHist = false;
  }

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

      String strMProductID = vars.getStringParameter("inpmProductId");
      String strPAttr = vars.getStringParameter("inpmProductId_ATR");

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

    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 strAgreementNo = vars.getStringParameter("inpagreementno");
         
     
    String strTabId = vars.getStringParameter("inpTabId");
      try {
        printPage(response, vars, strChanged, strAgreementNo, strTabId);
      } catch (ServletException ex) {
        pageErrorCallOut(response);
      }
View Full Code Here

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

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

      String strHRM_Job_Currency_ID = vars.getGlobalVariable("inphrmJobCurrencyId", windowId + "|HRM_Job_Currency_ID", "");
            if (strPHRM_Job_Paygrade_ID.equals("")) {
        strPHRM_Job_Paygrade_ID = getParentID(vars, strHRM_Job_Currency_ID);
        if (strPHRM_Job_Paygrade_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|HRM_Job_Paygrade_ID");
        vars.setSessionValue(windowId + "|HRM_Job_Paygrade_ID", strPHRM_Job_Paygrade_ID);

        refreshParentSession(vars, strPHRM_Job_Paygrade_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strHRM_Job_Currency_ID, strPHRM_Job_Paygrade_ID, tableSQL);

      else printPageDataSheet(response, vars, strPHRM_Job_Paygrade_ID, strHRM_Job_Currency_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Job_Currency_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Job_Currency_ID.equals("")) strHRM_Job_Currency_ID = vars.getRequiredGlobalVariable("inphrmJobCurrencyId", windowId + "|HRM_Job_Currency_ID");
      else vars.setSessionValue(windowId + "|HRM_Job_Currency_ID", strHRM_Job_Currency_ID);
     
     
      String strPHRM_Job_Paygrade_ID = getParentID(vars, strHRM_Job_Currency_ID);
     
      vars.setSessionValue(windowId + "|HRM_Job_Paygrade_ID", strPHRM_Job_Paygrade_ID);
      vars.setSessionValue("24ABC747C016466D8168AFA5DDE1F137|Pay Grades.view", "EDIT");

      refreshParentSession(vars, strPHRM_Job_Paygrade_ID);

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

      printPageEdit(response, request, vars, false, strHRM_Job_Currency_ID, strPHRM_Job_Paygrade_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPHRM_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|HRM_Job_Currency_ID");
      refreshParentSession(vars, strPHRM_Job_Paygrade_ID);


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

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

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

            String strPHRM_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");

     
      vars.removeSessionValue(windowId + "|HRM_Job_Currency_ID");
      String strHRM_Job_Currency_ID="";

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

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

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strHRM_Job_Currency_ID, strPHRM_Job_Paygrade_ID, tableSQL);

      else printPageDataSheet(response, vars, strPHRM_Job_Paygrade_ID, strHRM_Job_Currency_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPHRM_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");
     

      String strHRM_Job_Currency_ID = vars.getGlobalVariable("inphrmJobCurrencyId", windowId + "|HRM_Job_Currency_ID", "");
      vars.setSessionValue(tabId + "|CurrencyAssign.view", "RELATION");
      printPageDataSheet(response, vars, strPHRM_Job_Paygrade_ID, strHRM_Job_Currency_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPHRM_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPHRM_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPHRM_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");
      String strHRM_Job_Currency_ID = vars.getRequiredStringParameter("inphrmJobCurrencyId");
     
      String strNext = nextElement(vars, strHRM_Job_Currency_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPHRM_Job_Paygrade_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPHRM_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");
      String strHRM_Job_Currency_ID = vars.getRequiredStringParameter("inphrmJobCurrencyId");
     
      String strPrevious = previousElement(vars, strHRM_Job_Currency_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPHRM_Job_Paygrade_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");

      vars.setSessionValue(tabId + "|CurrencyAssign.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPHRM_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");

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

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

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

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

      printPageEdit(response, request, vars, false, strLast, strPHRM_Job_Paygrade_ID, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {
      String strPHRM_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");
      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I', strPHRM_Job_Paygrade_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_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");
      String strHRM_Job_Currency_ID = vars.getRequiredGlobalVariable("inphrmJobCurrencyId", windowId + "|HRM_Job_Currency_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U', strPHRM_Job_Paygrade_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_Job_Currency_ID, tableSQL);
          vars.setSessionValue(windowId + "|HRM_Job_Currency_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_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");

      String strHRM_Job_Currency_ID = vars.getRequiredInStringParameter("inphrmJobCurrencyId");
      String message = deleteRelation(vars, strHRM_Job_Currency_ID, strPHRM_Job_Paygrade_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|hrmJobCurrencyId");
        vars.setSessionValue(tabId + "|CurrencyAssign.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPHRM_Job_Paygrade_ID = vars.getGlobalVariable("inphrmJobPaygradeId", windowId + "|HRM_Job_Paygrade_ID");

      String strHRM_Job_Currency_ID = vars.getRequiredStringParameter("inphrmJobCurrencyId");
      //CurrencyAssignData data = getEditVariables(vars, strPHRM_Job_Paygrade_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 = CurrencyAssignData.delete(this, strHRM_Job_Currency_ID, strPHRM_Job_Paygrade_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 + "|hrmJobCurrencyId");
        vars.setSessionValue(tabId + "|CurrencyAssign.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());








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

  private static final int accesslevel = 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 strhrmGenralinfoId = request.getParameter("inphrmGenralinfoId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strhrmGenralinfoId.equals(""))
              total = saveRecord(vars, myError, 'U');
          else
              total = saveRecord(vars, myError, 'I');
         
          if (!myError.isEmpty() && total == 0)    
            throw new OBException(myError.getMessage());
        }
        vars.setSessionValue(request.getParameter("mappingName") +"|hash", vars.getPostDataHash());
        vars.setSessionValue(tabId + "|Header.view", "EDIT");
       
        return;
    }
   
    try {
      tableSQL = new TableSQLData(vars, this, tabId, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
    } catch (Exception ex) {
      ex.printStackTrace();
    }

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

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

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

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

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

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

      else printPageDataSheet(response, vars, strHRM_Genralinfo_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Genralinfo_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Genralinfo_ID.equals("")) strHRM_Genralinfo_ID = vars.getRequiredGlobalVariable("inphrmGenralinfoId", windowId + "|HRM_Genralinfo_ID");
      else vars.setSessionValue(windowId + "|HRM_Genralinfo_ID", strHRM_Genralinfo_ID);
     
      vars.setSessionValue(tabId + "|General.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|HRM_Genralinfo_ID");
      String strHRM_Genralinfo_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

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


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

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

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

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

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

      String strHRM_Genralinfo_ID = vars.getRequiredStringParameter("inphrmGenralinfoId");
     
      String strNext = nextElement(vars, strHRM_Genralinfo_ID, tableSQL);

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

      String strHRM_Genralinfo_ID = vars.getRequiredStringParameter("inphrmGenralinfoId");
     
      String strPrevious = previousElement(vars, strHRM_Genralinfo_ID, tableSQL);

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

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

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

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

      String strInitRecord = vars.getSessionValue(tabId + "|General.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 + "|General.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|HRM_Genralinfo_ID");

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

     
      String strFirst = firstElement(vars, tableSQL);

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

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

     
      String strLast = lastElement(vars, tableSQL);

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

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

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

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

      String strHRM_Genralinfo_ID = vars.getRequiredStringParameter("inphrmGenralinfoId");
      //GeneralData 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 = GeneralData.delete(this, strHRM_Genralinfo_ID, Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), Utility.getContext(this, vars, "#User_Org", windowId, accesslevel));
        } catch(ServletException ex) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myError.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myError);
        }
        if (myError==null && total==0) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
          vars.setMessage(tabId, myError);
        }
        vars.removeSessionValue(windowId + "|hrmGenralinfoId");
        vars.setSessionValue(tabId + "|General.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());








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

    boolHist = false;
  }

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

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

    boolHist = false;
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      String strChanged = vars.getStringParameter("inpLastFieldChanged");
      if (log4j.isDebugEnabled())
        log4j.debug("CHANGED: " + strChanged);
      String strOrderLine = vars.getStringParameter("inpcOrderlineId");
      String strRequisitionLine = vars.getStringParameter("inpmRequisitionlineId");
      try {
        printPage(response, vars, strOrderLine, strRequisitionLine);
      } catch (ServletException ex) {
        pageErrorCallOut(response);
      }
View Full Code Here

    boolHist = false;
  }

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

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

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

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

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

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

      String strHRM_Leave_Apply_ID = vars.getGlobalVariable("inphrmLeaveApplyId", windowId + "|HRM_Leave_Apply_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strHRM_Leave_Apply_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Leave_Apply_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Leave_Apply_ID.equals("")) strHRM_Leave_Apply_ID = vars.getRequiredGlobalVariable("inphrmLeaveApplyId", windowId + "|HRM_Leave_Apply_ID");
      else vars.setSessionValue(windowId + "|HRM_Leave_Apply_ID", strHRM_Leave_Apply_ID);
     
      vars.setSessionValue(tabId + "|ApplyLeave.view", "EDIT");

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

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


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

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

      } else printPageDataSheet(response, vars, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamTotaldays", tabId + "|paramTotaldays");
vars.getRequestGlobalVariable("inpParamTotaldays_f", tabId + "|paramTotaldays_f");

     
     
      vars.removeSessionValue(windowId + "|HRM_Leave_Apply_ID");
      String strHRM_Leave_Apply_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strHRM_Leave_Apply_ID = vars.getGlobalVariable("inphrmLeaveApplyId", windowId + "|HRM_Leave_Apply_ID", "");
      vars.setSessionValue(tabId + "|ApplyLeave.view", "RELATION");
      printPageDataSheet(response, vars, strHRM_Leave_Apply_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {


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

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

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

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

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

      String strHRM_Leave_Apply_ID = vars.getRequiredStringParameter("inphrmLeaveApplyId");
     
      String strNext = nextElement(vars, strHRM_Leave_Apply_ID, tableSQL);

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

      String strHRM_Leave_Apply_ID = vars.getRequiredStringParameter("inphrmLeaveApplyId");
     
      String strPrevious = previousElement(vars, strHRM_Leave_Apply_ID, tableSQL);

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

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

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

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

      String strInitRecord = vars.getSessionValue(tabId + "|ApplyLeave.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 + "|ApplyLeave.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|HRM_Leave_Apply_ID");

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

     
      String strFirst = firstElement(vars, tableSQL);

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

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

     
      String strLast = lastElement(vars, tableSQL);

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

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

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

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

      String strHRM_Leave_Apply_ID = vars.getRequiredStringParameter("inphrmLeaveApplyId");
      //ApplyLeaveData 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 = ApplyLeaveData.delete(this, strHRM_Leave_Apply_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 + "|hrmLeaveApplyId");
        vars.setSessionValue(tabId + "|ApplyLeave.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());








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

TOP

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

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