📄 leadlistconverter.jsp
字号:
<%@ include file="/includes/header.jsp" %>
<%@ page import="com.sourcetap.sfa.lead.*" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="com.sourcetap.sfa.util.EntityHelper" %>
<%@ page import="org.ofbiz.entity.util.*" %>
<%@ page import="com.sourcetap.sfa.ui.UIDealStageDropDown" %>
<jsp:useBean id="leadEventProcessor" class="com.sourcetap.sfa.lead.LeadEventProcessor" scope="application" />
<LINK rel="stylesheet" type="text/css" href="/sfa/css/report.css">
<script>
var searchTargetValue = '';
var searchTargetDisplay = '';
function setAccount(str_accountId, str_accountName)
{
searchTargetValue.value = str_accountId;
searchTargetValue.disabled = false;
searchTargetValue.checked = true;
searchTargetDisplay.value = str_accountName;
// alert('searchTargetValue' + searchTargetValue.name);
}
function showAccountSearch(str_target, str_displayTarget, str_accountName) {
searchTargetValue = document.getElementById(str_target);
searchTargetDisplay = document.getElementById(str_displayTarget);
searchWindow = window.open('/sfa/control/accountSearchPopup?action=find&accountName=' + str_accountName,'accountSearchPopup','width=900,height=600,top=50,left=150,scrollbars=1,resizable=1');
}
function setContact(str_Id, str_Name)
{
searchTargetValue.value = str_Id;
searchTargetValue.disabled = false;
searchTargetValue.checked = true;
searchTargetDisplay.value = str_Name;
}
function showContactSearch(str_target, str_displayTarget, str_Name) {
searchTargetValue = document.getElementById(str_target);
searchTargetDisplay = document.getElementById(str_displayTarget);
searchWindow = window.open('/sfa/control/contactSearchPopup?action=find&lastName=' + str_Name,'contactSearchPopup','width=900,height=600,top=50,left=150,scrollbars=1,resizable=1');
}
</script>
<%
try {
String action = UtilFormatOut.checkNull(request.getParameter("action"));
String listId = request.getParameter("listId");
String opportunityName = UtilFormatOut.checkNull(request.getParameter("opportunityName"));
String opportunityStageId = UtilFormatOut.checkNull(request.getParameter("opportunityStageId"));
boolean createContactFlag =true;
boolean createOpportunityFlag = false;
if ( !action.equals("start") && (request.getParameter("createContactFlag") == null ))
createContactFlag = false;
if ( !action.equals("start") && (request.getParameter("createOpportunityFlag") == null ))
createOpportunityFlag = false;
if ( action.equals("deleteList") )
{
action = "start";
delegator.removeByAnd("UiListItem", UtilMisc.toMap("listId", listId));
delegator.removeByAnd("UiList", UtilMisc.toMap("listId", listId));
}
else if ( action.equals("viewList") )
{
DynamicViewEntity dve = EntityHelper.createDynamicViewEntity( delegator, "Lead");
dve.addMemberEntity("UiListItem", "UiListItem");
dve.addViewLink("Lead", "UiListItem", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("leadId", "entityId")));
dve.addAlias("UiListItem", "listItemId", null, null, null, null, null);
dve.addAlias("UiListItem", "entityName", null, null, null, null, null);
dve.addAlias("UiListItem", "listId", null, null, null, null, null);
dve.addAlias("UiListItem", "status", null, null, null, null, null);
EntityCondition condition = new EntityConditionList(UtilMisc.toList(
new EntityExpr("listId", EntityOperator.EQUALS, listId),
new EntityExpr("entityName", EntityOperator.EQUALS, "Lead")),
EntityOperator.AND);
EntityListIterator eli = EntityHelper.findIteratorByCondition( delegator, dve, condition, null, UtilMisc.toList("lastName", "firstName"));
GenericValue leadGV = null;
%>
<TABLE class=its>
<THEAD><TR><TD>Status</TD><TD>Name</TD><TD>Linked Account</TD><TD>Linked Contact</TD></TR></THEAD><TBODY>
<%
int row=0;
while ( (leadGV = (GenericValue) eli.next() ) != null )
{
row++;
String rowClass = (( row % 2 ) == 0 ) ? "even" : "odd";
String name = UtilFormatOut.checkNull(leadGV.getString("firstName")) + " " + UtilFormatOut.checkNull(leadGV.getString("lastName"));
String linkedAccount = UtilFormatOut.checkNull(leadGV.getString("convertedAccountId"));
String linkedContact = UtilFormatOut.checkNull(leadGV.getString("convertedContactId"));
out.write("<TR class=" + rowClass + "><TD>" + leadGV.getString("status") + "</TD><TD>" + name + "</TD><TD>" + linkedAccount + "</TD><TD>" + linkedContact + "</TD></TR>\n");
}
eli.close();
%>
</TBODY></TABLE>
<%
}
if ( action.equals("checkOptions") )
{
if ( request.getParameter("findMatchingAccounts") == null )
action = "convertLeads";
else
action = "mapAccounts";
}
if ( action.equals("setAccountMapping") )
{
//find all parameters of the form lead2Account_<<listItemId>>
Enumeration params = request.getParameterNames();
while (params.hasMoreElements()) {
String paramName = (String) params.nextElement();
if ( paramName.startsWith("lead2Account_") )
{
String listItemId = paramName.substring(13);
String accountId = request.getParameter(paramName);
String contactId = request.getParameter("lead2Contact_" + listItemId);
GenericValue liGV = delegator.findByPrimaryKey("UiListItem", UtilMisc.toMap("listItemId", listItemId));
liGV.set("status", "accountMapped");
liGV.store();
if ( ( ( accountId != null ) && ( accountId.length() > 0) ) ||
( ( contactId != null ) && ( contactId.length() > 0) )
)
{
String leadId = liGV.getString("entityId");
GenericValue leadGV = delegator.findByPrimaryKey("Lead", UtilMisc.toMap("leadId", leadId));
leadGV.set("convertedAccountId", accountId);
leadGV.set("convertedContactId", contactId);
leadGV.store();
}
}
}
action = "mapAccounts";
}
if ( action.equals("start") )
{
EntityCondition condition = new EntityConditionList( UtilMisc.toList( new EntityExpr("partyId", EntityOperator.EQUALS, userInfo.getPartyId()),
new EntityExpr("partyId", EntityOperator.EQUALS, userInfo.getAccountId())), EntityOperator.OR );
condition = new EntityConditionList( UtilMisc.toList( condition, new EntityExpr("listType", EntityOperator.EQUALS, "Lead") ), EntityOperator.AND );
List leadLists = delegator.findByCondition( "UiList", condition, null, UtilMisc.toList("listName") );
if ( (leadLists == null ) || (leadLists.size() < 1 ))
{
%>
<br><br>Before You can use the mass convert option, you need to create a list of leads to convert.
<BR>This can be done from the Lead Query screens by setting the Save List As Option or during List import by specifying a list name.
%>
<% }
else
{
%>
<BR>Choose a List to convert<BR>
<TABLE class=its>
<THEAD><TR><TD>List Name</TD><TD>Action</TD></TR></THEAD><TBODY>
<%
Iterator iter = leadLists.iterator();
int i = 0;
while ( iter.hasNext() )
{
i++;
String rowClass = (( i % 2 ) == 0 ) ? "even" : "odd";
String checked = ( i==1) ? " checked " : "";
GenericValue listGV = (GenericValue) iter.next();
out.write("<TR class=" + rowClass + "><TD><a href=leadListConverter?action=getOptions&listId=" + listGV.getString("listId") + ">" + listGV.getString("listName") +"</a>" +
"</TD><TD><a href=leadListConverter?action=deleteList&listId=" + listGV.getString("listId") + ">Del</a> " +
"<a href=leadListConverter?action=viewList&listId=" + listGV.getString("listId") + ">View</a> " +
"</TD></TR>\n");
}
%>
</TBODY>
</TABLE>
<BR>
<%
}
}
else if ( action.equals("getOptions") )
{
List opportunityStages = UIDealStageDropDown.getDefaultSalesProcessStages(delegator, userInfo);
%>
<BR>
<BR><CENTER><B>Choose Setting for Lead Conversion</B></CENTER>
<BR><BR>Note: Unless you are sure that none of the Leads are already in the system as Accounts and Contacts, you should choose the "Find Matching Accounts" option to review
the data prior to conversion.
<BR><BR>
<FORM action=/sfa/control/leadListConverter>
<input type=hidden name=action value="checkOptions">
<input type=hidden name=listId value=<%=listId%>>
<TABLE class=freeFormSectionDisplayTable width=500>
<TR><TD class=freeFormSectionLabelOptional>Find Matching Accountst:</TD><TD class=freeFormSectionField><input type=checkbox name=findMatchingAccounts CHECKED></TD></TR>
<TR><TD class=freeFormSectionLabelOptional>Create Contact:</TD><TD class=freeFormSectionField><input type=checkbox name=createContactFlag CHECKED></TD></TR>
<TR><TD class=freeFormSectionLabelOptional>Create Opportunity:</TD><TD class=freeFormSectionField><input type=checkbox name=createOpportunityFlag></TD></TR>
<TR><TD class=freeFormSectionLabelOptional>Opportunity Name:</TD><TD class=freeFormSectionField><input type=text name=opportunityName value="<%=opportunityName%>"></TD></TR>
<TR><TD class=freeFormSectionLabelOptional>Opportunity Stage:</TD><TD class=freeFormSectionField>
<SELECT NAME="opportunityStageId" CLASS="selectBox">
<%
if ( opportunityStages != null )
{
for ( int i=0; i < opportunityStages.size(); i++ )
{
String checked = "";
GenericValue stageGV = (GenericValue) opportunityStages.get(i);
String stageId = stageGV.getString("stageId");
String stageName = stageGV.getString("stageName");
if ( opportunityStageId.length() < 1 )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -