📄 parsereportoptions.bsh
字号:
/* * Copyright (C) 2006 Open Source Strategies, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *//* * This file should be called before every report that uses the * flowReportOptions, stateReportOptions, etc. form files for * reporting. It takes care of parsing the input form data, * especially the dates, and setting up the context for correct * use by the form ftl files. * * After this script is called, call your report generation * script and get the form data from the context: * * glFiscalTypeId * fromDate (Timestamp or null if not specified) * thruDate (Timestamp or null if not specified) * * @author Leon Torres (leon@opensourcestrategies.com) * TODO: for comparative state, take the thru dates */import java.util.*;import java.sql.Timestamp;import org.ofbiz.base.util.*;// get the form dataorganizationPartyId = session.getAttribute("organizationPartyId");customTimePeriods = delegator.findByAndCache("CustomTimePeriod", UtilMisc.toMap("organizationPartyId", organizationPartyId), UtilMisc.toList("customTimePeriodId"));glFiscalTypes = delegator.findAll("GlFiscalType");context.put("organizationPartyId", organizationPartyId);context.put("customTimePeriods", customTimePeriods);context.put("glFiscalTypes", glFiscalTypes);// check that the reportDateOption is defined (radio button for chosing time period or dates)dateOption = parameters.get("reportDateOption");if (dateOption == null) return;// get the report form type (flow, state, comparativeFlow, comparativeState)reportFormType = parameters.get("reportFormType");// pass the glFiscalTypeId to the next scriptglFiscalTypeId = parameters.get("glFiscalTypeId");context.put("glFiscalTypeId", glFiscalTypeId);// determine the from and thru dates according to the report form typeif (dateOption.equals("byDate")) { if (reportFormType.equals("state")) { asOfDate = parameters.get("asOfDate"); if (asOfDate == null || asOfDate.length() == 0) return; asOfTimestamp = Timestamp.valueOf(asOfDate + " 23:59:59.999"); context.put("asOfDate", asOfTimestamp); } else if (reportFormType.equals("flow") || reportFormType.equals("comparative")) { fromDate = parameters.get("fromDate"); thruDate = parameters.get("thruDate"); if (fromDate == null || fromDate.length() == 0 || thruDate == null || thruDate.length() == 0) return; context.put("fromDate", Timestamp.valueOf(fromDate + " 00:00:00.000")); context.put("thruDate", Timestamp.valueOf(thruDate + " 23:59:59.999")); }} else if (dateOption.equals("byTimePeriod")) { if (reportFormType.equals("state") || reportFormType.equals("flow")) { context.put("customTimePeriodId", parameters.get("customTimePeriodId")); timePeriod = delegator.findByPrimaryKeyCache("CustomTimePeriod", UtilMisc.toMap("customTimePeriodId", context.get("customTimePeriodId"))); fromDate = new Timestamp(timePeriod.get("fromDate").getTime()); thruDate = new Timestamp(timePeriod.get("thruDate").getTime()); context.put("fromDate", fromDate); context.put("thruDate", thruDate); context.put("asOfDate", thruDate); } else if (reportFormType.equals("comparative")) { context.put("fromCustomTimePeriodId", parameters.get("fromCustomTimePeriodId")); context.put("thruCustomTimePeriodId", parameters.get("thruCustomTimePeriodId")); fromTimePeriod = delegator.findByPrimaryKeyCache("CustomTimePeriod", UtilMisc.toMap("customTimePeriodId", context.get("fromCustomTimePeriodId"))); thruTimePeriod = delegator.findByPrimaryKeyCache("CustomTimePeriod", UtilMisc.toMap("customTimePeriodId", context.get("thruCustomTimePeriodId"))); fromDate = new Timestamp(fromTimePeriod.get("thruDate").getTime()); thruDate = new Timestamp(thruTimePeriod.get("thruDate").getTime()); context.put("fromDate", fromDate); context.put("thruDate", thruDate); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -