⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewaccount.bsh

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 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 */import org.ofbiz.base.util.UtilMisc;import org.ofbiz.entity.condition.EntityConditionList;import org.ofbiz.entity.condition.EntityExpr;import org.ofbiz.entity.condition.EntityOperator;import org.ofbiz.entity.util.EntityFindOptions;import org.ofbiz.entity.util.EntityUtil;import com.opensourcestrategies.crmsfa.security.CrmsfaSecurity;import com.opensourcestrategies.crmsfa.party.PartyHelper;import com.opensourcestrategies.crmsfa.cases.UtilCase;partyId = parameters.get("partyId");// make sure that the partyId is actually an ACCOUNT before trying to display it as oncedelegator = request.getAttribute("delegator");validRoleTypeId = PartyHelper.getFirstValidRoleTypeId(partyId, UtilMisc.toList("ACCOUNT"), delegator);// if not, return right away (otherwise we get spaghetti code)if ((validRoleTypeId == null) || (!validRoleTypeId.equals("ACCOUNT")))  {    context.put("validView", false);    return;}/* finds all the information relevant to this account and puts them in the context, so the various forms   and FTLs of this screen can display them correctly */// is the account still active?  if there are no longer any current ACCOUNT PartyRelationships, then the answer is noaccountActive = true;activeRelationships = EntityUtil.filterByDate(delegator.findByAnd("PartyRelationship", UtilMisc.toMap("partyIdFrom", partyId, "roleTypeIdFrom", "ACCOUNT")));if ((activeRelationships == null) || (activeRelationships.size() == 0)) {    accountActive = false;}if (!accountActive) {    context.put("validView", true);    context.put("accountDeactivated", true);}dispatcher = request.getAttribute("dispatcher");// account summary datapartySummary = delegator.findByPrimaryKey("PartySummaryCRMView", UtilMisc.toMap("partyId", partyId));context.put("partySummary", partySummary);// gather data that should only be available for active accountsif (accountActive) {    // who is currently responsible for account    responsibleParty = PartyHelper.getCurrentResponsibleParty(partyId, "ACCOUNT", delegator);    context.put("responsibleParty", responsibleParty);    // account contacts TODO: this order by isn't used yet, maybe we will need to sort these one day    contactsOrderBy = parameters.get("contactsOrderBy");    if (contactsOrderBy == null) contactsOrderBy = "lastName";    findParams = UtilMisc.toMap("entityName", "PartyFromSummaryByRelationship",            "inputFields", UtilMisc.toMap("partyIdTo", partyId, "roleTypeIdTo", "ACCOUNT", "partyRelationshipTypeId", "CONTACT_REL_INV"),            "filterByDate", "Y");    findParams.put("orderBy", contactsOrderBy);    results = dispatcher.runSync("performFind", findParams);    context.put("contactsListIt", results.get("listIt"));    // set this flag to allow contact mechs to be shown    request.setAttribute("displayContactMechs", "Y");     // account opportunities    // this may have to be enhanced to exclude some types of opportunities (ie, closed ones)?    opportunitiesOrderBy = parameters.get("opportunitiesOrderBy");    if (opportunitiesOrderBy == null) opportunitiesOrderBy = "estimatedCloseDate";    findParams = UtilMisc.toMap("entityName", "SalesOpportunityAndRole",            "inputFields", UtilMisc.toMap("partyId", partyId, "roleTypeId", "ACCOUNT"),            "orderBy", opportunitiesOrderBy);    results = dispatcher.runSync("performFind", findParams);    context.put("opportunitiesListIt", results.get("listIt"));    // account data sources    sources = delegator.findByAnd("PartyDataSource", UtilMisc.toMap("partyId", partyId), UtilMisc.toList("fromDate DESC"));    context.put("dataSources", sources);    // account notes    results = dispatcher.runSync("performFind", UtilMisc.toMap("entityName", "PartyNoteView",                 "inputFields", UtilMisc.toMap("targetPartyId", partyId), "orderBy", "noteDateTime DESC"));    context.put("notesListIt", results.get("listIt"));    // cases related to this account (see myCases.bsh for another example)    context.put("casesListIt", UtilCase.getCasesForParty(delegator, partyId, "ACCOUNT", parameters.get("casesOrderBy")));    // account team members    findParams = UtilMisc.toMap("entityName", "PartyToSummaryByRelationship",            "inputFields", UtilMisc.toMap("partyIdFrom", partyId, "roleTypeIdFrom", "ACCOUNT", "partyRelationshipTypeId", "ASSIGNED_TO"),            "filterByDate", "Y");    findParams.put("orderBy", "lastName");    results = dispatcher.runSync("performFind", findParams);    accountTeamMembers = results.get("listIt");    context.put("accountTeamMembers", accountTeamMembers);    // check if there are any team members    hasTeamMembers = false;    // NOTE: ofbiz doesn't like this being called despite this being a legitimate use for hasNext.     // to turn the messages off, there's a flag in framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java    if ((accountTeamMembers != null) && (accountTeamMembers.hasNext())) {         hasTeamMembers = true;    }    context.put("hasTeamMembers", hasTeamMembers);    // permission to update account information    if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_ACCOUNT", "_UPDATE", request.getAttribute("userLogin"), partyId)) {        context.put("hasUpdatePermission", true);        // this implies ability to remove contacts too        context.put("hasContactRemoveAbility", true);        // this also means activiites may be created, but only if user has CRMSFA_ACT_CREATE        if (security.hasEntityPermission("CRMSFA_ACT", "_CREATE", userLogin)) {            context.put("hasNewActivityPermission", true);        }    }    // permission to deactivate account information, for generic view profile screen    if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_ACCOUNT", "_DEACTIVATE", request.getAttribute("userLogin"), partyId)) {        context.put("hasDeactivatePermission", true);    }    // permission to reassign accounts, for generic view profile screen    if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_ACCOUNT", "_REASSIGN", request.getAttribute("userLogin"), partyId)) {        context.put("hasReassignPermission", true);    }    // permission to create opportunities for account    if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_OPP", "_CREATE", request.getAttribute("userLogin"), partyId)) {        context.put("hasCreateOppPermission", true);    }    // permission to create cases for account    if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_CASE", "_CREATE", request.getAttribute("userLogin"), partyId)) {        context.put("hasCreateCasePermission", true);    }    // permission to change team member roles    hasTeamUpdatePermission = false; // this needs to be set so that a form-widget can test it with "use-when"    if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_TEAM", "_UPDATE", request.getAttribute("userLogin"), partyId)) {        hasTeamUpdatePermission = true;    }    context.put("hasTeamUpdatePermission", hasTeamUpdatePermission);    // permission to remove team members    if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_TEAM", "_REMOVE", request.getAttribute("userLogin"), partyId)) {        context.put("hasTeamRemovePermission", true);    }    // permission to assign team members    if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_TEAM", "_ASSIGN", request.getAttribute("userLogin"), partyId)) {        context.put("hasTeamAssignPermission", true);    }        context.put("validView", true);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -