📄 accountteam.jsp
字号:
<%@ page import="java.util.*" %>
<%@ page import="com.sourcetap.sfa.security.*" %>
<%@ page import="com.sourcetap.sfa.util.*" %>
<%@ include file="/includes/multiSelect.jsp" %>
<%@ include file="/includes/header.jsp" %>
<%
String action = request.getParameter("action");
String teamId = request.getParameter("teamId");
if ( (action != null) && (action.equals("updateTeam") ))
{
if ( (teamId != null) && (teamId.length() > 0) )
{
String unassignedRoles = request.getParameter("inpUnassigned");
String assignedRoles = request.getParameter("inpAssigned");
if ( unassignedRoles != null )
{
StringTokenizer st = new StringTokenizer(unassignedRoles, ";");
while (st.hasMoreTokens())
{
String contactId = st.nextToken();
SecurityWrapper.removeTeamMember( teamId, contactId, userInfo, delegator );
}
}
if ( assignedRoles != null )
{
StringTokenizer st = new StringTokenizer(assignedRoles, ";");
while (st.hasMoreTokens())
{
String contactId = st.nextToken();
SecurityWrapper.addTeamMember( teamId, contactId, userInfo, delegator );
}
}
}
}
String accountId = request.getParameter("accountId");
if ( (accountId == null ) || (accountId.length() < 1) )
out.write("Error: you must save the account before you can add team members to it");
else
{
// String roleName = "";
String assignedTo = "";
String title = "New Territory";
String nextAction = UIScreenSection.ACTION_INSERT;
List assignedContacts = null;
List unassignedContacts = null;
HashMap contactFields = new HashMap();
contactFields.put("accountId", userInfo.getAccountId());
unassignedContacts = delegator.findByAnd("Contact", contactFields, null);
// roleName = selectedRole.getString("roleName");
title = "Edit Team";
nextAction = UIScreenSection.ACTION_UPDATE;
//get EntityAccess for a account where the account id = current account id.
/*select a.account_id, a.account_name, c.account_id, c.contact_id, c.first_name, c.last_name from account a, entity_access ea, team_member tm, contact c
where a.account_Id = ea.entity_Id
and ea.entity = 'Account'
and ea.party_Entity_Type = 'Team'
and tm.team_Id = ea.party_Id
and tm.party_id = c.contact_id;
*/
DynamicViewEntity dve = EntityHelper.createDynamicViewEntity( delegator, "TeamMember");
dve.addMemberEntity("EntityAccess", "EntityAccess");
dve.addViewLink("TeamMember", "EntityAccess", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("teamId", "partyId")));
dve.addAlias("EntityAccess", "entityId", null, null, null, null, null);
dve.addAlias("EntityAccess", "entity", null, null, null, null, null);
dve.addAlias("EntityAccess", "partyEntityType", null, null, null, null, null);
EntityCondition condition = new EntityConditionList(UtilMisc.toList(
new EntityExpr("entityId", EntityOperator.EQUALS, accountId),
new EntityExpr("entity", EntityOperator.EQUALS, "Account"),
new EntityExpr("partyEntityType", EntityOperator.EQUALS, "Team")),
EntityOperator.AND);
List teamList = EntityHelper.findByCondition(delegator, dve, condition, null);
HashMap assignedMap = new HashMap();
if ( teamList != null )
{
GenericValue teamGV = (GenericValue)((LinkedList)teamList).get(0);
teamId = teamGV.getString("teamId");
DynamicViewEntity dve1 = EntityHelper.createDynamicViewEntity( delegator, "Contact");
dve1.addMemberEntity("TeamMember", "TeamMember");
dve1.addViewLink("Contact", "TeamMember", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("contactId", "partyId")));
dve1.addAlias("TeamMember", "teamId", null, null, null, null, null);
EntityCondition condition1 = new EntityExpr("teamId", EntityOperator.EQUALS, teamId);
assignedContacts = EntityHelper.findByCondition(delegator, dve1, condition1, null );
Iterator i = assignedContacts.iterator();
try{
while(i.hasNext()){
GenericValue genericValue = (GenericValue)i.next();
assignedMap.put( genericValue.getString("contactId"), null);
}
} catch (Exception e){ e.printStackTrace(); out.write(e.toString()); }
}
%>
<FORM NAME=entryForm METHOD=post onSubmit="preSubmit()" ACTION=accountTeam TARGET=oMIframe>
<INPUT TYPE=hidden NAME=accountId value=<%=accountId%>>
<INPUT TYPE=hidden NAME=teamId value=<%=teamId%>>
<INPUT TYPE=hidden NAME=action value=updateTeam>
<INPUT TYPE=hidden NAME=rowCount value=1>
<input type=hidden name=inpUnassigned id=inpUnassigned value="">
<input type=hidden name=inpAssigned id=inpAssigned value="">
<TABLE WIDTH=100% CLASS=freeFormSectionTitleTable>
<TR><TD><%=title%></TD></TR>
</TABLE>
<TABLE WIDTH=100% CLASS=freeFormSectionDisplayTable>
<TR><TD colspan=2>
<table border=0 width=100% CLASS=freeFormSectionDisplayTable>
<tr><td width=45%>Unassigned Users</td><td></td><td width=45%>Assigned Users</td></tr>
<tr><td><select style="width: 100%" style=freeFormSectionDisplayTable name=unassignedMember id=unassignedRole size=10 onChange="handleUnassignedChange()">
<%
if ( unassignedContacts != null )
{
Iterator i = unassignedContacts.iterator();
try{
while(i.hasNext()){
GenericValue genericValue = (GenericValue)i.next();
String contactId = genericValue.getString("contactId");
if ( !assignedMap.containsKey(contactId) )
{
/* prefix ul- signifies orignial unassigned entry, in order to tell which entries have been changed */
out.write("<option value=ul-" + contactId + ">" + genericValue.getString("firstName") + " " + genericValue.getString("lastName") );
}
}
} catch (Exception e){ e.printStackTrace(); out.write(e.toString()); }
}
%>
</select></td>
<td align=center><input disabled type=button name=btnSel1_1 value="---" onClick="selectTransfer(this,document.entryForm.assignedMember,document.entryForm.unassignedMember, 'Y')"></td>
<td><select style="width: 100%" name=assignedMember id=assignedMember size=10 onChange="handleAssignedChange()" >
<%
if ( assignedContacts != null )
{
Iterator i = assignedContacts.iterator();
try{
while(i.hasNext()){
GenericValue genericValue = (GenericValue)i.next();
/* prefix al- signifies orignial assigned entry, in order to tell which entries have been changed */
out.write("<option value=al-" + genericValue.getString("contactId") + ">" + genericValue.getString("firstName") + " " + genericValue.getString("lastName") );
}
} catch (Exception e){ e.printStackTrace(); out.write(e.toString()); }
}
%>
</select></td>
</tr>
</table>
<TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT NAME=savebtn CLASS=button value=save></TD></TR>
</TABLE>
</FORM>
<P>Add or remove users to the access team to grant them access to this account.
<P>You must have at least one member assigned to the team, or nobody will be able to access it.
<br>
<% } %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -