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

📄 territoryedit.jsp

📁 国外的一套开源CRM
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<%@ page import="com.sourcetap.sfa.contact.*" %>
<jsp:useBean id="contactWebEventProcessor" class="com.sourcetap.sfa.contact.ContactWebEventProcessor" scope="application" />
<jsp:useBean id="contactEventProcessor" class="com.sourcetap.sfa.contact.ContactEventProcessor" scope="application" />

<%@page import="java.util.*"%>
<%@page import="com.sourcetap.sfa.role.*"%>
<%@page import="com.sourcetap.sfa.ui.UIScreenSection"%>
<%@page import="java.util.StringTokenizer"%>
<%@page import="com.sourcetap.sfa.replication.*" %>
<%@page import="org.ofbiz.entity.condition.*" %>
<%@page import="org.ofbiz.entity.model.*" %>
<%@page import="org.ofbiz.entity.*" %>

<SCRIPT LANGUAGE="JavaScript">
function handleUnassignedChange() {
	document.entryForm.assignedRole.selectedIndex = -1;
	document.entryForm.btnSel1_1.disabled = false;
	document.entryForm.btnSel1_1.value = ">>>";
}
function handleAssignedChange() {
	document.entryForm.unassignedRole.selectedIndex = -1;
	document.entryForm.btnSel1_1.disabled = false;
	document.entryForm.btnSel1_1.value = "<<<";
}

function selectTransfer(btnObj, selObj1, selObj2)
{
	var selFrom;
	var selTo;
	var curOpt;

	if (btnObj.value == ">>>") {
		selTo = selObj1;
	} else {
		selTo = selObj2;
	}
	if (document.entryForm.unassignedRole.selectedIndex >= 0)
		selFrom = document.entryForm.unassignedRole;
	else if (document.entryForm.assignedRole.selectedIndex >= 0)
		selFrom = document.entryForm.assignedRole;

	curOpt = selFrom.options[selFrom.selectedIndex];
	selTo.options[selTo.length] = new Option(curOpt.text, curOpt.value, false, true);
	selFrom.options[selFrom.selectedIndex] = null;

	if (selTo == document.entryForm.unassignedRole)
		handleUnassignedChange();
	else if (selTo == document.entryForm.assignedRole)
		handleAssignedChange();
}

function preSubmit()
{
	var i;
	var tmpStr = "";
	var opt = "";

	for (i=0; i< document.entryForm.unassignedRole.length; i++)
	{
		opt = document.entryForm.unassignedRole.options[i].value;
		if (opt.substring(0,3) == "al-")
			tmpStr = tmpStr + opt.substring(3) + ";";
	}
	document.entryForm.inpUnassigned.value = tmpStr;

	tmpStr = "";
	for (i=0; i< document.entryForm.assignedRole.length; i++)
	{
		opt = document.entryForm.assignedRole.options[i].value;
		if (opt.substring(0,3) == "ul-")
		tmpStr = tmpStr + opt.substring(3) + ";";
	}
	document.entryForm.inpAssigned.value = tmpStr;
	return false;
}
</script>


<%@ include file="/includes/header.jsp" %>

Use the diagram to the left to add and delete territories and to assign users to territories
<br>

