📄 viewforecast.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 *//* Copyright (c) 2005-2006 Open Source Strategies, Inc. */import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilDateTime;userLogin = request.getAttribute("userLogin");salesForecastId = parameters.get("salesForecastId");forecasts = delegator.findByAndCache("SalesForecastAndCustomTimePeriod", UtilMisc.toMap("salesForecastId", salesForecastId));if (forecasts.size() == 0) { context.put("allowed", false); return;}forecast = forecasts.get(0);context.put("forecast", forecast);// if user isn't the internalPartyId of the forecastif (!forecast.getString("internalPartyId").equals(userLogin.getString("partyId"))) { // then check if user has viewall permission if (!security.hasEntityPermission("CRMSFA", "_4C_VIEWALL", userLogin)) { // if not, then permission denied context.put("allowed", false); return; }}// allow permission (may be redundant, but place here anyway)context.put("allowed", true);// check if closed, this means checking both the isClosed flag from period and if the thruDate is pastisClosed = false;if (forecast.getString("isClosed").equals("Y") || forecast.getDate("thruDate").before(UtilDateTime.nowTimestamp())) { isClosed = true;}context.put("isClosed", isClosed);// find childrenforecasts = delegator.findByAnd("SalesForecastAndCustomTimePeriod", UtilMisc.toMap("internalPartyId", forecast.getString("internalPartyId"), "parentPeriodId", forecast.getString("customTimePeriodId")), UtilMisc.toList("fromDate"));// create a pseudo forecast from the main forecast to serve as the "sum" row of the list of monthly forecastsif (forecasts.size() > 0) { pseudoForecast = forecast.getAllFields(); pseudoForecast.remove("salesForecastId"); // remove this so that the form displays "Forecast Totals" pseudoForecast.remove("internalPartyId"); // remove this as well forecasts.add(pseudoForecast);}context.put("forecasts", forecasts);// forecast historyforecastHistory = delegator.findByAnd("SalesForecastHistory", UtilMisc.toMap("salesForecastId", salesForecastId), UtilMisc.toList("salesForecastHistoryId DESC"));context.put("forecastHistory", forecastHistory);if (!isClosed) { security = request.getAttribute("security"); // check for update, which is currently a check for _4C_UPDATE and if the period is a month if (security.hasEntityPermission("CRMSFA", "_4C_UPDATE", userLogin) && forecast.getString("periodTypeId").equals("FISCAL_MONTH")) { context.put("hasUpdatePermission", true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -