#This is for the scc contact linkage
#called from IGAT_customer_entry_view.html. Closes window and returns the chosen customer number
forum message sccReturn {
set info [lindex $margs 1]
#set recipient element to _blank because we hardcoded it on the other page
begin_response -buffered text/html normal
forum_exec task storeUserSelection $info crm
}
#Provides values for the custom replies
forum on_tx_init {
global fc_functionMap
set fc_functionMap(Docshare.getCustomerData) fc.Docshare_getCustomerData
set fc_functionMap(Docshare.getCountryList) fc.Docshare_getCountryList
set fc_functionMap(Docshare.getCodeValues) fc.Docshare_getCodeValues
set fc_functionMap(Docshare.getReplyData) fc.Docshare_getReplyData
}
#Get the list of countries for custom replies
forum proc fc.Docshare_getCountryList {entryId args} {
return {{Canada - CA} {United States - US} {Afghanistan - AF} {Albania - AL} {Algeria - DZ} {American Samoa - AS}
{Andorra - AD} {Angola - AO} {Anguilla - AI} {Antartica - AQ} {Antigua and Barbuda - AG} {Argentina - AR}
{Armenia - AM} {Aruba - AW} {Australia - AU} {Austria - AT} {Azerbaijan - AZ} {Bahamas - BS} {Bahrain - BH}
{Bangladesh - BD} {Barbados - BB} {Belarus - BY} {Belgium - BE} {Belize - BZ} {Benin - BJ} {Bermuda - BM}
{Bhutan - BT} {Bolivia - BO} {Bosnia and Herzegovina - BA} {Bouvet Island - BV} {Brazil - BR}
{British Indian Ocean Territory - IO} {Brunei Darussalam - BN} {Bulgaria - BG} {Burkina Faso - BF}
{Burundi - BI} {Cambodia - KH} {Cameroon - CM} {Cape Verde - CV} {Cayman Islands - KY}
{Central African Republic - CF} {Chad - TD} {Chile - CL} {China - CN} {Christmas Island - CX}
{Cocos (Keeling) Islands - CC} {Colombia - CO} {Comoros - KM} {Congo - CG}
{Congo, The Democratic Republic of the - CD} {Cook Islands - CK} {Costa Rica - CR} {Côte D'Ivoire - CI}
{Croatia - HR} {Cuba - CU} {Cyprus - CY} {Czech Republic - CZ} {Denmark - DK} {Djibouti - DJ} {Dominica - DM}
{Dominican Republic - DO} {East Timor - TP} {Ecuador - EC} {Egypt - EG} {El Salvador - SV}
{Equatorial Guinea - GQ} {Eritrea - ER} {Estonia - EE} {Ethiopia - ET} {Falkland Islands (Malvinas) - FK}
{Faroe Islands - FO} {Fiji - FJ} {Finland - FI} {France - FR} {French Guiana - GF} {French Polynesia - PF}
{French Southern Territories - TF} {Gabon - GA} {Gambia - GM} {Georgia - GE} {Germany - DE} {Ghana - GH}
{Gibraltar - GI} {Greece - GR} {Greenland - GL} {Grenada - GD} {Guadeloupe - GP} {Guam - GU} {Guatemala - GT}
{Guinea - GN} {Guinea-Bissau - GW} {Guyana - GY} {Haiti - HT} {Heard Island and Mcdonald Islands - HM}
{Holy See (Vatican City State) - VA} {Honduras - HN} {Hong Kong - HK} {Hungary - HU} {Iceland - IS}
{India - IN} {Indonesia - ID} {Iran, Islamic Republic of - IR} {Iraq - IQ} {Ireland - IE} {Israel - IL}
{Italy - IT} {Jamaica - JM} {Japan - JP} {Jordan - JO} {Kazakstan - KZ} {Kenya - KE} {Kiribati - KI}
{Korea, Democratic People's Republic of - KP} {Korea, Republic of - KR} {Kuwait - KW} {Kyrgyzstan - KG}
{Lao People's Democratic Republic - LA} {Latvia - LV} {Lebanon - LB} {Lesotho - LS} {Liberia - LR}
{Libyan Arab Jamahiriya - LY} {Liechtenstein - LI} {Lithuania - LT} {Luxembourg - LU} {Macau - MO}
{Macedonia, The Former Yugoslav Republic of - MK} {Madagascar - MG} {Malawi - MW} {Malaysia - MY}
{Maldives - MV} {Mali - ML} {Malta - MT} {Marshall Islands - MH} {Martinique - MQ} {Mauritania - MR}
{Mauritius - MU} {Mayotte - YT} {Mexico - MX} {Micronesia, Federated States of - FM}
{Moldova, Republic of - MD} {Monaco - MC} {Mongolia - MN} {Montserrat - MS} {Morocco - MA} {Mozambique - MZ}
{Myanmar - MM} {Namibia - NA} {Nauru - NR} {Nepal - NP} {Netherlands - NL} {Netherlands Antilles - AN}
{New Caledonia - NC} {New Zealand - NZ} {Nicaragua - NI} {Niger - NE} {Nigeria - NG} {Niue - NU}
{Norfolk Island - NF} {Northern Mariana Islands - MP} {Norway - NO} {Oman - OM} {Pakistan - PK} {Palau - PW}
{Panama - PA} {Papua New Guinea - PG} {Paraguay - PY} {Peru - PE} {Philippines - PH} {Pitcairn - PN}
{Poland - PL} {Portugal - PT} {Puerto Rico - PR} {Qatar - QA} {Réunion - RE} {Romania - RO}
{Russian Federation - RU} {Rwanda - RW} {Saint Helena - SH} {Saint Kitts and Nevis - KN} {Saint Lucia - LC}
{Saint Pierre and Miquelon - PM} {Saint Vincent and the Grenadines - VC} {Samoa - WS} {San Marino - SM}
{Sao Tome and Principe - ST} {Saudi Arabia - SA} {Senegal - SN} {Seychelles - SC} {Sierra Leone - SL}
{Singapore - SG} {Slovakia - SK} {Slovenia - SI} {Solomon Islands - SB} {Somalia - SO} {South Africa - ZA}
{South Georgia and the South Sandwich Islands - GS} {Spain - ES} {Sri Lanka - LK} {Sudan - SD}
{Suriname - SR} {Svalbard and Jan Mayen - SJ} {Swaziland - SZ} {Sweden - SE} {Switzerland - CH}
{Syrian Arab Republic - SY} {Taiwan, Province of China - TW} {Tajikistan - TJ} {Tanzania, United Republic of - TZ}
{Thailand - TH} {Togo - TG} {Tokelau - TK} {Tonga - TO} {Trinidad and Tobago - TT} {Tunisia - TN} {Turkey - TR}
{Turkmenistan - TM} {Turks and Caicos Islands - TC} {Tuvalu - TV} {Uganda - UG} {Ukraine - UA} {United Arab Emirates - AE}
{United Kingdom - GB} {United States Minor Outlying Islands - UM} {Uruguay - UY} {Uzbekistan - UZ} {Vanuatu - VU} {Venezuela - VE}
{Viet Nam - VN} {Virgin Islands, British - VG} {Virgin Islands, U.S. - VI} {Wallis and Futuna - WF} {Western Sahara - EH}
{Yemen - YE} {Yugoslavia - YU} {Zambia - ZM} {Zimbabwe - ZW}
}
}
#get the list of codes for custom replies
forum proc fc.Docshare_getCodeValues {entryId args} {
return {
{General Inf.: SCC progr. & serv.} {General Inf.: OTHER} {NO ACTION-Service no longer req'd} {Document referral to Canadian SDOs}
{Document referral to IHS Sales} {Document referral to other} {Other referral} {ISO 9000 QMS} {ISO 14000 EMS} {Cdn Eletrical Code}
{EC Directives} {National Building Code} {National Fire Code} {Inspection of BPV} {National Plumbing Code} {Canadian OHS}
{Basic : Inf. on non-Canadian stds} {Id Cdn fed regs on Prod/Ser I} {Id Cdn prov regs on Prod/Ser I} {Id Cdn standards on Prod/Ser I}
{Id Cert. for Cdn Prod/Serv I} {Id Testing Organizations (1-5)} {ISO 9k/14k Survey Rep. PDForPick up} {ISO 9k/14k S.R. + S/H 1st class}
{ISO 9k/14k S.R. + S/H Courier} {Scope Service (1-5)} {Scope Service (6+)} {Id Cdn Std/Tech. Regs-Research} {Id For. stds/tech regs - Research}
{Id other stds/tech regs - WTO fee} {WTO/NAFTA: General information} {Content of Std - Confirm/Clarify} {VISITOR}
{Rush Service (within 24 hours)} {Global Research}
}
}
#Return the custom reply information to the template
forum proc fc.Docshare_getReplyData {entryId args} {
array set customData {}
set replyId [lindex $args 0]
return [docshare.getReplyData $replyId]
}
forum proc getReplyData {docId} {
array set customData {}
array set data [forum_exec task getTeValue customReplyFields $docId]
foreach item [array names data] {
set customData(data.$item) $data($item)
}
return [array get customData]
}
#Return the customer information about associated customer entry.
#Makes a forum_eval call
forum proc fc.Docshare_getCustomerData {entryId args} {
global Wgw_CurrentACA
set docId [lindex $args 0]
if {[isnull $docId]} return ""
set cmd "set d $docId"
append cmd {
array set customData {}
docshare.getCustomData $d customData
return [array get customData]
}
array set customCommandData [forum_eval $Wgw_CurrentACA infocustomers [getUserName] $cmd]
return [array get customCommandData]
}
#Returns the customer data to call. For forum_eval above
forum proc getCustomData {docId dataArray} {
upvar $dataArray customData
if {![isnull $docId]} {
if {![entry_info exists $docId]} {return ""}
if {[isnull [DocList.validateDocList read $docId 0 ""]]} {return ""}
customEntry.getDocData $docId customData
}
}
#Display custom reply information when modifying the reply
forum overload_object stcc modDocForm {
method_inline abstractField docId formType
}
forum method modDocForm.abstractField docId formType {
if {[aval docLevel $docId] > 2 } {
#this is a reply. . . . . .
array set customerData [docshare.getReplyData $docId]
if {![isnull [array names customerData]]} {
set fields "code act_tm ctry est_cost act_cost"
#Make sure that the expected data exists
foreach d $fields {
if {![info exists customerData(data.$d)] || [isnull $customerData(data.$d)] } {
set customerData(data.$d) ""
}
}
set options [fc.Docshare_getCodeValues 1]
CFO -html "
Code
Act.-Time
Act.-Cost
"
CFO -html "
"
CFO -html "
"
CFO -html "
"
CFO -html "
"
set countries [fc.Docshare_getCountryList 1]
CFO -html "
Country referenced
"
CFO -html "
"
CFO -html "
"
CFO -html "
"
###ZI CFO -html "
Est.-Cost
"
#### CFO -html "
Act.-Cost
"
#### CFO -html "
"
#### CFO -html "
"
###ZI
CFO -html "
"
CFO -html ""
CFO -html " "
}
}
forum_exec method 1 modDocForm.abstractField $docId $formType
}
#
#Save custom reply fields when adding a reply
forum overload_object stcc addReply {
method_inline modifyAttributes newId
}
forum method addReply.modifyAttributes newId {
#Do the original method, first
forum_exec method 1 addReply.modifyAttributes $newId
forum_exec task updateReplyAttributes $newId uFields
}
# Saves custom mod fields when modifying an entry
forum overload_object stcc modDoc {
method_inline modifyAttributes docId formType
}
forum method modDoc.modifyAttributes docId formType {
#First, do any other custom mods from other custom classes
forum_exec method 1 modDoc.modifyAttributes $docId $formType
forum_exec task updateReplyAttributes $docId uFields
}
forum task updateReplyAttributes {
set docId [lindex $args 0]
upvar [lindex $args 1] uFields
if {[aval docLevel $docId] > 2} {
#this is a reply . . .
array set customReplyInfo ""
if {[info exists uFields(ssf.data.text)]} {
foreach item $uFields(ssf.data.text) {
if {[info exists uFields($item)]} {
set customReplyInfo($item) $uFields($item)
}
}
}
if {![isnull [array names customReplyInfo]]} {
forum_exec task setTeValue customReplyFields [array get customReplyInfo] $docId
}
}
}
#Rights for searching for a customer entry when linking.
forum map_right read {
contactSearch
contactSearchForm
}
#Search for customer entry in customer forum for linking.
############################################################
#message contactSearchForm
#Accepts: margs 1 - context (fol, doc, mes, crossForum, crossForumDB)
# margs 2 - folder ID (or doc id)
############################################################
forum message contactSearchForm {
#save the arguments used to call this message
forum_exec task util_saveCallArguments $margs
set context [lindex $margs 1]
set folderId [lindex $margs 2]
begin_response text/html normal
wim open r
set topFolderId [wim property get topFolderId]
array set EhallProp [util.getEhallProps]
set backgTheme ""
forum_exec task emitDialogBoxHeader "[nlt common/Search "Search"]" $backgTheme
if {![docshare.checkAclAndIdAccess $topFolderId]} {
forum_exec view acl_deny_dialog
wim close
return
}
set folderTitle [Folder.getFolderTitle $folderId]
set folderLink [forum_exec task forumTitleLink $topFolderId]
# nlt_comment title/findItemsIn1 "%1 = link to folder"
emitln "
[format [nlt title/findItemsIn1 {Search for entries in %1$s}] $folderLink]
"
set uName [getUserName]
if {![strequal $uName "anonymous"]} {
set unseenText1 "r.unseen"
set unseenText2 ""
set unseenText3 ""
} else {
set unseenText1 ""
set unseenText2 "[nlt search/noUnseenIfAnonymous1 \
"List all unseen entries"]"
set unseenText3 "[nlt search/noUnseenIfAnonymous2 \
"(You must be logged in to use this function.)"]"
}
forum_exec task initNavigationGlobals
global g_folderListFrame g_docListFrame g_docFrame
global g_dialogBoxFrame g_codeFrame g_stdBannerFrame
global g_folderButtonFrame g_docButtonFrame
defineComposeFormObj CFO
CFO button ok "contactSearch $context $folderId content,20,0"
CFO button cancel return
CFO button help "_forum_search_simple"
if {$context == "crossForumDB"} {CFO -dialogbox}
CFO -target $g_docListFrame jsframes3
#forum_exec task buildSearchForm {} {} "sort" margs
#CHANGE COMMAND NAME HERE
#
#
set commandName "cmd358063336"
#
# set commandName "cmd199703089"
#
#
CFO -html "
"
CFO -html "
First Name "
CFO -insexp {set xxx "
"}
CFO -html "
Last Name "
CFO -insexp {set xxx "
"}
CFO -html "
"
CFO -html "
Email "
CFO -insexp {set xxx "
"}
CFO -html "
Phone Numbers "
CFO -insexp {set xxx "
"}
CFO -html "
"
CFO -html "
Company "
CFO -insexp {set xxx "
"}
CFO -html "
"
CFO -para
CFO -dialogbox
CFO button btn2 "newDocForm fol 100001 cmd358063336" chain
CFO buttonText btn2 "Create New Contact"
CFO buttonBar ok cancel btn2
CFO emit
wim close
}
############################################################
#message contactSearch
#Accepts: margs 1 - context (fol doc mes crossForum crossForumDB notify )
# margs 2 - folder ID
# margs 3 - search type,limit,start (limit=max number to show. start=# to skip)
# margs 4 - from date (optional)
############################################################
forum message contactSearch {
#save the arguments used to call this message
forum_exec task util_saveCallArguments $margs "returnSkip 1"
if {![docshare.checkAclAndIdAccess [wim property get topFolderId]]} {
forum_exec view acl_deny_dialog
return
}
begin_response text/html normal
emitln [avf.htmlHead] [avf.htmlTitle [nlt search/results "Search Results"]]
try { forum_exec task emitCloseDialogBox }
emitln [avf.htmlBody]
#Overload point - modify the uFields before the search starts
Search.setup_uFields {}
defineComposeFormObj CFO
set context [lindex $margs 1]
set folderId [lindex $margs 2]
set searchType [lindex [split [lindex $margs 3] ","] 0]
set resultsLimit [lindex [split [lindex $margs 3] ","] 1]
set resultsStart [lindex [split [lindex $margs 3] ","] 2]
if {[isnull $resultsLimit]} {set resultsLimit [forum_exec task getFolderPageSize]}
if {[isnull $resultsStart]} {set resultsStart 0}
set searchDate [lindex $margs 4]
set searchText ""
set authorText ""
set keywordText ""
set timespec ""
set timeValue ""
set fromDay ""
set fromMonth ""
set fromYear ""
set toDay ""
set toMonth ""
set toYear ""
set sortedBy ""
try { set searchText $uFields(searchText) }
try { set authorText $uFields(author) }
try { set keywordText $uFields(keywords) }
try { set timespec $uFields(timespec) }
try { set timeValue $uFields(time) }
try { set fromDay $uFields(fromDay) }
try { set fromMonth $uFields(fromMonth) }
try { set fromYear $uFields(fromYear) }
try { set toDay $uFields(toDay) }
try { set toMonth $uFields(toMonth) }
try { set toYear $uFields(toYear) }
# default to sort by document number
#
#
#
set sortedBy "docNum"
#
#Get the proper date formats for the fromDate and toDate
set curDate [date_time current]
set fromDate ""
set toDate ""
if {![isnull "$fromDay$fromMonth$fromYear"]} {
if {[isnull $fromDay]} {set fromDay [date_time format $curDate "%d" local]}
if {[isnull $fromMonth]} {set fromMonth [date_time format $curDate "%m" local]}
if {[isnull $fromYear]} {set fromYear [date_time format $curDate "%Y" local]}
set fromDate "$fromMonth/$fromDay/$fromYear"
}
if {(![isnull $fromYear] && $fromYear < 1971) || \
[catch {set fromDateSeconds [clock scan $fromDate]}]} {
emitln "
"
CFO button close return
CFO button help "_forum_search_advanced"
CFO buttonBar close help
CFO emit
return
}
#---Overloadable form element---
# Get the custom qualifiers from the search form
set customQualifiers [Search.getCustomQualifiers {
return ""
}]
#---Overloadable form element---
# Get the custom search options
array set searchOptions [Search.getCustomOptions {
return {}
}]
if {[info exists searchOptions(searchRestraints)] && [strequal $searchOptions(searchRestraints) -1]} {
return
}
#See if the user is using advanced search operators
if {[info exists uFields(advQuery)] && [strequal $uFields(advQuery) "on"]} {
if {![isnull $searchText]} {
set searchOptions(useAdvancedSearchOperators) 1
}
}
set searchArgs [list $searchType $searchDate $searchText $authorText $keywordText $timespec \
$timeValue $fromDate $toDate "$resultsLimit,$resultsStart" $customQualifiers \
$sortedBy [array get searchOptions]]
#---Overloadable element---
Search.GetBasicOptions {}
wim open r
#define a special object that emits the right html depending on the user's
# preferred display options
defineSearchEmitObj Emit
Emit header
global Wgw_CurrentACA Wgw_HiddenBaseDirectory Wgw_CurrentForum
set acaPath $Wgw_HiddenBaseDirectory/$Wgw_CurrentACA/$Wgw_CurrentForum
if {[catch {
set hits [forum_exec task emitSearchResults $searchArgs $acaPath 2 optionsArray docArray]
} errorMsg]} {
set errorCode "Browser exited"
if {[strequal $errorMsg $errorCode]} {
#The browser exited, just go away quietly
wim close
return
} else {
#This was a real error, pass it along
error $errorMsg
}
}
#Display the results
set hits [Search.showSearchResults docArray]
#Did all of the results get displayed?
if {![isnull $resultsLimit] && $hits > $resultsLimit} {
set remainder [expr {$hits - $resultsLimit}]
set newStart [expr {$resultsStart + $resultsLimit}]
set messageUrl [mlink_url search $context $folderId "$searchType,$resultsLimit,$newStart" $searchDate]
if {[catch {
Emit emit ""
} errorMsg]} {
set errorCode "Browser exited"
if {[strequal $errorMsg $errorCode]} {
#The browser exited, just go away quietly
wim close
return
} else {
#This was a real error, pass it along
error $errorMsg
}
}
}
if {$hits == 0} {
Emit emit "[nlt search/nothingFound \
"Nothing was found that matched your search critiera."]"
}
wim close
defineComposeFormObj CFO
CFO button cancel return
CFO button btn1 "contactSearchForm full searchForm fol 100001 multiple" chain
CFO buttonText btn1 "Search Again"
CFO button btn2 "newDocForm fol 100001 cmd358063336" chain
CFO buttonText btn2 "Create New Contact"
CFO -dialogbox
CFO buttonBar btn1 btn2 ok cancel
CFO emit
# display the standard "close|hall|help" navigation line (if any)
#Emit stdNav $folderId $context
showDebugInfo
}
############################################################
#message search
#Accepts: margs 1 - context (fol doc mes crossForum crossForumDB notify )
# margs 2 - folder ID
# margs 3 - search type,limit,start (limit=max number to show. start=# to skip)
# margs 4 - from date (optional)
############################################################
forum message contactSearch {
#save the arguments used to call this message
forum_exec task util_saveCallArguments $margs "returnSkip 1"
begin_response text/html normal
emitln [avf.htmlHead] [avf.htmlTitle [nlt search/results "Search Results"]]
try { forum_exec task emitCloseDialogBox }
emitln [avf.htmlBody]
defineComposeFormObj CFO
set context [lindex $margs 1]
set folderId [lindex $margs 2]
set searchType [lindex [split [lindex $margs 3] ","] 0]
set resultsLimit [lindex [split [lindex $margs 3] ","] 1]
set resultsStart [lindex [split [lindex $margs 3] ","] 2]
if {[isnull $resultsLimit]} {set resultsLimit [forum_exec task getFolderPageSize]}
if {[isnull $resultsStart]} {set resultsStart 0}
set searchDate [lindex $margs 4]
set searchText ""
set authorText ""
set keywordText ""
set timespec ""
set timeValue ""
set fromDay ""
set fromMonth ""
set fromYear ""
set toDay ""
set toMonth ""
set toYear ""
set sortedBy ""
try { set searchText $uFields(searchText) }
try { set authorText $uFields(author) }
try { set keywordText $uFields(keywords) }
try { set timespec $uFields(timespec) }
try { set timeValue $uFields(time) }
try { set fromDay $uFields(fromDay) }
try { set fromMonth $uFields(fromMonth) }
try { set fromYear $uFields(fromYear) }
try { set toDay $uFields(toDay) }
try { set toMonth $uFields(toMonth) }
try { set toYear $uFields(toYear) }
# default to sort by document number
#
#
#
set sortedBy "docNum"
#
#Get the proper date formats for the fromDate and toDate
set curDate [date_time current]
set fromDate ""
set toDate ""
if {![isnull "$fromDay$fromMonth$fromYear"]} {
if {[isnull $fromDay]} {set fromDay [date_time format $curDate "%d" local]}
if {[isnull $fromMonth]} {set fromMonth [date_time format $curDate "%m" local]}
if {[isnull $fromYear]} {set fromYear [date_time format $curDate "%Y" local]}
set fromDate "$fromMonth/$fromDay/$fromYear"
}
if {(![isnull $fromYear] && $fromYear < 1971) || \
[catch {set fromDateSeconds [clock scan $fromDate]}]} {
emitln "
"
CFO button close return
CFO button help "_forum_search_advanced"
CFO buttonBar close help
CFO emit
return
}
#---Overloadable form element---
# Get the custom qualifiers from the search form
set customQualifiers [Search.getCustomQualifiers {
return ""
}]
#See if the user is using advanced search operators
if {[info exists uFields(advQuery)] && [strequal $uFields(advQuery) "on"]} {
if {![isnull $searchText]} {
set searchOptions(useAdvancedSearchOperators) 1
}
}
set searchArgs [list $searchType $searchDate $searchText $authorText $keywordText $timespec \
$timeValue $fromDate $toDate "$resultsLimit,$resultsStart" $customQualifiers \
$sortedBy [array get searchOptions]]
#---Overloadable element---
Search.GetBasicOptions {}
wim open r
if {![docshare.checkAclAndIdAccess [wim property get topFolderId]]} {
forum_exec view acl_deny_dialog
wim close
return
}
#define a special object that emits the right html depending on the user's
# preferred display options
defineSearchEmitObj Emit
Emit header
global Wgw_CurrentACA Wgw_HiddenBaseDirectory Wgw_CurrentForum
set acaPath $Wgw_HiddenBaseDirectory/$Wgw_CurrentACA/$Wgw_CurrentForum
set hits [forum_exec task emitSearchResults $searchArgs $acaPath]
#Did all of the results get displayed?
if {![isnull $resultsLimit] && $hits > $resultsLimit} {
set remainder [expr {$hits - $resultsLimit}]
set newStart [expr {$resultsStart + $resultsLimit}]
set messageUrl [mlink_url search $context $folderId "$searchType,$resultsLimit,$newStart" $searchDate]
Emit emit ""
}
if {$hits == 0} {
Emit emit "[nlt search/nothingFound \
"Nothing was found that matched your search critiera."]"
}
wim close
#CUSTOM
defineComposeFormObj CFO
CFO button cancel return
CFO button btn1 "contactSearchForm full searchForm fol 100001 multiple" chain
CFO buttonText btn1 "Search Again"
CFO button btn2 "newDocForm fol 100001 cmd358063336" chain
CFO buttonText btn2 "Create New Contact"
CFO -dialogbox
CFO buttonBar btn1 btn2 ok cancel
CFO emit
#CUSTOM
# display the standard "close|hall|help" navigation line (if any)
#Emit stdNav $folderId $context
showDebugInfo
}
#Save customer information when adding an entry
forum overload_object stcc_customer addDoc {
method_inline modifyAttributes newId
}
forum method addDoc.modifyAttributes docId {
#First, do any other custom mods from other custom classes
forum_exec method 1 addDoc.modifyAttributes $docId
if {[info exists uFields(crm)]} {
if {![isnull $uFields(crm)]} {
array set customInfo [fc.Docshare_getCustomerData {} $uFields(crm)]
} else {
#it has either been set to blank, or never set in the first place. Null em out.
array set customInfo {data.firstName "" data.lastName "" data.phone "" data.company "" data.email ""}
}
#Don't commit any changes until the end of this loop
forum_exec task startKeyValueNoCommit
foreach item {firstName lastName phone email company} {
forum_exec task setTeValue $item $customInfo(data.$item) $docId
}
#Ok, commit all key value changes
forum_exec task endKeyValueNoCommit
}
#Check to see if there are any workflow transitions to be done
try {set workflowInUse [workflow.workflowInUse]} else {set workflowInUse 0}
if {$workflowInUse} {
try {workflow.doDocIdWorkflowTransitions $docId}
}
forum_exec task moveState $docId uFields
}
#Save customer information when modifying an entry
forum overload_object stcc_customer modDoc {
method_inline modifyAttributes docId formType
}
forum method modDoc.modifyAttributes docId formType {
#First, do any other custom mods from other custom classes
forum_exec method 1 modDoc.modifyAttributes $docId $formType
if {[info exists uFields(crm)]} {
if {![isnull $uFields(crm)]} {
array set customInfo [fc.Docshare_getCustomerData {} $uFields(crm)]
#Don't commit any changes until the end of this loop
forum_exec task startKeyValueNoCommit
foreach item {firstName lastName phone email company} {
forum_exec task setTeValue $item $customInfo(data.$item) $docId
}
#Ok, commit all key value changes
forum_exec task endKeyValueNoCommit
}
}
forum_exec task moveState $docId uFields
}
#if the entry is assigned to someone, move the state to assigned
forum task moveState {
set docId [lindex $args 0]
upvar [lindex $args 1] uFields
#######################################################################################
#CUSTOMIZABLE
set forumName "enq2004"
#set forumName "link"
set stateToMoveTo "Assigned"
set stateToMoveFrom "New Enquiry"
#/CUSTOMIZABLE
#######################################################################################
global Wgw_CurrentForum
if {[strequal $Wgw_CurrentForum $forumName]} {
if {[info exists uFields(assignedto)] && ![isnull $uFields(assignedto)]} {
if {[::profile::entry_exists -type user -case $uFields(assignedto)]} {
workflow.updateWorkflow $docId $uFields(assignedto) $stateToMoveTo $stateToMoveFrom
}
}
}
}
forum proc workflow.updateWorkflow {docId date stateToMoveTo stateToMoveFrom} {
#set up the workflow data structures
global cwf_workflow
workflow.setupWorkflowData
if {[workflow.getDocWorkflowState $docId wfp state]} {
regsub -all {[^a-zA-Z0-9\+]} $state {+} state1
regsub -all {[^a-zA-Z0-9\+]} $stateToMoveFrom {+} stateToMoveFrom
if {[lsearch $stateToMoveFrom $state1] >=0 } {
#state is in a delinquent state, move to open
workflow.setWorkflowState $wfp $stateToMoveTo $docId
}
}
}
#overloading the method that is called whenever a state is changed
forum overload_object stcc2 workflow {
method auditStateChange type args
}
#When a workflow is changed to accepted, it makes the assignee the owner of the entry
#this method is called twice, right before and right after a state change
forum method workflow.auditStateChange docId type wfp state {
global Wgw_CurrentForum
#######################################################################################
#CUSTOMIZABLE
set forumName "enq2004"
#set forumName "link"
set stateToMoveTo "Accepted"
#/CUSTOMIZABLE
#######################################################################################
global cwf_workflow
workflow.setupWorkflowData
#this is so that we don't store a record twice, only call after a state change
if {[strequal $type "enter"] && [strequal $state $stateToMoveTo] && [strequal $Wgw_CurrentForum $forumName]} {
set currentAssignee [forum_exec task getTeValue assignedto $docId]
if {![isnull $currentAssignee] && [::profile::entry_exists -type user $currentAssignee]} {
set newMods(createdBy) $currentAssignee
set newMods(logo) [forum_exec task getLogo $currentAssignee]
modify_entry newMods $docId
}
}
forum_exec method 1 workflow.auditStateChange $docId $type $wfp $state
}
forum proc workflow.updateWorkflow {docId date stateToMoveTo stateToMoveFrom} {
#set up the workflow data structures
global cwf_workflow
workflow.setupWorkflowData
if {[workflow.getDocWorkflowState $docId wfp state]} {
regsub -all {[^a-zA-Z0-9\+]} $state {+} state1
regsub -all {[^a-zA-Z0-9\+]} $stateToMoveFrom {+} stateToMoveFrom
if {[lsearch $stateToMoveFrom $state1] >=0 } {
#state is in a delinquent state, move to open
workflow.setWorkflowState $wfp $stateToMoveTo $docId
}
}
}
#parse the incoming emails fields for new entries
forum overload_object contact addDoc {
method modifyPostAttributes newId
}
forum method addDoc.modifyPostAttributes newId {
#Do the original method, first
forum_exec method 1 addDoc.modifyPostAttributes $newId
global Wgw_CurrentForum
set eEnquiryForum "enq2004"
#set eEnquiryForum "link"
#Is this an e-mail posting?
if {![isnull [forum_exec task getKeyValue fmEmail $newId]] && [strequal $Wgw_CurrentForum $eEnquiryForum]} {
#See if this entry used the pre-defined mail format
sam.parseAbstractEnq $newId
}
}
#this sets the email field names to the corresponding te_value field names
forum proc sam.adjustFields {line te_values} {
upvar $te_values value_array
set spl [split $line :]
set name [string tolower [lindex $spl 0]]
set value [string trim [lindex $spl 1]]
switch $name {
"first name" { set value_array(firstName) $value}
"last name" { set value_array(lastName) $value}
telephone { set value_array(phone) $value}
pre { set value_array(salutation) $value }
"postal code" { set value_array(postalcode) $value }
country { set value_array(ctry) $value }
company -
city -
address -
province -
fax -
message -
email {set value_array($name) $value}
{} -
default {}
}
}
#Special code to parse the abstract file that came in as the body of the e-mail posting
forum proc sam.parseAbstractEnq {docId} {
set abstract [read_abstract $docId]
set buffer ""
set foundStart 0
array set te_values {}
set abstractText ""
foreach line [split $abstract "\n"] {
regsub -all "\r" $line "" line
set line [string trim $line]
#Go through until we find the start of the text
if {!$foundStart && [string match "*:*" $line]} {
set foundStart 1
}
if {!$foundStart} {continue}
#We're keeping a buffer here, because its possible it will
#go to the next line
if {![isnull $line]} {
if {[string match "*:*" $line]} {
#good, we found a :, do the previous line
sam.adjustFields $buffer te_values
#load up the buffer
set buffer $line
} else {
#not the next line, keep the buffer going
append buffer $line
continue
}
}
}
#Pickup the last one
if {![isnull $buffer]} {
sam.adjustFields $buffer te_values
}
#error [array get te_values]
set title ""
if {[info exists te_values(message)]} {
set title $te_values(message)
unset te_values(message)
}
#remove the abstract if we got values from the parsing
if {![isnull [array get te_values]]} {
update_abstract "" $docId
}
set te_values(recvia) "Web contact form"
#Don't commit any changes until the end of this loop
forum_exec task startKeyValueNoCommit
#Ok, the parsing is done; now store the results
foreach name [array names te_values] {
forum_exec task setTeValue $name $te_values($name) $docId
}
#Ok, commit all key value changes
forum_exec task endKeyValueNoCommit
if {![isnull $title]} {
set newMods(title) $title
modify_entry newMods $docId
}
}