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);
}