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

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

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

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

        refreshParentSession(vars, strPVM_Vehicle_Info_ID);
      }


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

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

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

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

      refreshParentSession(vars, strPVM_Vehicle_Info_ID);

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

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

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


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

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

      } else printPageDataSheet(response, vars, strPVM_Vehicle_Info_ID, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamDocumentNo", tabId + "|paramDocumentNo");
vars.getRequestGlobalVariable("inpParamRepair_Date", tabId + "|paramRepair_Date");
vars.getRequestGlobalVariable("inpParamVM_Vehicle_Info_ID", tabId + "|paramVM_Vehicle_Info_ID");
vars.getRequestGlobalVariable("inpParamRepair_Date_f", tabId + "|paramRepair_Date_f");

            String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");

     
      vars.removeSessionValue(windowId + "|VM_Vehicle_Damage_ID");
      String strVM_Vehicle_Damage_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strVM_Vehicle_Damage_ID = vars.getGlobalVariable("inpvmVehicleDamageId", windowId + "|VM_Vehicle_Damage_ID", "");
      vars.setSessionValue(tabId + "|Damage.view", "RELATION");
      printPageDataSheet(response, vars, strPVM_Vehicle_Info_ID, strVM_Vehicle_Damage_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPVM_Vehicle_Info_ID = vars.getGlobalVariable("inpvmVehicleInfoId", windowId + "|VM_Vehicle_Info_ID");


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

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

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

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

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

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

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

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

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

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

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

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

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

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

      String strVM_Vehicle_Damage_ID = vars.getRequiredStringParameter("inpvmVehicleDamageId");
      //DamageData data = getEditVariables(vars, strPVM_Vehicle_Info_ID);
      int total = 0;
      OBError myError = null;
      if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
        vars.setMessage(tabId, myError);
      } else {
        try {
          total = DamageData.delete(this, strVM_Vehicle_Damage_ID, strPVM_Vehicle_Info_ID, Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), Utility.getContext(this, vars, "#User_Org", windowId, accesslevel));
        } catch(ServletException ex) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myError.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myError);
        }
        if (myError==null && total==0) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
          vars.setMessage(tabId, myError);
        }
        vars.removeSessionValue(windowId + "|vmVehicleDamageId");
        vars.setSessionValue(tabId + "|Damage.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("BUTTONProcessedC7B115279BCB48939E985CABA95C0546")) {
        vars.setSessionValue("buttonC7B115279BCB48939E985CABA95C0546.strprocessed", vars.getStringParameter("inpprocessed"));
        vars.setSessionValue("buttonC7B115279BCB48939E985CABA95C0546.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("buttonC7B115279BCB48939E985CABA95C0546.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("buttonC7B115279BCB48939E985CABA95C0546.strClient", vars.getStringParameter("inpadClientId"));
       
       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("buttonC7B115279BCB48939E985CABA95C0546.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "C7B115279BCB48939E985CABA95C0546", request.getServletPath());   
     } else if (vars.commandIn("BUTTONC7B115279BCB48939E985CABA95C0546")) {
        String strVM_Vehicle_Damage_ID = vars.getGlobalVariable("inpvmVehicleDamageId", windowId + "|VM_Vehicle_Damage_ID", "");
        String strprocessed = vars.getSessionValue("buttonC7B115279BCB48939E985CABA95C0546.strprocessed");
        String strProcessing = vars.getSessionValue("buttonC7B115279BCB48939E985CABA95C0546.strProcessing");
        String strOrg = vars.getSessionValue("buttonC7B115279BCB48939E985CABA95C0546.strOrg");
        String strClient = vars.getSessionValue("buttonC7B115279BCB48939E985CABA95C0546.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{      
          printPageButtonProcessedC7B115279BCB48939E985CABA95C0546(response, vars, strVM_Vehicle_Damage_ID, strprocessed, strProcessing);
        }


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



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



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


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

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

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

      String strVM_Vehicle_ID = vars.getGlobalVariable("inpvmVehicleId", windowId + "|VM_Vehicle_ID", "");
     

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

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

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

      else printPageDataSheet(response, vars, strVM_Vehicle_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strVM_Vehicle_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strVM_Vehicle_ID.equals("")) strVM_Vehicle_ID = vars.getRequiredGlobalVariable("inpvmVehicleId", windowId + "|VM_Vehicle_ID");
      else vars.setSessionValue(windowId + "|VM_Vehicle_ID", strVM_Vehicle_ID);
     
      vars.setSessionValue(tabId + "|TypeOfVehicle.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|VM_Vehicle_ID");
      String strVM_Vehicle_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strVM_Vehicle_ID = vars.getGlobalVariable("inpvmVehicleId", windowId + "|VM_Vehicle_ID", "");
      vars.setSessionValue(tabId + "|TypeOfVehicle.view", "RELATION");
      printPageDataSheet(response, vars, strVM_Vehicle_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {


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

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

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

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

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

      String strVM_Vehicle_ID = vars.getRequiredStringParameter("inpvmVehicleId");
     
      String strNext = nextElement(vars, strVM_Vehicle_ID, tableSQL);

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

      String strVM_Vehicle_ID = vars.getRequiredStringParameter("inpvmVehicleId");
     
      String strPrevious = previousElement(vars, strVM_Vehicle_ID, tableSQL);

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

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

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

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

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

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

     
      String strFirst = firstElement(vars, tableSQL);

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

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

     
      String strLast = lastElement(vars, tableSQL);

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

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

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

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

      String strVM_Vehicle_ID = vars.getRequiredStringParameter("inpvmVehicleId");
      //TypeOfVehicleData 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 = TypeOfVehicleData.delete(this, strVM_Vehicle_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 + "|vmVehicleId");
        vars.setSessionValue(tabId + "|TypeOfVehicle.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());








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

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

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

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

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

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

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

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|C_Cash_ID");
      String strC_Cash_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strC_Cash_ID = vars.getGlobalVariable("inpcCashId", windowId + "|C_Cash_ID", "");
      vars.setSessionValue(tabId + "|Header.view", "RELATION");
      printPageDataSheet(response, vars, strC_Cash_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_Cash_ID = vars.getGlobalVariable("inpcCashId", windowId + "|C_Cash_ID", "");
      vars.setSessionValue(tabId + "|Header.view", "EDIT");

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

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

      String strC_Cash_ID = vars.getRequiredStringParameter("inpcCashId");
     
      String strNext = nextElement(vars, strC_Cash_ID, tableSQL);

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

      String strC_Cash_ID = vars.getRequiredStringParameter("inpcCashId");
     
      String strPrevious = previousElement(vars, strC_Cash_ID, tableSQL);

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

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

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

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

      String strInitRecord = vars.getSessionValue(tabId + "|Header.initRecordNumber");
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
      int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
      if (initRecord==0) initRecord=1;
      initRecord += intRecordRange;
      strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord));
      vars.setSessionValue(tabId + "|Header.initRecordNumber", strInitRecord);
      vars.removeSessionValue(windowId + "|C_Cash_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_Cash_ID = vars.getRequiredGlobalVariable("inpcCashId", windowId + "|C_Cash_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_Cash_ID, tableSQL);
          vars.setSessionValue(windowId + "|C_Cash_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_Cash_ID = vars.getRequiredInStringParameter("inpcCashId");
      String message = deleteRelation(vars, strC_Cash_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|cCashId");
        vars.setSessionValue(tabId + "|Header.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {

      String strC_Cash_ID = vars.getRequiredStringParameter("inpcCashId");
      //HeaderData data = getEditVariables(vars);
      int total = 0;
      OBError myError = null;
      if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
        vars.setMessage(tabId, myError);
      } else {
        try {
          total = HeaderData.delete(this, strC_Cash_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 + "|cCashId");
        vars.setSessionValue(tabId + "|Header.view", "RELATION");
      }
      if (myError==null) {
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
        myError.setMessage(total + " " + myError.getMessage());
        vars.setMessage(tabId, myError);
      }
      response.sendRedirect(strDireccion + request.getServletPath());

     } else if (vars.commandIn("BUTTONProcessed144")) {
        vars.setSessionValue("button144.strprocessed", vars.getStringParameter("inpprocessed"));
        vars.setSessionValue("button144.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("button144.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("button144.strClient", vars.getStringParameter("inpadClientId"));
       
       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("button144.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "144", request.getServletPath());   
     } else if (vars.commandIn("BUTTON144")) {
        String strC_Cash_ID = vars.getGlobalVariable("inpcCashId", windowId + "|C_Cash_ID", "");
        String strprocessed = vars.getSessionValue("button144.strprocessed");
        String strProcessing = vars.getSessionValue("button144.strProcessing");
        String strOrg = vars.getSessionValue("button144.strOrg");
        String strClient = vars.getSessionValue("button144.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{      
          printPageButtonProcessed144(response, vars, strC_Cash_ID, strprocessed, strProcessing);
        }


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



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



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

    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 strSecQty = vars.getNumericParameter("inpsecondaryqty");
      String strConvRate = vars.getNumericParameter("inpconversionrate");
      String strTabId = vars.getStringParameter("inpTabId");
      try {
        printPage(response, vars, strSecQty, strConvRate, strTabId);
      } 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 strProductID = vars.getStringParameter("inpmProductId");
         
     
    String strTabId = vars.getStringParameter("inpTabId");
      try {
        printPage(response, vars, strChanged, strProductID, strTabId);
      } 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 strmStorageDetailId = request.getParameter("inpmStorageDetailId");
         String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID");
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strmStorageDetailId.equals(""))
              total = saveRecord(vars, myError, 'U', strPM_Locator_ID);
          else
              total = saveRecord(vars, myError, 'I', strPM_Locator_ID);
         
          if (!myError.isEmpty() && total == 0)    
            throw new OBException(myError.getMessage());
        }
        vars.setSessionValue(request.getParameter("mappingName") +"|hash", vars.getPostDataHash());
        vars.setSessionValue(tabId + "|Header.view", "EDIT");
       
        return;
    }
   
    try {
      tableSQL = new TableSQLData(vars, this, tabId, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
    } catch (Exception ex) {
      ex.printStackTrace();
    }

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

    if (vars.commandIn("DEFAULT")) {
      String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID", "");

      String strM_Storage_Detail_ID = vars.getGlobalVariable("inpmStorageDetailId", windowId + "|M_Storage_Detail_ID", "");
            if (strPM_Locator_ID.equals("")) {
        strPM_Locator_ID = getParentID(vars, strM_Storage_Detail_ID);
        if (strPM_Locator_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|M_Locator_ID");
        vars.setSessionValue(windowId + "|M_Locator_ID", strPM_Locator_ID);
      vars.removeSessionValue(windowId + "|M_Warehouse_ID");
        refreshParentSession(vars, strPM_Locator_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strM_Storage_Detail_ID, strPM_Locator_ID, tableSQL);

      else printPageDataSheet(response, vars, strPM_Locator_ID, strM_Storage_Detail_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strM_Storage_Detail_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strM_Storage_Detail_ID.equals("")) strM_Storage_Detail_ID = vars.getRequiredGlobalVariable("inpmStorageDetailId", windowId + "|M_Storage_Detail_ID");
      else vars.setSessionValue(windowId + "|M_Storage_Detail_ID", strM_Storage_Detail_ID);
     
     
      String strPM_Locator_ID = getParentID(vars, strM_Storage_Detail_ID);
     
      vars.setSessionValue(windowId + "|M_Locator_ID", strPM_Locator_ID);
      vars.setSessionValue("null|null.view", "EDIT");
      vars.removeSessionValue(windowId + "|M_Warehouse_ID");
      refreshParentSession(vars, strPM_Locator_ID);

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

      printPageEdit(response, request, vars, false, strM_Storage_Detail_ID, strPM_Locator_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|M_Storage_Detail_ID");
      refreshParentSession(vars, strPM_Locator_ID);


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

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

      } else printPageDataSheet(response, vars, strPM_Locator_ID, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamM_Product_ID", tabId + "|paramM_Product_ID");
vars.getRequestGlobalVariable("inpParamM_Locator_ID", tabId + "|paramM_Locator_ID");

            String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID");

     
      vars.removeSessionValue(windowId + "|M_Storage_Detail_ID");
      String strM_Storage_Detail_ID="";

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

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

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strM_Storage_Detail_ID, strPM_Locator_ID, tableSQL);

      else printPageDataSheet(response, vars, strPM_Locator_ID, strM_Storage_Detail_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID");
     

      String strM_Storage_Detail_ID = vars.getGlobalVariable("inpmStorageDetailId", windowId + "|M_Storage_Detail_ID", "");
      vars.setSessionValue(tabId + "|BinContents.view", "RELATION");
      printPageDataSheet(response, vars, strPM_Locator_ID, strM_Storage_Detail_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID");
      String strM_Storage_Detail_ID = vars.getRequiredStringParameter("inpmStorageDetailId");
     
      String strNext = nextElement(vars, strM_Storage_Detail_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPM_Locator_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID");
      String strM_Storage_Detail_ID = vars.getRequiredStringParameter("inpmStorageDetailId");
     
      String strPrevious = previousElement(vars, strM_Storage_Detail_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPM_Locator_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID");

      vars.setSessionValue(tabId + "|BinContents.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID");

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

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

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

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

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

      String strM_Storage_Detail_ID = vars.getRequiredInStringParameter("inpmStorageDetailId");
      String message = deleteRelation(vars, strM_Storage_Detail_ID, strPM_Locator_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|mStorageDetailId");
        vars.setSessionValue(tabId + "|BinContents.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPM_Locator_ID = vars.getGlobalVariable("inpmLocatorId", windowId + "|M_Locator_ID");

      String strM_Storage_Detail_ID = vars.getRequiredStringParameter("inpmStorageDetailId");
      //BinContentsData data = getEditVariables(vars, strPM_Locator_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 = BinContentsData.delete(this, strM_Storage_Detail_ID, strPM_Locator_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 + "|mStorageDetailId");
        vars.setSessionValue(tabId + "|BinContents.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 strBPartner = vars.getStringParameter("inpcBpartnerId");
      String strWindowId = vars.getStringParameter("inpwindowId");
      String strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId);
      String strPriceList = vars.getStringParameter("inpmPricelistId");
      try {
        printPage(response, vars, strWindowId, strBPartner, strIsSOTrx, strPriceList);
      } catch (ServletException ex) {
        pageErrorCallOut(response);
      }
View Full Code Here

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

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

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

    if (vars.commandIn("DEFAULT")) {
      String strPMA_Measure_Shift_ID = vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID", "");

      String strMA_Measure_Group_ID = vars.getGlobalVariable("inpmaMeasureGroupId", windowId + "|MA_Measure_Group_ID", "");
            if (strPMA_Measure_Shift_ID.equals("")) {
        strPMA_Measure_Shift_ID = getParentID(vars, strMA_Measure_Group_ID);
        if (strPMA_Measure_Shift_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|MA_Measure_Shift_ID");
        vars.setSessionValue(windowId + "|MA_Measure_Shift_ID", strPMA_Measure_Shift_ID);

        refreshParentSession(vars, strPMA_Measure_Shift_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strMA_Measure_Group_ID, strPMA_Measure_Shift_ID, tableSQL);

      else printPageDataSheet(response, vars, strPMA_Measure_Shift_ID, strMA_Measure_Group_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strMA_Measure_Group_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strMA_Measure_Group_ID.equals("")) strMA_Measure_Group_ID = vars.getRequiredGlobalVariable("inpmaMeasureGroupId", windowId + "|MA_Measure_Group_ID");
      else vars.setSessionValue(windowId + "|MA_Measure_Group_ID", strMA_Measure_Group_ID);
     
     
      String strPMA_Measure_Shift_ID = getParentID(vars, strMA_Measure_Group_ID);
     
      vars.setSessionValue(windowId + "|MA_Measure_Shift_ID", strPMA_Measure_Shift_ID);
      vars.setSessionValue("800158|Date and Shift.view", "EDIT");

      refreshParentSession(vars, strPMA_Measure_Shift_ID);

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

      printPageEdit(response, request, vars, false, strMA_Measure_Group_ID, strPMA_Measure_Shift_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPMA_Measure_Shift_ID = vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|MA_Measure_Group_ID");
      refreshParentSession(vars, strPMA_Measure_Shift_ID);


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

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

      } else printPageDataSheet(response, vars, strPMA_Measure_Shift_ID, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamMA_CCP_Group_ID", tabId + "|paramMA_CCP_Group_ID");
vars.getRequestGlobalVariable("inpParamMA_Measure_Shift_ID", tabId + "|paramMA_Measure_Shift_ID");

            String strPMA_Measure_Shift_ID = vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID");

     
      vars.removeSessionValue(windowId + "|MA_Measure_Group_ID");
      String strMA_Measure_Group_ID="";

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

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

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strMA_Measure_Group_ID, strPMA_Measure_Shift_ID, tableSQL);

      else printPageDataSheet(response, vars, strPMA_Measure_Shift_ID, strMA_Measure_Group_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPMA_Measure_Shift_ID = vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID");
     

      String strMA_Measure_Group_ID = vars.getGlobalVariable("inpmaMeasureGroupId", windowId + "|MA_Measure_Group_ID", "");
      vars.setSessionValue(tabId + "|CheckPointSet.view", "RELATION");
      printPageDataSheet(response, vars, strPMA_Measure_Shift_ID, strMA_Measure_Group_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPMA_Measure_Shift_ID = vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPMA_Measure_Shift_ID = vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPMA_Measure_Shift_ID = vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID");
      String strMA_Measure_Group_ID = vars.getRequiredStringParameter("inpmaMeasureGroupId");
     
      String strNext = nextElement(vars, strMA_Measure_Group_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPMA_Measure_Shift_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPMA_Measure_Shift_ID = vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID");
      String strMA_Measure_Group_ID = vars.getRequiredStringParameter("inpmaMeasureGroupId");
     
      String strPrevious = previousElement(vars, strMA_Measure_Group_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPMA_Measure_Shift_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID");

      vars.setSessionValue(tabId + "|CheckPointSet.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPMA_Measure_Shift_ID = vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID");

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

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

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

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

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

      String strMA_Measure_Group_ID = vars.getRequiredInStringParameter("inpmaMeasureGroupId");
      String message = deleteRelation(vars, strMA_Measure_Group_ID, strPMA_Measure_Shift_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|maMeasureGroupId");
        vars.setSessionValue(tabId + "|CheckPointSet.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPMA_Measure_Shift_ID = vars.getGlobalVariable("inpmaMeasureShiftId", windowId + "|MA_Measure_Shift_ID");

      String strMA_Measure_Group_ID = vars.getRequiredStringParameter("inpmaMeasureGroupId");
      //CheckPointSetData data = getEditVariables(vars, strPMA_Measure_Shift_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 = CheckPointSetData.delete(this, strMA_Measure_Group_ID, strPMA_Measure_Shift_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 + "|maMeasureGroupId");
        vars.setSessionValue(tabId + "|CheckPointSet.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 strSQL = vars.getStringParameter("inpsql");
      try {
        printPage(response, vars, strSQL);
      } 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 strTabId = vars.getStringParameter("inpTabId");

      String strMACCPGroupID = vars.getStringParameter("inpmaCcpGroupId");

      try {
        printPage(response, vars, strTabId, strMACCPGroupID);
      } catch (ServletException ex) {
        pageErrorCallOut(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.