Package org.openbravo.base.secureApp

Examples of org.openbravo.base.secureApp.VariablesSecureApp


    boolHist = false;
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      String strChanged = vars.getStringParameter("inpLastFieldChanged");
      if (log4j.isDebugEnabled())
        log4j.debug("CHANGED: " + strChanged);
      String strUOM = vars.getStringParameter("inpcUomId");
      String strMProductUOMID = vars.getStringParameter("inpmProductUomId");
      String strQuantityOrder = vars.getNumericParameter("inpquantityorder");
      String strTabId = vars.getStringParameter("inpTabId");
      try {
        printPage(response, vars, strChanged, strUOM, strMProductUOMID, strQuantityOrder, 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 strActualReturnDate = vars.getStringParameter("inpactualreturndate");
    String strReturnDate = vars.getStringParameter("inpreturndate");
    String strTabId = vars.getStringParameter("inpTabId");
      try {
        printPage(response, vars, strChanged, strActualReturnDate, strReturnDate, strTabId);
      } 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 strmInoutId = request.getParameter("inpmInoutId");
       
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strmInoutId.equals(""))
              total = saveRecord(vars, myError, 'U');
          else
              total = saveRecord(vars, myError, 'I');
         
          if (!myError.isEmpty() && total == 0)    
            throw new OBException(myError.getMessage());
        }
        vars.setSessionValue(request.getParameter("mappingName") +"|hash", vars.getPostDataHash());
        vars.setSessionValue(tabId + "|Header.view", "EDIT");
       
        return;
    }
   
    try {
      tableSQL = new TableSQLData(vars, this, tabId, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
    } catch (Exception ex) {
      ex.printStackTrace();
    }

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

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

      String strM_InOut_ID = vars.getGlobalVariable("inpmInoutId", windowId + "|M_InOut_ID", "");
     

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

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

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

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

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

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


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

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

      } else printPageDataSheet(response, vars, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamDocumentNo", tabId + "|paramDocumentNo");
vars.getRequestGlobalVariable("inpParamMovementDate", tabId + "|paramMovementDate");
vars.getRequestGlobalVariable("inpParamC_BPartner_ID", tabId + "|paramC_BPartner_ID");
vars.getRequestGlobalVariable("inpParamMovementDate_f", tabId + "|paramMovementDate_f");

     
     
      vars.removeSessionValue(windowId + "|M_InOut_ID");
      String strM_InOut_ID="";

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

      if (strView.equals("EDIT")) {
        strM_InOut_ID = firstElement(vars, tableSQL);
        if (strM_InOut_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, strM_InOut_ID, tableSQL);

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

      String strM_InOut_ID = vars.getGlobalVariable("inpmInoutId", windowId + "|M_InOut_ID", "");
      vars.setSessionValue(tabId + "|Header.view", "RELATION");
      printPageDataSheet(response, vars, strM_InOut_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {


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

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

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

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

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

      String strM_InOut_ID = vars.getRequiredStringParameter("inpmInoutId");
     
      String strNext = nextElement(vars, strM_InOut_ID, tableSQL);

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

      String strM_InOut_ID = vars.getRequiredStringParameter("inpmInoutId");
     
      String strPrevious = previousElement(vars, strM_InOut_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 + "|M_InOut_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 + "|M_InOut_ID");

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

     
      String strFirst = firstElement(vars, tableSQL);

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

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

     
      String strLast = lastElement(vars, tableSQL);

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

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

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

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

      String strM_InOut_ID = vars.getRequiredStringParameter("inpmInoutId");
      //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, strM_InOut_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 + "|mInoutId");
        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("BUTTONCalculate_Freight800141")) {
        vars.setSessionValue("button800141.strcalculateFreight", vars.getStringParameter("inpcalculateFreight"));
        vars.setSessionValue("button800141.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("button800141.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("button800141.strClient", vars.getStringParameter("inpadClientId"));
       
       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("button800141.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "800141", request.getServletPath());   
     } else if (vars.commandIn("BUTTON800141")) {
        String strM_InOut_ID = vars.getGlobalVariable("inpmInoutId", windowId + "|M_InOut_ID", "");
        String strcalculateFreight = vars.getSessionValue("button800141.strcalculateFreight");
        String strProcessing = vars.getSessionValue("button800141.strProcessing");
        String strOrg = vars.getSessionValue("button800141.strOrg");
        String strClient = vars.getSessionValue("button800141.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{      
          printPageButtonCalculate_Freight800141(response, vars, strM_InOut_ID, strcalculateFreight, strProcessing);
        }

     } else if (vars.commandIn("BUTTONGenerateTo154")) {
        vars.setSessionValue("button154.strgenerateto", vars.getStringParameter("inpgenerateto"));
        vars.setSessionValue("button154.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("button154.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("button154.strClient", vars.getStringParameter("inpadClientId"));
       
       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("button154.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "154", request.getServletPath());   
     } else if (vars.commandIn("BUTTON154")) {
        String strM_InOut_ID = vars.getGlobalVariable("inpmInoutId", windowId + "|M_InOut_ID", "");
        String strgenerateto = vars.getSessionValue("button154.strgenerateto");
        String strProcessing = vars.getSessionValue("button154.strProcessing");
        String strOrg = vars.getSessionValue("button154.strOrg");
        String strClient = vars.getSessionValue("button154.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{      
          printPageButtonGenerateTo154(response, vars, strM_InOut_ID, strgenerateto, strProcessing);
        }

     } else if (vars.commandIn("BUTTONDocAction109")) {
        vars.setSessionValue("button109.strdocaction", vars.getStringParameter("inpdocaction"));
        vars.setSessionValue("button109.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("button109.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("button109.strClient", vars.getStringParameter("inpadClientId"));
        vars.setSessionValue("button109.inpdocstatus", vars.getRequiredStringParameter("inpdocstatus"));

       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("button109.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "109", request.getServletPath());   
     } else if (vars.commandIn("BUTTON109")) {
        String strM_InOut_ID = vars.getGlobalVariable("inpmInoutId", windowId + "|M_InOut_ID", "");
        String strdocaction = vars.getSessionValue("button109.strdocaction");
        String strProcessing = vars.getSessionValue("button109.strProcessing");
        String strOrg = vars.getSessionValue("button109.strOrg");
        String strClient = vars.getSessionValue("button109.strClient");
       
        String strdocstatus = vars.getSessionValue("button109.inpdocstatus");
String stradTableId = "319";

        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{      
          printPageButtonDocAction109(response, vars, strM_InOut_ID, strdocaction, strProcessing, strdocstatus, stradTableId);
        }


    } else if (vars.commandIn("SAVE_BUTTONCalculate_Freight800141")) {
        String strM_InOut_ID = vars.getGlobalVariable("inpKey", windowId + "|M_InOut_ID", "");
        @SuppressWarnings("unused")
        String strcalculateFreight = vars.getStringParameter("inpcalculateFreight");
        String strProcessing = vars.getStringParameter("inpprocessing");
        OBError myMessage = null;
        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "800141", (("M_InOut_ID".equalsIgnoreCase("AD_Language"))?"0":strM_InOut_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
          String strcheaper = vars.getStringParameter("inpcheaper", "N");
PInstanceProcessData.insertPInstanceParam(this, pinstance, "10", "cheaper", strcheaper, vars.getClient(), vars.getOrg(), vars.getUser());
String strcalcQty = vars.getStringParameter("inpcalcQty", "N");
PInstanceProcessData.insertPInstanceParam(this, pinstance, "20", "calc_qty", strcalcQty, vars.getClient(), vars.getOrg(), vars.getUser());

         
          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("SAVE_BUTTONGenerateTo154")) {
        String strM_InOut_ID = vars.getGlobalVariable("inpKey", windowId + "|M_InOut_ID", "");
        @SuppressWarnings("unused")
        String strgenerateto = vars.getStringParameter("inpgenerateto");
        String strProcessing = vars.getStringParameter("inpprocessing");
        OBError myMessage = null;
        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "154", (("M_InOut_ID".equalsIgnoreCase("AD_Language"))?"0":strM_InOut_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
          String strmPricelistVersionId = vars.getStringParameter("inpmPricelistVersionId");
PInstanceProcessData.insertPInstanceParam(this, pinstance, "10", "M_Pricelist_Version_ID", strmPricelistVersionId, vars.getClient(), vars.getOrg(), vars.getUser());

         
          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("SAVE_BUTTONDocAction109")) {
        String strM_InOut_ID = vars.getGlobalVariable("inpKey", windowId + "|M_InOut_ID", "");
        @SuppressWarnings("unused")
        String strdocaction = vars.getStringParameter("inpdocaction");
        String strProcessing = vars.getStringParameter("inpprocessing");
        OBError myMessage = null;
        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "109", (("M_InOut_ID".equalsIgnoreCase("AD_Language"))?"0":strM_InOut_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
         
          HeaderData.updateDocAction(this, strdocaction, strM_InOut_ID);

          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myMessage.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myMessage);
        }
        //close popup
        if (myMessage!=null) {
          if (log4j.isDebugEnabled()) log4j.debug(myMessage.getMessage());
          vars.setMessage(tabId, myMessage);
        }
        printPageClosePopUp(response, vars);


    } else if (vars.commandIn("BUTTONCreateFrom")) {
        String strM_InOut_ID = vars.getGlobalVariable("inpmInoutId", windowId + "|M_InOut_ID", "");
        String strTableId = "319";
        String strProcessId = "";
        String strDateInvoiced = vars.getStringParameter("inpdateinvoiced", "");
        String strBPartnerLocation = vars.getStringParameter("inpcBpartnerLocationId", "");
        String strPriceList = vars.getStringParameter("inpmPricelistId", "");
        String strBPartner = vars.getStringParameter("inpcBpartnerId", "");
        String strBankAccount = vars.getStringParameter("inpcBankaccountId");
        String strStatementDate = vars.getStringParameter("inpstatementdate");
        String strOrg = vars.getStringParameter("inpadOrgId");
        String strClient = vars.getStringParameter("inpadClientId");
        String strIsreceipt = vars.getStringParameter("inpisreceipt");
        log4j.debug("Loading CreateFrom button in table: " + strTableId);
        vars.setSessionValue("CreateFrom|key", strM_InOut_ID);
        vars.setSessionValue("CreateFrom|tableId", strTableId);
        vars.setSessionValue("CreateFrom|tabId", tabId);
        vars.setSessionValue("CreateFrom|processId", strProcessId);
        vars.setSessionValue("CreateFrom|path", strDireccion + request.getServletPath());
        vars.setSessionValue("CreateFrom|bpartnerLocation", strBPartnerLocation);
        vars.setSessionValue("CreateFrom|dateInvoiced", strDateInvoiced);
        vars.setSessionValue("CreateFrom|pricelist", strPriceList);
        vars.setSessionValue("CreateFrom|bpartner", strBPartner);
        vars.setSessionValue("CreateFrom|windowId", windowId);
        vars.setSessionValue("CreateFrom|bankAccount", strBankAccount);
        vars.setSessionValue("CreateFrom|statementDate", strStatementDate);
        vars.setSessionValue("CreateFrom|adOrgId", strOrg);
        vars.setSessionValue("CreateFrom|isreceipt", strIsreceipt);
        vars.setSessionValue("CreateFrom|tabName", "Header");
        if ((org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) || !(Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),strClient&& Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),strOrg))){
          OBError myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
          vars.setMessage(tabId, myError);
          printPageClosePopUp(response, vars);
        }else{      
          response.sendRedirect(strDireccion + "/ad_actionButton/CreateFrom.html");
        }

    } else if (vars.commandIn("BUTTONPosted")) {
        String strM_InOut_ID = vars.getGlobalVariable("inpmInoutId", windowId + "|M_InOut_ID", "");
        String strTableId = "319";
        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", strM_InOut_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

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

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

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

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

      else printPageDataSheet(response, vars, strC_ValidCombination_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strC_ValidCombination_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strC_ValidCombination_ID.equals("")) strC_ValidCombination_ID = vars.getRequiredGlobalVariable("inpcValidcombinationId", windowId + "|C_ValidCombination_ID");
      else vars.setSessionValue(windowId + "|C_ValidCombination_ID", strC_ValidCombination_ID);
     
      vars.setSessionValue(tabId + "|Combination.view", "EDIT");

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|C_ValidCombination_ID");
      String strC_ValidCombination_ID="";

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

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

      if (strView.equals("EDIT"))

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

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

      String strC_ValidCombination_ID = vars.getGlobalVariable("inpcValidcombinationId", windowId + "|C_ValidCombination_ID", "");
      vars.setSessionValue(tabId + "|Combination.view", "RELATION");
      printPageDataSheet(response, vars, strC_ValidCombination_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_ValidCombination_ID = vars.getGlobalVariable("inpcValidcombinationId", windowId + "|C_ValidCombination_ID", "");
      vars.setSessionValue(tabId + "|Combination.view", "EDIT");

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

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

      String strC_ValidCombination_ID = vars.getRequiredStringParameter("inpcValidcombinationId");
     
      String strNext = nextElement(vars, strC_ValidCombination_ID, tableSQL);

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

      String strC_ValidCombination_ID = vars.getRequiredStringParameter("inpcValidcombinationId");
     
      String strPrevious = previousElement(vars, strC_ValidCombination_ID, tableSQL);

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

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

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

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

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

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

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

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

      String strM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID", "");
     

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

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

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

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

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

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


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

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

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

     
     
      vars.removeSessionValue(windowId + "|M_Internal_Consumption_ID");
      String strM_Internal_Consumption_ID="";

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

      if (strView.equals("EDIT")) {
        strM_Internal_Consumption_ID = firstElement(vars, tableSQL);
        if (strM_Internal_Consumption_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, strM_Internal_Consumption_ID, tableSQL);

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

      String strM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID", "");
      vars.setSessionValue(tabId + "|Header.view", "RELATION");
      printPageDataSheet(response, vars, strM_Internal_Consumption_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {


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

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

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

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

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

      String strM_Internal_Consumption_ID = vars.getRequiredStringParameter("inpmInternalConsumptionId");
     
      String strNext = nextElement(vars, strM_Internal_Consumption_ID, tableSQL);

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

      String strM_Internal_Consumption_ID = vars.getRequiredStringParameter("inpmInternalConsumptionId");
     
      String strPrevious = previousElement(vars, strM_Internal_Consumption_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 + "|M_Internal_Consumption_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 + "|M_Internal_Consumption_ID");

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

     
      String strFirst = firstElement(vars, tableSQL);

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

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

     
      String strLast = lastElement(vars, tableSQL);

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

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

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

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

      String strM_Internal_Consumption_ID = vars.getRequiredStringParameter("inpmInternalConsumptionId");
      //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, strM_Internal_Consumption_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 + "|mInternalConsumptionId");
        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("BUTTONProcessing800131")) {
        vars.setSessionValue("button800131.strprocessing", vars.getStringParameter("inpprocessing"));
        vars.setSessionValue("button800131.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("button800131.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("button800131.strClient", vars.getStringParameter("inpadClientId"));
       
       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("button800131.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "800131", request.getServletPath());   
     } else if (vars.commandIn("BUTTON800131")) {
        String strM_Internal_Consumption_ID = vars.getGlobalVariable("inpmInternalConsumptionId", windowId + "|M_Internal_Consumption_ID", "");
        String strprocessing = vars.getSessionValue("button800131.strprocessing");
        String strProcessing = vars.getSessionValue("button800131.strProcessing");
        String strOrg = vars.getSessionValue("button800131.strOrg");
        String strClient = vars.getSessionValue("button800131.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{      
          printPageButtonProcessing800131(response, vars, strM_Internal_Consumption_ID, strprocessing, strProcessing);
        }


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






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

    boolHist = false;
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      String strChanged = vars.getStringParameter("inpLastFieldChanged");
      if (log4j.isDebugEnabled())
        log4j.debug("CHANGED: " + strChanged);
      String strQty = vars.getNumericParameter("inpqty");
      String strPriceActual = vars.getNumericParameter("inppriceactual");
      String strPriceList = vars.getNumericParameter("inppricelist");
      String strDiscount = vars.getNumericParameter("inpdiscount");
      try {
        printPage(response, vars, strQty, strPriceActual, strDiscount, strPriceList, strChanged);
      } 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 strcRemittancelineId = request.getParameter("inpcRemittancelineId");
         String strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strcRemittancelineId.equals(""))
              total = saveRecord(vars, myError, 'U', strPC_Remittance_ID);
          else
              total = saveRecord(vars, myError, 'I', strPC_Remittance_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 strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID", "");

      String strC_Remittanceline_ID = vars.getGlobalVariable("inpcRemittancelineId", windowId + "|C_Remittanceline_ID", "");
            if (strPC_Remittance_ID.equals("")) {
        strPC_Remittance_ID = getParentID(vars, strC_Remittanceline_ID);
        if (strPC_Remittance_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|C_Remittance_ID");
        vars.setSessionValue(windowId + "|C_Remittance_ID", strPC_Remittance_ID);

        refreshParentSession(vars, strPC_Remittance_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strC_Remittanceline_ID, strPC_Remittance_ID, tableSQL);

      else printPageDataSheet(response, vars, strPC_Remittance_ID, strC_Remittanceline_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strC_Remittanceline_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strC_Remittanceline_ID.equals("")) strC_Remittanceline_ID = vars.getRequiredGlobalVariable("inpcRemittancelineId", windowId + "|C_Remittanceline_ID");
      else vars.setSessionValue(windowId + "|C_Remittanceline_ID", strC_Remittanceline_ID);
     
     
      String strPC_Remittance_ID = getParentID(vars, strC_Remittanceline_ID);
     
      vars.setSessionValue(windowId + "|C_Remittance_ID", strPC_Remittance_ID);
      vars.setSessionValue("800213|Header.view", "EDIT");

      refreshParentSession(vars, strPC_Remittance_ID);

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

      printPageEdit(response, request, vars, false, strC_Remittanceline_ID, strPC_Remittance_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|C_Remittanceline_ID");
      refreshParentSession(vars, strPC_Remittance_ID);


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

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

      } else printPageDataSheet(response, vars, strPC_Remittance_ID, "", tableSQL);
    } else if (vars.commandIn("SEARCH")) {
vars.getRequestGlobalVariable("inpParamC_Remittance_ID", tabId + "|paramC_Remittance_ID");
vars.getRequestGlobalVariable("inpParamLine", tabId + "|paramLine");
vars.getRequestGlobalVariable("inpParamLine_f", tabId + "|paramLine_f");

            String strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");

     
      vars.removeSessionValue(windowId + "|C_Remittanceline_ID");
      String strC_Remittanceline_ID="";

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

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

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strC_Remittanceline_ID, strPC_Remittance_ID, tableSQL);

      else printPageDataSheet(response, vars, strPC_Remittance_ID, strC_Remittanceline_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");
     

      String strC_Remittanceline_ID = vars.getGlobalVariable("inpcRemittancelineId", windowId + "|C_Remittanceline_ID", "");
      vars.setSessionValue(tabId + "|Lines.view", "RELATION");
      printPageDataSheet(response, vars, strPC_Remittance_ID, strC_Remittanceline_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");
      String strC_Remittanceline_ID = vars.getRequiredStringParameter("inpcRemittancelineId");
     
      String strNext = nextElement(vars, strC_Remittanceline_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPC_Remittance_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");
      String strC_Remittanceline_ID = vars.getRequiredStringParameter("inpcRemittancelineId");
     
      String strPrevious = previousElement(vars, strC_Remittanceline_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPC_Remittance_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");

      vars.setSessionValue(tabId + "|Lines.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");

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

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

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

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

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

      String strC_Remittanceline_ID = vars.getRequiredInStringParameter("inpcRemittancelineId");
      String message = deleteRelation(vars, strC_Remittanceline_ID, strPC_Remittance_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|cRemittancelineId");
        vars.setSessionValue(tabId + "|Lines.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPC_Remittance_ID = vars.getGlobalVariable("inpcRemittanceId", windowId + "|C_Remittance_ID");

      String strC_Remittanceline_ID = vars.getRequiredStringParameter("inpcRemittancelineId");
      //LinesData data = getEditVariables(vars, strPC_Remittance_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 = LinesData.delete(this, strC_Remittanceline_ID, strPC_Remittance_ID, Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), Utility.getContext(this, vars, "#User_Org", windowId, accesslevel));
        } catch(ServletException ex) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myError.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myError);
        }
        if (myError==null && total==0) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
          vars.setMessage(tabId, myError);
        }
        vars.removeSessionValue(windowId + "|cRemittancelineId");
        vars.setSessionValue(tabId + "|Lines.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 = 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 strmPricelistVersionId = request.getParameter("inpmPricelistVersionId");
         String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");
        if (editableTab) {
          int total = 0;
         
          if(commandType.equalsIgnoreCase("EDIT") && !strmPricelistVersionId.equals(""))
              total = saveRecord(vars, myError, 'U', strPM_PriceList_ID);
          else
              total = saveRecord(vars, myError, 'I', strPM_PriceList_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_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID", "");

      String strM_PriceList_Version_ID = vars.getGlobalVariable("inpmPricelistVersionId", windowId + "|M_PriceList_Version_ID", "");
            if (strPM_PriceList_ID.equals("")) {
        strPM_PriceList_ID = getParentID(vars, strM_PriceList_Version_ID);
        if (strPM_PriceList_ID.equals("")) throw new ServletException("Required parameter :" + windowId + "|M_PriceList_ID");
        vars.setSessionValue(windowId + "|M_PriceList_ID", strPM_PriceList_ID);

        refreshParentSession(vars, strPM_PriceList_ID);
      }


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

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

        printPageEdit(response, request, vars, false, strM_PriceList_Version_ID, strPM_PriceList_ID, tableSQL);

      else printPageDataSheet(response, vars, strPM_PriceList_ID, strM_PriceList_Version_ID, tableSQL);
    } else if (vars.commandIn("DIRECT")) {
      String strM_PriceList_Version_ID = vars.getStringParameter("inpDirectKey");
     
       
      if (strM_PriceList_Version_ID.equals("")) strM_PriceList_Version_ID = vars.getRequiredGlobalVariable("inpmPricelistVersionId", windowId + "|M_PriceList_Version_ID");
      else vars.setSessionValue(windowId + "|M_PriceList_Version_ID", strM_PriceList_Version_ID);
     
     
      String strPM_PriceList_ID = getParentID(vars, strM_PriceList_Version_ID);
     
      vars.setSessionValue(windowId + "|M_PriceList_ID", strPM_PriceList_ID);
      vars.setSessionValue("191|Price List.view", "EDIT");

      refreshParentSession(vars, strPM_PriceList_ID);

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

      printPageEdit(response, request, vars, false, strM_PriceList_Version_ID, strPM_PriceList_ID, tableSQL);

    } else if (vars.commandIn("TAB")) {
      String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID", false, false, true, "");
      vars.removeSessionValue(windowId + "|M_PriceList_Version_ID");
      refreshParentSession(vars, strPM_PriceList_ID);


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

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

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

            String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");

     
      vars.removeSessionValue(windowId + "|M_PriceList_Version_ID");
      String strM_PriceList_Version_ID="";

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

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

      if (strView.equals("EDIT"))

        printPageEdit(response, request, vars, false, strM_PriceList_Version_ID, strPM_PriceList_ID, tableSQL);

      else printPageDataSheet(response, vars, strPM_PriceList_ID, strM_PriceList_Version_ID, tableSQL);
    } else if (vars.commandIn("RELATION")) {
            String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");
     

      String strM_PriceList_Version_ID = vars.getGlobalVariable("inpmPricelistVersionId", windowId + "|M_PriceList_Version_ID", "");
      vars.setSessionValue(tabId + "|PriceListVersion.view", "RELATION");
      printPageDataSheet(response, vars, strPM_PriceList_ID, strM_PriceList_Version_ID, tableSQL);
    } else if (vars.commandIn("NEW")) {
      String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");


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

    } else if (vars.commandIn("EDIT")) {
      String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");

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

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

    } else if (vars.commandIn("NEXT")) {
      String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");
      String strM_PriceList_Version_ID = vars.getRequiredStringParameter("inpmPricelistVersionId");
     
      String strNext = nextElement(vars, strM_PriceList_Version_ID, tableSQL);

      printPageEdit(response, request, vars, false, strNext, strPM_PriceList_ID, tableSQL);
    } else if (vars.commandIn("PREVIOUS")) {
      String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");
      String strM_PriceList_Version_ID = vars.getRequiredStringParameter("inpmPricelistVersionId");
     
      String strPrevious = previousElement(vars, strM_PriceList_Version_ID, tableSQL);

      printPageEdit(response, request, vars, false, strPrevious, strPM_PriceList_ID, tableSQL);
    } else if (vars.commandIn("FIRST_RELATION")) {
vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");

      vars.setSessionValue(tabId + "|PriceListVersion.initRecordNumber", "0");
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
      String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");

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

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

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

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

      printPageEdit(response, request, vars, false, strLast, strPM_PriceList_ID, tableSQL);
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {
      String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");
      OBError myError = new OBError();     
      int total = saveRecord(vars, myError, 'I', strPM_PriceList_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_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");
      String strM_PriceList_Version_ID = vars.getRequiredGlobalVariable("inpmPricelistVersionId", windowId + "|M_PriceList_Version_ID");
      OBError myError = new OBError();
      int total = saveRecord(vars, myError, 'U', strPM_PriceList_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_PriceList_Version_ID, tableSQL);
          vars.setSessionValue(windowId + "|M_PriceList_Version_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_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");

      String strM_PriceList_Version_ID = vars.getRequiredInStringParameter("inpmPricelistVersionId");
      String message = deleteRelation(vars, strM_PriceList_Version_ID, strPM_PriceList_ID);
      if (!message.equals("")) {
        bdError(request, response, message, vars.getLanguage());
      } else {
        vars.removeSessionValue(windowId + "|mPricelistVersionId");
        vars.setSessionValue(tabId + "|PriceListVersion.view", "RELATION");
        response.sendRedirect(strDireccion + request.getServletPath());
      }*/
    } else if (vars.commandIn("DELETE")) {
      String strPM_PriceList_ID = vars.getGlobalVariable("inpmPricelistId", windowId + "|M_PriceList_ID");

      String strM_PriceList_Version_ID = vars.getRequiredStringParameter("inpmPricelistVersionId");
      //PriceListVersionData data = getEditVariables(vars, strPM_PriceList_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 = PriceListVersionData.delete(this, strM_PriceList_Version_ID, strPM_PriceList_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 + "|mPricelistVersionId");
        vars.setSessionValue(tabId + "|PriceListVersion.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("BUTTONM_Pricelist_Version_Generate800069")) {
        vars.setSessionValue("button800069.strmPricelistVersionGenerate", vars.getStringParameter("inpmPricelistVersionGenerate"));
        vars.setSessionValue("button800069.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("button800069.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("button800069.strClient", vars.getStringParameter("inpadClientId"));
       
       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("button800069.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "800069", request.getServletPath());   
     } else if (vars.commandIn("BUTTON800069")) {
        String strM_PriceList_Version_ID = vars.getGlobalVariable("inpmPricelistVersionId", windowId + "|M_PriceList_Version_ID", "");
        String strmPricelistVersionGenerate = vars.getSessionValue("button800069.strmPricelistVersionGenerate");
        String strProcessing = vars.getSessionValue("button800069.strProcessing");
        String strOrg = vars.getSessionValue("button800069.strOrg");
        String strClient = vars.getSessionValue("button800069.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{      
          printPageButtonM_Pricelist_Version_Generate800069(response, vars, strM_PriceList_Version_ID, strmPricelistVersionGenerate, strProcessing);
        }

     } else if (vars.commandIn("BUTTONProcCreate103")) {
        vars.setSessionValue("button103.strproccreate", vars.getStringParameter("inpproccreate"));
        vars.setSessionValue("button103.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
        vars.setSessionValue("button103.strOrg", vars.getStringParameter("inpadOrgId"));
        vars.setSessionValue("button103.strClient", vars.getStringParameter("inpadClientId"));
       
       
        HashMap<String, String> p = new HashMap<String, String>();
       
       
        //Save in session needed params for combos if needed
        vars.setSessionObject("button103.originalParams", FieldProviderFactory.getFieldProvider(p));
        printPageButtonFS(response, vars, "103", request.getServletPath());   
     } else if (vars.commandIn("BUTTON103")) {
        String strM_PriceList_Version_ID = vars.getGlobalVariable("inpmPricelistVersionId", windowId + "|M_PriceList_Version_ID", "");
        String strproccreate = vars.getSessionValue("button103.strproccreate");
        String strProcessing = vars.getSessionValue("button103.strProcessing");
        String strOrg = vars.getSessionValue("button103.strOrg");
        String strClient = vars.getSessionValue("button103.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{      
          printPageButtonProcCreate103(response, vars, strM_PriceList_Version_ID, strproccreate, strProcessing);
        }


    } else if (vars.commandIn("SAVE_BUTTONM_Pricelist_Version_Generate800069")) {
        String strM_PriceList_Version_ID = vars.getGlobalVariable("inpKey", windowId + "|M_PriceList_Version_ID", "");
        @SuppressWarnings("unused")
        String strmPricelistVersionGenerate = vars.getStringParameter("inpmPricelistVersionGenerate");
        String strProcessing = vars.getStringParameter("inpprocessing");
        OBError myMessage = null;
        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "800069", (("M_PriceList_Version_ID".equalsIgnoreCase("AD_Language"))?"0":strM_PriceList_Version_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
          String strmPricelistVersionOrigenId = vars.getStringParameter("inpmPricelistVersionOrigenId");
PInstanceProcessData.insertPInstanceParam(this, pinstance, "10", "M_PriceList_Version_Origen_ID", strmPricelistVersionOrigenId, vars.getClient(), vars.getOrg(), vars.getUser());

         
          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("SAVE_BUTTONProcCreate103")) {
        String strM_PriceList_Version_ID = vars.getGlobalVariable("inpKey", windowId + "|M_PriceList_Version_ID", "");
        @SuppressWarnings("unused")
        String strproccreate = vars.getStringParameter("inpproccreate");
        String strProcessing = vars.getStringParameter("inpprocessing");
        OBError myMessage = null;
        try {
          String pinstance = SequenceIdData.getUUID();
          PInstanceProcessData.insertPInstance(this, pinstance, "103", (("M_PriceList_Version_ID".equalsIgnoreCase("AD_Language"))?"0":strM_PriceList_Version_ID), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
          String strdeleteold = vars.getStringParameter("inpdeleteold", "N");
PInstanceProcessData.insertPInstanceParam(this, pinstance, "10", "DeleteOld", strdeleteold, vars.getClient(), vars.getOrg(), vars.getUser());

         
          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
          new ProcessRunner(bundle).execute(this);
         
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          if (!myMessage.isConnectionAvailable()) {
            bdErrorConnection(response);
            return;
          } else vars.setMessage(tabId, myMessage);
        }
        //close popup
        if (myMessage!=null) {
          if (log4j.isDebugEnabled()) log4j.debug(myMessage.getMessage());
          vars.setMessage(tabId, myMessage);
        }
        printPageClosePopUp(response, vars);






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

    boolHist = false;
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      String strHBActive = vars.getStringParameter("inpisheartbeatactive");
      String strRegActive = vars.getStringParameter("inpisregistrationactive");
      try {
        printPage(response, vars, strHBActive, strRegActive);
      } 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 strCommand = vars.getStringParameter("inpatCommandId");

      try {
        printPage(response, vars, strCommand);
      } 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.