<%
  String ENTITY = "Role";
  boolean roleChanged = false;

  String action = (request.getParameter("action") != null ? request.getParameter("action") :  "none" );
  String selectedRoleId = request.getParameter("roleId");

  if (request.getParameter("newButton.x")!=null)
	action = UIScreenSection.ACTION_SHOW_INSERT;
  else if (request.getParameter("editButton.x")!=null)
	action = UIScreenSection.ACTION_SHOW_UPDATE;
  else if (request.getParameter("deleteButton.x")!=null)
	action = "confirmDelete";


  String userAction = request.getParameter("useraction");

  if ( (userAction != null) && (userAction.equals(UIScreenSection.ACTION_INSERT) ))
  {
		boolean result = contactEventProcessor.QuickInsert( userInfo, delegator,
				request.getParameter("firstName"),
				request.getParameter("lastName"),
				request.getParameter("login"),
				request.getParameter("password") );

		if ( result )
			out.write("<font color=ff0000>User Created</font><p>");
		else
			out.write("<font color=ff0000>Error creating user please contact your system administrator</font><p>");
  }

  GenericValue selectedRole = null;

  if ( (selectedRoleId != null)&& !selectedRoleId.equals("") )
  {
        ModelEntity roleEntity = delegator.getModelEntity("Role");
        HashMap hashMap = new HashMap();
        hashMap.put("roleId", selectedRoleId);
        GenericPK genericPk = new GenericPK(roleEntity, hashMap);
        selectedRole = delegator.findByPrimaryKey(genericPk);
  }

  if ( action.equals(UIScreenSection.ACTION_SHOW_INSERT) || action.equals(UIScreenSection.ACTION_SHOW_UPDATE) )
  {
	if ( selectedRole == null )
		out.write("Error:  you must select an existing territory first.  No territory specified");
	else
	{
		String roleName = "";
		String assignedTo = "";
		String title = "New territory under " + selectedRole.getString("roleName");
		String nextAction = UIScreenSection.ACTION_INSERT;
		List assignedContacts = null;
		List unassignedContacts = null;

		HashMap contactFields = new HashMap();
		contactFields.put("roleId", null);
		contactFields.put("accountId", userInfo.getAccountId());

		unassignedContacts = delegator.findByAnd("Contact", contactFields, null);

		if ( action.equals(UIScreenSection.ACTION_SHOW_UPDATE) )
		{
			roleName = selectedRole.getString("roleName");
			title = "Edit " + roleName;
			nextAction = UIScreenSection.ACTION_UPDATE;

			contactFields = new HashMap();
			contactFields.put("roleId", selectedRoleId);
			contactFields.put("accountId", userInfo.getAccountId());
			assignedContacts = delegator.findByAnd("Contact", contactFields, null);
		}

%>
<hr>
	<FORM NAME=entryForm METHOD=post onSubmit="preSubmit()" ACTION=territoryEdit TARGET=contentFrame>
	    <INPUT TYPE=hidden NAME=roleId value=<%=selectedRoleId%>>
	    <INPUT TYPE=hidden NAME=action value=<%=nextAction%>>
        <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>Territory Name</TD><TD><INPUT TYPE=TEXT NAME=roleName SIZE=30 CLASS=freeFormSectionInputBox MAXLENGTH=60 VALUE='<%=roleName%>'></TD></TR>
	      <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=freeFormSectionDisplayTable name=unassignedRole id=unassignedRole size=10 onChange="handleUnassignedChange()">
<%
		if ( unassignedContacts != null )
		{
			Iterator i = unassignedContacts.iterator();
			try{
				while(i.hasNext()){
					GenericValue genericValue = (GenericValue)i.next();
					/* prefix ul- signifies orignial unassigned entry, in order to tell which entries have been changed */
					out.write("<option value=ul-" + genericValue.getString("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.assignedRole,document.entryForm.unassignedRole)"></td>
		<td><select style="width: 100%" name=assignedRole id=assignedRole 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 CLASS=button value=save></TD></TR>
	    </TABLE>

	 </FORM>

<%
    }

%>
<hr>
Use the following form to add new users.  You can edit them and enter additional details in the contact screen
for your company.
<br><br>

<FORM NAME=userForm METHOD=post ACTION=territoryEdit TARGET=contentFrame>
    <INPUT TYPE=hidden NAME=roleId value=<%=selectedRoleId%>>
    <INPUT TYPE=hidden NAME=useraction value=<%=UIScreenSection.ACTION_INSERT%>>
    <INPUT TYPE=hidden NAME=action value=<%=action%>>
    <INPUT TYPE=hidden NAME=rowCount value=1>

    <TABLE WIDTH=100% CLASS=freeFormSectionTitleTable>
      <TR><TD>Quick Create New User</TD></TR>
    </TABLE>

    <TABLE WIDTH=100% CLASS=freeFormSectionDisplayTable>
      <TR><TD>First Name</TD><TD><INPUT TYPE=TEXT NAME=firstName SIZE=30 CLASS=freeFormSectionInputBox MAXLENGTH=60></TD></TR>
      <TR><TD>Last Name</TD><TD><INPUT TYPE=TEXT NAME=lastName SIZE=30 CLASS=freeFormSectionInputBox MAXLENGTH=60></TD></TR>
      <TR><TD>Login</TD><TD><INPUT TYPE=TEXT NAME=login SIZE=30 CLASS=freeFormSectionInputBox MAXLENGTH=60></TD></TR>
      <TR><TD>Password</TD><TD><INPUT TYPE=TEXT NAME=password SIZE=30 CLASS=freeFormSectionInputBox MAXLENGTH=60></TD></TR>
      <TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT CLASS=button value=save></TD></TR>
    </TABLE>

 </FORM>
<%

  }
  else if (action.equals("confirmDelete"))
  {

⌨️ 快捷键说明

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