📄 viewcontact.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.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;import com.opensourcestrategies.crmsfa.opportunities.UtilOpportunity;/* finds all the information relevant to this contact and puts them in the context, so the various formsand FTLs of this screen can display them correctly */partyId = parameters.get("partyId");//make sure that the partyId is actually an CONTACT before trying to display it as oncedelegator = request.getAttribute("delegator");validRoleTypeId = PartyHelper.getFirstValidRoleTypeId(partyId, UtilMisc.toList("CONTACT"), delegator);// if not, return right away (otherwise we get spaghetti code)if ((validRoleTypeId == null) || (!validRoleTypeId.equals("CONTACT"))) { context.put("validView", false); // other pages will know this page shouldn't be viewed return;}// is the contact still active? if there are no longer any current CONTACT PartyRelationships, then the answer is nocontactActive = true;activeRelationships = EntityUtil.filterByDate(delegator.findByAnd("PartyRelationship", UtilMisc.toMap("partyIdFrom", partyId, "roleTypeIdFrom", "CONTACT")));if ((activeRelationships == null) || (activeRelationships.size() == 0)) { contactActive = false;}if (!contactActive) { context.put("contactDeactivated", true); context.put("validView", true); // can still view history of deactivated contacts}dispatcher = request.getAttribute("dispatcher");// contact summary datapartySummary = delegator.findByPrimaryKey("PartySummaryCRMView", UtilMisc.toMap("partyId", partyId));context.put("partySummary", partySummary);// gather data that should only be available for active accountsif (contactActive) { // who is currently responsible for contact responsibleParty = PartyHelper.getCurrentResponsibleParty(partyId, "CONTACT", delegator); context.put("responsibleParty", responsibleParty); // contact accounts findParams = UtilMisc.toMap("entityName", "PartyToSummaryByRelationship", "inputFields", UtilMisc.toMap("partyIdFrom", partyId, "roleTypeIdFrom", "CONTACT", "roleTypeIdTo", "ACCOUNT", "partyRelationshipTypeId", "CONTACT_REL_INV"), "filterByDate", "Y"); findParams.put("orderBy", "groupName"); results = dispatcher.runSync("performFind", findParams); context.put("accountsListIt", results.get("listIt")); // opportunities related to contact opportunitiesOrderBy = parameters.get("opportunitiesOrderBy"); if (opportunitiesOrderBy == null) opportunitiesOrderBy = "estimatedCloseDate"; findParams = UtilMisc.toMap("entityName", "SalesOpportunityAndRole", "inputFields", UtilMisc.toMap("partyId", partyId, "roleTypeId", "CONTACT"), "orderBy", opportunitiesOrderBy); results = dispatcher.runSync("performFind", findParams); context.put("opportunitiesListIt", results.get("listIt")); // cases related to this contact (see myCases.bsh for another example) context.put("casesListIt", UtilCase.getCasesForParty(delegator, partyId, "CONTACT", parameters.get("casesOrderBy"))); // contact notes results = dispatcher.runSync("performFind", UtilMisc.toMap("entityName", "PartyNoteView", "inputFields", UtilMisc.toMap("targetPartyId", partyId), "orderBy", "noteDateTime DESC")); context.put("notesListIt", results.get("listIt")); // permission to update contact information, for generic view profile screen if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_CONTACT", "_UPDATE", request.getAttribute("userLogin"), partyId)) { context.put("hasUpdatePermission", true); // this implies ability to remove contacts too context.put("hasAccountsRemoveAbility", 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 reassign contact if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_CONTACT", "_REASSIGN", request.getAttribute("userLogin"), partyId)) { context.put("hasReassignPermission", true); } // permission to deactivate contact if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_CONTACT", "_DEACTIVATE", request.getAttribute("userLogin"), partyId)) { context.put("hasDeactivatePermission", true); } // permission to create cases for account if (CrmsfaSecurity.hasPartyRelationSecurity(request.getAttribute("security"), "CRMSFA_CASE", "_CREATE", request.getAttribute("userLogin"), partyId)) { context.put("hasCreateCasePermission", true); } // set this flag to allow contact mechs to be shown request.setAttribute("displayContactMechs", "Y"); // set this flag to tell other scripts this page can be viewed context.put("validView", true);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -