Package org.openbravo.base.secureApp

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

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

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

      String strHRM_Tm_Workshift_ID = vars.getGlobalVariable("inphrmTmWorkshiftId", windowId + "|HRM_Tm_Workshift_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strHRM_Tm_Workshift_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Tm_Workshift_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Tm_Workshift_ID.equals("")) strHRM_Tm_Workshift_ID = vars.getRequiredGlobalVariable("inphrmTmWorkshiftId", windowId + "|HRM_Tm_Workshift_ID");
      else vars.setSessionValue(windowId + "|HRM_Tm_Workshift_ID", strHRM_Tm_Workshift_ID);
     
      vars.setSessionValue(tabId + "|WorkShifts.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|HRM_Tm_Workshift_ID");
      String strHRM_Tm_Workshift_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strHRM_Tm_Workshift_ID = vars.getGlobalVariable("inphrmTmWorkshiftId", windowId + "|HRM_Tm_Workshift_ID", "");
      vars.setSessionValue(tabId + "|WorkShifts.view", "RELATION");
      printPageDataSheet(response, vars, strHRM_Tm_Workshift_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {


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

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

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

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

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

      String strHRM_Tm_Workshift_ID = vars.getRequiredStringParameter("inphrmTmWorkshiftId");
     
      String strNext = nextElement(vars, strHRM_Tm_Workshift_ID, tableSQL);

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

      String strHRM_Tm_Workshift_ID = vars.getRequiredStringParameter("inphrmTmWorkshiftId");
     
      String strPrevious = previousElement(vars, strHRM_Tm_Workshift_ID, tableSQL);

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

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

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

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

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

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

     
      String strFirst = firstElement(vars, tableSQL);

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

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

     
      String strLast = lastElement(vars, tableSQL);

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

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

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

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

      String strHRM_Tm_Workshift_ID = vars.getRequiredStringParameter("inphrmTmWorkshiftId");
      //WorkShiftsData 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 = WorkShiftsData.delete(this, strHRM_Tm_Workshift_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 + "|hrmTmWorkshiftId");
        vars.setSessionValue(tabId + "|WorkShifts.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


    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 strRegistration = vars.getStringParameter("inpvmVehicleInfoId")
     
    String strTabId = vars.getStringParameter("inpTabId");
      try {
        printPage(response, vars, strChanged, strRegistration, 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 strMultiplyRate = vars.getNumericParameter("inpmultiplyrate");
      String strDivideRate = vars.getStringParameter("inpdividerate");
      String strTabId = vars.getStringParameter("inpTabId");

      try {
        printPage(response, vars, strChanged, strMultiplyRate, strDivideRate, 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")) {
      try {
        printPage(response, vars);
      } 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 strhrmHrSpeHolId = request.getParameter("inphrmHrSpeHolId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strhrmHrSpeHolId.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_Hr_Spe_Hol_ID = vars.getGlobalVariable("inphrmHrSpeHolId", windowId + "|HRM_Hr_Spe_Hol_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strHRM_Hr_Spe_Hol_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Hr_Spe_Hol_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Hr_Spe_Hol_ID.equals("")) strHRM_Hr_Spe_Hol_ID = vars.getRequiredGlobalVariable("inphrmHrSpeHolId", windowId + "|HRM_Hr_Spe_Hol_ID");
      else vars.setSessionValue(windowId + "|HRM_Hr_Spe_Hol_ID", strHRM_Hr_Spe_Hol_ID);
     
      vars.setSessionValue(tabId + "|SpecificHolidays.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|HRM_Hr_Spe_Hol_ID");
      String strHRM_Hr_Spe_Hol_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strHRM_Hr_Spe_Hol_ID = vars.getGlobalVariable("inphrmHrSpeHolId", windowId + "|HRM_Hr_Spe_Hol_ID", "");
      vars.setSessionValue(tabId + "|SpecificHolidays.view", "RELATION");
      printPageDataSheet(response, vars, strHRM_Hr_Spe_Hol_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_Hr_Spe_Hol_ID = vars.getGlobalVariable("inphrmHrSpeHolId", windowId + "|HRM_Hr_Spe_Hol_ID", "");
      vars.setSessionValue(tabId + "|SpecificHolidays.view", "EDIT");

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

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

      String strHRM_Hr_Spe_Hol_ID = vars.getRequiredStringParameter("inphrmHrSpeHolId");
     
      String strNext = nextElement(vars, strHRM_Hr_Spe_Hol_ID, tableSQL);

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

      String strHRM_Hr_Spe_Hol_ID = vars.getRequiredStringParameter("inphrmHrSpeHolId");
     
      String strPrevious = previousElement(vars, strHRM_Hr_Spe_Hol_ID, tableSQL);

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

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

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

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

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

      String strHRM_Hr_Spe_Hol_ID = vars.getRequiredStringParameter("inphrmHrSpeHolId");
      //SpecificHolidaysData 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 = SpecificHolidaysData.delete(this, strHRM_Hr_Spe_Hol_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 + "|hrmHrSpeHolId");
        vars.setSessionValue(tabId + "|SpecificHolidays.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");
      String strcProjectLineId = vars.getStringParameter("inpcProjectlineId");
      String strPlannedQty = vars.getNumericParameter("inpplannedqty", "0");
      String strPlannedPrice = vars.getNumericParameter("inpplannedprice", "0");
      String strPlannedPurchasePrice = vars.getNumericParameter("inpplannedpoprice", "0");
      String strPlannedMargin = vars.getNumericParameter("inpplannedmarginamt", "0");
      String strTabId = vars.getStringParameter("inpTabId");
      try {
        printPage(response, vars, strPlannedQty, strPlannedPrice, strPlannedPurchasePrice,
            strPlannedMargin, strcProjectLineId, strTabId, strChanged);
      } catch (ServletException ex) {
        pageErrorCallOut(response);
View Full Code Here

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

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

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

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

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

      else printPageDataSheet(response, vars, strC_Glitem_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strC_Glitem_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strC_Glitem_ID.equals("")) strC_Glitem_ID = vars.getRequiredGlobalVariable("inpcGlitemId", windowId + "|C_Glitem_ID");
      else vars.setSessionValue(windowId + "|C_Glitem_ID", strC_Glitem_ID);
     
      vars.setSessionValue(tabId + "|GLItem.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|C_Glitem_ID");
      String strC_Glitem_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strC_Glitem_ID = vars.getGlobalVariable("inpcGlitemId", windowId + "|C_Glitem_ID", "");
      vars.setSessionValue(tabId + "|GLItem.view", "RELATION");
      printPageDataSheet(response, vars, strC_Glitem_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_Glitem_ID = vars.getGlobalVariable("inpcGlitemId", windowId + "|C_Glitem_ID", "");
      vars.setSessionValue(tabId + "|GLItem.view", "EDIT");

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

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

      String strC_Glitem_ID = vars.getRequiredStringParameter("inpcGlitemId");
     
      String strNext = nextElement(vars, strC_Glitem_ID, tableSQL);

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

      String strC_Glitem_ID = vars.getRequiredStringParameter("inpcGlitemId");
     
      String strPrevious = previousElement(vars, strC_Glitem_ID, tableSQL);

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

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

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

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

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

      String strC_Glitem_ID = vars.getRequiredStringParameter("inpcGlitemId");
      //GLItemData 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 = GLItemData.delete(this, strC_Glitem_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 + "|cGlitemId");
        vars.setSessionValue(tabId + "|GLItem.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 strhrmLicensesId = request.getParameter("inphrmLicensesId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strhrmLicensesId.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_Licenses_ID = vars.getGlobalVariable("inphrmLicensesId", windowId + "|HRM_Licenses_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strHRM_Licenses_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strHRM_Licenses_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strHRM_Licenses_ID.equals("")) strHRM_Licenses_ID = vars.getRequiredGlobalVariable("inphrmLicensesId", windowId + "|HRM_Licenses_ID");
      else vars.setSessionValue(windowId + "|HRM_Licenses_ID", strHRM_Licenses_ID);
     
      vars.setSessionValue(tabId + "|Licenses.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|HRM_Licenses_ID");
      String strHRM_Licenses_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strHRM_Licenses_ID = vars.getGlobalVariable("inphrmLicensesId", windowId + "|HRM_Licenses_ID", "");
      vars.setSessionValue(tabId + "|Licenses.view", "RELATION");
      printPageDataSheet(response, vars, strHRM_Licenses_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_Licenses_ID = vars.getGlobalVariable("inphrmLicensesId", windowId + "|HRM_Licenses_ID", "");
      vars.setSessionValue(tabId + "|Licenses.view", "EDIT");

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

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

      String strHRM_Licenses_ID = vars.getRequiredStringParameter("inphrmLicensesId");
     
      String strNext = nextElement(vars, strHRM_Licenses_ID, tableSQL);

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

      String strHRM_Licenses_ID = vars.getRequiredStringParameter("inphrmLicensesId");
     
      String strPrevious = previousElement(vars, strHRM_Licenses_ID, tableSQL);

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

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

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

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

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

      String strHRM_Licenses_ID = vars.getRequiredStringParameter("inphrmLicensesId");
      //LicensesData 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 = LicensesData.delete(this, strHRM_Licenses_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 + "|hrmLicensesId");
        vars.setSessionValue(tabId + "|Licenses.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 = 4;
  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 stradLanguageId = request.getParameter("inpadLanguageId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !stradLanguageId.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_Language_ID = vars.getGlobalVariable("inpadLanguageId", windowId + "|AD_Language_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strAD_Language_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strAD_Language_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strAD_Language_ID.equals("")) strAD_Language_ID = vars.getRequiredGlobalVariable("inpadLanguageId", windowId + "|AD_Language_ID");
      else vars.setSessionValue(windowId + "|AD_Language_ID", strAD_Language_ID);
     
      vars.setSessionValue(tabId + "|Language.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|AD_Language_ID");
      String strAD_Language_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strAD_Language_ID = vars.getGlobalVariable("inpadLanguageId", windowId + "|AD_Language_ID", "");
      vars.setSessionValue(tabId + "|Language.view", "RELATION");
      printPageDataSheet(response, vars, strAD_Language_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_Language_ID = vars.getGlobalVariable("inpadLanguageId", windowId + "|AD_Language_ID", "");
      vars.setSessionValue(tabId + "|Language.view", "EDIT");

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

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

      String strAD_Language_ID = vars.getRequiredStringParameter("inpadLanguageId");
     
      String strNext = nextElement(vars, strAD_Language_ID, tableSQL);

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

      String strAD_Language_ID = vars.getRequiredStringParameter("inpadLanguageId");
     
      String strPrevious = previousElement(vars, strAD_Language_ID, tableSQL);

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

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

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

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

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

      String strAD_Language_ID = vars.getRequiredStringParameter("inpadLanguageId");
      //LanguageData 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 = LanguageData.delete(this, strAD_Language_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 + "|adLanguageId");
        vars.setSessionValue(tabId + "|Language.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("BUTTONProcessing179")) {
        vars.setSessionValue("button179.strprocessing", vars.getStringParameter("inpprocessing"));
        vars.setSessionValue("button179.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("button179.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("button179.strClient", vars.getStringParameter("inpadClientId"));
       
       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("button179.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "179", request.getServletPath());   
     } else if (vars.commandIn("BUTTON179")) {
        String strAD_Language_ID = vars.getGlobalVariable("inpadLanguageId", windowId + "|AD_Language_ID", "");
        String strprocessing = vars.getSessionValue("button179.strprocessing");
        String strProcessing = vars.getSessionValue("button179.strProcessing");
        String strOrg = vars.getSessionValue("button179.strOrg");
        String strClient = vars.getSessionValue("button179.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{      
          printPageButtonProcessing179(response, vars, strAD_Language_ID, strprocessing, strProcessing);
        }


    } else if (vars.commandIn("SAVE_BUTTONProcessing179")) {
        String strAD_Language_ID = vars.getGlobalVariable("inpKey", windowId + "|AD_Language_ID", "");
        @SuppressWarnings("unused")
        String strprocessing = vars.getStringParameter("inpprocessing");
        String strProcessing = vars.getStringParameter("inpprocessing");
        OBError myMessage = null;
        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "179", (("AD_Language_ID".equalsIgnoreCase("AD_Language"))?"0":strAD_Language_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.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 strStmAmount = vars.getNumericParameter("inpstmtamt");
      String strChgAmount = vars.getNumericParameter("inpchargeamt");
      String strTrxAmount = vars.getNumericParameter("inptrxamt");
      String strConvChgAmount = vars.getNumericParameter("inpconvertchargeamt");
      String strTabId = vars.getStringParameter("inpTabId");
      String strBankStmtLine = vars.getStringParameter("inpcBankstatementlineId");
      String strCurrencyId = vars.getStringParameter("inpcCurrencyId");
      String strDP = vars.getStringParameter("inpcDebtPaymentId");

      try {
        printPage(response, vars, strChanged, strStmAmount, strTrxAmount, strChgAmount, strTabId,
            strConvChgAmount, strBankStmtLine, strCurrencyId, strDP);
      } catch (ServletException ex) {
View Full Code Here

TOP

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

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