Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function SW_AgreementInForce(varAccountID,varAgreementID)
- varTodaysDate = Date
- varTodaysDate = ReturnDateDDMMMYYYY(varTodaysDate)
- varAgrID = 0
- varSelect = "SELECT ID FROM dbo.Rent_Agreements WITH (NOLOCK) WHERE Account_Reference_TG_VC = '" & varAccountID & "' AND Seq_No_TG_IN = " & varAgreementID & " AND SubAccount_TG_VC IS NULL AND Status = 'L' AND (StartDate <= '" & varTodaysDate & "' AND (EndDate > '" & varTodaysDate & "' OR EndDate IS NULL))"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varAgrID = .Fields("ID").Value
- .MoveNext
- Loop
- End With
- SW_AgreementInForce = varAgrID
- End Function
- Function SW_SO_Update_Workfile(varID, varAssetID, varAgrID, varCurBal, varPrevBal, varCurRent, varLastActionBy, varLastActionDated, varLastActionTime, varLastAction, varCurMonLevel, varS0Comp, varS1Comp, varS2Comp, varDDComp, varReportID, varDD, varGroupID)
- varInsert = "INSERT INTO dbo.usr_SW_Debt_Management_SO_Workfile_T (AccountID,AssetID,AgreementID,CurrentExpBalance, PrevExpBalance, CurrentRent, LastActionBy, LastActionDated, LastActionTime, LastAction, CurrentMonLevel, Stage0Completed, Stage1Completed, Stage2Completed, StageDDCompleted, ReportID, DD, ContactGroupID) VALUES('" & varID & "'," & varAssetID & "," & varAgrID & "," & varCurBal & "," & varPrevBal & "," & varCurRent & ",'" & varLastActionBy & "','" & varLastActionDated & "','" & varLastActionTime & "','" & varLastAction & "','" & varCurMonLevel & "'," & varS0Comp & "," & varS1Comp & "," & varS2Comp & "," & varDDComp & ",'" & vaRReportID & "'," & varDD & "," & varGroupID & ")"
- ' MSGBOX varInsert
- With SQLConnection.Execute(varInsert)
- End With
- End Function
- Function CreateDesktopUser(ContactID,UserName,ParentID)
- varInsert = "INSERT INTO dbo.Shared_Users_T (Contact_ID,User_Level_ID,Username_VC,Password_Changed_DT,Force_Password_Change_BT,On_Hold_BT,Restrict_Monday_BT,Restrict_Tuesday_BT,Restrict_Wednesday_BT,Restrict_Thursday_BT,Restrict_Friday_BT,Restrict_Saturday_BT,Restrict_Sunday_BT) VALUES(" & ContactID & ",43,'" & Username & "'," & DATE & ",0,0,0,0,0,0,0,0,0)"
- With SQLConnection.Execute(varInsert)
- End With
- varSelect = "SELECT User_ID From Shared_Users_T WHERE Contact_ID = '" & ContactID & "'"
- With SQLConnection.Execute(varSelect)
- If (Not .EOF) And (Not .BOF) Then
- UserID = .Fields("User_ID").Value
- End If
- End With
- varInsert = "INSERT INTO dbo.Shared_Organisation_Hierarchy_T (User_ID,Default_Assignment_BT,Allow_Task_Assignment_BT,Allow_Task_Escalation_BT,Parent_ID) VALUES(" & UserID & ",1,1,1," & ParentID & ")"
- With SQLConnection.Execute(varInsert)
- End With
- varInsert = "INSERT INTO dbo.Shared_User_Roles_T (User_ID,Role_ID) VALUES(" & UserID & ",113)"
- With SQLConnection.Execute(varInsert)
- End With
- End Function
- Function UpdateUserContact(ContactID,JobTitle,CompanyName,Department)
- varUpdate = "UPDATE dbo.Contact_Contacts_T SET Job_Title_VC = '" & JobTitle & "', Company_Name_VC = '" & CompanyName & "', Department_VC = '" & Department & "' WHERE Contact_ID = " & ContactID
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- '*** Start *** CRM Snapshot ***
- Function BuildCRMInitial
- BuildCRMInitial = GetHTMLFile("\\srv-fls-01\data\Snapshot\CRMInitialSnapshot.txt")
- End Function
- Function SW_FTA_VerifyCompletionReason(varValid,varReason)
- varSelect = "SELECT CASE WHEN " & varReason & " IN (" & varValid & ") THEN 1 ELSE 0 END AS Valid"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- SW_FTA_VerifyCompletionReason = .Fields("Valid").Value
- .MoveNext
- Loop
- End With
- End Function
- Function GetHTMLFile(Filename)
- dim fso
- dim html
- set fso = CreateObject("Scripting.FileSystemObject")
- ' Open the file for input.
- Set MyFile = fso.OpenTextFile(Filename, 1)
- ' Read from the file and display the results.
- Do While MyFile.AtEndOfStream <> True
- TextLine = MyFile.ReadLine
- html = html & TextLine
- Loop
- MyFile.Close
- GetHTMLFile = html
- End Function
- Function GetTaskCount(GroupContact)
- Dim varselect
- Dim Processed
- Dim TaskCount
- varselect = "select snap.Group_Contact_ID, count(distinct tasks.task_ID) as open_task_count from usr_CRM_Snapshot_V as snap left join CRM_Calls_T as calls on calls.Call_Relates_To_Group_Contact_ID=snap.Group_Contact_ID left join Tasking_Tasks_T as tasks on tasks.crm_call_id=calls.call_id and tasks.Status_ID=58 and tasks.system_task_bt=0 where tasks.Status_ID=58 and tasks.system_task_bt=0 and snap.Group_Contact_ID =" & GroupContact & " group by snap.Group_Contact_ID"
- With SQLConnection.Execute(varselect)
- If Not .Eof Then
- TaskCount = .Fields("open_task_count").Value
- Processed = True
- End If
- .Close
- End With
- If Not Processed Then Exit Function
- GetTaskCount=TaskCount
- End Function
- Function ValidateSnapshotRoles(UserID)
- Dim varselect
- Dim Processed
- Dim ValidRoles
- '2 - Raglan All Access
- '9 - HSC Teamleaders (old role)
- '10 - HSC Front Desk (old role)
- '** New Roles For Unite **
- '152 - CC Advisor
- '154 - CC Team Leader
- '155 - CC Manager
- varselect = "select COUNT(*) as Roles from Shared_User_Roles_T where Role_ID in (2, 9, 10, 135, 136, 137, 138, 152, 154, 155) and User_ID=" & UserID
- With SQLConnection.Execute(varselect)
- If Not .Eof Then
- ValidRoles = .Fields("Roles").Value
- Processed = True
- End If
- .Close
- End With
- If Not Processed Then Exit Function
- ValidateSnapshotRoles=ValidRoles
- End Function
- Function UpdateSnapshotTracker(UserID, CallerID) ' CallerID is Group Contact ID
- Dim strSQLclear
- Dim strSQLins
- ' Purge previous record for current user
- strSQLclear = "DELETE FROM SW_USR_Snapshot_Tracker_T where UserID=" & UserID
- ' Record current caller context
- strSQLins = "INSERT INTO SW_USR_Snapshot_Tracker_T (UserID, ContactID) VALUES (" & UserID & ", " & CallerID & ")"
- With SQLConnection.Execute(strSQLclear)
- End With
- With SQLConnection.Execute(strSQLins)
- End With
- End Function
- Function BuildCRMSnapshot(GroupContact)
- Dim html
- Dim body
- Dim q
- Dim rs
- Dim varselect
- Dim Processed
- Dim TenancyReference
- Dim ExpectedBalance
- Dim HearingVulnerabilties
- Dim VisualVulnerabilities
- Dim CommsVulnerabilities
- Dim DisabledVulnerabilities
- Dim StickVulnerabilities
- Dim Agreement
- Dim CurrentActionLevel
- Dim ActionStatus
- Dim Longitude
- Dim Latitude
- Dim Asbestos
- Dim OpenCalls
- Dim OpenRequests
- Dim OpenASB
- Dim OpenComplaint
- Dim OpenRTB
- Dim OpenPlans
- Dim Applications
- Dim GasServicing
- Dim BedroomTax
- Dim Arrears24
- Dim Arrears18
- Dim Arrears12
- Dim Arrears6
- Dim DateOfBirth
- Dim Allpay
- Dim Callpay
- Dim Experian
- Dim UC
- Dim SWSelectStage
- Dim GroupID
- Dim ContactID
- Dim CCPD
- Dim CCSD
- Dim CCLD
- Dim CCMI
- Dim CCMC
- Dim Asset_ID
- Dim Estate_ID
- Dim SwipeCardOrdered
- Dim DateSwipeCardPrinted
- Dim AccountStartDate
- Dim img
- Dim TaskCount
- TaskCount = GetTaskCount(GroupContact)
- varselect = "SELECT * FROM dbo.usr_CRM_Snapshot_V WHERE Group_Contact_ID = " & GroupContact
- With SQLConnection.Execute(varSelect)
- If Not .Eof Then
- TenancyReference = .Fields("TenancyReference").Value
- ExpectedBalance = .Fields("ExpectedBalance").Value
- HearingVulnerabilities = .Fields("HearingVulnerabilities").Value
- VisualVulnerabilities = .Fields("VisualVulnerabilities").Value
- 'CommsVulnerabilities = .Fields("CommsVulnerabilities").Value
- DisabledVulnerabilities = .Fields("DisabledVulnerabilities").Value
- StickVulnerabilities = .Fields("StickVulnerabilities").Value
- Agreement = .Fields("Agreement").Value
- CurrentActionLevel = .Fields("CurrentActionLevel").Value
- ActionStatus = .Fields("ActionStatus").Value
- Longitude = .Fields("Longitude").Value
- Latitude = .Fields("Latitude").Value
- Postcode = .Fields("Postcode").Value
- Asbestos = .Fields("Asbestos").Value
- OpenCalls = .Fields("OpenCalls").Value
- OpenRequests = .Fields("OpenRequests").Value
- OpenASB = .Fields("OpenASB").Value
- OpenComplaint = .Fields("OpenComplaint").Value
- OpenRTB = .Fields("OpenRTB").Value
- OpenPlans = .Fields("OpenPlans").Value
- Applications = .Fields("Applications").Value
- GasServicing = .Fields("GasServicing").Value
- BedroomTax = .Fields("BedroomTax").Value
- Arrears24 = .Fields("Arrears24Months").Value
- Arrears18 = .Fields("Arrears18Months").Value
- Arrears12 = .Fields("Arrears12Months").Value
- Arrears6 = .Fields("Arrears6Months").Value
- DateOfBirth = .Fields("DateOfBirth").Value
- LastPaymentValue = .Fields("LastPaymentValue").Value
- LastPaymentMethod = .Fields("LastPaymentMethod").Value
- HomeTel = .Fields("HomeTel").Value
- MobTel = .Fields("MobTel").Value
- HomeTelSourceCheck = .Fields("HomeTelSourceCheck").Value
- MobTelSourceCheck = .Fields("MobTelSourceCheck").Value
- Email = .Fields("Email").Value
- TIPSUsername = .Fields("TIPSUsername").Value
- TIPSLastLoginDate = .Fields("TIPSLastLoginDate").Value
- AccountEndDate = .Fields("AccountEndDate").Value
- Gender = .Fields("ContactGender").Value
- Ethnicity = .Fields("ContactEthnicity").Value
- MaritalStatus = .Fields("ContactMaritalStatus").Value
- EmploymentStatus = .Fields("ContactEmploymentStatus").Value
- Religion = .Fields("ContactReligion").Value
- SexualOrientation = .Fields("ContactSexualOrientation").Value
- Warranty = .Fields("Warranty").Value
- NumberOutstandingRepairs = .Fields("NumberOutstandingRepairs").Value
- NotDisabled = .Fields("NotDisabled").Value
- Risk = .Fields("Risk").Value
- NonRisk = .Fields("Non_Risk").Value
- Experian = .Fields("Experian").Value
- UC = .Fields("UC").Value
- SWSelectStage = .Fields("SWSelectStage").Value
- GroupID = .Fields("Group_ID").Value
- ContactID = .Fields("ContactID").Value
- CCPD = .Fields("CCPD").Value
- CCSD = .Fields("CCSD").Value
- CCLD = .Fields("CCLD").Value
- CCMI = .Fields("CCMI").Value
- CCMC = .Fields("CCMC").Value
- Asset_ID = .Fields("Asset_ID").Value
- Estate_ID = .Fields("Estate_ID").Value
- SwipeCardOrdered = .Fields("SwipeCardOrdered").Value
- DateSwipeCardPrinted = .Fields("DateSwipeCardPrinted").Value
- AccountStartDate = .Fields("AccountStartDate").Value
- Processed = True
- End If
- .Close
- End With
- If Not Processed Then Exit Function
- ' Call File.WriteAllText("\\srv-fls-01\data\Snapshot\test.txt", "This is new text to be added.",True)
- q = chr(34)
- html = GetHTMLFile("\\srv-fls-01\data\Snapshot\CRMSnapshotHeaderNew.txt")
- html = replace(html,"24M",Arrears24)
- html = replace(html,"18M",Arrears18)
- html = replace(html,"12M",Arrears12)
- html = replace(html,"6M",Arrears6)
- html = replace(html,"CURRENT",ExpectedBalance)
- ' Begin HTML body output
- body = body & "<table cols=4>"
- body = body & "<tr><td width=25% valign=top>"
- ' Security check
- body = body & "<table cols=2 width=400px><tr>"
- body = body & "<td class=" & q & "Security" & q & " colspan=2 align=center>Security Check</td></tr>"
- ' Dob
- If Len(DateOfBirth) > 0 Then
- body = body & "<td><font face=arial size=2><b>Date of Birth</b></font></td>"
- Else
- body = body & "<td><font face=arial size=2 color=red><b>Date of Birth</b></font></td>"
- End If
- ' body = body & "<tr><td><font face=arial size=2><b>Date of Birth</b></font></td>"
- body = body & "<td><font face=arial size=2>" & DateOfBirth & "</font></td>"
- ' Rent account no
- body = body & "<tr><td><font face=arial size=2><b>Rent Account Number</b></font></td>"
- body = body & "<td><font face=arial size=2>" & TenancyReference & "</font></td>"
- ' Last payment method
- body = body & "<tr><td><font face=arial size=2><b>Last Payment Method</b></font></td>"
- body = body & "<td><font face=arial size=2>" & LastPaymentMethod & "</font></td>"
- ' Last payment amount
- body = body & "<tr><td><font face=arial size=2><b>Last Payment Amount</b></font></td>"
- body = body & "<td><font face=arial size=2>" & LastPaymentValue & "</font></td>"
- body = body & "</tr><tr>"
- ' Contact Details
- body = body & "<td class=" & q & "Contact" & q & " colspan=2 align=center>Contact Details</td></tr><tr>"
- ' TESTING TaskCount
- ' body = body & "<td><font face=arial size=2><b>Open Tasks</b></font></td><td><font face=arial size=2>" & TaskCount & "</font></td></tr><tr>"
- ' Home Telephone
- If Len(HomeTel) > 0 Then
- body = body & "<td><font face=arial size=2><b>Home Telephone</b></font></td>"
- Else
- body = body & "<td><font face=arial size=2 color=red><b>Home Telephone</b></font></td>"
- End If
- If HomeTelSourceCheck = 0 Then ' If 0 then number is from wrong table (or blank)
- body = body & "<td><font face=arial size=2 color=red>" & HomeTel & "</font></td></tr><tr>"
- Else
- body = body & "<td><font face=arial size=2>" & HomeTel & "</font></td></tr><tr>"
- End If
- ' Mobile
- If Len (MobTel) > 0 Then
- body = body & "<td><font face=arial size=2><b>Mobile Telephone</b></font></td>"
- Else
- body = body & "<td><font face=arial size=2 color=red><b>Mobile Telephone</b></font></td>"
- End If
- If MobTelSourceCheck = 0 Then ' If 0 then number is from wrong table (or blank)
- body = body & "<td><font face=arial size=2 color=red>" & MobTel & "</font></td></tr><tr>"
- Else
- body = body & "<td><font face=arial size=2>" & MobTel & "</font></td></tr><tr>"
- End If
- ' Email
- If Len(Email) > 0 Then
- body = body & "<td><font face=arial size=2><b>Email Address</b></font></td>"
- 'body = body & "<td><font face=arial size=2><a href='#' title='Click to update' onclick=" & q & "amendPopup('Update E-mail', '" & Email & "')" & q & ">" & Email & "</font></td></tr><tr>"
- body = body & "<td><font face=arial size=2><a href='\\srv-fls-01\data\Snapshot\PopupWFCaller.lnk' title='Click to update'>" & Email & "</font></td></tr><tr>"
- Else
- body = body & "<td><font face=arial size=2 color=red><b>Email Address</b></font></td>"
- 'body = body & "<td><font face=arial size=2><a href='#' title='Click to update' onclick=" & q & "amendPopup('Update E-mail', '')" & q & ">Update</font></td></tr><tr>"
- body = body & "<td><font face=arial size=2><a href='\\srv-fls-01\data\Snapshot\PopupWFCaller.lnk' title='Click to update'>Update</font></td></tr><tr>"
- End If
- 'body = body & "<td><font face=arial size=2>" & Email & "</font></td></tr><tr>"
- ' Gender
- If Len(Gender) > 0 Then
- body = body & "<td><font face=arial size=2><b>Gender</b></font></td>"
- Else
- body = body & "<td><font face=arial size=2 color=red><b>Gender</b></font></td>"
- End If
- body = body & "<td><font face=arial size=2>" & Gender & "</font></td></tr><tr>"
- ' Ethnicity
- If Len(Ethnicity) > 0 Then
- body = body & "<td><font face=arial size=2><b>Ethnicity</b></font></td>"
- Else
- body = body & "<td><font face=arial size=2 color=red><b>Ethnicity</b></font</td>"
- End If
- body = body & "<td><font face=arial size=2>" & Ethnicity & "</font></td></tr><tr>"
- ' Marital Status
- If Len(MaritalStatus) > 0 Then
- body = body & "<td><font face=arial size=2><b>Marital Status</b></font></td>"
- Else
- body = body & "<td><font face=arial size=2 color=red><b>Marital Status</td></font></td>"
- End If
- body = body & "<td><font face=arial size=2>" & MaritalStatus & "</font></td></tr><tr>"
- ' Employment Status
- If Len(EmploymentStatus) > 0 Then
- body = body & "<td><font face=arial size=2><b>Employment Status</b></font></td>"
- Else
- body = body & "<td><font face=arial size=2 color=red><b>Employment Status</b></font></td>"
- End If
- body = body & "<td><font face=arial size=2>" & EmploymentStatus & "</font></td></tr><tr>"
- ' Religion
- If Len(Religion) > 0 Then
- body = body & "<td><font face=arial size=2><b>Religion</b></font></td>"
- Else
- body = body & "<td><font face=arial size=2 color=red><b>Religion</b></font></tr>"
- End If
- body = body & "<td><font face=arial size=2>" & Religion & "</font></td></tr><tr>"
- ' Orientation
- If Len(SexualOrientation) > 0 Then
- body = body & "<td><font face=arial size=2><b>Sexual Orientation</b></font></td>"
- Else
- body = body & "<td><font face=arial size=2 color=red><b>Sexual Orientation</b></font></td>"
- End If
- body = body & "<td><font face=arial size=2>" & SexualOrientation & "</font></td>"
- body = body & "</tr></table>"
- body = body & "</td>"
- ' End Security Check & Contact Details Section
- body = body & "<td> </td>"
- body = body & "<td> </td>"
- body = body & "</td><td valign=top>"
- ' Icons Section Titles
- body = body & "<table cols=13 width=600px>"
- body = body & "<td class=" & q & "risk" & q & " colspan=1 align=center>Risks</td>"
- body = body & "<td width=50> </td>"
- ' body = body & "<td class=" & q & "links" & q & " colspan=2 align=center>Quick Links</td>"
- ' If Len(NonRisk) > 0 Then
- body = body & "<td class=" & q & "links" & q & " colspan=1 align=center>Vulnerabilities</td>"
- body = body & "<td width=50> </td>"
- ' End If
- body = body & "<td class=" & q & "pi" & q & " colspan=5 align=center>Personal Indicators</td>"
- ' body = body & "<td width=50> </td>"
- ' body = body & "<td class=" & q & "SWSelect" & q & " colspan=1 align=center>Select</td>"
- body = body & "</tr><tr>"
- ' Risk
- If Len(Risk) > 0 Then
- body = body & "<td><img Title=" & q & "Risks:" & vbCrLf & replace(Risk, ";", vbCrLf) & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\risk_present.gif" & q & "></td>"
- Else
- body = body & "<td><img Title=" & q & "No risk present" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_risk_present.gif" & q & "></td>"
- End If
- body = body & "<td width=50> </td>"
- ' Vulnerabilities (Non-risk)
- If Len(NonRisk) > 0 Then
- body = body & "<td><img Title=" & q & "Vulnerabilities:" & vbCrLf & replace(NonRisk, ";", vbCrLf) & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\vulnerabilities.png" & q & "></td>"
- Else
- body = body & "<td><img Title=" & q & "No vulnerabilities" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_vulnerabilities.png" & q & "></td>"
- End If
- body = body & "<td width=50> </td>"
- '' Quick Links
- '' Account Details
- ' If Len(AccountEndDate) > 0 and Len(TenancyReference) > 0 Then
- ' img = "\\srv-fls-01\data\Snapshot\CRM Images\account_details_term.gif"
- ' Else
- ' If Len(TenancyReference) > 0 and Len(AccountEndDate) = 0 Then
- ' img = "\\srv-fls-01\data\Snapshot\CRM Images\account_details.gif"
- ' Else
- ' img = "\\srv-fls-01\data\Snapshot\CRM Images\no_account_details.gif"
- ' End If
- ' End If
- '
- ' If Len (AccountEndDate) > 0 and Len(TenancyReference) > 0 Then
- ' text = "Account End Date " & AccountEndDate
- ' Else
- ' If Len(TenancyReference) > 0 and Len(AccountEndDate) = 0 Then
- ' text = "Drill into the Rent Account"
- ' Else
- ' text = "No tenancy reference available"
- ' End If
- ' End If
- '
- ' If Len(TenancyReference) > 0 Then
- ' body = body & "<td><a href=" & q & "activeh://AccountDetails/" & TenancyReference & q & "><img Title=" & q & text & q & " src=" & q & img & q & " border=0></a></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & text & q & " src=" & q & img & q & "></td>"
- ' End If
- '' Account financial
- ' If Len(TenancyReference) > 0 Then
- ' img = "\\srv-fls-01\data\Snapshot\CRM Images\account_financial.gif"
- ' Else
- ' img = "\\srv-fls-01\data\Snapshot\CRM Images\no_account_financial.gif"
- ' End If
- '
- ' If Len(TenancyReference) > 0 Then
- ' body = body & "<td><a href=" & q & "activeh://AccountFinancial/" & TenancyReference & q & "><img Title=" & q & "Display Account Financials" & q & " src=" & q & img & q & " border=0></a></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No tenancy reference available" & q & " src=" & q & img & q & "></td>"
- ' End If
- '
- ' body = body & "<td width=50> </td>"
- ' Personal Indicators
- ' Hearing
- If Len(HearingVulnerabilities) > 0 Then
- img = "\\srv-fls-01\data\Snapshot\CRM Images\hearing_impairment.gif"
- Else
- If Len(HearingVulnerabilities) = 0 and Len(NotDisabled) = 0 Then
- img = "\\srv-fls-01\data\Snapshot\CRM Images\notconfirmed_hearing_impairment.gif"
- Else
- img = "\\srv-fls-01\data\Snapshot\CRM Images\no_hearing_impairment.gif"
- End If
- End If
- body = body & "<td><img Title=" & q & HearingVulnerabilities & q & " src=" & q & img & q & "></td>"
- ' Disabled
- If Len(DisabledVulnerabilities) > 0 Then
- img = "\\srv-fls-01\data\Snapshot\CRM Images\disabled.gif"
- Else
- If Len(DisabledVulnerabilities) = 0 and Len(NotDisabled) = 0 Then
- img = "\\srv-fls-01\data\Snapshot\CRM Images\notconfirmed_disabled.gif"
- Else
- img = "\\srv-fls-01\data\Snapshot\CRM Images\not_disabled.gif"
- End If
- End If
- body = body & "<td><img Title=" & q & DisabledVulnerabilities & q & " src=" & q & img & q & "></td>"
- ' Visual
- If Len(VisualVulnerabilities) > 0 Then
- img = "\\srv-fls-01\data\Snapshot\CRM Images\visual_impairment.gif"
- Else
- If Len(VisualVulnerabilities) = 0 and Len(NotDisabled) = 0 Then
- img = "\\srv-fls-01\data\Snapshot\CRM Images\notconfirmed_visual_impairment.gif"
- Else
- img = "\\srv-fls-01\data\Snapshot\CRM Images\no_visual_impairment.gif"
- End If
- End If
- body = body & "<td><img Title=" & q & VisualVulnerabilities & q & " src=" & q & img & q & "></td>"
- ' Stick
- If Len(StickVulnerabilities) > 0 Then
- img = "\\srv-fls-01\data\Snapshot\CRM Images\stick_user.gif"
- Else
- If Len(StickVulnerabilities) = 0 and Len(NotDisabled) = 0 Then
- img = "\\srv-fls-01\data\Snapshot\CRM Images\notconfirmed_stick_user.gif"
- Else
- img = "\\srv-fls-01\data\Snapshot\CRM Images\not_stick_user.gif"
- End If
- End If
- body = body & "<td><img Title=" & q & StickVulnerabilities & q & " src=" & q & img & q & "></td>"
- ' Bedroom Tax
- If Len(BedroomTax) > 0 and InStr(BedroomTax, "under") > 0 Then
- img = "\\srv-fls-01\data\Snapshot\CRM Images\bedroom_tax.gif"
- Else
- img = "\\srv-fls-01\data\Snapshot\CRM Images\no_bedroom_tax.gif"
- End If
- body = body & "<td><img Title=" & q & BedroomTax & q & " src=" & q & img & q & "></td>"
- body = body & "<td width=50> </td>"
- '' Select
- ' If SWSelectStage = "Select" Then
- ' img = "\\srv-fls-01\data\Snapshot\CRM Images\SW_Select_gold.png" '
- ' Else
- ' if SWSelectStage = "Standard" Then
- ' img = "\\srv-fls-01\data\Snapshot\CRM Images\SW_Select_std.png"
- ' Else
- ' img = "\\srv-fls-01\data\Snapshot\CRM Images\no_SW_Select.png"
- ' End If
- ' End If
- ' body = body & "<td><a href=" & q & "activeh://GroupCharacteristics/" & GroupID & q & "><img Title=" & q & "Tier: " & SWSelectStage & q & " src=" & q & img & q & "></td>"
- ' body = body & "<td width=50> </td>"'
- ' body = body & "</tr>"
- 'html = html & body
- ' Rent Notifications and Open Activity - Titles
- body = body & "<tr>"
- body = body & "<td class=" & q & "rents" & q & " colspan=1 align=center>Rents</td>"
- body = body & "<td width=50> </td>"
- ' body = body & "<td class=" & q & "activity" & q & " colspan=5 align=center>Open Activity</td>"
- If TaskCount > 0 Then
- body = body & "<td class=" & q & "activity" & q & " colspan=1 align=center>Tasks</td>"
- body = body & "<td> </td>"
- End If
- body = body & "<td width=50> </td>"
- body = body & "<td width=50> </td>"
- body = body & "<td> </td>"
- body = body & "</tr><tr>"
- ' Rents Notifications
- ' Arrears
- If Cdbl(ExpectedBalance) > 0 Then
- img = "\\srv-fls-01\data\Snapshot\CRM Images\arrears.gif"
- Else
- img = "\\srv-fls-01\data\Snapshot\CRM Images\no_arrears.gif"
- End If
- If Cdbl(ExpectedBalance) > 0 Then
- body = body & "<td><img Title=" & q & "Account is currently £" & ExpectedBalance & " in arrears" & q & " src=" & q & img & q & "></td>"
- Else
- body = body & "<td><img Title=" & q & "Account is not in arrears" & q & " src=" & q & img & q & "></td>"
- End If
- '' Agreement
- ' If Len(Agreement) > 0 Then
- ' body = body & "<td><img Title=" & q & Agreement & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\agreement.gif" & q & "></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No Agreements" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_agreement.gif" & q & "></td>"
- ' End If
- '
- '' Action Level
- ' If Len(CurrentActionLevel) > 0 Then
- ' body = body & "<td><img Title=" & q & CurrentActionLevel & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\notice.gif" & q & "></td>"
- ' Else
- ' body = body & "<td> </td>"
- ' End If
- '
- '' Court Action
- ' If Len(ActionStatus) > 0 Then
- ' body = body & "<td><img Title=" & q & ActionStatus & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\court_action.gif" & q & "></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No Court Actions" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_court_action.gif" & q & "></td>"
- ' End If
- '
- '' Universal Credit
- ' If UC = "1" Then
- ' body = body & "<td><a href=" & q & "activeh://GroupCharacteristics/" & GroupID & q & "><img title=" & q & "Receives Universal Credit" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\UC.png" & q & "></img></td>"
- ' Else
- ' body = body & "<td><img title=" & q & "Does not receive Universal Credit" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_UC.png" & q & "></img></td>"
- ' End If
- body = body & "<td> </td>"
- ' Open Activity
- ' Calls
- ' If OpenCalls > 0 Then
- ' body = body & "<td><img Title=" & q & OpenCalls & " calls are currently open" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\open_calls.gif" & q & "></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No calls open" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_open_calls.gif" & q & "></td>"
- ' End If
- '
- '' Repairs
- ' If NumberOutstandingRepairs > 0 Then
- ' body = body & "<td><a href=" & q & "" & q & "><img Title=" & q & NumberOutstandingRepairs & " repairs are currently outstanding" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\repairs_present.gif" & q & " border=0></a></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No repairs outstanding" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_repairs_present.gif" & q & "></td>"
- ' End If
- '
- '' ASB
- ' If OpenASB > 0 Then
- ' body = body & "<td><img Title=" & q & OpenASB & " ASB cases are currently open" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\asb.gif" & q & "></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No ASB cases open" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_asb.gif" & q & "></td>"
- ' End If
- '
- '' Complaint
- ' If OpenComplaint > 0 Then
- ' body = body & "<td><img Title=" & q & OpenComplaint & " complaints are currently open" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\complaint.gif" & q & "></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No complaints are open" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_complaint.gif" & q & "></td>"
- ' End If
- '
- ' RTB
- ' If OpenRTB > 0 Then
- ' body = body & "<td><img Title=" & q & OpenRTB & " Right To Buy cases are currently open" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\right_to_buy.gif" & q & "></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No Right To Buy cases are open" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_right_to_buy.gif" & q & "></td>"
- ' End If
- ' Plan
- ' If OpenPlans > 0 Then
- ' body = body & "<td><img Title=" & q & OpenPlans & " open plans against this property" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\planned.gif" & q & "></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No open plans against this property" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_planned.gif" & q & "></td>"
- ' End If
- ' Tasks
- If TaskCount > 0 Then
- body = body & "<td><img Title=" & q & "Open Tasks: " & TaskCount & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\Task.png" & q & "></td>"
- End If
- body = body & "<td width=50> </td>"
- body = body & "<td width=50> </td>"
- body = body & "<td> </td>"
- body = body & "</tr>"
- 'html = html & body
- ' Property Information - Payments - Other - Titles
- body = body & "<tr>"
- ' body = body & "<td class=" & q & "property" & q & " colspan=4 align=center>Property Information</td>"
- ' body = body & "<td> </td>"
- body = body & "<td class=" & q & "Payments" & q & " colspan=2 align=center>Payments</td>"
- body = body & "<td> </td>"
- body = body & "<td class=" & q & "other" & q & " colspan=1 align=center>Other</td>"
- body = body & "<td width=50> </td>"
- ' body = body & "<td> </td>"
- body = body & "</tr>"
- body = body & "<tr>"
- '' Proprerty Information
- '' Asbestos
- ' If Len(Asbestos) > 0 Then
- ' body = body & "<td><img Title=" & q & "Asbestos present at property" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\asbestos.gif" & q & "></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No Asbestos present" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\asbestos_not_present.gif" & q & "></td>"
- ' End If
- '
- '' Gas
- ' If Len(GasServicing) > 0 Then
- ' body = body & "<td><img Title=" & q & GasServicing & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\gas_servicing.gif" & q & "></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No gas servicing issues" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_gas_servicing.gif" & q & "></td>"
- ' End If
- '
- '' Map
- ' If Len(Longitude) > 0 And Len(Latitude) > 0 Then
- ' body = body & "<td><a href=" & q & "https://maps.google.com/?q=" & Latitude & "," & Longitude & q & " target=_blank border=0><img Title=" & q & "See property on map" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\plot_on_map.gif" & q & " border=0></a></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No co-ordinates to locate property" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_plot_on_map.gif" & q & "></td>"
- ' End If
- '
- '' Warranty
- ' If Len(Warranty) > 0 Then
- ' body = body & "<td><img Title=" & q & "Warranty Information: " & Warranty & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\warranty.png" & q & "></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "No Warranty Information" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\not_warranty.png" & q & "></td>"
- ' End If
- '
- ' body = body & "<td colspan=1> </td>"
- ' Payments
- ' Allpay
- If ((CDate(AccountStartDate)>Cdate("2016-09-26")) or (Estate_ID=5284 or Estate_ID=5285) or ((Estate_ID=5488 or Estate_ID=5489 or Estate_ID=5490) and (CDate(AccountStartDate)>Cdate("2016-09-26") or Cdate(DateSwipeCardPrinted)>Cdate("2016-09-26") or len(SwipeCardOrdered)>0))) then
- body = body & "<td><a href=" & q & "https://webconnect.allpay.net" & q & " target=_blank border=0><img Title=" & q & Allpay & " Allpay Link" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\allpay.gif" & q & " border=0></a></td>"
- body = body & "<td width=50> </td>"
- Else
- body = body & "<td colspan=2> </td>"
- End If
- 'body = body & "<td><a href=" & q & "https://www.callpay.net/Login.aspx" & q & " target=_blank border=0><img Title=" & q & Callpay & " Callpay Link" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\callpay.gif" & q & " border=0></a></td>"
- 'body = body & "<td><a href=" & q & "https://secure.worldpay.com/sso/public/auth/login.html?serviceIdentifier=merchantadmin " & q & " target=_blank border=0><img Title=" & q & AllPay & " AllPay Link" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\allpay.png" & q & " border=0></a></td>"
- body = body & "<td colspan=1> </td>"
- '' Other
- '' Applications
- ' body = body & "<td><img Title=" & q & Applications & " applications are active" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\lettings.gif" & q & "></td>"
- '
- '' Last Login
- If Len(TIPSLastLoginDate) > 0 Then
- body = body & "<td><img Title=" & q & "Last Login: " & TIPSLastLoginDate & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\Web.png" & q & "></td>"
- Else
- body=body & "<td><img Title=" & q & "TIPS not used" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\not_Web.png" & q & "></img></td>"
- End If
- '' Experian
- ' If Experian > 0 Then
- ' body = body & "<td><a href=" & q & "activeh://GroupCharacteristics/" & GroupID & q & "><img title=" & q & "Opted in to Experian" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\experian.png" & q & " border=0></td>"
- ' Else
- ' body = body & "<td><img title=" & q & "Opted out of Experian" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_experian.png" & q & " border=0></td>"
- ' End If
- '
- ' body = body & "<td width=50> </td>"
- ' body = body & "<td width=50> </td>"
- ' body = body & "<td> </td>"
- ' body = body & "</tr>"
- ' body = body & "<tr>"
- '
- '' CC Indicators
- ' body = body & "<td class=" & q & "pi" & q & " colspan=5 align=center>CC Indicators</td></tr>"
- ' body = body & "<tr>"
- '
- '' Contact Characteristic - Physical Disability
- ' If CCPD = 1 Then
- ' body = body & "<td><a href=" & q & "activeh://ContactCharacteristics/" & ContactID & q & "><img Title=" & q & "Contact has Physical Disabilities, please allow additional time to respond" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\disabled.gif" & q & " border = 0></a></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "Contact has no Physical Disabilities recorded" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\not_disabled.gif" & q & " border = 0></td>"
- ' End If
- '
- '' Contact Characteristic - Sensory Disability
- ' If CCSD =1 Then
- ' body = body & "<td><a href=" & q & "activeh://ContactCharacteristics/" & ContactID & q & "><img Title=" & q & "Contact has Sensory Disabilities, please..." & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\hearing_impairment.gif" & q & " border = 0></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "Contact has no Sensory Disabilities recorded" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_hearing_impairment.gif" & q & "></img></td>"
- ' End if
- '
- '' Contact Characteristic - Learning Difficulty
- ' If CCLD = 1 Then
- ' body = body & "<td><a href=" & q & "activeh://ContactCharacteristics/" & ContactID & q & "><img Title=" & q & "Contact has Learning Difficulties, please explain clearly and avoid disrupting routine" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\learningdifficulties.gif" & q & " border = 0></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "Contact has no Learning Difficulties recorded" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_learningdifficulties.gif" & q & " border = 0></td>"
- ' End If
- '
- '' Contact Characteristic - Mental Illness
- ' If CCMI = 1 Then
- ' body = body & "<td><a href=" & q & "activeh://ContactCharacteristics/" & ContactID & q & "><img Title=" & q & "Contact has Mental Illnesses, please..." & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\mentalillness.png" & q & " border = 0></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "Contact has no Mental Illnesses recorded" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_mentalillness.gif" & q & " border = 0></td>"
- ' End If
- '
- '' Contact Characteristic - Medical Conditions
- ' If CCMC = 1 Then
- ' body = body & "<td><a href=" & q & "activeh://ContactCharacteristics/" & ContactID & q & "><img Title=" & q & "Contact has Medical Conditions, please click here for further information" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\medicalconditions.png" & q & " border = 0></td>"
- ' Else
- ' body = body & "<td><img Title=" & q & "Contact has no Medical Conditions recorded" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_medicalconditions.gif" & q & " border = 0></td>"
- ' End If
- '
- ' body = body & "</tr>"
- html = html & body
- html = html & "</table>"
- html = html & "</tr>"
- html = html & "</tr><tr>"
- html = html & "<td> </td>" ' inserts balnk cell
- html = html & "<td> </td>" ' inserts blank cell
- ' html = html & "<table>" ' inserts new table
- ' html = html & "<tr>" ' inserts new row
- ' html = html & "<div id=" & q & "chart_div" & q & " style=" & q & "width: 400px; height=300px;" & q & "></div>" ' Graph
- ' html = html & "</tr>"
- ' html = html & "</table>"
- html = html & "</td></tr></table>"
- html = html & "</body></html>"
- BuildCRMSnapshot = html
- End Function
- '*** End *** CRM Snapshot ***
- Function UpdateVoidCaseAsbestosCheckAuditT(varCaseID,varTaskID)
- varSelect = "insert into usr_SW_Void_Management_Case_Asbestos_Check_Audit_T(Case_ID,Task_ID) values (" & varCaseID & "," & varTaskID & ")"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function UpdateVoidCaseFolderCreationAuditT(varCaseID)
- varSelect = "insert into usr_SW_Void_Management_Case_Folder_Creation_Audit_T(Case_ID) values (" & varCaseID & ")"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function InsertVoidCompletionDateAuditT (CaseID,CompletionDate)
- varSelect = "insert into usr_SW_Void_Management_Completion_Date_Audit_T(Case_ID) values (" & CaseID & ")"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function UpdateVoidCompletionDateAuditT (CaseID,CompletionDate)
- varUpdate = "update usr_SW_Void_Management_Completion_Date_Audit_T set Completion_Date = '" & CompletionDate & "' where Case_ID = '" & CaseID & "'"
- with SQLConnection.Execute(varUpdate)
- End with
- End Function
- Function UpdateVoidCaseCreationNotificationsAuditT(varCaseID,varTaskID,varRecipientVC)
- varSelect = "insert into usr_SW_Void_Management_Case_Notifications_Audit_T(Case_ID,Task_ID,Task_Recipient_VC) values (" & varCaseID & "," & varTaskID & ",'" & varRecipientVC & "')"
- with SQLConnection.Execute(varSelect)
- End with
- End Function
- Function UpdateLastIssuedDate(varWorksOrderID)
- varUpdate = "update Repairs_Works_Orders_T set LastIssued_DT = getdate() where WorksOrder_ID = " & varWorksOrderID & ""
- with SQLConnection.Execute(varUpdate)
- end with
- End Function
- Function UpdateLettingsFolderCreationAuditT(varApplicationID)
- varSelect = "insert into usr_SW_Lettings_Case_Folder_Creation_Audit_T (Application_ID) values (" & varApplicationID & ")"
- with SQLConnection.Execute(varSelect)
- end With
- End Function
- Function UpdateVoidCaseStepCompletionTaskingAuditT(varCaseID,varMatrixID)
- varSelect = "insert into usr_SW_Void_Management_Process_Step_Task_Completion_Audit_T (Case_ID,Matrix_ID) values (" & varCaseID & "," & varMatrixID & ")"
- with SQLConnection.Execute(varSelect)
- End with
- End Function
- Function UpdateVoidCaseProvisionalOfferAuditT(varCaseID,varTaskID)
- varSelect = "insert into usr_SW_Void_Management_Provisional_Offer_Audit_T(Case_ID,Task_ID) values (" & varCaseID & "," & varTaskID & ")"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function UpdateVoidCaseKeySafeAuditT(varCaseID,varTaskID)
- varSelect = "insert into usr_SW_Void_Management_Case_Keysafe_Audit_T(case_ID,Task_ID) values (" & varCaseID & "," & varTaskID & ")"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function UpdateOptOutTracker (AccountRef)
- Dim strSQL
- strSQL = ("Insert into SW_USR_Experian_OptOut_T Values (" & AccountRef & ")")
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function WorksOrderAudit(varOrderID,varLastIssuedDate,varOrderStatus,varComments,varDateTime)
- varInsert = "INSERT INTO dbo.RAGLAN_USR_Works_Orders_Audit_T (OrderID,LastIssuedDate,OrderStatus,Comments,DateTime) VALUES (" & varOrderID & ",'" & varLastIssuedDate & "'," & varOrderStatus & ",'" & varComments & "','" & varDateTime & "')"
- With SQLConnection.Execute(varInsert)
- End With
- End Function
- Function UpdateBulkSMSTable(Mobile,varSent)
- varUpdate = "UPDATE SW_Bulk_SMS_Loader_T SET Sent = '" & varSent & "' WHERE Mobile = '" & Mobile & "'"
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function UpdateAgreementPayment(varAccountID,varSequenceNumber,varVariance,varPaymentID)
- varUpdate = "update Rent_Payments Set AgreementReferenceUpdated = '" & varSequenceNumber & "', AmountOfPayment = '" & varVariance & "' where Account_TG_VC = '" & varAccountID & "' and ID = '" & varPaymentID & "'"
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- '--------Prompted Arrears Functions START---------
- Function UpdatePromptedArrearsControl(varID,varCurrentRunDate,varUserID)
- varCurrentRunDate = ReturnDateDDMMMYYYY(varCurrentRunDate)
- varUpdate = "UPDATE RAGLAN_USR_Prompted_Rent_Arrears_Control_T SET LastRunDate = '" & varCurrentRunDate & "', UserID = '" & varUserID & "', AccountLastProcessed = 'COMPLETED' WHERE ID = '" & varID & "'"
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function UpdatePromptedArrearsControlTMP(varID,varCurrentRunDate,varUserID)
- varCurrentRunDate = ReturnDateDDMMMYYYY(varCurrentRunDate)
- varUpdate = "UPDATE RAGLAN_USR_Prompted_Rent_Arrears_Control_TMP_T SET LastRunDate = '" & varCurrentRunDate & "', UserID = '" & varUserID & "', AccountLastProcessed = 'COMPLETED' WHERE ID = '" & varID & "'"
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function UpdateArrearsProgressControl(varAccountID,varID)
- varUpdate = "UPDATE RAGLAN_USR_Prompted_Rent_Arrears_Control_T SET AccountLastProcessed = '" & varAccountID & "' WHERE ID = " & varID
- WITH SQLConnection.Execute(varUpdate)
- END WITH
- End Function
- Function UpdateArrearsProgressControlTMP(varAccountID,varID)
- varUpdate = "UPDATE RAGLAN_USR_Prompted_Rent_Arrears_Control_TMP_T SET AccountLastProcessed = '" & varAccountID & "' WHERE ID = " & varID
- WITH SQLConnection.Execute(varUpdate)
- END WITH
- End Function
- Function UpdateOccDel_T(OccID)
- varUpdate = "Update dbo.RHA_USR_Occurrence_Deletions_T SET IsDeleted_BT = '1' where OccID = " & OccID
- WITH SQLConnection.Execute(varUpdate)
- END WITH
- End Function
- Function UpdateOccDelErr(OccID,ErrorLog)
- varUpdate = "Update dbo.RHA_USR_Occurrence_Deletions_T SET Error = ('"& ErrorLog &"') where OccID = " & OccID
- WITH SQLConnection.Execute(varUpdate)
- END WITH
- End Function
- Function UpdateRRTrackerT(Task,Order,Recharge,Cost,DateTime)
- Dim strSQL
- strSQL = ("Insert into RHA_USR_WF_Recharge_Task_Tracker_T (Task_ID,Order_ID,Recharge_BT,Value_MN,DateTime_DT) Values ('" & Task & "','" & Order & "','" & Recharge & "','" & Cost & "','" & DateTime & "')")
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function AgreementBalance(varAccountID,varAgreementID)
- varSelect = "SELECT ISNULL(dbo.fn_GetRentAgreementBalance(dbo.fn_CurrentYearMonth(),'" & varAccountID & "','','S'," & varAgreementID & "),0) AS Balance"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varBalance = .Fields("Balance").Value
- .MoveNext
- Loop
- End With
- AgreementBalance = varBalance
- End Function
- Function AgreementValue(varAgreementID)
- varSelect = "SELECT ISNULL(AGREE.AgreementValue,0) AS AgreementValue FROM Rent_Agreements AGREE (NOLOCK) WHERE AGREE.ID = '" & varAgreementID & "'"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varValue = .Fields("AgreementValue").Value
- .MoveNext
- Loop
- End With
- AgreementValue = varValue
- End Function
- Function ClearXMLTracker
- Dim strSQL
- strSQL = ("Delete from RHA_WF_IWXMLTracker_T")
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function UpdateXMLTracker(FilePath)
- Dim strSQL
- strSQL = ("Insert into RHA_WF_IWXMLTracker_T (XMLFilePath) Values ('" & FilePath & "')")
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function WriteToAgreementsProcessAuditTable(varUser)
- varInsert = "insert into usr_STO_Agreements_Update_Audit_T (Processed_By_Username_VC,Processed_DT) values ('" & varUser & "',getdate())"
- with SQLConnection.Execute(varInsert)
- end with
- End Function
- Function UpdateAsbestosError(ErrDesc, Counter)
- varInsert = "UPDATE WF_USR_AsbestosImport_T SET Error = '" & ErrDesc & "' where Count = '" & Counter & "'"
- With SQLConnection.Execute(varInsert)
- End With
- End Function
- Function UpdateAsbestosImport(OccID, Counter)
- varInsert = "UPDATE WF_USR_AsbestosImport_T SET OccID = " & OccID & "where Count = '" & Counter & "'"
- With SQLConnection.Execute(varInsert)
- End With
- End Function
- Function UpdateAsbestosTracker(AssetID, OccID)
- Dim strSQL
- strSQL = ("Insert into WF_USR_AsbestosTracker_T (AssetID, OccID) Values (" & AssetID & "," & OccID & ")")
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function WorksOrderTracker(WO,Contr,WFName)
- varSelect = "INSERT INTO WF_USR_WorksOrderTracker_T (WorksOrder,Contractor,[Workflow Name]) VALUES ('" & WO & "','" & Contr & "','" & WFName &"')"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function BuildBenefitPaymentsReceivedInLastXXDaysV2(varDays)
- ' Same as old version but should be much quicker as SQL will do the inserting during the select
- varFromDate = DateAdd("d",(varDays*-1),Date)
- varFromDate = ReturnDateDDMMMYYYY(varFromDate)
- varToDate = Date
- varToDate = ReturnDateDDMMMYYYY(varToDate)
- varSelect = "DELETE FROM RAGLAN_USR_Benefit_Payments_Last_Received_T"
- SQLConnection.Execute varSelect
- varselect = "INSERT INTO RAGLAN_USR_Benefit_Payments_Last_Received_T (ID,BenefitAmount) "
- varselect = varselect & "SELECT RA.ID,ISNULL(HBDueInPeriod.Total,0) FROM Rent_Accounts AS RA (NOLOCK) INNER JOIN (SELECT SubAcc.Account_TG_VC AS AccountID,SubAcc.ID AS SubAccountID,SubAccount_TG_VC AS SubAccountCode,SubAcc.ID AS AccountIDSubAccountCode FROM Rent_SubAccounts AS SubAcc (NOLOCK) UNION SELECT RA1.ID AS AccountID,'' AS SubAccountID,'' AS SubAccountCode,RA1.ID AS AccountIDSubAccountCode FROM Rent_Accounts AS RA1 (NOLOCK)) AS MainAccount ON MainAccount.AccountID=RA.ID INNER JOIN (SELECT SUM(rp.Value) AS Total,AccountRef AS Account FROM Rent_Payments rp (NOLOCK) INNER JOIN ActiveH_Codes_V acv ON acv.ID=('MP'+rp.MethodOfPayment) AND acv.F3='HB' WHERE (rp.PaymentDate BETWEEN '" & varFromDate & "' AND '" & varToDate & "') AND (LEFT(rp.ID,2)='PY') GROUP BY rp.AccountRef) AS HBDueInPeriod ON HBDueInPeriod.Account=MainAccount.AccountIDSubAccountCode"
- SQLConnection.Execute varSelect
- End Function
- Function FilesInDirectory(varDirectory)
- Dim fs, fo, x, varFileListing, varSep
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set fo = fs.GetFolder(varDirectory)
- varFileListing = ""
- varSep = ""
- For Each x In fo.files
- varFileListing = x.Name & varSep & varFileListing
- varSep = ","
- Next
- Set fo = Nothing
- Set fs = Nothing
- FilesInDirectory = varFileListing
- End Function
- Function GetExpectedBalance(varAccountID,varDate)
- varDate = ReturnDateDDMMMYYYY(varDate)
- varSelect = "SELECT dbo.fn_GetRentExpectedBalanceForDate('" & varDate & "','" & varAccountID & "','S') AS Balance"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- GetExpectedBalance = .Fields("Balance").Value
- .MoveNext
- Loop
- End With
- End Function
- Function GetAccountBalance(varAccountID,varDate)
- varDate = ReturnDateDDMMMYYYY(varDate)
- varSelect = "SELECT dbo.fn_GetRentBalanceAccountOrSubAccountForDate('" & varDate & "','" & varAccountID & "','S') AS Balance"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- GetAccountBalance = .Fields("Balance").Value
- .MoveNext
- Loop
- End With
- End Function
- Function ReturnDateDDMMMYYYY(varDateToConvert)
- DIM varRetval
- DIM varMonthDesc
- DIM varMonthNumber
- IF Len(varDateToConvert) > 0 Then
- varMonthNumber=Month(varDateToConvert)
- If varMonthNumber="1" Then
- varMonthDesc="Jan"
- Else
- If varMonthNumber="2" Then
- varMonthDesc="Feb"
- Else
- If varMonthNumber="3" Then
- varMonthDesc="Mar"
- Else
- If varMonthNumber="4" Then
- varMonthDesc="Apr"
- Else
- If varMonthNumber="5" Then
- varMonthDesc="May"
- Else
- If varMonthNumber="6" Then
- varMonthDesc="Jun"
- Else
- If varMonthNumber="7" Then
- varMonthDesc="Jul"
- Else
- If varMonthNumber="8" Then
- varMonthDesc="Aug"
- Else
- If varMonthNumber="9" Then
- varMonthDesc="Sep"
- Else
- If varMonthNumber="10" Then
- varMonthDesc="Oct"
- Else
- If varMonthNumber="11" Then
- varMonthDesc="Nov"
- Else
- If varMonthNumber="12" Then
- varMonthDesc="Dec"
- End If
- End If
- End If
- End If
- End If
- End If
- End If
- End If
- End If
- End If
- End If
- End If
- varRetval = CStr(Day(varDateToConvert)) + " " + varMonthDesc + " " + CStr(Year(varDateToConvert))
- Else
- varRetval = ""
- End If
- ReturnDateDDMMMYYYY = varRetval
- End Function
- Function ClearPromptedRentArrearsTable
- varSelect = "DELETE FROM RAGLAN_USR_Prompted_Arrears_Actions_T"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function ClearPromptedRentArrearsTableTMP
- varSelect = "DELETE FROM RAGLAN_USR_Prompted_Arrears_Actions_TMP_T"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function DirectDebitMOPs(varAccountID)
- varMOPCount = 0
- varSelect = "SELECT Count(*) AS MOPCount FROM Rent_AccountMOPs (NOLOCK) WHERE ID LIKE ('" & varAccountID & "**%') AND MOP IN ('10')"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varMOPCount = .Fields("MOPCount").Value
- .MoveNext
- Loop
- End With
- DirectDebitMOPs = varMOPCount
- End Function
- Function HousingBenefitMOPs(varAccountID)
- varMOPCount = 0
- varSelect = "SELECT Count(*) AS MOPCount FROM Rent_AccountMOPs (NOLOCK) WHERE ID LIKE ('" & varAccountID & "**%') AND MOP IN ('2')"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varMOPCount = .Fields("MOPCount").Value
- .MoveNext
- Loop
- End With
- HousingBenefitMOPs = varMOPCount
- End Function
- Function AgreementBeingKept(varAccountID,varAgreementID)
- varAgreementRef = varAccountID & "**" & varAgreementID
- varAgrID = ""
- varVariance = 0
- varTodaysDate = ReturnDateDDMMMYYYY(Date)
- varSelect = "SELECT ID, StartDate, EndDate FROM Rent_Agreements (NOLOCK) WHERE ID = '" & varAgreementRef & "' AND (StartDate <= '" & varTodaysDate & "' AND (EndDate > '" & varTodaysDate & "' OR EndDate IS NULL))"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varAgrID = .Fields("ID").Value
- .MoveNext
- Loop
- End With
- If varAgrID <> "" Then
- varSelect = "SELECT dbo.fn_GetRentAgreementVarianceAccountOrSubAccountForDate('" & varTodaysDate & "','" & varAccountID & "','S','" & varAgreementID & "') AS VarianceAmount"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varVariance = .Fields("VarianceAmount").Value
- .MoveNext
- Loop
- End With
- End If
- AgreementBeingKept = varVariance
- End Function
- Function AgreementBeingKeptOLD(varAccountID,varAgreementID)
- varAgreementRef = varAccountID & "**" & varAgreementID
- varAgrID = ""
- varVariance = 0
- varSelect = "SELECT ID, StartDate, EndDate FROM Rent_Agreements (NOLOCK) WHERE ID = '" & varAgreementRef & "' AND (StartDate <= " & Date & " AND (EndDate > " & Date & " OR EndDate IS NULL))"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varAgrID = .Fields("ID").Value
- .MoveNext
- Loop
- End With
- If varAgrID <> "" Then
- varSelect = "SELECT dbo.fn_GetRentAgreementVarianceAccountOrSubAccountForDate('" & Date & "','" & varAccountID & "','S','" & varAgreementID & "') AS VarianceAmount"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varVariance = .Fields("Variance").Value
- .MoveNext
- Loop
- End With
- End If
- AgreementBeingKept = varVariance
- End Function
- Function AgreementInForce(varAccountID,varAgreementID)
- varAgreementRef = varAccountID & "**" & varAgreementID
- varTodaysDate = Date
- varTodaysDate = ReturnDateDDMMMYYYY(varTodaysDate)
- varAgrID = ""
- varSelect = "SELECT ID FROM Rent_Agreements (NOLOCK) WHERE ID = '" & varAgreementRef & "' AND (StartDate <= '" & varTodaysDate & "' AND (EndDate > '" & varTodaysDate & "' OR EndDate IS NULL))"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varAgrID = .Fields("ID").Value
- .MoveNext
- Loop
- End With
- AgreementInForce = varAgrID
- End Function
- Function PromptedArrearsActionDetailsUpdate(varAccountID,varCurMonLevel,varDateCurMonLevelSet,varBalanceAtTimeOfSuggestion,varRecommendedActionID,varDateOfLastRun,varOwningBodyID,varAreaOfficeID,varSchemeID,varHousingOfficerID,varAssetID,varGroupID,varMopHB,varAddressID,varMopDD,varSpPaymentRecvd,varDateSpPaymentRecvd,varNettRent,varCurrentBenefitValue,varActualBalance,varBalanceLastPeriodIncBen,varBalanceLastPeriod,varAgreementID,varAgreementNumber)
- varDateOfLastRun = ReturnDateDDMMMYYYY(varDateOfLastRun)
- varDateCurMonLevelSet = ReturnDateDDMMMYYYY(varDateCurMonLevelSet)
- If LEN(varAgreementID) > 0 Then
- varAgreementAmount = AgreementValue(varAgreementID)
- varAgreementBalance = AgreementBalance(varAccountID,varAgreementNumber)
- Else
- varAgreementAmount = 0
- varAgreementBalance = 0
- End If
- varSelect = "INSERT INTO RAGLAN_USR_Prompted_Arrears_Actions_T (AccountID,CurrentMonitoringLevel,DateCurrentMonitoringLevelSet,BalanceAtTimeOfSuggestion,RecommendedAction,DateOfLastRun,OwningBodyID,AreaOfficeID,SchemeID,HousingOfficerID,AssetID,GroupID,HBFlag,AddressID,DDFlag,SpPaymentRecvd,DateSpPaymentRecvd,NettRent,CurrentBenefitValue,ActualBalanceAtTimeOfSuggestion,PreviousPeriodBalance,ActualPreviousPeriodBalance,AgreementID,AgreementAmount,AgreementBalance) VALUES('" & varAccountID & "','" & varCurMonLevel & "','" & varDateCurMonLevelSet & "'," & varBalanceAtTimeOfSuggestion & ",'" & varRecommendedActionID & "','" & varDateOfLastRun & "'," & varOwningBodyID & "," & varAreaOfficeID & "," & varSchemeID & "," & varHousingOfficerID & "," & varAssetID & "," & varGroupID & "," & varMopHB & "," & varAddressID & "," & varMopDD & "," & varSpPaymentRecvd & ",'" & varDateSpPaymentRecvd & "'," & varNettRent & "," & varCurrentBenefitValue & "," & varActualBalance & "," & varBalanceLastPeriodIncBen & "," & varBalanceLastPeriod & ",'" & varAgreementID & "'," & varAgreementAmount & "," & varAgreementBalance & ")"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function PromptedArrearsActionDetailsUpdateTMP(varAccountID,varCurMonLevel,varDateCurMonLevelSet,varBalanceAtTimeOfSuggestion,varRecommendedActionID,varDateOfLastRun,varOwningBodyID,varAreaOfficeID,varSchemeID,varHousingOfficerID,varAssetID,varGroupID,varMopHB,varAddressID,varMopDD,varSpPaymentRecvd,varDateSpPaymentRecvd,varNettRent,varCurrentBenefitValue,varActualBalance,varBalanceLastPeriodIncBen,varBalanceLastPeriod,varAgreementID,varAgreementNumber)
- varDateOfLastRun = ReturnDateDDMMMYYYY(varDateOfLastRun)
- varDateCurMonLevelSet = ReturnDateDDMMMYYYY(varDateCurMonLevelSet)
- If LEN(varAgreementID) > 0 Then
- varAgreementAmount = AgreementValue(varAgreementID)
- varAgreementBalance = AgreementBalance(varAccountID,varAgreementNumber)
- Else
- varAgreementAmount = 0
- varAgreementBalance = 0
- End If
- varSelect = "INSERT INTO RAGLAN_USR_Prompted_Arrears_Actions_TMP_T (AccountID,CurrentMonitoringLevel,DateCurrentMonitoringLevelSet,BalanceAtTimeOfSuggestion,RecommendedAction,DateOfLastRun,OwningBodyID,AreaOfficeID,SchemeID,HousingOfficerID,AssetID,GroupID,HBFlag,AddressID,DDFlag,SpPaymentRecvd,DateSpPaymentRecvd,NettRent,CurrentBenefitValue,ActualBalanceAtTimeOfSuggestion,PreviousPeriodBalance,ActualPreviousPeriodBalance,AgreementID,AgreementAmount,AgreementBalance) VALUES('" & varAccountID & "','" & varCurMonLevel & "','" & varDateCurMonLevelSet & "'," & varBalanceAtTimeOfSuggestion & ",'" & varRecommendedActionID & "','" & varDateOfLastRun & "'," & varOwningBodyID & "," & varAreaOfficeID & "," & varSchemeID & "," & varHousingOfficerID & "," & varAssetID & "," & varGroupID & "," & varMopHB & "," & varAddressID & "," & varMopDD & "," & varSpPaymentRecvd & ",'" & varDateSpPaymentRecvd & "'," & varNettRent & "," & varCurrentBenefitValue & "," & varActualBalance & "," & varBalanceLastPeriodIncBen & "," & varBalanceLastPeriod & ",'" & varAgreementID & "'," & varAgreementAmount & "," & varAgreementBalance & ")"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function TestWord
- dim objWord, objdoc
- set objWord = createobject("Word.Application")
- objword.visible = true
- end function
- '--------Prompted Arrears Functions END-----------
- '######## SMS Functions #########
- Function GetUserCodeDescription(CodeID)
- varSelect = "select left(Description_VC,1) as MatScore from Shared_User_Defined_Codes_T where Code_ID = " & CodeID
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- GetUserCodeDescription = .Fields("MatScore").Value
- .MoveNext
- Loop
- End With
- End Function
- Function InsertIntousrSchemeAccStatusChangeT (varSchemeID,varServiceID,varOwnerUserID,varTodaysDate)
- varSelect = "insert into usr_RAG_SchemeAcc_Status_Change_Tasking_T (Scheme_ID,Service_ID,User_ID,Date_Sent_DT) values (" & varSChemeID & "," & varServiceID & "," & varOwnerUserID & ",'" & varTodaysDate & "')"
- with SQLConnection.Execute(varSelect)
- End With
- End Function
- Function SMS_Get_ContactID(TargetNumber)
- Dim varExecute
- if left(TargetNumber,4) = "0044" then TargetNumber = "0" & Mid(TargetNumber,5,len(TargetNumber))
- varExecute = "SELECT top 1 LEFT(MainLKUPID,CHARINDEX('*',MainLKUPID)-1) Contact_ID FROM [CRM_SYS_CTI_References_INF_V] WHERE CTI_Reference = '" & TargetNumber & "'"
- SMS_Get_ContactID = GetSQLColumns(varExecute, "")
- End function
- Function SMS_Get_ContactGroupID(TargetNumber)
- Dim varExecute
- if left(TargetNumber,4) = "0044" then TargetNumber = "0" & Mid(TargetNumber,5,len(TargetNumber))
- if left(TargetNumber,2) = "44" then TargetNumber = "0" & Mid(TargetNumber,3,len(TargetNumber))
- varExecute = "SELECT top 1 dbo.fn_Field(MainLKUPID,'*',2) Group_ID FROM [CRM_SYS_CTI_References_INF_V] WHERE dbo.fn_Field(MainLKUPID,'*',2) is not NULL AND CTI_Reference = '" & TargetNumber & "'"
- SMS_Get_ContactGroupID = GetSQLColumns(varExecute, "")
- End function
- Function SMS_Get_GroupContactID(TargetNumber)
- Dim varExecute
- if left(TargetNumber,4) = "0044" then TargetNumber = "0" & Mid(TargetNumber,5,len(TargetNumber))
- if left(TargetNumber,2) = "44" then TargetNumber = "0" & Mid(TargetNumber,3,len(TargetNumber))
- varExecute = "SELECT top 1 RIGHT(MainLKUPID,CHARINDEX('*',REVERSE(MainLKUPID))-1) GroupContact_ID FROM [CRM_SYS_CTI_References_INF_V] WHERE CTI_Reference = '" & TargetNumber & "'"
- SMS_Get_GroupContactID = GetSQLColumns(varExecute, "")
- End function
- Function SMS_Get_ContactRentBalance(TargetNumber)
- Dim ContactGroupID
- Dim varExecute
- if left(TargetNumber,4) = "0044" then TargetNumber = "0" & Mid(TargetNumber,5,len(TargetNumber))
- if left(TargetNumber,2) = "44" then TargetNumber = "0" & Mid(TargetNumber,3,len(TargetNumber))
- ContactGroupID = SMS_Get_ContactGroupID(TargetNumber)
- 'msgbox( ContactGroupID & "," & TargetNumber)
- if len(ContactGroupID) > 0 then
- varExecute = _
- "SELECT 'Your balance is ' + CAST(dbo.fn_GetRentBalanceAccountorSubaccountForDate(GETDATE(), ID, 'S') - dbo.fn_GetRentExpectedBalanceForDate(GETDATE(), ID, 'S') AS varchar) + ' on rent account ' + ID + '. Quote this if calling Ideal HA customer services on 0845 330 2325. Txt ? for all options.' AS MessageToReturn FROM Rent_Accounts WHERE (AccountEndDate IS NULL) and ContactDatabaseReference = " & ContactGroupID
- SMS_Get_ContactRentBalance = GetSQLColumns(varExecute, "")
- else SMS_Get_ContactRentBalance = "No balance available, txt ? for assistance"
- End if
- End Function
- Function SMS_Get_Mobile_From_Request(Request_ID)
- dim varExecute
- varExecute = _
- "SELECT top 1 CTI_Reference FROM [CRM_SYS_CTI_References_INF_V] left join Repairs_requests_T on Repairs_requests_T.RequestedBYContacts_ID = RIGHT(MainLKUPID,CHARINDEX('*',REVERSE(MainLKUPID))-1) where CTI_Reference like '07%' and Request_ID = " & Request_ID
- SMS_Get_Mobile_From_Request = GetSQLColumns(varExecute, "")
- End Function
- Function SMS_First_Word( First_Word_Caps , Mess)
- ' Swap a few obvious errors...
- 'Swap dot for ?
- if left(First_Word_Caps,1) = "." then
- First_Word_Caps = "?" & Mid(First_Word_Caps, 2, len(First_Word_Caps))
- end if
- if First_Word_Caps = "??" then First_Word_Caps = "?"
- if left(First_Word_Caps,2) = "??" then First_Word_Caps = "?"
- if First_Word_Caps = "?C" then First_Word_Caps = "?CALL"
- if First_Word_Caps = "?CALLME" then First_Word_Caps = "?CALL"
- if First_Word_Caps = "?B" then First_Word_Caps = "?BAL"
- if First_Word_Caps = "?BALANCE" then First_Word_Caps = "?BAL"
- SMS_First_Word = Trim(First_Word_Caps)
- ' msgbox( ">" & First_Word_Caps & "<")
- End Function
- Function SMS_Inbox_Request( First_Word_Caps , Mess )
- dim OutMess
- OutMess = ""
- ' Ask where the parameters are..
- if First_Word_Caps = "ASB" and len(Trim(Mess)) < 5 then OutMess = "Please include details eg- ASB LOUD MUSIC IN MY CLOSE AFTER MIDNIGHT"
- if First_Word_Caps = "REP" and len(Trim(Mess)) < 5 then OutMess = "Please include details eg- REP BATHROOM TAP NOW LEAKING CONSTANTLY"
- if First_Word_Caps = "SUG" and len(Trim(Mess)) < 5 then OutMess = "Please include details eg- SUG LONGER OPENING ON SATURDAY UNTIL 1PM WOULD BE GOOD"
- if First_Word_Caps = "COMP" and len(Trim(Mess)) < 5 then OutMess = "Please include details eg- COMP CONTRACTOR DID NOT CLEANUP AFTER RECENT REPAIR"
- if First_Word_Caps = "BID" and len(Trim(Mess)) < 5 then OutMess = "Please include details eg- BID P108090 A719 (where P108090 is a bid & 719 is your application no"
- ' Screen out invalid stuff...
- IF InStr("|?|?BAL|?CALL|ASB|REP|SUG|COMP|" , "|" & First_Word_Caps & "|") = 0 then
- OutMess = "Sorry, we did not understand your question. Pls text ? for help or ?CALL and we will call you back. We are here to help!"
- end if
- SMS_Inbox_Request = OutMess
- End Function
- Function GetSQLColumns(SQLString, Parms)
- GetSQLColumns = ""
- dim strConnection
- strConnection = SQLString
- With SQLConnection.Execute(strConnection)
- If Parms = "" then
- Do Until .EOF
- GetSQLColumns = GetSQLColumns & .Fields(0).Value
- .MoveNext
- Loop
- end if
- End With
- End Function
- Function SMS_Obtain_Basic_Details(TargetNumber)
- Dim ContactID
- Dim ContactDetails
- Dim GroupID
- Dim GroupDetails
- Dim VarExecute
- ContactID = SMS_Get_ContactID(TargetNumber)
- If len(ContactID) then
- ContactDetails = "Contact " & ContactID & " Details: "
- VarExecute = _
- "select (Formatted_Name_VC) + (case when SCL.Description_VC <> '' then ' ,Preferred Language ' + SCL.Description_VC else '' End) + (case when SCEA.Description_VC <> '' then ' ,Ethnic Origin ' + SCEA.Description_VC else '' End) + (case when SCR.Description_VC <> '' then ' ,Religion ' + SCR.Description_VC else '' End) + (Case when Date_of_Birth_DT is null then '' else ' , DOB ' + convert(varchar, Date_of_Birth_DT, 101 ) end) + (case when isnull(General_Notes_VC,'') = '' then '' else char(13) + char(10) + 'General Notes: ' + isnull(General_Notes_VC,'') End) + (case when isnull(General_warning_Message_VC,'') = '' then '' else char(13) + char(10) + 'WARNING MESSAGE: ' + isnull(General_warning_Message_VC,'') End) + (case when SCSO.Description_VC <> '' then ' ,Sexual Orientation ' + SCSO.Description_VC else '' End) from Contact_Contacts_T left join Shared_codes_T as SCL (nolock) on SCL.Code_ID = Preferred_Language_Code_ID left join Shared_codes_T as SCEA (nolock) on SCEA.Code_ID = Ethnic_Origin_A_Code_ID left join Shared_codes_T as SCR (nolock) on SCR.Code_ID = Religion_Code_ID left join Shared_codes_T as SCSO (nolock) on SCSO.Code_ID = Sexual_Orientation_ID where Contact_Id = " & ContactID
- ContactDetails = ContactDetails & GetSQLColumns(varExecute, "")
- End If
- GroupID = SMS_Get_ContactGroupID(TargetNumber)
- If len(GroupID) then
- If len(ContactDetails) > 0 then ContactDetails = ContactDetails & vbcrlf & vbcrlf
- ContactDetails = ContactDetails & "Group " & GroupID & " Details: "
- VarExecute = _
- "select (Group_Name_VC) + (case when SCL.Description_VC <> '' then ' ,Preferred Language ' + SCL.Description_VC else '' End) + (case when SCEA.Description_VC <> '' then ' ,Ethnic Origin ' + SCEA.Description_VC else '' End) + (case when SCR.Description_VC <> '' then ' ,Religion ' + SCR.Description_VC else '' End) + (case when isnull(General_Notes_VC,'') = '' then '' else char(13)+ char(10) + 'General Notes: ' + isnull(General_Notes_VC,'') End) + (case when isnull(General_warning_Message_VC,'') = '' then '' else char(13)+ char(10) + 'WARNING MESSAGE: ' + isnull (General_warning_Message_VC,'') End) + (case when isnull(dbo.fn_Contact_Group_Vulnerabilities(Group_ID),'') = '' then '' else char(13)+ char(10) + 'Vulnerabilities/Disabilities: ' + isnull(dbo.fn_Contact_Group_Vulnerabilities(Group_ID),'') End) + (case when isnull(Rent_Accounts.ID,'') = '' then '' else char(13)+ char(10) + char(13)+ char(10) + 'Current Tenant Rent Account: ' + isnull(Rent_Accounts.ID,'') + '; ' + Shared_Addresses_T.Formatted_Address_VC End) from Contact_Groups_T left join Shared_codes_T as SCL (nolock) on SCL.Code_ID = Group_Preferred_Language_Code_ID left join Shared_codes_T as SCEA (nolock) on SCEA.Code_ID = Group_Ethnic_Origin_A_Code_ID left join Shared_codes_T as SCR (nolock) on SCR.Code_ID = Group_Religion_Code_ID left join Rent_Accounts (nolock) on Rent_Accounts.ContactDatabaseReference = Group_ID and (Rent_Accounts.AccountEndDate is null or Rent_Accounts.AccountEndDate >= getdate()) left join Asset_Assets_T (nolock) on Rent_Accounts.MainAsset = Asset_Assets_T.asset_ID left JOIN Shared_Addresses_T ON Asset_Assets_T.Address_ID = Shared_Addresses_T.Address_ID where Group_Id = " & GroupID
- ContactDetails = "Known Texter " & TargetNumber & " details:" & chr(13) & chr(10) & chr(13) & chr(10) & ContactDetails & GetSQLColumns(varExecute, "")
- End If
- SMS_Obtain_Basic_Details = ContactDetails
- End Function
- Function SMSContactDetails(TargetNumber)
- Dim ContactID
- Dim ContactDetails
- Dim GroupID
- Dim GroupDetails
- Dim VarExecute
- ContactID = SMS_Get_ContactID(TargetNumber)
- If len(ContactID) then
- ContactDetails = "Contact " & ContactID & " Details: "
- VarExecute = _
- "select (Formatted_Name_VC) from Contact_Contacts_T where Contact_Id = " & ContactID
- ContactDetails = ContactDetails & GetSQLColumns(varExecute, "")
- End If
- GroupID = SMS_Get_ContactGroupID(TargetNumber)
- If len(GroupID) then
- If len(ContactDetails) > 0 then ContactDetails = ContactDetails & vbcrlf & vbcrlf
- ContactDetails = ContactDetails & "Group " & GroupID & " Details: "
- VarExecute = _
- "SELECT dbo.Contact_Groups_T.Group_Name_VC + ', Current Tenant Address: ' + isnull(Shared_Addresses_T.Formatted_Address_VC, 'UNKNOWN') FROM dbo.Contact_Groups_T LEFT OUTER JOIN dbo.Rent_Accounts WITH (nolock) ON dbo.Rent_Accounts.ContactDatabaseReference = dbo.Contact_Groups_T.Group_ID AND (dbo.Rent_Accounts.AccountEndDate IS NULL OR dbo.Rent_Accounts.AccountEndDate >= GETDATE()) LEFT OUTER JOIN dbo.Asset_Assets_T WITH (nolock) ON dbo.Rent_Accounts.MainAsset = dbo.Asset_Assets_T.Asset_ID LEFT OUTER JOIN dbo.Shared_Addresses_T ON dbo.Asset_Assets_T.Address_ID = dbo.Shared_Addresses_T.Address_ID where Group_Id = " & GroupID
- ContactDetails = "Known Texter " & TargetNumber & " details:" & chr(13) & chr(10) & chr(13) & chr(10) & ContactDetails & GetSQLColumns(varExecute, "")
- End If
- SMSContactDetails = ContactDetails
- End Function
- Function SendSMSForHighPriorityOrder(OrderID)
- SQLConnection.Execute("Repairs_USR_Create_SMS_For_Order " & cstr(OrderID))
- End Function
- Function SendSMS(TargetNumber, MessageBody)
- Dim varExecute
- SendSMS = False
- varExecute = _
- "INSERT INTO Shared_SMS_Outbox_T (Status_ID,Recipient_VC,Message_VC,Sent_User_ID) VALUES(0,'" & TargetNumber & "','" & MessageBody & "',1)"
- SQLConnection.Execute(varExecute)
- SendSMS = True
- end function
- function SQLExec(VarExecute)
- SQLConnection.Execute(varExecute)
- end function
- '################################
- function updateTracker(info, procID)
- dim strsql
- strsql = ("Exec usr_upd_WorkflowExecute '" & info & "', " & procID)
- with sqlconnection.execute(strsql)
- end with
- End function
- '---------------------------------------PIR Import Functions-------------------------
- Function createImageRef(Asset)
- dim strsql
- strsql = ("Select dbo.fn_USR_createImagePath(" & Asset & ")")
- with sqlconnection.execute(strsql)
- do until .eof
- createImageRef = .fields(0)
- .movenext
- loop
- end with
- End Function
- Function assetType(Asset)
- dim strsql
- strsql =("Select Asset_Type_ID from Asset_Assets_T with (Nolock) where Asset_ID = " & Asset)
- with sqlconnection.execute(strsql)
- do until .eof
- assetType = .fields(0)
- .movenext
- loop
- end with
- End Function
- Function getOccurrence(Asset, Attr)
- dim strsql
- strsql = ("Exec sp_getAttributeOccurrence " & Asset & "," & Attr)
- with sqlconnection.execute(strsql)
- do until .eof
- getOccurrence = .fields(0)
- .movenext
- loop
- End With
- End Function
- Function insertElectricalData(File)
- Dim strSQL, objApp, objWkbk, intRow, Ass, certDt, certNo, CertType, WO, sqlDEL, Status
- sqlDEL = ("Delete from WF_USR_ElectricalImport_T")
- with sqlconnection.execute(sqlDEL)
- end with
- set objApp = createObject("Excel.Application")
- set objWkbk = objApp.Workbooks.Open(File)
- intRow = 2
- do until objApp.cells(intRow, 2) = ""
- Ass = objApp.cells(intRow, 1).Value
- certDt = objApp.cells(intRow, 2).Value
- certNo = objApp.cells(intRow, 3).Value
- certType = objApp.cells(intRow, 4).Value
- Status = objApp.cells(intRow, 5).value
- WO = objApp.cells(intRow, 6).Value
- if left(Status, 3) = "Sat" then
- Status = 2328
- else
- Status = 2329
- end if
- strSQL = "Insert into WF_USR_ElectricalImport_T (AssetRef, CertificateDate, CertificateNumber, CertType, WorksOrder, StatusID) Values "
- strSQL = strSQL & "(" & Ass & ", '" & certDt & "','" & certNo & "','" & certType & "'," & WO & ", " & Status & ")"
- 'msgbox(strSQL)
- if Ass <> "" then
- with sqlconnection.execute(strSQL)
- end with
- end if
- intRow = intRow + 1
- loop
- objWkbk.Close
- objApp.quit
- End Function
- '--------------------------------------------------------------------------------------------------
- '------------------------------Wessex Import Functions-------------------------------
- Function updateWessexRequest(Req, Job)
- dim strSQL
- strSQL = ("Update WF_USR_WessexImport_T set RequestID = " & Req & " where JobRef = '" & Job & "'")
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function updateWessexAsset(Asset, Job)
- dim strSQL
- strSQL = ("Update WF_USR_WessexImport_T set AssetID = '" & Asset & "' where jobref = '" & Job & "'")
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function getAssetID(Addr, Pcode)
- Dim strSQL
- strSQL = ("Select dbo.getAssetFromAddress('" & Left(Addr, 20) & "','" & Pcode & "')")
- with sqlconnection.execute(strSQL)
- do until .eof
- getAssetID = .fields(0)
- .movenext
- loop
- end with
- End Function
- Function wessexDataImport(file)
- Dim strSQL, objApp, objWkbk, intRow, Job, LogDate, Pri, trade, Desc, Address, Postcode, sqlDEL
- sqlDEL = ("Delete from WF_USR_WessexImport_T")
- with sqlconnection.execute (sqlDEL)
- end with
- set objApp = createObject("Excel.Application")
- set objWkbk = objApp.Workbooks.Open(file)
- intRow = 2
- do until objApp.cells(intRow, 2) = ""
- Job = objApp.cells(intRow, 1).value & "/" & objApp.cells(intRow, 2).Value
- LogDate = objApp.cells(intRow, 4).value & " " & Left(objApp.cells(intRow, 5).Value, 2) & ":" & Right(objApp.cells(intRow, 5), 2)
- Pri = objApp.cells(intRow, 8).value
- trade = objApp.cells(intRow, 18).value
- Desc = objApp.cells(intRow, 10).value & " " & objApp.cells(intRow, 11).value & " " & objApp.cells(intRow, 12).value & " " & objApp.cells(intRow, 13).value
- Address = Replace(objApp.cells(intRow, 16).Value, "#", "$")
- Postcode = objApp.cells(intRow, 17).value
- trade = objApp.cells(intRow, 18).value
- strsql = ("insert into WF_USR_WessexImport_T (JobRef, LogDateTime, Priority, Trade, Description, Address, Postcode) Values ('" & Job & "','" & LogDate & "','" & Pri & "','" & Trade & "','" & Replace(Desc, "'", "@") & "','" & Replace(Address, "'", "@") & "','" & Postcode & "')")
- with sqlconnection.execute(strsql)
- end with
- intRow = intRow +1
- loop
- objWkbk.close
- objApp.quit
- End Function
- Function updateWessexNullRequest(Job)
- dim strSQL
- strSQL = ("Update WF_USR_WessexImport_T set RequestID = 0 where JobRef = '" & Job & "'")
- with SqlConnection.Execute(strSQL)
- end with
- end Function
- '---------------------------------------------------------------------------------------
- Function TestWord
- dim objWord, objdoc
- set objWord = createobject("Word.Application")
- objword.visible = true
- end function
- Function sendAuthNotification(WorksOrder)
- Dim strSQL
- strSQL = ("Exec RHA_USR_sendAuthoristionEmail " & WorksOrder)
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function updateElecTable(AssetID, Message)
- Dim strSQL
- strSQL = ("Update WF_USR_ElecCertImport_T set Update_VC = '" & Message & "' where Asset_ID = " & AssetID )
- With sqlConnection.execute(strSQL)
- End With
- End Function
- Function updateGasTable(AssetID, Message)
- Dim strSQL
- strSQL = ("Update WF_USR_GasCertImport_T set Update_VC = '" & Message & "' where Asset_ID = " & AssetID )
- With sqlConnection.execute(strSQL)
- End With
- End Function
- function importAsbestosData(file)
- Dim objExcel, objwkbk, intRow, AssetID, OccID, strSQL
- set objExcel = CreateObject("Excel.Application")
- set objwkbk = objExcel.Workbooks.Open(file)
- intRow = 2
- strsqla = ("Delete from WF_USR_AsbestosTracker_T")
- with sqlconnection.execute (strsqla)
- end with
- do until objExcel.cells(intRow,1) = ""
- AssetID = objExcel.Cells(intRow, 1).Value
- OccID = objExcel.Cells(intRow, 2).Value
- strSQL = ("Insert Into WF_USR_AsbestosTracker_T (AssetID, OccID) Values (" & AssetID & ",'" & OccID & "')")
- with sqlconnection.execute(strSQL)
- end with
- introw = introw + 1
- loop
- objwkbk.close
- objExcel.Quit
- End Function
- function importOccforDeletions(file)
- Dim objExcel, objwkbk, intRow, AssetID, OccID, strSQL
- set objExcel = CreateObject("Excel.Application")
- set objwkbk = objExcel.Workbooks.Open(file)
- intRow = 2
- do until objExcel.cells(intRow,1) = ""
- AssetID = objExcel.Cells(intRow, 1).Value
- OccID = objExcel.Cells(intRow, 2).Value
- strSQL = ("Insert Into RHA_USR_Occurrence_Deletions_T (AssetID, OccID) Values ('" & AssetID & "','" & OccID & "')")
- with sqlconnection.execute(strSQL)
- end with
- introw = introw + 1
- loop
- objwkbk.close
- objExcel.Quit
- End Function
- function importElecData(file)
- Dim objExcel, objwkbk, intRow, AssetID, certDate, certRef, certStatus, Comments, strSQL
- set objExcel = CreateObject("Excel.Application")
- set objwkbk = objExcel.Workbooks.Open(file)
- intRow = 2
- strsqla = ("Delete from WF_USR_ElecCertImport_T")
- with sqlconnection.execute (strsqla)
- end with
- do until objExcel.cells(intRow,1) = ""
- AssetID = objExcel.Cells(intRow, 1).Value
- certDate = objExcel.Cells(intRow, 2).Value
- certRef = objExcel.Cells(intRow, 3).Value
- if objExcel.Cells(intRow, 4).Value = "PASS" then
- certStatus = 2328
- else
- if objExcel.Cells(intRow, 4).Value = "FAIL" then
- certStatus = 2329
- Else
- certStatus = 0
- End If
- End If
- Comments = objExcel.Cells(intRow, 5).Value
- strSQL = ("Insert Into WF_USR_ElecCertImport_T (Asset_ID, CertDate, CertRef, CertStatus, Comments) Values (" & AssetID & ",'" & formatSQLDateTime(CDate(certDate)) & "','" & certRef & "'," & certStatus & ",'" & Comments & "')")
- with sqlconnection.execute(strSQL)
- end with
- introw = introw + 1
- loop
- objwkbk.close
- objExcel.Quit
- End Function
- function importGasData(file)
- Dim objExcel, objwkbk, intRow, AssetID, certDate, certRef, certStatus, Comments, strSQL
- set objExcel = CreateObject("Excel.Application")
- set objwkbk = objExcel.Workbooks.Open(file)
- intRow = 2
- strsqla = ("Delete from WF_USR_GasCertImport_T")
- with sqlconnection.execute (strsqla)
- end with
- do until objExcel.cells(intRow,1) = ""
- AssetID = objExcel.Cells(intRow, 1).Value
- certDate = objExcel.Cells(intRow, 2).Value
- certRef = objExcel.Cells(intRow, 3).Value
- if objExcel.Cells(intRow, 4).Value = "PASS" then
- certStatus = 1512
- else
- if objExcel.Cells(intRow, 4).Value = "FAIL" then
- certStatus = 1513
- Else
- certStatus = 0
- End If
- End If
- Comments = objExcel.Cells(intRow, 5).Value
- strSQL = ("Insert Into WF_USR_GasCertImport_T (Asset_ID, CertDate, CertRef, CertStatus, Comments) Values (" & AssetID & ",'" & formatSQLDateTime(CDate(certDate)) & "','" & certRef & "'," & certStatus & ",'" & Comments & "')")
- with sqlconnection.execute(strSQL)
- end with
- introw = introw + 1
- loop
- objwkbk.close
- objExcel.Quit
- End Function
- Function formatSQLDateTime(Date_dt)
- formatSQLDateTime = (Year(Date_dt) & "-" & Month(Date_dt) & "-" & Day(Date_dt) & " 00:00:00.000")
- End Function
- Function SendEmailbccSQL(Recip, bcc, Sndr, Subj, Msg, Prof)
- Dim strSQL
- Msg = replace(Msg,"'","")
- strSQL = ("exec msdb.dbo.sp_send_dbmail @profile_name = '" & Prof & "', @recipients = '" & Recip & "', @blind_copy_recipients = '" & bcc & "', @from_address = '" & Sndr & "', @subject = '" & Subj & "', @body = '" & Msg & "'")
- With sqlconnection.execute (strSQL)
- End With
- End Function
- Function SendEmailSQL(Recip, Sndr, cc, bcc, Subj, Msg, Prof)
- Dim strSQL
- 'msgbox "DEBUG - In SendEmailSQL"
- 'msgbox "DEBUG - Please ignore" & vbcrlf & vbcrlf & "EmailAddress - " & Recip & vbcrlf & "FromAddress - " & Sndr & vbcrlf & "CCAddress - " & cc & vbcrlf & "BCCAdress - " & bcc & vbcrlf & "Subject - " & Subj & vbcrlf & "Body - " & left(Msg,20) & vbcrlf & "Mail Profile - " & Prof
- Msg = replace(Msg,"'","")
- 'msgbox "New message body - " & Msg
- strSQL = ("exec msdb.dbo.sp_send_dbmail @profile_name = '" & Prof & "', @recipients = '" & Recip & "', @copy_recipients = '" & cc & "', @blind_copy_recipients = '" & bcc & "', @from_address = '" & Sndr & "', @subject = '" & Subj & "', @body = '" & Msg & "'")
- With sqlconnection.execute (strSQL)
- End With
- 'msgbox "DEBUG - sp_send_dbmail sent"
- End Function
- Function SendHTMLEmailSQL(Recip, Sndr, cc, bcc, Subj, Msg, Format, Prof)
- Dim strSQL
- Msg = replace(Msg,"'","")
- strSQL = ("exec msdb.dbo.sp_send_dbmail @profile_name = '" & Prof & "', @recipients = '" & Recip & "', @copy_recipients = '" & cc & "', @blind_copy_recipients = '" & bcc & "', @from_address = '" & Sndr & "', @subject = '" & Subj & "', @body = '" & Msg & "', @body_format = '" & Format & "'")
- With sqlconnection.execute (strSQL)
- End With
- End Function
- Function UpdateOwner(CaseID, Owner)
- Dim strSQL
- strSQL = ("Update WF_HPM_ComplaintsTracker_T set CaseOwner = " & Owner & " where Case_ID = " & CaseID)
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function UpdateCoOrd(CaseID, CoOrd)
- Dim strSQL
- strSQL = ("Update WF_HPM_ComplaintsTracker_T set CaseCoOrd = " & CoOrd &" where Case_ID = " & CaseID)
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function PANotified(CaseID)
- Dim strSQL
- strSQL = ("Update WF_HPM_ComplaintsTracker_T set Status = 3, LstUpdated = getdate() where Case_ID = " & CaseID)
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function CoOrdAdded(CaseID, CoOrd)
- Dim strSQL
- strSQL = ("Update WF_HPM_ComplaintsTracker_T set Status = 2, LstUpdated = getdate(), CaseCoOrd = " & CoOrd & " where Case_ID = " & CaseID)
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function NewComplaint(CaseID, Owner, CoOrd)
- Dim strSql
- strSQL = ("Insert Into WF_HPM_ComplaintsTracker_T (Case_ID, CaseOwner, CaseCoOrd) Values (" & CaseID & "," & Owner & "," & CoOrd & ")")
- with sqlconnection.execute(strSQL)
- end with
- End Function
- Function OpenDIP(Path)
- Dim ObjApp
- 'MsgBox path
- Set ObjApp = CreateObject("WScript.Shell")
- ObjApp.Exec Path
- End Function
- Function OpenDocumotive(IndexName, UniqueID, DatabasePath)
- Dim objShell, objRS
- Dim objFSO
- Set objRS = SQLConnection.Execute("SELECT DIPView_Exe_Location_VC FROM Shared_Options_Extended_T (NOLOCK) WHERE Options_Extended_ID = 1")
- If Not (objRS.BOF OR objRS.EOF) Then
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- ' to disable Imageviewer comment out the if statement below and uncomment the message box
- 'msgbox "Documotive unavailable"
- If objFSO.FileExists(objRS.Fields("DIPView_Exe_Location_VC").Value) Then
- Set objShell = CreateObject("WScript.Shell")
- 'MsgBox objRS.Fields("DIPView_Exe_Location_VC").Value & " -Live -search """ & IndexName & """ """ & CStr(UniqueID) & """ """ & DatabasePath & """"
- 'DatebasePath = "IDS://ragdoc/raglan housing"
- 'to switch between test and live
- 'objShell.Exec objRS.Fields("DIPView_Exe_Location_VC").Value & " -test -search """ & IndexName & """ """ & CStr(UniqueID) & """ """ & DatabasePath & """"
- objShell.Exec objRS.Fields("DIPView_Exe_Location_VC").Value & " -Live -search """ & IndexName & """ """ & CStr(UniqueID) & """ """ & DatabasePath & """"
- Set objShell = Nothing
- End If
- Set objFSO = Nothing
- objRS.Close
- End If
- Set objRS = Nothing
- End Function
- Function OpenDocumotiveInvoice(IndexName, UniqueID)
- Dim objShell
- Set objShell = CreateObject("WScript.Shell")
- 'MsgBox "\\ragdoc\documotive$\WorkflowViewer\ImageViewer.exe -search """ & IndexName & """ """ & CStr(UniqueID) & """"
- objShell.Exec "\\ragdoc\documotive$\WorkflowViewer\ImageViewer.exe -search """ & IndexName & """ """ & CStr(UniqueID) & """"
- Set objShell = Nothing
- End Function
- Function AccountLocked (AccountID)
- Dim StrSQL
- strSQL = ("Select cast(UserName as varchar(150)) from tempdb.dbo.sysmislocks where primarykeyvalue = " & AccountID & " and databasename = DB_NAME() and Username <> replace(System_User, 'RAGLAN\', '')")
- with sqlconnection.execute (strSQL)
- do until .eof
- AccountLocked = sentence(.fields(0))
- .movenext
- loop
- end with
- End Function
- Function BuildNonAccessTable
- 'Function that will build up the info in the Non Access table for the non access workflow
- dim nonAccess
- 'Build the SOR No Access Table
- nonAccess = ("EXEC WF_USR_NonAccess_SP")
- 'msgbox ("About to run the proc")
- with sqlconnection.execute(nonAccess)
- 'msgbox("Procedure Exec")
- end with
- End Function
- Function VMOccExtend(CaseID)
- Dim strSQL
- strSQL = ("Update WF_HPMVoidsTracker_T set OccExtended = 1 where Case_ID = " & CaseID)
- with sqlconnection.execute (strSQL)
- end with
- End Function
- Function VMMutualExch(CaseID)
- Dim strSQL
- strSQL = ("update WF_HPMVoidsTracker_T set MutualEx = 1 where Case_ID = " & CaseID)
- with sqlconnection.execute (strSQL)
- end with
- End Function
- Function VMForcedEntry(caseID, Completion)
- Dim strSQL
- strSQL = ("Update WF_HPMVoidsTracker_T set ForcedEntry = '" & Completion & "' where Case_ID = " & CaseID )
- with sqlconnection.execute (strSQL)
- end with
- End Function
- Function UpdateHSCDoc(CaseID)
- Dim strSQL
- strSQL = ("Update WF_HPMVoidsTracker_T Set HSCStart = 1 where Case_ID = " & CaseID)
- With sqlconnection.execute (strSQL)
- End With
- End Function
- Function UpdateAnalCode(CaseID, Analysis)
- Dim strSQL
- strSQL = ("update WF_HPMVoidsTracker_T set PriorityCode_ID = " & Analysis & " where Case_ID = " & CaseID)
- with sqlconnection.execute (strSQL)
- end with
- End Function
- Function CaseStatusReason(CaseID)
- Dim strSQL
- strSQL = ("select Description_VC from Shared_PC_Processes_T as SPP with (nolock) inner join Shared_Codes_T as Reason with (nolock) on Reason.Code_ID=SPP.Status_Reason_ID where Process_ID = " & CaseID)
- with sqlconnection.execute(strSQL)
- do until .eof
- CaseStatusReason = sentence(.fields(0))
- .movenext
- loop
- End With
- End Function
- Function VoidsStatusChange(Case_ID, Status_ID)
- Dim strSQL
- strSQL = ("Update WF_HPMVoidsTracker_T set Status_ID = " & Status_ID & " where case_ID = " & Case_ID)
- with sqlconnection.execute(strSQL)
- end with
- End Function
- 'Stamps the Voids Tracker table to state that the new case tasks have been generated
- Function NewVoidsCase (Case_ID, Status_ID, Entry)
- Dim strSQL
- strSQL = ("insert into WF_HPMVoidsTracker_T (Case_ID, CreationTask, Status_ID, ForcedEntry) Values (" & Case_ID & ", getdate(), " & Status_ID & ", " & Entry & ")")
- with sqlconnection.execute(strSQL)
- End With
- End Function
- 'Stamps the Voids Tracker table to state that the Hand Over task has been generated
- Function VoidsHandOver (Case_ID)
- Dim strSQL
- strSQL = ("update WF_HPMVoidsTracker_T set HandOver = 1 where case_id = " & Case_ID)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- 'Will stamp the Voids Tracker table to say that the task that generates when the keys have been returned has been completed.
- Function VoidsKeyReturn (Case_ID)
- Dim strSQL
- strSQL = ("update WF_HPMVoidsTracker_T set KeyReturned = 1 where case_id = " & Case_ID)
- With sqlconnection.execute(strSQL)
- End With
- End Function
- Function CreateElecFile(File)
- Dim fso, txtstream
- Set fso = CreateObject("Scripting.FileSystemObject")
- 'msgbox File
- File = cstr(File)
- set txtstream = fso.CreateTextFile(File,True)
- End Function
- 'Create the file for the gas extract
- Function CreateGasFile(File)
- Dim fso, txtstream
- Set fso = CreateObject("Scripting.FileSystemObject")
- 'msgbox File
- File = cstr(File)
- set txtstream = fso.CreateTextFile(File,True)
- End Function
- Function CreateAsbestosFile(File)
- Dim fso, txtstream
- Set fso = CreateObject("Scripting.FileSystemObject")
- File = cstr(File)
- set txtstream = fso.CreateTextFile(File,True)
- End Function
- Function addElecInfoToFile(FilePath, LineInfo)
- dim fso, txtstream
- set fso = CreateObject("Scripting.FileSystemObject")
- Set txtstream = fso.OpenTextFile(FilePath,8)
- txtstream.Write LineInfo
- txtstream.Close
- End Function
- 'Add the information to the gas extract
- Function addGasInfoToFile(FilePath, LineInfo)
- dim fso, txtstream
- set fso = CreateObject("Scripting.FileSystemObject")
- Set txtstream = fso.OpenTextFile(FilePath,8)
- txtstream.Write LineInfo
- txtstream.Close
- End Function
- 'Update the RHA_ContractorsTracker_T table with the value supplied
- 'Created by KS 13/03/2010
- Function UpdateContractorTracker(Contractor)
- Dim strSQL
- strSQL = ("insert into RHA_ContractorsTracker_T (Contractor_ID) Values (" & Contractor & ")")
- with sqlconnection.execute (strSQL)
- End With
- End Function
- 'Update the RHA_ContractorsTracker_T table with the value supplied
- 'Created by KS 13/03/2010
- Function UpdateContractorTracker(Contractor)
- Dim strSQL
- strSQL = ("insert into RHA_ContractorsTracker_T (Contractor_ID) Values (" & Contractor & ")")
- with sqlconnection.execute (strSQL)
- End With
- End Function
- 'Convert date entered into DD/MM/YYYY format for date conversion purposes
- 'Created by KS 20/11/09
- function convertDate(Date_dt)
- ConvertDate = (Day(date_Dt) & "/" & Month(Date_DT) & "/" & Year(Date_Dt))
- End Function
- function GetOrderStatus(WO_ID)
- with sqlconnection.execute("SELECT Status_ID FROM Repairs_Works_Orders_T with(nolock) WHERE WorksOrder_ID = " & WO_ID)
- do until .eof
- GetOrderStatus= sentence(.fields(0))
- .movenext
- loop
- end with
- end function
- 'function that will write back the information of when a workflow was last run (primary use with manual flows)
- 'Create by KS 05/08/2009
- Function StampWorkflowRanTable(WF_Desc, Outcome, User)
- dim strSQL
- strSQL = ("EXEC RHA_INSERT_WF_P '" + WF_Desc + "', '" + Outcome + "', '" + User + "'")
- 'msgbox strSQL
- with sqlconnection.execute (strSQL)
- end with
- end function
- FUNCTION UserRoleForAppointments(UserID)
- UserRoleForAppointments = 0
- with sqlconnection.execute("SELECT count(Role_ID) FROM dbo.Shared_User_Roles_T with (nolock) WHERE (Role_ID IN (9, 10)) AND User_ID = " & UserID)
- If Not .eof AND Not .bof Then
- UserRoleForAppointments = .fields(0)
- .close
- End IF
- end with
- END FUNCTION
- FUNCTION DesignatedAuthoriser(AuthoriserID)
- DesignatedAuthoriser = 0
- with sqlconnection.execute("select count(Authorisation_ID) from dbo.RHA_AppointmentsExtract_V with (nolock) where Authorisation_ID = " & AuthoriserID)
- If Not .eof AND Not .bof Then
- DesignatedAuthoriser= .fields(0)
- .close
- End IF
- end with
- END FUNCTION
- function GetGroupVul(GroupID)
- dim strResult
- with sqlconnection.execute("SELECT Vulnerability_Code_ID AS Vul_ID FROM Contact_Group_Vulnerabilities_T with (nolock) WHERE Group_ID = " & GroupID)
- do until .eof
- if not isnull(.fields(0)) then
- strResult = .fields(0)
- end if
- .movenext
- loop
- end with
- GetGroupVul= strResult
- end function
- function GetContractorCode(WO_ID)
- with sqlconnection.execute("SELECT Contractor_ID FROM Repairs_Works_Orders_T with (nolock) WHERE WorksOrder_ID = " & WO_ID)
- do until .eof
- GetContractorCode= sentence(.fields(0))
- .movenext
- loop
- end with
- end function
- Function SQLPropertyHasAsbestosXMLOLD(AssetID)
- Dim varDateFitted
- Dim strCommand
- Dim varAsbestosText
- Dim varTmp
- Dim varLocation
- Dim varFloorLevel
- Dim varComments
- varDateFitted = 9
- varAsbestosText = ""
- strCommand = "SELECT Occurrence_ID AS OccurrenceID, Asset_ID AS AssetID, Attribute_ID AS AttributeID, CASE WHEN Fitted_Renewed_Date_DT <= '31 DEC 1995' Then '1' Else '0' END AS FittedRenewDate FROM Asset_Attribute_Occurrences_T with (nolock) WHERE Attribute_ID = 208 AND Asset_ID = " & AssetID
- ' msgbox (strCommand)
- With sqlconnection.execute (strCommand)
- If Not .eof AND Not .bof Then
- varDateFitted = (.Fields("FittedRenewDate").Value)
- .Close
- End If
- End With
- If varDateFitted = 9 Then
- SQLPropertyHasAsbestosXML = "ADVISORY:- There MAY be Asbestos in this property. If any suspected materials are found STOP WORK IMMEDIATELY and contact the Administration Team."
- Else
- If varDateFitted = 1 Then
- strCommand = "SELECT Asset_Assets_T.Asset_ID AS AssetID, Asset_Attribute_Occurrences_T.Attribute_ID AS AttributeID, ISNULL(FLOORLEVEL.Description_VC,'') AS FloorLevel, ISNULL(Shared_Codes_T.Description_VC,'') AS Location, ISNULL(Asset_Attribute_Occurrences_T.Comment_Lines_VC,'') AS Comments, ISNULL(ASBESTOSTYPE.Description_VC,'') AS AsbestosType FROM Asset_Assets_T with (nolock) INNER JOIN Asset_Attribute_Occurrences_T with (NOLOCK) ON Asset_Assets_T.Asset_ID = Asset_Attribute_Occurrences_T.Asset_ID LEFT JOIN Shared_User_Defined_Codes_T FLOORLEVEL with (NOLOCK) ON FLOORLEVEL.Code_ID = Asset_Attribute_Occurrences_T.Group_ID LEFT JOIN Shared_Codes_T with (NOLOCK) ON Shared_Codes_T.Code_ID = Asset_Attribute_Occurrences_T.Location_ID INNER JOIN Asset_Attribute_Occurrence_User_Data_T USERDATA with (NOLOCK) ON Asset_Attribute_Occurrences_T.Occurrence_ID = USERDATA.Occurrence_ID LEFT JOIN Shared_User_Defined_Codes_T ASBESTOSTYPE with (NOLOCK) ON ASBESTOSTYPE.Code_ID = USERDATA.User_Code_3_ID WHERE Asset_Attribute_Occurrences_T.Attribute_ID=253 AND Asset_Assets_T.Asset_ID = " & AssetID
- With sqlconnection.execute (strCommand)
- Do Until .EOF
- varFloorLevel = (.Fields("FloorLevel").Value)
- varLocation = (.Fields("Location").Value)
- varComments = (.Fields("Comments").Value)
- varAsbestosType = (.Fields("AsbestosType").Value)
- varTmp = ""
- If varFloorLevel<>"" Then
- varTmp = varFloorLevel
- End If
- If varLocation<>"" Then
- If varTmp<>"" Then
- varTmp = varTmp & " : " & varLocation
- Else
- varTmp = varLocation
- End If
- End If
- If varComments<>"" Then
- If varTmp<>"" Then
- varTmp = varTmp & " : " & varComments
- Else
- varTmp = varComments
- End If
- End If
- If varAsbestosType<>"" Then
- If varTmp<>"" Then
- varTmp = varTmp & ". Asbestos Type: " & varAsbestosType
- Else
- varTmp = varAsbestosType
- End If
- End If
- If varTmp<>"" Then
- If varAsbestosText <> "" Then
- varAsbestosText = varAsbestosText & "|" & varTmp
- Else
- varAsbestosText = varTmp
- End If
- End If
- .MoveNext
- Loop
- End With
- End If
- If varDateFitted = 1 AND varAsbestosText <> "" Then
- ' SQLPropertyHasAsbestosXML = Replace(varAsbestosText,"|",vbcrlf)
- SQLPropertyHasAsbestosXML = "WARNING:- There is Asbestos in this property. Contact the Administration Team before starting work."
- Else
- If varDateFitted = 1 AND varAsbestosText = "" Then
- SQLPropertyHasAsbestosXML = "ADVISORY:- There MAY be Asbestos in this property. If any suspected materials are found STOP WORK IMMEDIATELY and contact the Administration Team."
- Else
- SQLPropertyHasAsbestosXML = "Due to the Build/Refurb date this property is unlikely to contain asbestos."
- End If
- End If
- End If
- strcommand = "select dbo.fn_XML_Safe_Text('" & SQLPropertyHasAsbestosXML & "')"
- With SQLConnection.Execute(strcommand)
- do until .eof
- SQLPropertyHasAsbestosXML = .fields(0)
- exit do
- loop
- End With
- End Function
- Function SQLPropertyHasAsbestosXML(AssetID)
- Dim varDateFitted
- Dim strCommand
- Dim varAsbestosText
- Dim varTmp
- Dim varLocation
- Dim varFloorLevel
- Dim varComments
- varDateFitted = 9
- varAsbestosText = ""
- strCommand = "SELECT Occurrence_ID AS OccurrenceID, Asset_ID AS AssetID, Attribute_ID AS AttributeID, CASE WHEN Fitted_Renewed_Date_DT <= '31 DEC 1999' Then '1' Else '0' END AS FittedRenewDate FROM Asset_Attribute_Occurrences_T with (nolock) WHERE Attribute_ID = 208 AND Asset_ID = " & AssetID
- ' msgbox (strCommand)
- With sqlconnection.execute (strCommand)
- If Not .eof AND Not .bof Then
- varDateFitted = (.Fields("FittedRenewDate").Value)
- .Close
- End If
- End With
- If varDateFitted = 9 Then
- SQLPropertyHasAsbestosXML = "WARNING:- This property may have ASBESTOS containing materials as advised in a general notice to yourselves. If any suspected materials are found PLEASE STOP WORK IMMEDIATELY and contact STONEWATER on 01908 628092."
- Else
- If varDateFitted = 1 Then
- strCommand = "SELECT Asset_Assets_T.Asset_ID AS AssetID, Asset_Attribute_Occurrences_T.Attribute_ID AS AttributeID, ISNULL(FLOORLEVEL.Description_VC,'') AS FloorLevel, ISNULL(Shared_Codes_T.Description_VC,'') AS Location, ISNULL(Asset_Attribute_Occurrences_T.Comment_Lines_VC,'') AS Comments, ISNULL(ASBESTOSTYPE.Description_VC,'') AS AsbestosType FROM Asset_Assets_T with (nolock) INNER JOIN Asset_Attribute_Occurrences_T with (NOLOCK) ON Asset_Assets_T.Asset_ID = Asset_Attribute_Occurrences_T.Asset_ID LEFT JOIN Shared_User_Defined_Codes_T FLOORLEVEL with (NOLOCK) ON FLOORLEVEL.Code_ID = Asset_Attribute_Occurrences_T.Group_ID LEFT JOIN Shared_Codes_T with (NOLOCK) ON Shared_Codes_T.Code_ID = Asset_Attribute_Occurrences_T.Location_ID INNER JOIN Asset_Attribute_Occurrence_User_Data_T USERDATA with (NOLOCK) ON Asset_Attribute_Occurrences_T.Occurrence_ID = USERDATA.Occurrence_ID LEFT JOIN Shared_User_Defined_Codes_T ASBESTOSTYPE with (NOLOCK) ON ASBESTOSTYPE.Code_ID = USERDATA.User_Code_3_ID WHERE Asset_Attribute_Occurrences_T.Attribute_ID=253 AND Asset_Assets_T.Asset_ID = " & AssetID
- With sqlconnection.execute (strCommand)
- Do Until .EOF
- varFloorLevel = (.Fields("FloorLevel").Value)
- varLocation = (.Fields("Location").Value)
- varComments = (.Fields("Comments").Value)
- varAsbestosType = (.Fields("AsbestosType").Value)
- varTmp = ""
- If varFloorLevel<>"" Then
- varTmp = varFloorLevel
- End If
- If varLocation<>"" Then
- If varTmp<>"" Then
- varTmp = varTmp & " : " & varLocation
- Else
- varTmp = varLocation
- End If
- End If
- If varComments<>"" Then
- If varTmp<>"" Then
- varTmp = varTmp & " : " & varComments
- Else
- varTmp = varComments
- End If
- End If
- If varAsbestosType<>"" Then
- If varTmp<>"" Then
- varTmp = varTmp & ". Asbestos Type: " & varAsbestosType
- Else
- varTmp = varAsbestosType
- End If
- End If
- If varTmp<>"" Then
- If varAsbestosText <> "" Then
- varAsbestosText = varAsbestosText & "|" & varTmp
- Else
- varAsbestosText = varTmp
- End If
- End If
- .MoveNext
- Loop
- End With
- End If
- If varDateFitted = 1 AND varAsbestosText <> "" Then
- ' SQLPropertyHasAsbestosXML = Replace(varAsbestosText,"|",vbcrlf)
- SQLPropertyHasAsbestosXML = "WARNING:- There are ASBESTOS materials contained within this property. You must access the relevant Asbestos Register to assess if the asbestos materials will affect your work. If you have any issue with accessing this information please contact STONEWATER on 01908 628092."
- Else
- If varDateFitted = 1 AND varAsbestosText = "" Then
- SQLPropertyHasAsbestosXML = "WARNING:- This property may have ASBESTOS containing materials as advised in a general notice to yourselves. If any suspected materials are found PLEASE STOP WORK IMMEDIATELY and contact STONEWATER on 01908 628092."
- Else
- SQLPropertyHasAsbestosXML = "Due to the Build/Refurb date this property is unlikely to contain asbestos, however if any suspected materials are found PLEASE STOP WORK IMMEDIATELY and contact STONEWATER on 01908 628092."
- End If
- End If
- End If
- strcommand = "select dbo.fn_XML_Safe_Text('" & SQLPropertyHasAsbestosXML & "')"
- With SQLConnection.Execute(strcommand)
- do until .eof
- SQLPropertyHasAsbestosXML = .fields(0)
- exit do
- loop
- End With
- End Function
- Function SQLPropertyHasAsbestosOLD(AssetID)
- Dim varDateFitted
- Dim strCommand
- Dim varAsbestosText
- Dim varTmp
- Dim varLocation
- Dim varFloorLevel
- Dim varComments
- varDateFitted = 9
- varAsbestosText = ""
- strCommand = "SELECT Occurrence_ID AS OccurrenceID, Asset_ID AS AssetID, Attribute_ID AS AttributeID, CASE WHEN Fitted_Renewed_Date_DT <= '31 DEC 1995' Then '1' Else '0' END AS FittedRenewDate FROM Asset_Attribute_Occurrences_T with (nolock) WHERE Attribute_ID = 208 AND Asset_ID = " & AssetID
- ' msgbox (strCommand)
- With sqlconnection.execute (strCommand)
- If Not .eof AND Not .bof Then
- varDateFitted = (.Fields("FittedRenewDate").Value)
- .Close
- End If
- End With
- If varDateFitted = 9 Then
- SQLPropertyHasAsbestos = "WARNING:- This property may have ASBESTOS containing materials as advised in a general notice to yourselves. If any suspected materials are found PLEASE STOP WORK IMMEDIATELY and contact the HSC on 01202 319119, or email asbestos@raglan.org direct with your enquiry"
- Else
- If varDateFitted = 1 Then
- strCommand = "SELECT Asset_Assets_T.Asset_ID AS AssetID, Asset_Attribute_Occurrences_T.Attribute_ID AS AttributeID, ISNULL(FLOORLEVEL.Description_VC,'') AS FloorLevel, ISNULL(Shared_Codes_T.Description_VC,'') AS Location, ISNULL(Asset_Attribute_Occurrences_T.Comment_Lines_VC,'') AS Comments, ISNULL(ASBESTOSTYPE.Description_VC,'') AS AsbestosType FROM Asset_Assets_T with (nolock) INNER JOIN Asset_Attribute_Occurrences_T with (NOLOCK) ON Asset_Assets_T.Asset_ID = Asset_Attribute_Occurrences_T.Asset_ID LEFT JOIN Shared_User_Defined_Codes_T FLOORLEVEL with (NOLOCK) ON FLOORLEVEL.Code_ID = Asset_Attribute_Occurrences_T.Group_ID LEFT JOIN Shared_Codes_T with (NOLOCK) ON Shared_Codes_T.Code_ID = Asset_Attribute_Occurrences_T.Location_ID INNER JOIN Asset_Attribute_Occurrence_User_Data_T USERDATA with (NOLOCK) ON Asset_Attribute_Occurrences_T.Occurrence_ID = USERDATA.Occurrence_ID LEFT JOIN Shared_User_Defined_Codes_T ASBESTOSTYPE with (NOLOCK) ON ASBESTOSTYPE.Code_ID = USERDATA.User_Code_3_ID WHERE Asset_Attribute_Occurrences_T.Attribute_ID=515 AND Asset_Assets_T.Asset_ID = " & AssetID
- With sqlconnection.execute (strCommand)
- Do Until .EOF
- varFloorLevel = (.Fields("FloorLevel").Value)
- varLocation = (.Fields("Location").Value)
- varComments = (.Fields("Comments").Value)
- varAsbestosType = (.Fields("AsbestosType").Value)
- varTmp = ""
- If varFloorLevel<>"" Then
- varTmp = varFloorLevel
- End If
- If varLocation<>"" Then
- If varTmp<>"" Then
- varTmp = varTmp & " : " & varLocation
- Else
- varTmp = varLocation
- End If
- End If
- If varComments<>"" Then
- If varTmp<>"" Then
- varTmp = varTmp & " : " & varComments
- Else
- varTmp = varComments
- End If
- End If
- If varAsbestosType<>"" Then
- If varTmp<>"" Then
- varTmp = varTmp & ". Asbestos Type: " & varAsbestosType
- Else
- varTmp = varAsbestosType
- End If
- End If
- If varTmp<>"" Then
- If varAsbestosText <> "" Then
- varAsbestosText = varAsbestosText & "|" & varTmp
- Else
- varAsbestosText = varTmp
- End If
- End If
- .MoveNext
- Loop
- End With
- End If
- If varDateFitted = 1 AND varAsbestosText <> "" Then
- SQLPropertyHasAsbestos = Replace(varAsbestosText,"|",vbcrlf)
- Else
- If varDateFitted = 1 AND varAsbestosText = "" Then
- SQLPropertyHasAsbestos = "WARNING:- This property may have ASBESTOS containing materials as advised in a general notice to yourselves. If any suspected materials are found PLEASE STOP WORK IMMEDIATELY and contact the HSC on 01202 319119, or email asbestos@raglan.org direct with your enquiry"
- End If
- End If
- End If
- End Function
- Function SQLPropertyHasAsbestos(AssetID)
- Dim varDateFitted
- Dim strCommand
- varDateFitted = 9
- strCommand = "SELECT Occurrence_ID AS OccurrenceID, Asset_ID AS AssetID, Attribute_ID AS AttributeID, CASE WHEN Fitted_Renewed_Date_DT <= '31 DEC 1999' Then '1' Else '0' END AS FittedRenewDate FROM Asset_Attribute_Occurrences_T with (nolock) WHERE Attribute_ID = 208 AND Asset_ID = " & AssetID
- With sqlconnection.execute (strCommand)
- If Not .eof AND Not .bof Then
- varDateFitted = (.Fields("FittedRenewDate").Value)
- .Close
- End If
- End With
- If varDateFitted = 9 Then
- SQLPropertyHasAsbestos = "WARNING:- This property may have ASBESTOS containing materials as advised in a general notice to yourselves. If any suspected materials are found PLEASE STOP WORK IMMEDIATELY and contact STONEWATER on 01908 628092."
- Else
- If varDateFitted = 1 Then
- strCommand = "SELECT Asset_Assets_T.Asset_ID AS AssetID, Asset_Attribute_Occurrences_T.Attribute_ID AS AttributeID, ISNULL(FLOORLEVEL.Description_VC,'') AS FloorLevel, ISNULL(Shared_Codes_T.Description_VC,'') AS Location, ISNULL(Asset_Attribute_Occurrences_T.Comment_Lines_VC,'') AS Comments, ISNULL(ASBESTOSTYPE.Description_VC,'') AS AsbestosType FROM Asset_Assets_T with (nolock) INNER JOIN Asset_Attribute_Occurrences_T with (NOLOCK) ON Asset_Assets_T.Asset_ID = Asset_Attribute_Occurrences_T.Asset_ID LEFT JOIN Shared_User_Defined_Codes_T FLOORLEVEL with (NOLOCK) ON FLOORLEVEL.Code_ID = Asset_Attribute_Occurrences_T.Group_ID LEFT JOIN Shared_Codes_T with (NOLOCK) ON Shared_Codes_T.Code_ID = Asset_Attribute_Occurrences_T.Location_ID INNER JOIN Asset_Attribute_Occurrence_User_Data_T USERDATA with (NOLOCK) ON Asset_Attribute_Occurrences_T.Occurrence_ID = USERDATA.Occurrence_ID LEFT JOIN Shared_User_Defined_Codes_T ASBESTOSTYPE with (NOLOCK) ON ASBESTOSTYPE.Code_ID = USERDATA.User_Code_3_ID WHERE Asset_Attribute_Occurrences_T.Attribute_ID=515 AND Asset_Assets_T.Asset_ID = " & AssetID
- With sqlconnection.execute (strCommand)
- Do Until .EOF
- varAsbestosType = (.Fields("AsbestosType").Value)
- .MoveNext
- Loop
- End With
- End If
- If varDateFitted = 1 AND varAsbestosType <> "" Then
- SQLPropertyHasAsbestos = "WARNING:- There are ASBESTOS materials contained within this property. You must access the relevant Asbestos Register to assess if the asbestos materials will affect your work. If you have any issue with accessing this information please contact STONEWATER on 01908 628092."
- Else
- If varDateFitted = 1 AND varAsbestosText = "" Then
- SQLPropertyHasAsbestos = "WARNING:- This property may have ASBESTOS containing materials as advised in a general notice to yourselves. If any suspected materials are found PLEASE STOP WORK IMMEDIATELY and contact STONEWATER on 01908 628092."
- Else
- SQLPropertyHasAsbestos = "Due to the Build/Refurb date this property is unlikely to contain asbestos, however if any suspected materials are found PLEASE STOP WORK IMMEDIATELY and contact STONEWATER on 01908 628092."
- End If
- End If
- End If
- End Function
- function GetJobTypeID(OrderID)
- dim strJobType
- dim strExec
- strExec = "SELECT TOP 1 RRTL.Job_Type_ID From Repairs_Works_Order_Lines_T AS RWOL (nolock) INNER JOIN Repairs_Requests_Task_Lines_T RRTL with (nolock) ON"
- strExec = strExec & " RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RRTL.SystemUplift_BT = 0 AND RWOL.Status_ID <> 29 AND RWOL.WorksOrder_ID = " & OrderID
- with SQLConnection.execute(strExec)
- do until .eof
- strJobType = .fields(0)
- exit do
- loop
- end with
- GetJobTypeID = strJobType
- end function
- function GetPriorityID(OrderID)
- dim strPriority
- dim strExec
- strExec = "SELECT TOP 1 RRTL.Priority_ID From Repairs_Works_Order_Lines_T AS RWOL (nolock) INNER JOIN Repairs_Requests_Task_Lines_T RRTL with (nolock) ON"
- strExec = strExec & " RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RWOL.Status_ID <> 29 and RWOL.WorksOrder_ID = " & OrderID
- with SQLConnection.execute(strExec)
- do until .eof
- strPriority = .fields(0)
- exit do
- loop
- end with
- GetPriorityID = strPriority
- end function
- function GetPriorityIDv2(OrderID)
- 'Function created to remove the system uplift tasks from being considered for the priority. also will now pick up the newest line rather than the oldest. New version created so that can switch back to original if needs be. KS 24/11/09
- dim strPriority
- dim strExec
- strExec = "SELECT TOP 1 RRTL.Priority_ID From Repairs_Works_Order_Lines_T AS RWOL (nolock) INNER JOIN Repairs_Requests_Task_Lines_T RRTL with (nolock) ON RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RWOL.Status_ID <> 29 and RWOL.WorksOrder_ID = " & OrderID & " and SystemUplift_BT = 0 order by RWOL.worksOrderline_Id desc"
- with SQLConnection.execute(strExec)
- do until .eof
- strPriority = .fields(0)
- exit do
- loop
- end with
- GetPriorityIDv2 = strPriority
- end function
- function showBrowser(URL)
- Dim WinShell
- Set WinShell = CreateObject ("WScript.Shell")
- Winshell.RUN "iexplore.exe " & URL
- end function
- Function ContractorPath(ContractorID)
- ContractorPath = 0
- 'Ian Williams
- If (ContractorID = "10131") Then
- ContractorPath = 1
- End if
- 'Connaught
- If (ContractorID = "10132") Then
- ContractorPath = 2
- End if
- 'Wates
- If (ContractorID = "10625") Then
- ContractorPath = 3
- End If
- 'Armitage
- If (ContractorID = "10575") Then
- ContractorPath = 4
- End If
- 'A1 Maintenance
- If (ContractorID = "10571") Then
- ContractorPath = 5
- End If
- '3 Solutions
- If (ContractorID = "10406") Then
- ContractorPath = 6
- End If
- 'Axis
- If (ContractorID = "10577") Then
- ContractorPath = 7
- End If
- End Function
- function UpdateUDESMS(WorksOrderID, SMSNumber)
- Dim varExecute
- UpdateUDESMS= False
- varInsertReqd = 1
- varSelect = "select count(SYS_Parent_Link_ID) as OrderFound from usr_Repairs_Works_Orders_UDE_1_T with (nolock)where SYS_Parent_Link_ID = '" & WorksOrderID & "'"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varInsertReqd = .Fields("OrderFound").Value
- .MoveNext
- Loop
- End With
- If varInsertReqd = 0 Then
- varExecute = "INSERT INTO usr_Repairs_Works_Orders_UDE_1_T (SYS_Parent_Link_ID,USR_Panel1_SMS_Text_Number_used_VC) VALUES('" & WorksOrderID & "','" & SMSNumber & "')"
- Else
- varExecute = "UPDATE usr_Repairs_Works_Orders_UDE_1_T SET USR_Panel1_SMS_Text_Number_used_VC= '" & SMSNumber & "' WHERE SYS_Parent_Link_ID = '" & WorksOrderID & "'"
- End If
- With SQLConnection.Execute(varExecute)
- End With
- UpdateUDESMS= True
- end function
- function UpdateUDEAppointmentREQ(WorksOrderID,AppREQ)
- Dim varExecute
- UpdateUDEAppointmentREQ= False
- varInsertReqd = 1
- varSelect = "select count(SYS_Parent_Link_ID) as OrderFound from usr_Repairs_Works_Orders_UDE_1_T with (nolock) where SYS_Parent_Link_ID = '" & WorksOrderID & "'"
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varInsertReqd = .Fields("OrderFound").Value
- .MoveNext
- Loop
- End With
- If varInsertReqd = 0 Then
- varExecute = "INSERT INTO usr_Repairs_Works_Orders_UDE_1_T (SYS_Parent_Link_ID,USR_Panel1_Appointment_Required_BT) VALUES('" & WorksOrderID & "','" & AppREQ & "')"
- Else
- varExecute = "UPDATE usr_Repairs_Works_Orders_UDE_1_T SET USR_Panel1_Appointment_Required_BT = '" & AppREQ & "' WHERE SYS_Parent_Link_ID = '" & WorksOrderID & "'"
- End If
- With SQLConnection.Execute(varExecute)
- End With
- UpdateUDEAppointmentREQ= True
- end function
- function WorkOrderStatus(Printed,Cancelled,Completed)
- WorkOrderStatus = 1
- if len(Printed) = 0 then
- WorkOrderStatus = 0
- end if
- if len(Completed) > 0 then
- WorkOrderStatus = 3
- end if
- if len(Cancelled) > 0 then
- WorkOrderStatus = 2
- end if
- end function
- 'New Version to fix an XML production bug - KS 26/03/09
- function WorkOrderStatusv2(Printed,Cancelled,Completed, RaisedBy)
- WorkOrderStatusv2 = 1
- if len(Printed) = 0 then
- WorkOrderStatusv2 = 0
- end if
- if len(Completed) > 0 or RaisedBy = "521" or RaisedBy = "522" then
- WorkOrderStatusv2 = 3
- end if
- if len(Cancelled) > 0 then
- WorkOrderStatusv2 = 2
- end if
- end function
- Function ReadFromCSVFile(File)
- Dim fso
- Dim txtstream
- Const ForReading = 1, ForWriting = 2, ForAppending = 8
- set fso=CreateObject("Scripting.FileSystemObject")
- set txtstream=fso.OpenTextFile(File, ForReading, True)
- ReadFromCSVFile = txtstream.ReadLine
- txtstream.Close
- End Function
- Function ReadAllTextFile(FileName)
- Const ForReading = 1, ForWriting = 2
- Dim fso, f
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set f = fso.OpenTextFile(FileName, ForReading, True)
- ReadAllTextFile = f.ReadAll
- End Function
- Function LettingsApplicationVariationTracker(varApplicationID,varStatus,varType,varPrison,varForces,varUK,varInitial)
- Rem Version 1.0 17th January 2008 AMS/CAP
- If varInitial = True Then
- varSelect = "INSERT INTO RAGLAN_Lettings_Application_Changed_T (ApplicationID, PreviousStatus, ApplicationType, InPrisonFlag, MemberOfForcesFlag, ResidesInUKFlag) VALUES (" & varApplicationID & ", '" & varStatus & "', '" & varType & "', '" & varPrison & "', '" & varForces & "', '" & varUK & "')"
- Else
- varSelect = "UPDATE RAGLAN_Lettings_Application_Changed_T SET PreviousStatus='" & varStatus & "', ApplicationType='" & varType & "', InPrisonFlag='" & varPrison & "', MemberOfForcesFlag='" & varForces & "', ResidesInUKFlag='" & varUK & "' WHERE ApplicationID = '" & varApplicationID & "'"
- End If
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function AccountTerminationTracker(varAccountID,varEndDate,varProvFlag,varInitial)
- Rem Version 1.0 25th January 2008 AMS/CAP
- If varInitial = True Then
- varSelect = "INSERT INTO RAGLAN_Tenancy_Termination_Tracker_T (ID, TenancyEndDate, ProvisionalFlag) VALUES ('" & varAccountID & "', '" & varEndDate & "', '" & varProvFlag & "')"
- Else
- varSelect = "UPDATE RAGLAN_Tenancy_Termination_Tracker_T SET TenancyEndDate='" & varEndDate & "', ProvisionalFlag='" & varProvFlag & "' WHERE ID = '" & varAccountID & "'"
- End If
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function CORE_Exported_Flag(varGroupID)
- varUpdate = "update usr_Contact_Groups_UDE_1_T set USR_Panel1_CORE_Exported_System_Updated_BT=1 where SYS_Parent_Link_ID=" & varGroupID
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function CORE_Clear_Down(varGroupID)
- varUpdate="UPDATE usr_Contact_Groups_UDE_1_T SET USR_Panel1_CORE_Key_Dates_Major_Works_Completion_Date_DT=NULL, USR_Panel1_CORE_Reason_for_Vacancy_IN=NULL, USR_Panel1_CORE_Economic_Status__Person_4_IN=NULL, USR_Panel1_CORE_Economic_Status__Person_3_IN=NULL, USR_Panel1_CORE_Economic_Status__Person_1_IN=NULL, USR_Panel1_CORE_Economic_Status__Person_2_IN=NULL, USR_Panel1_CORE_Nationality_of_Main_Applicant_IN=NULL, USR_Panel1_CORE_Occupation_of_Main_Applicant_IN=NULL, USR_Panel1_CORE_Economic_Status__Person_5_IN=NULL, USR_Panel1_CORE_Economic_Status__Person_6_IN=NULL, USR_Panel1_CORE_Economic_Status__Person_7_IN=NULL, USR_Panel1_CORE_Main_Reason_for_Leaving_Prev_Accom_IN=NULL, USR_Panel1_CORE_Prior_to_Letting_Was_This_Household_IN=NULL, USR_Panel1_CORE_CORE_Type_IN=NULL, USR_Panel1_CORE_Type_of_Accom_For_Last_Household_IN=NULL, USR_Panel1_CORE_Economic_Status__Person_8_IN=NULL, USR_Panel1_CORE_Allocation_System__Common_Housing_Register_IN=NULL, USR_Panel1_CORE_Allocation_System__Choice_Based_Lettings_IN=NULL, USR_Panel1_CORE_Will_Tenant_Qualify_For_Housing_Benefit_IN=NULL, USR_Panel1_CORE_Allocation_System__Common_Allocation_Policy_IN=NULL, USR_Panel1_SALES_Funded_Through_Any_Other_KeyWorker_Scheme_IN=NULL, USR_Panel1_SALES_Purchaser_Previously_Owned_a_Property_IN=NULL, USR_Panel1_SALES_Funded_Through_the_KeyWorker_Living_Prog_IN=NULL, USR_Panel1_SALES_Register_With__HomeBuy_Agent_IN=NULL, USR_Panel1_SALES_Register_With__Your_HA_IN=NULL, USR_Panel1_SALES_Register_With__Local_Authority_IN=NULL, USR_Panel1_CORE_Does_Household_Contain_a_Pregnant_Woman_IN=NULL, USR_Panel1_SALES_Exchange_of_Contracts_DT=NULL, USR_Panel1_CORE_Does_Any_Household_Member_Use_Wheelchair_IN=NULL, USR_Panel1_CORE_Any_Household_Member_Disabled_IN=NULL, USR_Panel1_CORE_Exported_System_Updated_BT=0 WHERE SYS_Parent_Link_ID = " & varGroupID
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- public function mPost
- dim rs
- dim lngCount
- dim strStmt
- dim objIface
- ''
- set objIface = CreateObject("SQLDocumentWFPlugin.CDocIface")
- if objIface is nothing then
- msgbox("Object Creation Failed")
- end if
- objIface.Initialize SQLUtilities
- set rs = CreateObject("ADODB.Recordset")
- strStmt = "SELECT Document_ID FROM Repairs_Documents_T with (nolock) WHERE Document_ID IN(147127,147129,147131,147133,147134,147135,147136,147137,147138,147139,147140,147141,147142,147143,147144,147145,147146,147147,147148,147149,147151,147152,147153,147154,147155,147156,147157,147158,147159,147160,147161,147162,147163,147164,147166,147167,147168,147169,147170,147171,147172,147173,147174,147175,147176,147177,147178,147179,147180,147181,147182,147183,147184,147185,147186,147188,147189,147190,147191,147192,147193,147194,147195,147196,147197,147198,147199,147200,147201,147202,147203,147204,147205,147206,147207,147208,147209,147210,147211,147212,147213,147214,147215,147216,147217,147218,147219,147220,147221,147222,147223,147224,147225,147226,147227,147230,147231,147232,147233,147234,147235,147236,147237,147240,147241,147242,147243,147244,147245,147246,147247,147248,147251,147253,147254,147255,147256,147128,147130,147150,147187,147228,147229,147238,147239,147249,147252,147257,147258,147259,147260,147261,147262,147263,147264,147265,147266,147267,147268,147269,147270,147271,147272,147273,147274,147275,147276,147277,147278,147279,147280,147281,147282,147283,147284,147285,147286,147288,147289,147290,147291,147292,147293,147294,147295,147296,147297,147298,147299,147300,147301,147302,147303,147304,147305,147306,147307,147308,147309,147310,147311,147312,147313,147314,147315,147316,147317,147318,147319,147320,147321,147322,147323,147324,147325,147326,147327,147328,147329,147330,147331,147332,147333,147334,147335,147336,147337,147338,147339,147340,147341,147342,147343,147344,147345,147346,147347,147348,147349,147350,147351,147352,147353,147354,147355,147356,147357,147358,147359,147363,147364,147365,147366,147367,147368,147373,147374,147375,147376,147378,147381,147382,147383,147384,147385,147386,147387,147388,147389,147391,147393,147394,147396,147397,147398,147399,147400,147401,147402,147403,147405,147406,147407,147408,147409,147410,147411,147360,147361,147362,147369,147370,147371,147372,147390,147392,147395,147404,147412,147413,147414,147415,147416,147417,147418,147419,147420,147421,147422,147423,147424,147425,147426,147427)"
- rs.CursorLocation = 3
- rs.Open strStmt, SQLConnection, 3, 1, 1
- Set rs.ActiveConnection = Nothing
- if not rs.eof and not rs.bof then
- rs.movefirst
- for lngCount = 1 to rs.RecordCount
- if objIface.DocumentIsValid(rs.fields(0).value) then
- objIface.PostDocument clng(rs.fields(0).value)
- else
- msgbox "Document : " & rs.fields(0).value & " " & objIface.ErrorReason,vbexclamation+vbokonly,"Posting Error"
- end if
- rs.movenext
- next
- else
- msgBox("no documents selected.")
- end if
- objIface.Terminate
- set objIface = nothing
- end function
- Function PropertyHasAsbestos(AssetID)
- dim strFormatAssetID
- dim strCommand
- strFormatAssetID = String(7 - Len(AssetID),"0") & AssetID
- strCommand = "SELECT TOP 1 ID FROM DTS_Asset_Attributes with (nolock) WHERE ID LIKE '" & strFormatAssetID & "198**%'"
- with sqlconnection.execute (strCommand)
- if not .eof and not .bof then
- PropertyHasAsbestos = "WARNING: This property contains asbestos materials. You should contact Housing Services Centre 01202 312760 who will provide you with further details."
- end if
- .close
- end with
- strCommand = "SELECT TOP 1 ID FROM DTS_Asset_Attributes with (nolock) WHERE ID LIKE '" & strFormatAssetID & "4**%'"
- with sqlconnection.execute (strCommand)
- if not .eof and not .bof then
- PropertyHasAsbestos = "WARNING: This property may have asbestos containing materials as advised in a general notice to yourselves. If any suspected materials are found PLEASE STOP WORK IMMEDIATELY and contact Housing Services Centre on 01202 312760."
- end if
- .close
- end with
- End Function
- Function ClearUSRTable(TableName)
- sqlconnection.execute ("DELETE FROM " & cstr(TableName))
- End Function
- Function BuildUSRTable(RunDate)
- dim strCommand
- ' Resident Managers Selection
- strCommand = "INSERT INTO USR_Asset_Resident_Letters_T (Asset_ID,Request_ID,Resident_Manager_VC,Resident_Fax_VC) ("
- strCommand = strCommand & "SELECT RRT.Asset_ID, RRT.Request_ID,"
- strCommand = strCommand & "CASE "
- strCommand = strCommand & "WHEN LEN(UDEA.USR_Panel1_Resident_Manager_Name_VC) > 0 then UDEA.USR_Panel1_Resident_Manager_Name_VC "
- strCommand = strCommand & "WHEN LEN(UDEB.USR_Panel1_Resident_Manager_Name_VC) > 0 then UDEB.USR_Panel1_Resident_Manager_Name_VC "
- strCommand = strCommand & "WHEN LEN(UDEC.USR_Panel1_Resident_Manager_Name_VC) > 0 then UDEC.USR_Panel1_Resident_Manager_Name_VC "
- strCommand = strCommand & "END AS ResidentManager, "
- strCommand = strCommand & "CASE "
- strCommand = strCommand & "WHEN LEN(UDEA.USR_Panel1_Resident_Manager_Fax_VC) > 0 then UDEA.USR_Panel1_Resident_Manager_Fax_VC "
- strCommand = strCommand & "WHEN LEN(UDEB.USR_Panel1_Resident_Manager_Fax_VC) > 0 then UDEB.USR_Panel1_Resident_Manager_Fax_VC "
- strCommand = strCommand & "WHEN LEN(UDEC.USR_Panel1_Resident_Manager_Fax_VC) > 0 then UDEC.USR_Panel1_Resident_Manager_Fax_VC "
- strCommand = strCommand & "END AS ResidentFax "
- strCommand = strCommand & "From Repairs_Requests_T AS RRT with (nolock)"
- strCommand = strCommand & "INNER JOIN Asset_Assets_T AAT with (nolock) ON AAT.Asset_ID = RRT.Asset_ID "
- strCommand = strCommand & "INNER JOIN Asset_Types_T ATT with (nolock) ON ATT.Asset_Type_ID = AAT.Asset_Type_ID "
- strCommand = strCommand & "INNER JOIN Asset_Asset_Structure_T AASTA with (nolock)ON AASTA.Child_ID = AAT.Asset_ID "
- strCommand = strCommand & "LEFT JOIN Asset_Asset_Structure_T AASTB with (nolock)ON AASTB.Child_ID = AASTA.Parent_ID "
- strCommand = strCommand & "LEFT JOIN Asset_Asset_Structure_T AASTC with (nolock) ON AASTC.Child_ID = AASTB.Parent_ID "
- strCommand = strCommand & "LEFT JOIN usr_Asset_Assets_UDE_1_T UDEA with (nolock) ON UDEA.SYS_Parent_Link_ID = AAT.Asset_ID "
- strCommand = strCommand & "LEFT JOIN usr_Asset_Assets_UDE_1_T UDEB with (nolock) ON UDEB.SYS_Parent_Link_ID = AASTA.Parent_ID "
- strCommand = strCommand & "LEFT JOIN usr_Asset_Assets_UDE_1_T UDEC with (nolock) ON UDEC.SYS_Parent_Link_ID = AASTB.Parent_ID "
- strCommand = strCommand & "WHERE CONVERT(varchar(12),RRT.Request_DT,103) = '%1' "
- strCommand = strCommand & "AND (UDEA.USR_Panel1_Resident_Manager_Name_VC IS NOT NULL OR UDEB.USR_Panel1_Resident_Manager_Name_VC IS NOT NULL OR UDEC.USR_Panel1_Resident_Manager_Name_VC IS NOT NULL) "
- strCommand = strCommand & ")"
- strCommand = replace(strCommand,"%1",RunDate)
- SQLConnection.execute strCommand
- End Function
- function ConfirmationOrder(Confirmation)
- if confirmation = "True" then
- ConfirmationOrder = "** Confirmation Order **"
- end if
- end function
- Function AssetIsDisposed(AssetID)
- dim strCommand
- strCommand = replace("select top 1 Status_Type_ID, Effective_Date_DT from Asset_Asset_Status_T with (nolock) where (Asset_ID = %1) order by Effective_Date_DT DESC","%1",AssetId)
- with sqlconnection.execute(strCommand)
- if not .eof and not .bof then
- if .fields(0).Value = "134" then
- msgbox "This asset was disposed on " & .fields(1).Value,vbexclamation+vbokonly,"Disposed"
- AssetIsDisposed = True
- end if
- end if
- .close
- end with
- End Function
- 'Function SendEmailToContractor(OrderID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,RiskCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning)
- '
- ' dim strBody
- ' dim strEmailAddress
- ' dim strCommand
- ' dim dblTotal
- ' dim lngLines
- ' dim strSOR
- '
- ' strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
- ' strBody = strbody & vbcrlf & "Asset: " & AssetReference
- ' if len(AsbestosWarning) > 0 then
- ' strBody = strBody & AsbestosWarning
- ' end if
- ' strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- ' strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- ' strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- ' strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
- ' strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
- ' strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
- ' strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
- ' strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- ' strBody = strBody & vbcrlf & "Order Date: " & OrderDate
- ' strBody = strBody & vbcrlf & "Risk Code: " & RiskCode
- ' strBody = strBody & vbcrlf & "Job Type: " & JobType
- ' strBody = strBody & vbcrlf & "Priority: " & Priority
- ' strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- ' strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- ' strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- ' strBody = strBody & vbcrlf & vbcrlf & '"======================================================================================================="
- ' strCommand = Replace("SELECT SST.SOR_Code_VC, rrtlt.NarrativeDescription_VC, rrtlt.Quantity_DC,rwolt.ContractValue_MN From Repairs_Requests_Task_Lines_T RRTLT (nolock) INNER JOIN Repairs_Works_Order_Lines_T RWOLT (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID LEFT JOIN Shared_SORS_T SST (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE rrtlt.Status_ID = 5 AND RWOLT.WorksOrder_ID = xxx","xxx",OrderID)
- ' with sqlconnection.execute(strCommand)
- ' do until .eof
- ' strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- ' for lngLines = 0 to ubound(strSOR)
- ' if lngLines = 0 then
- ' if isnull(.fields(0)) then
- ' strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- ' else
- ' strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & 'strsor(lngLines)
- ' end if
- ' strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- ' strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- ' else
- ' strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- ' end if
- ' next
- ' dblTotal = dblTotal + .fields(3)
- ' .movenext
- ' loop
- ' end with
- ' strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- ' strBody = strBody & vbcrlf & vbcrlf & '"======================================================================================================="
- ' strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- ' strEmailAddress = GetContractorEmailAddress(Contractor)
- ' msgbox strBody,vbexclamation+vbokonly,"Email should be this"
- ' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & 'ConfirmationOrder,"ActiveHWO@raglan.org",strEmailAddress,"","ActiveHWO@raglan.org",strBody,"",""
- 'End Function'
- 'NEW VERSION - RS 06 AUG 2008'
- Function SendEmailToContractorOldVersion(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,RiskCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning)
- dim strBody
- dim strEmailAddress
- dim strCommand
- dim dblTotal
- dim lngLines
- dim strSOR
- strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
- strBody = strbody & vbcrlf & "Request ID: " & RequestID
- strBody = strbody & vbcrlf & "Asset: " & AssetReference
- if len(AsbestosWarning) > 0 then
- strBody = strBody & vbcrlf & AsbestosWarning
- end if
- strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
- strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
- strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
- strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
- strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- strBody = strBody & vbcrlf & "Order Date: " & OrderDate
- strBody = strBody & vbcrlf & "Risk Code: " & RiskCode
- strBody = strBody & vbcrlf & "Job Type: " & JobType
- strBody = strBody & vbcrlf & "Priority: " & Priority
- strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strCommand = Replace("SELECT SST.SOR_Code_VC, rrtlt.NarrativeDescription_VC, rrtlt.Quantity_DC,rwolt.ContractValue_MN,rwolt.WorksOrderLine_ID From Repairs_Requests_Task_Lines_T RRTLT with (nolock) INNER JOIN Repairs_Works_Order_Lines_T RWOLT with (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID LEFT JOIN Shared_SORS_T SST with (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE rrtlt.Status_ID = 5 AND RWOLT.WorksOrder_ID = xxx","xxx",OrderID)
- with sqlconnection.execute(strCommand)
- do until .eof
- strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- for lngLines = 0 to ubound(strSOR)
- if lngLines = 0 then
- if isnull(.fields(0)) then
- strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- else
- strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
- end if
- strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
- strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- else
- strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- end if
- next
- dblTotal = dblTotal + .fields(3)
- .movenext
- loop
- end with
- strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- strEmailAddress = GetContractorEmailAddress(Contractor)
- ' msgbox strBody,vbexclamation+vbokonly,"Email should be this"
- CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@raglan.org",strEmailAddress,"","ActiveHWO@raglan.org",strBody,"",""
- End Function
- function GetOverdueTasksNotEscalated(OverdueDays)
- dim varSQLStatement
- dim varTasksToEscalate
- varSQLStatement = "SELECT TT.Task_ID, TT.Status_ID, TT.System_Task_BT, TT.Required_By_DT, TT.Assigned_To_ID, TTA.Assigned_DT, TTA.Organisation_Hierarchy_ID FROM Tasking_Tasks_T TT with (nolock) LEFT JOIN Tasking_Task_Assignment_T TTA with (nolock) ON TT.Task_ID = TTA.Task_ID AND TT.Assigned_To_ID = TTA.Organisation_Hierarchy_ID WHERE TT.Required_By_DT IS NOT NULL AND TT.Required_By_DT < DATEADD(Day," & OverdueDays & ",GETDATE()) AND TT.Status_ID IN (57, 58) AND TT.Task_ID NOT IN (SELECT TTT.Task_ID FROM Tasking_Tasks_T TTT with (nolock) LEFT JOIN Tasking_Task_Assignment_T TTAT with (nolock) ON TTT.Task_ID = TTAT.Task_ID WHERE TTAT.Assignment_Type_ID = 63 AND TTT.Required_By_DT IS NOT NULL AND TTT.Required_By_DT < DATEADD(Day," & OverdueDays & ",GETDATE()) AND TTAT.Assigned_DT > TTT.Required_By_DT) ORDER BY TT.Task_ID, TTA.Task_Assignment_ID"
- with sqlconnection.execute(varSQLStatement)
- do until .eof
- varTasksToEscalate = ListAppend(CStr(varTasksToEscalate),CStr(.Fields("Task_ID").Value))
- .movenext
- loop
- end with
- GetOverdueTasksNotEscalated = varTasksToEscalate
- end function
- function GetOverdueTasksEscalated(OverdueDays)
- dim varSQLStatement
- dim varTasksToEscalate
- varSQLStatement = "SELECT TT.Task_ID, TT.Status_ID, TT.System_Task_BT, TT.Required_By_DT, TT.Assigned_To_ID, TTA.Assigned_DT, TTA.Organisation_Hierarchy_ID FROM Tasking_Tasks_T TT with (nolock) LEFT JOIN Tasking_Task_Assignment_T TTA with (nolock) ON TT.Task_ID = TTA.Task_ID AND TT.Assigned_To_ID = TTA.Organisation_Hierarchy_ID WHERE TT.Required_By_DT IS NOT NULL AND TT.Required_By_DT < DATEADD(Day," & OverdueDays & ",GETDATE()) AND TTA.Assigned_DT < DATEADD(Day,-" & OverdueDays & ",GETDATE()) AND TT.Status_ID IN (57, 58) AND TT.Task_ID IN (SELECT TTT.Task_ID FROM Tasking_Tasks_T TTT with (nolock) LEFT JOIN Tasking_Task_Assignment_T TTAT with (nolock) ON TTT.Task_ID = TTAT.Task_ID WHERE TTAT.Assignment_Type_ID = 63 AND TTT.Required_By_DT IS NOT NULL AND TTT.Required_By_DT < DATEADD(Day," & OverdueDays & ",GETDATE()) AND TTAT.Assigned_DT > TTT.Required_By_DT) ORDER BY TT.Task_ID, TTA.Task_Assignment_ID"
- with sqlconnection.execute(varSQLStatement)
- do until .eof
- varTasksToEscalate = ListAppend(CStr(varTasksToEscalate),CStr(.Fields("Task_ID").Value))
- .movenext
- loop
- end with
- GetOverdueTasksEscalated = varTasksToEscalate
- end function
- Function CDOEMailUsingOutputAttach(Subject,From,Recipient,Cc,Bcc,Body,HTMLBody,AttachFilePath)
- '
- ' This function allows generation of an email via Outlook
- ' with an optional attachment file if required
- '
- Dim objMessage, objConfiguration
- Set objMessage = CreateObject("CDO.Message")
- Set objConfiguration = CreateObject("CDO.Configuration")
- On Error Resume Next
- objMessage.Subject = Subject
- objMessage.From = From
- objMessage.To = Recipient
- objMessage.Bcc = Bcc
- objMessage.Cc = Cc
- if len(Body) > 0 then
- objMessage.TextBody = Body
- else
- objMessage.HTMLBody = HTMLBody
- end if
- If Len(AttachFilePath) > 0 Then
- objMessage.AddAttachment AttachFilePath
- Else
- End If
- ' Do not touch parameters below! unless you fully understand the implications
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ragexcas1"
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "raglan\ActiveHSMS"
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Opera09"
- ' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Housing Services Centre"
- ' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "opera09"
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 180
- objConfiguration.Fields.Update
- Set objMessage.Configuration = objConfiguration
- objMessage.Send
- Set objMessage = Nothing
- End Function
- Function CDOEMailUsingOutputAttachCopy(Subject,From,Recipient,Cc,Bcc,Body,HTMLBody,AttachFilePath)
- '
- ' This function allows generation of an email via Outlook
- ' with an optional attachment file if required
- '
- Dim objMessage, objConfiguration
- Set objMessage = CreateObject("CDO.Message")
- Set objConfiguration = CreateObject("CDO.Configuration")
- ' On Error Resume Next
- objMessage.Subject = Subject
- objMessage.From = From
- objMessage.To = Recipient
- objMessage.Bcc = Bcc
- objMessage.Cc = Cc
- if len(Body) > 0 then
- objMessage.TextBody = Body
- else
- objMessage.HTMLBody = HTMLBody
- end if
- If Len(AttachFilePath) > 0 Then
- objMessage.AddAttachment AttachFilePath
- Else
- End If
- ' Do not touch parameters below! unless you fully understand the implications
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ragexcas1"
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "raglan\ActiveHSMS"
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Opera09"
- ' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Housing Services Centre"
- ' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "opera09"
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 180
- objConfiguration.Fields.Update
- Set objMessage.Configuration = objConfiguration
- objMessage.Send
- Set objMessage = Nothing
- End Function
- Function DeleteCSVFile(File)
- Dim fso
- set fso=CreateObject("Scripting.FileSystemObject")
- if fso.FileExists(File) then fso.DeleteFile File
- End Function
- Function AnyRequestsOrTasksPresent(CallID)
- dim strStat
- dim lngReqCount
- dim lngTaskCount
- dim blnClosed
- strStat = "SELECT Count(Repairs_Requests_T.Request_ID), Count(Tasking_Tasks_T.Task_ID) FROM CRM_Calls_T with (nolock) LEFT OUTER JOIN Repairs_Requests_T with (nolock) ON Repairs_Requests_T.CRMReference_ID = " & CallID & " LEFT OUTER JOIN Tasking_Tasks_T with (nolock) ON Tasking_Tasks_T.CRM_Call_ID = " & CallID & " WHERE Call_ID = " & CallID
- with sqlconnection.execute(strStat)
- if not isnull(.fields(0)) then lngReqCount = .fields(0)
- if not isnull(.fields(1)) then lngTaskCount = .fields(1)
- end with
- AnyRequestsOrTasksPresent = lngReqCount > 0 OR lngTaskCount > 0
- with sqlconnection.execute("SELECT Call_Status_ID From CRM_Calls_T with (nolock) WHERE Call_ID = " & CallID)
- if cstr(.fields(0)) = "59" or cstr(.fields(0)) = "60" then blnClosed = True
- end with
- if blnClosed then AnyRequestsOrTasksPresent = True
- End Function
- Function NumberOfLines(Description,LengthOfItem)
- dim lngLength
- dim lngLines
- dim strResult
- strResult = ReturnDelimitedText(replace(replace(Description,chr(10),""),chr(13)," "),LengthOfItem)
- for lngLength = 1 to len(strResult)
- if mid(strResult,lngLength,1) = chr(13) then lngLines = lngLines + 1
- next
- NumberOfLines = lngLines + 1
- End Function
- Function NumberOfLinesForSOR(Description)
- dim lngLength
- dim lngLines
- dim strResult
- strResult = ReturnDelimitedText(Description,47)
- for lngLength = 1 to len(strResult)
- if mid(strResult,lngLength,1) = chr(13) then lngLines = lngLines + 1
- next
- NumberOfLinesForSOR = lngLines + 2
- End Function
- Function ReturnDelimitedText(Text, Width)
- Dim strResult
- Dim lngAnchor
- Dim lngTarget
- Dim blnContinue
- Dim strLine
- Dim lngLineIndex
- Dim astrLines(100)
- Dim strWord
- Dim strText
- Dim lngCharsLeft
- Dim blnNeedsASpace
- Dim lngNumLines
- Dim strPossibleNextBit
- strText = Text
- If Len(Text) = 0 Then Exit Function
- lngLineIndex = 1
- blnContinue = True
- Do
- 'Extract next word
- 'Find out where the next space is
- lngTarget = InStr(strText, " ")
- 'Is there anything after this word?
- If lngTarget > 0 Then
- 'If so, grab the word and cut remaining text
- strWord = Left(strText, lngTarget - 1)
- strText = Mid(strText, lngTarget + 1)
- Else
- 'Otherwise, grab the last word and signal that we're about to stop this
- strWord = strText
- blnContinue = False
- End If
- blnNeedsASpace = (strLine <> "")
- 'Find out what would happen if we added the next word to the
- 'current line
- If blnNeedsASpace Then
- strPossibleNextBit = strLine & " " & strWord
- Else
- strPossibleNextBit = strWord
- End If
- 'Will the word (with a space) fit on this line?
- If Len(strPossibleNextBit) > Width Then
- 'If not, is the word longer than a line?
- If Len(strWord) > Width Then
- 'If so, chop it up.
- 'Add a space if reqd.
- If blnNeedsASpace Then
- strLine = strLine & " "
- End If
- 'Find out how much we can find on the rest of this line
- lngCharsLeft = Width - Len(strLine)
- 'Add the chunk
- strLine = strLine & Left(strWord, lngCharsLeft)
- astrLines(lngLineIndex) = strLine
- lngLineIndex = lngLineIndex + 1
- 'Cut the remaining bits of the word up
- strWord = Mid(strWord, lngCharsLeft + 1)
- 'It is STILL too big to fit?
- If Len(strWord) > Width Then
- 'If so, we're gonna have to keep chopping it up
- Do
- astrLines(lngLineIndex) = Left(strWord, Width)
- lngLineIndex = lngLineIndex + 1
- strWord = Mid(strWord, Width + 1)
- Loop Until strWord = ""
- Else
- 'Otherwise, add the bit that's left
- astrLines(lngLineIndex) = strWord
- lngLineIndex = lngLineIndex + 1
- End If
- strLine = ""
- Else
- 'Word is NOT longer than a line - add it to the next line
- astrLines(lngLineIndex) = strLine
- lngLineIndex = lngLineIndex + 1
- strLine = strWord
- End If
- Else
- 'If it will fit on this line, add it
- If blnNeedsASpace Then
- strLine = strLine & " " & strWord
- Else
- strLine = strWord
- End If
- End If
- Loop Until Not blnContinue
- 'Is there a bit left?
- If Len(strLine) > 0 Then
- 'If so, add it
- astrLines(lngLineIndex) = strLine
- lngNumLines = lngLineIndex
- Else
- lngNumLines = lngLineIndex - 1
- End If
- For lngLineIndex = 1 To lngNumLines
- strResult = strResult & left(astrLines(lngLineIndex),width)
- If lngLineIndex < lngNumLines Then
- strResult = strResult & Chr(13) & Chr(10)
- End If
- Next
- ReturnDelimitedText= strResult
- End Function
- Function MailUsingOutputAttach(Subject,Recipient,Body,Username,AttachFilePath,Params)
- '
- ' This function allows generation of an email via Outlook
- ' with an optional attachment file if required
- '
- On Error resume Next:err.clear
- Dim objOutput
- Set objoutput = CreateObject("Output.CEmail")
- objoutput.Subject = Subject
- objoutput.ToList = Recipient
- objoutput.MessageText = Body
- objoutput.Username = Username
- If Len(AttachFilePath) > 0 Then
- objoutput.Attachment = AttachFilePath
- End If
- objoutput.password = ""
- objoutput.SendEmail
- Set objoutput = Nothing
- End Function
- Function BuildTaskDescription(WorksOrderID, EstimatedValue, Narrative)
- dim strDesc
- dim strAsset
- dim strDate
- dim strAddressID
- dim strAddress
- with sqlconnection.execute("SELECT RRT.Asset_ID, RWOT.Raised_DT FROM Repairs_Works_Orders_T RWOT with (nolock) INNER JOIN Repairs_Requests_T RRT with (nolock) ON RWOT.Request_ID = RRT.Request_ID WHERE (RWOT.WorksOrder_ID = " & WorksOrderID & ")")
- if not .eof then
- strAsset = cstr(.fields(0))
- strDate = cstr(.fields(1))
- end if
- end with
- with sqlconnection.execute("SELECT Address_ID from Asset_Assets_T with (nolock) where Asset_ID = " & clng(strAsset))
- if not .eof then
- strAddressID = cstr(.fields(0))
- end if
- end with
- strDesc = "Insurance Claim Enquiry" & vbcrlf & "Order Number: " & WorksOrderID & vbcrlf & "Description: " & Narrative & vbcrlf & "Date Raised: " & strDate & vbcrlf & "Estimated value: " & formatnumber(EstimatedValue,2) & vbcrlf & "Asset Details:" & vbcrlf & GetAssetAddress(strAddressID)
- BuildTaskDescription = strDesc
- End Function
- Function ValidateCostAccount(CostAccount)
- dim pos
- dim ca
- ValidateCostAccount = 0
- pos = instr(3,CostAccount,"-")
- ca = mid(CostAccount,pos+1,4)
- if ca = "5185" or ca = "9010" then ValidateCostAccount = 1
- End Function
- Function ReturnResultFromString(String1,String2,String3,String4)
- dim strResult
- '-- Debug msgbox String1 & ", " & string2 & ", " & string3 & ", " & string4
- if len(String1) > 0 then
- strResult = String1
- end if
- if len(String2) > 0 then
- if len(strResult) = 0 then
- strResult = String2
- else
- strResult = strResult & vbcrlf & vbcrlf & String2
- end if
- end if
- if len(String3) > 0 then
- if len(strResult) = 0 then
- strResult = String3
- else
- strResult = strResult & vbcrlf & vbcrlf & String3
- end if
- end if
- if len(String4) > 0 then
- if len(strResult) = 0 then
- strResult = String4
- else
- strResult = strResult & vbcrlf & vbcrlf & String4
- end if
- end if
- '-- Debug msgbox strResult
- ReturnResultFromString = Sentence(strResult)
- End Function
- function Sentence(Word)
- dim strResult
- dim lng
- dim strLast
- dim strChar
- for lng = 1 to len(Word)
- if len(strLast) = 0 or strLast = " " or strLast = ":" or strLast = "'" or strlast = vblf or strLast = "(" then
- strChar = ucase(mid(word,lng,1))
- else
- strChar = lcase(mid(word,lng,1))
- end if
- if len(strResult) = 0 then
- strResult = strChar
- else
- strResult = strResult & strChar
- end if
- strLast = mid(Word,lng,1)
- next
- Sentence = strResult
- end function
- Function BuildOutputForRHA_CRM_Display_Panels(Remarks,HousingOfficer_ID,Inspector_ID, Round_ID,LettingArea_ID,Principal_Surveyor)
- dim strResult
- dim blnPad
- if isnull(Remarks) then Remarks = vbnullstring
- if isnull(HousingOfficer_ID) then HousingOfficer_ID = 0
- if isnull(Inspector_ID) then Inspector_ID = 0
- if isnull(Round_ID) then Round_ID = 0
- if isnull(LettingArea_ID) then LettingArea_ID = 0
- if isnull(Principal_Surveyor) then Principal_Surveyor = 0
- ' --Debug msgbox "HousingOfficer = " & HousingOfficer_ID
- if len(HousingOfficer_ID) > 0 then
- if len(strResult) = 0 then
- strResult = "Housing Officer: " & GetDescriptionForCode(HousingOfficer_ID)
- end if
- end if
- ' --Debug msgbox "Inspector = " & Inspector_ID
- if len(Inspector_ID) > 0 then
- if len(strResult) = 0 then
- '-- strResult = "Inspector:" & GetInspectorNameFromCode(Inspector_ID)
- strResult = "Repairs Surveyor: " & GetInspectorNameFromCode(Inspector_ID)
- else
- if blnpad then
- strResult = strResult & vbcrlf & "Repairs Surveyor: " & GetInspectorNameFromCode(Inspector_ID)
- blnpad = false
- else
- strResult = strResult & vbcrlf & "Repairs Surveyor: " & GetInspectorNameFromCode(Inspector_ID)
- end if
- end if
- end if
- ' --Debug msgbox "Round = " & Round_ID
- if len(Round_ID) > 0 then
- if len(strResult) = 0 then
- '--strResult = "Round:" & GetDescriptionForCode(Round_ID)
- strResult = "Rent Setting Officer: " & GetDescriptionForCode(Round_ID)
- else
- if blnpad then
- strResult = strResult & vbcrlf & "Rent Setting Officer: " & GetDescriptionForCode(Round_ID)
- blnPad = false
- else
- strResult = strResult & vbcrlf & "Rent Setting Officer: " & GetDescriptionForCode(Round_ID)
- end if
- end if
- end if
- ' --Debug msgbox "LettingArea = " & LettingArea_ID
- if len(LettingArea_ID) > 0 then
- if len(strResult) = 0 then
- '--strResult = "Letting Area:" & GetDescriptionForCode(LettingArea_ID)
- strResult = "Regional Housing Manager: " & GetDescriptionForCode(LettingArea_ID)
- else
- if blnPad then
- strResult = strResult & vbcrlf & "Regional Housing Manager: " & GetDescriptionForCode(LettingArea_ID)
- blnpad = false
- else
- strResult = strResult & vbcrlf & "Regional Housing Manager: " & GetDescriptionForCode(LettingArea_ID)
- end if
- end if
- end if
- ' --Debug msgbox "Principal Surveyor = " & Principal_Surveyor
- if len(Principal_Surveyor) > 0 then
- if len(strResult) = 0 then
- '--strResult = "Principal Surveyor:" & GetDescriptionForCode(Principal_Surveyor)
- strResult = "Planned Works Surveyor: " & GetDescriptionForCode(Principal_Surveyor)
- else
- strResult = strResult & vbcrlf & "Planned Works Surveyor: " & GetDescriptionForCode(Principal_Surveyor)
- end if
- end if
- if len(remarks) > 0 then
- strResult = strResult & vbcrlf & vbcrlf & Remarks
- blnPad = True
- end if
- BuildOutputForRHA_CRM_Display_Panels = Sentence(strResult)
- end function
- function GetRisk(Contact_ID)
- dim strResult
- with sqlconnection.execute("SELECT USR_Panel1_Risk_IN FROM usr_Contact_Contacts_UDE_1_T with (nolock) WHERE SYS_Parent_Link_ID = " & Contact_ID)
- do until .eof
- if not isnull(.fields(0)) then
- strResult = GetDescriptionForUserCode(.fields(0))
- end if
- .movenext
- loop
- end with
- GetRisk = strResult
- end function
- function GetVulnerabilitiesForContact(Contact_ID)
- dim strResult
- dim strRisk
- with sqlconnection.execute("SELECT Vulnerability_Code_ID FROM Contact_Contact_Vulnerabilities_T with (nolock) WHERE (Expiry_Date_DT > getdate() or Expiry_Date_Dt is null) and Contact_ID = " & Contact_ID)
- do until .eof
- if len(strResult) = 0 then
- strResult = "Vulnerability:" & GetDescriptionForCode( .fields(0))
- else
- strResult = strResult & "," & GetDescriptionForCode(.fields(0))
- end if
- .movenext
- loop
- end with
- strRisk = GetRisk(Contact_ID)
- if len(strRisk) > 0 then
- if len(strResult) > 0 then
- strResult = strResult & vbcrlf & vbcrlf & strRisk
- else
- strResult = strRisk
- end if
- end if
- GetVulnerabilitiesForContact = Sentence(strResult)
- end function
- function GetInspectorNameFromCode(Inspector_ID)
- dim strStatement
- strStatement = "SELECT CCT.Forename_VC + ' ' + CCT.Surname_VC AS FullName_VC FROM Repairs_Inspectors_T RIT with (nolock) INNER JOIN Shared_Users_T SUT with (nolock) ON SUT.User_ID = RIT.User_ID INNER JOIN Contact_Contacts_T CCT with (nolock) ON CCT.Contact_ID = SUT.Contact_ID WHERE RIT.Inspector_ID = %1"
- with sqlconnection.execute( replace(strStatement,"%1",Inspector_ID))
- do until .eof
- GetInspectorNameFromCode = sentence(.fields(0))
- .movenext
- loop
- end with
- end function
- function GetDescriptionForCode(Code_ID)
- with sqlconnection.execute("Select Description_VC from Shared_Codes_T with (nolock) WHERE Code_ID = " & Code_ID)
- do until .eof
- GetDescriptionForCode = sentence(.fields(0))
- .movenext
- loop
- end with
- end function
- function GetDescriptionForUserCode(Code_ID)
- with sqlconnection.execute("Select Description_VC from Shared_User_Defined_Codes_T with (nolock) WHERE Code_ID = " & Code_ID)
- do until .eof
- GetDescriptionForUSerCode = sentence(.fields(0))
- .movenext
- loop
- end with
- end function
- Function ShowLookup
- dim Lookup
- set Lookup = CreateObject("SQLSearchDialog.CSQLSearch")
- set Lookup.SqlUtil = SQLUtilities
- Lookup.LookupCaption = "Lookup from workflow"
- Lookup.LKUPItem = 178
- Lookup.ShowSearchDialog vbNullstring,vbnullstring
- if len(mid(Lookup.SelectedItems.value,3)) > 0 then
- ShowLookup = mid(Lookup.SelectedItems.Value,3)
- else
- ShowLookup = 0
- end if
- set lookup = nothing
- end function
- function GetEmailAddress(User)
- with sqlconnection.execute("Select Reference_VC from Shared_Users_T AS SUT with (nolock) INNER JOIN Contact_Contact_Details_T CCDT with (nolock) ON SUT.Contact_ID = CCDT.Contact_ID WHERE SYS_Number_Code_ID = 75 and SUT.User_ID = " & User)
- do until .eof
- GetEmailAddress = .fields(0)
- .movenext
- loop
- end with
- end function
- 'Post Inspections
- Function InspectionRandomSelector(varPercentage)
- Rem Version 1.0 24th November 2005 AMS/CAP
- varSelect = "SELECT COUNT(*) AS Counter FROM Repairs_Works_Orders_T with (nolock) WHERE Status_ID = 15"
- varDummy = ""
- With SQLConnection.Execute(varSelect)
- Do Until .EOF
- varCounter = .Fields("Counter").Value
- .MoveNext
- Loop
- End With
- varTmpCheck = varCounter * varPercentage
- varTmpCheck2 = Int(varCounter * varPercentage)
- If varTmpCheck = varTmpCheck2 Then
- InspectionRandomSelector = 1
- Else
- InspectionRandomSelector = 0
- End If
- End Function
- Function CreateFileWithHeaderIfNotExists(File,Header)
- Dim fso
- Dim txtstream
- set fso=CreateObject("Scripting.FileSystemObject")
- if not(fso.FileExists(File)) Then
- set txtstream=fso.OpenTextFile(File, 8, True)
- txtstream.Write Header
- txtstream.Close
- end if
- End Function
- Function OutputToCSVFile(File,Line)
- Dim fso
- Dim txtstream
- set fso=CreateObject("Scripting.FileSystemObject")
- set txtstream=fso.OpenTextFile(File, 8, True)
- txtstream.Write Line
- txtstream.Close
- End Function
- sub showassetinfo(record)
- msgbox record
- end sub
- function Increase(Counter)
- Increase = Counter + 1
- end function
- function CountDelimiter(ItemToCount,Delimiter)
- dim lngCount
- dim lngResult
- for lngcount =1 to len(itemtocount)
- if mid(itemtocount,lngcount,len(Delimiter)) = Delimiter then
- lngResult = lngResult + 1
- end if
- next
- if lngResult = 0 and len(itemtocount) > 0 then lngResult = 1
- CountDelimiter = lngResult
- end function
- Function IsConnectionActive
- dim varSelect
- sqlConnection.Open
- varselect = "SELECT TOP 1 From Shared_Codes_T with (nolock)"
- with sqlConnection.Execute(varSelect)
- do until .eof
- msgbox .fields(0)
- .movenext
- loop
- end with
- sqlConnection.Close
- end function
- function Input(caption)
- Input = inputbox(caption)
- end function
- function MultiplyTogether(a,b)
- MultiplyTogether = a*b
- end function
- Function Notamsgbox( DebugMessage)
- End Function
- Function WriteToFile(FileName, FileText)
- dim fsMMSystem
- dim tsMMFile
- Set fsMMSystem = Createobject("Scripting.FileSystemObject")
- Set tsMMFile = fsMMSystem.CreateTextFile(FileName, True)
- tsMMFile.Write FileText
- tsMMFile.Close
- Set tsMMFile = Nothing
- Set fsMMSystem = Nothing
- end function
- function ZetafaxText(FaxNumber, FaxPerson, FaxOrganisation, FromPerson, FromOrganisation, FaxBody, FaxLetterHead, FaxServerLocation, FaxName)
- Dim strFaxHeader
- dim strFaxBody
- strFaxHeader = "[Details]" & vbCrLf
- strFaxHeader = strFaxHeader & "DestFaxNumber=" & FaxNumber & vbCrLf
- strFaxHeader = strFaxHeader & "DestPerson=" & FaxPerson & vbCrLf
- strFaxHeader = strFaxHeader & "DestOrganisation=" & FaxOrganisation & vbCrLf
- strFaxHeader = strFaxHeader & "SourcePerson=" & FromPerson & vbCrLf
- strFaxHeader = strFaxHeader & "SourceDepartment=" & FromOrganisation & vbCrLf
- 'if ini file specifies a letter head then tell Zetafax to use it!
- If Len(FaxLetterHead) > 0 Then
- strFaxHeader = strFaxHeader & "Letterhead=" & FaxLetterHead
- End If
- strFaxBody = vbCrLf & "[Fax]" & vbCrLf & FaxBody
- WriteToFile FaxServerLocation & "\" & FaxName, strFaxHeader & strFaxBody
- ZetafaxText = true
- End Function
- ' End of MIS Family HA Functions
- Function WriteToFile(FileName, FileText)
- dim fsMMSystem
- dim tsMMFile
- Set fsMMSystem = Createobject("Scripting.FileSystemObject")
- Set tsMMFile = fsMMSystem.CreateTextFile(FileName, True)
- tsMMFile.Write FileText
- tsMMFile.Close
- Set tsMMFile = Nothing
- Set fsMMSystem = Nothing
- end function
- function GetJobType(OrderID)
- dim strJobType
- dim strExec
- strExec = "SELECT TOP 1 RRTL.Job_Type_ID From Repairs_Works_Order_Lines_T AS RWOL with (nolock) INNER JOIN Repairs_Requests_Task_Lines_T RRTL with (nolock) ON"
- strExec = strExec & " RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RRTL.SystemUplift_BT = 0 AND RWOL.WorksOrder_ID = " & OrderID
- with SQLConnection.execute(strExec)
- do until .eof
- strJobType = .fields(0)
- exit do
- loop
- end with
- GetJobType = GetDescriptionForCode(strJobType)
- end function
- function GetDescriptionForCode(Code)
- with SQLConnection.execute("SELECT Description_VC from Shared_Codes_T with (nolock) WHERE Code_ID = " & Code)
- do until .eof
- GetDescriptionForCode = .fields(0)
- exit do
- loop
- end with
- end function
- function GetPriority(OrderID)
- dim strPriority
- dim strExec
- strExec = "SELECT TOP 1 RRTL.Priority_ID From Repairs_Works_Order_Lines_T AS RWOL with (nolock) INNER JOIN Repairs_Requests_Task_Lines_T RRTL with (nolock) ON"
- strExec = strExec & " RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RWOL.WorksOrder_ID = " & OrderID
- with SQLConnection.execute(strExec)
- do until .eof
- strPriority = .fields(0)
- exit do
- loop
- end with
- GetPriority = GetPriorityDescription(strPriority)
- end function
- function GetPriorityDesc(OrderID)
- 'Function created to remove the system uplift tasks from being considered for the priority. also will now pick up the newest line rather than the oldest. New version created so that can switch back to original if needs be. KS 24/11/09
- dim strPriority
- dim strExec
- strExec = "SELECT TOP 1 Priorities.Description_VC From Repairs_Works_Order_Lines_T AS RWOL (nolock) INNER JOIN Repairs_Requests_Task_Lines_T RRTL with (nolock) ON RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID INNER JOIN Shared_Priorities_T Priorities (nolock) on RRTL.Priority_ID = Priorities.Code_ID WHERE RWOL.Status_ID <> 29 and RWOL.WorksOrder_ID = " & OrderID & " and SystemUplift_BT = 0 order by RWOL.worksOrderline_Id desc"
- with SQLConnection.execute(strExec)
- do until .eof
- strPriority = .fields(0)
- exit do
- loop
- end with
- GetPriorityDesc = strPriority
- end function
- function GetPriorityDescription(PriorityCode)
- with SQLConnection.execute("SELECT Description_VC from Shared_Priorities_T with (nolock) WHERE Code_ID = " & PriorityCode)
- do until .eof
- GetPriorityDescription = .fields(0)
- exit do
- loop
- end with
- end function
- function GetAssetAddress(AddressID)
- dim strNumberName
- dim strPremisName
- dim strStreet
- dim strAreaDistrict
- dim strTownCity
- dim strCounty
- dim strCountry
- dim strPostcode
- with sqlconnection.execute("SELECT * From Shared_Addresses_T with (nolock) WHERE Address_ID = " & AddressID)
- do until .eof
- if isnull(.fields("Property_Number_or_Name_VC")) then
- strNumberName = vbnullstring
- else
- strNumberName = .fields("Property_Number_or_Name_VC")
- end if
- if isnull(.fields("Property_or_Premises_Name_VC")) then
- strPremisName = vbnullstring
- else
- strPremisName = .fields("Property_or_Premises_Name_VC")
- end if
- if isnull(.fields("Street_VC")) then
- strStreet = vbnullstring
- else
- strStreet = .fields("Street_VC")
- end if
- if isnull(.fields("District_VC")) then
- strAreaDistrict = vbnullstring
- else
- strAreaDistrict = .fields("District_VC")
- end if
- if isnull(.fields("Town_VC")) then
- strTownCity = vbnullstring
- else
- strTownCity = .fields("Town_VC")
- end if
- if isnull(.fields("County_VC")) then
- strCounty = vbnullstring
- else
- strCounty = .fields("County_VC")
- end if
- if isnull(.fields("Country_VC")) then
- strCountry = vbnullstring
- else
- strCountry = .fields("Country_VC")
- end if
- if isnull(.fields("Postcode_VC")) then
- strPostcode = vbnullstring
- else
- strPostcode = .fields("Postcode_VC")
- end if
- exit do
- loop
- end with
- with sqlConnection.execute("SELECT dbo.fn_USR_FormatAddressAligned ('" & replace(strNumberName,"'","''") & "','" & replace(strPremisName,"'","''") & "','" & replace(strStreet,"'","''") & "','" & replace(strAreaDistrict,"'","''") & "','" & replace(strTownCity,"'","''") & "','" & replace(strCounty,"'","''") & "','" & strCountry & "')")
- if len(strPostCode) > 0 then
- GetAssetAddress = replace(.fields(0) & chr(13) & strPostcode,chr(13),chr(13) & chr(10))
- else
- GetAssetAddress = replace(.fields(0),chr(13),chr(13) & chr(10))
- end if
- end with
- end function
- function GetGroupHomeNumber(GroupID)
- with sqlconnection.execute("SELECT Reference_VC from Contact_Group_Details_T with (nolock) WHERE Group_ID = " & groupid & " and SYS_Number_Code_ID = 71 and Expiry_Date_DT is null")
- do until .eof
- GetGroupHomeNumber = .fields(0)
- exit do
- loop
- end with
- end function
- function GetContactWorkNumber(ContactID,NumberID)
- with sqlconnection.execute("SELECT Reference_VC from Contact_Contact_Details_T with (nolock)WHERE Contact_ID = " & ContactId & " and SYS_Number_Code_ID = " & NumberID)
- do until .eof
- GetContactWorkNumber = .fields(0)
- exit do
- loop
- end with
- end function
- function GetContactNumber(GroupID,NumberID)
- with sqlconnection.execute("SELECT Reference_VC from Contact_Group_Details_T with (nolock) WHERE Group_ID = " & GroupId & " and SYS_Number_Code_ID = " & NumberID)
- do until .eof
- GetContactNumber = .fields(0)
- exit do
- loop
- end with
- end function
- function GetContactName(ContactID)
- with sqlconnection.execute("SELECT Formatted_Name_VC from Contact_Contacts_T with (nolock) WHERE Contact_ID = " & ContactID)
- do until .eof
- GetContactName = .fields(0)
- exit do
- loop
- end with
- end function
- function GetContactMobileNumber(ContactID)
- with sqlconnection.execute("SELECT DISTINCT isnull(CASE WHEN condet.Reference_VC IS NULL THEN (select grpdet.Reference_VC from dbo.Contact_Group_Details_T AS grpdet WITH (nolock) LEFT OUTER JOIN dbo.Contact_Group_Contacts_T AS grpcon WITH (nolock) ON grpdet.Group_ID = grpcon.Group_ID and grpdet.SYS_Number_Code_ID=74 where grpcon.Contact_ID= " & ContactID & "and grpdet.Expiry_Date_DT is null) ELSE condet.Reference_VC END, ' ') FROM dbo.Contact_Group_Details_T AS grpdet WITH (nolock) LEFT OUTER JOIN dbo.Contact_Group_Contacts_T AS grpcon WITH (nolock) ON grpdet.Group_ID = grpcon.Group_ID LEFT OUTER JOIN dbo.Contact_Contact_Details_T AS condet WITH (nolock) ON condet.Contact_ID = grpcon.Contact_ID AND condet.SYS_Number_Code_ID = 74 where grpcon.Contact_ID= " & ContactID)
- do until .eof
- GetContactMobileNumber = .fields(0)
- exit do
- loop
- end with
- end function
- Function GetContractorEmailAddress(Contractor)
- dim strCommand
- strCommand = replace("select Reference_VC From Contact_Group_Details_T CGDT with (nolock) INNER JOIN Repairs_Contractors_T RCT with (nolock) ON RCT.Contact_ID = CGDT.Group_ID WHERE CGDT.SYS_Number_Code_ID = 75 and RCT.Contractor_ID = xxx","xxx",Contractor)
- with sqlConnection.execute(strCommand)
- if not .eof and not .bof then
- GetContractorEmailAddress = .fields(0)
- end if
- end with
- End Function
- Function GetPreferredContactMethod(Contractor)
- ' 11 = Fax
- dim lngResult
- dim strCommand
- strCommand = "SELECT USR_Panel2_Works_Order_Delivery_Method_IN FROM usr_Repairs_Contractors_UDE_1_T with (nolock) WHERE SYS_Parent_Link_ID = " & Contractor
- with Sqlconnection.Execute(strCommand)
- if not .eof and not .bof then
- if not isnull(.fields(0)) then
- lngResult = .fields(0)
- end if
- end if
- end with
- GetPreferredContactMethod = lngResult
- End Function
- function GetEstimatedCompletionDate(OrderID)
- with sqlconnection.execute("SELECT dbo.getEstCompletion(" & orderID & ")")
- do until .eof
- getEstimatedCompletionDate = .fields(0)
- .movenext
- loop
- end with
- end function
- ''#################Raglan CBL Listing WOrkflow v1.0##################
- FUNCTION CalculateSituationTransfer(Share,Under,Wheel,Supp,Med,Adapt,ShelNLR,Major,Racial,Sexual,OtherHar,Domestic,RagTemp,Except,AdaptNLR)
- CalculateSituationTransfer = "G"
- IF Share = "True" OR Under = "True" OR Wheel = "True" OR Med = 21 OR Adapt = "True" OR ShelNLR = "True" THEN
- CalculateSituationTransfer = "P"
- END IF
- IF Major = "True" OR Racial = "True" OR Sexual = "True" OR OtherHar = "True" OR Domestic = "True" OR RagTemp = "True" OR Except = "True" OR Medical = 22 OR AdaptNLR = "True" THEN
- CalculateSituationTransfer = "U"
- END IF
- END FUNCTION
- FUNCTION CalculateSituationApplicant(Reason,Share,Evict,Medical,Except)
- CalculateSituationApplicant = "G"
- SELECT CASE Reason
- CASE 24
- CalculateSituationApplicant = "P"
- CASE 25
- CalculateSituationApplicant = "P"
- CASE 28
- CalculateSituationApplicant = "P"
- CASE 32
- CalculateSituationApplicant = "P"
- CASE 33
- CalculateSituationApplicant = "P"
- CASE 34
- CalculateSituationApplicant = "P"
- CASE 36
- CalculateSituationApplicant = "P"
- CASE 37
- CalculateSituationApplicant = "P"
- CASE 38
- CalculateSituationApplicant = "U"
- CASE 39
- CalculateSituationApplicant = "U"
- CASE 40
- CalculateSituationApplicant = "U"
- CASE 42
- CalculateSituationApplicant = "P"
- CASE 43
- CalculateSituationApplicant = "U"
- CASE 44
- CalculateSituationApplicant = "P"
- END SELECT
- IF (Share = "True" OR Evict = "True" OR Medical = 21) AND CalculateSituationApplicant <> "U" THEN
- CalculateSituationApplicant = "P"
- END IF
- IF Medical = 22 OR Except = "True" THEN
- CalculateSituationApplicant = "U"
- END IF
- END FUNCTION
- ''################# RHA RS 06 June 2007 ##################
- 'FUNCTION SendEmailToContractorVariation(OrderID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,RiskCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning)
- '
- ' dim strBody
- ' dim strEmailAddress
- ' dim strCommand
- ' dim dblTotal
- ' dim lngLines
- ' dim strSOR
- '
- ' strBody = "VARIATION to Order Number: " & OrderID & " " & ConfirmationOrder
- ' strBody = strbody & vbcrlf & "Asset: " & AssetReference
- ' if len(AsbestosWarning) > 0 then
- ' strBody = strBody & AsbestosWarning
- ' end if
- ' strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- ' strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- ' strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- ' strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
- ' strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
- ' strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
- ' strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
- ' strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- ' strBody = strBody & vbcrlf & "Order Date: " & OrderDate
- ' strBody = strBody & vbcrlf & "Risk Code: " & RiskCode
- ' strBody = strBody & vbcrlf & "Job Type: " & JobType
- ' strBody = strBody & vbcrlf & "Priority: " & Priority
- ' strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- ' strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- ' strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- ' strBody = strBody & vbcrlf & vbcrlf & '"======================================================================================================="
- ' strCommand = Replace("SELECT SST.SOR_Code_VC, rrtlt.NarrativeDescription_VC, rrtlt.Quantity_DC,rwolt.ContractValue_MN From Repairs_Requests_Task_Lines_T RRTLT (nolock) INNER JOIN Repairs_Works_Order_Lines_T RWOLT (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID LEFT JOIN Shared_SORS_T SST (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE rrtlt.Status_ID = 5 AND RWOLT.WorksOrder_ID = xxx","xxx",OrderID)
- ' with sqlconnection.execute(strCommand)
- ' do until .eof
- ' strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- ' for lngLines = 0 to ubound(strSOR)
- ' if lngLines = 0 then
- ' if isnull(.fields(0)) then
- ' strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- ' else
- ' strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & 'strsor(lngLines)
- ' end if
- ' strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- ' strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- ' else
- ' strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- ' end if
- ' next
- ' dblTotal = dblTotal + .fields(3)
- ' .movenext
- ' loop
- ' end with
- '
- ' strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- '
- ' strBody = strBody & vbcrlf & vbcrlf & '"======================================================================================================="
- '
- ' strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- '
- ' strEmailAddress = GetContractorEmailAddress(Contractor)
- '
- '' msgbox strBody,vbexclamation+vbokonly,"Email should be this"
- '
- ' CDOEmailUsingOutputAttach "Variation to Works Order " & OrderID & " " & 'ConfirmationOrder,"ActiveHWO@raglan.org",strEmailAddress,"","ActiveHWO@raglan.org",strBody,"",""
- '
- 'End Function
- 'NEW VERSION - RS 06 AUG 2008
- 'Amendment 26/11/2015 - added additional variables at start, assigned values to variables and changed from CDOMail to SQLMail
- Function SendEmailToContractorVariation(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,RiskCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning)
- dim strBody
- dim strEmailAddress
- dim strCommand
- dim dblTotal
- dim lngLines
- dim strSOR
- dim strProfile '- 26/11/2015
- dim strFromaddress '- 26/11/2015
- dim strCCaddress '- 26/11/2015
- dim strBCCaddress '- 26/11/2015
- dim strSubject '- 26/11/2015
- strBody = "VARIATION to Order Number: " & OrderID & " " & ConfirmationOrder
- strBody = strbody & vbcrlf & "Request ID: " & RequestID
- strBody = strbody & vbcrlf & "Asset: " & AssetReference
- if len(AsbestosWarning) > 0 then
- strBody = strBody & vbcrlf & AsbestosWarning
- end if
- strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
- strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
- strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
- strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
- strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- strBody = strBody & vbcrlf & "Order Date: " & OrderDate
- strBody = strBody & vbcrlf & "Risk Code: " & RiskCode
- strBody = strBody & vbcrlf & "Job Type: " & JobType
- strBody = strBody & vbcrlf & "Priority: " & Priority
- strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strCommand = Replace("SELECT SST.SOR_Code_VC, rrtlt.NarrativeDescription_VC, rrtlt.Quantity_DC,rwolt.ContractValue_MN,rwolt.WorksOrderLine_ID From Repairs_Requests_Task_Lines_T RRTLT with (nolock) INNER JOIN Repairs_Works_Order_Lines_T RWOLT with (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID LEFT JOIN Shared_SORS_T SST with (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE rrtlt.Status_ID = 5 AND RWOLT.WorksOrder_ID = xxx","xxx",OrderID)
- with sqlconnection.execute(strCommand)
- do until .eof
- strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- for lngLines = 0 to ubound(strSOR)
- if lngLines = 0 then
- if isnull(.fields(0)) then
- strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- else
- strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
- end if
- strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
- strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- else
- strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- end if
- next
- dblTotal = dblTotal + .fields(3)
- .movenext
- loop
- end with
- strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- strEmailAddress = GetContractorEmailAddress(Contractor) ' - retrieve email from contractor
- strFromaddress = "activeH.WO@stonewater.org"
- strCCaddress = ""
- strBCCaddress = "activeH.WO@stonewater.org;stonewaterworksorders@gmail.com;dan.garbett@stonewater.org.uk"
- strSubject = "Works Order " & OrderID
- strProfile = "ContractorEmails"
- 'msgbox "DEBUG - Sending to SendEmailSQL"
- 'msgbox "Body = " & strBody
- 'msgbox "EmailAddress - " & strEmailAddress & vbcrlf & "FromAddress - " & strFromaddress & vbcrlf & "CCAddress - " & strCCaddress & vbcrlf & "BCCAdress - " & strBCCaddress & vbcrlf & "Subject - " & strSubject & vbcrlf & "Body - " & left(strBody,20) & vbcrlf & "Mail Profile - " & strProfile
- SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
- 'msgbox "DEBUG - Returned from SendEmailSQL"
- ' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",strEmailAddress,"","ActiveH.WO@stonewater.org;stonewaterworksorders@gmail.com",strBody,"",""
- End Function
- function RHA_GetOtherTelNumberForContact(Contact_ID)
- dim strResult
- with sqlconnection.execute("SELECT OtherTel FROM RHA_CRM_Caller_Panel_OtherTel_V with (nolock) WHERE Group_Contact_ID = " & Contact_ID)
- do until .eof
- if len(strResult) = 0 then
- strResult = "Other Tel: " & ( .fields(0))
- else
- strResult = strResult & ","
- end if
- .movenext
- loop
- end with
- RHA_GetOtherTelNumberForContact = Sentence(strResult)
- end function
- Function ReturnResultFromStringNoLineSpaces(String1,String2,String3,String4)
- dim strResult
- '-- Debug msgbox String1 & ", " & string2 & ", " & string3 & ", " & string4
- if len(String1) > 0 then
- strResult = String1
- end if
- if len(String2) > 0 then
- if len(strResult) = 0 then
- strResult = String2
- else
- strResult = strResult & vbcrlf & String2
- end if
- end if
- if len(String3) > 0 then
- if len(strResult) = 0 then
- strResult = String3
- else
- strResult = strResult & vbcrlf & String3
- end if
- end if
- if len(String4) > 0 then
- if len(strResult) = 0 then
- strResult = String4
- else
- strResult = strResult & vbcrlf & String4
- end if
- end if
- '-- Debug msgbox strResult
- ReturnResultFromStringNoLineSpaces = Sentence(strResult)
- End Function
- function GetNewPriority(OrderID)
- dim strPriority
- dim strExec
- strExec = "SELECT TOP 1 RRTL.Priority_ID From Repairs_Works_Order_Lines_T AS RWOL with (nolock) INNER JOIN Repairs_Requests_Task_Lines_T RRTL with (nolock) ON"
- strExec = strExec & " RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RWOL.WorksOrder_ID = " & OrderID & " AND (NOT (RWOL.Status_ID IN ('27','28','29')))"
- with SQLConnection.execute(strExec)
- do until .eof
- strPriority = .fields(0)
- exit do
- loop
- end with
- GetNewPriority = GetPriorityDescription(strPriority)
- end function
- Function NewTenancyTracker(VarAccountID)
- Rem Version 1.0 08 APR 2008 RS
- varSelect = "INSERT INTO RHA_NewTenancyTracker (ID) VALUES (" & varAccountID & ")"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- function RHA_SendEmailToDefectsAgent (OrderID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,RiskCode,JobType,Priority,EstimatedCompletion,ConfirmationOrder,AsbestosWarning,EmailAddress)
- dim strBody
- dim strEmailAddress
- dim strCommand
- dim dblTotal
- dim lngLines
- dim strSOR
- dim strProfile '- 26/11/2015
- dim strFromaddress '- 26/11/2015
- dim strCCaddress '- 26/11/2015
- dim strBCCaddress '- 26/11/2015
- dim strSubject '- 26/11/2015
- strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
- strBody = strbody & vbcrlf & "Asset: " & AssetReference
- if len(AsbestosWarning) > 0 then
- strBody = strBody & AsbestosWarning
- end if
- strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
- strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
- strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
- strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
- strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- strBody = strBody & vbcrlf & "Order Date: " & OrderDate
- strBody = strBody & vbcrlf & "Risk Code: " & RiskCode
- strBody = strBody & vbcrlf & "Job Type: " & JobType
- strBody = strBody & vbcrlf & "Priority: " & Priority
- strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strCommand = Replace("SELECT SST.SOR_Code_VC, rrtlt.NarrativeDescription_VC, rrtlt.Quantity_DC,rwolt.ContractValue_MN From Repairs_Requests_Task_Lines_T RRTLT with (nolock) INNER JOIN Repairs_Works_Order_Lines_T RWOLT with (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID LEFT JOIN Shared_SORS_T SST with (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE rrtlt.Status_ID = 5 AND RWOLT.WorksOrder_ID = xxx","xxx",OrderID)
- with sqlconnection.execute(strCommand)
- do until .eof
- strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- for lngLines = 0 to ubound(strSOR)
- if lngLines = 0 then
- if isnull(.fields(0)) then
- strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- else
- strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
- end if
- strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- else
- strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- end if
- next
- dblTotal = dblTotal + .fields(3)
- .movenext
- loop
- end with
- strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- strEmailAddress = EmailAddress
- strFromaddress = "ActiveH.WO@Stonewater.org"
- strCCaddress = ""
- strBCCaddress = "ActiveH.WO@stonewater.org"
- strSubject = "Works Order " & OrderID
- strProfile = "ContractorEmails"
- SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
- ' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",strEmailAddress,"","ActiveHWO@stonewater.org",strBody,"",""
- End Function
- Function AssetDisposedCheck(AssetID)
- 'RHA RS 19 AUG 2008 - Replacement Function to Check for disposed status.
- dim strCommand
- strCommand = "select dbo.fn_AssetStatus(" & AssetID & ", getdate()) as Status, Effective_Date_DT from Asset_Asset_Status_T with (nolock) Where Asset_ID = " & AssetID
- with sqlconnection.execute(strCommand)
- if not .eof and not .bof then
- if .fields(0).Value = "Disposed" then
- msgbox "This asset was disposed on " & .fields(1).Value,vbexclamation+vbokonly,"Disposed"
- AssetDisposedCheck = True
- else
- AssetDisposedCheck = False
- end if
- end if
- .close
- end with
- End Function
- '*****DO NOT USE THIS VERSION UNTIL 581 GO LIVE*****
- Function AssetDisposedCheckv2(AssetID)
- 'RHA RS 19 AUG 2008 - Replacement Function to Check for disposed status.
- 'RHA KS 08 MAY 2010 - cleaned function up so it just uses the SQL function, table Asset_Asset_Status_t has
- ' been removed in 580
- dim strCommand
- strCommand = "select top 1 dbo.fn_AssetStatus(" & AssetID & ", getdate()) as Status, Effective_From_Dt from Asset_Asset_Status_Effectives_T with (nolock) where Status_Type_ID = 134 and Asset_ID = " & AssetID & " order by Effective_From_Dt desc"
- with sqlconnection.execute(strCommand)
- if not .eof and not .bof then
- if .fields(0).Value = "Disposed" then
- msgbox "This asset was disposed on " & .fields(1).Value, vbexclamation+vbokonly, "Disposed"
- AssetDisposedCheckv2 = TRUE
- else
- AssetDisposedCheckv2 = False
- end if
- end if
- .close
- end with
- End Function
- Function BuildTmpTablesForPartnersWF
- 'RHA RS 07 Oct 2008
- 'RHA RS 10 DEC 2008 Added REPLACE Command to remove the ' character from the addresses.
- dim strCommand
- dim varLastRunDate
- dim varNewRunDate
- dim strWorkOrderID
- dim strAssetID
- dim strAddress
- dim strContractorPatch
- dim strDateAdded
- dim strHierarchyID
- dim strGroupName
- dim nonAccess
- 'Update the LastRunTime Table
- with sqlconnection.execute("set dateformat dmy insert into RHA_Repairs_Partnering_Manual_Hook_T(LastRunTime) VALUES (getdate())")
- end with
- 'Build the Tenent Recharge Table
- with sqlconnection.execute("SET DATEFORMAT DMY select WorksOrder_ID,Address from RHA_Repairs_TenentRechargePartners_V (nolock) WHERE ((DateTime_DT > '" & varLastRunDate & "') AND (DateTime_DT <= '" & varNewRunDate & "'))")
- 'msgbox varNewRunDate,vbexclamation+vbokonly,"TENENT RECHARGE Post Select"
- Do Until .EOF
- strWorkOrderID = .fields(0)
- strAddress = .fields(1)
- strAddress = REPLACE(strAddress, "'","")
- strCommand = "insert into RHA_Temp_Recharges_T(WorksOrderID,Address) VALUES ('" & strWorkOrderID & "','" & strAddress & "')"
- with sqlconnection.execute(strCommand)
- end with
- .MoveNext
- LOOP
- end with
- 'Build the Insurance Reclaim Table
- with sqlconnection.execute("set dateformat dmy select WorksOrder_ID,Address from RHA_Repairs_InsuranceReclaimPartners_V (nolock) WHERE ((DateTime_DT > '" & varLastRunDate & "') AND (DateTime_DT <= '" & varNewRunDate & "'))")
- Do Until .EOF
- strWorkOrderID = .fields(0)
- strAddress = .fields(1)
- strAddress = REPLACE(strAddress, "'","")
- strCommand = "insert into RHA_Temp_InsuranceReclaim_T(WorksOrderID, Address) VALUES ('" & strWorkOrderID & "','" & strAddress & "')"
- with sqlconnection.execute(strCommand)
- end with
- .MoveNext
- LOOP
- end with
- 'Build the Disabled Adaptations Table
- with sqlconnection.execute("set dateformat dmy select WorksOrder_ID,Address,Group_Name_VC,OfficeSupervisorID from RHA_Repairs_DisabledAdaptationsPartners_V (nolock) WHERE ((DateTime_DT > '" & varLastRunDate & "') AND (DateTime_DT <= '" & varNewRunDate & "'))")
- Do Until .EOF
- strWorkOrderID = .fields(0)
- strAddress = .fields(1)
- strGroupName = .fields(2)
- strHierarchyID = .fields(3)
- strAddress = REPLACE(strAddress, "'","")
- strGroupName = REPLACE(strGroupName, "'"," ")
- strCommand = "insert into RHA_Temp_DisabledAdaptations_T(WorksOrderID,Address,GroupName,AssignToID) VALUES ('" & strWorkOrderID & "' ,'" & strAddress & "' ,'" & strGroupName & "' ,'" & strHierarchyID & "')"
- with sqlconnection.execute(strCommand)
- end with
- .MoveNext
- LOOP
- end with
- End Function
- Function getSchemeAssetID(Asset)
- dim strSQL
- strSQL = ("select case when child.Parent_Asset_Type_ID = 1 then child.Parent_ID else (select par.Parent_ID from Asset_Asset_Structure_T as child1 with (nolock) inner join Asset_Asset_Structure_T as par with (nolock) on child1.Parent_ID=par.Child_ID where child1.Child_ID = " & Asset & ") end from Asset_Asset_Structure_T as child with (nolock) inner join Asset_Asset_Structure_T as par with (nolock) on child.Parent_ID = par.Child_ID where child.Child_ID = " & Asset)
- with sqlconnection.execute(strSQL)
- do until .eof
- getSchemeAssetID = .fields(0)
- .movenext
- loop
- end with
- End Function
- Function GetAgeOfProperty(AssetID)
- dim strResult
- dim strCommand
- strCommand = "SET DATEFORMAT DMY SELECT dbo.Asset_Attribute_Occurrences_T.Fitted_Renewed_Date_DT AS BuildDate FROM dbo.Asset_Assets_T WITH (nolock) INNER JOIN dbo.Asset_Attribute_Occurrences_T WITH (nolock) ON dbo.Asset_Assets_T.Asset_ID = dbo.Asset_Attribute_Occurrences_T.Asset_ID INNER JOIN dbo.Shared_User_Defined_Codes_T WITH (nolock) ON dbo.Asset_Attribute_Occurrences_T.Type_ID = dbo.Shared_User_Defined_Codes_T.Code_ID WHERE(dbo.Asset_Attribute_Occurrences_T.Attribute_ID = 208) AND dbo.Asset_Assets_T.Asset_ID = " & AssetID
- with sqlconnection.execute(strCommand)
- do until .eof
- if not isnull(.fields(0)) then
- strResult = .fields(0)
- else
- strResult = "Not Found"
- end if
- .movenext
- Loop
- end with
- GetAgeOfProperty = strResult
- End Function
- Function BuildTmpTablesForAssuredStarterWarning
- 'RHA 20 Oct 2008 RS
- dim strCommand
- dim varLastRunDate
- dim varNewRunDate
- dim strAccountID
- dim strAccountStartDate
- dim strAddress
- dim strLHOID
- dim strTenantNames
- dim strRHMEmail
- dim strLHOName
- with sqlconnection.execute("set dateformat dmy SELECT TOP 1 LastRunTime FROM RHA_Rents_AssuredShorthold_Manual_Hook_T ORDER BY ID DESC")
- varLastRunDate = .fields(0)
- 'msgbox varLastRunDate,vbexclamation+vbokonly,"Last Run Time"
- end with
- with sqlconnection.execute("SELECT GETDATE() AS CurrentDateTime")
- varNewRunDate = .fields(0)
- 'msgbox varNewRunDate,vbexclamation+vbokonly,"New Run Time"
- end with
- 'Build the TMP Table
- with sqlconnection.execute("set dateformat dmy SELECT ID,AccountStartDate,Address,LHO_ID,TenantNames,LHO_Username,RHMEmail FROM RHA_Rents_AssuredShortholdStarterTenancy_V with (nolock) WHERE ((FinalReviewWarningDate > '" & varLastRunDate & "') AND (FinalReviewWarningDate <= '" & varNewRunDate & "'))")
- Do Until .EOF
- strAccountID = .fields(0)
- strAccountStartDate = .fields(1)
- strAddress = .fields(2)
- strLHOID = .fields(3)
- strTenantNames = .fields(4)
- strLHOName = .fields(5)
- strRHMEmail = .fields(6)
- strAddress = REPLACE(strAddress, "'","")
- strTenantNames = REPLACE(strTenantNames, "'"," ")
- strCommand = "set dateformat dmy INSERT INTO RHA_TEMP_Rents_AssuredShortWarning_T (AccountID,AccountStartDate,Address,TenantNames,LHOID,LHOName,RHMEmail) VALUES ('" & strAccountID & "','" & strAccountStartDate & "','" & strAddress & "','" & strTenantNames & "','" & strLHOID & "','" & strLHOName & "','" & strRHMEmail & "')"
- with sqlconnection.execute(strCommand)
- end with
- .MoveNext
- LOOP
- end with
- 'msgbox varLastRunDate,vbexclamation+vbokonly,"Post Table Updates"
- 'Update the lastruntime table
- with sqlconnection.execute("set dateformat dmy INSERT INTO RHA_Rents_AssuredShorthold_Manual_Hook_T(LastRunTime) VALUES ('" & varNewRunDate & "')")
- end with
- END FUNCTION
- Function AssuredStarterTracker(VarAccountID,varTenancyType)
- Rem Version 1.0 30 Oct 2008 RS
- varSelect = "INSERT INTO RHA_Rents_AssuredStarterTracker_T (ID,TenancyType) VALUES ('" & varAccountID & "','" & varTenancyType & "')"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function GetRSOHierarchyID(AssetID)
- dim varHID
- varSelect = "SELECT Hierarchy_ID FROM RHA_AssetsByRSOS_V with (nolock) WHERE Asset_ID = '" & AssetID & "'"
- with sqlconnection.execute(varSelect)
- varHID = .fields(0)
- End With
- GetRSOHierarchyID = varHID
- End Function
- Function NewAssuredStarterTenancyTracker(VarAccountID)
- Rem Version 1.0 30 Oct 2008 RS
- varSelect = "INSERT INTO RHA_Rents_AssuredStarterTracker_T (ID) VALUES (" & varAccountID & ")"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function DeleteAssuredStarterTracker(varAccountID)
- Rem Version 1.0 30 Oct 2008 RS
- varSelect = "DELETE FROM RHA_Rents_AssuredStarterTracker_T WHERE ID = '" & varAccountID & "'"
- with sqlconnection.execute(varSelect)
- end with
- End Function
- Function NewGasLetterNoPlan(VarLetterType,VarAccountRef,VarAssetRef,VarFormattedAssetAddress,VarUnformattedAssetAddress,VarDearNames,VarSalutation,VarContractorName,VarContractorTel)
- rem Version 1.0 14 July 2008 RS
- dim varIDSeed
- varSelect = "INSERT INTO RAGLAN_GASSERVICELETTERS_T (LetterType, AccountRef, AssetRef, FormattedAssetAddress, UnformattedAssetAddress, DearNames, Salutation, ContractorName, ContractorTel) VALUES ('" & VarLetterType & "', '" & VarAccountRef & "', '" & VarAssetRef & "', '" & VarFormattedAssetAddress & "', '" & VarUnformattedAssetAddress & "', '" & VarDearNames & "', '" & VarSalutation & "', '" & VarContractorName & "', '" & VarContractorTel & "')"
- WITH SQLConnection.Execute(varSelect)
- END WITH
- varSelect = "SELECT MAX(ID) FROM RAGLAN_GASSERVICELETTERS_T WITH (NOLOCK) WHERE (AccountRef = '" & VarAccountRef & "')"
- WITH SQLConnection.Execute(varSelect)
- DO UNTIL .EOF
- varIDSeed = .fields(0)
- EXIT DO
- LOOP
- END WITH
- NewGasLetterNoPlan = varIDSeed
- END FUNCTION
- Function GetGasServiceType(AssetID)
- 'RS New Function 20 Apr 2009
- 'Values are... 1573 Gas Service Required, 1574 Supply Only, 1575 Gas Supply Carcus Inactive,
- '1576 No Gas, 1577 Not Known.
- varSelect = ("SELECT CASE WHEN dbo.Asset_Attribute_Occurrences_T.Type_ID = '1573' THEN 'Gas Service Required' WHEN dbo.Asset_Attribute_Occurrences_T.Type_ID = '1574' THEN 'Supply Only or No Appliances' WHEN dbo.Asset_Attribute_Occurrences_T.Type_ID = '1575' THEN 'Gas Supplier Made Carcuss Inactive' WHEN dbo.Asset_Attribute_Occurrences_T.Type_ID = '1576' THEN 'No Gas in Property or Communal Services' WHEN dbo.Asset_Attribute_Occurrences_T.Type_ID = '1577' THEN 'Not Known Check Required' ELSE 'Gas Service Type not Setup' End As Type FROM dbo.Asset_Assets_T with (nolock) LEFT OUTER JOIN dbo.Asset_Attribute_Occurrences_T with (nolock) ON dbo.Asset_Assets_T.Asset_ID = dbo.Asset_Attribute_Occurrences_T.Asset_ID WHERE (dbo.Asset_Assets_T.Asset_ID = '" & AssetID & "') AND (dbo.Asset_Attribute_Occurrences_T.Attribute_ID = 333)")
- with SQLConnection.Execute(varSelect)
- Do Until .EOF
- varResult = .fields(0)
- .MoveNext
- Loop
- End With
- 'msgbox varResult
- GetGasServiceType = varResult
- End Function
- Function getContract(OrderID)
- dim strContract, strExec
- strExec = "SELECT TOP 1 RC.Description_vc, RC.Contract_ID From Repairs_Works_Order_Lines_T AS RWOL (NoLock) INNER JOIN Repairs_Contracts_T as RC (NoLock) on rwol.Contract_ID = RC.Contract_ID Where rwol.WorksOrder_ID =" & OrderID
- with SQLConnection.execute(strExec)
- do until .eof
- strContract = .fields(0)
- strContract = .fields(1) & " (" & strcontract &")"
- exit do
- loop
- end with
- getContract = strContract
- End Function
- function GetJobTypeDesc(OrderID)
- dim strJobType, strExec
- strExec = "SELECT TOP 1 RRTL.Job_Type_ID From Repairs_Works_Order_Lines_T AS RWOL (nolock) INNER JOIN Repairs_Requests_Task_Lines_T RRTL (nolock) ON RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RRTL.SystemUplift_BT = 0 AND RWOL.WorksOrder_ID = " & OrderID
- with SQLConnection.execute(strExec)
- do until .eof
- strJobType = .fields(0)
- exit do
- loop
- end with
- GetJobTypeDesc = replace(GetDescriptionForCode(strJobType)," & "," and ") & " (" & strJobType & ")"
- end function
- 'Updated 12/11/10 to include the Visit Requirement in the email. KS
- Function SendEmailToContractorOLD(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,VulCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning, Contract, Visit)
- dim strBody
- dim strEmailAddress
- dim strCommand
- dim dblTotal
- dim lngLines
- dim strSOR
- strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
- strBody = strbody & vbcrlf & "Request ID: " & RequestID
- strBody = strbody & vbcrlf & "Asset: " & AssetReference
- if len(AsbestosWarning) > 0 then
- strBody = strBody & vbcrlf & AsbestosWarning
- end if
- strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- strBody = strBody & vbcrlf & "Contract: " & Contract
- strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
- strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
- strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
- strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
- strBody = strBody & vbcrlf & "Visit Requirements: " & Visit
- strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
- strBody = strBody & vbcrlf & vbcrlf & "Vulnerability Code(s): " & VulCode
- strBody = strBody & vbcrlf & "Job Type: " & JobType
- strBody = strBody & vbcrlf & "Priority: " & Priority
- strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strCommand = ("SELECT SST.SOR_Code_VC, RRTLT.NarrativeDescription_VC, RRTLT.Quantity_DC, RWOLT.ContractValue_MN, RWOLT.WorksOrderLine_ID, RRTLT.TradeCode_ID, dbo.Shared_Codes_T.Description_VC FROM dbo.Repairs_Requests_Task_Lines_T AS RRTLT (nolock) INNER JOIN dbo.Repairs_Works_Order_Lines_T AS RWOLT (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID INNER JOIN dbo.Shared_Codes_T (nolock)ON RRTLT.TradeCode_ID = dbo.Shared_Codes_T.Code_ID LEFT OUTER JOIN dbo.Shared_SORs_T AS SST (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE (RRTLT.Status_ID = 5) AND RWOLT.WorksOrder_ID =" & OrderID)
- with sqlconnection.execute(strCommand)
- do until .eof
- strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- for lngLines = 0 to ubound(strSOR)
- if lngLines = 0 then
- if isnull(.fields(0)) then
- strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- else
- strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
- end if
- strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
- strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
- else
- strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- end if
- next
- dblTotal = dblTotal + .fields(3)
- .movenext
- loop
- end with
- strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- strEmailAddress = GetContractorEmailAddress(Contractor)
- msgbox strBody,vbexclamation+vbokonly,"Email sent using SendEmailToContractorOLD - PLEASE INFORM BUSINESS SYSTEMS IMMEDIATELY"
- CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@raglan.org",strEmailAddress,"","ActiveHWO@raglan.org",strBody,"",""
- 'msgbox "Email Sent"
- End Function
- 'Amendment 26/11/2015 - added additional variables at start, assigned values to variables and changed from CDOMail to SQLMail
- Function SendEmailToContractor(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,VulCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning, Contract, Visit, FilePath, EmailAddress)
- dim strBody
- dim strEmailAddress
- dim strCommand
- dim dblTotal
- dim lngLines
- dim strSOR
- dim strProfile '- 26/11/2015
- dim strFromaddress '- 26/11/2015
- dim strCCaddress '- 26/11/2015
- dim strBCCaddress '- 26/11/2015
- dim strSubject '- 26/11/2015
- strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
- strBody = strbody & vbcrlf & "Request ID: " & RequestID
- strBody = strbody & vbcrlf & "Asset: " & AssetReference
- if len(AsbestosWarning) > 0 then
- strBody = strBody & vbcrlf & AsbestosWarning
- end if
- strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- strBody = strBody & vbcrlf & "Contract: " & Contract
- strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
- strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
- strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
- strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
- strBody = strBody & vbcrlf & "Visit Requirements: " & Visit
- strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
- strBody = strBody & vbcrlf & vbcrlf & "Vulnerability Code(s): " & VulCode
- strBody = strBody & vbcrlf & "Job Type: " & JobType
- strBody = strBody & vbcrlf & "Priority: " & Priority
- strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strCommand = ("SELECT SST.SOR_Code_VC, RRTLT.NarrativeDescription_VC, RRTLT.Quantity_DC, RWOLT.ContractValue_MN, RWOLT.WorksOrderLine_ID, RRTLT.TradeCode_ID, dbo.Shared_Codes_T.Description_VC FROM dbo.Repairs_Requests_Task_Lines_T AS RRTLT (nolock) INNER JOIN dbo.Repairs_Works_Order_Lines_T AS RWOLT (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID INNER JOIN dbo.Shared_Codes_T (nolock) ON RRTLT.TradeCode_ID = dbo.Shared_Codes_T.Code_ID LEFT OUTER JOIN dbo.Shared_SORs_T AS SST (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE (RRTLT.Status_ID = 5) AND RWOLT.WorksOrder_ID = " & OrderID)
- with sqlconnection.execute(strCommand)
- do until .eof
- strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- for lngLines = 0 to ubound(strSOR)
- if lngLines = 0 then
- if isnull(.fields(0)) then
- strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- else
- strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
- end if
- strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
- strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
- else
- strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- end if
- next
- dblTotal = dblTotal + .fields(3)
- .movenext
- loop
- end with
- strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- strEmailAddress = GetContractorEmailAddress(Contractor) ' - retrieve email from contractor
- strFromaddress = "ActiveH.WO@Stonewater.org"
- strCCaddress = ""
- strBCCaddress = "ActiveH.WO@stonewater.org;stonewaterworksorders@gmail.com"
- strSubject = "Works Order " & OrderID
- strProfile = "ContractorEmails"
- SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
- ' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",EmailAddress,"","ActiveH.WO@stonewater.org;stonewaterworksorders@gmail.com",strBody,"",FilePath
- msgbox "Email Sent to Contractor: " & EmailAddress
- End Function
- ' Copied from SendEmailToContractor for use with monthly estate management lot worksorders
- Function SendEmailToContractorEM(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,VulCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning, Contract, Visit, FilePath, EmailAddress)
- dim strBody
- dim strEmailAddress
- dim strCommand
- dim dblTotal
- dim lngLines
- dim strSOR
- dim strProfile '- 26/11/2015
- dim strFromaddress '- 26/11/2015
- dim strCCaddress '- 26/11/2015
- dim strBCCaddress '- 26/11/2015
- dim strSubject '- 26/11/2015
- strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
- strBody = strbody & vbcrlf & "Request ID: " & RequestID
- strBody = strbody & vbcrlf & "Asset: " & AssetReference
- if len(AsbestosWarning) > 0 then
- strBody = strBody & vbcrlf & AsbestosWarning
- end if
- ' strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- strBody = strBody & vbcrlf & "Contract: " & Contract
- ' strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- ' strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
- ' strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
- ' strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
- ' strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
- ' strBody = strBody & vbcrlf & "Visit Requirements: " & Visit
- ' strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
- ' strBody = strBody & vbcrlf & vbcrlf & "Vulnerability Code(s): " & VulCode
- strBody = strBody & vbcrlf & "Job Type: " & JobType
- strBody = strBody & vbcrlf & "Priority: " & Priority
- ' strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- ' strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strCommand = ("SELECT SST.SOR_Code_VC, RRTLT.NarrativeDescription_VC, RRTLT.Quantity_DC, RWOLT.ContractValue_MN, RWOLT.WorksOrderLine_ID, RRTLT.TradeCode_ID, dbo.Shared_Codes_T.Description_VC FROM dbo.Repairs_Requests_Task_Lines_T AS RRTLT (nolock) INNER JOIN dbo.Repairs_Works_Order_Lines_T AS RWOLT (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID INNER JOIN dbo.Shared_Codes_T (nolock) ON RRTLT.TradeCode_ID = dbo.Shared_Codes_T.Code_ID LEFT OUTER JOIN dbo.Shared_SORs_T AS SST (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE (RRTLT.Status_ID = 5) AND RWOLT.WorksOrder_ID = " & OrderID)
- with sqlconnection.execute(strCommand)
- do until .eof
- strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- for lngLines = 0 to ubound(strSOR)
- if lngLines = 0 then
- if isnull(.fields(0)) then
- strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- else
- strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
- end if
- strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
- strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
- else
- strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- end if
- next
- dblTotal = dblTotal + .fields(3)
- .movenext
- loop
- end with
- strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- strEmailAddress = GetContractorEmailAddress(Contractor) ' - retrieve email from contractor
- strFromaddress = "ActiveH.WO@Stonewater.org"
- strCCaddress = "jag.gill@stonewater.org;Anne.Phillips@stonewater.org"
- strBCCaddress = "indrek.ankur@stonewater.org;dennis.miller@stonewater.org;ActiveH.WO@stonewater.org;stonewaterworksorders@gmail.com"
- strSubject = "Works Order " & OrderID
- strProfile = "ContractorEmails"
- SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
- ' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",EmailAddress,"","ActiveH.WO@stonewater.org;stonewaterworksorders@gmail.com",strBody,"",FilePath
- ' msgbox "Email Sent to Contractor: " & strEmailAddress
- End Function
- 'Emails the email address that is passed to the function
- 'Created 08/12/09 KS
- 'Modification to remove the Asbestos information (KS 13/03/10)
- Function SendEmailToSchemeGroup(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,VulCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, Contract,SchemeEmail)
- dim strBody
- dim strEmailAddress
- dim strCommand
- dim dblTotal
- dim lngLines
- dim strSOR
- dim strProfile '- 26/11/2015
- dim strFromaddress '- 26/11/2015
- dim strCCaddress '- 26/11/2015
- dim strBCCaddress '- 26/11/2015
- dim strSubject '- 26/11/2015
- strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
- strBody = strbody & vbcrlf & "Request ID: " & RequestID
- strBody = strbody & vbcrlf & "Asset: " & AssetReference
- strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- strBody = strBody & vbcrlf & "Contract: " & Contract
- strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
- strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
- strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
- strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
- strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
- strBody = strBody & vbcrlf & vbcrlf & "Vulnerability Code(s): " & VulCode
- strBody = strBody & vbcrlf & "Job Type: " & JobType
- strBody = strBody & vbcrlf & "Priority: " & Priority
- strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strCommand = ("SELECT SST.SOR_Code_VC, RRTLT.NarrativeDescription_VC, RRTLT.Quantity_DC, RWOLT.ContractValue_MN, RWOLT.WorksOrderLine_ID, RRTLT.TradeCode_ID, dbo.Shared_Codes_T.Description_VC FROM dbo.Repairs_Requests_Task_Lines_T AS RRTLT (nolock) INNER JOIN dbo.Repairs_Works_Order_Lines_T AS RWOLT (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID INNER JOIN dbo.Shared_Codes_T (nolock)ON RRTLT.TradeCode_ID = dbo.Shared_Codes_T.Code_ID LEFT OUTER JOIN dbo.Shared_SORs_T AS SST (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE (RRTLT.Status_ID = 5) AND RWOLT.WorksOrder_ID =" & OrderID)
- with sqlconnection.execute(strCommand)
- do until .eof
- strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- for lngLines = 0 to ubound(strSOR)
- if lngLines = 0 then
- if isnull(.fields(0)) then
- strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- else
- strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
- end if
- strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
- strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
- else
- strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- end if
- next
- dblTotal = dblTotal + .fields(3)
- .movenext
- loop
- end with
- strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- strEmailAddress = SchemeEmail
- strFromaddress = "ActiveH.WO@Stonewater.org"
- strCCaddress = ""
- strBCCaddress = ""
- strSubject = "Works Order " & OrderID
- strProfile = "ContractorEmails"
- SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
- ' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",SchemeEmail,"","ActiveH.WO@stonewater.org",strBody,"",""
- msgbox "Email Sent to Scheme: " & SchemeEmail
- End Function
- 'Emails the email address that is passed to the function
- 'Created 13/03/2010 KS
- Function SendEmailToSpokesPerson(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,VulCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, Contract,SpokespersonEmail)
- dim strBody
- dim strEmailAddress
- dim strCommand
- dim dblTotal
- dim lngLines
- dim strSOR
- dim strProfile '- 26/11/2015
- dim strFromaddress '- 26/11/2015
- dim strCCaddress '- 26/11/2015
- dim strBCCaddress '- 26/11/2015
- dim strSubject '- 26/11/2015
- strBody = "The following repair has been logged against the communal area for which you are the elected spokesperson"
- strBody = strBody & vbcrlf & vbcrlf & "Order Number: " & OrderID & " " & ConfirmationOrder
- strBody = strbody & vbcrlf & "Request ID: " & RequestID
- strBody = strbody & vbcrlf & "Asset: " & AssetReference
- strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- strBody = strBody & vbcrlf & "Contract: " & Contract
- strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
- strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
- strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
- strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
- strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
- strBody = strBody & vbcrlf & vbcrlf & "Vulnerability Code(s): " & VulCode
- strBody = strBody & vbcrlf & "Job Type: " & JobType
- strBody = strBody & vbcrlf & "Priority: " & Priority
- strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strCommand = ("SELECT SST.SOR_Code_VC, RRTLT.NarrativeDescription_VC, RRTLT.Quantity_DC, RWOLT.ContractValue_MN, RWOLT.WorksOrderLine_ID, RRTLT.TradeCode_ID, dbo.Shared_Codes_T.Description_VC FROM dbo.Repairs_Requests_Task_Lines_T AS RRTLT (nolock) INNER JOIN dbo.Repairs_Works_Order_Lines_T AS RWOLT (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID INNER JOIN dbo.Shared_Codes_T (nolock)ON RRTLT.TradeCode_ID = dbo.Shared_Codes_T.Code_ID LEFT OUTER JOIN dbo.Shared_SORs_T AS SST (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE (RRTLT.Status_ID = 5) AND RWOLT.WorksOrder_ID =" & OrderID)
- with sqlconnection.execute(strCommand)
- do until .eof
- strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- for lngLines = 0 to ubound(strSOR)
- if lngLines = 0 then
- if isnull(.fields(0)) then
- strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- else
- strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
- end if
- strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
- strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
- else
- strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- end if
- next
- dblTotal = dblTotal + .fields(3)
- .movenext
- loop
- end with
- strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- strEmailAddress = SpokesPersonEmail
- strFromaddress = "ActiveH.WO@Stonewater.org"
- strCCaddress = ""
- strBCCaddress = ""
- strSubject = "Works Order " & OrderID
- strProfile = "ContractorEmails"
- SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
- ' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",SpokesPersonEmail,"","ActiveH.WO@stonewater.org",strBody,"",""
- 'msgbox "Email Sent"
- End Function
- 'Emails the email address that is passed to the function
- 'Created 13/03/2010 KS
- Function SendEmailToSpokesPersonTrim(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContractorContact,OrderDate,JobType,Priority,EstimatedCompletion, ConfirmationOrder, Contract,SpokespersonEmail)
- dim strBody
- dim strEmailAddress
- dim strCommand
- dim dblTotal
- dim lngLines
- dim strSOR
- dim strProfile '- 26/11/2015
- dim strFromaddress '- 26/11/2015
- dim strCCaddress '- 26/11/2015
- dim strBCCaddress '- 26/11/2015
- dim strSubject '- 26/11/2015
- strBody = "The following repair has been logged against the communal area for which you are the elected spokesperson"
- strBody = strBody & vbcrlf & vbcrlf & "Order Number: " & OrderID & " " & ConfirmationOrder
- strBody = strbody & vbcrlf & "Request ID: " & RequestID
- strBody = strbody & vbcrlf & "Asset: " & AssetReference
- strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
- strBody = strBody & vbcrlf & "Contractor: " & ContractorName
- strBody = strBody & vbcrlf & "Contract: " & Contract
- strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
- strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
- strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
- strBody = strBody & vbcrlf & "Job Type: " & JobType
- strBody = strBody & vbcrlf & "Priority: " & Priority
- strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
- strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
- strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strCommand = ("SELECT SST.SOR_Code_VC, RRTLT.NarrativeDescription_VC, RRTLT.Quantity_DC, RWOLT.ContractValue_MN, RWOLT.WorksOrderLine_ID, RRTLT.TradeCode_ID, dbo.Shared_Codes_T.Description_VC FROM dbo.Repairs_Requests_Task_Lines_T AS RRTLT (nolock) INNER JOIN dbo.Repairs_Works_Order_Lines_T AS RWOLT (nolock) ON RWOLT.RequestTaskLine_ID = RRTLT.RequestLine_ID INNER JOIN dbo.Shared_Codes_T (nolock)ON RRTLT.TradeCode_ID = dbo.Shared_Codes_T.Code_ID LEFT OUTER JOIN dbo.Shared_SORs_T AS SST (nolock) ON SST.SOR_ID = RRTLT.Schedule_ID WHERE (RRTLT.Status_ID = 5) AND RWOLT.WorksOrder_ID =" & OrderID)
- with sqlconnection.execute(strCommand)
- do until .eof
- strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
- for lngLines = 0 to ubound(strSOR)
- if lngLines = 0 then
- if isnull(.fields(0)) then
- strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
- else
- strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
- end if
- strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
- strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
- strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
- strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
- else
- strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
- end if
- next
- dblTotal = dblTotal + .fields(3)
- .movenext
- loop
- end with
- strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
- strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
- strBody = strBody & vbcrlf & vbcrlf & vbcrlf
- strEmailAddress = SpokesPersonEmail
- strFromaddress = "ActiveH.WO@Stonewater.org"
- strCCaddress = ""
- strBCCaddress = ""
- strSubject = "Works Order " & OrderID
- strProfile = "ContractorEmails"
- SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
- ' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",SpokesPersonEmail,"","ActiveHWO@stonewater.org",strBody,"",""
- 'msgbox "Email Sent"
- End Function
- Function ContactWhitePanel(String1,String2,String3,String4,String5,String6,String7)
- dim strResult
- '-- Debug msgbox String1 & ", " & string2 & ", " & string3 & ", " & string4
- if len(String1) > 0 then
- strResult = String1
- end if
- if len(String2) > 0 then
- if len(strResult) = 0 then
- strResult = String2
- else
- strResult = strResult & vbcrlf & String2
- end if
- end if
- if len(String3) > 0 then
- if len(strResult) = 0 then
- strResult = String3
- else
- strResult = strResult & vbcrlf & String3
- end if
- end if
- if len(String4) > 0 then
- if len(strResult) = 0 then
- strResult = String4
- else
- strResult = strResult & vbcrlf & String4
- end if
- end if
- if len(String5) > 0 then
- if len(strResult) = 0 then
- strResult = String5
- else
- strResult = strResult & vbcrlf & String5
- end if
- end if
- if len(String6) > 0 then
- if len(strResult) = 0 then
- strResult = String6
- else
- strResult = strResult & vbcrlf & String6
- end if
- end if
- if len(String7) > 0 then
- if len(strResult) = 0 then
- strResult = String7
- else
- strResult = strResult & vbcrlf & String7
- end if
- end if
- '-- Debug msgbox strResult
- ContactWhitePanel = Sentence(strResult)
- End Function
- function GetContactVul(GroupID)
- dim iResult, strSQL
- strSQL = "SELECT dbo.Contact_Group_Contacts_T.Group_ID, COUNT(dbo.Contact_Contact_Vulnerabilities_T.Vulnerability_Code_ID) AS NoVuls FROM dbo.Contact_Contact_Vulnerabilities_T WITH (NOLOCK) INNER JOIN dbo.Contact_Group_Contacts_T WITH (NOLOCK) ON dbo.Contact_Contact_Vulnerabilities_T.Contact_ID = dbo.Contact_Group_Contacts_T.Contact_ID AND (dbo.Contact_Contact_Vulnerabilities_T.Expiry_Date_DT >= GETDATE() OR dbo.Contact_Contact_Vulnerabilities_T.Expiry_Date_DT IS NULL) GROUP BY dbo.Contact_Group_Contacts_T.Group_ID having dbo.Contact_Group_Contacts_T.Group_ID = " & GroupID
- iresult = 0
- With SQLConnection.Execute(strSQL)
- Do Until .EOF
- iResult = .Fields("NoVuls").Value
- .MoveNext
- Loop
- End With
- GetContactVul= iResult
- end function
- Function ClearOutstandingTasksWorkfile()
- varSelect = "DELETE FROM RAGLAN_USR_Outstanding_Tasks_Workfile_T"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function BuildOutstandingTasksWorkfile(varTaskID,varRequiredByDate,varTaskDesc,varUser,varEmailAddress,varReportingSection)
- varUpdate = "INSERT INTO RAGLAN_USR_Outstanding_Tasks_Workfile_T (TaskID, RequiredByDate, TaskDescription, UserName, EmailAddress, ReportingSection) VALUES (" & varTaskID & ",'" & varRequiredByDate & "','" & varTaskDesc & "','" & varUser & "','" & varEmailAddress & "'," & varReportingSection & ")"
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function EMailCDOUsingOutputAttach(Subject,From,Recipient,Cc,Bcc,Body,HTMLBody,AttachFilePath)
- '
- ' This function allows generation of an email via Outlook
- ' with an optional attachment file if required
- '
- On Error resume Next:err.clear
- Dim objMessage, objConfiguration
- Set objMessage = CreateObject("CDO.Message")
- Set objConfiguration = CreateObject("CDO.Configuration")
- objMessage.Subject = Subject
- objMessage.From = From
- objMessage.To = Recipient
- objMessage.Bcc = Bcc
- objMessage.Cc = Cc
- if len(Body) > 0 then
- objMessage.TextBody = Body
- else
- objMessage.HTMLBody = HTMLBody
- end if
- If Len(AttachFilePath) > 0 Then
- objMessage.AddAttachment = AttachFilePath
- End If
- ' Do not touch parameters below! unless you fully understand the implications
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "172.20.0.72"
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "raglan\ActiveHSMS"
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Opera09"
- ' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Housing Services Centre"
- ' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "opera09"
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
- objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 180
- objConfiguration.Fields.Update
- Set objMessage.Configuration = objConfiguration
- objMessage.Send
- Set objMessage = Nothing
- EMailCDOUsingOutputAttach = err.number
- End Function
- Function RHA_Document_Delete_And_Duplicate
- Dim strStatusMessage
- Dim strDocumentNumber
- Dim strSQL
- Dim objRecordset
- Dim objCommand
- 'Initialise status message (there will be no status when the screen is first displayed)
- strStatusMessage = vbNullString
- Do
- strDocumentNumber = InputBox(strStatusMessage & "Please enter the document number to reassign:", "ActiveH Reassign Document Number", strDocumentNumber)
- If LenB(strDocumentNumber) = 0 Then
- Exit Do
- End If
- 'Initialise status message
- strStatusMessage = vbNullString
- If IsNumeric(strDocumentNumber) Then
- strSQL = "SELECT Status_ID, LEN(RTRIM(Contractors_Reference_CH)) As ContractorsRefLength FROM Repairs_Documents_T WHERE Document_ID=" & strDocumentNumber
- Set objRecordset = SQLConnection.Execute(strSQL)
- If Not (objRecordset.BOF And objRecordset.EOF) Then
- If objRecordset.Fields("Status_ID").Value <> 84 Then
- strStatusMessage = "The document number entered does not have a status of registered!" & vbCrLf & vbCrLf
- End If
- If objRecordset.Fields("ContractorsRefLength").Value = 30 Then
- strStatusMessage = "The contractors document reference has the maximum of 30 characters and therefore cannot be changed when copying to a new document!" & vbCrLf & vbCrLf
- End If
- Else
- strStatusMessage = "The document number entered does not exist!" & vbCrLf & vbCrLf
- End If
- Set objRecordset = Nothing
- Else
- strStatusMessage = "The document number entered is not a numeric value!" & vbCrLf & vbCrLf
- End if
- 'IF the status message has not yet been updated THEN no errors have occurred so execute the stored procedure
- If LenB(strStatusMessage) = 0 Then
- Set objCommand = CreateObject("ADODB.Command")
- objCommand.ActiveConnection = SQLConnection
- objCommand.CommandText = "up_parmupd_Repairs_usr_RHA_Document_Delete_And_Duplicate"
- objCommand.CommandType = 4 'adCmdStoredProc
- objCommand.Parameters.Refresh
- objCommand.Parameters(1).Value = CStr(strDocumentNumber)
- objCommand.Execute
- strStatusMessage = "Document id: " & strDocumentNumber & " has successfully been reassigned to document id: " & objCommand.Parameters(2).Value & vbCrLf & vbCrLf
- Set objCommand = Nothing
- strDocumentNumber = vbNullString
- End If
- Loop
- End Function
- Function RHA_Document_Delete_And_Duplicate
- Dim strStatusMessage
- Dim strDocumentNumber
- Dim strSQL
- Dim objRecordset
- Dim objCommand
- 'Initialise status message (there will be no status when the screen is first displayed)
- strStatusMessage = vbNullString
- Do
- strDocumentNumber = InputBox(strStatusMessage & "Please enter the document number to reassign:", "ActiveH Reassign Document Number", strDocumentNumber)
- If LenB(strDocumentNumber) = 0 Then
- Exit Do
- End If
- 'Initialise status message
- strStatusMessage = vbNullString
- If IsNumeric(strDocumentNumber) Then
- strSQL = "SELECT Status_ID, LEN(RTRIM(Contractors_Reference_CH)) As ContractorsRefLength FROM Repairs_Documents_T WHERE Document_ID=" & strDocumentNumber
- Set objRecordset = SQLConnection.Execute(strSQL)
- If Not (objRecordset.BOF And objRecordset.EOF) Then
- If objRecordset.Fields("Status_ID").Value <> 84 Then
- strStatusMessage = "The document number entered does not have a status of registered!" & vbCrLf & vbCrLf
- End If
- If objRecordset.Fields("ContractorsRefLength").Value = 30 Then
- strStatusMessage = "The contractors document reference has the maximum of 30 characters and therefore cannot be changed when copying to a new document!" & vbCrLf & vbCrLf
- End If
- Else
- strStatusMessage = "The document number entered does not exist!" & vbCrLf & vbCrLf
- End If
- Set objRecordset = Nothing
- Else
- strStatusMessage = "The document number entered is not a numeric value!" & vbCrLf & vbCrLf
- End if
- 'IF the status message has not yet been updated THEN no errors have occurred so execute the stored procedure
- If LenB(strStatusMessage) = 0 Then
- Set objCommand = CreateObject("ADODB.Command")
- objCommand.ActiveConnection = SQLConnection
- objCommand.CommandText = "up_parmupd_Repairs_usr_RHA_Document_Delete_And_Duplicate"
- objCommand.CommandType = 4 'adCmdStoredProc
- objCommand.Parameters.Refresh
- objCommand.Parameters(1).Value = CStr(strDocumentNumber)
- objCommand.Execute
- strStatusMessage = "Document id: " & strDocumentNumber & " has successfully been reassigned to document id: " & objCommand.Parameters(2).Value & vbCrLf & vbCrLf
- Set objCommand = Nothing
- strDocumentNumber = vbNullString
- End If
- Loop
- End Function
- Function UpdateTaskRequestsT(varTaskRequestID,varTaskID)
- SQLConnection.Execute "UPDATE usr_Raglan_Task_Requests_T SET Audit_Task_ID_Created_ID = " & varTaskID & " WHERE Task_Request_ID = " & varTaskRequestID
- End Function
- Function RaiseError(ErrDescription, ErrNumber, ErrSource)
- 'MsgBox ErrDescription & vbnewline & ErrNumber & vbnewline & ErrSource
- Err.Raise ErrNumber, ErrDescription, ErrSource
- End Function
- Function HPMTaskMinutes (Case_ID,Task_ID,Minutes)
- Dim strSQL
- ' msgbox("Insert into WF_HPM_TaskMinutes_T values ("& Case_ID & "," & Task_ID & "," & Minutes & "," & UserID & ",convert(datetime,'" & CompletionDate & "'))")
- strSQL = ("Insert into WF_HPM_TaskMinutes_T values ("& Case_ID & "," & Task_ID & "," & Minutes & ")")
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function HPMNBShortlistRanking (Case_ID,Task_ID,Ranking)
- Dim strSQL
- ' msgbox("Insert into usr_SW_HPM_ShortlistRanking_T values ("& Case_ID & "," & Task_ID & "," & Ranking & "," & UserID & ",convert(datetime,'" & CompletionDate & "'))")
- strSQL = ("Insert into usr_SW_HPM_ShortlistRanking_T values ("& Case_ID & "," & Task_ID & "," & Ranking & ")")
- msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function HPMVVRAScore (Case_ID,Task_ID,VVRAScore)
- Dim strSQL
- ' msgbox("Insert into WF_HPM_TaskMinutes_T values ("& Case_ID & "," & Task_ID & "," & VVRAScore & "," & UserID & ",convert(datetime,'" & CompletionDate & "'))")
- strSQL = ("Insert into WF_HPM_VVRAScore_T values ("& Case_ID & "," & Task_ID & "," & VVRAScore &")")
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function HPMStoreCalls (Case_ID,Case_Call_ID,CRM_Call_ID)
- Dim strSQL
- strSQL = ("Insert into WF_HPM_Case_Calls_Audit_T values ("& Case_ID & "," & Case_Call_ID & "," & CRM_Call_ID & ")")
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function HPMLetterInput (Case_ID,Task_ID,LetterInput,LetterID)
- Dim strSQL
- strSQL = ("Insert into WF_HPM_TaskLeterInput_T values ("& Case_ID & "," & Task_ID & ",'" & LetterInput & "'," & LetterID & ", Getdate()" & ")")
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function HPMLetterInputDiary (Case_ID,Task_ID,Diary_ID,LetterID,User_ID)
- Dim strSQL
- strSQL = ("Insert into WF_HPM_TaskLetterInput_Diary_T (Case_ID,Task_ID,Diary_ID,Letter_ID,User_ID,Date) values (" & Case_ID & "," & Task_ID & "," & Diary_ID & "," & LetterID & "," & User_ID & ", Getdate()" & ")")
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- strSQL = ("update WF_HPM_TaskLetterInput_Diary_T set LetterInput = (select isnull(Details_VC,' ') from Shared_Diary_T where Diary_ID = " & Diary_ID & ") where Diary_ID = " & Diary_ID )
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function HPMStoreCaseOwner (Case_ID,Case_Owner_ID,Department_BT,Insert_BT)
- Dim strSQL
- if Insert_BT = 1 then
- strSQL = ("Insert into WF_HPM_Case_Owner_Audit_T values ("& Case_ID & "," & Case_Owner_ID & "," & Department_BT & ")")
- else
- strSQL = ("update WF_HPM_Case_Owner_Audit_T set Owner_ID = " & Case_Owner_ID & ", Department_BT = " & Department_BT & " where Case_Id = " & Case_ID)
- end if
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function HPMStoreVVRA (Case_ID,targetedintimidated,PerpetratorsKnown,healthaffected,familysupport,happenedbefore,prejudice,howoften,VVRARelatesto,RelatesToContact,Score,User)
- Dim strSQL
- strSQL = ("Insert into WF_HPM_VVRA_Audit_T (Case_ID,USR_Panel2_Being_targeted_intimidated_or_harassed_IN,USR_Panel2_Do_you_know_the_Perpetrators_IN,USR_Panel2_Has_anyones_health_been_affected_by_this_IN,USR_Panel2_Have_any_family_friends_or_professional_support_IN,USR_Panel2_If_you_know_them_has_ASB_happened_before_IN,USR_Panel2_Is_this_incident_related_to_prejudice_IN,USR_Panel2_Other_than_this_occasion_happening_how_often_IN,USR_Panel2_VVRA_Relates_to_IN,Date,Relates_To_contact_ID,VVRA_Score,User_ID) values ("& Case_ID & "," & targetedintimidated & "," & PerpetratorsKnown & "," & healthaffected & "," & familysupport & "," & happenedbefore & "," & prejudice & "," & howoften & "," & VVRARelatesto & ", Getdate()" & "," & RelatesToContact & "," & Score & "," & User & ")")
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- function HPMStoreReportersActionPlan(CaseID,RelatesTocontactID,UserID,P1Relatesto,P1updateeveryIN,P1needtoIN,P1needtoIN1,P1needtoIN2,P1needtoIN3,P1needtoIN4,P1needtoVC,P1needtoVC1,P1needtoVC2,P1contactIN,P1contactIN1,P1contactIN2,P1contactIN3,P1contactIN4,P1contactVC,P1contactVC1,P1contactVC2,P1organiseIN,P1organiseIN1,P1organiseIN2,P1organiseIN3,P1organiseIN4,P1organiseVC,P1organiseVC1,P1organiseVC2,P1NextstepIN,P1NextstepIN1,P1NextstepIN2,P1NextstepIN3,P1NextstepIN4,P1NextstepVC,P1NextstepVC1,P1NextstepVC2)
- Dim strSQL
- strSQL = ("Insert into WF_HPM_Reporter_Action_Plan_Audit_T values (" & CaseID & ", Getdate()" & "," & RelatesTocontactID & "," & P1Relatesto & "," & UserID & "," & P1updateeveryIN & "," & P1needtoIN & "," & P1needtoIN1 & "," & P1needtoIN2 & "," & P1needtoIN3 & "," & P1needtoIN4 & "," & P1needtoVC & "," & P1needtoVC1 & "," & P1needtoVC2 & "," & P1contactIN & "," & P1contactIN1 & "," & P1contactIN2 & "," & P1contactIN3 & "," & P1contactIN4 & "," & P1contactVC & "," & P1contactVC1 & "," & P1contactVC2 & "," & P1organiseIN & "," & P1organiseIN1 & "," & P1organiseIN2 & "," & P1organiseIN3 & "," & P1organiseIN4 & "," & P1organiseVC & "," & P1organiseVC1 & "," & P1organiseVC2 & "," & P1NextstepIN & "," & P1NextstepIN1 & "," & P1NextstepIN2 & "," & P1NextstepIN3 & "," & P1NextstepIN4 & "," & P1NextstepVC & "," & P1NextstepVC1 & "," & P1NextstepVC2 & ")")
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function HPMStorePerpASBStatus(CaseID,ASBStatusID,RelatesTocontactID,UserID)
- Dim strSQL
- strSQL = ("Insert into usr_SW_Perpetrator_ASB_Status_Audit_T values (" & CaseID & "," & ASBStatusID & ",0" & ", Getdate()" & "," & RelatesTocontactID & "," & UserID & ")")
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- function HPMTestStoreReportersActionPlan(CaseID,RelatesTocontactID,UserID,P1updateeveryIN,P1needtoIN,P1needtoIN1,P1needtoIN2,P1needtoIN3,P1needtoIN4,P1needtootherVC,P1needtootherVC1,P1needtootherVC2,P1contactIN,P1contactIN1,P1contactIN2,P1contactIN3,P1contactIN4,P1contactotherVC,P1contactotherVC1,P1contactotherVC2,P1organiseIN,P1organiseIN1,P1organiseIN2,P1organiseIN3,P1organiseIN4,P1organiseotherVC,P1organiseotherVC1,P1organiseotherVC2,P1NextstepIN,P1NextstepIN1,P1NextstepIN2,P1NextstepIN3,P1NextstepIN4,P1NextstepotherVC,P1NextstepotherVC1,P1NextstepotherVC2)
- Dim strSQL
- strSQL2 = ("Insert into WF_HPM_Reporter_Action_Plan_Audit_T values (" & CaseID & ", Getdate()" & "," & RelatesTocontactID & "," & UserID & "," & P1updateeveryIN & "," & P1needtoIN & "," & P1needtoIN1 & "," & P1needtoIN2 & "," & P1needtoIN3 & "," & P1needtoIN4 & "," & P1needtootherVC & "," & P1needtootherVC1 & "," & P1needtootherVC2 & "," & P1contactIN & "," & P1contactIN1 & "," & P1contactIN2 & "," & P1contactIN3 & "," & P1contactIN4 & "," & P1contactotherVC & "," & P1contactotherVC1 & "," & P1contactotherVC2 & "," & P1organiseIN & "," & P1organiseIN1 & "," & P1organiseIN2 & "," & P1organiseIN3 & "," & P1organiseIN4 & "," & P1organiseotherVC & "," & P1organiseotherVC1 & "," & P1organiseotherVC2 & "," & P1NextstepIN & "," & P1NextstepIN1 & "," & P1NextstepIN2 & "," & P1NextstepIN3 & "," & P1NextstepIN4 & "," & P1NextstepotherVC & "," & P1NextstepotherVC1 & "," & P1NextstepotherVC2 & ")")
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function AttachASBMailMerge(CaseID,LetterDirectory,LetterName)
- Dim strSQL
- Dim FilePath
- Dim FullLetterName
- Dim LetterDate
- Dim DayNumber
- Dim MonthNumber
- if Day(Date) < 10 then DayNumber = "0" & CStr(Day(Date)) else DayNumber = CStr(Day(Date))
- if Month(Date) < 10 then MonthNumber = "0" & CStr(Month(Date)) else MonthNumber = CStr(Month(Date))
- LetterDate = DayNumber + "_" + MonthNumber + "_" + CStr(Year(Date))
- ' UAT
- ' FilePath ="\\filesrv-01\Data\Shared\IT\Unite_Test_Attachments\" & LetterDirectory & "\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- ' TEST
- ' FilePath ="W:\System_Attachments\" & LetterDirectory & "\TEST\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- ' Live
- FilePath ="W:\System_Attachments\" & LetterDirectory & "\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- FullLetterName = LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- strSQL = ("insert into USR_HPM_MM_Attachments_T ([Attachment_Location_ID],[Parent_ID],[Filename_VC],[Description_VC],[Date_Time_Received_DT]) values(1," & CaseID & ", '" & FilePath & "','" & FullLetterName & "'," & "GETDATE())")
- ' msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function CreateLettingsApplicantFolder(varApplicationID)
- Dim objFSO, objFolder, strDirectory
- ' Directory for UAT
- ' strDirectory = "\\filesrv-01\Data\Shared\IT\Unite_Test_Attachments\Applications\" & varApplicationID & ""
- ' Directory for TEST
- ' strDirectory = "W:\System_Attachments\Applicants\TEST\"& varApplicationID & ""
- ' Directory for Live
- strDirectory = "W:\System_Attachments\Applicants\"& varApplicationID & ""
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- If objFSO.FolderExists(strDirectory) Then
- Set objFolder = objFSO.GetFolder(strDirectory)
- ' msgbox("already exsists" & strDirectory)
- Else
- Set objFolder = objFSO.CreateFolder(strDirectory)
- msgbox("Just created " & strDirectory)
- End If
- If err.number = vbEmpty then
- Set objShell = CreateObject("WScript.Shell")
- objShell.run ("Explorer" &" " & strDirectory & "\" )
- Else
- msgbox("VBScript Error: " & err.number)
- End If
- End Function
- Function CreateStonewaterVoidManagementCaseFolder(CaseID)
- Dim objFSO, objFolder, strDirectory
- ' Directory for UAT
- ' strDirectory = "\\filesrv-01\Data\Shared\IT\Unite_Test_Attachments\Voids\" & CaseID & ""
- ' Directory for TEST
- ' strDirectory = "W:\System_Attachments\Voids\TEST\" & CaseID & ""
- ' Directory for Live
- strDirectory = "W:\System_Attachments\Voids\"& CaseID & ""
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- If objFSO.FolderExists(strDirectory) Then
- Set objFolder = objFSO.GetFolder(strDirectory)
- ' msgbox("already exsists" & strDirectory)
- Else
- Set objFolder = objFSO.CreateFolder(strDirectory)
- msgbox("Just created " & strDirectory)
- End If
- If err.number = vbEmpty then
- Set objShell = CreateObject("WScript.Shell")
- objShell.run ("Explorer" &" " & strDirectory & "\" )
- Else
- msgbox("VBScript Error: " & err.number)
- End If
- End Function
- Function CreateStonewaterASBFolder(CaseID)
- Dim objFSO, objFolder, strDirectory
- ' Directory for UAT
- ' strDirectory = "\\filesrv-01\Data\Shared\IT\Unite_Test_Attachments\ASB\" & CaseID & ""
- ' Directory for TEST
- ' strDirectory = "W:\System_Attachments\ASB\TEST" & CaseID & ""
- ' Directory for Live
- strDirectory = "W:\System_Attachments\ASB\" & CaseID & ""
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- If objFSO.FolderExists(strDirectory) Then
- Set objFolder = objFSO.GetFolder(strDirectory)
- ' msgbox("already exsists" & strDirectory)
- Else
- Set objFolder = objFSO.CreateFolder(strDirectory)
- msgbox("Just created " & strDirectory)
- End If
- If err.number = vbEmpty then
- Set objShell = CreateObject("WScript.Shell")
- objShell.run ("Explorer" &" " & strDirectory & "\" )
- Else
- msgbox("VBScript Error: " & err.number)
- End If
- End Function
- Function CreateHomeOwnershipCaseFolder(CaseID, Path)
- Dim objFSO, objFolder, strDirectory
- strDirectory = Path & "\" & CaseID & ""
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- If objFSO.FolderExists(strDirectory) Then
- Set objFolder = objFSO.GetFolder(strDirectory)
- ' msgbox("already exists" & strDirectory)
- Else
- Set objFolder = objFSO.CreateFolder(strDirectory)
- msgbox("Just created " & strDirectory)
- End If
- If err.number = vbEmpty then
- Set objShell = CreateObject("WScript.Shell")
- objShell.run ("Explorer" &" " & strDirectory & "\" )
- Else
- msgbox("VBScript Error: " & err.number)
- End If
- End Function
- Function CreateStonewaterCustomerFeedbackFolder(CaseID,Path,FolderName,Open)
- Dim objFSO, objFolder, strDirectory
- ' Directory for TEST
- strDirectory = Path & FolderName & "\" & CaseID & ""
- 'msgbox(strDirectory)
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- If objFSO.FolderExists(strDirectory) Then
- Set objFolder = objFSO.GetFolder(strDirectory)
- msgbox("already exsists" & strDirectory)
- Else
- Set objFolder = objFSO.CreateFolder(strDirectory)
- msgbox("Just created " & strDirectory)
- End If
- If err.number = vbEmpty then
- Set objShell = CreateObject("WScript.Shell")
- if Open = 1 then
- objShell.run ("Explorer" &" " & strDirectory & "\" )
- End if
- Else
- msgbox("VBScript Error: " & err.number)
- End If
- End Function
- Function HPMMethodofPayment (Case_ID,Task_ID,MethodofPayment)
- Dim strSQL
- ' msgbox("Insert into WF_HPM_MethodOfPayments_T values ("& Case_ID & "," & Task_ID & "," & MethodofPayment & "'))")
- strSQL = ("Insert into WF_HPM_MethodOfPayments_T values ("& Case_ID & "," & Task_ID & "," & MethodofPayment & ")")
- ' msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function HPMExchangeCompletionDates (Case_ID,SubCategory,ExchangeDate,CompletionDate)
- Dim strSQL
- ' msgbox("Insert into WF_HPM_Exchange_Completion_Dates_T values ("& Case_ID & "," & ExchangeDate & "," & CompletionDate & "'))")
- strSQL = ("Insert into WF_HPM_Exchange_Completion_Dates_T values ("& Case_ID & ",'" & SubCategory & "','" & ExchangeDate & "','" & CompletionDate & "')")
- ' msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function Raglan_Task_Requests(Hierarchy_ID,Source_type_ID,Subject_VC,Description_VC,Classification_VC,HyperlinkTarget_VC,HyperlinkLabel_VC,Priority_ID,Audit_Date_Requested_DT,Audit_Requested_By_VC)
- Dim strSQL
- strSQL = ("insert into usr_Raglan_Task_Requests_T ([Assign_To_Hierarchy_ID],[Source_Type_ID],[Subject_VC],[Description_VC],[Classification_ID],[HyperlinkTarget_VC],[HyperlinkLabel_VC],[Priority_ID],[Audit_Date_Requested_DT],[Audit_Requested_By_VC]) values ("& Hierarchy_ID & "," & Source_type_ID & ",'" & Subject_VC & "','" & Description_VC & "'," & Classification_VC & ",'" & HyperlinkTarget_VC & "','" & HyperlinkLabel_VC & "'," & Priority_ID & ",convert(datetime,'" & Audit_Date_Requested_DT& "',103),'"& Audit_Requested_By_VC &"')")
- 'msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function AttachMailMerge(CaseID,LetterDirectory,LetterName)
- Dim strSQL
- Dim FilePath
- Dim FullLetterName
- Dim LetterDate
- Dim DayNumber
- Dim MonthNumber
- if Day(Date) < 10 then DayNumber = "0" & CStr(Day(Date)) else DayNumber = CStr(Day(Date))
- if Month(Date) < 10 then MonthNumber = "0" & CStr(Month(Date)) else MonthNumber = CStr(Month(Date))
- LetterDate = DayNumber + "_" + MonthNumber + "_" + CStr(Year(Date))
- ' TEST
- ' FilePath = "W:\Sysytem_Attachments\" & LetterDirectory & "\TEST\Case_" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- ' Live
- FilePath = "W:\Sysytem_Attachments\" & LetterDirectory & "\Case_" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- FullLetterName = LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- strSQL = ("insert into USR_HPM_MM_Attachments_T ([Attachment_Location_ID],[Parent_ID],[Filename_VC],[Description_VC],[Date_Time_Received_DT]) values(1," & CaseID & ", '" & FilePath & "','" & FullLetterName & "'," & "GETDATE())")
- ' msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function AttachHOMailMerge(CaseID,LetterDirectory,LetterName)
- Dim strSQL
- Dim FilePath
- Dim FullLetterName
- Dim LetterDate
- Dim DayNumber
- Dim MonthNumber
- if Day(Date) < 10 then DayNumber = "0" & CStr(Day(Date)) else DayNumber = CStr(Day(Date))
- if Month(Date) < 10 then MonthNumber = "0" & CStr(Month(Date)) else MonthNumber = CStr(Month(Date))
- LetterDate = DayNumber + "_" + MonthNumber + "_" + CStr(Year(Date))
- ' FilePath = LetterDirectory & "\Case_" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- FilePath = LetterDirectory & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- FullLetterName = LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- strSQL = ("insert into USR_HPM_MM_Attachments_T ([Attachment_Location_ID],[Parent_ID],[Filename_VC],[Description_VC],[Date_Time_Received_DT]) values(1," & CaseID & ", '" & FilePath & "','" & FullLetterName & "'," & "GETDATE())")
- ' msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function AttachCaseProcessingMailMerge(CaseID,Path,LetterDirectory,LetterName)
- Dim strSQL
- Dim FilePath
- Dim FullLetterName
- Dim LetterDate
- Dim DayNumber
- Dim MonthNumber
- if Day(Date) < 10 then DayNumber = "0" & CStr(Day(Date)) else DayNumber = CStr(Day(Date))
- if Month(Date) < 10 then MonthNumber = "0" & CStr(Month(Date)) else MonthNumber = CStr(Month(Date))
- LetterDate = DayNumber + "_" + MonthNumber + "_" + CStr(Year(Date))
- ' UAT
- ' FilePath ="\\filesrv-01\Data\Shared\IT\Unite_Test_Attachments\" & LetterDirectory & "\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- ' TEST
- FilePath = Path & LetterDirectory & "\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- ' Live
- ' FilePath ="W:\System_Attachments\" & LetterDirectory & "\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- FullLetterName = LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
- strSQL = ("insert into USR_HPM_MM_Attachments_T ([Attachment_Location_ID],[Parent_ID],[Filename_VC],[Description_VC],[Date_Time_Received_DT]) values(1," & CaseID & ", '" & FilePath & "','" & FullLetterName & "'," & "GETDATE())")
- ' msgbox(strSQL)
- with sqlconnection.execute (strSQL)
- End With
- End Function
- Function UpdateSMSIn(msgID)
- varSMSUpdate = "UPDATE Shared_SMS_Inbox_T SET READ_BT = 1 where Message_ID = " & msgID
- WITH SQLConnection.Execute(varSMSUpdate)
- END WITH
- End Function
- '*************************************
- ' Scheme Accounting Custom Functions
- '*************************************
- Function GetAccountListingHTML(AccountNumber, TrxDateFrom, TrxDateTo)
- Dim objCmd, objRS
- Set objCmd = SQLUtilities.SQLConnect.CreateCommand
- objCmd.CommandType = 4
- objCmd.CommandText = "USR_RAG_SchemeAccounting_Transaction_List_2"
- objCmd.Parameters.Refresh
- objCmd.Parameters("@AccountNumber").Value = AccountNumber
- objCmd.Parameters("@TrxDateFrom").Value = TrxDateFrom
- objCmd.Parameters("@TrxDateTo").Value = TrxDateTo
- Set objRS = objCmd.Execute
- GetAccountListingHTML = AccountListingRSToHTML(objRS)
- Set objCmd = Nothing
- End Function
- Function AccountListingRSToHTML(objRS)
- Dim strReturn, strLastAccount, curSubTotal, curTotal, blnFirst
- strReturn = GetAccountListingHeaderHTML()
- strReturn = strReturn & _
- "<table cellpadding=""0"" cellspacing=""0"" style=""width: 100%; font-size: 100%;"">" & vbNewLine & _
- " <tr>" & vbNewline & _
- " <th style=""background-color: SteelBlue;"">Journal Entry</th>" & vbNewLine & _
- " <th style=""background-color: SteelBlue;"">Voucher No.</th>" & vbNewLine & _
- " <th style=""background-color: SteelBlue;"">Series</th>" & vbNewline & _
- " <th style=""background-color: SteelBlue;"">Date</th>" & vbNewline & _
- " <th style=""background-color: SteelBlue;"">Reference</th>" & vbNewline & _
- " <th style=""background-color: SteelBlue;"">Description</th>" & vbNewline & _
- " <th style=""background-color: SteelBlue;"">Amount</th>" & vbNewline & _
- " </tr>" & vbNewLine
- curSubTotal = CCur(0)
- curTotal = CCur(0)
- blnFirst = True
- Do While Not (objRS.BOF Or objRS.EOF)
- If strLastAccount <> objRS.Fields("Account Number").Value Then
- If Not blnFirst Then
- strReturn = strReturn & _
- " <tr>" & vbNewLine & _
- " <td colspan=""7"" style=""background-color: AliceBlue; text-align: right;"">" & FormatNumber(curSubTotal, 2) & "</td>" & vbNewline & _
- " </tr>" & vbNewLine
- curSubTotal = CCur(0)
- End If
- strLastAccount = objRS.Fields("Account Number").Value
- strReturn = strReturn & _
- " <tr>" & vbNewLine & _
- " <td colspan=""7"" style=""background-color: LightBlue"">" & objRS.Fields("Account Number").Value & " - " & objRS.Fields("Account Description").Value & "</td>" & vbNewline & _
- " </tr>" & vbNewLine
- End If
- If objRS.Fields("History TRX").Value = "Yes" Then
- strReturn = strReturn & _
- " <tr>" & vbNewLine & _
- " <td>" & objRS.Fields("Journal Entry").Value & "</td>" & vbNewLine & _
- " <td><a href=""" & objRS.Fields("Document Number for Drillback").Value & """ target=""_blank"">" & objRS.Fields("Originating Control Number").Value & "</a></td>" & vbNewLine & _
- " <td>" & objRS.Fields("Creditors Name").Value & "</td>" & vbnewline & _
- " <td>" & objRS.Fields("TRX Date").Value & "</td>" & vbNewLine & _
- " <td>" & objRS.Fields("Reference").Value & "</td>" & vbNewLine & _
- " <td>" & objRS.Fields("Description").Value & "</td>" & vbNewLine & _
- " <td style=""text-align: right;"">" & FormatNumber(objRS.Fields("Amount").Value, 2) & "</td>" & vbNewline & _
- " </tr>" & vbNewLine
- Else
- strReturn = strReturn & _
- " <tr>" & vbNewLine & _
- " <td><a href=""" & objRS.Fields("Journal Entry For Drillback").Value & """ target=""_blank"">" & objRS.Fields("Journal Entry").Value & "</a></td>" & vbNewLine & _
- " <td><a href=""" & objRS.Fields("Document Number for Drillback").Value & """ target=""_blank"">" & objRS.Fields("Originating Control Number").Value & "</a></td>" & vbNewLine & _
- " <td>" & objRS.Fields("Creditors Name").Value & "</td>" & vbnewline & _
- " <td>" & objRS.Fields("TRX Date").Value & "</td>" & vbNewLine & _
- " <td>" & objRS.Fields("Reference").Value & "</td>" & vbNewLine & _
- " <td>" & objRS.Fields("Description").Value & "</td>" & vbNewLine & _
- " <td style=""text-align: right;"">" & FormatNumber(objRS.Fields("Amount").Value, 2) & "</td>" & vbNewline & _
- " </tr>" & vbNewLine
- End If
- curSubTotal = curSubTotal + CCur(objRS.Fields("Amount").Value)
- curTotal = curTotal + CCur(objRS.Fields("Amount").Value)
- blnFirst = False
- objRS.MoveNext
- Loop
- objRS.Close
- If Not blnFirst Then
- strReturn = strReturn & _
- " <tr>" & vbNewLine & _
- " <td colspan=""7"" style=""background-color: AliceBlue; text-align: right;"">" & FormatNumber(curSubTotal, 2) & "</td>" & vbNewline & _
- " </tr>" & vbNewLine
- strReturn = strReturn & _
- " <tr>" & vbNewLine & _
- " <td colspan=""7"" style=""background-color: AliceBlue; text-align: right; font-weight: bold;"">" & FormatNumber(curTotal, 2) & "</td>" & vbNewline & _
- " </tr>" & vbNewLine
- End If
- strReturn = strReturn & _
- "</table>"
- AccountListingRSToHTML = strReturn
- End Function
- Function GetAccountListingHeaderHTML()
- Dim strReturn
- strReturn = _
- "<table cellpadding=""0"" cellspacing=""0"" style=""width: 100%; table-layout: fixed; font-size: 100%;"">" & vbNewline & _
- " <tr>" & vbNewline & _
- " <th style=""border-bottom: 2px solid LightBlue; width: 16px;""> </th>" & vbNewline & _
- " <th id=""tabAccountTransactions"" style=""cursor: default; padding: 5px 20px 5px 20px; border-left: 2px solid LightBlue; border-top: 2px solid LightBlue; border-right: 2px solid LightBlue; border-bottom: 2px solid White;"">Account Transactions</th>" & vbNewline & _
- " <th style=""border-bottom: 2px solid LightBlue; width: 16px;""> </th>" & vbNewline & _
- " <th style=""border-bottom: 2px solid LightBlue;""> </th>" & vbNewline & _
- " </tr>" & vbNewline & _
- "</table>" & vbNewline & _
- "<br />"
- GetAccountListingHeaderHTML = strReturn
- End Function
- Function GetNominalAccountNetChange(AccountNumber, TrxDateFrom, TrxDateTo)
- With SQLUtilities.SQLConnect.CreateCommand
- .CommandType = 4 'adCmdStoredProc
- .CommandText = "USR_RAG_Get_Nominal_Account_Net_Change_2"
- .Parameters.Refresh
- .Parameters("@AccountNumber").Value = CStr(AccountNumber)
- .Parameters("@TrxDateFrom").Value = CDate(TrxDateFrom)
- .Parameters("@TrxDateTo").Value = CDate(TrxDateTo)
- .Execute
- GetNominalAccountNetChange = .Parameters("@NetChange").Value
- End With
- End Function
- Function GetSDValues(AccountNumber, ServiceDefinitionID, TrxDateFrom, TrxDateTo, ServiceAssetIDs)
- With SQLUtilities.SQLConnect.CreateCommand
- .CommandType = 4
- .CommandText = "USR_RAG_Get_Surplus_Deficit_Values_6"
- .Parameters.Refresh
- .Parameters("@AccountNumber").Value = CStr(AccountNumber)
- .Parameters("@ServiceDefinitionID").Value = CStr(ServiceDefinitionID)
- .Parameters("@TrxDateFrom").Value = CDate(TrxDateFrom)
- .Parameters("@TrxDateTo").Value = CDate(TrxDateTo)
- .Parameters("@ServiceAssetIDs").Value = Cstr(ServiceAssetIDs)
- .Execute
- GetSDValues= .Parameters("@SDValue").Value
- End With
- End Function
- Function GetExpenditureValues(AccountNumber, ServiceDefinitionID, TrxDateFrom, TrxDateTo, ServiceAssetIDs)
- With SQLUtilities.SQLConnect.CreateCommand
- .CommandType = 4
- .CommandText = "USR_RAG_Get_Surplus_Deficit_Values_6"
- .Parameters.Refresh
- .Parameters("@AccountNumber").Value = CStr(AccountNumber)
- .Parameters("@ServiceDefinitionID").Value = CStr(ServiceDefinitionID)
- .Parameters("@TrxDateFrom").Value = CDate(TrxDateFrom)
- .Parameters("@TrxDateTo").Value = CDate(TrxDateTo)
- .Parameters("@ServiceAssetIDs").Value = Cstr(ServiceAssetIDs)
- .Execute
- GetExpenditureValues= .Parameters("@Expenditure").Value
- End With
- End Function
- Function GetChargeValues(AccountNumber, ServiceDefinitionID, TrxDateFrom, TrxDateTo, ServiceAssetIDs)
- With SQLUtilities.SQLConnect.CreateCommand
- .CommandType = 4
- .CommandText = "USR_RAG_Get_Surplus_Deficit_Values_6"
- .Parameters.Refresh
- .Parameters("@AccountNumber").Value = CStr(AccountNumber)
- .Parameters("@ServiceDefinitionID").Value = CStr(ServiceDefinitionID)
- .Parameters("@TrxDateFrom").Value = CDate(TrxDateFrom)
- .Parameters("@TrxDateTo").Value = CDate(TrxDateTo)
- .Parameters("@ServiceAssetIDs").Value = Cstr(ServiceAssetIDs)
- .Execute
- GetChargeValues= .Parameters("@Charges").Value
- End With
- End Function
- Function GetAOAValues(AccountNumber, ServiceDefinitionID, TrxDateFrom, TrxDateTo, ServiceAssetIDs)
- With SQLUtilities.SQLConnect.CreateCommand
- .CommandType = 4
- .CommandText = "USR_RAG_Get_Admin_On_Actuals"
- .Parameters.Refresh
- .Parameters("@AccountNumber").Value = CStr(AccountNumber)
- .Parameters("@ServiceDefinitionID").Value = CStr(ServiceDefinitionID)
- .Parameters("@TrxDateFrom").Value = CDate(TrxDateFrom)
- .Parameters("@TrxDateTo").Value = CDate(TrxDateTo)
- .Parameters("@ServiceAssetIDs").Value = CStr(ServiceAssetIDs)
- .Execute
- GetAOAValues= .Parameters("@AOAValue").Value
- End With
- End Function
- Function GetSchemeAccExpenditure(ServiceDefinitionID, CostCentre, CostAccount, ChargeFromDate, ChargeToDate)
- With SQLUtilities.SQLConnect.CreateCommand
- .CommandType = 4
- .CommandText = "usr_RAG_Get_SchemeAcc_Expenditure"
- .Parameters.Refresh
- .Parameters("@Service_Definition_ID").Value = ServiceDefinitionID
- .Parameters("@Cost_Centre_VC").Value = CStr(CostCentre)
- .Parameters("@Cost_Account_VC").Value = CStr(CostAccount)
- .Parameters("@Charge_From_DT").Value = CDate(ChargeFromDate)
- .Parameters("@Charge_To_DT").Value = CDate(ChargeToDate)
- .Execute
- GetSchemeAccExpenditure = CStr(.Parameters("@Expenditure_DC").Value)
- GetSchemeAccExpenditure = GetSchemeAccExpenditure & "*" & CStr(.Parameters("@Expenditure_Inflated_DC").Value)
- GetSchemeAccExpenditure = GetSchemeAccExpenditure & "*" & CStr(.Parameters("@Expenditure_Individual_Percentage_DC").Value)
- GetSchemeAccExpenditure = GetSchemeAccExpenditure & "*" & CStr(.Parameters("@Expenditure_Communal_Percentage_DC").Value)
- GetSchemeAccExpenditure = GetSchemeAccExpenditure & "*" & CStr(.Parameters("@Expenditure_Communal_Car_Park_Percentage_DC").Value)
- GetSchemeAccExpenditure = GetSchemeAccExpenditure & "*" & CStr(.Parameters("@Expenditure_Admin_DC").Value)
- End With
- End Function
- Function GetSchemeAccIncome(ServiceDefinitionID, CostCentre, ChargeFromDate, ChargeToDate, AssetIDs)
- With SQLUtilities.SQLConnect.CreateCommand
- .CommandType = 4
- .CommandText = "usr_RAG_Get_SchemeAcc_Income_Affordable"
- .Parameters.Refresh
- .Parameters("@Service_Definition_ID").Value = ServiceDefinitionID
- .Parameters("@Cost_Centre_VC").Value = CStr(CostCentre)
- .Parameters("@Charge_From_DT").Value = CDate(ChargeFromDate)
- .Parameters("@Charge_To_DT").Value = CDate(ChargeToDate)
- .Parameters("@Asset_IDs").Value = CStr(AssetIDs)
- .Execute
- GetSchemeAccIncome = CStr(.Parameters("@Charge_DC").Value)
- GetSchemeAccIncome = GetSchemeAccIncome & "*" & CStr(.Parameters("@Charge_Admin_DC").Value)
- End With
- End Function
- Function CreateSchemeAccDynamicsInvoices(CostCentre, CostAccount, ChargeFromDate, ChargeToDate)
- With SQLUtilities.SQLConnect.CreateCommand
- .CommandType = 4
- .CommandText = "usr_RAG_Get_SchemeAcc_Dynamics_Invoices"
- .Parameters.Refresh
- .Parameters("@Cost_Centre_VC").Value = CStr(CostCentre)
- .Parameters("@Cost_Account_VC").Value = CStr(CostAccount)
- .Parameters("@Charge_From_DT").Value = CDate(ChargeFromDate)
- .Parameters("@Charge_To_DT").Value = CDate(ChargeToDate)
- .Execute
- End With
- End Function
- Function getSchemeAccParts(ServiceDefinitionID, ServiceCharge, AssetID)
- dim strSQL
- strSQL = ("select case when Service_Definition_ID = 47 then (Gas/GasInScheme)*" & ServiceCharge & " when Service_Definition_ID = 46 then (Electric/ElectricInScheme)*" & ServiceCharge & " when Service_Definition_ID = 49 then (MetWat/MeteredWaterInScheme)*" & ServiceCharge & " when Service_Definition_ID = 50 then (WatRate/WaterRatesInScheme)*" & ServiceCharge & " end as Parts from usr_RAG_SchemeAcc_Service_Apportionment_3_V where Service_Definition_ID = " & ServiceDefinitionID & " and Asset_ID = " & AssetID)
- with sqlconnection.execute(strSQL)
- do until .eof
- getSchemeAccParts = .fields(0)
- .movenext
- loop
- end with
- end function
- function importOrderInfo(file)
- Dim objExcel, objwkbk, intRow, assetID, sorCode, Qty, Comments, ContractID, strSQL
- set objExcel = CreateObject("Excel.Application")
- set objwkbk = objExcel.Workbooks.Open(file)
- intRow = 2
- strsqla = ("Delete from RHA_USR_OrderCreate_T")
- with sqlconnection.execute (strsqla)
- end with
- do until objExcel.cells(intRow,1) = ""
- assetID = objExcel.Cells(intRow, 2).Value
- sorCode = objExcel.Cells(intRow, 3).Value
- Qty = objExcel.Cells(intRow, 4).Value
- Comments = objExcel.Cells(intRow, 5).Value
- ContractID = objExcel.Cells(intRow, 6).Value
- strSQL = ("Insert Into RHA_USR_OrderCreate_T (AssetID, SORCode, Qty, Comments, ContractID) Values (" & AssetID & ",'" & sorCode & "'," & Qty & ",'" & Comments & "'," & ContractID & ")")
- with sqlconnection.execute(strSQL)
- end with
- introw = introw + 1
- loop
- objwkbk.close
- objExcel.Quit
- End Function
- Function CreateOrderFile(File)
- Dim fso, txtstream
- set fso = CreateObject("Scripting.FileSystemObject")
- File = cstr(File)
- set txtstream = fso.CreateTextFile(File, True)
- End Function
- Function addOrderInfoToFile(FilePath, LineInfo)
- dim fso, txtstream
- set fso = CreateObject("Scripting.FileSystemObject")
- Set txtstream = fso.OpenTextFile(FilePath,8)
- txtstream.Write LineInfo
- txtstream.Close
- End Function
- ' /_/_/ ACL Functions 07854-655009 - /_/_/
- Private Function ACLReadLineFromCSVFile(File, Lin)
- Dim fso
- Dim txtstream
- Const ForReading = 1, ForWriting = 2, ForAppending = 8
- set fso=CreateObject("Scripting.FileSystemObject")
- set txtstream=fso.OpenTextFile(File, ForReading, True)
- For x = 1 to Lin
- ACLReadLineFromCSVFile = "-EOF-"
- if not txtstream.AtEndOfStream then
- ACLReadLineFromCSVFile = txtstream.ReadLine
- end if
- Next
- txtstream.Close
- End Function
- Function SQLExec(VarExecute)
- SQLConnection.Execute(varExecute)
- End Function
- Private Function ACLSQLExecResult(VarExecute, ResCol)
- If ResCol = "" then
- SQLConnection.Execute(VarExecute)
- Exit Function
- End if
- With SQLConnection.Execute(varExecute)
- Do Until .EOF
- ACLSQLExecResult = .Fields( ResCol ).Value
- .MoveNext
- Loop
- End With
- End Function
- Private Function ACLField( FullString , Delim , Occurance )
- 'FIELD' function
- ACLField = ""
- If Len(FullString) = Len(Delim) Or Len(FullString) < Occurance Then Exit Function
- Tempstring = Delim & FullString & Delim
- Pos2 = 1
- For Y = 1 To Occurance
- Pos1 = InStr(Pos2, Tempstring, Delim, 1)
- Pos2 = InStr(Pos1 + 1, Tempstring, Delim, 1)
- If Pos2 = 0 Then Exit Function
- Temp = Mid(Tempstring, Pos1 + 1, Pos2 - Pos1 - 1)
- Next
- ACLField = Temp
- End Function
- ' /_/_/ End of ACL Functions 07854-655009 - /_/_/
- '****Dynamics Interface - Web Component- - START ****
- Function CreateRentRefundAddress(varCreditorID,varAccountID,varAddress1,varAddress2,varAddress3,varCounty,varPostCode,varTelNum,varEmail,varBankName,varBankNumber,varBankSort)
- Dim objUtils 'As AMSDynamicsGPWeb.GPUtilities
- Dim objDoc 'As AMSDynamicsGPWeb.CreditorAddress
- Set objUtils = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.GPUtilities")
- Set objUtils = mCreateGPUtilities
- Set objDoc = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.CreditorAddress")
- With objDoc
- .CreditorID = CStr(varCreditorID)
- .AddressCode = CStr(varAccountID)
- .Address1 = CStr(varAddress1)
- .Address2 = CStr(varAddress2)
- .Address3 = CStr(varAddress3)
- .County = CStr(varCounty)
- .Postcode = CStr(varPostCode)
- .TelephoneNumber1 = CStr(varTelNum)
- .TaxScheduleID = "PS"
- .EmailAddress = CStr(varEmail)
- .EmailToAddress = ""
- .UserDefined1 = ""
- .WebsiteAddress = ""
- .BankAccountCountryRegion = 3
- .BankAccountName = CStr(varBankName)
- .BankAccountNumber = CStr(varBankNumber)
- .BankAccountSortCode = CStr(varBankSort)
- End With
- On Error Resume Next
- objUtils.Connect
- objUtils.PostTransaction objUtils.Cast_IPostable(objDoc)
- If Err.Number <> 0 Then
- MsgBox Err.Description & vbnewline & err.source, vbCritical
- Else
- CreateRentRefundAddress = objDoc.AddressCode
- End If
- objUtils.CloseConnection
- Set objDoc = Nothing
- Set objUtils = Nothing
- End Function
- Function CreateRentsInvoice(varBatchNumber,varCreditorID,varDescription,varDocumentNumber,varNetTotal,varVATTotal,TransactionID,varAccountID)
- Dim objUtils 'As AMSDynamicsGPWeb.GPUtilities
- Dim objDoc 'As AMSDynamicsGPWeb.PMTransaction
- Set objUtils = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.GPUtilities")
- Set ObjUtils = mCreateGPUtilities
- Set objDoc = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.PMTransaction")
- With objDoc
- .BatchNumber = CStr(varBatchNumber)
- .CreditorID = CStr(varCreditorID)
- .Description = CStr(varDescription)
- .DocumentDate = Now
- .DocumentType = 1
- .DocumentNumber = CStr(varDocumentNumber)
- .NetTotal = CStr(varNetTotal)
- .VATTotal = CStr(varVATTotal)
- .RemitToAddressID = CStr(varAccountID)
- End With
- mAddRentsInvoiceLines objDoc, TransactionID
- On Error Resume Next
- objUtils.Connect
- objUtils.PostTransaction objUtils.Cast_IPostable(objDoc)
- If Err.Number <> 0 Then
- MsgBox Err.Description & vbnewline & err.source, vbCritical
- Else
- CreateRentsInvoice = objDoc.VoucherNumber
- End If
- objUtils.CloseConnection
- Set objDoc = Nothing
- Set objUtils = Nothing
- End Function
- Sub mAddRentsInvoiceLines(objDoc, TransactionID)
- Dim objCmd, objRS
- Dim objUtils
- Set objCmd = SQLUtilities.SQLConnect.CreateCommand
- objCmd.CommandType = 4 'Stored Proc
- objCmd.CommandText = "USR_SW_Rents_Get_Invoice_Lines"
- objCmd.Parameters.Refresh
- objCmd.Parameters("@TransactionID").Value = TransactionID
- Set objRS = objCmd.Execute
- Do While Not (objRS.BOF Or objRS.EOF)
- With objDoc.TransactionLines.Add
- .NominalAccount = objRS.Fields("Nominal_Account_VC").Value
- .Reference = objRS.Fields("Reference_VC").Value
- .NetValue = objRS.Fields("Value_DC").Value
- .VATValue = objRS.Fields("VAT_Value_DC").Value
- .VATCode = objRS.Fields("VAT_Code_IN").Value
- End With
- objRS.MoveNext
- Loop
- objRS.Close
- Set objRS = Nothing
- Set objCmd = Nothing
- End Sub
- Function CreateRepairsJournal(varBatchNumber,varReference,varSourceDocument, DocumentID,varAuthorisedDate)
- Dim objUtils 'As AMSDynamicsGPWeb.GPUtilities
- Dim objDoc 'As AMSDynamicsGPWeb.GLTransaction
- Set objUtils = mCreateGPUtilities
- Set objDoc = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.GLTransaction")
- With objDoc
- .BatchNumber = "" & varBatchNumber
- .Reference = "" & varReference
- .TransactionDate = "" & varAuthorisedDate
- .TransactionType = 0
- .SourceDocument = "" & varSourceDocument
- End With
- mAddRepairsJournalLines objDoc, DocumentID
- On Error Resume Next
- objUtils.Connect
- objUtils.PostTransaction objUtils.Cast_IPostable(objDoc)
- If Err.Number <> 0 Then
- 'MsgBox Err.Description & vbnewline & err.source, vbCritical
- Else
- CreateRepairsJournal = objDoc.JournalEntryNumber
- End If
- objUtils.CloseConnection
- Set objDoc = Nothing
- Set objUtils = Nothing
- End Function
- Function CreateRentsJournal(varBatchNumber,varReference,varSourceDocument, TransactionID)
- Dim objUtils 'As AMSDynamicsGPWeb.GPUtilities
- Dim objDoc 'As AMSDynamicsGPWeb.GLTransaction
- Set objUtils = mCreateGPUtilities
- Set objDoc = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.GLTransaction")
- With objDoc
- .BatchNumber = "" & varBatchNumber
- .Reference = "" & varReference
- .TransactionDate = Now
- .TransactionType = 0
- .SourceDocument = "" & varSourceDocument
- End With
- mAddRentsJournalLines objDoc, TransactionID
- On Error Resume Next
- objUtils.Connect
- objUtils.PostTransaction objUtils.Cast_IPostable(objDoc)
- If Err.Number <> 0 Then
- MsgBox Err.Description & vbnewline & err.source, vbCritical
- Else
- CreateRentsJournal = objDoc.JournalEntryNumber
- End If
- objUtils.CloseConnection
- Set objDoc = Nothing
- Set objUtils = Nothing
- End Function
- Function mCreateGPUtilities()
- Dim objCmd, objRS
- Dim objUtils
- Set objCmd = SQLUtilities.SQLConnect.CreateCommand
- objCmd.CommandType = 4 'Stored Proc
- objCmd.CommandText = "USR_SW_Shared_Dynamics_GP_Integration_Settings"
- Set objRS = objCmd.Execute
- If Not (objRS.BOF Or objRS.EOF) Then
- Set objUtils = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.GPUtilities")
- With objUtils
- .Server = CStr(objRS.Fields("GP_Server_VC").Value)
- .Connect
- .ChangeCompany CStr(objRS.Fields("GP_DBName_VC").Value)
- .CloseConnection
- .XMLSavePath = CStr(objRS.Fields("Document_Export_Path_VC").Value)
- End With
- Set mCreateGPUtilities = objUtils
- End If
- objRS.Close
- Set objRS = Nothing
- Set objCmd = Nothing
- End Function
- Sub mAddRepairsJournalLines(objDoc, DocumentID)
- Dim objCmd, objRS
- Dim objUtils
- Set objCmd = SQLUtilities.SQLConnect.CreateCommand
- objCmd.CommandType = 4 'Stored Proc
- objCmd.CommandText = "USR_SW_Repairs_Get_Reallocation_Journal_Lines"
- objCmd.Parameters.Refresh
- objCmd.Parameters("@Document_ID").Value = DocumentID
- Set objRS = objCmd.Execute
- Do While Not (objRS.BOF Or objRS.EOF)
- With objDoc.TransactionLines.Add
- .NominalAccount = objRS.Fields("Nominal_Account_VC").Value
- .Reference = objRS.Fields("Reference_VC").Value
- .LineValue = objRS.Fields("Value_DC").Value
- End With
- varSQL = "INSERT INTO usr_SW_Repairs_UDFI_Processed_Document_Details_T (Document_ID,Nominal_Account_VC,Reference_VC,Value_DC) values (" & DocumentID & ",'" & objRS.Fields("Nominal_Account_VC").Value & "','" & objRS.Fields("Reference_VC").Value & "','" & objRS.Fields("Value_DC").Value & "')"
- With SQLconnection.Execute(varSQL)
- End With
- objRS.MoveNext
- Loop
- objRS.Close
- Set objRS = Nothing
- Set objCmd = Nothing
- End Sub
- Sub mAddRentsJournalLines(objDoc, TransactionID)
- Dim objCmd, objRS
- Dim objUtils
- Set objCmd = SQLUtilities.SQLConnect.CreateCommand
- objCmd.CommandType = 4 'Stored Proc
- objCmd.CommandText = "USR_SW_Rents_Get_Reallocation_Journal_Lines"
- objCmd.Parameters.Refresh
- objCmd.Parameters("@TransactionID").Value = TransactionID
- Set objRS = objCmd.Execute
- Do While Not (objRS.BOF Or objRS.EOF)
- With objDoc.TransactionLines.Add
- .NominalAccount = objRS.Fields("Nominal_Account_VC").Value
- .Reference = objRS.Fields("Reference_VC").Value
- .LineValue = objRS.Fields("Value_DC").Value
- End With
- objRS.MoveNext
- Loop
- objRS.Close
- Set objRS = Nothing
- Set objCmd = Nothing
- End Sub
- Function InsertIntoRepairsUDFIProcessedDocuments(varDocumentID,varProcessedBy)
- varSelect = "insert into usr_SW_Repairs_UDFI_Processed_Documents_T(Document_ID,Processed_DT,Processed_By_VC) values (" & varDocumentID & ",getdate(),'" & varProcessedBy & "')"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function InsertIntoRentsUDFIProcessedTransactions(varAccountID,varTransactionID,varProcessedBy)
- varSelect = "insert into usr_SW_Rents_UDFI_Processed_Transactions_T(Account_ID,Transaction_ID,Processed_DT,Processed_By_VC) values ('" & varAccountID & "','" & varTransactionID & "',getdate(),'" & varProcessedBy & "')"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function InsertIntoRentsUDFIProcessedInvoices(varAccountID,varTransactionID,varInvoiceID,varProcessedBy)
- varSelect = "insert into usr_SW_Rents_UDFI_Processed_Invoices_T(Account_ID,Transaction_ID,Invoice_ID,Processed_DT,Processed_By_VC) values ('" & varAccountID & "','" & varTransactionID & "','" & varInvoiceID & "',getdate(),'" & varProcessedBy & "')"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- '***************Unite*********************
- Function DeleteFromCancelledApplicationAuditTable(varApplicationID)
- varDelete = "delete from usr_SW_Lettings_Cancelled_Application_Audit_T where Application_ID = " & varApplicationID
- with SQLConnection.Execute(varDelete)
- end with
- End Function
- Function UpdateEmergencyTransferTaskingAudit(varMatchID,varTaskID,varUsername)
- varSelect = "Insert into usr_SW_Lettings_Match_Task_Audit_T (Match_ID,Task_ID,Generated_Date_DT,Generated_By_VC) values (" & varMatchID & "," & varTaskID & ", getdate(),'" & varUsername & "')"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function InsertIntoViewingAndSignupAuditTable(varMatchID,varOfferID,varApplicationID,varTaskID)
- varInsert = "insert into usr_SW_Lettings_Viewing_and_Signup_T(Match_ID,Offer_ID,Application_ID,Task_ID) values (" & varMatchID & "," & varOfferID & "," & varApplicationID & "," & varTaskID & ")"
- with SQLConnection.Execute(varInsert)
- end with
- End Function
- Function UpdateEpisodeAndPoliciesAuditTable(varEpisodeID,varOriginalPolicyID,varPolicyID)
- varInsert = "insert into usr_SW_Lettings_Episode_Policy_Audit_T (Episode_ID,Original_Policy_ID,Policy_ID) values (" & varEpisodeID & "," & varOriginalPolicyID & "," & varPolicyID & ")"
- With SQLConnection.Execute(varInsert)
- End With
- End Function
- Function DeleteFromEpisodePolicyAuditTable(varEpisodeID)
- varSelect = "delete from usr_SW_Lettings_Episode_Policy_Audit_T where Episode_ID = " & varEpisodeID & ""
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function UpdateGenerateActionFailedTable(varAccountID,varNextAction)
- varInsert = "insert into usr_SW_Debt_Management_Generate_Action_Failed_T (Account_ID,Next_Action_VC) values ('" & varAccountID & "','" & varNextAction & "')"
- With SQLConnection.Execute(varInsert)
- End With
- End Function
- Function DeleteFromGenerateActionFailedTable(varAccountID,varNextAction)
- varDelete = "delete from usr_SW_Debt_Management_Generate_Action_Failed_T where Account_ID = '" & varAccountID & "' and Next_Action_VC = '" & varNextAction & "'"
- With SQLConnection.Execute(varDelete)
- End With
- End Function
- Function UpdateDMTaskingAuditT(varAccountID,varWorkflowRef,varTaskID,varEpisodeID)
- varInsert = "insert into usr_SW_Debt_Management_Tasking_Audit_T(Account_ID,Workflow_Reference_VC,Task_ID,Generated_Date_DT,Episode_ID) values ('" & varAccountID & "','" & varWorkflowRef & "'," & varTaskID & ",getdate(),'" & varEpisodeID & "')"
- with SQLConnection.Execute(varInsert)
- End with
- End Function
- Function UpdateDMTaskingAuditTCourtOutcome(varAccountID,varWorkflowRef,varTaskID,varEpisodeID,varMonitoringLevel,varHearingDate)
- varInsert = "insert into usr_SW_Debt_Management_Tasking_Audit_Outcome_of_Court_Hearing_T(Account_ID,Workflow_Reference_VC,Task_ID,Generated_Date_DT,Episode_ID,Monitoring_Level_VC,Hearing_Date_DT) values ('" & varAccountID & "','" & varWorkflowRef & "'," & varTaskID & ",getdate(),'" & varEpisodeID & "','" & varMonitoringLevel & "','" & varHearingDate & "')"
- 'msgBox varInsert
- with SQLConnection.Execute(varInsert)
- end with
- End Function
- Function UpdateDMTaskingAuditTWFDM010(varAccountID,varWorkflowRef,varTaskID,varMonitoringLevel)
- varInsert = "insert into usr_SW_Debt_Management_Tasking_Audit_T(Account_ID,Workflow_Reference_VC,Task_ID,Generated_Date_DT,Monitoring_Level_VC) values ('" & varAccountID & "','" & varWorkflowRef & "'," & varTaskID & ",getdate(),'" & varMonitoringLevel & "')"
- with SQLConnection.Execute(varInsert)
- End with
- End Function
- Function UpdateCourtDetailsTrackerT(varAccountID,varEpisodeID,varCourtOrderCode,varDaysUntilEnforcement,varMoneyJudgement,varCourtOrderNumber,varTermsOfOrder,varCourtOrderCosts)
- varUpdate = "update usr_SW_Debt_Management_Court_Details_Tracker_T set Episode_ID = '" & varEpisodeID & "', Court_Order_Code_VC = '" & varCourtOrderCode & "', Days_Unit_Order_Enforcement_NM = '" & varDaysUntilEnforcement & "', Money_Judgement_DC = " & varMoneyJudgement & ", Court_Order_Number_VC = '" & varCourtOrderNumber & "', Terms_Of_Order_VC = '" & varTermsOfOrder & "',Court_Order_Costs_DC = " & varCourtOrderCosts & ", Updated_Date_DT = getdate() where Account_ID = '" & varAccountID & "'"
- with SQLConnection.Execute(varUpdate)
- End with
- End Function
- Function InsertIntoCourtDetailsTrackerT(varAccountID,varEpisodeID,varCourtOrderCode,varDaysUntilEnforcement,varMoneyJudgement,varCourtOrderNumber,varTermsOfOrder,varCourtOrderCosts)
- varInsert = "insert into usr_SW_Debt_Management_Court_Details_Tracker_T (Account_ID,Episode_ID,Court_Order_Code_VC,Days_Unit_Order_Enforcement_NM,Money_Judgement_DC,Court_Order_Number_VC,Terms_Of_Order_VC,Court_Order_Costs_DC,Updated_Date_DT) values ('" & varAccountID & "','" & varEpisodeID & "','" & varCourtOrderCode & "','" & varDaysUntilEnforcement & "','" & varMoneyJudgement & "','" & varCourtOrderNumber & "','" & varTermsOfOrder & "'," & varCourtOrderCosts & ",getdate())"
- with SQLConnection.Execute(varInsert)
- End with
- End Function
- Function InsertIntoGatewaySubmissionErrorsT(varXMLFile,varFileName,varResponse)
- varInsert = "insert into usr_SW_Gateway_Submission_Errors_T(Submission_XML_VC,Error_Response_VC,File_Name_VC,Submission_Date_DT) values ('" & varXMLFile & "','" & varResponse & "','" & varFileName & "',getdate())"
- with SQLConnection.Execute(varInsert)
- End with
- End Function
- Function SendSMSDebtManagement(TargetNumber, MessageBody)
- Dim varExecute
- SendSMSDebtManagement = False
- 'varExecute = _
- '"INSERT INTO Shared_SMS_Outbox_T (Status_ID,Recipient_VC,Message_VC,Sent_User_ID) VALUES(0,'" & TargetNumber & "','" & MessageBody & "',1)"
- 'SQLConnection.Execute(varExecute)
- SendSMSDebtManagement = True
- end function
- Function UpdateEvictionTrackerT(varAccountID,varAccountEpisodeID,varEvictionDate,varEvictionTime)
- varUpdate = "update usr_SW_Debt_Management_Evictions_Tracker_T set Account_Episode_ID = '" & varAccountEpisodeID & "', Eviction_Date_DT = '" & varEvictionDate & "', Eviction_Time_DT = '" & varEvictionTime & "' where Account_ID = '" & varAccountID & "'"
- with SQLConnection.Execute(varUpdate)
- End with
- End Function
- Function UpdateEvictionAppealTrackerT(varAccountID,varAccountEpisodeID,varAppealDate,varAppealTime)
- varUpdate = "update usr_SW_Debt_Management_Eviction_Appeals_Tracker_T set Account_Episode_ID = '" & varAccountEpisodeID & "', Appeal_Date_DT = '" & varAppealDate & "', Appeal_Time_DT = '" & varAppealTime & "' where Account_ID = '" & varAccountID & "'"
- with SQLConnection.Execute(varUpdate)
- End with
- End Function
- Function InsertIntoEvictionTrackerT(varAccountID,varAccountEpisodeID,varEvictionDate,varEvictionTime)
- varInsert = "insert into usr_SW_Debt_Management_Evictions_Tracker_T (Account_ID,Account_Episode_ID,Eviction_Date_DT,Eviction_Time_DT) values ('" & varAccountID & "','" & varAccountEpisodeID & "'," & varEvictionDate & ",'" & varEvictionTime & "')"
- with SQLConnection.Execute(varInsert)
- End with
- End Function
- Function InsertIntoEvictionAppealTrackerT(varAccountID,varAccountEpisodeID,varAppealDate,varAppealTime)
- varInsert = "insert into usr_SW_Debt_Management_Eviction_Appeals_Tracker_T (Account_ID,Account_Episode_ID,Appeal_Date_DT,Appeal_Time_DT) values ('" & varAccountID & "','" & varAccountEpisodeID & "','" & varAppealDate & "','" & varAppealTime & "')"
- with SQLConnection.Execute(varInsert)
- End with
- End Function
- Function UpdateDebtManagementLogSuccess(varAccountID,varCurrentAction,varNextAction,varMonitoringLevel)
- varUpdate = "insert into usr_SW_Debt_Management_Log_T (Account_ID,Last_Action_VC,New_Action_VC,Last_Monitoring_Level_VC,Processed_Date_DT,Success_BT) values ('" & varAccountID & "','" & varCurrentAction & "','" & varNextAction & "','" & varMonitoringLevel & "',getdate(),1)"
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function UpdateDebtManagementLogFailure(varAccountID,varCurrentAction,varNextAction,varMonitoringLevel)
- varUpdate = "insert into usr_SW_Debt_Management_Log_T (Account_ID,Last_Action_VC,New_Action_VC,Last_Monitoring_Level_VC,Processed_Date_DT,Success_BT) values ('" & varAccountID & "','" & varCurrentAction & "','" & varNextAction & "','" & varMonitoringLevel & "',getdate(),0)"
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function PrepareXMLForSubmission(varXML)
- HTML = replace(replace(varXML,"<","<"),">",">")
- PrepareXMLForSubmission = HTML
- End Function
- Function PrepareForContractors(varHTML)
- XML = replace(replace(varHTML,"<","<"),">",">")
- PrepareForContractors = XML
- End Function
- Function SendXML(varSite,varRequest)
- 'msgbox varRequest
- DIM WebRequest
- SET WebRequest = CreateObject ("MSXML2.XMLHTTP")
- WITH WebRequest
- .Open "POST", varSite , False
- .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
- .setRequestHeader "SOAPAction", "http://www.mis-ams.com/GatewaySubmission"
- .send varRequest
- 'If .Status >= 400 And .Status <= 599 Then msgbox( "Error Occurred : " & .Status & " - " & .statusText)
- SendXML = .responseText
- END WITH
- SET WebRequest = Nothing
- End Function
- Function VerifyFile(Filename)
- Dim fso
- Not_Found = 0
- set fso=CreateObject("Scripting.FileSystemObject")
- If fso.FileExists(Filename) Then
- Not_Found = 1
- Else
- Not_Found = 0
- End If
- VerifyFile = Not_Found
- End Function
- Function CheckDirectory(fldr)
- On Error resume Next:err.clear
- Dim fso, msg
- msg = False
- Set fso = CreateObject("Scripting.FileSystemObject")
- If fso.FolderExists(fldr) Then msg = True Else msg = False End If
- CheckDirectory = msg
- End Function
- Function VoidManagementSpecTemplateImport(varFile)
- Dim strSQL, objApp, objWkbk, intRow, sqlDEL, Quantity, SORCode, Priority, TenRecharge, ContractID, AssetID, Location
- sqlDEL = "Delete from usr_SW_Void_Management_Spec_Import_T"
- With sqlconnection.execute (sqlDEL)
- End With
- set objApp = createObject("Excel.Application")
- set objWkbk = objApp.Workbooks.Open(varFile)
- ContractID = objApp.Cells(3, 2).Value
- AssetID = objApp.Cells(4, 2).Value
- intRow = 8
- do until objApp.cells(intRow, 2) = ""
- If len(objApp.Cells(intRow, 1).Value) = 0 Then Quantity = 0 Else Quantity = objApp.Cells(intRow, 1).Value End If
- SORCode = objApp.Cells(intRow, 2).Value
- TenRecharge = replace(objApp.Cells(intRow, 4).Value ,"a",1)
- JobType = objApp.Cells(intRow, 6).Value
- Location = objApp.Cells(intRow, 7).Value
- strsql = "insert into usr_SW_Void_Management_Spec_Import_T (Asset_ID,Contract_ID,SOR_Code_VC,Quantity_DC,Tenant_Rechargeable_BT,Location_VC) Values ('" & AssetID & "','" & ContractID & "','" & SORCode & "'," & Quantity & ",'" & TenRecharge & "','" & Location & "')"
- With sqlconnection.execute(strsql)
- End With
- intRow = intRow +1
- loop
- objWkbk.close
- objApp.quit
- strDEL = "delete from usr_SW_Void_Management_Spec_Import_T where Quantity_DC = 0"
- With SQLConnection.Execute(strDEL)
- End With
- End Function
- Function UpdateDMJointLetterAudit(varMergeLetterID,varDataSource,varMailmergeID)
- varUpdate = "insert into usr_SW_Debt_Management_Joint_Mail_Merge_Audit_T(Merge_Letter_ID,Merge_Data_Source_VC,Mail_Merge_ID) values (" & varMergeLetterID & ",'" & varDataSource & "'," & varMailMergeID & ")"
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function GenerateWebSecurityPassword
- With SQLUtilities.SQLConnect.CreateCommand
- .CommandType = 4 'adCmdStoredProc
- .CommandText = "USR_SW_TIPS_GenerateRandomPassword"
- .Parameters.Refresh
- .Execute
- GenerateWebSecurityPassword = .Parameters("@Password").Value
- End With
- End Function
- Function UpdateWebSecurityPassword(varContactID,varNewPassword)
- varUpdate = "update Contact_Contacts_T SET Web_Security_Password_VC = dbo.fn_EncryptSecurityString('" & varNewPassword & "'), Web_Security_Date_Last_Password_Changed_DT=getdate(),Web_Security_Force_Change_BT=1 where Contact_ID = " & varContactID & ""
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function FilesInDirectory(varDirectory)
- Dim fs, fo, x, varFileListing, varSep
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set fo = fs.GetFolder(varDirectory)
- varFileListing = ""
- varSep = ""
- For Each x In fo.files
- varFileListing = x.Name & varSep & varFileListing
- varSep = ","
- Next
- Set fo = Nothing
- Set fs = Nothing
- FilesInDirectory = varFileListing
- End Function
- Function MoveFile(varMoveFrom,varMoveTo)
- On Error resume Next:err.clear
- Dim fso
- Set fso = CreateObject("Scripting.FileSystemObject")
- fso.MoveFile varMoveFrom, varMoveTo
- Set fso = Nothing
- If Err.Number = 0 Then MoveFile = err.description
- End Function
- Function VerifyFile(Filename)
- Dim fso
- Not_Found = 0
- set fso=CreateObject("Scripting.FileSystemObject")
- If fso.FileExists(Filename) Then
- Not_Found = 1
- Else
- Not_Found = 0
- End If
- VerifyFile = Not_Found
- End Function
- Function ReadFromCSVFile(File)
- Dim fso
- Dim txtstream
- Const ForReading = 1, ForWriting = 2, ForAppending = 8
- set fso=CreateObject("Scripting.FileSystemObject")
- set txtstream=fso.OpenTextFile(File, ForReading, True)
- ReadFromCSVFile = txtstream.ReadLine
- txtstream.Close
- End Function
- Function ConvertCOOPUnpaidDD(FileName)
- dim objFSO
- dim COOPFile
- dim COOPText
- dim OutputFile
- dim lngCount
- dim reflen
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- If not objFSO.FileExists(FileName) Then
- MSGBOX "File cannot be found",vbCritical+vbOKONly,"COOP Unpaid DD Payment File Re Format"
- Else
- Set COOPFile = objFSO.OpenTextFile(FileName, 1, True)
- Set OutputFile = objFSO.CreateTextFile(replace(FileName,".csv"," - reformat.csv"),2,True)
- lngcount = 0
- Do While Not COOPFile.AtEndOfStream
- COOPText= COOPFile.ReadLine
- lngCount = lngCount + 1
- If lngCount > 7 Then
- If SQLUtilities.Globals.Field(cstr(COOPText),",",1) <> "Comment:" and SQLUtilities.Globals.Field(cstr(COOPText),",",1) <> "" and SQLUtilities.Globals.Field(cstr(COOPText),",",14) <> "" then
- transactiondate = SQLUtilities.Globals.Field(cstr(COOPText),",",14)
- transactionamount = SQLUtilities.Globals.Field(cstr(COOPText),",",7)
- transactionreference = replace(SQLUtilities.Globals.Field(cstr(COOPText),",",1)," ","")
- If IsNumeric(transactionreference) = "False" Then
- reflen = Len(transactionreference) - 1
- transactionreference = Left(transactionreference,reflen)
- End If
- outputfile.Writeline transactionreference & ",unpaid " & transactiondate & ",-" & transactionamount
- End If
- End If
- Loop
- OutputFile.Close
- COOPFile.Close
- msgbox "Re Format of COOP Unpaid DD Import File Finished",vbinformation+vbokonly,"COOP Unpaid DD Payment File Re Format"
- End If
- End Function
- Function UpdateRobustAsbestosSurveyAuditT(varCaseID,varTaskID)
- varSelect = "insert into usr_SW_Void_Management_Robust_Asbestos_Audit_T(Case_ID,Task_ID) values (" & varCaseID & "," & varTaskID & ")"
- With SQLConnection.Execute(varSelect)
- End With
- End Function
- Function UpdateUpcomingPostInspectionAuditT(varCaseID,varTaskID)
- varSelect = "insert into usr_SW_Void_Management_Upcoming_Post_Inspection_Audit_T(Case_ID,Task_ID) values (" & varCaseID & "," & varTaskID & ")"
- with SQLConnection.Execute(varSelect)
- end with
- End Function
- Function InsertIntoEmailAuditT(varContactID,varPassword)
- varSelect = "INSERT INTO usr_SW_TIPS_WebSecurity_EmailAudit_T (Contact_ID,Password_VC) values (" & varContactID & ",'" & varPassword & "')"
- WITH SQLConnection.Execute(varSelect)
- END WITH
- END Function
- Function DeleteFromEmailAuditT(varContactID)
- varSelect = "Delete from usr_SW_TIPS_WebSecurity_EmailAudit_T WHERE Contact_ID = " & varContactID & ""
- WITH SQLConnection.Execute(varSelect)
- END WITH
- End Function
- Function GenerateWebSecurityPassword
- With SQLUtilities.SQLConnect.CreateCommand
- .CommandType = 4 'adCmdStoredProc
- .CommandText = "USR_SW_TIPS_GenerateRandomPassword"
- .Parameters.Refresh
- .Execute
- GenerateWebSecurityPassword = .Parameters("@Password").Value
- End With
- End Function
- Function UpdateWebSecurityPassword(varContactID,varNewPassword)
- varUpdate = "update Contact_Contacts_T SET Web_Security_Password_VC = dbo.fn_EncryptSecurityString('" & varNewPassword & "'), Web_Security_Date_Last_Password_Changed_DT=getdate(),Web_Security_Force_Change_BT=1 where Contact_ID = " & varContactID & ""
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function Usr_HPM_Automated_Desktop_Task
- Dim objCmd
- Dim ErrorCode
- Set objCmd = SQLUtilities.SQLConnect.CreateCommand
- objCmd.CommandType = 4 'Stored Proc
- objCmd.CommandText = "Usr_HPM_Desktop_Task_Automation_SP"
- 'objCmd.Parameters.Refresh
- 'objCmd.Parameters("@TransactionID").Value = TransactionID
- Set ErrorCode = objCmd.Execute
- Set objCmd = Nothing
- End Function
- Function Usr_HPM_Update_DT_Timestamp(CaseID,DesktopTaskID)
- varUpdate = "UPDATE dbo.Usr_Case_Desktop_Task_Audit_T SET Desktop_Task_sent_At = GETDATE() WHERE Case_ID = " & CaseID & " AND Desktop_Task_ID = " & DesktopTaskID
- With SQLConnection.Execute(varUpdate)
- End With
- End Function
- Function GetDateInput()
- Dim objShell
- Set objExplorer = CreateObject("InternetExplorer.Application")
- Set objShell = CreateObject("WScript.Shell")
- Call CreateHTMLFile
- Call CreateSleepFile
- objExplorer.Navigate "file:///H:\Datepicker.html"
- objExplorer.ToolBar = 0
- objExplorer.StatusBar = 0
- objExplorer.Width=400
- objExplorer.Height = 300
- objExplorer.Visible = 1
- Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
- objShell.Run("H:\Sleep.vbs")
- Loop
- GetDateInput = CDate(objExplorer.Document.Body.All.Calendar1.Value)
- objExplorer.Quit
- End Function
- Sub CreateSleepFile
- Dim MyFSO, MyFile
- Set MyFSO = CreateObject ("Scripting.FileSystemObject")
- Set MyFile = MyFSO.CreateTextFile( "H:\Sleep.vbs", True )
- MyFile.WriteLine( "WScript.sleep 250" )
- MyFile.Close
- End Sub
- Sub CreateHTMLFile
- Dim MyFSO, MyFile
- Set MyFSO = CreateObject ("Scripting.FileSystemObject")
- Set MyFile = MyFSO.CreateTextFile( "H:\Datepicker.html", True )
- htmlFile = "<HTML>" & vbNewLine & vbNewLine & vbNewLine & _
- "<HEAD>" & vbNewLine & _
- "<TITLE>Date Picker</TITLE>" & vbNewLine & _
- "</HEAD>" & vbNewLine & _
- "<SCRIPT language=""VBScript"">" & vbNewLine & _
- "<!--" & vbNewLine & _
- "Sub OKButton_OnClick" & vbNewLine & _
- "OkClicked.Value = 1" & vbNewLine & _
- "End Sub" & vbNewLine & _
- "'-->" & vbNewLine & _
- "</SCRIPT>" & vbNewLine & _
- "<BODY bgcolor=""buttonface"">" & vbNewLine & _
- "<p align=""center"">" & vbNewLine & _
- "<OBJECT CLASSID=""clsid:8E27C92B-1264-101C-8A2F-040224009C02"" id=Calendar1>" & vbNewLine & _
- "<param name=""BackColor"" value=""-2147483633"">" & vbNewLine & _
- "<param name=""DayLength"" value=""1"">" & vbNewLine & _
- "<param name=""MonthLength"" value=""1"">" & vbNewLine & _
- "<param name=""DayFontColor"" value=""0"">" & vbNewLine & _
- "<param name=""FirstDay"" value=""7"">" & vbNewLine & _
- "<param name=""GridCellEffect"" value=""1"">" & vbNewLine & _
- "<param name=""GridFontColor"" value=""10485760"">" & vbNewLine & _
- "<param name=""GridLinesColor"" value=""-2147483632"">" & vbNewLine & _
- "<param name=""ShowDateSelectors"" value=""-1"">" & vbNewLine & _
- "<param name=""ShowDays"" value=""-1"">" & vbNewLine & _
- "<param name=""ShowHorizontalGrid"" value=""-1"">" & vbNewLine & _
- "<param name=""ShowTitle"" value=""-1"">" & vbNewLine & _
- "<param name=""ShowVerticalGrid"" value=""-1"">" & vbNewLine & _
- "<param name=""TitleFontColor"" value=""10485760"">" & vbNewLine & _
- "<param name=""ValueIsNull"" value=""0"">" & vbNewLine & _
- "</OBJECT>" & vbNewLine & _
- "<br>" & vbNewLine & _
- "<INPUT NAME=""OKButton"" TYPE=""BUTTON"" VALUE=""OK"" >" & vbNewLine & _
- "<input type=""hidden"" name=""OKClicked"" size=""20""></P>" & vbNewLine & _
- "</BODY>" & vbNewLine & _
- "</HTML>"
- MyFile.WriteLine(htmlFile)
- MyFile.Close
- End Sub
- Function HPMNBUpdateDiaryAuditTable(ClassificationID,DiaryID)
- crmSql = "select TOP 1 Call_ID FROM CRM_Calls_T WHERE Classification_ID = " & ClassificationID & " ORDER BY Call_ID DESC"
- With SQLConnection.Execute(crmSql)
- Do Until .EOF
- LatestCallID = .Fields("Call_ID").Value
- .MoveNext
- Loop
- End With
- auditSql = "INSERT INTO usr_SW_New_Build_Diary_CRM_Audit_T VALUES (" & DiaryID & ", " & LatestCallID & ")"
- With SQLConnection.Execute(auditSql)
- End With
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement