String strCommand = null;
FuelLogData[] data=null;
XmlDocument xmlDocument=null;
FieldProvider dataField = vars.getEditionData(tabId);
vars.removeEditionData(tabId);
String strParamAmount = vars.getSessionValue(tabId + "|paramAmount");
String strParamName = vars.getSessionValue(tabId + "|paramName");
String strParamAmount_f = vars.getSessionValue(tabId + "|paramAmount_f");
boolean hasSearchCondition=false;
if (!(strParamAmount.equals("") && strParamName.equals("") && strParamAmount_f.equals(""))) hasSearchCondition=true;
String strParamSessionDate = vars.getGlobalVariable("inpParamSessionDate", Utility.getTransactionalDate(this, vars, windowId), "");
String buscador = "";
String[] discard = {"", "isNotTest"};
if (vars.getSessionValue("#ShowTest", "N").equals("Y")) discard[1] = new String("isTest");
if (dataField==null) {
if (!boolNew) {
discard[0] = new String("newDiscard");
data = FuelLogData.selectEdit(this, vars.getSessionValue("#AD_SqlDateTimeFormat"), vars.getLanguage(), strPVM_Vehicle_Info_ID, strVM_Fuel_Entry_ID, Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel));
if (!strVM_Fuel_Entry_ID.equals("") && (data == null || data.length==0)) {
response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
return;
}
refreshSessionEdit(vars, data);
strCommand = "EDIT";
}
if (boolNew || data==null || data.length==0) {
discard[0] = new String ("editDiscard");
strCommand = "NEW";
data = new FuelLogData[0];
} else {
discard[0] = new String ("newDiscard");
}
} else {
if (dataField.getField("vmFuelEntryId") == null || dataField.getField("vmFuelEntryId").equals("")) {
discard[0] = new String ("editDiscard");
strCommand = "NEW";
boolNew = true;
} else {
discard[0] = new String ("newDiscard");
strCommand = "EDIT";
}
}
if (dataField==null) {
if (boolNew || data==null || data.length==0) {
refreshSessionNew(vars, strPVM_Vehicle_Info_ID);
data = FuelLogData.set(strPVM_Vehicle_Info_ID, Utility.getDefault(this, vars, "Totalkm", "", "60A281DE71234897A1641706076B3A01", "0", dataField), Utility.getDefault(this, vars, "Posted", "N", "60A281DE71234897A1641706076B3A01", "N", dataField), (vars.getLanguage().equals("en_US")?ListData.selectName(this, "234", Utility.getDefault(this, vars, "Posted", "N", "60A281DE71234897A1641706076B3A01", "N", dataField)):ListData.selectNameTrl(this, vars.getLanguage(), "234", Utility.getDefault(this, vars, "Posted", "N", "60A281DE71234897A1641706076B3A01", "N", dataField))), Utility.getDefault(this, vars, "Address", "", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "Processing", "N", "60A281DE71234897A1641706076B3A01", "N", dataField), Utility.getDefault(this, vars, "Tankposition", "", "60A281DE71234897A1641706076B3A01", "", dataField), "", Utility.getDefault(this, vars, "AD_Client_ID", "@AD_CLIENT_ID@", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "AD_Org_ID", "@AD_ORG_ID@", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "Createdby", "", "60A281DE71234897A1641706076B3A01", "", dataField), FuelLogData.selectDef919F2A0A6C5311DEAA10A76E7F6B5440_0(this, Utility.getDefault(this, vars, "Createdby", "", "60A281DE71234897A1641706076B3A01", "", dataField)), Utility.getDefault(this, vars, "Updatedby", "", "60A281DE71234897A1641706076B3A01", "", dataField), FuelLogData.selectDef91AD78266C5311DEAFB777BAEEA5999D_1(this, Utility.getDefault(this, vars, "Updatedby", "", "60A281DE71234897A1641706076B3A01", "", dataField)), "Y", Utility.getDefault(this, vars, "DocumentNo", "", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "Date", "@#Date@", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "Prekmread", "", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "Curkmread", "", "60A281DE71234897A1641706076B3A01", "0", dataField), Utility.getDefault(this, vars, "Liters", "", "60A281DE71234897A1641706076B3A01", "0", dataField), Utility.getDefault(this, vars, "Perlitcost", "", "60A281DE71234897A1641706076B3A01", "0", dataField), Utility.getDefault(this, vars, "Amount", "", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "Fueltype", "", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "Mileage", "", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "C_Bpartner_ID", "", "60A281DE71234897A1641706076B3A01", "", dataField), FuelLogData.selectDef925B83D06C5311DE9742CFE9EE9F507D_2(this, Utility.getDefault(this, vars, "C_Bpartner_ID", "", "60A281DE71234897A1641706076B3A01", "", dataField)), Utility.getDefault(this, vars, "C_Bpartner_Location_ID", "", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "Business", "Y", "60A281DE71234897A1641706076B3A01", "N", dataField), Utility.getDefault(this, vars, "Processed", "N", "60A281DE71234897A1641706076B3A01", "N", dataField), (vars.getLanguage().equals("en_US")?ListData.selectName(this, "3C738BCC218F4A0F9211AD935E085C85", Utility.getDefault(this, vars, "Processed", "N", "60A281DE71234897A1641706076B3A01", "N", dataField)):ListData.selectNameTrl(this, vars.getLanguage(), "3C738BCC218F4A0F9211AD935E085C85", Utility.getDefault(this, vars, "Processed", "N", "60A281DE71234897A1641706076B3A01", "N", dataField))), Utility.getDefault(this, vars, "Serialno", "", "60A281DE71234897A1641706076B3A01", "", dataField), Utility.getDefault(this, vars, "Name", "", "60A281DE71234897A1641706076B3A01", "", dataField));
data[0].documentno = "<" + Utility.getDocumentNo( this, vars, windowId, "vm_fuel_entry", "", "", false, false) + ">";
}
}
String currentPOrg=VehicleInformationData.selectOrg(this, strPVM_Vehicle_Info_ID);
String currentOrg = (boolNew?"":(dataField!=null?dataField.getField("adOrgId"):data[0].getField("adOrgId")));
if (!currentOrg.equals("") && !currentOrg.startsWith("'")) currentOrg = "'"+currentOrg+"'";
String currentClient = (boolNew?"":(dataField!=null?dataField.getField("adClientId"):data[0].getField("adClientId")));
if (!currentClient.equals("") && !currentClient.startsWith("'")) currentClient = "'"+currentClient+"'";
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)));
if (editableTab)
xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpWindows/vehicle/management/system/Vehicle/FuelLog_Edition",discard).createXmlDocument();
else
xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpWindows/vehicle/management/system/Vehicle/FuelLog_NonEditable",discard).createXmlDocument();
xmlDocument.setParameter("tabId", tabId);
ToolBar toolbar = new ToolBar(this, editableTab, vars.getLanguage(), "FuelLog", (strCommand.equals("NEW") || boolNew || (dataField==null && (data==null || data.length==0))), "document.frmMain.inpvmFuelEntryId", "", "..", "".equals("Y"), "Vehicle", strReplaceWith, true, false, false, Utility.hasTabAttachments(this, vars, tabId, strVM_Fuel_Entry_ID));
toolbar.prepareEditionTemplate("N".equals("Y"), hasSearchCondition, vars.getSessionValue("#ShowTest", "N").equals("Y"), "STD", Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
xmlDocument.setParameter("toolbar", toolbar.toString());
try {
WindowTabs tabs = new WindowTabs(this, vars, tabId, windowId, true, (strCommand.equalsIgnoreCase("NEW")));
xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
// if (!strVM_Fuel_Entry_ID.equals("")) xmlDocument.setParameter("childTabContainer", tabs.childTabs(false));
// else xmlDocument.setParameter("childTabContainer", tabs.childTabs(true));
xmlDocument.setParameter("childTabContainer", tabs.childTabs(false));
NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "FuelLog_Relation.html", "Vehicle", "W", strReplaceWith, tabs.breadcrumb());
xmlDocument.setParameter("navigationBar", nav.toString());
LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "FuelLog_Relation.html", strReplaceWith);
xmlDocument.setParameter("leftTabs", lBar.editionTemplate(strCommand.equals("NEW")));
} catch (Exception ex) {
throw new ServletException(ex);
}
xmlDocument.setParameter("parentOrg", currentPOrg);
xmlDocument.setParameter("commandType", strCommand);
xmlDocument.setParameter("buscador",buscador);
xmlDocument.setParameter("windowId", windowId);
xmlDocument.setParameter("changed", "");
xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
xmlDocument.setParameter("theme", vars.getTheme());
final String strMappingName = UtilityData.selectObjectMapping(this, tabId);
xmlDocument.setParameter("mappingName", strMappingName);
xmlDocument.setParameter("confirmOnChanges", Utility.getJSConfirmOnChanges(vars, windowId));
//xmlDocument.setParameter("buttonReference", Utility.messageBD(this, "Reference", vars.getLanguage()));
xmlDocument.setParameter("paramSessionDate", strParamSessionDate);
xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
OBError myMessage = vars.getMessage(tabId);
vars.removeMessage(tabId);
if (myMessage!=null) {
xmlDocument.setParameter("messageType", myMessage.getType());
xmlDocument.setParameter("messageTitle", myMessage.getTitle());
xmlDocument.setParameter("messageMessage", myMessage.getMessage());
}
xmlDocument.setParameter("displayLogic", getDisplayLogicContext(vars, boolNew));
if (dataField==null) {
xmlDocument.setData("structure1",data);
} else {
FieldProvider[] dataAux = new FieldProvider[1];
dataAux[0] = dataField;
xmlDocument.setData("structure1",dataAux);
}
try {
ComboTableData comboTableData = null;
comboTableData = new ComboTableData(vars, this, "19", "VM_Vehicle_Info_ID", "", "", Utility.getReferenceableOrg(vars, (dataField!=null?dataField.getField("adOrgId"):data[0].getField("adOrgId").equals("")?vars.getOrg():data[0].getField("adOrgId"))), Utility.getContext(this, vars, "#User_Client", windowId), 0);
Utility.fillSQLParameters(this, vars, (dataField==null?data[0]:dataField), comboTableData, windowId, (dataField==null?data[0].getField("vmVehicleInfoId"):dataField.getField("vmVehicleInfoId")));
xmlDocument.setData("reportVM_Vehicle_Info_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
xmlDocument.setParameter("Date_Format", vars.getSessionValue("#AD_SqlDateFormat"));
comboTableData = new ComboTableData(vars, this, "17", "Tankposition", "3D85EC2E0B734DE48FB52AD1552B2E6A", "", Utility.getReferenceableOrg(vars, (dataField!=null?dataField.getField("adOrgId"):data[0].getField("adOrgId").equals("")?vars.getOrg():data[0].getField("adOrgId"))), Utility.getContext(this, vars, "#User_Client", windowId), 0);
Utility.fillSQLParameters(this, vars, (dataField==null?data[0]:dataField), comboTableData, windowId, (dataField==null?data[0].getField("tankposition"):dataField.getField("tankposition")));
xmlDocument.setData("reportTankposition","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
comboTableData = new ComboTableData(vars, this, "17", "Fueltype", "3C08B47B7B3F4318901B10EB18307680", "", Utility.getReferenceableOrg(vars, (dataField!=null?dataField.getField("adOrgId"):data[0].getField("adOrgId").equals("")?vars.getOrg():data[0].getField("adOrgId"))), Utility.getContext(this, vars, "#User_Client", windowId), 0);
Utility.fillSQLParameters(this, vars, (dataField==null?data[0]:dataField), comboTableData, windowId, (dataField==null?data[0].getField("fueltype"):dataField.getField("fueltype")));
xmlDocument.setData("reportFueltype","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
xmlDocument.setParameter("buttonLiters", Utility.messageBD(this, "Calc", vars.getLanguage()));
xmlDocument.setParameter("buttonPerlitcost", Utility.messageBD(this, "Calc", vars.getLanguage()));
xmlDocument.setParameter("buttonAmount", Utility.messageBD(this, "Calc", vars.getLanguage()));
xmlDocument.setParameter("Processed_BTNname", Utility.getButtonName(this, vars, "3C738BCC218F4A0F9211AD935E085C85", (dataField==null?data[0].getField("processed"):dataField.getField("processed")), "Processed_linkBTN", usedButtonShortCuts, reservedButtonShortCuts));
xmlDocument.setParameter("Posted_BTNname", Utility.getButtonName(this, vars, "234", (dataField==null?data[0].getField("posted"):dataField.getField("posted")), "Posted_linkBTN", usedButtonShortCuts, reservedButtonShortCuts));
xmlDocument.setParameter("Created_Format", vars.getSessionValue("#AD_SqlDateTimeFormat"));xmlDocument.setParameter("Created_Maxlength", Integer.toString(vars.getSessionValue("#AD_SqlDateTimeFormat").length()));
xmlDocument.setParameter("Updated_Format", vars.getSessionValue("#AD_SqlDateTimeFormat"));xmlDocument.setParameter("Updated_Maxlength", Integer.toString(vars.getSessionValue("#AD_SqlDateTimeFormat").length()));
} catch (Exception ex) {
ex.printStackTrace();
throw new ServletException(ex);