· 8 years ago · Nov 06, 2017, 12:34 PM
1Function SW_AgreementInForce(varAccountID,varAgreementID)
2
3 varTodaysDate = Date
4 varTodaysDate = ReturnDateDDMMMYYYY(varTodaysDate)
5 varAgrID = 0
6
7 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))"
8
9 With SQLConnection.Execute(varSelect)
10 Do Until .EOF
11 varAgrID = .Fields("ID").Value
12 .MoveNext
13 Loop
14 End With
15
16 SW_AgreementInForce = varAgrID
17
18End Function
19
20Function SW_SO_Update_Workfile(varID, varAssetID, varAgrID, varCurBal, varPrevBal, varCurRent, varLastActionBy, varLastActionDated, varLastActionTime, varLastAction, varCurMonLevel, varS0Comp, varS1Comp, varS2Comp, varDDComp, varReportID, varDD, varGroupID)
21
22varInsert = "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 & ")"
23' MSGBOX varInsert
24With SQLConnection.Execute(varInsert)
25End With
26
27End Function
28
29Function CreateDesktopUser(ContactID,UserName,ParentID)
30
31varInsert = "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)"
32
33With SQLConnection.Execute(varInsert)
34End With
35
36varSelect = "SELECT User_ID From Shared_Users_T WHERE Contact_ID = '" & ContactID & "'"
37
38With SQLConnection.Execute(varSelect)
39 If (Not .EOF) And (Not .BOF) Then
40 UserID = .Fields("User_ID").Value
41 End If
42End With
43
44varInsert = "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 & ")"
45
46With SQLConnection.Execute(varInsert)
47End With
48
49varInsert = "INSERT INTO dbo.Shared_User_Roles_T (User_ID,Role_ID) VALUES(" & UserID & ",113)"
50
51With SQLConnection.Execute(varInsert)
52End With
53
54End Function
55
56Function UpdateUserContact(ContactID,JobTitle,CompanyName,Department)
57
58varUpdate = "UPDATE dbo.Contact_Contacts_T SET Job_Title_VC = '" & JobTitle & "', Company_Name_VC = '" & CompanyName & "', Department_VC = '" & Department & "' WHERE Contact_ID = " & ContactID
59
60With SQLConnection.Execute(varUpdate)
61End With
62
63End Function
64
65'*** Start *** CRM Snapshot ***
66
67Function BuildCRMInitial
68 BuildCRMInitial = GetHTMLFile("\\srv-fls-01\data\Snapshot\CRMInitialSnapshot.txt")
69
70End Function
71
72Function SW_FTA_VerifyCompletionReason(varValid,varReason)
73
74varSelect = "SELECT CASE WHEN " & varReason & " IN (" & varValid & ") THEN 1 ELSE 0 END AS Valid"
75
76With SQLConnection.Execute(varSelect)
77 Do Until .EOF
78 SW_FTA_VerifyCompletionReason = .Fields("Valid").Value
79 .MoveNext
80 Loop
81End With
82
83End Function
84
85Function GetHTMLFile(Filename)
86 dim fso
87 dim html
88 set fso = CreateObject("Scripting.FileSystemObject")
89
90' Open the file for input.
91 Set MyFile = fso.OpenTextFile(Filename, 1)
92' Read from the file and display the results.
93 Do While MyFile.AtEndOfStream <> True
94 TextLine = MyFile.ReadLine
95 html = html & TextLine
96 Loop
97
98 MyFile.Close
99 GetHTMLFile = html
100End Function
101
102Function GetTaskCount(GroupContact)
103
104 Dim varselect
105 Dim Processed
106 Dim TaskCount
107
108 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"
109
110 With SQLConnection.Execute(varselect)
111 If Not .Eof Then
112 TaskCount = .Fields("open_task_count").Value
113 Processed = True
114 End If
115 .Close
116 End With
117
118 If Not Processed Then Exit Function
119
120 GetTaskCount=TaskCount
121
122End Function
123
124
125Function ValidateSnapshotRoles(UserID)
126
127 Dim varselect
128 Dim Processed
129 Dim ValidRoles
130
131 '2 - Raglan All Access
132 '9 - HSC Teamleaders (old role)
133 '10 - HSC Front Desk (old role)
134 '** New Roles For Unite **
135 '152 - CC Advisor
136 '154 - CC Team Leader
137 '155 - CC Manager
138 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
139
140 With SQLConnection.Execute(varselect)
141 If Not .Eof Then
142 ValidRoles = .Fields("Roles").Value
143 Processed = True
144 End If
145 .Close
146 End With
147
148 If Not Processed Then Exit Function
149
150 ValidateSnapshotRoles=ValidRoles
151
152End Function
153
154Function UpdateSnapshotTracker(UserID, CallerID) ' CallerID is Group Contact ID
155
156 Dim strSQLclear
157 Dim strSQLins
158
159 ' Purge previous record for current user
160 strSQLclear = "DELETE FROM SW_USR_Snapshot_Tracker_T where UserID=" & UserID
161
162 ' Record current caller context
163 strSQLins = "INSERT INTO SW_USR_Snapshot_Tracker_T (UserID, ContactID) VALUES (" & UserID & ", " & CallerID & ")"
164
165 With SQLConnection.Execute(strSQLclear)
166 End With
167
168 With SQLConnection.Execute(strSQLins)
169 End With
170
171End Function
172
173
174
175Function BuildCRMSnapshot(GroupContact)
176 Dim html
177 Dim body
178 Dim q
179 Dim rs
180 Dim varselect
181 Dim Processed
182
183 Dim TenancyReference
184 Dim ExpectedBalance
185 Dim HearingVulnerabilties
186 Dim VisualVulnerabilities
187 Dim CommsVulnerabilities
188 Dim DisabledVulnerabilities
189 Dim StickVulnerabilities
190 Dim Agreement
191 Dim CurrentActionLevel
192 Dim ActionStatus
193 Dim Longitude
194 Dim Latitude
195 Dim Asbestos
196 Dim OpenCalls
197 Dim OpenRequests
198 Dim OpenASB
199 Dim OpenComplaint
200 Dim OpenRTB
201 Dim OpenPlans
202 Dim Applications
203 Dim GasServicing
204 Dim BedroomTax
205 Dim Arrears24
206 Dim Arrears18
207 Dim Arrears12
208 Dim Arrears6
209 Dim DateOfBirth
210 Dim Allpay
211 Dim Callpay
212 Dim Experian
213 Dim UC
214 Dim SWSelectStage
215 Dim GroupID
216 Dim ContactID
217 Dim CCPD
218 Dim CCSD
219 Dim CCLD
220 Dim CCMI
221 Dim CCMC
222 Dim Asset_ID
223 Dim Estate_ID
224 Dim SwipeCardOrdered
225 Dim DateSwipeCardPrinted
226 Dim AccountStartDate
227
228 Dim img
229
230 Dim TaskCount
231
232 TaskCount = GetTaskCount(GroupContact)
233 varselect = "SELECT * FROM dbo.usr_CRM_Snapshot_V WHERE Group_Contact_ID = " & GroupContact
234
235 With SQLConnection.Execute(varSelect)
236 If Not .Eof Then
237 TenancyReference = .Fields("TenancyReference").Value
238 ExpectedBalance = .Fields("ExpectedBalance").Value
239 HearingVulnerabilities = .Fields("HearingVulnerabilities").Value
240 VisualVulnerabilities = .Fields("VisualVulnerabilities").Value
241 'CommsVulnerabilities = .Fields("CommsVulnerabilities").Value
242 DisabledVulnerabilities = .Fields("DisabledVulnerabilities").Value
243 StickVulnerabilities = .Fields("StickVulnerabilities").Value
244 Agreement = .Fields("Agreement").Value
245 CurrentActionLevel = .Fields("CurrentActionLevel").Value
246 ActionStatus = .Fields("ActionStatus").Value
247 Longitude = .Fields("Longitude").Value
248 Latitude = .Fields("Latitude").Value
249 Postcode = .Fields("Postcode").Value
250 Asbestos = .Fields("Asbestos").Value
251 OpenCalls = .Fields("OpenCalls").Value
252 OpenRequests = .Fields("OpenRequests").Value
253 OpenASB = .Fields("OpenASB").Value
254 OpenComplaint = .Fields("OpenComplaint").Value
255 OpenRTB = .Fields("OpenRTB").Value
256 OpenPlans = .Fields("OpenPlans").Value
257 Applications = .Fields("Applications").Value
258 GasServicing = .Fields("GasServicing").Value
259 BedroomTax = .Fields("BedroomTax").Value
260 Arrears24 = .Fields("Arrears24Months").Value
261 Arrears18 = .Fields("Arrears18Months").Value
262 Arrears12 = .Fields("Arrears12Months").Value
263 Arrears6 = .Fields("Arrears6Months").Value
264 DateOfBirth = .Fields("DateOfBirth").Value
265 LastPaymentValue = .Fields("LastPaymentValue").Value
266 LastPaymentMethod = .Fields("LastPaymentMethod").Value
267 HomeTel = .Fields("HomeTel").Value
268 MobTel = .Fields("MobTel").Value
269 HomeTelSourceCheck = .Fields("HomeTelSourceCheck").Value
270 MobTelSourceCheck = .Fields("MobTelSourceCheck").Value
271 Email = .Fields("Email").Value
272 TIPSUsername = .Fields("TIPSUsername").Value
273 TIPSLastLoginDate = .Fields("TIPSLastLoginDate").Value
274 AccountEndDate = .Fields("AccountEndDate").Value
275 Gender = .Fields("ContactGender").Value
276 Ethnicity = .Fields("ContactEthnicity").Value
277 MaritalStatus = .Fields("ContactMaritalStatus").Value
278 EmploymentStatus = .Fields("ContactEmploymentStatus").Value
279 Religion = .Fields("ContactReligion").Value
280 SexualOrientation = .Fields("ContactSexualOrientation").Value
281 Warranty = .Fields("Warranty").Value
282 NumberOutstandingRepairs = .Fields("NumberOutstandingRepairs").Value
283 NotDisabled = .Fields("NotDisabled").Value
284 Risk = .Fields("Risk").Value
285 NonRisk = .Fields("Non_Risk").Value
286 Experian = .Fields("Experian").Value
287 UC = .Fields("UC").Value
288 SWSelectStage = .Fields("SWSelectStage").Value
289 GroupID = .Fields("Group_ID").Value
290 ContactID = .Fields("ContactID").Value
291 CCPD = .Fields("CCPD").Value
292 CCSD = .Fields("CCSD").Value
293 CCLD = .Fields("CCLD").Value
294 CCMI = .Fields("CCMI").Value
295 CCMC = .Fields("CCMC").Value
296 Asset_ID = .Fields("Asset_ID").Value
297 Estate_ID = .Fields("Estate_ID").Value
298 SwipeCardOrdered = .Fields("SwipeCardOrdered").Value
299 DateSwipeCardPrinted = .Fields("DateSwipeCardPrinted").Value
300 AccountStartDate = .Fields("AccountStartDate").Value
301 Processed = True
302 End If
303 .Close
304 End With
305
306 If Not Processed Then Exit Function
307
308 ' Call File.WriteAllText("\\srv-fls-01\data\Snapshot\test.txt", "This is new text to be added.",True)
309
310 q = chr(34)
311
312
313 html = GetHTMLFile("\\srv-fls-01\data\Snapshot\CRMSnapshotHeaderNew.txt")
314
315 html = replace(html,"24M",Arrears24)
316 html = replace(html,"18M",Arrears18)
317 html = replace(html,"12M",Arrears12)
318 html = replace(html,"6M",Arrears6)
319 html = replace(html,"CURRENT",ExpectedBalance)
320
321
322' Begin HTML body output
323
324 body = body & "<table cols=4>"
325 body = body & "<tr><td width=25% valign=top>"
326
327' Security check
328 body = body & "<table cols=2 width=400px><tr>"
329 body = body & "<td class=" & q & "Security" & q & " colspan=2 align=center>Security Check</td></tr>"
330' Dob
331 If Len(DateOfBirth) > 0 Then
332 body = body & "<td><font face=arial size=2><b>Date of Birth</b></font></td>"
333 Else
334 body = body & "<td><font face=arial size=2 color=red><b>Date of Birth</b></font></td>"
335 End If
336' body = body & "<tr><td><font face=arial size=2><b>Date of Birth</b></font></td>"
337 body = body & "<td><font face=arial size=2>" & DateOfBirth & "</font></td>"
338' Rent account no
339 body = body & "<tr><td><font face=arial size=2><b>Rent Account Number</b></font></td>"
340 body = body & "<td><font face=arial size=2>" & TenancyReference & "</font></td>"
341' Last payment method
342 body = body & "<tr><td><font face=arial size=2><b>Last Payment Method</b></font></td>"
343 body = body & "<td><font face=arial size=2>" & LastPaymentMethod & "</font></td>"
344' Last payment amount
345 body = body & "<tr><td><font face=arial size=2><b>Last Payment Amount</b></font></td>"
346 body = body & "<td><font face=arial size=2>" & LastPaymentValue & "</font></td>"
347 body = body & "</tr><tr>"
348
349' Contact Details
350 body = body & "<td class=" & q & "Contact" & q & " colspan=2 align=center>Contact Details</td></tr><tr>"
351
352' TESTING TaskCount
353' 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>"
354
355
356' Home Telephone
357 If Len(HomeTel) > 0 Then
358 body = body & "<td><font face=arial size=2><b>Home Telephone</b></font></td>"
359 Else
360 body = body & "<td><font face=arial size=2 color=red><b>Home Telephone</b></font></td>"
361 End If
362
363 If HomeTelSourceCheck = 0 Then ' If 0 then number is from wrong table (or blank)
364 body = body & "<td><font face=arial size=2 color=red>" & HomeTel & "</font></td></tr><tr>"
365 Else
366 body = body & "<td><font face=arial size=2>" & HomeTel & "</font></td></tr><tr>"
367 End If
368
369' Mobile
370 If Len (MobTel) > 0 Then
371 body = body & "<td><font face=arial size=2><b>Mobile Telephone</b></font></td>"
372 Else
373 body = body & "<td><font face=arial size=2 color=red><b>Mobile Telephone</b></font></td>"
374 End If
375
376 If MobTelSourceCheck = 0 Then ' If 0 then number is from wrong table (or blank)
377 body = body & "<td><font face=arial size=2 color=red>" & MobTel & "</font></td></tr><tr>"
378 Else
379 body = body & "<td><font face=arial size=2>" & MobTel & "</font></td></tr><tr>"
380 End If
381
382
383' Email
384 If Len(Email) > 0 Then
385 body = body & "<td><font face=arial size=2><b>Email Address</b></font></td>"
386 '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>"
387 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>"
388
389 Else
390 body = body & "<td><font face=arial size=2 color=red><b>Email Address</b></font></td>"
391 '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>"
392 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>"
393 End If
394
395 'body = body & "<td><font face=arial size=2>" & Email & "</font></td></tr><tr>"
396
397' Gender
398 If Len(Gender) > 0 Then
399 body = body & "<td><font face=arial size=2><b>Gender</b></font></td>"
400 Else
401 body = body & "<td><font face=arial size=2 color=red><b>Gender</b></font></td>"
402 End If
403
404 body = body & "<td><font face=arial size=2>" & Gender & "</font></td></tr><tr>"
405
406' Ethnicity
407 If Len(Ethnicity) > 0 Then
408 body = body & "<td><font face=arial size=2><b>Ethnicity</b></font></td>"
409 Else
410 body = body & "<td><font face=arial size=2 color=red><b>Ethnicity</b></font</td>"
411 End If
412
413 body = body & "<td><font face=arial size=2>" & Ethnicity & "</font></td></tr><tr>"
414
415' Marital Status
416 If Len(MaritalStatus) > 0 Then
417 body = body & "<td><font face=arial size=2><b>Marital Status</b></font></td>"
418 Else
419 body = body & "<td><font face=arial size=2 color=red><b>Marital Status</td></font></td>"
420 End If
421
422 body = body & "<td><font face=arial size=2>" & MaritalStatus & "</font></td></tr><tr>"
423
424' Employment Status
425 If Len(EmploymentStatus) > 0 Then
426 body = body & "<td><font face=arial size=2><b>Employment Status</b></font></td>"
427 Else
428 body = body & "<td><font face=arial size=2 color=red><b>Employment Status</b></font></td>"
429 End If
430
431 body = body & "<td><font face=arial size=2>" & EmploymentStatus & "</font></td></tr><tr>"
432' Religion
433 If Len(Religion) > 0 Then
434 body = body & "<td><font face=arial size=2><b>Religion</b></font></td>"
435 Else
436 body = body & "<td><font face=arial size=2 color=red><b>Religion</b></font></tr>"
437 End If
438
439 body = body & "<td><font face=arial size=2>" & Religion & "</font></td></tr><tr>"
440
441' Orientation
442 If Len(SexualOrientation) > 0 Then
443 body = body & "<td><font face=arial size=2><b>Sexual Orientation</b></font></td>"
444 Else
445 body = body & "<td><font face=arial size=2 color=red><b>Sexual Orientation</b></font></td>"
446 End If
447
448 body = body & "<td><font face=arial size=2>" & SexualOrientation & "</font></td>"
449
450 body = body & "</tr></table>"
451 body = body & "</td>"
452' End Security Check & Contact Details Section
453
454 body = body & "<td> </td>"
455 body = body & "<td> </td>"
456 body = body & "</td><td valign=top>"
457
458
459' Icons Section Titles
460 body = body & "<table cols=13 width=600px>"
461 body = body & "<td class=" & q & "risk" & q & " colspan=1 align=center>Risks</td>"
462 body = body & "<td width=50> </td>"
463' body = body & "<td class=" & q & "links" & q & " colspan=2 align=center>Quick Links</td>"
464' If Len(NonRisk) > 0 Then
465 body = body & "<td class=" & q & "links" & q & " colspan=1 align=center>Vulnerabilities</td>"
466 body = body & "<td width=50> </td>"
467' End If
468 body = body & "<td class=" & q & "pi" & q & " colspan=5 align=center>Personal Indicators</td>"
469' body = body & "<td width=50> </td>"
470' body = body & "<td class=" & q & "SWSelect" & q & " colspan=1 align=center>Select</td>"
471 body = body & "</tr><tr>"
472
473' Risk
474 If Len(Risk) > 0 Then
475 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>"
476 Else
477 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>"
478 End If
479
480 body = body & "<td width=50> </td>"
481
482' Vulnerabilities (Non-risk)
483If Len(NonRisk) > 0 Then
484 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>"
485 Else
486 body = body & "<td><img Title=" & q & "No vulnerabilities" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_vulnerabilities.png" & q & "></td>"
487 End If
488
489 body = body & "<td width=50> </td>"
490
491'' Quick Links
492'' Account Details
493' If Len(AccountEndDate) > 0 and Len(TenancyReference) > 0 Then
494' img = "\\srv-fls-01\data\Snapshot\CRM Images\account_details_term.gif"
495' Else
496' If Len(TenancyReference) > 0 and Len(AccountEndDate) = 0 Then
497' img = "\\srv-fls-01\data\Snapshot\CRM Images\account_details.gif"
498' Else
499' img = "\\srv-fls-01\data\Snapshot\CRM Images\no_account_details.gif"
500' End If
501' End If
502'
503' If Len (AccountEndDate) > 0 and Len(TenancyReference) > 0 Then
504' text = "Account End Date " & AccountEndDate
505' Else
506' If Len(TenancyReference) > 0 and Len(AccountEndDate) = 0 Then
507' text = "Drill into the Rent Account"
508' Else
509' text = "No tenancy reference available"
510' End If
511' End If
512'
513' If Len(TenancyReference) > 0 Then
514' body = body & "<td><a href=" & q & "activeh://AccountDetails/" & TenancyReference & q & "><img Title=" & q & text & q & " src=" & q & img & q & " border=0></a></td>"
515' Else
516' body = body & "<td><img Title=" & q & text & q & " src=" & q & img & q & "></td>"
517' End If
518'' Account financial
519' If Len(TenancyReference) > 0 Then
520' img = "\\srv-fls-01\data\Snapshot\CRM Images\account_financial.gif"
521' Else
522' img = "\\srv-fls-01\data\Snapshot\CRM Images\no_account_financial.gif"
523' End If
524'
525' If Len(TenancyReference) > 0 Then
526' 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>"
527' Else
528' body = body & "<td><img Title=" & q & "No tenancy reference available" & q & " src=" & q & img & q & "></td>"
529' End If
530'
531' body = body & "<td width=50> </td>"
532
533' Personal Indicators
534' Hearing
535 If Len(HearingVulnerabilities) > 0 Then
536 img = "\\srv-fls-01\data\Snapshot\CRM Images\hearing_impairment.gif"
537 Else
538 If Len(HearingVulnerabilities) = 0 and Len(NotDisabled) = 0 Then
539 img = "\\srv-fls-01\data\Snapshot\CRM Images\notconfirmed_hearing_impairment.gif"
540 Else
541 img = "\\srv-fls-01\data\Snapshot\CRM Images\no_hearing_impairment.gif"
542 End If
543 End If
544
545 body = body & "<td><img Title=" & q & HearingVulnerabilities & q & " src=" & q & img & q & "></td>"
546
547' Disabled
548 If Len(DisabledVulnerabilities) > 0 Then
549 img = "\\srv-fls-01\data\Snapshot\CRM Images\disabled.gif"
550 Else
551 If Len(DisabledVulnerabilities) = 0 and Len(NotDisabled) = 0 Then
552 img = "\\srv-fls-01\data\Snapshot\CRM Images\notconfirmed_disabled.gif"
553 Else
554 img = "\\srv-fls-01\data\Snapshot\CRM Images\not_disabled.gif"
555 End If
556 End If
557
558 body = body & "<td><img Title=" & q & DisabledVulnerabilities & q & " src=" & q & img & q & "></td>"
559
560' Visual
561 If Len(VisualVulnerabilities) > 0 Then
562 img = "\\srv-fls-01\data\Snapshot\CRM Images\visual_impairment.gif"
563 Else
564 If Len(VisualVulnerabilities) = 0 and Len(NotDisabled) = 0 Then
565 img = "\\srv-fls-01\data\Snapshot\CRM Images\notconfirmed_visual_impairment.gif"
566 Else
567 img = "\\srv-fls-01\data\Snapshot\CRM Images\no_visual_impairment.gif"
568 End If
569 End If
570
571 body = body & "<td><img Title=" & q & VisualVulnerabilities & q & " src=" & q & img & q & "></td>"
572
573' Stick
574 If Len(StickVulnerabilities) > 0 Then
575 img = "\\srv-fls-01\data\Snapshot\CRM Images\stick_user.gif"
576 Else
577 If Len(StickVulnerabilities) = 0 and Len(NotDisabled) = 0 Then
578 img = "\\srv-fls-01\data\Snapshot\CRM Images\notconfirmed_stick_user.gif"
579 Else
580 img = "\\srv-fls-01\data\Snapshot\CRM Images\not_stick_user.gif"
581 End If
582 End If
583
584 body = body & "<td><img Title=" & q & StickVulnerabilities & q & " src=" & q & img & q & "></td>"
585
586' Bedroom Tax
587 If Len(BedroomTax) > 0 and InStr(BedroomTax, "under") > 0 Then
588 img = "\\srv-fls-01\data\Snapshot\CRM Images\bedroom_tax.gif"
589 Else
590 img = "\\srv-fls-01\data\Snapshot\CRM Images\no_bedroom_tax.gif"
591 End If
592
593 body = body & "<td><img Title=" & q & BedroomTax & q & " src=" & q & img & q & "></td>"
594 body = body & "<td width=50> </td>"
595
596'' Select
597' If SWSelectStage = "Select" Then
598' img = "\\srv-fls-01\data\Snapshot\CRM Images\SW_Select_gold.png" '
599' Else
600' if SWSelectStage = "Standard" Then
601' img = "\\srv-fls-01\data\Snapshot\CRM Images\SW_Select_std.png"
602' Else
603' img = "\\srv-fls-01\data\Snapshot\CRM Images\no_SW_Select.png"
604' End If
605' End If
606
607' body = body & "<td><a href=" & q & "activeh://GroupCharacteristics/" & GroupID & q & "><img Title=" & q & "Tier: " & SWSelectStage & q & " src=" & q & img & q & "></td>"
608' body = body & "<td width=50> </td>"'
609' body = body & "</tr>"
610
611 'html = html & body
612
613' Rent Notifications and Open Activity - Titles
614 body = body & "<tr>"
615 body = body & "<td class=" & q & "rents" & q & " colspan=1 align=center>Rents</td>"
616 body = body & "<td width=50> </td>"
617' body = body & "<td class=" & q & "activity" & q & " colspan=5 align=center>Open Activity</td>"
618 If TaskCount > 0 Then
619 body = body & "<td class=" & q & "activity" & q & " colspan=1 align=center>Tasks</td>"
620 body = body & "<td> </td>"
621 End If
622 body = body & "<td width=50> </td>"
623 body = body & "<td width=50> </td>"
624 body = body & "<td> </td>"
625 body = body & "</tr><tr>"
626
627' Rents Notifications
628' Arrears
629 If Cdbl(ExpectedBalance) > 0 Then
630 img = "\\srv-fls-01\data\Snapshot\CRM Images\arrears.gif"
631 Else
632 img = "\\srv-fls-01\data\Snapshot\CRM Images\no_arrears.gif"
633 End If
634
635 If Cdbl(ExpectedBalance) > 0 Then
636 body = body & "<td><img Title=" & q & "Account is currently £" & ExpectedBalance & " in arrears" & q & " src=" & q & img & q & "></td>"
637 Else
638 body = body & "<td><img Title=" & q & "Account is not in arrears" & q & " src=" & q & img & q & "></td>"
639 End If
640
641'' Agreement
642' If Len(Agreement) > 0 Then
643' body = body & "<td><img Title=" & q & Agreement & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\agreement.gif" & q & "></td>"
644' Else
645' body = body & "<td><img Title=" & q & "No Agreements" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\no_agreement.gif" & q & "></td>"
646' End If
647'
648'' Action Level
649' If Len(CurrentActionLevel) > 0 Then
650' body = body & "<td><img Title=" & q & CurrentActionLevel & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\notice.gif" & q & "></td>"
651' Else
652' body = body & "<td> </td>"
653' End If
654'
655'' Court Action
656' If Len(ActionStatus) > 0 Then
657' body = body & "<td><img Title=" & q & ActionStatus & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\court_action.gif" & q & "></td>"
658' Else
659' 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>"
660' End If
661'
662'' Universal Credit
663' If UC = "1" Then
664' 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>"
665' Else
666' 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>"
667' End If
668
669 body = body & "<td> </td>"
670
671' Open Activity
672' Calls
673' If OpenCalls > 0 Then
674' 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>"
675' Else
676' 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>"
677' End If
678'
679'' Repairs
680' If NumberOutstandingRepairs > 0 Then
681' 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>"
682' Else
683' 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>"
684' End If
685'
686'' ASB
687' If OpenASB > 0 Then
688' 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>"
689' Else
690' 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>"
691' End If
692'
693'' Complaint
694' If OpenComplaint > 0 Then
695' 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>"
696' Else
697' 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>"
698' End If
699'
700' RTB
701' If OpenRTB > 0 Then
702' 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>"
703' Else
704' 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>"
705' End If
706' Plan
707' If OpenPlans > 0 Then
708' 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>"
709' Else
710' 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>"
711' End If
712
713
714' Tasks
715 If TaskCount > 0 Then
716 body = body & "<td><img Title=" & q & "Open Tasks: " & TaskCount & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\Task.png" & q & "></td>"
717 End If
718
719
720 body = body & "<td width=50> </td>"
721 body = body & "<td width=50> </td>"
722 body = body & "<td> </td>"
723 body = body & "</tr>"
724 'html = html & body
725
726' Property Information - Payments - Other - Titles
727 body = body & "<tr>"
728' body = body & "<td class=" & q & "property" & q & " colspan=4 align=center>Property Information</td>"
729' body = body & "<td> </td>"
730 body = body & "<td class=" & q & "Payments" & q & " colspan=2 align=center>Payments</td>"
731 body = body & "<td> </td>"
732 body = body & "<td class=" & q & "other" & q & " colspan=1 align=center>Other</td>"
733 body = body & "<td width=50> </td>"
734' body = body & "<td> </td>"
735 body = body & "</tr>"
736 body = body & "<tr>"
737
738'' Proprerty Information
739'' Asbestos
740' If Len(Asbestos) > 0 Then
741' body = body & "<td><img Title=" & q & "Asbestos present at property" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\asbestos.gif" & q & "></td>"
742' Else
743' 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>"
744' End If
745'
746'' Gas
747' If Len(GasServicing) > 0 Then
748' body = body & "<td><img Title=" & q & GasServicing & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\gas_servicing.gif" & q & "></td>"
749' Else
750' 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>"
751' End If
752'
753'' Map
754' If Len(Longitude) > 0 And Len(Latitude) > 0 Then
755' 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>"
756' Else
757' 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>"
758' End If
759'
760'' Warranty
761' If Len(Warranty) > 0 Then
762' body = body & "<td><img Title=" & q & "Warranty Information: " & Warranty & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\warranty.png" & q & "></td>"
763' Else
764' body = body & "<td><img Title=" & q & "No Warranty Information" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\not_warranty.png" & q & "></td>"
765' End If
766'
767' body = body & "<td colspan=1> </td>"
768
769' Payments
770' Allpay
771 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
772 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>"
773 body = body & "<td width=50> </td>"
774 Else
775 body = body & "<td colspan=2> </td>"
776 End If
777
778 '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>"
779 '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>"
780 body = body & "<td colspan=1> </td>"
781
782
783'' Other
784'' Applications
785' body = body & "<td><img Title=" & q & Applications & " applications are active" & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\lettings.gif" & q & "></td>"
786'
787'' Last Login
788 If Len(TIPSLastLoginDate) > 0 Then
789 body = body & "<td><img Title=" & q & "Last Login: " & TIPSLastLoginDate & q & " src=" & q & "\\srv-fls-01\data\Snapshot\CRM Images\Web.png" & q & "></td>"
790 Else
791 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>"
792 End If
793
794'' Experian
795' If Experian > 0 Then
796' 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>"
797' Else
798' 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>"
799' End If
800'
801' body = body & "<td width=50> </td>"
802' body = body & "<td width=50> </td>"
803' body = body & "<td> </td>"
804' body = body & "</tr>"
805' body = body & "<tr>"
806'
807'' CC Indicators
808' body = body & "<td class=" & q & "pi" & q & " colspan=5 align=center>CC Indicators</td></tr>"
809' body = body & "<tr>"
810'
811'' Contact Characteristic - Physical Disability
812' If CCPD = 1 Then
813' 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>"
814' Else
815' 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>"
816' End If
817'
818'' Contact Characteristic - Sensory Disability
819' If CCSD =1 Then
820' 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>"
821' Else
822' 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>"
823' End if
824'
825'' Contact Characteristic - Learning Difficulty
826' If CCLD = 1 Then
827' 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>"
828' Else
829' 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>"
830' End If
831'
832'' Contact Characteristic - Mental Illness
833' If CCMI = 1 Then
834' 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>"
835' Else
836' 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>"
837' End If
838'
839'' Contact Characteristic - Medical Conditions
840' If CCMC = 1 Then
841' 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>"
842' Else
843' 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>"
844' End If
845'
846' body = body & "</tr>"
847
848 html = html & body
849 html = html & "</table>"
850 html = html & "</tr>"
851 html = html & "</tr><tr>"
852 html = html & "<td> </td>" ' inserts balnk cell
853 html = html & "<td> </td>" ' inserts blank cell
854' html = html & "<table>" ' inserts new table
855' html = html & "<tr>" ' inserts new row
856' html = html & "<div id=" & q & "chart_div" & q & " style=" & q & "width: 400px; height=300px;" & q & "></div>" ' Graph
857' html = html & "</tr>"
858' html = html & "</table>"
859 html = html & "</td></tr></table>"
860 html = html & "</body></html>"
861 BuildCRMSnapshot = html
862
863End Function
864
865
866'*** End *** CRM Snapshot ***
867
868
869
870Function UpdateVoidCaseAsbestosCheckAuditT(varCaseID,varTaskID)
871
872 varSelect = "insert into usr_SW_Void_Management_Case_Asbestos_Check_Audit_T(Case_ID,Task_ID) values (" & varCaseID & "," & varTaskID & ")"
873
874 With SQLConnection.Execute(varSelect)
875 End With
876End Function
877
878
879Function UpdateVoidCaseFolderCreationAuditT(varCaseID)
880
881 varSelect = "insert into usr_SW_Void_Management_Case_Folder_Creation_Audit_T(Case_ID) values (" & varCaseID & ")"
882
883 With SQLConnection.Execute(varSelect)
884 End With
885End Function
886
887Function InsertVoidCompletionDateAuditT (CaseID,CompletionDate)
888
889 varSelect = "insert into usr_SW_Void_Management_Completion_Date_Audit_T(Case_ID) values (" & CaseID & ")"
890
891 With SQLConnection.Execute(varSelect)
892 End With
893End Function
894
895Function UpdateVoidCompletionDateAuditT (CaseID,CompletionDate)
896
897 varUpdate = "update usr_SW_Void_Management_Completion_Date_Audit_T set Completion_Date = '" & CompletionDate & "' where Case_ID = '" & CaseID & "'"
898
899 with SQLConnection.Execute(varUpdate)
900 End with
901End Function
902
903Function UpdateVoidCaseCreationNotificationsAuditT(varCaseID,varTaskID,varRecipientVC)
904
905 varSelect = "insert into usr_SW_Void_Management_Case_Notifications_Audit_T(Case_ID,Task_ID,Task_Recipient_VC) values (" & varCaseID & "," & varTaskID & ",'" & varRecipientVC & "')"
906
907 with SQLConnection.Execute(varSelect)
908 End with
909End Function
910
911Function UpdateLastIssuedDate(varWorksOrderID)
912
913 varUpdate = "update Repairs_Works_Orders_T set LastIssued_DT = getdate() where WorksOrder_ID = " & varWorksOrderID & ""
914
915 with SQLConnection.Execute(varUpdate)
916 end with
917
918End Function
919
920Function UpdateLettingsFolderCreationAuditT(varApplicationID)
921
922 varSelect = "insert into usr_SW_Lettings_Case_Folder_Creation_Audit_T (Application_ID) values (" & varApplicationID & ")"
923
924 with SQLConnection.Execute(varSelect)
925 end With
926
927End Function
928
929Function UpdateVoidCaseStepCompletionTaskingAuditT(varCaseID,varMatrixID)
930
931 varSelect = "insert into usr_SW_Void_Management_Process_Step_Task_Completion_Audit_T (Case_ID,Matrix_ID) values (" & varCaseID & "," & varMatrixID & ")"
932
933 with SQLConnection.Execute(varSelect)
934 End with
935
936End Function
937
938Function UpdateVoidCaseProvisionalOfferAuditT(varCaseID,varTaskID)
939
940 varSelect = "insert into usr_SW_Void_Management_Provisional_Offer_Audit_T(Case_ID,Task_ID) values (" & varCaseID & "," & varTaskID & ")"
941
942 With SQLConnection.Execute(varSelect)
943 End With
944End Function
945
946Function UpdateVoidCaseKeySafeAuditT(varCaseID,varTaskID)
947 varSelect = "insert into usr_SW_Void_Management_Case_Keysafe_Audit_T(case_ID,Task_ID) values (" & varCaseID & "," & varTaskID & ")"
948
949 With SQLConnection.Execute(varSelect)
950 End With
951End Function
952
953
954Function UpdateOptOutTracker (AccountRef)
955Dim strSQL
956
957 strSQL = ("Insert into SW_USR_Experian_OptOut_T Values (" & AccountRef & ")")
958 with sqlconnection.execute(strSQL)
959 end with
960End Function
961
962Function WorksOrderAudit(varOrderID,varLastIssuedDate,varOrderStatus,varComments,varDateTime)
963
964varInsert = "INSERT INTO dbo.RAGLAN_USR_Works_Orders_Audit_T (OrderID,LastIssuedDate,OrderStatus,Comments,DateTime) VALUES (" & varOrderID & ",'" & varLastIssuedDate & "'," & varOrderStatus & ",'" & varComments & "','" & varDateTime & "')"
965
966With SQLConnection.Execute(varInsert)
967End With
968
969End Function
970
971Function UpdateBulkSMSTable(Mobile,varSent)
972
973 varUpdate = "UPDATE SW_Bulk_SMS_Loader_T SET Sent = '" & varSent & "' WHERE Mobile = '" & Mobile & "'"
974
975 With SQLConnection.Execute(varUpdate)
976 End With
977
978End Function
979
980Function UpdateAgreementPayment(varAccountID,varSequenceNumber,varVariance,varPaymentID)
981 varUpdate = "update Rent_Payments Set AgreementReferenceUpdated = '" & varSequenceNumber & "', AmountOfPayment = '" & varVariance & "' where Account_TG_VC = '" & varAccountID & "' and ID = '" & varPaymentID & "'"
982 With SQLConnection.Execute(varUpdate)
983 End With
984End Function
985
986'--------Prompted Arrears Functions START---------
987Function UpdatePromptedArrearsControl(varID,varCurrentRunDate,varUserID)
988
989 varCurrentRunDate = ReturnDateDDMMMYYYY(varCurrentRunDate)
990 varUpdate = "UPDATE RAGLAN_USR_Prompted_Rent_Arrears_Control_T SET LastRunDate = '" & varCurrentRunDate & "', UserID = '" & varUserID & "', AccountLastProcessed = 'COMPLETED' WHERE ID = '" & varID & "'"
991 With SQLConnection.Execute(varUpdate)
992 End With
993
994End Function
995
996Function UpdatePromptedArrearsControlTMP(varID,varCurrentRunDate,varUserID)
997
998 varCurrentRunDate = ReturnDateDDMMMYYYY(varCurrentRunDate)
999 varUpdate = "UPDATE RAGLAN_USR_Prompted_Rent_Arrears_Control_TMP_T SET LastRunDate = '" & varCurrentRunDate & "', UserID = '" & varUserID & "', AccountLastProcessed = 'COMPLETED' WHERE ID = '" & varID & "'"
1000 With SQLConnection.Execute(varUpdate)
1001 End With
1002
1003End Function
1004
1005
1006Function UpdateArrearsProgressControl(varAccountID,varID)
1007
1008 varUpdate = "UPDATE RAGLAN_USR_Prompted_Rent_Arrears_Control_T SET AccountLastProcessed = '" & varAccountID & "' WHERE ID = " & varID
1009 WITH SQLConnection.Execute(varUpdate)
1010 END WITH
1011
1012End Function
1013
1014Function UpdateArrearsProgressControlTMP(varAccountID,varID)
1015
1016 varUpdate = "UPDATE RAGLAN_USR_Prompted_Rent_Arrears_Control_TMP_T SET AccountLastProcessed = '" & varAccountID & "' WHERE ID = " & varID
1017 WITH SQLConnection.Execute(varUpdate)
1018 END WITH
1019
1020End Function
1021
1022Function UpdateOccDel_T(OccID)
1023
1024 varUpdate = "Update dbo.RHA_USR_Occurrence_Deletions_T SET IsDeleted_BT = '1' where OccID = " & OccID
1025 WITH SQLConnection.Execute(varUpdate)
1026 END WITH
1027
1028End Function
1029
1030Function UpdateOccDelErr(OccID,ErrorLog)
1031
1032varUpdate = "Update dbo.RHA_USR_Occurrence_Deletions_T SET Error = ('"& ErrorLog &"') where OccID = " & OccID
1033 WITH SQLConnection.Execute(varUpdate)
1034 END WITH
1035
1036End Function
1037
1038Function UpdateRRTrackerT(Task,Order,Recharge,Cost,DateTime)
1039 Dim strSQL
1040
1041 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 & "')")
1042 with sqlconnection.execute(strSQL)
1043 end with
1044End Function
1045
1046Function AgreementBalance(varAccountID,varAgreementID)
1047
1048 varSelect = "SELECT ISNULL(dbo.fn_GetRentAgreementBalance(dbo.fn_CurrentYearMonth(),'" & varAccountID & "','','S'," & varAgreementID & "),0) AS Balance"
1049
1050 With SQLConnection.Execute(varSelect)
1051 Do Until .EOF
1052 varBalance = .Fields("Balance").Value
1053 .MoveNext
1054 Loop
1055 End With
1056
1057 AgreementBalance = varBalance
1058
1059End Function
1060
1061Function AgreementValue(varAgreementID)
1062
1063 varSelect = "SELECT ISNULL(AGREE.AgreementValue,0) AS AgreementValue FROM Rent_Agreements AGREE (NOLOCK) WHERE AGREE.ID = '" & varAgreementID & "'"
1064
1065 With SQLConnection.Execute(varSelect)
1066 Do Until .EOF
1067 varValue = .Fields("AgreementValue").Value
1068 .MoveNext
1069 Loop
1070 End With
1071
1072 AgreementValue = varValue
1073
1074End Function
1075
1076Function ClearXMLTracker
1077 Dim strSQL
1078
1079 strSQL = ("Delete from RHA_WF_IWXMLTracker_T")
1080 with sqlconnection.execute(strSQL)
1081 end with
1082End Function
1083
1084Function UpdateXMLTracker(FilePath)
1085 Dim strSQL
1086
1087 strSQL = ("Insert into RHA_WF_IWXMLTracker_T (XMLFilePath) Values ('" & FilePath & "')")
1088 with sqlconnection.execute(strSQL)
1089 end with
1090End Function
1091
1092Function WriteToAgreementsProcessAuditTable(varUser)
1093 varInsert = "insert into usr_STO_Agreements_Update_Audit_T (Processed_By_Username_VC,Processed_DT) values ('" & varUser & "',getdate())"
1094
1095 with SQLConnection.Execute(varInsert)
1096 end with
1097
1098End Function
1099
1100Function UpdateAsbestosError(ErrDesc, Counter)
1101 varInsert = "UPDATE WF_USR_AsbestosImport_T SET Error = '" & ErrDesc & "' where Count = '" & Counter & "'"
1102 With SQLConnection.Execute(varInsert)
1103 End With
1104End Function
1105
1106Function UpdateAsbestosImport(OccID, Counter)
1107 varInsert = "UPDATE WF_USR_AsbestosImport_T SET OccID = " & OccID & "where Count = '" & Counter & "'"
1108 With SQLConnection.Execute(varInsert)
1109 End With
1110End Function
1111
1112Function UpdateAsbestosTracker(AssetID, OccID)
1113 Dim strSQL
1114
1115 strSQL = ("Insert into WF_USR_AsbestosTracker_T (AssetID, OccID) Values (" & AssetID & "," & OccID & ")")
1116 with sqlconnection.execute(strSQL)
1117 end with
1118End Function
1119
1120
1121Function WorksOrderTracker(WO,Contr,WFName)
1122 varSelect = "INSERT INTO WF_USR_WorksOrderTracker_T (WorksOrder,Contractor,[Workflow Name]) VALUES ('" & WO & "','" & Contr & "','" & WFName &"')"
1123 With SQLConnection.Execute(varSelect)
1124 End With
1125End Function
1126
1127
1128Function BuildBenefitPaymentsReceivedInLastXXDaysV2(varDays)
1129' Same as old version but should be much quicker as SQL will do the inserting during the select
1130 varFromDate = DateAdd("d",(varDays*-1),Date)
1131 varFromDate = ReturnDateDDMMMYYYY(varFromDate)
1132
1133 varToDate = Date
1134 varToDate = ReturnDateDDMMMYYYY(varToDate)
1135
1136 varSelect = "DELETE FROM RAGLAN_USR_Benefit_Payments_Last_Received_T"
1137
1138 SQLConnection.Execute varSelect
1139 varselect = "INSERT INTO RAGLAN_USR_Benefit_Payments_Last_Received_T (ID,BenefitAmount) "
1140 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"
1141
1142 SQLConnection.Execute varSelect
1143
1144End Function
1145
1146Function FilesInDirectory(varDirectory)
1147
1148 Dim fs, fo, x, varFileListing, varSep
1149
1150 Set fs = CreateObject("Scripting.FileSystemObject")
1151 Set fo = fs.GetFolder(varDirectory)
1152
1153 varFileListing = ""
1154 varSep = ""
1155
1156 For Each x In fo.files
1157 varFileListing = x.Name & varSep & varFileListing
1158 varSep = ","
1159 Next
1160
1161 Set fo = Nothing
1162 Set fs = Nothing
1163
1164 FilesInDirectory = varFileListing
1165
1166End Function
1167
1168Function GetExpectedBalance(varAccountID,varDate)
1169
1170 varDate = ReturnDateDDMMMYYYY(varDate)
1171 varSelect = "SELECT dbo.fn_GetRentExpectedBalanceForDate('" & varDate & "','" & varAccountID & "','S') AS Balance"
1172
1173 With SQLConnection.Execute(varSelect)
1174 Do Until .EOF
1175 GetExpectedBalance = .Fields("Balance").Value
1176 .MoveNext
1177 Loop
1178 End With
1179
1180End Function
1181
1182Function GetAccountBalance(varAccountID,varDate)
1183
1184 varDate = ReturnDateDDMMMYYYY(varDate)
1185 varSelect = "SELECT dbo.fn_GetRentBalanceAccountOrSubAccountForDate('" & varDate & "','" & varAccountID & "','S') AS Balance"
1186
1187 With SQLConnection.Execute(varSelect)
1188 Do Until .EOF
1189 GetAccountBalance = .Fields("Balance").Value
1190 .MoveNext
1191 Loop
1192 End With
1193
1194End Function
1195
1196Function ReturnDateDDMMMYYYY(varDateToConvert)
1197
1198 DIM varRetval
1199 DIM varMonthDesc
1200 DIM varMonthNumber
1201
1202 IF Len(varDateToConvert) > 0 Then
1203
1204 varMonthNumber=Month(varDateToConvert)
1205
1206 If varMonthNumber="1" Then
1207 varMonthDesc="Jan"
1208 Else
1209 If varMonthNumber="2" Then
1210 varMonthDesc="Feb"
1211 Else
1212 If varMonthNumber="3" Then
1213 varMonthDesc="Mar"
1214 Else
1215 If varMonthNumber="4" Then
1216 varMonthDesc="Apr"
1217 Else
1218 If varMonthNumber="5" Then
1219 varMonthDesc="May"
1220 Else
1221 If varMonthNumber="6" Then
1222 varMonthDesc="Jun"
1223 Else
1224 If varMonthNumber="7" Then
1225 varMonthDesc="Jul"
1226 Else
1227 If varMonthNumber="8" Then
1228 varMonthDesc="Aug"
1229 Else
1230 If varMonthNumber="9" Then
1231 varMonthDesc="Sep"
1232 Else
1233 If varMonthNumber="10" Then
1234 varMonthDesc="Oct"
1235 Else
1236 If varMonthNumber="11" Then
1237 varMonthDesc="Nov"
1238 Else
1239 If varMonthNumber="12" Then
1240 varMonthDesc="Dec"
1241 End If
1242 End If
1243 End If
1244 End If
1245 End If
1246 End If
1247 End If
1248 End If
1249 End If
1250 End If
1251 End If
1252 End If
1253
1254 varRetval = CStr(Day(varDateToConvert)) + " " + varMonthDesc + " " + CStr(Year(varDateToConvert))
1255
1256 Else
1257 varRetval = ""
1258 End If
1259
1260 ReturnDateDDMMMYYYY = varRetval
1261
1262End Function
1263
1264Function ClearPromptedRentArrearsTable
1265
1266 varSelect = "DELETE FROM RAGLAN_USR_Prompted_Arrears_Actions_T"
1267
1268 With SQLConnection.Execute(varSelect)
1269 End With
1270
1271End Function
1272
1273Function ClearPromptedRentArrearsTableTMP
1274
1275 varSelect = "DELETE FROM RAGLAN_USR_Prompted_Arrears_Actions_TMP_T"
1276
1277 With SQLConnection.Execute(varSelect)
1278 End With
1279
1280End Function
1281
1282Function DirectDebitMOPs(varAccountID)
1283
1284 varMOPCount = 0
1285
1286 varSelect = "SELECT Count(*) AS MOPCount FROM Rent_AccountMOPs (NOLOCK) WHERE ID LIKE ('" & varAccountID & "**%') AND MOP IN ('10')"
1287
1288 With SQLConnection.Execute(varSelect)
1289 Do Until .EOF
1290 varMOPCount = .Fields("MOPCount").Value
1291 .MoveNext
1292 Loop
1293 End With
1294
1295 DirectDebitMOPs = varMOPCount
1296
1297End Function
1298
1299Function HousingBenefitMOPs(varAccountID)
1300
1301 varMOPCount = 0
1302
1303 varSelect = "SELECT Count(*) AS MOPCount FROM Rent_AccountMOPs (NOLOCK) WHERE ID LIKE ('" & varAccountID & "**%') AND MOP IN ('2')"
1304
1305 With SQLConnection.Execute(varSelect)
1306 Do Until .EOF
1307 varMOPCount = .Fields("MOPCount").Value
1308 .MoveNext
1309 Loop
1310 End With
1311
1312 HousingBenefitMOPs = varMOPCount
1313
1314End Function
1315
1316Function AgreementBeingKept(varAccountID,varAgreementID)
1317
1318 varAgreementRef = varAccountID & "**" & varAgreementID
1319 varAgrID = ""
1320 varVariance = 0
1321 varTodaysDate = ReturnDateDDMMMYYYY(Date)
1322
1323 varSelect = "SELECT ID, StartDate, EndDate FROM Rent_Agreements (NOLOCK) WHERE ID = '" & varAgreementRef & "' AND (StartDate <= '" & varTodaysDate & "' AND (EndDate > '" & varTodaysDate & "' OR EndDate IS NULL))"
1324
1325 With SQLConnection.Execute(varSelect)
1326 Do Until .EOF
1327 varAgrID = .Fields("ID").Value
1328 .MoveNext
1329 Loop
1330 End With
1331
1332 If varAgrID <> "" Then
1333
1334 varSelect = "SELECT dbo.fn_GetRentAgreementVarianceAccountOrSubAccountForDate('" & varTodaysDate & "','" & varAccountID & "','S','" & varAgreementID & "') AS VarianceAmount"
1335
1336 With SQLConnection.Execute(varSelect)
1337 Do Until .EOF
1338 varVariance = .Fields("VarianceAmount").Value
1339 .MoveNext
1340 Loop
1341 End With
1342 End If
1343
1344 AgreementBeingKept = varVariance
1345
1346End Function
1347
1348
1349Function AgreementBeingKeptOLD(varAccountID,varAgreementID)
1350
1351 varAgreementRef = varAccountID & "**" & varAgreementID
1352 varAgrID = ""
1353 varVariance = 0
1354
1355 varSelect = "SELECT ID, StartDate, EndDate FROM Rent_Agreements (NOLOCK) WHERE ID = '" & varAgreementRef & "' AND (StartDate <= " & Date & " AND (EndDate > " & Date & " OR EndDate IS NULL))"
1356
1357 With SQLConnection.Execute(varSelect)
1358 Do Until .EOF
1359 varAgrID = .Fields("ID").Value
1360 .MoveNext
1361 Loop
1362 End With
1363
1364 If varAgrID <> "" Then
1365
1366 varSelect = "SELECT dbo.fn_GetRentAgreementVarianceAccountOrSubAccountForDate('" & Date & "','" & varAccountID & "','S','" & varAgreementID & "') AS VarianceAmount"
1367
1368 With SQLConnection.Execute(varSelect)
1369 Do Until .EOF
1370 varVariance = .Fields("Variance").Value
1371 .MoveNext
1372 Loop
1373 End With
1374 End If
1375
1376 AgreementBeingKept = varVariance
1377
1378End Function
1379
1380Function AgreementInForce(varAccountID,varAgreementID)
1381
1382 varAgreementRef = varAccountID & "**" & varAgreementID
1383 varTodaysDate = Date
1384 varTodaysDate = ReturnDateDDMMMYYYY(varTodaysDate)
1385 varAgrID = ""
1386
1387 varSelect = "SELECT ID FROM Rent_Agreements (NOLOCK) WHERE ID = '" & varAgreementRef & "' AND (StartDate <= '" & varTodaysDate & "' AND (EndDate > '" & varTodaysDate & "' OR EndDate IS NULL))"
1388
1389 With SQLConnection.Execute(varSelect)
1390 Do Until .EOF
1391 varAgrID = .Fields("ID").Value
1392 .MoveNext
1393 Loop
1394 End With
1395
1396 AgreementInForce = varAgrID
1397
1398End Function
1399
1400Function 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)
1401
1402 varDateOfLastRun = ReturnDateDDMMMYYYY(varDateOfLastRun)
1403 varDateCurMonLevelSet = ReturnDateDDMMMYYYY(varDateCurMonLevelSet)
1404
1405 If LEN(varAgreementID) > 0 Then
1406 varAgreementAmount = AgreementValue(varAgreementID)
1407 varAgreementBalance = AgreementBalance(varAccountID,varAgreementNumber)
1408 Else
1409 varAgreementAmount = 0
1410 varAgreementBalance = 0
1411 End If
1412
1413 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 & ")"
1414
1415 With SQLConnection.Execute(varSelect)
1416 End With
1417
1418End Function
1419
1420Function 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)
1421
1422 varDateOfLastRun = ReturnDateDDMMMYYYY(varDateOfLastRun)
1423 varDateCurMonLevelSet = ReturnDateDDMMMYYYY(varDateCurMonLevelSet)
1424
1425 If LEN(varAgreementID) > 0 Then
1426 varAgreementAmount = AgreementValue(varAgreementID)
1427 varAgreementBalance = AgreementBalance(varAccountID,varAgreementNumber)
1428 Else
1429 varAgreementAmount = 0
1430 varAgreementBalance = 0
1431 End If
1432
1433 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 & ")"
1434
1435 With SQLConnection.Execute(varSelect)
1436 End With
1437
1438End Function
1439
1440Function TestWord
1441 dim objWord, objdoc
1442
1443 set objWord = createobject("Word.Application")
1444 objword.visible = true
1445
1446end function
1447
1448'--------Prompted Arrears Functions END-----------
1449
1450'######## SMS Functions #########
1451Function GetUserCodeDescription(CodeID)
1452varSelect = "select left(Description_VC,1) as MatScore from Shared_User_Defined_Codes_T where Code_ID = " & CodeID
1453
1454With SQLConnection.Execute(varSelect)
1455 Do Until .EOF
1456 GetUserCodeDescription = .Fields("MatScore").Value
1457 .MoveNext
1458 Loop
1459End With
1460End Function
1461
1462Function InsertIntousrSchemeAccStatusChangeT (varSchemeID,varServiceID,varOwnerUserID,varTodaysDate)
1463
1464varSelect = "insert into usr_RAG_SchemeAcc_Status_Change_Tasking_T (Scheme_ID,Service_ID,User_ID,Date_Sent_DT) values (" & varSChemeID & "," & varServiceID & "," & varOwnerUserID & ",'" & varTodaysDate & "')"
1465
1466 with SQLConnection.Execute(varSelect)
1467 End With
1468
1469End Function
1470
1471
1472Function SMS_Get_ContactID(TargetNumber)
1473 Dim varExecute
1474 if left(TargetNumber,4) = "0044" then TargetNumber = "0" & Mid(TargetNumber,5,len(TargetNumber))
1475 varExecute = "SELECT top 1 LEFT(MainLKUPID,CHARINDEX('*',MainLKUPID)-1) Contact_ID FROM [CRM_SYS_CTI_References_INF_V] WHERE CTI_Reference = '" & TargetNumber & "'"
1476 SMS_Get_ContactID = GetSQLColumns(varExecute, "")
1477End function
1478
1479Function SMS_Get_ContactGroupID(TargetNumber)
1480 Dim varExecute
1481 if left(TargetNumber,4) = "0044" then TargetNumber = "0" & Mid(TargetNumber,5,len(TargetNumber))
1482 if left(TargetNumber,2) = "44" then TargetNumber = "0" & Mid(TargetNumber,3,len(TargetNumber))
1483
1484 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 & "'"
1485 SMS_Get_ContactGroupID = GetSQLColumns(varExecute, "")
1486End function
1487
1488Function SMS_Get_GroupContactID(TargetNumber)
1489 Dim varExecute
1490 if left(TargetNumber,4) = "0044" then TargetNumber = "0" & Mid(TargetNumber,5,len(TargetNumber))
1491 if left(TargetNumber,2) = "44" then TargetNumber = "0" & Mid(TargetNumber,3,len(TargetNumber))
1492 varExecute = "SELECT top 1 RIGHT(MainLKUPID,CHARINDEX('*',REVERSE(MainLKUPID))-1) GroupContact_ID FROM [CRM_SYS_CTI_References_INF_V] WHERE CTI_Reference = '" & TargetNumber & "'"
1493 SMS_Get_GroupContactID = GetSQLColumns(varExecute, "")
1494End function
1495
1496Function SMS_Get_ContactRentBalance(TargetNumber)
1497 Dim ContactGroupID
1498 Dim varExecute
1499
1500 if left(TargetNumber,4) = "0044" then TargetNumber = "0" & Mid(TargetNumber,5,len(TargetNumber))
1501 if left(TargetNumber,2) = "44" then TargetNumber = "0" & Mid(TargetNumber,3,len(TargetNumber))
1502
1503
1504 ContactGroupID = SMS_Get_ContactGroupID(TargetNumber)
1505'msgbox( ContactGroupID & "," & TargetNumber)
1506if len(ContactGroupID) > 0 then
1507 varExecute = _
1508"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
1509
1510 SMS_Get_ContactRentBalance = GetSQLColumns(varExecute, "")
1511else SMS_Get_ContactRentBalance = "No balance available, txt ? for assistance"
1512End if
1513End Function
1514
1515Function SMS_Get_Mobile_From_Request(Request_ID)
1516 dim varExecute
1517 varExecute = _
1518"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
1519SMS_Get_Mobile_From_Request = GetSQLColumns(varExecute, "")
1520End Function
1521
1522Function SMS_First_Word( First_Word_Caps , Mess)
1523
1524' Swap a few obvious errors...
1525
1526'Swap dot for ?
1527if left(First_Word_Caps,1) = "." then
1528 First_Word_Caps = "?" & Mid(First_Word_Caps, 2, len(First_Word_Caps))
1529end if
1530if First_Word_Caps = "??" then First_Word_Caps = "?"
1531if left(First_Word_Caps,2) = "??" then First_Word_Caps = "?"
1532if First_Word_Caps = "?C" then First_Word_Caps = "?CALL"
1533if First_Word_Caps = "?CALLME" then First_Word_Caps = "?CALL"
1534if First_Word_Caps = "?B" then First_Word_Caps = "?BAL"
1535if First_Word_Caps = "?BALANCE" then First_Word_Caps = "?BAL"
1536SMS_First_Word = Trim(First_Word_Caps)
1537' msgbox( ">" & First_Word_Caps & "<")
1538End Function
1539
1540
1541Function SMS_Inbox_Request( First_Word_Caps , Mess )
1542 dim OutMess
1543 OutMess = ""
1544' Ask where the parameters are..
1545
1546if First_Word_Caps = "ASB" and len(Trim(Mess)) < 5 then OutMess = "Please include details eg- ASB LOUD MUSIC IN MY CLOSE AFTER MIDNIGHT"
1547if First_Word_Caps = "REP" and len(Trim(Mess)) < 5 then OutMess = "Please include details eg- REP BATHROOM TAP NOW LEAKING CONSTANTLY"
1548if 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"
1549if First_Word_Caps = "COMP" and len(Trim(Mess)) < 5 then OutMess = "Please include details eg- COMP CONTRACTOR DID NOT CLEANUP AFTER RECENT REPAIR"
1550if 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"
1551
1552' Screen out invalid stuff...
1553IF InStr("|?|?BAL|?CALL|ASB|REP|SUG|COMP|" , "|" & First_Word_Caps & "|") = 0 then
1554 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!"
1555end if
1556
1557SMS_Inbox_Request = OutMess
1558
1559End Function
1560
1561Function GetSQLColumns(SQLString, Parms)
1562 GetSQLColumns = ""
1563 dim strConnection
1564 strConnection = SQLString
1565 With SQLConnection.Execute(strConnection)
1566 If Parms = "" then
1567 Do Until .EOF
1568 GetSQLColumns = GetSQLColumns & .Fields(0).Value
1569 .MoveNext
1570 Loop
1571 end if
1572 End With
1573End Function
1574
1575Function SMS_Obtain_Basic_Details(TargetNumber)
1576 Dim ContactID
1577 Dim ContactDetails
1578 Dim GroupID
1579 Dim GroupDetails
1580 Dim VarExecute
1581 ContactID = SMS_Get_ContactID(TargetNumber)
1582 If len(ContactID) then
1583 ContactDetails = "Contact " & ContactID & " Details: "
1584
1585VarExecute = _
1586"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
1587
1588ContactDetails = ContactDetails & GetSQLColumns(varExecute, "")
1589
1590 End If
1591 GroupID = SMS_Get_ContactGroupID(TargetNumber)
1592 If len(GroupID) then
1593 If len(ContactDetails) > 0 then ContactDetails = ContactDetails & vbcrlf & vbcrlf
1594 ContactDetails = ContactDetails & "Group " & GroupID & " Details: "
1595
1596VarExecute = _
1597"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
1598
1599ContactDetails = "Known Texter " & TargetNumber & " details:" & chr(13) & chr(10) & chr(13) & chr(10) & ContactDetails & GetSQLColumns(varExecute, "")
1600
1601 End If
1602
1603 SMS_Obtain_Basic_Details = ContactDetails
1604End Function
1605
1606Function SMSContactDetails(TargetNumber)
1607 Dim ContactID
1608 Dim ContactDetails
1609 Dim GroupID
1610 Dim GroupDetails
1611 Dim VarExecute
1612 ContactID = SMS_Get_ContactID(TargetNumber)
1613 If len(ContactID) then
1614 ContactDetails = "Contact " & ContactID & " Details: "
1615
1616VarExecute = _
1617"select (Formatted_Name_VC) from Contact_Contacts_T where Contact_Id = " & ContactID
1618
1619ContactDetails = ContactDetails & GetSQLColumns(varExecute, "")
1620
1621 End If
1622 GroupID = SMS_Get_ContactGroupID(TargetNumber)
1623 If len(GroupID) then
1624 If len(ContactDetails) > 0 then ContactDetails = ContactDetails & vbcrlf & vbcrlf
1625 ContactDetails = ContactDetails & "Group " & GroupID & " Details: "
1626
1627VarExecute = _
1628"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
1629
1630ContactDetails = "Known Texter " & TargetNumber & " details:" & chr(13) & chr(10) & chr(13) & chr(10) & ContactDetails & GetSQLColumns(varExecute, "")
1631
1632 End If
1633
1634 SMSContactDetails = ContactDetails
1635End Function
1636
1637
1638Function SendSMSForHighPriorityOrder(OrderID)
1639 SQLConnection.Execute("Repairs_USR_Create_SMS_For_Order " & cstr(OrderID))
1640End Function
1641
1642Function SendSMS(TargetNumber, MessageBody)
1643 Dim varExecute
1644
1645 SendSMS = False
1646
1647 varExecute = _
1648 "INSERT INTO Shared_SMS_Outbox_T (Status_ID,Recipient_VC,Message_VC,Sent_User_ID) VALUES(0,'" & TargetNumber & "','" & MessageBody & "',1)"
1649 SQLConnection.Execute(varExecute)
1650 SendSMS = True
1651end function
1652
1653function SQLExec(VarExecute)
1654 SQLConnection.Execute(varExecute)
1655end function
1656
1657'################################
1658
1659function updateTracker(info, procID)
1660 dim strsql
1661 strsql = ("Exec usr_upd_WorkflowExecute '" & info & "', " & procID)
1662
1663 with sqlconnection.execute(strsql)
1664 end with
1665End function
1666
1667'---------------------------------------PIR Import Functions-------------------------
1668Function createImageRef(Asset)
1669 dim strsql
1670
1671 strsql = ("Select dbo.fn_USR_createImagePath(" & Asset & ")")
1672 with sqlconnection.execute(strsql)
1673 do until .eof
1674 createImageRef = .fields(0)
1675 .movenext
1676 loop
1677 end with
1678End Function
1679
1680Function assetType(Asset)
1681 dim strsql
1682 strsql =("Select Asset_Type_ID from Asset_Assets_T with (Nolock) where Asset_ID = " & Asset)
1683
1684 with sqlconnection.execute(strsql)
1685 do until .eof
1686 assetType = .fields(0)
1687 .movenext
1688 loop
1689 end with
1690End Function
1691
1692Function getOccurrence(Asset, Attr)
1693 dim strsql
1694 strsql = ("Exec sp_getAttributeOccurrence " & Asset & "," & Attr)
1695
1696 with sqlconnection.execute(strsql)
1697 do until .eof
1698 getOccurrence = .fields(0)
1699 .movenext
1700 loop
1701 End With
1702End Function
1703
1704Function insertElectricalData(File)
1705 Dim strSQL, objApp, objWkbk, intRow, Ass, certDt, certNo, CertType, WO, sqlDEL, Status
1706
1707 sqlDEL = ("Delete from WF_USR_ElectricalImport_T")
1708 with sqlconnection.execute(sqlDEL)
1709 end with
1710
1711 set objApp = createObject("Excel.Application")
1712 set objWkbk = objApp.Workbooks.Open(File)
1713
1714 intRow = 2
1715 do until objApp.cells(intRow, 2) = ""
1716 Ass = objApp.cells(intRow, 1).Value
1717 certDt = objApp.cells(intRow, 2).Value
1718 certNo = objApp.cells(intRow, 3).Value
1719 certType = objApp.cells(intRow, 4).Value
1720 Status = objApp.cells(intRow, 5).value
1721 WO = objApp.cells(intRow, 6).Value
1722
1723 if left(Status, 3) = "Sat" then
1724 Status = 2328
1725 else
1726 Status = 2329
1727 end if
1728
1729 strSQL = "Insert into WF_USR_ElectricalImport_T (AssetRef, CertificateDate, CertificateNumber, CertType, WorksOrder, StatusID) Values "
1730 strSQL = strSQL & "(" & Ass & ", '" & certDt & "','" & certNo & "','" & certType & "'," & WO & ", " & Status & ")"
1731
1732 'msgbox(strSQL)
1733
1734 if Ass <> "" then
1735 with sqlconnection.execute(strSQL)
1736 end with
1737 end if
1738 intRow = intRow + 1
1739 loop
1740 objWkbk.Close
1741 objApp.quit
1742
1743End Function
1744'--------------------------------------------------------------------------------------------------
1745
1746'------------------------------Wessex Import Functions-------------------------------
1747Function updateWessexRequest(Req, Job)
1748 dim strSQL
1749 strSQL = ("Update WF_USR_WessexImport_T set RequestID = " & Req & " where JobRef = '" & Job & "'")
1750
1751 with sqlconnection.execute(strSQL)
1752 end with
1753End Function
1754
1755Function updateWessexAsset(Asset, Job)
1756 dim strSQL
1757 strSQL = ("Update WF_USR_WessexImport_T set AssetID = '" & Asset & "' where jobref = '" & Job & "'")
1758
1759 with sqlconnection.execute(strSQL)
1760 end with
1761
1762End Function
1763
1764Function getAssetID(Addr, Pcode)
1765 Dim strSQL
1766
1767 strSQL = ("Select dbo.getAssetFromAddress('" & Left(Addr, 20) & "','" & Pcode & "')")
1768
1769 with sqlconnection.execute(strSQL)
1770 do until .eof
1771 getAssetID = .fields(0)
1772 .movenext
1773 loop
1774 end with
1775
1776End Function
1777
1778Function wessexDataImport(file)
1779 Dim strSQL, objApp, objWkbk, intRow, Job, LogDate, Pri, trade, Desc, Address, Postcode, sqlDEL
1780 sqlDEL = ("Delete from WF_USR_WessexImport_T")
1781 with sqlconnection.execute (sqlDEL)
1782 end with
1783
1784 set objApp = createObject("Excel.Application")
1785 set objWkbk = objApp.Workbooks.Open(file)
1786
1787 intRow = 2
1788
1789 do until objApp.cells(intRow, 2) = ""
1790 Job = objApp.cells(intRow, 1).value & "/" & objApp.cells(intRow, 2).Value
1791 LogDate = objApp.cells(intRow, 4).value & " " & Left(objApp.cells(intRow, 5).Value, 2) & ":" & Right(objApp.cells(intRow, 5), 2)
1792 Pri = objApp.cells(intRow, 8).value
1793 trade = objApp.cells(intRow, 18).value
1794 Desc = objApp.cells(intRow, 10).value & " " & objApp.cells(intRow, 11).value & " " & objApp.cells(intRow, 12).value & " " & objApp.cells(intRow, 13).value
1795 Address = Replace(objApp.cells(intRow, 16).Value, "#", "$")
1796 Postcode = objApp.cells(intRow, 17).value
1797 trade = objApp.cells(intRow, 18).value
1798
1799 strsql = ("insert into WF_USR_WessexImport_T (JobRef, LogDateTime, Priority, Trade, Description, Address, Postcode) Values ('" & Job & "','" & LogDate & "','" & Pri & "','" & Trade & "','" & Replace(Desc, "'", "@") & "','" & Replace(Address, "'", "@") & "','" & Postcode & "')")
1800
1801 with sqlconnection.execute(strsql)
1802 end with
1803
1804 intRow = intRow +1
1805 loop
1806
1807 objWkbk.close
1808 objApp.quit
1809
1810End Function
1811
1812Function updateWessexNullRequest(Job)
1813 dim strSQL
1814
1815 strSQL = ("Update WF_USR_WessexImport_T set RequestID = 0 where JobRef = '" & Job & "'")
1816
1817 with SqlConnection.Execute(strSQL)
1818 end with
1819end Function
1820
1821'---------------------------------------------------------------------------------------
1822
1823
1824Function TestWord
1825 dim objWord, objdoc
1826
1827 set objWord = createobject("Word.Application")
1828 objword.visible = true
1829
1830end function
1831
1832
1833Function sendAuthNotification(WorksOrder)
1834 Dim strSQL
1835
1836 strSQL = ("Exec RHA_USR_sendAuthoristionEmail " & WorksOrder)
1837 with sqlconnection.execute(strSQL)
1838 end with
1839End Function
1840
1841Function updateElecTable(AssetID, Message)
1842 Dim strSQL
1843
1844 strSQL = ("Update WF_USR_ElecCertImport_T set Update_VC = '" & Message & "' where Asset_ID = " & AssetID )
1845
1846 With sqlConnection.execute(strSQL)
1847 End With
1848End Function
1849
1850Function updateGasTable(AssetID, Message)
1851 Dim strSQL
1852
1853 strSQL = ("Update WF_USR_GasCertImport_T set Update_VC = '" & Message & "' where Asset_ID = " & AssetID )
1854
1855 With sqlConnection.execute(strSQL)
1856 End With
1857End Function
1858
1859function importAsbestosData(file)
1860 Dim objExcel, objwkbk, intRow, AssetID, OccID, strSQL
1861
1862 set objExcel = CreateObject("Excel.Application")
1863 set objwkbk = objExcel.Workbooks.Open(file)
1864
1865 intRow = 2
1866
1867 strsqla = ("Delete from WF_USR_AsbestosTracker_T")
1868
1869 with sqlconnection.execute (strsqla)
1870 end with
1871
1872 do until objExcel.cells(intRow,1) = ""
1873 AssetID = objExcel.Cells(intRow, 1).Value
1874 OccID = objExcel.Cells(intRow, 2).Value
1875
1876 strSQL = ("Insert Into WF_USR_AsbestosTracker_T (AssetID, OccID) Values (" & AssetID & ",'" & OccID & "')")
1877
1878 with sqlconnection.execute(strSQL)
1879 end with
1880 introw = introw + 1
1881 loop
1882
1883 objwkbk.close
1884 objExcel.Quit
1885End Function
1886
1887function importOccforDeletions(file)
1888 Dim objExcel, objwkbk, intRow, AssetID, OccID, strSQL
1889
1890 set objExcel = CreateObject("Excel.Application")
1891 set objwkbk = objExcel.Workbooks.Open(file)
1892
1893 intRow = 2
1894
1895 do until objExcel.cells(intRow,1) = ""
1896 AssetID = objExcel.Cells(intRow, 1).Value
1897 OccID = objExcel.Cells(intRow, 2).Value
1898
1899 strSQL = ("Insert Into RHA_USR_Occurrence_Deletions_T (AssetID, OccID) Values ('" & AssetID & "','" & OccID & "')")
1900
1901 with sqlconnection.execute(strSQL)
1902 end with
1903 introw = introw + 1
1904 loop
1905
1906 objwkbk.close
1907 objExcel.Quit
1908End Function
1909
1910function importElecData(file)
1911 Dim objExcel, objwkbk, intRow, AssetID, certDate, certRef, certStatus, Comments, strSQL
1912
1913 set objExcel = CreateObject("Excel.Application")
1914 set objwkbk = objExcel.Workbooks.Open(file)
1915
1916 intRow = 2
1917
1918 strsqla = ("Delete from WF_USR_ElecCertImport_T")
1919
1920 with sqlconnection.execute (strsqla)
1921 end with
1922
1923 do until objExcel.cells(intRow,1) = ""
1924 AssetID = objExcel.Cells(intRow, 1).Value
1925 certDate = objExcel.Cells(intRow, 2).Value
1926 certRef = objExcel.Cells(intRow, 3).Value
1927
1928 if objExcel.Cells(intRow, 4).Value = "PASS" then
1929 certStatus = 2328
1930 else
1931 if objExcel.Cells(intRow, 4).Value = "FAIL" then
1932 certStatus = 2329
1933 Else
1934 certStatus = 0
1935 End If
1936 End If
1937 Comments = objExcel.Cells(intRow, 5).Value
1938
1939 strSQL = ("Insert Into WF_USR_ElecCertImport_T (Asset_ID, CertDate, CertRef, CertStatus, Comments) Values (" & AssetID & ",'" & formatSQLDateTime(CDate(certDate)) & "','" & certRef & "'," & certStatus & ",'" & Comments & "')")
1940
1941 with sqlconnection.execute(strSQL)
1942 end with
1943 introw = introw + 1
1944 loop
1945
1946 objwkbk.close
1947 objExcel.Quit
1948End Function
1949
1950function importGasData(file)
1951 Dim objExcel, objwkbk, intRow, AssetID, certDate, certRef, certStatus, Comments, strSQL
1952
1953 set objExcel = CreateObject("Excel.Application")
1954 set objwkbk = objExcel.Workbooks.Open(file)
1955
1956 intRow = 2
1957
1958 strsqla = ("Delete from WF_USR_GasCertImport_T")
1959
1960 with sqlconnection.execute (strsqla)
1961 end with
1962
1963 do until objExcel.cells(intRow,1) = ""
1964 AssetID = objExcel.Cells(intRow, 1).Value
1965 certDate = objExcel.Cells(intRow, 2).Value
1966 certRef = objExcel.Cells(intRow, 3).Value
1967
1968 if objExcel.Cells(intRow, 4).Value = "PASS" then
1969 certStatus = 1512
1970 else
1971 if objExcel.Cells(intRow, 4).Value = "FAIL" then
1972 certStatus = 1513
1973 Else
1974 certStatus = 0
1975 End If
1976 End If
1977 Comments = objExcel.Cells(intRow, 5).Value
1978
1979 strSQL = ("Insert Into WF_USR_GasCertImport_T (Asset_ID, CertDate, CertRef, CertStatus, Comments) Values (" & AssetID & ",'" & formatSQLDateTime(CDate(certDate)) & "','" & certRef & "'," & certStatus & ",'" & Comments & "')")
1980
1981 with sqlconnection.execute(strSQL)
1982 end with
1983 introw = introw + 1
1984 loop
1985
1986 objwkbk.close
1987 objExcel.Quit
1988End Function
1989
1990Function formatSQLDateTime(Date_dt)
1991 formatSQLDateTime = (Year(Date_dt) & "-" & Month(Date_dt) & "-" & Day(Date_dt) & " 00:00:00.000")
1992End Function
1993
1994Function SendEmailbccSQL(Recip, bcc, Sndr, Subj, Msg, Prof)
1995 Dim strSQL
1996 Msg = replace(Msg,"'","")
1997 strSQL = ("exec msdb.dbo.sp_send_dbmail @profile_name = '" & Prof & "', @recipients = '" & Recip & "', @blind_copy_recipients = '" & bcc & "', @from_address = '" & Sndr & "', @subject = '" & Subj & "', @body = '" & Msg & "'")
1998
1999 With sqlconnection.execute (strSQL)
2000 End With
2001End Function
2002
2003Function SendEmailSQL(Recip, Sndr, cc, bcc, Subj, Msg, Prof)
2004 Dim strSQL
2005 'msgbox "DEBUG - In SendEmailSQL"
2006 '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
2007
2008 Msg = replace(Msg,"'","")
2009 'msgbox "New message body - " & Msg
2010 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 & "'")
2011
2012 With sqlconnection.execute (strSQL)
2013 End With
2014
2015 'msgbox "DEBUG - sp_send_dbmail sent"
2016
2017End Function
2018
2019Function SendHTMLEmailSQL(Recip, Sndr, cc, bcc, Subj, Msg, Format, Prof)
2020
2021 Dim strSQL
2022
2023 Msg = replace(Msg,"'","")
2024
2025 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 & "'")
2026
2027 With sqlconnection.execute (strSQL)
2028 End With
2029
2030End Function
2031
2032Function UpdateOwner(CaseID, Owner)
2033 Dim strSQL
2034 strSQL = ("Update WF_HPM_ComplaintsTracker_T set CaseOwner = " & Owner & " where Case_ID = " & CaseID)
2035 with sqlconnection.execute(strSQL)
2036 end with
2037End Function
2038
2039Function UpdateCoOrd(CaseID, CoOrd)
2040 Dim strSQL
2041 strSQL = ("Update WF_HPM_ComplaintsTracker_T set CaseCoOrd = " & CoOrd &" where Case_ID = " & CaseID)
2042 with sqlconnection.execute(strSQL)
2043 end with
2044End Function
2045
2046Function PANotified(CaseID)
2047 Dim strSQL
2048 strSQL = ("Update WF_HPM_ComplaintsTracker_T set Status = 3, LstUpdated = getdate() where Case_ID = " & CaseID)
2049 with sqlconnection.execute(strSQL)
2050 end with
2051End Function
2052
2053
2054Function CoOrdAdded(CaseID, CoOrd)
2055 Dim strSQL
2056 strSQL = ("Update WF_HPM_ComplaintsTracker_T set Status = 2, LstUpdated = getdate(), CaseCoOrd = " & CoOrd & " where Case_ID = " & CaseID)
2057 with sqlconnection.execute(strSQL)
2058 end with
2059End Function
2060
2061Function NewComplaint(CaseID, Owner, CoOrd)
2062 Dim strSql
2063 strSQL = ("Insert Into WF_HPM_ComplaintsTracker_T (Case_ID, CaseOwner, CaseCoOrd) Values (" & CaseID & "," & Owner & "," & CoOrd & ")")
2064 with sqlconnection.execute(strSQL)
2065 end with
2066End Function
2067
2068Function OpenDIP(Path)
2069 Dim ObjApp
2070 'MsgBox path
2071 Set ObjApp = CreateObject("WScript.Shell")
2072 ObjApp.Exec Path
2073End Function
2074
2075
2076Function OpenDocumotive(IndexName, UniqueID, DatabasePath)
2077 Dim objShell, objRS
2078 Dim objFSO
2079
2080 Set objRS = SQLConnection.Execute("SELECT DIPView_Exe_Location_VC FROM Shared_Options_Extended_T (NOLOCK) WHERE Options_Extended_ID = 1")
2081 If Not (objRS.BOF OR objRS.EOF) Then
2082 Set objFSO = CreateObject("Scripting.FileSystemObject")
2083' to disable Imageviewer comment out the if statement below and uncomment the message box
2084'msgbox "Documotive unavailable"
2085
2086 If objFSO.FileExists(objRS.Fields("DIPView_Exe_Location_VC").Value) Then
2087 Set objShell = CreateObject("WScript.Shell")
2088
2089 'MsgBox objRS.Fields("DIPView_Exe_Location_VC").Value & " -Live -search """ & IndexName & """ """ & CStr(UniqueID) & """ """ & DatabasePath & """"
2090
2091 'DatebasePath = "IDS://ragdoc/raglan housing"
2092
2093'to switch between test and live
2094 'objShell.Exec objRS.Fields("DIPView_Exe_Location_VC").Value & " -test -search """ & IndexName & """ """ & CStr(UniqueID) & """ """ & DatabasePath & """"
2095
2096 objShell.Exec objRS.Fields("DIPView_Exe_Location_VC").Value & " -Live -search """ & IndexName & """ """ & CStr(UniqueID) & """ """ & DatabasePath & """"
2097
2098 Set objShell = Nothing
2099 End If
2100 Set objFSO = Nothing
2101
2102 objRS.Close
2103 End If
2104 Set objRS = Nothing
2105End Function
2106
2107
2108
2109
2110Function OpenDocumotiveInvoice(IndexName, UniqueID)
2111 Dim objShell
2112 Set objShell = CreateObject("WScript.Shell")
2113
2114 'MsgBox "\\ragdoc\documotive$\WorkflowViewer\ImageViewer.exe -search """ & IndexName & """ """ & CStr(UniqueID) & """"
2115
2116 objShell.Exec "\\ragdoc\documotive$\WorkflowViewer\ImageViewer.exe -search """ & IndexName & """ """ & CStr(UniqueID) & """"
2117
2118 Set objShell = Nothing
2119End Function
2120
2121
2122
2123
2124Function AccountLocked (AccountID)
2125Dim StrSQL
2126strSQL = ("Select cast(UserName as varchar(150)) from tempdb.dbo.sysmislocks where primarykeyvalue = " & AccountID & " and databasename = DB_NAME() and Username <> replace(System_User, 'RAGLAN\', '')")
2127with sqlconnection.execute (strSQL)
2128 do until .eof
2129 AccountLocked = sentence(.fields(0))
2130 .movenext
2131 loop
2132end with
2133End Function
2134
2135Function BuildNonAccessTable
2136'Function that will build up the info in the Non Access table for the non access workflow
2137 dim nonAccess
2138'Build the SOR No Access Table
2139 nonAccess = ("EXEC WF_USR_NonAccess_SP")
2140 'msgbox ("About to run the proc")
2141 with sqlconnection.execute(nonAccess)
2142 'msgbox("Procedure Exec")
2143 end with
2144End Function
2145
2146Function VMOccExtend(CaseID)
2147 Dim strSQL
2148 strSQL = ("Update WF_HPMVoidsTracker_T set OccExtended = 1 where Case_ID = " & CaseID)
2149
2150 with sqlconnection.execute (strSQL)
2151 end with
2152End Function
2153
2154Function VMMutualExch(CaseID)
2155 Dim strSQL
2156 strSQL = ("update WF_HPMVoidsTracker_T set MutualEx = 1 where Case_ID = " & CaseID)
2157
2158 with sqlconnection.execute (strSQL)
2159 end with
2160End Function
2161
2162Function VMForcedEntry(caseID, Completion)
2163 Dim strSQL
2164 strSQL = ("Update WF_HPMVoidsTracker_T set ForcedEntry = '" & Completion & "' where Case_ID = " & CaseID )
2165
2166 with sqlconnection.execute (strSQL)
2167 end with
2168End Function
2169
2170Function UpdateHSCDoc(CaseID)
2171 Dim strSQL
2172 strSQL = ("Update WF_HPMVoidsTracker_T Set HSCStart = 1 where Case_ID = " & CaseID)
2173
2174 With sqlconnection.execute (strSQL)
2175 End With
2176End Function
2177
2178Function UpdateAnalCode(CaseID, Analysis)
2179 Dim strSQL
2180 strSQL = ("update WF_HPMVoidsTracker_T set PriorityCode_ID = " & Analysis & " where Case_ID = " & CaseID)
2181
2182 with sqlconnection.execute (strSQL)
2183 end with
2184End Function
2185
2186Function CaseStatusReason(CaseID)
2187 Dim strSQL
2188 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)
2189 with sqlconnection.execute(strSQL)
2190 do until .eof
2191 CaseStatusReason = sentence(.fields(0))
2192 .movenext
2193 loop
2194 End With
2195End Function
2196
2197Function VoidsStatusChange(Case_ID, Status_ID)
2198 Dim strSQL
2199 strSQL = ("Update WF_HPMVoidsTracker_T set Status_ID = " & Status_ID & " where case_ID = " & Case_ID)
2200
2201 with sqlconnection.execute(strSQL)
2202 end with
2203End Function
2204'Stamps the Voids Tracker table to state that the new case tasks have been generated
2205Function NewVoidsCase (Case_ID, Status_ID, Entry)
2206 Dim strSQL
2207 strSQL = ("insert into WF_HPMVoidsTracker_T (Case_ID, CreationTask, Status_ID, ForcedEntry) Values (" & Case_ID & ", getdate(), " & Status_ID & ", " & Entry & ")")
2208
2209 with sqlconnection.execute(strSQL)
2210 End With
2211End Function
2212'Stamps the Voids Tracker table to state that the Hand Over task has been generated
2213Function VoidsHandOver (Case_ID)
2214 Dim strSQL
2215 strSQL = ("update WF_HPMVoidsTracker_T set HandOver = 1 where case_id = " & Case_ID)
2216
2217 with sqlconnection.execute (strSQL)
2218 End With
2219End Function
2220
2221'Will stamp the Voids Tracker table to say that the task that generates when the keys have been returned has been completed.
2222Function VoidsKeyReturn (Case_ID)
2223 Dim strSQL
2224 strSQL = ("update WF_HPMVoidsTracker_T set KeyReturned = 1 where case_id = " & Case_ID)
2225
2226 With sqlconnection.execute(strSQL)
2227 End With
2228End Function
2229
2230Function CreateElecFile(File)
2231 Dim fso, txtstream
2232
2233 Set fso = CreateObject("Scripting.FileSystemObject")
2234 'msgbox File
2235
2236 File = cstr(File)
2237 set txtstream = fso.CreateTextFile(File,True)
2238End Function
2239
2240'Create the file for the gas extract
2241Function CreateGasFile(File)
2242 Dim fso, txtstream
2243
2244 Set fso = CreateObject("Scripting.FileSystemObject")
2245 'msgbox File
2246
2247 File = cstr(File)
2248 set txtstream = fso.CreateTextFile(File,True)
2249End Function
2250
2251Function CreateAsbestosFile(File)
2252 Dim fso, txtstream
2253
2254 Set fso = CreateObject("Scripting.FileSystemObject")
2255
2256 File = cstr(File)
2257 set txtstream = fso.CreateTextFile(File,True)
2258End Function
2259
2260Function addElecInfoToFile(FilePath, LineInfo)
2261 dim fso, txtstream
2262
2263 set fso = CreateObject("Scripting.FileSystemObject")
2264 Set txtstream = fso.OpenTextFile(FilePath,8)
2265
2266 txtstream.Write LineInfo
2267 txtstream.Close
2268End Function
2269
2270'Add the information to the gas extract
2271Function addGasInfoToFile(FilePath, LineInfo)
2272 dim fso, txtstream
2273
2274 set fso = CreateObject("Scripting.FileSystemObject")
2275 Set txtstream = fso.OpenTextFile(FilePath,8)
2276
2277 txtstream.Write LineInfo
2278 txtstream.Close
2279End Function
2280
2281'Update the RHA_ContractorsTracker_T table with the value supplied
2282'Created by KS 13/03/2010
2283Function UpdateContractorTracker(Contractor)
2284 Dim strSQL
2285 strSQL = ("insert into RHA_ContractorsTracker_T (Contractor_ID) Values (" & Contractor & ")")
2286 with sqlconnection.execute (strSQL)
2287 End With
2288End Function
2289
2290'Update the RHA_ContractorsTracker_T table with the value supplied
2291'Created by KS 13/03/2010
2292Function UpdateContractorTracker(Contractor)
2293 Dim strSQL
2294 strSQL = ("insert into RHA_ContractorsTracker_T (Contractor_ID) Values (" & Contractor & ")")
2295 with sqlconnection.execute (strSQL)
2296 End With
2297End Function
2298
2299
2300'Convert date entered into DD/MM/YYYY format for date conversion purposes
2301'Created by KS 20/11/09
2302function convertDate(Date_dt)
2303 ConvertDate = (Day(date_Dt) & "/" & Month(Date_DT) & "/" & Year(Date_Dt))
2304End Function
2305
2306function GetOrderStatus(WO_ID)
2307
2308 with sqlconnection.execute("SELECT Status_ID FROM Repairs_Works_Orders_T with(nolock) WHERE WorksOrder_ID = " & WO_ID)
2309 do until .eof
2310 GetOrderStatus= sentence(.fields(0))
2311 .movenext
2312 loop
2313 end with
2314
2315end function
2316
2317'function that will write back the information of when a workflow was last run (primary use with manual flows)
2318'Create by KS 05/08/2009
2319Function StampWorkflowRanTable(WF_Desc, Outcome, User)
2320 dim strSQL
2321 strSQL = ("EXEC RHA_INSERT_WF_P '" + WF_Desc + "', '" + Outcome + "', '" + User + "'")
2322 'msgbox strSQL
2323 with sqlconnection.execute (strSQL)
2324 end with
2325end function
2326
2327FUNCTION UserRoleForAppointments(UserID)
2328 UserRoleForAppointments = 0
2329 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)
2330 If Not .eof AND Not .bof Then
2331 UserRoleForAppointments = .fields(0)
2332 .close
2333 End IF
2334 end with
2335END FUNCTION
2336
2337
2338FUNCTION DesignatedAuthoriser(AuthoriserID)
2339 DesignatedAuthoriser = 0
2340 with sqlconnection.execute("select count(Authorisation_ID) from dbo.RHA_AppointmentsExtract_V with (nolock) where Authorisation_ID = " & AuthoriserID)
2341 If Not .eof AND Not .bof Then
2342 DesignatedAuthoriser= .fields(0)
2343 .close
2344 End IF
2345 end with
2346END FUNCTION
2347
2348function GetGroupVul(GroupID)
2349 dim strResult
2350 with sqlconnection.execute("SELECT Vulnerability_Code_ID AS Vul_ID FROM Contact_Group_Vulnerabilities_T with (nolock) WHERE Group_ID = " & GroupID)
2351 do until .eof
2352 if not isnull(.fields(0)) then
2353 strResult = .fields(0)
2354 end if
2355 .movenext
2356 loop
2357 end with
2358 GetGroupVul= strResult
2359end function
2360
2361function GetContractorCode(WO_ID)
2362
2363 with sqlconnection.execute("SELECT Contractor_ID FROM Repairs_Works_Orders_T with (nolock) WHERE WorksOrder_ID = " & WO_ID)
2364 do until .eof
2365 GetContractorCode= sentence(.fields(0))
2366 .movenext
2367 loop
2368 end with
2369
2370end function
2371
2372Function SQLPropertyHasAsbestosXMLOLD(AssetID)
2373
2374 Dim varDateFitted
2375 Dim strCommand
2376 Dim varAsbestosText
2377 Dim varTmp
2378 Dim varLocation
2379 Dim varFloorLevel
2380 Dim varComments
2381
2382 varDateFitted = 9
2383 varAsbestosText = ""
2384
2385 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
2386' msgbox (strCommand)
2387 With sqlconnection.execute (strCommand)
2388 If Not .eof AND Not .bof Then
2389 varDateFitted = (.Fields("FittedRenewDate").Value)
2390 .Close
2391 End If
2392 End With
2393
2394 If varDateFitted = 9 Then
2395 SQLPropertyHasAsbestosXML = "ADVISORY:- There MAY be Asbestos in this property. If any suspected materials are found STOP WORK IMMEDIATELY and contact the Administration Team."
2396 Else
2397 If varDateFitted = 1 Then
2398 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
2399 With sqlconnection.execute (strCommand)
2400 Do Until .EOF
2401 varFloorLevel = (.Fields("FloorLevel").Value)
2402 varLocation = (.Fields("Location").Value)
2403 varComments = (.Fields("Comments").Value)
2404 varAsbestosType = (.Fields("AsbestosType").Value)
2405 varTmp = ""
2406 If varFloorLevel<>"" Then
2407 varTmp = varFloorLevel
2408 End If
2409 If varLocation<>"" Then
2410 If varTmp<>"" Then
2411 varTmp = varTmp & " : " & varLocation
2412 Else
2413 varTmp = varLocation
2414 End If
2415 End If
2416 If varComments<>"" Then
2417 If varTmp<>"" Then
2418 varTmp = varTmp & " : " & varComments
2419 Else
2420 varTmp = varComments
2421 End If
2422 End If
2423 If varAsbestosType<>"" Then
2424 If varTmp<>"" Then
2425 varTmp = varTmp & ". Asbestos Type: " & varAsbestosType
2426 Else
2427 varTmp = varAsbestosType
2428 End If
2429 End If
2430 If varTmp<>"" Then
2431 If varAsbestosText <> "" Then
2432 varAsbestosText = varAsbestosText & "|" & varTmp
2433 Else
2434 varAsbestosText = varTmp
2435 End If
2436 End If
2437 .MoveNext
2438 Loop
2439 End With
2440 End If
2441
2442 If varDateFitted = 1 AND varAsbestosText <> "" Then
2443' SQLPropertyHasAsbestosXML = Replace(varAsbestosText,"|",vbcrlf)
2444 SQLPropertyHasAsbestosXML = "WARNING:- There is Asbestos in this property. Contact the Administration Team before starting work."
2445 Else
2446 If varDateFitted = 1 AND varAsbestosText = "" Then
2447 SQLPropertyHasAsbestosXML = "ADVISORY:- There MAY be Asbestos in this property. If any suspected materials are found STOP WORK IMMEDIATELY and contact the Administration Team."
2448 Else
2449 SQLPropertyHasAsbestosXML = "Due to the Build/Refurb date this property is unlikely to contain asbestos."
2450 End If
2451 End If
2452 End If
2453 strcommand = "select dbo.fn_XML_Safe_Text('" & SQLPropertyHasAsbestosXML & "')"
2454 With SQLConnection.Execute(strcommand)
2455
2456 do until .eof
2457 SQLPropertyHasAsbestosXML = .fields(0)
2458 exit do
2459 loop
2460 End With
2461End Function
2462
2463Function SQLPropertyHasAsbestosXML(AssetID)
2464
2465 Dim varDateFitted
2466 Dim strCommand
2467 Dim varAsbestosText
2468 Dim varTmp
2469 Dim varLocation
2470 Dim varFloorLevel
2471 Dim varComments
2472
2473 varDateFitted = 9
2474 varAsbestosText = ""
2475
2476 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
2477' msgbox (strCommand)
2478 With sqlconnection.execute (strCommand)
2479 If Not .eof AND Not .bof Then
2480 varDateFitted = (.Fields("FittedRenewDate").Value)
2481 .Close
2482 End If
2483 End With
2484
2485 If varDateFitted = 9 Then
2486 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."
2487 Else
2488 If varDateFitted = 1 Then
2489 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
2490 With sqlconnection.execute (strCommand)
2491 Do Until .EOF
2492 varFloorLevel = (.Fields("FloorLevel").Value)
2493 varLocation = (.Fields("Location").Value)
2494 varComments = (.Fields("Comments").Value)
2495 varAsbestosType = (.Fields("AsbestosType").Value)
2496 varTmp = ""
2497 If varFloorLevel<>"" Then
2498 varTmp = varFloorLevel
2499 End If
2500 If varLocation<>"" Then
2501 If varTmp<>"" Then
2502 varTmp = varTmp & " : " & varLocation
2503 Else
2504 varTmp = varLocation
2505 End If
2506 End If
2507 If varComments<>"" Then
2508 If varTmp<>"" Then
2509 varTmp = varTmp & " : " & varComments
2510 Else
2511 varTmp = varComments
2512 End If
2513 End If
2514 If varAsbestosType<>"" Then
2515 If varTmp<>"" Then
2516 varTmp = varTmp & ". Asbestos Type: " & varAsbestosType
2517 Else
2518 varTmp = varAsbestosType
2519 End If
2520 End If
2521 If varTmp<>"" Then
2522 If varAsbestosText <> "" Then
2523 varAsbestosText = varAsbestosText & "|" & varTmp
2524 Else
2525 varAsbestosText = varTmp
2526 End If
2527 End If
2528 .MoveNext
2529 Loop
2530 End With
2531 End If
2532
2533 If varDateFitted = 1 AND varAsbestosText <> "" Then
2534' SQLPropertyHasAsbestosXML = Replace(varAsbestosText,"|",vbcrlf)
2535 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."
2536 Else
2537 If varDateFitted = 1 AND varAsbestosText = "" Then
2538 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."
2539 Else
2540 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."
2541 End If
2542 End If
2543 End If
2544 strcommand = "select dbo.fn_XML_Safe_Text('" & SQLPropertyHasAsbestosXML & "')"
2545 With SQLConnection.Execute(strcommand)
2546
2547 do until .eof
2548 SQLPropertyHasAsbestosXML = .fields(0)
2549 exit do
2550 loop
2551 End With
2552End Function
2553
2554Function SQLPropertyHasAsbestosOLD(AssetID)
2555
2556 Dim varDateFitted
2557 Dim strCommand
2558 Dim varAsbestosText
2559 Dim varTmp
2560 Dim varLocation
2561 Dim varFloorLevel
2562 Dim varComments
2563
2564 varDateFitted = 9
2565 varAsbestosText = ""
2566
2567 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
2568' msgbox (strCommand)
2569 With sqlconnection.execute (strCommand)
2570 If Not .eof AND Not .bof Then
2571 varDateFitted = (.Fields("FittedRenewDate").Value)
2572 .Close
2573 End If
2574 End With
2575
2576 If varDateFitted = 9 Then
2577 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"
2578 Else
2579 If varDateFitted = 1 Then
2580 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
2581 With sqlconnection.execute (strCommand)
2582 Do Until .EOF
2583 varFloorLevel = (.Fields("FloorLevel").Value)
2584 varLocation = (.Fields("Location").Value)
2585 varComments = (.Fields("Comments").Value)
2586 varAsbestosType = (.Fields("AsbestosType").Value)
2587 varTmp = ""
2588 If varFloorLevel<>"" Then
2589 varTmp = varFloorLevel
2590 End If
2591 If varLocation<>"" Then
2592 If varTmp<>"" Then
2593 varTmp = varTmp & " : " & varLocation
2594 Else
2595 varTmp = varLocation
2596 End If
2597 End If
2598 If varComments<>"" Then
2599 If varTmp<>"" Then
2600 varTmp = varTmp & " : " & varComments
2601 Else
2602 varTmp = varComments
2603 End If
2604 End If
2605 If varAsbestosType<>"" Then
2606 If varTmp<>"" Then
2607 varTmp = varTmp & ". Asbestos Type: " & varAsbestosType
2608 Else
2609 varTmp = varAsbestosType
2610 End If
2611 End If
2612 If varTmp<>"" Then
2613 If varAsbestosText <> "" Then
2614 varAsbestosText = varAsbestosText & "|" & varTmp
2615 Else
2616 varAsbestosText = varTmp
2617 End If
2618 End If
2619 .MoveNext
2620 Loop
2621 End With
2622 End If
2623
2624 If varDateFitted = 1 AND varAsbestosText <> "" Then
2625 SQLPropertyHasAsbestos = Replace(varAsbestosText,"|",vbcrlf)
2626 Else
2627 If varDateFitted = 1 AND varAsbestosText = "" Then
2628 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"
2629 End If
2630 End If
2631 End If
2632
2633End Function
2634
2635Function SQLPropertyHasAsbestos(AssetID)
2636
2637 Dim varDateFitted
2638 Dim strCommand
2639
2640 varDateFitted = 9
2641
2642 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
2643
2644 With sqlconnection.execute (strCommand)
2645 If Not .eof AND Not .bof Then
2646 varDateFitted = (.Fields("FittedRenewDate").Value)
2647 .Close
2648 End If
2649 End With
2650
2651 If varDateFitted = 9 Then
2652 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."
2653 Else
2654 If varDateFitted = 1 Then
2655 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
2656 With sqlconnection.execute (strCommand)
2657 Do Until .EOF
2658 varAsbestosType = (.Fields("AsbestosType").Value)
2659 .MoveNext
2660 Loop
2661 End With
2662 End If
2663
2664 If varDateFitted = 1 AND varAsbestosType <> "" Then
2665 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."
2666 Else
2667 If varDateFitted = 1 AND varAsbestosText = "" Then
2668 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."
2669 Else
2670 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."
2671 End If
2672 End If
2673 End If
2674
2675End Function
2676
2677function GetJobTypeID(OrderID)
2678 dim strJobType
2679 dim strExec
2680 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"
2681 strExec = strExec & " RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RRTL.SystemUplift_BT = 0 AND RWOL.Status_ID <> 29 AND RWOL.WorksOrder_ID = " & OrderID
2682 with SQLConnection.execute(strExec)
2683 do until .eof
2684 strJobType = .fields(0)
2685 exit do
2686 loop
2687 end with
2688 GetJobTypeID = strJobType
2689end function
2690
2691
2692function GetPriorityID(OrderID)
2693 dim strPriority
2694 dim strExec
2695 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"
2696 strExec = strExec & " RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RWOL.Status_ID <> 29 and RWOL.WorksOrder_ID = " & OrderID
2697 with SQLConnection.execute(strExec)
2698 do until .eof
2699 strPriority = .fields(0)
2700 exit do
2701 loop
2702 end with
2703 GetPriorityID = strPriority
2704end function
2705
2706
2707
2708function GetPriorityIDv2(OrderID)
2709'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
2710 dim strPriority
2711 dim strExec
2712 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"
2713 with SQLConnection.execute(strExec)
2714 do until .eof
2715 strPriority = .fields(0)
2716 exit do
2717 loop
2718 end with
2719 GetPriorityIDv2 = strPriority
2720end function
2721
2722function showBrowser(URL)
2723Dim WinShell
2724Set WinShell = CreateObject ("WScript.Shell")
2725Winshell.RUN "iexplore.exe " & URL
2726end function
2727
2728Function ContractorPath(ContractorID)
2729 ContractorPath = 0
2730'Ian Williams
2731 If (ContractorID = "10131") Then
2732 ContractorPath = 1
2733 End if
2734'Connaught
2735 If (ContractorID = "10132") Then
2736 ContractorPath = 2
2737 End if
2738'Wates
2739 If (ContractorID = "10625") Then
2740 ContractorPath = 3
2741 End If
2742'Armitage
2743 If (ContractorID = "10575") Then
2744 ContractorPath = 4
2745 End If
2746'A1 Maintenance
2747 If (ContractorID = "10571") Then
2748 ContractorPath = 5
2749 End If
2750'3 Solutions
2751 If (ContractorID = "10406") Then
2752 ContractorPath = 6
2753 End If
2754'Axis
2755 If (ContractorID = "10577") Then
2756 ContractorPath = 7
2757 End If
2758End Function
2759
2760
2761function UpdateUDESMS(WorksOrderID, SMSNumber)
2762 Dim varExecute
2763
2764 UpdateUDESMS= False
2765 varInsertReqd = 1
2766 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 & "'"
2767
2768 With SQLConnection.Execute(varSelect)
2769 Do Until .EOF
2770 varInsertReqd = .Fields("OrderFound").Value
2771 .MoveNext
2772 Loop
2773 End With
2774
2775 If varInsertReqd = 0 Then
2776 varExecute = "INSERT INTO usr_Repairs_Works_Orders_UDE_1_T (SYS_Parent_Link_ID,USR_Panel1_SMS_Text_Number_used_VC) VALUES('" & WorksOrderID & "','" & SMSNumber & "')"
2777
2778 Else
2779 varExecute = "UPDATE usr_Repairs_Works_Orders_UDE_1_T SET USR_Panel1_SMS_Text_Number_used_VC= '" & SMSNumber & "' WHERE SYS_Parent_Link_ID = '" & WorksOrderID & "'"
2780
2781 End If
2782
2783 With SQLConnection.Execute(varExecute)
2784 End With
2785
2786 UpdateUDESMS= True
2787end function
2788
2789function UpdateUDEAppointmentREQ(WorksOrderID,AppREQ)
2790 Dim varExecute
2791
2792 UpdateUDEAppointmentREQ= False
2793 varInsertReqd = 1
2794 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 & "'"
2795
2796 With SQLConnection.Execute(varSelect)
2797 Do Until .EOF
2798 varInsertReqd = .Fields("OrderFound").Value
2799 .MoveNext
2800 Loop
2801 End With
2802
2803 If varInsertReqd = 0 Then
2804 varExecute = "INSERT INTO usr_Repairs_Works_Orders_UDE_1_T (SYS_Parent_Link_ID,USR_Panel1_Appointment_Required_BT) VALUES('" & WorksOrderID & "','" & AppREQ & "')"
2805
2806 Else
2807 varExecute = "UPDATE usr_Repairs_Works_Orders_UDE_1_T SET USR_Panel1_Appointment_Required_BT = '" & AppREQ & "' WHERE SYS_Parent_Link_ID = '" & WorksOrderID & "'"
2808
2809 End If
2810
2811 With SQLConnection.Execute(varExecute)
2812 End With
2813
2814 UpdateUDEAppointmentREQ= True
2815end function
2816
2817
2818function WorkOrderStatus(Printed,Cancelled,Completed)
2819 WorkOrderStatus = 1
2820 if len(Printed) = 0 then
2821 WorkOrderStatus = 0
2822 end if
2823 if len(Completed) > 0 then
2824 WorkOrderStatus = 3
2825 end if
2826 if len(Cancelled) > 0 then
2827 WorkOrderStatus = 2
2828 end if
2829end function
2830
2831'New Version to fix an XML production bug - KS 26/03/09
2832function WorkOrderStatusv2(Printed,Cancelled,Completed, RaisedBy)
2833 WorkOrderStatusv2 = 1
2834 if len(Printed) = 0 then
2835 WorkOrderStatusv2 = 0
2836 end if
2837 if len(Completed) > 0 or RaisedBy = "521" or RaisedBy = "522" then
2838 WorkOrderStatusv2 = 3
2839 end if
2840 if len(Cancelled) > 0 then
2841 WorkOrderStatusv2 = 2
2842 end if
2843end function
2844
2845
2846Function ReadFromCSVFile(File)
2847 Dim fso
2848 Dim txtstream
2849 Const ForReading = 1, ForWriting = 2, ForAppending = 8
2850 set fso=CreateObject("Scripting.FileSystemObject")
2851 set txtstream=fso.OpenTextFile(File, ForReading, True)
2852 ReadFromCSVFile = txtstream.ReadLine
2853 txtstream.Close
2854End Function
2855
2856Function ReadAllTextFile(FileName)
2857 Const ForReading = 1, ForWriting = 2
2858 Dim fso, f
2859 Set fso = CreateObject("Scripting.FileSystemObject")
2860 Set f = fso.OpenTextFile(FileName, ForReading, True)
2861 ReadAllTextFile = f.ReadAll
2862End Function
2863
2864Function LettingsApplicationVariationTracker(varApplicationID,varStatus,varType,varPrison,varForces,varUK,varInitial)
2865
2866Rem Version 1.0 17th January 2008 AMS/CAP
2867
2868 If varInitial = True Then
2869 varSelect = "INSERT INTO RAGLAN_Lettings_Application_Changed_T (ApplicationID, PreviousStatus, ApplicationType, InPrisonFlag, MemberOfForcesFlag, ResidesInUKFlag) VALUES (" & varApplicationID & ", '" & varStatus & "', '" & varType & "', '" & varPrison & "', '" & varForces & "', '" & varUK & "')"
2870 Else
2871 varSelect = "UPDATE RAGLAN_Lettings_Application_Changed_T SET PreviousStatus='" & varStatus & "', ApplicationType='" & varType & "', InPrisonFlag='" & varPrison & "', MemberOfForcesFlag='" & varForces & "', ResidesInUKFlag='" & varUK & "' WHERE ApplicationID = '" & varApplicationID & "'"
2872 End If
2873
2874 With SQLConnection.Execute(varSelect)
2875 End With
2876
2877End Function
2878
2879Function AccountTerminationTracker(varAccountID,varEndDate,varProvFlag,varInitial)
2880
2881Rem Version 1.0 25th January 2008 AMS/CAP
2882
2883 If varInitial = True Then
2884 varSelect = "INSERT INTO RAGLAN_Tenancy_Termination_Tracker_T (ID, TenancyEndDate, ProvisionalFlag) VALUES ('" & varAccountID & "', '" & varEndDate & "', '" & varProvFlag & "')"
2885 Else
2886 varSelect = "UPDATE RAGLAN_Tenancy_Termination_Tracker_T SET TenancyEndDate='" & varEndDate & "', ProvisionalFlag='" & varProvFlag & "' WHERE ID = '" & varAccountID & "'"
2887 End If
2888
2889 With SQLConnection.Execute(varSelect)
2890 End With
2891
2892End Function
2893
2894Function CORE_Exported_Flag(varGroupID)
2895
2896 varUpdate = "update usr_Contact_Groups_UDE_1_T set USR_Panel1_CORE_Exported_System_Updated_BT=1 where SYS_Parent_Link_ID=" & varGroupID
2897
2898 With SQLConnection.Execute(varUpdate)
2899 End With
2900
2901End Function
2902
2903Function CORE_Clear_Down(varGroupID)
2904
2905varUpdate="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
2906
2907 With SQLConnection.Execute(varUpdate)
2908 End With
2909
2910End Function
2911
2912public function mPost
2913 dim rs
2914 dim lngCount
2915 dim strStmt
2916 dim objIface
2917 ''
2918 set objIface = CreateObject("SQLDocumentWFPlugin.CDocIface")
2919 if objIface is nothing then
2920 msgbox("Object Creation Failed")
2921 end if
2922
2923 objIface.Initialize SQLUtilities
2924
2925 set rs = CreateObject("ADODB.Recordset")
2926 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)"
2927 rs.CursorLocation = 3
2928 rs.Open strStmt, SQLConnection, 3, 1, 1
2929 Set rs.ActiveConnection = Nothing
2930 if not rs.eof and not rs.bof then
2931 rs.movefirst
2932 for lngCount = 1 to rs.RecordCount
2933 if objIface.DocumentIsValid(rs.fields(0).value) then
2934 objIface.PostDocument clng(rs.fields(0).value)
2935 else
2936 msgbox "Document : " & rs.fields(0).value & " " & objIface.ErrorReason,vbexclamation+vbokonly,"Posting Error"
2937 end if
2938 rs.movenext
2939 next
2940 else
2941 msgBox("no documents selected.")
2942 end if
2943 objIface.Terminate
2944 set objIface = nothing
2945end function
2946
2947Function PropertyHasAsbestos(AssetID)
2948 dim strFormatAssetID
2949 dim strCommand
2950 strFormatAssetID = String(7 - Len(AssetID),"0") & AssetID
2951 strCommand = "SELECT TOP 1 ID FROM DTS_Asset_Attributes with (nolock) WHERE ID LIKE '" & strFormatAssetID & "198**%'"
2952 with sqlconnection.execute (strCommand)
2953 if not .eof and not .bof then
2954 PropertyHasAsbestos = "WARNING: This property contains asbestos materials. You should contact Housing Services Centre 01202 312760 who will provide you with further details."
2955 end if
2956 .close
2957 end with
2958 strCommand = "SELECT TOP 1 ID FROM DTS_Asset_Attributes with (nolock) WHERE ID LIKE '" & strFormatAssetID & "4**%'"
2959 with sqlconnection.execute (strCommand)
2960 if not .eof and not .bof then
2961 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."
2962 end if
2963 .close
2964 end with
2965End Function
2966
2967Function ClearUSRTable(TableName)
2968 sqlconnection.execute ("DELETE FROM " & cstr(TableName))
2969End Function
2970
2971Function BuildUSRTable(RunDate)
2972 dim strCommand
2973' Resident Managers Selection
2974 strCommand = "INSERT INTO USR_Asset_Resident_Letters_T (Asset_ID,Request_ID,Resident_Manager_VC,Resident_Fax_VC) ("
2975 strCommand = strCommand & "SELECT RRT.Asset_ID, RRT.Request_ID,"
2976 strCommand = strCommand & "CASE "
2977 strCommand = strCommand & "WHEN LEN(UDEA.USR_Panel1_Resident_Manager_Name_VC) > 0 then UDEA.USR_Panel1_Resident_Manager_Name_VC "
2978 strCommand = strCommand & "WHEN LEN(UDEB.USR_Panel1_Resident_Manager_Name_VC) > 0 then UDEB.USR_Panel1_Resident_Manager_Name_VC "
2979 strCommand = strCommand & "WHEN LEN(UDEC.USR_Panel1_Resident_Manager_Name_VC) > 0 then UDEC.USR_Panel1_Resident_Manager_Name_VC "
2980 strCommand = strCommand & "END AS ResidentManager, "
2981 strCommand = strCommand & "CASE "
2982 strCommand = strCommand & "WHEN LEN(UDEA.USR_Panel1_Resident_Manager_Fax_VC) > 0 then UDEA.USR_Panel1_Resident_Manager_Fax_VC "
2983 strCommand = strCommand & "WHEN LEN(UDEB.USR_Panel1_Resident_Manager_Fax_VC) > 0 then UDEB.USR_Panel1_Resident_Manager_Fax_VC "
2984 strCommand = strCommand & "WHEN LEN(UDEC.USR_Panel1_Resident_Manager_Fax_VC) > 0 then UDEC.USR_Panel1_Resident_Manager_Fax_VC "
2985 strCommand = strCommand & "END AS ResidentFax "
2986 strCommand = strCommand & "From Repairs_Requests_T AS RRT with (nolock)"
2987 strCommand = strCommand & "INNER JOIN Asset_Assets_T AAT with (nolock) ON AAT.Asset_ID = RRT.Asset_ID "
2988 strCommand = strCommand & "INNER JOIN Asset_Types_T ATT with (nolock) ON ATT.Asset_Type_ID = AAT.Asset_Type_ID "
2989 strCommand = strCommand & "INNER JOIN Asset_Asset_Structure_T AASTA with (nolock)ON AASTA.Child_ID = AAT.Asset_ID "
2990 strCommand = strCommand & "LEFT JOIN Asset_Asset_Structure_T AASTB with (nolock)ON AASTB.Child_ID = AASTA.Parent_ID "
2991 strCommand = strCommand & "LEFT JOIN Asset_Asset_Structure_T AASTC with (nolock) ON AASTC.Child_ID = AASTB.Parent_ID "
2992 strCommand = strCommand & "LEFT JOIN usr_Asset_Assets_UDE_1_T UDEA with (nolock) ON UDEA.SYS_Parent_Link_ID = AAT.Asset_ID "
2993 strCommand = strCommand & "LEFT JOIN usr_Asset_Assets_UDE_1_T UDEB with (nolock) ON UDEB.SYS_Parent_Link_ID = AASTA.Parent_ID "
2994 strCommand = strCommand & "LEFT JOIN usr_Asset_Assets_UDE_1_T UDEC with (nolock) ON UDEC.SYS_Parent_Link_ID = AASTB.Parent_ID "
2995 strCommand = strCommand & "WHERE CONVERT(varchar(12),RRT.Request_DT,103) = '%1' "
2996 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) "
2997 strCommand = strCommand & ")"
2998 strCommand = replace(strCommand,"%1",RunDate)
2999 SQLConnection.execute strCommand
3000End Function
3001
3002function ConfirmationOrder(Confirmation)
3003 if confirmation = "True" then
3004 ConfirmationOrder = "** Confirmation Order **"
3005 end if
3006end function
3007
3008Function AssetIsDisposed(AssetID)
3009 dim strCommand
3010 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)
3011 with sqlconnection.execute(strCommand)
3012 if not .eof and not .bof then
3013 if .fields(0).Value = "134" then
3014 msgbox "This asset was disposed on " & .fields(1).Value,vbexclamation+vbokonly,"Disposed"
3015 AssetIsDisposed = True
3016 end if
3017 end if
3018 .close
3019 end with
3020End Function
3021
3022'Function SendEmailToContractor(OrderID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,RiskCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning)
3023'
3024' dim strBody
3025' dim strEmailAddress
3026' dim strCommand
3027' dim dblTotal
3028' dim lngLines
3029' dim strSOR
3030'
3031' strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
3032' strBody = strbody & vbcrlf & "Asset: " & AssetReference
3033' if len(AsbestosWarning) > 0 then
3034' strBody = strBody & AsbestosWarning
3035' end if
3036' strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
3037' strBody = strBody & vbcrlf & "Contractor: " & ContractorName
3038' strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
3039' strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
3040' strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
3041' strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
3042' strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
3043' strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
3044' strBody = strBody & vbcrlf & "Order Date: " & OrderDate
3045' strBody = strBody & vbcrlf & "Risk Code: " & RiskCode
3046' strBody = strBody & vbcrlf & "Job Type: " & JobType
3047' strBody = strBody & vbcrlf & "Priority: " & Priority
3048' strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
3049' strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
3050' strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
3051' strBody = strBody & vbcrlf & vbcrlf & '"======================================================================================================="
3052
3053' 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)
3054' with sqlconnection.execute(strCommand)
3055' do until .eof
3056' strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
3057' for lngLines = 0 to ubound(strSOR)
3058' if lngLines = 0 then
3059' if isnull(.fields(0)) then
3060' strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
3061' else
3062' strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & 'strsor(lngLines)
3063' end if
3064' strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
3065' strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
3066' else
3067' strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
3068' end if
3069' next
3070' dblTotal = dblTotal + .fields(3)
3071' .movenext
3072' loop
3073' end with
3074
3075' strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
3076
3077' strBody = strBody & vbcrlf & vbcrlf & '"======================================================================================================="
3078
3079' strBody = strBody & vbcrlf & vbcrlf & vbcrlf
3080
3081' strEmailAddress = GetContractorEmailAddress(Contractor)
3082
3083' msgbox strBody,vbexclamation+vbokonly,"Email should be this"
3084
3085' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & 'ConfirmationOrder,"ActiveHWO@raglan.org",strEmailAddress,"","ActiveHWO@raglan.org",strBody,"",""
3086
3087'End Function'
3088
3089'NEW VERSION - RS 06 AUG 2008'
3090Function SendEmailToContractorOldVersion(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,RiskCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning)
3091
3092 dim strBody
3093 dim strEmailAddress
3094 dim strCommand
3095 dim dblTotal
3096 dim lngLines
3097 dim strSOR
3098
3099 strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
3100 strBody = strbody & vbcrlf & "Request ID: " & RequestID
3101 strBody = strbody & vbcrlf & "Asset: " & AssetReference
3102 if len(AsbestosWarning) > 0 then
3103 strBody = strBody & vbcrlf & AsbestosWarning
3104 end if
3105 strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
3106 strBody = strBody & vbcrlf & "Contractor: " & ContractorName
3107 strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
3108 strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
3109 strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
3110 strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
3111 strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
3112 strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
3113 strBody = strBody & vbcrlf & "Order Date: " & OrderDate
3114 strBody = strBody & vbcrlf & "Risk Code: " & RiskCode
3115 strBody = strBody & vbcrlf & "Job Type: " & JobType
3116 strBody = strBody & vbcrlf & "Priority: " & Priority
3117 strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
3118 strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
3119 strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
3120 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
3121
3122 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)
3123 with sqlconnection.execute(strCommand)
3124 do until .eof
3125 strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
3126 for lngLines = 0 to ubound(strSOR)
3127 if lngLines = 0 then
3128 if isnull(.fields(0)) then
3129 strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
3130 else
3131 strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
3132 end if
3133 strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
3134 strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
3135 strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
3136
3137 else
3138 strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
3139 end if
3140 next
3141 dblTotal = dblTotal + .fields(3)
3142 .movenext
3143 loop
3144 end with
3145
3146 strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
3147
3148 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
3149
3150 strBody = strBody & vbcrlf & vbcrlf & vbcrlf
3151
3152 strEmailAddress = GetContractorEmailAddress(Contractor)
3153
3154' msgbox strBody,vbexclamation+vbokonly,"Email should be this"
3155
3156 CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@raglan.org",strEmailAddress,"","ActiveHWO@raglan.org",strBody,"",""
3157
3158End Function
3159
3160
3161function GetOverdueTasksNotEscalated(OverdueDays)
3162 dim varSQLStatement
3163 dim varTasksToEscalate
3164
3165 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"
3166
3167 with sqlconnection.execute(varSQLStatement)
3168 do until .eof
3169 varTasksToEscalate = ListAppend(CStr(varTasksToEscalate),CStr(.Fields("Task_ID").Value))
3170 .movenext
3171 loop
3172 end with
3173 GetOverdueTasksNotEscalated = varTasksToEscalate
3174end function
3175
3176function GetOverdueTasksEscalated(OverdueDays)
3177 dim varSQLStatement
3178 dim varTasksToEscalate
3179
3180 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"
3181
3182 with sqlconnection.execute(varSQLStatement)
3183 do until .eof
3184 varTasksToEscalate = ListAppend(CStr(varTasksToEscalate),CStr(.Fields("Task_ID").Value))
3185 .movenext
3186 loop
3187 end with
3188 GetOverdueTasksEscalated = varTasksToEscalate
3189end function
3190
3191
3192Function CDOEMailUsingOutputAttach(Subject,From,Recipient,Cc,Bcc,Body,HTMLBody,AttachFilePath)
3193'
3194' This function allows generation of an email via Outlook
3195' with an optional attachment file if required
3196'
3197
3198 Dim objMessage, objConfiguration
3199
3200 Set objMessage = CreateObject("CDO.Message")
3201 Set objConfiguration = CreateObject("CDO.Configuration")
3202
3203 On Error Resume Next
3204
3205 objMessage.Subject = Subject
3206 objMessage.From = From
3207 objMessage.To = Recipient
3208 objMessage.Bcc = Bcc
3209 objMessage.Cc = Cc
3210 if len(Body) > 0 then
3211 objMessage.TextBody = Body
3212 else
3213 objMessage.HTMLBody = HTMLBody
3214 end if
3215 If Len(AttachFilePath) > 0 Then
3216 objMessage.AddAttachment AttachFilePath
3217 Else
3218 End If
3219
3220' Do not touch parameters below! unless you fully understand the implications
3221
3222 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
3223 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ragexcas1"
3224 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
3225 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "raglan\ActiveHSMS"
3226 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Opera09"
3227' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Housing Services Centre"
3228' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "opera09"
3229 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
3230 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 180
3231
3232 objConfiguration.Fields.Update
3233
3234 Set objMessage.Configuration = objConfiguration
3235
3236 objMessage.Send
3237
3238 Set objMessage = Nothing
3239
3240End Function
3241
3242Function CDOEMailUsingOutputAttachCopy(Subject,From,Recipient,Cc,Bcc,Body,HTMLBody,AttachFilePath)
3243'
3244' This function allows generation of an email via Outlook
3245' with an optional attachment file if required
3246'
3247
3248 Dim objMessage, objConfiguration
3249
3250 Set objMessage = CreateObject("CDO.Message")
3251 Set objConfiguration = CreateObject("CDO.Configuration")
3252
3253' On Error Resume Next
3254
3255 objMessage.Subject = Subject
3256 objMessage.From = From
3257 objMessage.To = Recipient
3258 objMessage.Bcc = Bcc
3259 objMessage.Cc = Cc
3260 if len(Body) > 0 then
3261 objMessage.TextBody = Body
3262 else
3263 objMessage.HTMLBody = HTMLBody
3264 end if
3265 If Len(AttachFilePath) > 0 Then
3266 objMessage.AddAttachment AttachFilePath
3267 Else
3268 End If
3269
3270' Do not touch parameters below! unless you fully understand the implications
3271
3272 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
3273 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ragexcas1"
3274 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
3275 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "raglan\ActiveHSMS"
3276 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Opera09"
3277' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Housing Services Centre"
3278' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "opera09"
3279 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
3280 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 180
3281
3282 objConfiguration.Fields.Update
3283
3284 Set objMessage.Configuration = objConfiguration
3285
3286 objMessage.Send
3287
3288 Set objMessage = Nothing
3289
3290End Function
3291
3292Function DeleteCSVFile(File)
3293 Dim fso
3294 set fso=CreateObject("Scripting.FileSystemObject")
3295 if fso.FileExists(File) then fso.DeleteFile File
3296End Function
3297
3298Function AnyRequestsOrTasksPresent(CallID)
3299 dim strStat
3300 dim lngReqCount
3301 dim lngTaskCount
3302
3303 dim blnClosed
3304 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
3305 with sqlconnection.execute(strStat)
3306 if not isnull(.fields(0)) then lngReqCount = .fields(0)
3307 if not isnull(.fields(1)) then lngTaskCount = .fields(1)
3308 end with
3309 AnyRequestsOrTasksPresent = lngReqCount > 0 OR lngTaskCount > 0
3310
3311 with sqlconnection.execute("SELECT Call_Status_ID From CRM_Calls_T with (nolock) WHERE Call_ID = " & CallID)
3312 if cstr(.fields(0)) = "59" or cstr(.fields(0)) = "60" then blnClosed = True
3313 end with
3314 if blnClosed then AnyRequestsOrTasksPresent = True
3315End Function
3316
3317Function NumberOfLines(Description,LengthOfItem)
3318 dim lngLength
3319 dim lngLines
3320 dim strResult
3321
3322 strResult = ReturnDelimitedText(replace(replace(Description,chr(10),""),chr(13)," "),LengthOfItem)
3323
3324 for lngLength = 1 to len(strResult)
3325 if mid(strResult,lngLength,1) = chr(13) then lngLines = lngLines + 1
3326 next
3327 NumberOfLines = lngLines + 1
3328End Function
3329
3330Function NumberOfLinesForSOR(Description)
3331 dim lngLength
3332 dim lngLines
3333 dim strResult
3334 strResult = ReturnDelimitedText(Description,47)
3335
3336 for lngLength = 1 to len(strResult)
3337 if mid(strResult,lngLength,1) = chr(13) then lngLines = lngLines + 1
3338 next
3339 NumberOfLinesForSOR = lngLines + 2
3340End Function
3341
3342Function ReturnDelimitedText(Text, Width)
3343
3344 Dim strResult
3345 Dim lngAnchor
3346 Dim lngTarget
3347 Dim blnContinue
3348 Dim strLine
3349 Dim lngLineIndex
3350 Dim astrLines(100)
3351 Dim strWord
3352 Dim strText
3353 Dim lngCharsLeft
3354 Dim blnNeedsASpace
3355 Dim lngNumLines
3356 Dim strPossibleNextBit
3357
3358 strText = Text
3359 If Len(Text) = 0 Then Exit Function
3360 lngLineIndex = 1
3361
3362 blnContinue = True
3363 Do
3364 'Extract next word
3365
3366 'Find out where the next space is
3367 lngTarget = InStr(strText, " ")
3368
3369 'Is there anything after this word?
3370 If lngTarget > 0 Then
3371
3372 'If so, grab the word and cut remaining text
3373 strWord = Left(strText, lngTarget - 1)
3374 strText = Mid(strText, lngTarget + 1)
3375 Else
3376
3377 'Otherwise, grab the last word and signal that we're about to stop this
3378 strWord = strText
3379 blnContinue = False
3380 End If
3381
3382 blnNeedsASpace = (strLine <> "")
3383
3384 'Find out what would happen if we added the next word to the
3385 'current line
3386 If blnNeedsASpace Then
3387 strPossibleNextBit = strLine & " " & strWord
3388 Else
3389 strPossibleNextBit = strWord
3390 End If
3391
3392 'Will the word (with a space) fit on this line?
3393 If Len(strPossibleNextBit) > Width Then
3394
3395 'If not, is the word longer than a line?
3396 If Len(strWord) > Width Then
3397
3398 'If so, chop it up.
3399 'Add a space if reqd.
3400 If blnNeedsASpace Then
3401 strLine = strLine & " "
3402 End If
3403
3404 'Find out how much we can find on the rest of this line
3405 lngCharsLeft = Width - Len(strLine)
3406
3407 'Add the chunk
3408 strLine = strLine & Left(strWord, lngCharsLeft)
3409 astrLines(lngLineIndex) = strLine
3410 lngLineIndex = lngLineIndex + 1
3411
3412 'Cut the remaining bits of the word up
3413 strWord = Mid(strWord, lngCharsLeft + 1)
3414
3415 'It is STILL too big to fit?
3416 If Len(strWord) > Width Then
3417
3418 'If so, we're gonna have to keep chopping it up
3419 Do
3420 astrLines(lngLineIndex) = Left(strWord, Width)
3421 lngLineIndex = lngLineIndex + 1
3422 strWord = Mid(strWord, Width + 1)
3423 Loop Until strWord = ""
3424 Else
3425
3426 'Otherwise, add the bit that's left
3427 astrLines(lngLineIndex) = strWord
3428 lngLineIndex = lngLineIndex + 1
3429 End If
3430
3431 strLine = ""
3432 Else
3433
3434 'Word is NOT longer than a line - add it to the next line
3435 astrLines(lngLineIndex) = strLine
3436 lngLineIndex = lngLineIndex + 1
3437 strLine = strWord
3438 End If
3439 Else
3440
3441 'If it will fit on this line, add it
3442 If blnNeedsASpace Then
3443 strLine = strLine & " " & strWord
3444 Else
3445 strLine = strWord
3446 End If
3447 End If
3448 Loop Until Not blnContinue
3449
3450 'Is there a bit left?
3451 If Len(strLine) > 0 Then
3452
3453 'If so, add it
3454 astrLines(lngLineIndex) = strLine
3455 lngNumLines = lngLineIndex
3456 Else
3457 lngNumLines = lngLineIndex - 1
3458 End If
3459
3460 For lngLineIndex = 1 To lngNumLines
3461 strResult = strResult & left(astrLines(lngLineIndex),width)
3462 If lngLineIndex < lngNumLines Then
3463 strResult = strResult & Chr(13) & Chr(10)
3464 End If
3465 Next
3466
3467 ReturnDelimitedText= strResult
3468End Function
3469
3470Function MailUsingOutputAttach(Subject,Recipient,Body,Username,AttachFilePath,Params)
3471'
3472' This function allows generation of an email via Outlook
3473' with an optional attachment file if required
3474'
3475 On Error resume Next:err.clear
3476 Dim objOutput
3477 Set objoutput = CreateObject("Output.CEmail")
3478 objoutput.Subject = Subject
3479 objoutput.ToList = Recipient
3480 objoutput.MessageText = Body
3481 objoutput.Username = Username
3482 If Len(AttachFilePath) > 0 Then
3483 objoutput.Attachment = AttachFilePath
3484 End If
3485 objoutput.password = ""
3486 objoutput.SendEmail
3487 Set objoutput = Nothing
3488End Function
3489
3490Function BuildTaskDescription(WorksOrderID, EstimatedValue, Narrative)
3491 dim strDesc
3492 dim strAsset
3493 dim strDate
3494 dim strAddressID
3495 dim strAddress
3496 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 & ")")
3497 if not .eof then
3498 strAsset = cstr(.fields(0))
3499 strDate = cstr(.fields(1))
3500 end if
3501 end with
3502 with sqlconnection.execute("SELECT Address_ID from Asset_Assets_T with (nolock) where Asset_ID = " & clng(strAsset))
3503 if not .eof then
3504 strAddressID = cstr(.fields(0))
3505 end if
3506 end with
3507 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)
3508 BuildTaskDescription = strDesc
3509End Function
3510
3511Function ValidateCostAccount(CostAccount)
3512 dim pos
3513 dim ca
3514 ValidateCostAccount = 0
3515 pos = instr(3,CostAccount,"-")
3516 ca = mid(CostAccount,pos+1,4)
3517 if ca = "5185" or ca = "9010" then ValidateCostAccount = 1
3518End Function
3519
3520
3521Function ReturnResultFromString(String1,String2,String3,String4)
3522 dim strResult
3523'-- Debug msgbox String1 & ", " & string2 & ", " & string3 & ", " & string4
3524 if len(String1) > 0 then
3525 strResult = String1
3526 end if
3527 if len(String2) > 0 then
3528 if len(strResult) = 0 then
3529 strResult = String2
3530 else
3531 strResult = strResult & vbcrlf & vbcrlf & String2
3532 end if
3533 end if
3534 if len(String3) > 0 then
3535 if len(strResult) = 0 then
3536 strResult = String3
3537 else
3538 strResult = strResult & vbcrlf & vbcrlf & String3
3539 end if
3540 end if
3541 if len(String4) > 0 then
3542 if len(strResult) = 0 then
3543 strResult = String4
3544 else
3545 strResult = strResult & vbcrlf & vbcrlf & String4
3546 end if
3547 end if
3548'-- Debug msgbox strResult
3549 ReturnResultFromString = Sentence(strResult)
3550End Function
3551
3552function Sentence(Word)
3553 dim strResult
3554 dim lng
3555 dim strLast
3556 dim strChar
3557 for lng = 1 to len(Word)
3558 if len(strLast) = 0 or strLast = " " or strLast = ":" or strLast = "'" or strlast = vblf or strLast = "(" then
3559 strChar = ucase(mid(word,lng,1))
3560 else
3561 strChar = lcase(mid(word,lng,1))
3562 end if
3563 if len(strResult) = 0 then
3564 strResult = strChar
3565 else
3566 strResult = strResult & strChar
3567 end if
3568 strLast = mid(Word,lng,1)
3569 next
3570 Sentence = strResult
3571end function
3572
3573Function BuildOutputForRHA_CRM_Display_Panels(Remarks,HousingOfficer_ID,Inspector_ID, Round_ID,LettingArea_ID,Principal_Surveyor)
3574
3575 dim strResult
3576 dim blnPad
3577 if isnull(Remarks) then Remarks = vbnullstring
3578 if isnull(HousingOfficer_ID) then HousingOfficer_ID = 0
3579 if isnull(Inspector_ID) then Inspector_ID = 0
3580 if isnull(Round_ID) then Round_ID = 0
3581 if isnull(LettingArea_ID) then LettingArea_ID = 0
3582 if isnull(Principal_Surveyor) then Principal_Surveyor = 0
3583
3584
3585' --Debug msgbox "HousingOfficer = " & HousingOfficer_ID
3586 if len(HousingOfficer_ID) > 0 then
3587 if len(strResult) = 0 then
3588 strResult = "Housing Officer: " & GetDescriptionForCode(HousingOfficer_ID)
3589 end if
3590 end if
3591' --Debug msgbox "Inspector = " & Inspector_ID
3592 if len(Inspector_ID) > 0 then
3593 if len(strResult) = 0 then
3594 '-- strResult = "Inspector:" & GetInspectorNameFromCode(Inspector_ID)
3595 strResult = "Repairs Surveyor: " & GetInspectorNameFromCode(Inspector_ID)
3596 else
3597 if blnpad then
3598 strResult = strResult & vbcrlf & "Repairs Surveyor: " & GetInspectorNameFromCode(Inspector_ID)
3599 blnpad = false
3600 else
3601 strResult = strResult & vbcrlf & "Repairs Surveyor: " & GetInspectorNameFromCode(Inspector_ID)
3602 end if
3603 end if
3604 end if
3605' --Debug msgbox "Round = " & Round_ID
3606 if len(Round_ID) > 0 then
3607 if len(strResult) = 0 then
3608 '--strResult = "Round:" & GetDescriptionForCode(Round_ID)
3609 strResult = "Rent Setting Officer: " & GetDescriptionForCode(Round_ID)
3610 else
3611 if blnpad then
3612 strResult = strResult & vbcrlf & "Rent Setting Officer: " & GetDescriptionForCode(Round_ID)
3613 blnPad = false
3614 else
3615 strResult = strResult & vbcrlf & "Rent Setting Officer: " & GetDescriptionForCode(Round_ID)
3616 end if
3617 end if
3618 end if
3619' --Debug msgbox "LettingArea = " & LettingArea_ID
3620 if len(LettingArea_ID) > 0 then
3621 if len(strResult) = 0 then
3622 '--strResult = "Letting Area:" & GetDescriptionForCode(LettingArea_ID)
3623 strResult = "Regional Housing Manager: " & GetDescriptionForCode(LettingArea_ID)
3624 else
3625 if blnPad then
3626 strResult = strResult & vbcrlf & "Regional Housing Manager: " & GetDescriptionForCode(LettingArea_ID)
3627 blnpad = false
3628 else
3629 strResult = strResult & vbcrlf & "Regional Housing Manager: " & GetDescriptionForCode(LettingArea_ID)
3630 end if
3631 end if
3632 end if
3633' --Debug msgbox "Principal Surveyor = " & Principal_Surveyor
3634 if len(Principal_Surveyor) > 0 then
3635 if len(strResult) = 0 then
3636 '--strResult = "Principal Surveyor:" & GetDescriptionForCode(Principal_Surveyor)
3637 strResult = "Planned Works Surveyor: " & GetDescriptionForCode(Principal_Surveyor)
3638 else
3639 strResult = strResult & vbcrlf & "Planned Works Surveyor: " & GetDescriptionForCode(Principal_Surveyor)
3640 end if
3641 end if
3642 if len(remarks) > 0 then
3643 strResult = strResult & vbcrlf & vbcrlf & Remarks
3644 blnPad = True
3645 end if
3646 BuildOutputForRHA_CRM_Display_Panels = Sentence(strResult)
3647end function
3648
3649function GetRisk(Contact_ID)
3650 dim strResult
3651 with sqlconnection.execute("SELECT USR_Panel1_Risk_IN FROM usr_Contact_Contacts_UDE_1_T with (nolock) WHERE SYS_Parent_Link_ID = " & Contact_ID)
3652 do until .eof
3653 if not isnull(.fields(0)) then
3654 strResult = GetDescriptionForUserCode(.fields(0))
3655 end if
3656 .movenext
3657 loop
3658 end with
3659 GetRisk = strResult
3660end function
3661
3662function GetVulnerabilitiesForContact(Contact_ID)
3663 dim strResult
3664 dim strRisk
3665 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)
3666 do until .eof
3667 if len(strResult) = 0 then
3668 strResult = "Vulnerability:" & GetDescriptionForCode( .fields(0))
3669 else
3670 strResult = strResult & "," & GetDescriptionForCode(.fields(0))
3671 end if
3672 .movenext
3673 loop
3674 end with
3675 strRisk = GetRisk(Contact_ID)
3676 if len(strRisk) > 0 then
3677 if len(strResult) > 0 then
3678 strResult = strResult & vbcrlf & vbcrlf & strRisk
3679 else
3680 strResult = strRisk
3681 end if
3682 end if
3683 GetVulnerabilitiesForContact = Sentence(strResult)
3684end function
3685
3686function GetInspectorNameFromCode(Inspector_ID)
3687 dim strStatement
3688 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"
3689 with sqlconnection.execute( replace(strStatement,"%1",Inspector_ID))
3690 do until .eof
3691 GetInspectorNameFromCode = sentence(.fields(0))
3692 .movenext
3693 loop
3694 end with
3695end function
3696
3697function GetDescriptionForCode(Code_ID)
3698
3699 with sqlconnection.execute("Select Description_VC from Shared_Codes_T with (nolock) WHERE Code_ID = " & Code_ID)
3700 do until .eof
3701 GetDescriptionForCode = sentence(.fields(0))
3702 .movenext
3703 loop
3704 end with
3705
3706end function
3707
3708function GetDescriptionForUserCode(Code_ID)
3709
3710 with sqlconnection.execute("Select Description_VC from Shared_User_Defined_Codes_T with (nolock) WHERE Code_ID = " & Code_ID)
3711 do until .eof
3712 GetDescriptionForUSerCode = sentence(.fields(0))
3713 .movenext
3714 loop
3715 end with
3716
3717end function
3718
3719
3720Function ShowLookup
3721
3722 dim Lookup
3723 set Lookup = CreateObject("SQLSearchDialog.CSQLSearch")
3724 set Lookup.SqlUtil = SQLUtilities
3725
3726 Lookup.LookupCaption = "Lookup from workflow"
3727 Lookup.LKUPItem = 178
3728 Lookup.ShowSearchDialog vbNullstring,vbnullstring
3729 if len(mid(Lookup.SelectedItems.value,3)) > 0 then
3730 ShowLookup = mid(Lookup.SelectedItems.Value,3)
3731 else
3732 ShowLookup = 0
3733 end if
3734 set lookup = nothing
3735
3736end function
3737
3738function GetEmailAddress(User)
3739 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)
3740 do until .eof
3741 GetEmailAddress = .fields(0)
3742 .movenext
3743 loop
3744 end with
3745end function
3746
3747'Post Inspections
3748Function InspectionRandomSelector(varPercentage)
3749Rem Version 1.0 24th November 2005 AMS/CAP
3750varSelect = "SELECT COUNT(*) AS Counter FROM Repairs_Works_Orders_T with (nolock) WHERE Status_ID = 15"
3751varDummy = ""
3752With SQLConnection.Execute(varSelect)
3753Do Until .EOF
3754 varCounter = .Fields("Counter").Value
3755 .MoveNext
3756Loop
3757End With
3758varTmpCheck = varCounter * varPercentage
3759varTmpCheck2 = Int(varCounter * varPercentage)
3760If varTmpCheck = varTmpCheck2 Then
3761InspectionRandomSelector = 1
3762Else
3763InspectionRandomSelector = 0
3764End If
3765End Function
3766
3767Function CreateFileWithHeaderIfNotExists(File,Header)
3768 Dim fso
3769 Dim txtstream
3770 set fso=CreateObject("Scripting.FileSystemObject")
3771 if not(fso.FileExists(File)) Then
3772 set txtstream=fso.OpenTextFile(File, 8, True)
3773 txtstream.Write Header
3774 txtstream.Close
3775 end if
3776End Function
3777
3778Function OutputToCSVFile(File,Line)
3779 Dim fso
3780 Dim txtstream
3781 set fso=CreateObject("Scripting.FileSystemObject")
3782 set txtstream=fso.OpenTextFile(File, 8, True)
3783 txtstream.Write Line
3784 txtstream.Close
3785End Function
3786
3787sub showassetinfo(record)
3788 msgbox record
3789end sub
3790
3791function Increase(Counter)
3792 Increase = Counter + 1
3793end function
3794
3795function CountDelimiter(ItemToCount,Delimiter)
3796 dim lngCount
3797 dim lngResult
3798 for lngcount =1 to len(itemtocount)
3799 if mid(itemtocount,lngcount,len(Delimiter)) = Delimiter then
3800 lngResult = lngResult + 1
3801 end if
3802 next
3803 if lngResult = 0 and len(itemtocount) > 0 then lngResult = 1
3804 CountDelimiter = lngResult
3805end function
3806
3807Function IsConnectionActive
3808 dim varSelect
3809 sqlConnection.Open
3810 varselect = "SELECT TOP 1 From Shared_Codes_T with (nolock)"
3811 with sqlConnection.Execute(varSelect)
3812 do until .eof
3813 msgbox .fields(0)
3814 .movenext
3815 loop
3816 end with
3817 sqlConnection.Close
3818end function
3819
3820function Input(caption)
3821 Input = inputbox(caption)
3822end function
3823
3824function MultiplyTogether(a,b)
3825 MultiplyTogether = a*b
3826end function
3827
3828Function Notamsgbox( DebugMessage)
3829End Function
3830
3831Function WriteToFile(FileName, FileText)
3832
3833 dim fsMMSystem
3834 dim tsMMFile
3835
3836 Set fsMMSystem = Createobject("Scripting.FileSystemObject")
3837 Set tsMMFile = fsMMSystem.CreateTextFile(FileName, True)
3838
3839 tsMMFile.Write FileText
3840 tsMMFile.Close
3841
3842 Set tsMMFile = Nothing
3843 Set fsMMSystem = Nothing
3844
3845end function
3846
3847
3848function ZetafaxText(FaxNumber, FaxPerson, FaxOrganisation, FromPerson, FromOrganisation, FaxBody, FaxLetterHead, FaxServerLocation, FaxName)
3849
3850 Dim strFaxHeader
3851 dim strFaxBody
3852
3853 strFaxHeader = "[Details]" & vbCrLf
3854 strFaxHeader = strFaxHeader & "DestFaxNumber=" & FaxNumber & vbCrLf
3855 strFaxHeader = strFaxHeader & "DestPerson=" & FaxPerson & vbCrLf
3856 strFaxHeader = strFaxHeader & "DestOrganisation=" & FaxOrganisation & vbCrLf
3857 strFaxHeader = strFaxHeader & "SourcePerson=" & FromPerson & vbCrLf
3858 strFaxHeader = strFaxHeader & "SourceDepartment=" & FromOrganisation & vbCrLf
3859
3860 'if ini file specifies a letter head then tell Zetafax to use it!
3861 If Len(FaxLetterHead) > 0 Then
3862 strFaxHeader = strFaxHeader & "Letterhead=" & FaxLetterHead
3863 End If
3864
3865 strFaxBody = vbCrLf & "[Fax]" & vbCrLf & FaxBody
3866
3867 WriteToFile FaxServerLocation & "\" & FaxName, strFaxHeader & strFaxBody
3868
3869 ZetafaxText = true
3870
3871End Function
3872
3873
3874' End of MIS Family HA Functions
3875
3876
3877Function WriteToFile(FileName, FileText)
3878
3879 dim fsMMSystem
3880 dim tsMMFile
3881
3882 Set fsMMSystem = Createobject("Scripting.FileSystemObject")
3883 Set tsMMFile = fsMMSystem.CreateTextFile(FileName, True)
3884
3885 tsMMFile.Write FileText
3886 tsMMFile.Close
3887
3888 Set tsMMFile = Nothing
3889 Set fsMMSystem = Nothing
3890
3891end function
3892
3893function GetJobType(OrderID)
3894 dim strJobType
3895 dim strExec
3896 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"
3897 strExec = strExec & " RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RRTL.SystemUplift_BT = 0 AND RWOL.WorksOrder_ID = " & OrderID
3898 with SQLConnection.execute(strExec)
3899 do until .eof
3900 strJobType = .fields(0)
3901 exit do
3902 loop
3903 end with
3904 GetJobType = GetDescriptionForCode(strJobType)
3905end function
3906
3907function GetDescriptionForCode(Code)
3908 with SQLConnection.execute("SELECT Description_VC from Shared_Codes_T with (nolock) WHERE Code_ID = " & Code)
3909 do until .eof
3910 GetDescriptionForCode = .fields(0)
3911 exit do
3912 loop
3913 end with
3914end function
3915
3916function GetPriority(OrderID)
3917 dim strPriority
3918 dim strExec
3919 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"
3920 strExec = strExec & " RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RWOL.WorksOrder_ID = " & OrderID
3921 with SQLConnection.execute(strExec)
3922 do until .eof
3923 strPriority = .fields(0)
3924 exit do
3925 loop
3926 end with
3927 GetPriority = GetPriorityDescription(strPriority)
3928end function
3929
3930function GetPriorityDesc(OrderID)
3931'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
3932 dim strPriority
3933 dim strExec
3934 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"
3935 with SQLConnection.execute(strExec)
3936 do until .eof
3937 strPriority = .fields(0)
3938 exit do
3939 loop
3940 end with
3941 GetPriorityDesc = strPriority
3942end function
3943
3944function GetPriorityDescription(PriorityCode)
3945 with SQLConnection.execute("SELECT Description_VC from Shared_Priorities_T with (nolock) WHERE Code_ID = " & PriorityCode)
3946 do until .eof
3947 GetPriorityDescription = .fields(0)
3948 exit do
3949 loop
3950 end with
3951end function
3952
3953function GetAssetAddress(AddressID)
3954 dim strNumberName
3955 dim strPremisName
3956 dim strStreet
3957 dim strAreaDistrict
3958 dim strTownCity
3959 dim strCounty
3960 dim strCountry
3961 dim strPostcode
3962 with sqlconnection.execute("SELECT * From Shared_Addresses_T with (nolock) WHERE Address_ID = " & AddressID)
3963 do until .eof
3964 if isnull(.fields("Property_Number_or_Name_VC")) then
3965 strNumberName = vbnullstring
3966 else
3967 strNumberName = .fields("Property_Number_or_Name_VC")
3968 end if
3969 if isnull(.fields("Property_or_Premises_Name_VC")) then
3970 strPremisName = vbnullstring
3971 else
3972 strPremisName = .fields("Property_or_Premises_Name_VC")
3973 end if
3974 if isnull(.fields("Street_VC")) then
3975 strStreet = vbnullstring
3976 else
3977 strStreet = .fields("Street_VC")
3978 end if
3979 if isnull(.fields("District_VC")) then
3980 strAreaDistrict = vbnullstring
3981 else
3982 strAreaDistrict = .fields("District_VC")
3983 end if
3984 if isnull(.fields("Town_VC")) then
3985 strTownCity = vbnullstring
3986 else
3987 strTownCity = .fields("Town_VC")
3988 end if
3989 if isnull(.fields("County_VC")) then
3990 strCounty = vbnullstring
3991 else
3992 strCounty = .fields("County_VC")
3993 end if
3994 if isnull(.fields("Country_VC")) then
3995 strCountry = vbnullstring
3996 else
3997 strCountry = .fields("Country_VC")
3998 end if
3999 if isnull(.fields("Postcode_VC")) then
4000 strPostcode = vbnullstring
4001 else
4002 strPostcode = .fields("Postcode_VC")
4003 end if
4004 exit do
4005 loop
4006 end with
4007 with sqlConnection.execute("SELECT dbo.fn_USR_FormatAddressAligned ('" & replace(strNumberName,"'","''") & "','" & replace(strPremisName,"'","''") & "','" & replace(strStreet,"'","''") & "','" & replace(strAreaDistrict,"'","''") & "','" & replace(strTownCity,"'","''") & "','" & replace(strCounty,"'","''") & "','" & strCountry & "')")
4008 if len(strPostCode) > 0 then
4009 GetAssetAddress = replace(.fields(0) & chr(13) & strPostcode,chr(13),chr(13) & chr(10))
4010 else
4011 GetAssetAddress = replace(.fields(0),chr(13),chr(13) & chr(10))
4012 end if
4013 end with
4014end function
4015
4016function GetGroupHomeNumber(GroupID)
4017 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")
4018 do until .eof
4019 GetGroupHomeNumber = .fields(0)
4020 exit do
4021 loop
4022 end with
4023end function
4024
4025function GetContactWorkNumber(ContactID,NumberID)
4026 with sqlconnection.execute("SELECT Reference_VC from Contact_Contact_Details_T with (nolock)WHERE Contact_ID = " & ContactId & " and SYS_Number_Code_ID = " & NumberID)
4027 do until .eof
4028 GetContactWorkNumber = .fields(0)
4029 exit do
4030 loop
4031 end with
4032end function
4033
4034function GetContactNumber(GroupID,NumberID)
4035 with sqlconnection.execute("SELECT Reference_VC from Contact_Group_Details_T with (nolock) WHERE Group_ID = " & GroupId & " and SYS_Number_Code_ID = " & NumberID)
4036 do until .eof
4037 GetContactNumber = .fields(0)
4038 exit do
4039 loop
4040 end with
4041end function
4042
4043function GetContactName(ContactID)
4044 with sqlconnection.execute("SELECT Formatted_Name_VC from Contact_Contacts_T with (nolock) WHERE Contact_ID = " & ContactID)
4045 do until .eof
4046 GetContactName = .fields(0)
4047 exit do
4048 loop
4049 end with
4050end function
4051
4052function GetContactMobileNumber(ContactID)
4053 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)
4054 do until .eof
4055 GetContactMobileNumber = .fields(0)
4056 exit do
4057 loop
4058 end with
4059end function
4060
4061Function GetContractorEmailAddress(Contractor)
4062 dim strCommand
4063 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)
4064
4065
4066 with sqlConnection.execute(strCommand)
4067 if not .eof and not .bof then
4068 GetContractorEmailAddress = .fields(0)
4069 end if
4070 end with
4071End Function
4072
4073Function GetPreferredContactMethod(Contractor)
4074' 11 = Fax
4075 dim lngResult
4076 dim strCommand
4077 strCommand = "SELECT USR_Panel2_Works_Order_Delivery_Method_IN FROM usr_Repairs_Contractors_UDE_1_T with (nolock) WHERE SYS_Parent_Link_ID = " & Contractor
4078
4079 with Sqlconnection.Execute(strCommand)
4080 if not .eof and not .bof then
4081 if not isnull(.fields(0)) then
4082 lngResult = .fields(0)
4083 end if
4084 end if
4085 end with
4086
4087GetPreferredContactMethod = lngResult
4088End Function
4089
4090function GetEstimatedCompletionDate(OrderID)
4091 with sqlconnection.execute("SELECT dbo.getEstCompletion(" & orderID & ")")
4092 do until .eof
4093 getEstimatedCompletionDate = .fields(0)
4094 .movenext
4095 loop
4096 end with
4097end function
4098
4099''#################Raglan CBL Listing WOrkflow v1.0##################
4100
4101FUNCTION CalculateSituationTransfer(Share,Under,Wheel,Supp,Med,Adapt,ShelNLR,Major,Racial,Sexual,OtherHar,Domestic,RagTemp,Except,AdaptNLR)
4102 CalculateSituationTransfer = "G"
4103 IF Share = "True" OR Under = "True" OR Wheel = "True" OR Med = 21 OR Adapt = "True" OR ShelNLR = "True" THEN
4104 CalculateSituationTransfer = "P"
4105 END IF
4106 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
4107 CalculateSituationTransfer = "U"
4108 END IF
4109END FUNCTION
4110
4111FUNCTION CalculateSituationApplicant(Reason,Share,Evict,Medical,Except)
4112 CalculateSituationApplicant = "G"
4113 SELECT CASE Reason
4114 CASE 24
4115 CalculateSituationApplicant = "P"
4116 CASE 25
4117 CalculateSituationApplicant = "P"
4118 CASE 28
4119 CalculateSituationApplicant = "P"
4120 CASE 32
4121 CalculateSituationApplicant = "P"
4122 CASE 33
4123 CalculateSituationApplicant = "P"
4124 CASE 34
4125 CalculateSituationApplicant = "P"
4126 CASE 36
4127 CalculateSituationApplicant = "P"
4128 CASE 37
4129 CalculateSituationApplicant = "P"
4130 CASE 38
4131 CalculateSituationApplicant = "U"
4132 CASE 39
4133 CalculateSituationApplicant = "U"
4134 CASE 40
4135 CalculateSituationApplicant = "U"
4136 CASE 42
4137 CalculateSituationApplicant = "P"
4138 CASE 43
4139 CalculateSituationApplicant = "U"
4140 CASE 44
4141 CalculateSituationApplicant = "P"
4142 END SELECT
4143 IF (Share = "True" OR Evict = "True" OR Medical = 21) AND CalculateSituationApplicant <> "U" THEN
4144 CalculateSituationApplicant = "P"
4145 END IF
4146 IF Medical = 22 OR Except = "True" THEN
4147 CalculateSituationApplicant = "U"
4148 END IF
4149END FUNCTION
4150
4151''################# RHA RS 06 June 2007 ##################
4152'FUNCTION SendEmailToContractorVariation(OrderID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,RiskCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning)
4153'
4154' dim strBody
4155' dim strEmailAddress
4156' dim strCommand
4157' dim dblTotal
4158' dim lngLines
4159' dim strSOR
4160'
4161' strBody = "VARIATION to Order Number: " & OrderID & " " & ConfirmationOrder
4162' strBody = strbody & vbcrlf & "Asset: " & AssetReference
4163' if len(AsbestosWarning) > 0 then
4164' strBody = strBody & AsbestosWarning
4165' end if
4166' strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
4167' strBody = strBody & vbcrlf & "Contractor: " & ContractorName
4168' strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
4169' strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
4170' strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
4171' strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
4172' strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
4173' strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
4174' strBody = strBody & vbcrlf & "Order Date: " & OrderDate
4175' strBody = strBody & vbcrlf & "Risk Code: " & RiskCode
4176' strBody = strBody & vbcrlf & "Job Type: " & JobType
4177' strBody = strBody & vbcrlf & "Priority: " & Priority
4178' strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
4179' strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
4180' strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
4181' strBody = strBody & vbcrlf & vbcrlf & '"======================================================================================================="
4182
4183' 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)
4184' with sqlconnection.execute(strCommand)
4185' do until .eof
4186' strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
4187' for lngLines = 0 to ubound(strSOR)
4188' if lngLines = 0 then
4189' if isnull(.fields(0)) then
4190' strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
4191' else
4192' strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & 'strsor(lngLines)
4193' end if
4194' strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
4195' strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
4196' else
4197' strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
4198' end if
4199' next
4200' dblTotal = dblTotal + .fields(3)
4201' .movenext
4202' loop
4203' end with
4204'
4205' strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
4206'
4207' strBody = strBody & vbcrlf & vbcrlf & '"======================================================================================================="
4208'
4209' strBody = strBody & vbcrlf & vbcrlf & vbcrlf
4210'
4211' strEmailAddress = GetContractorEmailAddress(Contractor)
4212'
4213'' msgbox strBody,vbexclamation+vbokonly,"Email should be this"
4214'
4215' CDOEmailUsingOutputAttach "Variation to Works Order " & OrderID & " " & 'ConfirmationOrder,"ActiveHWO@raglan.org",strEmailAddress,"","ActiveHWO@raglan.org",strBody,"",""
4216'
4217'End Function
4218
4219'NEW VERSION - RS 06 AUG 2008
4220'Amendment 26/11/2015 - added additional variables at start, assigned values to variables and changed from CDOMail to SQLMail
4221Function SendEmailToContractorVariation(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,RiskCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning)
4222
4223 dim strBody
4224 dim strEmailAddress
4225 dim strCommand
4226 dim dblTotal
4227 dim lngLines
4228 dim strSOR
4229 dim strProfile '- 26/11/2015
4230 dim strFromaddress '- 26/11/2015
4231 dim strCCaddress '- 26/11/2015
4232 dim strBCCaddress '- 26/11/2015
4233 dim strSubject '- 26/11/2015
4234
4235
4236 strBody = "VARIATION to Order Number: " & OrderID & " " & ConfirmationOrder
4237strBody = strbody & vbcrlf & "Request ID: " & RequestID
4238 strBody = strbody & vbcrlf & "Asset: " & AssetReference
4239 if len(AsbestosWarning) > 0 then
4240 strBody = strBody & vbcrlf & AsbestosWarning
4241 end if
4242 strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
4243 strBody = strBody & vbcrlf & "Contractor: " & ContractorName
4244 strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
4245 strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
4246 strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
4247 strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
4248 strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
4249 strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
4250 strBody = strBody & vbcrlf & "Order Date: " & OrderDate
4251 strBody = strBody & vbcrlf & "Risk Code: " & RiskCode
4252 strBody = strBody & vbcrlf & "Job Type: " & JobType
4253 strBody = strBody & vbcrlf & "Priority: " & Priority
4254 strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
4255 strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
4256 strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
4257 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
4258
4259 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)
4260 with sqlconnection.execute(strCommand)
4261 do until .eof
4262 strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
4263 for lngLines = 0 to ubound(strSOR)
4264 if lngLines = 0 then
4265 if isnull(.fields(0)) then
4266 strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
4267 else
4268 strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
4269 end if
4270 strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
4271 strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
4272 strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
4273
4274 else
4275 strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
4276 end if
4277 next
4278 dblTotal = dblTotal + .fields(3)
4279 .movenext
4280 loop
4281 end with
4282
4283 strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
4284
4285 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
4286
4287 strBody = strBody & vbcrlf & vbcrlf & vbcrlf
4288
4289 strEmailAddress = GetContractorEmailAddress(Contractor) ' - retrieve email from contractor
4290
4291 strFromaddress = "activeH.WO@stonewater.org"
4292 strCCaddress = ""
4293 strBCCaddress = "activeH.WO@stonewater.org;stonewaterworksorders@gmail.com;dan.garbett@stonewater.org.uk"
4294 strSubject = "Works Order " & OrderID
4295 strProfile = "ContractorEmails"
4296
4297
4298 'msgbox "DEBUG - Sending to SendEmailSQL"
4299 'msgbox "Body = " & strBody
4300 'msgbox "EmailAddress - " & strEmailAddress & vbcrlf & "FromAddress - " & strFromaddress & vbcrlf & "CCAddress - " & strCCaddress & vbcrlf & "BCCAdress - " & strBCCaddress & vbcrlf & "Subject - " & strSubject & vbcrlf & "Body - " & left(strBody,20) & vbcrlf & "Mail Profile - " & strProfile
4301
4302 SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
4303
4304 'msgbox "DEBUG - Returned from SendEmailSQL"
4305
4306' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",strEmailAddress,"","ActiveH.WO@stonewater.org;stonewaterworksorders@gmail.com",strBody,"",""
4307
4308End Function
4309
4310
4311
4312function RHA_GetOtherTelNumberForContact(Contact_ID)
4313 dim strResult
4314 with sqlconnection.execute("SELECT OtherTel FROM RHA_CRM_Caller_Panel_OtherTel_V with (nolock) WHERE Group_Contact_ID = " & Contact_ID)
4315 do until .eof
4316 if len(strResult) = 0 then
4317 strResult = "Other Tel: " & ( .fields(0))
4318 else
4319 strResult = strResult & ","
4320 end if
4321 .movenext
4322 loop
4323 end with
4324 RHA_GetOtherTelNumberForContact = Sentence(strResult)
4325end function
4326
4327Function ReturnResultFromStringNoLineSpaces(String1,String2,String3,String4)
4328 dim strResult
4329'-- Debug msgbox String1 & ", " & string2 & ", " & string3 & ", " & string4
4330 if len(String1) > 0 then
4331 strResult = String1
4332 end if
4333 if len(String2) > 0 then
4334 if len(strResult) = 0 then
4335 strResult = String2
4336 else
4337 strResult = strResult & vbcrlf & String2
4338 end if
4339 end if
4340 if len(String3) > 0 then
4341 if len(strResult) = 0 then
4342 strResult = String3
4343 else
4344 strResult = strResult & vbcrlf & String3
4345 end if
4346 end if
4347 if len(String4) > 0 then
4348 if len(strResult) = 0 then
4349 strResult = String4
4350 else
4351 strResult = strResult & vbcrlf & String4
4352 end if
4353 end if
4354'-- Debug msgbox strResult
4355 ReturnResultFromStringNoLineSpaces = Sentence(strResult)
4356End Function
4357
4358function GetNewPriority(OrderID)
4359 dim strPriority
4360 dim strExec
4361 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"
4362 strExec = strExec & " RRTL.RequestLine_ID = RWOL.RequestTaskLine_ID WHERE RWOL.WorksOrder_ID = " & OrderID & " AND (NOT (RWOL.Status_ID IN ('27','28','29')))"
4363 with SQLConnection.execute(strExec)
4364 do until .eof
4365 strPriority = .fields(0)
4366 exit do
4367 loop
4368 end with
4369 GetNewPriority = GetPriorityDescription(strPriority)
4370end function
4371
4372Function NewTenancyTracker(VarAccountID)
4373
4374Rem Version 1.0 08 APR 2008 RS
4375
4376 varSelect = "INSERT INTO RHA_NewTenancyTracker (ID) VALUES (" & varAccountID & ")"
4377
4378 With SQLConnection.Execute(varSelect)
4379 End With
4380
4381End Function
4382
4383function RHA_SendEmailToDefectsAgent (OrderID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,RiskCode,JobType,Priority,EstimatedCompletion,ConfirmationOrder,AsbestosWarning,EmailAddress)
4384
4385 dim strBody
4386 dim strEmailAddress
4387 dim strCommand
4388 dim dblTotal
4389 dim lngLines
4390 dim strSOR
4391 dim strProfile '- 26/11/2015
4392 dim strFromaddress '- 26/11/2015
4393 dim strCCaddress '- 26/11/2015
4394 dim strBCCaddress '- 26/11/2015
4395 dim strSubject '- 26/11/2015
4396
4397 strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
4398 strBody = strbody & vbcrlf & "Asset: " & AssetReference
4399 if len(AsbestosWarning) > 0 then
4400 strBody = strBody & AsbestosWarning
4401 end if
4402 strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
4403 strBody = strBody & vbcrlf & "Contractor: " & ContractorName
4404 strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
4405 strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
4406 strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
4407 strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
4408 strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
4409 strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
4410 strBody = strBody & vbcrlf & "Order Date: " & OrderDate
4411 strBody = strBody & vbcrlf & "Risk Code: " & RiskCode
4412 strBody = strBody & vbcrlf & "Job Type: " & JobType
4413 strBody = strBody & vbcrlf & "Priority: " & Priority
4414 strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
4415 strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
4416 strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
4417 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
4418
4419 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)
4420 with sqlconnection.execute(strCommand)
4421 do until .eof
4422 strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
4423 for lngLines = 0 to ubound(strSOR)
4424 if lngLines = 0 then
4425 if isnull(.fields(0)) then
4426 strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
4427 else
4428 strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
4429 end if
4430 strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
4431 strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
4432 else
4433 strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
4434 end if
4435 next
4436 dblTotal = dblTotal + .fields(3)
4437 .movenext
4438 loop
4439 end with
4440
4441 strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
4442
4443 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
4444
4445 strBody = strBody & vbcrlf & vbcrlf & vbcrlf
4446
4447 strEmailAddress = EmailAddress
4448
4449 strFromaddress = "ActiveH.WO@Stonewater.org"
4450 strCCaddress = ""
4451 strBCCaddress = "ActiveH.WO@stonewater.org"
4452 strSubject = "Works Order " & OrderID
4453 strProfile = "ContractorEmails"
4454
4455 SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
4456
4457' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",strEmailAddress,"","ActiveHWO@stonewater.org",strBody,"",""
4458
4459End Function
4460
4461Function AssetDisposedCheck(AssetID)
4462'RHA RS 19 AUG 2008 - Replacement Function to Check for disposed status.
4463 dim strCommand
4464 strCommand = "select dbo.fn_AssetStatus(" & AssetID & ", getdate()) as Status, Effective_Date_DT from Asset_Asset_Status_T with (nolock) Where Asset_ID = " & AssetID
4465 with sqlconnection.execute(strCommand)
4466 if not .eof and not .bof then
4467 if .fields(0).Value = "Disposed" then
4468 msgbox "This asset was disposed on " & .fields(1).Value,vbexclamation+vbokonly,"Disposed"
4469 AssetDisposedCheck = True
4470 else
4471 AssetDisposedCheck = False
4472 end if
4473 end if
4474 .close
4475 end with
4476End Function
4477
4478'*****DO NOT USE THIS VERSION UNTIL 581 GO LIVE*****
4479Function AssetDisposedCheckv2(AssetID)
4480'RHA RS 19 AUG 2008 - Replacement Function to Check for disposed status.
4481'RHA KS 08 MAY 2010 - cleaned function up so it just uses the SQL function, table Asset_Asset_Status_t has
4482' been removed in 580
4483 dim strCommand
4484 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"
4485 with sqlconnection.execute(strCommand)
4486 if not .eof and not .bof then
4487 if .fields(0).Value = "Disposed" then
4488 msgbox "This asset was disposed on " & .fields(1).Value, vbexclamation+vbokonly, "Disposed"
4489 AssetDisposedCheckv2 = TRUE
4490 else
4491 AssetDisposedCheckv2 = False
4492 end if
4493 end if
4494 .close
4495 end with
4496End Function
4497
4498Function BuildTmpTablesForPartnersWF
4499'RHA RS 07 Oct 2008
4500'RHA RS 10 DEC 2008 Added REPLACE Command to remove the ' character from the addresses.
4501 dim strCommand
4502 dim varLastRunDate
4503 dim varNewRunDate
4504 dim strWorkOrderID
4505 dim strAssetID
4506 dim strAddress
4507 dim strContractorPatch
4508 dim strDateAdded
4509 dim strHierarchyID
4510 dim strGroupName
4511 dim nonAccess
4512
4513'Update the LastRunTime Table
4514 with sqlconnection.execute("set dateformat dmy insert into RHA_Repairs_Partnering_Manual_Hook_T(LastRunTime) VALUES (getdate())")
4515 end with
4516
4517'Build the Tenent Recharge Table
4518 with sqlconnection.execute("SET DATEFORMAT DMY select WorksOrder_ID,Address from RHA_Repairs_TenentRechargePartners_V (nolock) WHERE ((DateTime_DT > '" & varLastRunDate & "') AND (DateTime_DT <= '" & varNewRunDate & "'))")
4519 'msgbox varNewRunDate,vbexclamation+vbokonly,"TENENT RECHARGE Post Select"
4520 Do Until .EOF
4521 strWorkOrderID = .fields(0)
4522 strAddress = .fields(1)
4523 strAddress = REPLACE(strAddress, "'","")
4524
4525 strCommand = "insert into RHA_Temp_Recharges_T(WorksOrderID,Address) VALUES ('" & strWorkOrderID & "','" & strAddress & "')"
4526 with sqlconnection.execute(strCommand)
4527 end with
4528 .MoveNext
4529 LOOP
4530 end with
4531
4532'Build the Insurance Reclaim Table
4533 with sqlconnection.execute("set dateformat dmy select WorksOrder_ID,Address from RHA_Repairs_InsuranceReclaimPartners_V (nolock) WHERE ((DateTime_DT > '" & varLastRunDate & "') AND (DateTime_DT <= '" & varNewRunDate & "'))")
4534 Do Until .EOF
4535 strWorkOrderID = .fields(0)
4536 strAddress = .fields(1)
4537 strAddress = REPLACE(strAddress, "'","")
4538 strCommand = "insert into RHA_Temp_InsuranceReclaim_T(WorksOrderID, Address) VALUES ('" & strWorkOrderID & "','" & strAddress & "')"
4539 with sqlconnection.execute(strCommand)
4540 end with
4541 .MoveNext
4542 LOOP
4543 end with
4544
4545'Build the Disabled Adaptations Table
4546 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 & "'))")
4547 Do Until .EOF
4548 strWorkOrderID = .fields(0)
4549 strAddress = .fields(1)
4550 strGroupName = .fields(2)
4551 strHierarchyID = .fields(3)
4552 strAddress = REPLACE(strAddress, "'","")
4553 strGroupName = REPLACE(strGroupName, "'"," ")
4554 strCommand = "insert into RHA_Temp_DisabledAdaptations_T(WorksOrderID,Address,GroupName,AssignToID) VALUES ('" & strWorkOrderID & "' ,'" & strAddress & "' ,'" & strGroupName & "' ,'" & strHierarchyID & "')"
4555 with sqlconnection.execute(strCommand)
4556 end with
4557 .MoveNext
4558 LOOP
4559 end with
4560End Function
4561
4562
4563Function getSchemeAssetID(Asset)
4564 dim strSQL
4565 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)
4566
4567 with sqlconnection.execute(strSQL)
4568 do until .eof
4569 getSchemeAssetID = .fields(0)
4570 .movenext
4571 loop
4572 end with
4573
4574End Function
4575
4576Function GetAgeOfProperty(AssetID)
4577 dim strResult
4578 dim strCommand
4579 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
4580 with sqlconnection.execute(strCommand)
4581 do until .eof
4582 if not isnull(.fields(0)) then
4583 strResult = .fields(0)
4584 else
4585 strResult = "Not Found"
4586 end if
4587 .movenext
4588 Loop
4589 end with
4590 GetAgeOfProperty = strResult
4591End Function
4592
4593Function BuildTmpTablesForAssuredStarterWarning
4594'RHA 20 Oct 2008 RS
4595 dim strCommand
4596 dim varLastRunDate
4597 dim varNewRunDate
4598 dim strAccountID
4599 dim strAccountStartDate
4600 dim strAddress
4601 dim strLHOID
4602 dim strTenantNames
4603 dim strRHMEmail
4604 dim strLHOName
4605 with sqlconnection.execute("set dateformat dmy SELECT TOP 1 LastRunTime FROM RHA_Rents_AssuredShorthold_Manual_Hook_T ORDER BY ID DESC")
4606 varLastRunDate = .fields(0)
4607 'msgbox varLastRunDate,vbexclamation+vbokonly,"Last Run Time"
4608 end with
4609 with sqlconnection.execute("SELECT GETDATE() AS CurrentDateTime")
4610 varNewRunDate = .fields(0)
4611 'msgbox varNewRunDate,vbexclamation+vbokonly,"New Run Time"
4612 end with
4613'Build the TMP Table
4614 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 & "'))")
4615 Do Until .EOF
4616 strAccountID = .fields(0)
4617 strAccountStartDate = .fields(1)
4618 strAddress = .fields(2)
4619 strLHOID = .fields(3)
4620 strTenantNames = .fields(4)
4621 strLHOName = .fields(5)
4622 strRHMEmail = .fields(6)
4623 strAddress = REPLACE(strAddress, "'","")
4624 strTenantNames = REPLACE(strTenantNames, "'"," ")
4625 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 & "')"
4626 with sqlconnection.execute(strCommand)
4627 end with
4628 .MoveNext
4629 LOOP
4630 end with
4631 'msgbox varLastRunDate,vbexclamation+vbokonly,"Post Table Updates"
4632'Update the lastruntime table
4633 with sqlconnection.execute("set dateformat dmy INSERT INTO RHA_Rents_AssuredShorthold_Manual_Hook_T(LastRunTime) VALUES ('" & varNewRunDate & "')")
4634 end with
4635
4636END FUNCTION
4637
4638Function AssuredStarterTracker(VarAccountID,varTenancyType)
4639Rem Version 1.0 30 Oct 2008 RS
4640 varSelect = "INSERT INTO RHA_Rents_AssuredStarterTracker_T (ID,TenancyType) VALUES ('" & varAccountID & "','" & varTenancyType & "')"
4641 With SQLConnection.Execute(varSelect)
4642 End With
4643End Function
4644
4645Function GetRSOHierarchyID(AssetID)
4646 dim varHID
4647 varSelect = "SELECT Hierarchy_ID FROM RHA_AssetsByRSOS_V with (nolock) WHERE Asset_ID = '" & AssetID & "'"
4648 with sqlconnection.execute(varSelect)
4649 varHID = .fields(0)
4650 End With
4651 GetRSOHierarchyID = varHID
4652End Function
4653
4654Function NewAssuredStarterTenancyTracker(VarAccountID)
4655Rem Version 1.0 30 Oct 2008 RS
4656 varSelect = "INSERT INTO RHA_Rents_AssuredStarterTracker_T (ID) VALUES (" & varAccountID & ")"
4657 With SQLConnection.Execute(varSelect)
4658 End With
4659End Function
4660
4661Function DeleteAssuredStarterTracker(varAccountID)
4662 Rem Version 1.0 30 Oct 2008 RS
4663 varSelect = "DELETE FROM RHA_Rents_AssuredStarterTracker_T WHERE ID = '" & varAccountID & "'"
4664 with sqlconnection.execute(varSelect)
4665 end with
4666End Function
4667
4668Function NewGasLetterNoPlan(VarLetterType,VarAccountRef,VarAssetRef,VarFormattedAssetAddress,VarUnformattedAssetAddress,VarDearNames,VarSalutation,VarContractorName,VarContractorTel)
4669rem Version 1.0 14 July 2008 RS
4670 dim varIDSeed
4671 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 & "')"
4672 WITH SQLConnection.Execute(varSelect)
4673 END WITH
4674 varSelect = "SELECT MAX(ID) FROM RAGLAN_GASSERVICELETTERS_T WITH (NOLOCK) WHERE (AccountRef = '" & VarAccountRef & "')"
4675 WITH SQLConnection.Execute(varSelect)
4676 DO UNTIL .EOF
4677 varIDSeed = .fields(0)
4678 EXIT DO
4679 LOOP
4680 END WITH
4681 NewGasLetterNoPlan = varIDSeed
4682END FUNCTION
4683
4684Function GetGasServiceType(AssetID)
4685'RS New Function 20 Apr 2009
4686'Values are... 1573 Gas Service Required, 1574 Supply Only, 1575 Gas Supply Carcus Inactive,
4687'1576 No Gas, 1577 Not Known.
4688 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)")
4689 with SQLConnection.Execute(varSelect)
4690 Do Until .EOF
4691 varResult = .fields(0)
4692 .MoveNext
4693 Loop
4694 End With
4695 'msgbox varResult
4696 GetGasServiceType = varResult
4697End Function
4698
4699Function getContract(OrderID)
4700 dim strContract, strExec
4701 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
4702 with SQLConnection.execute(strExec)
4703 do until .eof
4704 strContract = .fields(0)
4705 strContract = .fields(1) & " (" & strcontract &")"
4706 exit do
4707 loop
4708 end with
4709 getContract = strContract
4710End Function
4711
4712function GetJobTypeDesc(OrderID)
4713 dim strJobType, strExec
4714 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
4715 with SQLConnection.execute(strExec)
4716 do until .eof
4717 strJobType = .fields(0)
4718 exit do
4719 loop
4720 end with
4721 GetJobTypeDesc = replace(GetDescriptionForCode(strJobType)," & "," and ") & " (" & strJobType & ")"
4722end function
4723
4724'Updated 12/11/10 to include the Visit Requirement in the email. KS
4725Function SendEmailToContractorOLD(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,VulCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, AsbestosWarning, Contract, Visit)
4726
4727 dim strBody
4728 dim strEmailAddress
4729 dim strCommand
4730 dim dblTotal
4731 dim lngLines
4732 dim strSOR
4733
4734 strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
4735 strBody = strbody & vbcrlf & "Request ID: " & RequestID
4736 strBody = strbody & vbcrlf & "Asset: " & AssetReference
4737 if len(AsbestosWarning) > 0 then
4738 strBody = strBody & vbcrlf & AsbestosWarning
4739 end if
4740 strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
4741 strBody = strBody & vbcrlf & "Contractor: " & ContractorName
4742 strBody = strBody & vbcrlf & "Contract: " & Contract
4743 strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
4744 strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
4745 strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
4746 strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
4747 strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
4748 strBody = strBody & vbcrlf & "Visit Requirements: " & Visit
4749 strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
4750 strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
4751 strBody = strBody & vbcrlf & vbcrlf & "Vulnerability Code(s): " & VulCode
4752 strBody = strBody & vbcrlf & "Job Type: " & JobType
4753 strBody = strBody & vbcrlf & "Priority: " & Priority
4754 strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
4755 strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
4756 strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
4757 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
4758
4759 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)
4760 with sqlconnection.execute(strCommand)
4761 do until .eof
4762 strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
4763 for lngLines = 0 to ubound(strSOR)
4764 if lngLines = 0 then
4765 if isnull(.fields(0)) then
4766 strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
4767 else
4768 strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
4769 end if
4770 strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
4771 strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
4772 strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
4773 strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
4774
4775 else
4776 strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
4777 end if
4778 next
4779 dblTotal = dblTotal + .fields(3)
4780 .movenext
4781 loop
4782 end with
4783
4784 strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
4785
4786 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
4787
4788 strBody = strBody & vbcrlf & vbcrlf & vbcrlf
4789
4790 strEmailAddress = GetContractorEmailAddress(Contractor)
4791
4792 msgbox strBody,vbexclamation+vbokonly,"Email sent using SendEmailToContractorOLD - PLEASE INFORM BUSINESS SYSTEMS IMMEDIATELY"
4793
4794 CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@raglan.org",strEmailAddress,"","ActiveHWO@raglan.org",strBody,"",""
4795'msgbox "Email Sent"
4796End Function
4797
4798'Amendment 26/11/2015 - added additional variables at start, assigned values to variables and changed from CDOMail to SQLMail
4799Function 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)
4800
4801 dim strBody
4802 dim strEmailAddress
4803 dim strCommand
4804 dim dblTotal
4805 dim lngLines
4806 dim strSOR
4807 dim strProfile '- 26/11/2015
4808 dim strFromaddress '- 26/11/2015
4809 dim strCCaddress '- 26/11/2015
4810 dim strBCCaddress '- 26/11/2015
4811 dim strSubject '- 26/11/2015
4812
4813 strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
4814 strBody = strbody & vbcrlf & "Request ID: " & RequestID
4815 strBody = strbody & vbcrlf & "Asset: " & AssetReference
4816 if len(AsbestosWarning) > 0 then
4817 strBody = strBody & vbcrlf & AsbestosWarning
4818 end if
4819 strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
4820 strBody = strBody & vbcrlf & "Contractor: " & ContractorName
4821 strBody = strBody & vbcrlf & "Contract: " & Contract
4822 strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
4823 strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
4824 strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
4825 strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
4826 strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
4827 strBody = strBody & vbcrlf & "Visit Requirements: " & Visit
4828 strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
4829 strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
4830 strBody = strBody & vbcrlf & vbcrlf & "Vulnerability Code(s): " & VulCode
4831 strBody = strBody & vbcrlf & "Job Type: " & JobType
4832 strBody = strBody & vbcrlf & "Priority: " & Priority
4833 strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
4834 strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
4835 strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
4836 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
4837
4838 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)
4839 with sqlconnection.execute(strCommand)
4840 do until .eof
4841 strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
4842 for lngLines = 0 to ubound(strSOR)
4843 if lngLines = 0 then
4844 if isnull(.fields(0)) then
4845 strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
4846 else
4847 strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
4848 end if
4849 strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
4850 strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
4851 strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
4852 strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
4853
4854 else
4855 strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
4856 end if
4857 next
4858 dblTotal = dblTotal + .fields(3)
4859 .movenext
4860 loop
4861 end with
4862
4863 strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
4864
4865 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
4866
4867 strBody = strBody & vbcrlf & vbcrlf & vbcrlf
4868
4869 strEmailAddress = GetContractorEmailAddress(Contractor) ' - retrieve email from contractor
4870
4871 strFromaddress = "ActiveH.WO@Stonewater.org"
4872 strCCaddress = ""
4873 strBCCaddress = "ActiveH.WO@stonewater.org;stonewaterworksorders@gmail.com"
4874 strSubject = "Works Order " & OrderID
4875 strProfile = "ContractorEmails"
4876
4877 SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
4878
4879' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",EmailAddress,"","ActiveH.WO@stonewater.org;stonewaterworksorders@gmail.com",strBody,"",FilePath
4880msgbox "Email Sent to Contractor: " & EmailAddress
4881End Function
4882
4883' Copied from SendEmailToContractor for use with monthly estate management lot worksorders
4884Function 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)
4885
4886 dim strBody
4887 dim strEmailAddress
4888 dim strCommand
4889 dim dblTotal
4890 dim lngLines
4891 dim strSOR
4892 dim strProfile '- 26/11/2015
4893 dim strFromaddress '- 26/11/2015
4894 dim strCCaddress '- 26/11/2015
4895 dim strBCCaddress '- 26/11/2015
4896 dim strSubject '- 26/11/2015
4897
4898 strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
4899 strBody = strbody & vbcrlf & "Request ID: " & RequestID
4900 strBody = strbody & vbcrlf & "Asset: " & AssetReference
4901 if len(AsbestosWarning) > 0 then
4902 strBody = strBody & vbcrlf & AsbestosWarning
4903 end if
4904' strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
4905 strBody = strBody & vbcrlf & "Contractor: " & ContractorName
4906 strBody = strBody & vbcrlf & "Contract: " & Contract
4907' strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
4908' strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
4909' strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
4910' strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
4911' strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
4912' strBody = strBody & vbcrlf & "Visit Requirements: " & Visit
4913' strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
4914 strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
4915' strBody = strBody & vbcrlf & vbcrlf & "Vulnerability Code(s): " & VulCode
4916 strBody = strBody & vbcrlf & "Job Type: " & JobType
4917 strBody = strBody & vbcrlf & "Priority: " & Priority
4918' strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
4919' strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
4920 strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
4921 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
4922
4923 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)
4924 with sqlconnection.execute(strCommand)
4925 do until .eof
4926 strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
4927 for lngLines = 0 to ubound(strSOR)
4928 if lngLines = 0 then
4929 if isnull(.fields(0)) then
4930 strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
4931 else
4932 strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
4933 end if
4934 strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
4935 strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
4936 strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
4937 strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
4938
4939 else
4940 strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
4941 end if
4942 next
4943 dblTotal = dblTotal + .fields(3)
4944 .movenext
4945 loop
4946 end with
4947
4948 strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
4949
4950 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
4951
4952 strBody = strBody & vbcrlf & vbcrlf & vbcrlf
4953
4954 strEmailAddress = GetContractorEmailAddress(Contractor) ' - retrieve email from contractor
4955
4956 strFromaddress = "ActiveH.WO@Stonewater.org"
4957 strCCaddress = "jag.gill@stonewater.org;Anne.Phillips@stonewater.org"
4958 strBCCaddress = "indrek.ankur@stonewater.org;dennis.miller@stonewater.org;ActiveH.WO@stonewater.org;stonewaterworksorders@gmail.com"
4959 strSubject = "Works Order " & OrderID
4960 strProfile = "ContractorEmails"
4961
4962 SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
4963
4964' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",EmailAddress,"","ActiveH.WO@stonewater.org;stonewaterworksorders@gmail.com",strBody,"",FilePath
4965' msgbox "Email Sent to Contractor: " & strEmailAddress
4966End Function
4967
4968
4969'Emails the email address that is passed to the function
4970'Created 08/12/09 KS
4971'Modification to remove the Asbestos information (KS 13/03/10)
4972Function SendEmailToSchemeGroup(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,VulCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, Contract,SchemeEmail)
4973
4974 dim strBody
4975 dim strEmailAddress
4976 dim strCommand
4977 dim dblTotal
4978 dim lngLines
4979 dim strSOR
4980 dim strProfile '- 26/11/2015
4981 dim strFromaddress '- 26/11/2015
4982 dim strCCaddress '- 26/11/2015
4983 dim strBCCaddress '- 26/11/2015
4984 dim strSubject '- 26/11/2015
4985
4986 strBody = "Order Number: " & OrderID & " " & ConfirmationOrder
4987 strBody = strbody & vbcrlf & "Request ID: " & RequestID
4988 strBody = strbody & vbcrlf & "Asset: " & AssetReference
4989
4990 strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
4991 strBody = strBody & vbcrlf & "Contractor: " & ContractorName
4992 strBody = strBody & vbcrlf & "Contract: " & Contract
4993 strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
4994 strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
4995 strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
4996 strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
4997 strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
4998 strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
4999 strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
5000 strBody = strBody & vbcrlf & vbcrlf & "Vulnerability Code(s): " & VulCode
5001 strBody = strBody & vbcrlf & "Job Type: " & JobType
5002 strBody = strBody & vbcrlf & "Priority: " & Priority
5003 strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
5004 strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
5005 strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
5006 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
5007
5008 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)
5009 with sqlconnection.execute(strCommand)
5010 do until .eof
5011 strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
5012 for lngLines = 0 to ubound(strSOR)
5013 if lngLines = 0 then
5014 if isnull(.fields(0)) then
5015 strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
5016 else
5017 strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
5018 end if
5019 strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
5020 strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
5021 strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
5022 strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
5023
5024 else
5025 strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
5026 end if
5027 next
5028 dblTotal = dblTotal + .fields(3)
5029 .movenext
5030 loop
5031 end with
5032
5033 strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
5034
5035 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
5036
5037 strBody = strBody & vbcrlf & vbcrlf & vbcrlf
5038
5039 strEmailAddress = SchemeEmail
5040 strFromaddress = "ActiveH.WO@Stonewater.org"
5041 strCCaddress = ""
5042 strBCCaddress = ""
5043 strSubject = "Works Order " & OrderID
5044 strProfile = "ContractorEmails"
5045
5046 SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
5047
5048' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",SchemeEmail,"","ActiveH.WO@stonewater.org",strBody,"",""
5049msgbox "Email Sent to Scheme: " & SchemeEmail
5050End Function
5051
5052'Emails the email address that is passed to the function
5053'Created 13/03/2010 KS
5054Function SendEmailToSpokesPerson(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContactGroupName,ContactGroupHomeNumber,ContactWorkNumber,ContactMobileNumber,ContractorContact,OrderDate,VulCode,JobType,Priority,EstimatedCompletion, ConfirmationOrder, Contract,SpokespersonEmail)
5055
5056 dim strBody
5057 dim strEmailAddress
5058 dim strCommand
5059 dim dblTotal
5060 dim lngLines
5061 dim strSOR
5062 dim strProfile '- 26/11/2015
5063 dim strFromaddress '- 26/11/2015
5064 dim strCCaddress '- 26/11/2015
5065 dim strBCCaddress '- 26/11/2015
5066 dim strSubject '- 26/11/2015
5067
5068 strBody = "The following repair has been logged against the communal area for which you are the elected spokesperson"
5069 strBody = strBody & vbcrlf & vbcrlf & "Order Number: " & OrderID & " " & ConfirmationOrder
5070 strBody = strbody & vbcrlf & "Request ID: " & RequestID
5071 strBody = strbody & vbcrlf & "Asset: " & AssetReference
5072
5073 strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
5074 strBody = strBody & vbcrlf & "Contractor: " & ContractorName
5075 strBody = strBody & vbcrlf & "Contract: " & Contract
5076 strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
5077 strBody = strBody & vbcrlf & vbcrlf & "Contact Name: " & ContactGroupName
5078 strBody = strBody & vbcrlf & "Contact Home Number: " & ContactGroupHomeNumber
5079 strBody = strBody & vbcrlf & "Contact Work Number: " & ContactWorkNumber
5080 strBody = strBody & vbcrlf & "Contact Mobile Number: " & ContactMobileNumber
5081 strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
5082 strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
5083 strBody = strBody & vbcrlf & vbcrlf & "Vulnerability Code(s): " & VulCode
5084 strBody = strBody & vbcrlf & "Job Type: " & JobType
5085 strBody = strBody & vbcrlf & "Priority: " & Priority
5086 strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
5087 strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
5088 strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
5089 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
5090
5091 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)
5092 with sqlconnection.execute(strCommand)
5093 do until .eof
5094 strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
5095 for lngLines = 0 to ubound(strSOR)
5096 if lngLines = 0 then
5097 if isnull(.fields(0)) then
5098 strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
5099 else
5100 strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
5101 end if
5102 strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
5103 strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
5104 strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
5105 strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
5106
5107 else
5108 strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
5109 end if
5110 next
5111 dblTotal = dblTotal + .fields(3)
5112 .movenext
5113 loop
5114 end with
5115
5116 strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
5117
5118 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
5119
5120 strBody = strBody & vbcrlf & vbcrlf & vbcrlf
5121
5122 strEmailAddress = SpokesPersonEmail
5123 strFromaddress = "ActiveH.WO@Stonewater.org"
5124 strCCaddress = ""
5125 strBCCaddress = ""
5126 strSubject = "Works Order " & OrderID
5127 strProfile = "ContractorEmails"
5128
5129 SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
5130
5131' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",SpokesPersonEmail,"","ActiveH.WO@stonewater.org",strBody,"",""
5132'msgbox "Email Sent"
5133End Function
5134
5135'Emails the email address that is passed to the function
5136'Created 13/03/2010 KS
5137Function SendEmailToSpokesPersonTrim(OrderID,RequestID,Contractor,AssetReference,AssetAddress,AccessRestrictions,RequestDescription,ContractorName,ReportedDateTime,ContractorContact,OrderDate,JobType,Priority,EstimatedCompletion, ConfirmationOrder, Contract,SpokespersonEmail)
5138
5139 dim strBody
5140 dim strEmailAddress
5141 dim strCommand
5142 dim dblTotal
5143 dim lngLines
5144 dim strSOR
5145 dim strProfile '- 26/11/2015
5146 dim strFromaddress '- 26/11/2015
5147 dim strCCaddress '- 26/11/2015
5148 dim strBCCaddress '- 26/11/2015
5149 dim strSubject '- 26/11/2015
5150
5151 strBody = "The following repair has been logged against the communal area for which you are the elected spokesperson"
5152 strBody = strBody & vbcrlf & vbcrlf & "Order Number: " & OrderID & " " & ConfirmationOrder
5153 strBody = strbody & vbcrlf & "Request ID: " & RequestID
5154 strBody = strbody & vbcrlf & "Asset: " & AssetReference
5155
5156 strBody = strBody & vbcrlf & "Address: " & replace(AssetAddress,vbcrlf,",")
5157 strBody = strBody & vbcrlf & "Contractor: " & ContractorName
5158 strBody = strBody & vbcrlf & "Contract: " & Contract
5159 strBody = strBody & vbcrlf & "Reported Date: " & ReportedDateTime
5160 strBody = strBody & vbcrlf & vbcrlf & "Contractor Contact: " & ContractorContact
5161 strBody = strBody & vbcrlf & vbcrlf & "Order Date: " & OrderDate
5162 strBody = strBody & vbcrlf & "Job Type: " & JobType
5163 strBody = strBody & vbcrlf & "Priority: " & Priority
5164 strBody = strBody & vbcrlf & "Estimated Completion: " & EstimatedCompletion
5165 strBody = strBody & vbcrlf & "Access Restrictions: " & AccessRestrictions
5166 strBody = strBody & vbcrlf & "Job Description: " & RequestDescription
5167 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
5168
5169 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)
5170 with sqlconnection.execute(strCommand)
5171 do until .eof
5172 strSOR = split(cstr(ReturnDelimitedText(.fields(1).Value,47)),vbcrlf)
5173 for lngLines = 0 to ubound(strSOR)
5174 if lngLines = 0 then
5175 if isnull(.fields(0)) then
5176 strBody = strBody & vbcrlf & "SOR: " & space(10) & " " & strsor(lngLines)
5177 else
5178 strBody = strBody & vbcrlf & "SOR: " & space(10 - len(.fields(0))) & .fields(0) & " " & strsor(lngLines)
5179 end if
5180 strBody = strBody & " OrderLineID: " & cdbl(.fields(4))
5181 strBody = strBody & space(10) & " Qty: " & formatnumber(cdbl(.fields(2)),2)
5182 strBody = strBody & " Value: " & FormatNumber(cdbl(.fields(3)) / cdbl(.fields(2)),2)
5183 strBody = strbody & vbcrlf & "Trade: " & .fields(6) & " (" & .fields(5) & ")"
5184
5185 else
5186 strBody = strBody & vbcrlf & space(15) & " " & strsor(lngLines)
5187 end if
5188 next
5189 dblTotal = dblTotal + .fields(3)
5190 .movenext
5191 loop
5192 end with
5193
5194 strBody = strBody & vbcrlf & vbcrlf & space(85) & "Total: " & formatnumber(dblTotal,2)
5195
5196 strBody = strBody & vbcrlf & vbcrlf & "======================================================================================================="
5197
5198 strBody = strBody & vbcrlf & vbcrlf & vbcrlf
5199
5200 strEmailAddress = SpokesPersonEmail
5201 strFromaddress = "ActiveH.WO@Stonewater.org"
5202 strCCaddress = ""
5203 strBCCaddress = ""
5204 strSubject = "Works Order " & OrderID
5205 strProfile = "ContractorEmails"
5206
5207 SendEmailSQL strEmailAddress, strFromaddress, strCCaddress, strBCCaddress, strSubject, strBody, strProfile
5208
5209' CDOEmailUsingOutputAttach "Works Order " & OrderID & " " & ConfirmationOrder,"ActiveHWO@stonewater.org",SpokesPersonEmail,"","ActiveHWO@stonewater.org",strBody,"",""
5210'msgbox "Email Sent"
5211End Function
5212
5213Function ContactWhitePanel(String1,String2,String3,String4,String5,String6,String7)
5214 dim strResult
5215'-- Debug msgbox String1 & ", " & string2 & ", " & string3 & ", " & string4
5216 if len(String1) > 0 then
5217 strResult = String1
5218 end if
5219 if len(String2) > 0 then
5220 if len(strResult) = 0 then
5221 strResult = String2
5222 else
5223 strResult = strResult & vbcrlf & String2
5224 end if
5225 end if
5226 if len(String3) > 0 then
5227 if len(strResult) = 0 then
5228 strResult = String3
5229 else
5230 strResult = strResult & vbcrlf & String3
5231 end if
5232 end if
5233 if len(String4) > 0 then
5234 if len(strResult) = 0 then
5235 strResult = String4
5236 else
5237 strResult = strResult & vbcrlf & String4
5238 end if
5239 end if
5240 if len(String5) > 0 then
5241 if len(strResult) = 0 then
5242 strResult = String5
5243 else
5244 strResult = strResult & vbcrlf & String5
5245 end if
5246 end if
5247 if len(String6) > 0 then
5248 if len(strResult) = 0 then
5249 strResult = String6
5250 else
5251 strResult = strResult & vbcrlf & String6
5252 end if
5253 end if
5254 if len(String7) > 0 then
5255 if len(strResult) = 0 then
5256 strResult = String7
5257 else
5258 strResult = strResult & vbcrlf & String7
5259 end if
5260 end if
5261'-- Debug msgbox strResult
5262 ContactWhitePanel = Sentence(strResult)
5263End Function
5264function GetContactVul(GroupID)
5265 dim iResult, strSQL
5266
5267 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
5268
5269 iresult = 0
5270 With SQLConnection.Execute(strSQL)
5271 Do Until .EOF
5272 iResult = .Fields("NoVuls").Value
5273 .MoveNext
5274 Loop
5275End With
5276 GetContactVul= iResult
5277end function
5278
5279Function ClearOutstandingTasksWorkfile()
5280 varSelect = "DELETE FROM RAGLAN_USR_Outstanding_Tasks_Workfile_T"
5281 With SQLConnection.Execute(varSelect)
5282 End With
5283End Function
5284
5285Function BuildOutstandingTasksWorkfile(varTaskID,varRequiredByDate,varTaskDesc,varUser,varEmailAddress,varReportingSection)
5286
5287 varUpdate = "INSERT INTO RAGLAN_USR_Outstanding_Tasks_Workfile_T (TaskID, RequiredByDate, TaskDescription, UserName, EmailAddress, ReportingSection) VALUES (" & varTaskID & ",'" & varRequiredByDate & "','" & varTaskDesc & "','" & varUser & "','" & varEmailAddress & "'," & varReportingSection & ")"
5288 With SQLConnection.Execute(varUpdate)
5289 End With
5290
5291End Function
5292
5293Function EMailCDOUsingOutputAttach(Subject,From,Recipient,Cc,Bcc,Body,HTMLBody,AttachFilePath)
5294'
5295' This function allows generation of an email via Outlook
5296' with an optional attachment file if required
5297'
5298 On Error resume Next:err.clear
5299
5300 Dim objMessage, objConfiguration
5301
5302 Set objMessage = CreateObject("CDO.Message")
5303 Set objConfiguration = CreateObject("CDO.Configuration")
5304
5305 objMessage.Subject = Subject
5306 objMessage.From = From
5307 objMessage.To = Recipient
5308 objMessage.Bcc = Bcc
5309 objMessage.Cc = Cc
5310 if len(Body) > 0 then
5311 objMessage.TextBody = Body
5312 else
5313 objMessage.HTMLBody = HTMLBody
5314 end if
5315 If Len(AttachFilePath) > 0 Then
5316 objMessage.AddAttachment = AttachFilePath
5317 End If
5318
5319' Do not touch parameters below! unless you fully understand the implications
5320
5321 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
5322 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "172.20.0.72"
5323 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
5324 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "raglan\ActiveHSMS"
5325 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Opera09"
5326' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Housing Services Centre"
5327' objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "opera09"
5328 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
5329 objConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 180
5330
5331 objConfiguration.Fields.Update
5332
5333 Set objMessage.Configuration = objConfiguration
5334
5335 objMessage.Send
5336
5337 Set objMessage = Nothing
5338
5339 EMailCDOUsingOutputAttach = err.number
5340
5341End Function
5342
5343Function RHA_Document_Delete_And_Duplicate
5344
5345 Dim strStatusMessage
5346 Dim strDocumentNumber
5347 Dim strSQL
5348 Dim objRecordset
5349 Dim objCommand
5350
5351 'Initialise status message (there will be no status when the screen is first displayed)
5352 strStatusMessage = vbNullString
5353
5354 Do
5355 strDocumentNumber = InputBox(strStatusMessage & "Please enter the document number to reassign:", "ActiveH Reassign Document Number", strDocumentNumber)
5356
5357 If LenB(strDocumentNumber) = 0 Then
5358 Exit Do
5359 End If
5360
5361 'Initialise status message
5362 strStatusMessage = vbNullString
5363
5364 If IsNumeric(strDocumentNumber) Then
5365
5366 strSQL = "SELECT Status_ID, LEN(RTRIM(Contractors_Reference_CH)) As ContractorsRefLength FROM Repairs_Documents_T WHERE Document_ID=" & strDocumentNumber
5367
5368 Set objRecordset = SQLConnection.Execute(strSQL)
5369
5370 If Not (objRecordset.BOF And objRecordset.EOF) Then
5371
5372 If objRecordset.Fields("Status_ID").Value <> 84 Then
5373 strStatusMessage = "The document number entered does not have a status of registered!" & vbCrLf & vbCrLf
5374 End If
5375
5376 If objRecordset.Fields("ContractorsRefLength").Value = 30 Then
5377 strStatusMessage = "The contractors document reference has the maximum of 30 characters and therefore cannot be changed when copying to a new document!" & vbCrLf & vbCrLf
5378 End If
5379
5380 Else
5381 strStatusMessage = "The document number entered does not exist!" & vbCrLf & vbCrLf
5382 End If
5383
5384 Set objRecordset = Nothing
5385
5386 Else
5387 strStatusMessage = "The document number entered is not a numeric value!" & vbCrLf & vbCrLf
5388 End if
5389
5390 'IF the status message has not yet been updated THEN no errors have occurred so execute the stored procedure
5391 If LenB(strStatusMessage) = 0 Then
5392
5393 Set objCommand = CreateObject("ADODB.Command")
5394
5395 objCommand.ActiveConnection = SQLConnection
5396 objCommand.CommandText = "up_parmupd_Repairs_usr_RHA_Document_Delete_And_Duplicate"
5397 objCommand.CommandType = 4 'adCmdStoredProc
5398 objCommand.Parameters.Refresh
5399 objCommand.Parameters(1).Value = CStr(strDocumentNumber)
5400 objCommand.Execute
5401
5402 strStatusMessage = "Document id: " & strDocumentNumber & " has successfully been reassigned to document id: " & objCommand.Parameters(2).Value & vbCrLf & vbCrLf
5403 Set objCommand = Nothing
5404
5405 strDocumentNumber = vbNullString
5406 End If
5407
5408 Loop
5409
5410End Function
5411
5412
5413
5414
5415
5416
5417
5418
5419Function RHA_Document_Delete_And_Duplicate
5420
5421 Dim strStatusMessage
5422 Dim strDocumentNumber
5423 Dim strSQL
5424 Dim objRecordset
5425 Dim objCommand
5426
5427 'Initialise status message (there will be no status when the screen is first displayed)
5428 strStatusMessage = vbNullString
5429
5430 Do
5431 strDocumentNumber = InputBox(strStatusMessage & "Please enter the document number to reassign:", "ActiveH Reassign Document Number", strDocumentNumber)
5432
5433 If LenB(strDocumentNumber) = 0 Then
5434 Exit Do
5435 End If
5436
5437 'Initialise status message
5438 strStatusMessage = vbNullString
5439
5440 If IsNumeric(strDocumentNumber) Then
5441
5442 strSQL = "SELECT Status_ID, LEN(RTRIM(Contractors_Reference_CH)) As ContractorsRefLength FROM Repairs_Documents_T WHERE Document_ID=" & strDocumentNumber
5443
5444 Set objRecordset = SQLConnection.Execute(strSQL)
5445
5446 If Not (objRecordset.BOF And objRecordset.EOF) Then
5447
5448 If objRecordset.Fields("Status_ID").Value <> 84 Then
5449 strStatusMessage = "The document number entered does not have a status of registered!" & vbCrLf & vbCrLf
5450 End If
5451
5452 If objRecordset.Fields("ContractorsRefLength").Value = 30 Then
5453 strStatusMessage = "The contractors document reference has the maximum of 30 characters and therefore cannot be changed when copying to a new document!" & vbCrLf & vbCrLf
5454 End If
5455
5456 Else
5457 strStatusMessage = "The document number entered does not exist!" & vbCrLf & vbCrLf
5458 End If
5459
5460 Set objRecordset = Nothing
5461
5462 Else
5463 strStatusMessage = "The document number entered is not a numeric value!" & vbCrLf & vbCrLf
5464 End if
5465
5466 'IF the status message has not yet been updated THEN no errors have occurred so execute the stored procedure
5467 If LenB(strStatusMessage) = 0 Then
5468
5469 Set objCommand = CreateObject("ADODB.Command")
5470
5471 objCommand.ActiveConnection = SQLConnection
5472 objCommand.CommandText = "up_parmupd_Repairs_usr_RHA_Document_Delete_And_Duplicate"
5473 objCommand.CommandType = 4 'adCmdStoredProc
5474 objCommand.Parameters.Refresh
5475 objCommand.Parameters(1).Value = CStr(strDocumentNumber)
5476 objCommand.Execute
5477
5478 strStatusMessage = "Document id: " & strDocumentNumber & " has successfully been reassigned to document id: " & objCommand.Parameters(2).Value & vbCrLf & vbCrLf
5479 Set objCommand = Nothing
5480
5481 strDocumentNumber = vbNullString
5482 End If
5483
5484 Loop
5485
5486End Function
5487
5488
5489
5490Function UpdateTaskRequestsT(varTaskRequestID,varTaskID)
5491 SQLConnection.Execute "UPDATE usr_Raglan_Task_Requests_T SET Audit_Task_ID_Created_ID = " & varTaskID & " WHERE Task_Request_ID = " & varTaskRequestID
5492End Function
5493
5494Function RaiseError(ErrDescription, ErrNumber, ErrSource)
5495 'MsgBox ErrDescription & vbnewline & ErrNumber & vbnewline & ErrSource
5496 Err.Raise ErrNumber, ErrDescription, ErrSource
5497End Function
5498
5499
5500
5501Function HPMTaskMinutes (Case_ID,Task_ID,Minutes)
5502 Dim strSQL
5503
5504' msgbox("Insert into WF_HPM_TaskMinutes_T values ("& Case_ID & "," & Task_ID & "," & Minutes & "," & UserID & ",convert(datetime,'" & CompletionDate & "'))")
5505
5506
5507 strSQL = ("Insert into WF_HPM_TaskMinutes_T values ("& Case_ID & "," & Task_ID & "," & Minutes & ")")
5508
5509 'msgbox(strSQL)
5510
5511 with sqlconnection.execute (strSQL)
5512 End With
5513End Function
5514
5515Function HPMNBShortlistRanking (Case_ID,Task_ID,Ranking)
5516 Dim strSQL
5517
5518' msgbox("Insert into usr_SW_HPM_ShortlistRanking_T values ("& Case_ID & "," & Task_ID & "," & Ranking & "," & UserID & ",convert(datetime,'" & CompletionDate & "'))")
5519
5520
5521 strSQL = ("Insert into usr_SW_HPM_ShortlistRanking_T values ("& Case_ID & "," & Task_ID & "," & Ranking & ")")
5522
5523 msgbox(strSQL)
5524
5525 with sqlconnection.execute (strSQL)
5526 End With
5527End Function
5528
5529
5530Function HPMVVRAScore (Case_ID,Task_ID,VVRAScore)
5531 Dim strSQL
5532
5533' msgbox("Insert into WF_HPM_TaskMinutes_T values ("& Case_ID & "," & Task_ID & "," & VVRAScore & "," & UserID & ",convert(datetime,'" & CompletionDate & "'))")
5534
5535
5536 strSQL = ("Insert into WF_HPM_VVRAScore_T values ("& Case_ID & "," & Task_ID & "," & VVRAScore &")")
5537
5538 'msgbox(strSQL)
5539
5540 with sqlconnection.execute (strSQL)
5541 End With
5542End Function
5543
5544
5545
5546
5547
5548Function HPMStoreCalls (Case_ID,Case_Call_ID,CRM_Call_ID)
5549 Dim strSQL
5550
5551 strSQL = ("Insert into WF_HPM_Case_Calls_Audit_T values ("& Case_ID & "," & Case_Call_ID & "," & CRM_Call_ID & ")")
5552
5553 'msgbox(strSQL)
5554
5555 with sqlconnection.execute (strSQL)
5556 End With
5557End Function
5558
5559
5560Function HPMLetterInput (Case_ID,Task_ID,LetterInput,LetterID)
5561 Dim strSQL
5562
5563 strSQL = ("Insert into WF_HPM_TaskLeterInput_T values ("& Case_ID & "," & Task_ID & ",'" & LetterInput & "'," & LetterID & ", Getdate()" & ")")
5564
5565 'msgbox(strSQL)
5566
5567 with sqlconnection.execute (strSQL)
5568 End With
5569End Function
5570
5571
5572
5573Function HPMLetterInputDiary (Case_ID,Task_ID,Diary_ID,LetterID,User_ID)
5574 Dim strSQL
5575
5576
5577 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()" & ")")
5578
5579 'msgbox(strSQL)
5580
5581 with sqlconnection.execute (strSQL)
5582 End With
5583
5584 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 )
5585
5586 'msgbox(strSQL)
5587
5588 with sqlconnection.execute (strSQL)
5589 End With
5590End Function
5591
5592
5593Function HPMStoreCaseOwner (Case_ID,Case_Owner_ID,Department_BT,Insert_BT)
5594 Dim strSQL
5595
5596 if Insert_BT = 1 then
5597 strSQL = ("Insert into WF_HPM_Case_Owner_Audit_T values ("& Case_ID & "," & Case_Owner_ID & "," & Department_BT & ")")
5598 else
5599 strSQL = ("update WF_HPM_Case_Owner_Audit_T set Owner_ID = " & Case_Owner_ID & ", Department_BT = " & Department_BT & " where Case_Id = " & Case_ID)
5600 end if
5601 'msgbox(strSQL)
5602
5603 with sqlconnection.execute (strSQL)
5604 End With
5605End Function
5606
5607
5608
5609
5610
5611Function HPMStoreVVRA (Case_ID,targetedintimidated,PerpetratorsKnown,healthaffected,familysupport,happenedbefore,prejudice,howoften,VVRARelatesto,RelatesToContact,Score,User)
5612 Dim strSQL
5613
5614 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 & ")")
5615
5616'msgbox(strSQL)
5617
5618 with sqlconnection.execute (strSQL)
5619 End With
5620End Function
5621
5622
5623
5624function 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)
5625
5626Dim strSQL
5627
5628strSQL = ("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 & ")")
5629
5630'msgbox(strSQL)
5631
5632
5633 with sqlconnection.execute (strSQL)
5634 End With
5635End Function
5636
5637Function HPMStorePerpASBStatus(CaseID,ASBStatusID,RelatesTocontactID,UserID)
5638
5639Dim strSQL
5640
5641strSQL = ("Insert into usr_SW_Perpetrator_ASB_Status_Audit_T values (" & CaseID & "," & ASBStatusID & ",0" & ", Getdate()" & "," & RelatesTocontactID & "," & UserID & ")")
5642
5643'msgbox(strSQL)
5644
5645 with sqlconnection.execute (strSQL)
5646 End With
5647End Function
5648
5649function 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)
5650
5651Dim strSQL
5652
5653strSQL2 = ("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 & ")")
5654
5655'msgbox(strSQL)
5656
5657
5658 with sqlconnection.execute (strSQL)
5659 End With
5660End Function
5661
5662
5663Function AttachASBMailMerge(CaseID,LetterDirectory,LetterName)
5664
5665 Dim strSQL
5666 Dim FilePath
5667 Dim FullLetterName
5668 Dim LetterDate
5669 Dim DayNumber
5670 Dim MonthNumber
5671
5672
5673 if Day(Date) < 10 then DayNumber = "0" & CStr(Day(Date)) else DayNumber = CStr(Day(Date))
5674
5675 if Month(Date) < 10 then MonthNumber = "0" & CStr(Month(Date)) else MonthNumber = CStr(Month(Date))
5676
5677 LetterDate = DayNumber + "_" + MonthNumber + "_" + CStr(Year(Date))
5678
5679' UAT
5680' FilePath ="\\filesrv-01\Data\Shared\IT\Unite_Test_Attachments\" & LetterDirectory & "\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
5681
5682' TEST
5683' FilePath ="W:\System_Attachments\" & LetterDirectory & "\TEST\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
5684
5685' Live
5686 FilePath ="W:\System_Attachments\" & LetterDirectory & "\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
5687
5688
5689
5690 FullLetterName = LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
5691
5692 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())")
5693
5694' msgbox(strSQL)
5695
5696 with sqlconnection.execute (strSQL)
5697 End With
5698End Function
5699
5700
5701Function CreateLettingsApplicantFolder(varApplicationID)
5702
5703Dim objFSO, objFolder, strDirectory
5704
5705' Directory for UAT
5706' strDirectory = "\\filesrv-01\Data\Shared\IT\Unite_Test_Attachments\Applications\" & varApplicationID & ""
5707
5708' Directory for TEST
5709' strDirectory = "W:\System_Attachments\Applicants\TEST\"& varApplicationID & ""
5710
5711' Directory for Live
5712 strDirectory = "W:\System_Attachments\Applicants\"& varApplicationID & ""
5713
5714 Set objFSO = CreateObject("Scripting.FileSystemObject")
5715
5716 If objFSO.FolderExists(strDirectory) Then
5717 Set objFolder = objFSO.GetFolder(strDirectory)
5718' msgbox("already exsists" & strDirectory)
5719 Else
5720 Set objFolder = objFSO.CreateFolder(strDirectory)
5721 msgbox("Just created " & strDirectory)
5722 End If
5723
5724 If err.number = vbEmpty then
5725 Set objShell = CreateObject("WScript.Shell")
5726 objShell.run ("Explorer" &" " & strDirectory & "\" )
5727 Else
5728 msgbox("VBScript Error: " & err.number)
5729
5730 End If
5731
5732End Function
5733
5734
5735Function CreateStonewaterVoidManagementCaseFolder(CaseID)
5736
5737Dim objFSO, objFolder, strDirectory
5738
5739' Directory for UAT
5740' strDirectory = "\\filesrv-01\Data\Shared\IT\Unite_Test_Attachments\Voids\" & CaseID & ""
5741
5742' Directory for TEST
5743' strDirectory = "W:\System_Attachments\Voids\TEST\" & CaseID & ""
5744
5745' Directory for Live
5746 strDirectory = "W:\System_Attachments\Voids\"& CaseID & ""
5747
5748 Set objFSO = CreateObject("Scripting.FileSystemObject")
5749
5750 If objFSO.FolderExists(strDirectory) Then
5751 Set objFolder = objFSO.GetFolder(strDirectory)
5752' msgbox("already exsists" & strDirectory)
5753 Else
5754 Set objFolder = objFSO.CreateFolder(strDirectory)
5755 msgbox("Just created " & strDirectory)
5756 End If
5757
5758 If err.number = vbEmpty then
5759 Set objShell = CreateObject("WScript.Shell")
5760 objShell.run ("Explorer" &" " & strDirectory & "\" )
5761 Else
5762 msgbox("VBScript Error: " & err.number)
5763
5764 End If
5765
5766End Function
5767
5768
5769
5770
5771Function CreateStonewaterASBFolder(CaseID)
5772
5773Dim objFSO, objFolder, strDirectory
5774
5775' Directory for UAT
5776' strDirectory = "\\filesrv-01\Data\Shared\IT\Unite_Test_Attachments\ASB\" & CaseID & ""
5777
5778' Directory for TEST
5779' strDirectory = "W:\System_Attachments\ASB\TEST" & CaseID & ""
5780
5781' Directory for Live
5782 strDirectory = "W:\System_Attachments\ASB\" & CaseID & ""
5783
5784
5785 Set objFSO = CreateObject("Scripting.FileSystemObject")
5786
5787 If objFSO.FolderExists(strDirectory) Then
5788 Set objFolder = objFSO.GetFolder(strDirectory)
5789' msgbox("already exsists" & strDirectory)
5790 Else
5791 Set objFolder = objFSO.CreateFolder(strDirectory)
5792 msgbox("Just created " & strDirectory)
5793 End If
5794
5795 If err.number = vbEmpty then
5796 Set objShell = CreateObject("WScript.Shell")
5797 objShell.run ("Explorer" &" " & strDirectory & "\" )
5798 Else
5799 msgbox("VBScript Error: " & err.number)
5800
5801 End If
5802
5803End Function
5804
5805
5806
5807Function CreateHomeOwnershipCaseFolder(CaseID, Path)
5808
5809
5810Dim objFSO, objFolder, strDirectory
5811
5812 strDirectory = Path & "\" & CaseID & ""
5813
5814 Set objFSO = CreateObject("Scripting.FileSystemObject")
5815
5816 If objFSO.FolderExists(strDirectory) Then
5817 Set objFolder = objFSO.GetFolder(strDirectory)
5818' msgbox("already exists" & strDirectory)
5819 Else
5820 Set objFolder = objFSO.CreateFolder(strDirectory)
5821 msgbox("Just created " & strDirectory)
5822 End If
5823
5824 If err.number = vbEmpty then
5825 Set objShell = CreateObject("WScript.Shell")
5826 objShell.run ("Explorer" &" " & strDirectory & "\" )
5827 Else
5828 msgbox("VBScript Error: " & err.number)
5829
5830 End If
5831
5832
5833
5834End Function
5835
5836
5837
5838Function CreateStonewaterCustomerFeedbackFolder(CaseID,Path,FolderName,Open)
5839
5840Dim objFSO, objFolder, strDirectory
5841
5842
5843' Directory for TEST
5844 strDirectory = Path & FolderName & "\" & CaseID & ""
5845
5846'msgbox(strDirectory)
5847
5848 Set objFSO = CreateObject("Scripting.FileSystemObject")
5849
5850 If objFSO.FolderExists(strDirectory) Then
5851 Set objFolder = objFSO.GetFolder(strDirectory)
5852 msgbox("already exsists" & strDirectory)
5853 Else
5854 Set objFolder = objFSO.CreateFolder(strDirectory)
5855 msgbox("Just created " & strDirectory)
5856 End If
5857
5858 If err.number = vbEmpty then
5859 Set objShell = CreateObject("WScript.Shell")
5860 if Open = 1 then
5861 objShell.run ("Explorer" &" " & strDirectory & "\" )
5862 End if
5863 Else
5864 msgbox("VBScript Error: " & err.number)
5865
5866 End If
5867
5868End Function
5869
5870
5871
5872
5873
5874Function HPMMethodofPayment (Case_ID,Task_ID,MethodofPayment)
5875 Dim strSQL
5876
5877' msgbox("Insert into WF_HPM_MethodOfPayments_T values ("& Case_ID & "," & Task_ID & "," & MethodofPayment & "'))")
5878
5879
5880 strSQL = ("Insert into WF_HPM_MethodOfPayments_T values ("& Case_ID & "," & Task_ID & "," & MethodofPayment & ")")
5881
5882' msgbox(strSQL)
5883
5884 with sqlconnection.execute (strSQL)
5885 End With
5886End Function
5887
5888Function HPMExchangeCompletionDates (Case_ID,SubCategory,ExchangeDate,CompletionDate)
5889 Dim strSQL
5890
5891' msgbox("Insert into WF_HPM_Exchange_Completion_Dates_T values ("& Case_ID & "," & ExchangeDate & "," & CompletionDate & "'))")
5892
5893
5894 strSQL = ("Insert into WF_HPM_Exchange_Completion_Dates_T values ("& Case_ID & ",'" & SubCategory & "','" & ExchangeDate & "','" & CompletionDate & "')")
5895
5896' msgbox(strSQL)
5897
5898 with sqlconnection.execute (strSQL)
5899 End With
5900End Function
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911Function 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)
5912
5913 Dim strSQL
5914
5915 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 &"')")
5916
5917 'msgbox(strSQL)
5918
5919 with sqlconnection.execute (strSQL)
5920 End With
5921End Function
5922
5923
5924
5925Function AttachMailMerge(CaseID,LetterDirectory,LetterName)
5926
5927 Dim strSQL
5928 Dim FilePath
5929 Dim FullLetterName
5930 Dim LetterDate
5931 Dim DayNumber
5932 Dim MonthNumber
5933
5934
5935 if Day(Date) < 10 then DayNumber = "0" & CStr(Day(Date)) else DayNumber = CStr(Day(Date))
5936
5937 if Month(Date) < 10 then MonthNumber = "0" & CStr(Month(Date)) else MonthNumber = CStr(Month(Date))
5938
5939 LetterDate = DayNumber + "_" + MonthNumber + "_" + CStr(Year(Date))
5940
5941' TEST
5942' FilePath = "W:\Sysytem_Attachments\" & LetterDirectory & "\TEST\Case_" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
5943
5944' Live
5945 FilePath = "W:\Sysytem_Attachments\" & LetterDirectory & "\Case_" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
5946
5947
5948 FullLetterName = LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
5949
5950 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())")
5951
5952' msgbox(strSQL)
5953
5954 with sqlconnection.execute (strSQL)
5955 End With
5956End Function
5957
5958
5959Function AttachHOMailMerge(CaseID,LetterDirectory,LetterName)
5960
5961 Dim strSQL
5962 Dim FilePath
5963 Dim FullLetterName
5964 Dim LetterDate
5965 Dim DayNumber
5966 Dim MonthNumber
5967
5968 if Day(Date) < 10 then DayNumber = "0" & CStr(Day(Date)) else DayNumber = CStr(Day(Date))
5969
5970 if Month(Date) < 10 then MonthNumber = "0" & CStr(Month(Date)) else MonthNumber = CStr(Month(Date))
5971
5972 LetterDate = DayNumber + "_" + MonthNumber + "_" + CStr(Year(Date))
5973
5974
5975' FilePath = LetterDirectory & "\Case_" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
5976
5977 FilePath = LetterDirectory & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
5978
5979
5980 FullLetterName = LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
5981
5982 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())")
5983
5984' msgbox(strSQL)
5985
5986 with sqlconnection.execute (strSQL)
5987 End With
5988End Function
5989
5990
5991
5992Function AttachCaseProcessingMailMerge(CaseID,Path,LetterDirectory,LetterName)
5993
5994 Dim strSQL
5995 Dim FilePath
5996 Dim FullLetterName
5997 Dim LetterDate
5998 Dim DayNumber
5999 Dim MonthNumber
6000
6001
6002 if Day(Date) < 10 then DayNumber = "0" & CStr(Day(Date)) else DayNumber = CStr(Day(Date))
6003
6004 if Month(Date) < 10 then MonthNumber = "0" & CStr(Month(Date)) else MonthNumber = CStr(Month(Date))
6005
6006 LetterDate = DayNumber + "_" + MonthNumber + "_" + CStr(Year(Date))
6007
6008' UAT
6009' FilePath ="\\filesrv-01\Data\Shared\IT\Unite_Test_Attachments\" & LetterDirectory & "\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
6010
6011' TEST
6012 FilePath = Path & LetterDirectory & "\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
6013
6014
6015' Live
6016' FilePath ="W:\System_Attachments\" & LetterDirectory & "\" & CaseID & "\" & LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
6017
6018
6019
6020 FullLetterName = LetterName & "_" & CaseID & "_" & LetterDate & ".pdf"
6021
6022 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())")
6023
6024' msgbox(strSQL)
6025
6026 with sqlconnection.execute (strSQL)
6027 End With
6028End Function
6029
6030
6031
6032Function UpdateSMSIn(msgID)
6033
6034 varSMSUpdate = "UPDATE Shared_SMS_Inbox_T SET READ_BT = 1 where Message_ID = " & msgID
6035 WITH SQLConnection.Execute(varSMSUpdate)
6036 END WITH
6037
6038End Function
6039
6040
6041
6042'*************************************
6043' Scheme Accounting Custom Functions
6044'*************************************
6045
6046Function GetAccountListingHTML(AccountNumber, TrxDateFrom, TrxDateTo)
6047 Dim objCmd, objRS
6048
6049 Set objCmd = SQLUtilities.SQLConnect.CreateCommand
6050 objCmd.CommandType = 4
6051 objCmd.CommandText = "USR_RAG_SchemeAccounting_Transaction_List_2"
6052 objCmd.Parameters.Refresh
6053
6054 objCmd.Parameters("@AccountNumber").Value = AccountNumber
6055 objCmd.Parameters("@TrxDateFrom").Value = TrxDateFrom
6056 objCmd.Parameters("@TrxDateTo").Value = TrxDateTo
6057
6058 Set objRS = objCmd.Execute
6059 GetAccountListingHTML = AccountListingRSToHTML(objRS)
6060
6061 Set objCmd = Nothing
6062
6063End Function
6064
6065Function AccountListingRSToHTML(objRS)
6066 Dim strReturn, strLastAccount, curSubTotal, curTotal, blnFirst
6067 strReturn = GetAccountListingHeaderHTML()
6068
6069 strReturn = strReturn & _
6070 "<table cellpadding=""0"" cellspacing=""0"" style=""width: 100%; font-size: 100%;"">" & vbNewLine & _
6071 " <tr>" & vbNewline & _
6072 " <th style=""background-color: SteelBlue;"">Journal Entry</th>" & vbNewLine & _
6073 " <th style=""background-color: SteelBlue;"">Voucher No.</th>" & vbNewLine & _
6074 " <th style=""background-color: SteelBlue;"">Series</th>" & vbNewline & _
6075 " <th style=""background-color: SteelBlue;"">Date</th>" & vbNewline & _
6076 " <th style=""background-color: SteelBlue;"">Reference</th>" & vbNewline & _
6077 " <th style=""background-color: SteelBlue;"">Description</th>" & vbNewline & _
6078 " <th style=""background-color: SteelBlue;"">Amount</th>" & vbNewline & _
6079 " </tr>" & vbNewLine
6080
6081 curSubTotal = CCur(0)
6082 curTotal = CCur(0)
6083 blnFirst = True
6084
6085 Do While Not (objRS.BOF Or objRS.EOF)
6086 If strLastAccount <> objRS.Fields("Account Number").Value Then
6087 If Not blnFirst Then
6088 strReturn = strReturn & _
6089 " <tr>" & vbNewLine & _
6090 " <td colspan=""7"" style=""background-color: AliceBlue; text-align: right;"">" & FormatNumber(curSubTotal, 2) & "</td>" & vbNewline & _
6091 " </tr>" & vbNewLine
6092
6093 curSubTotal = CCur(0)
6094 End If
6095
6096 strLastAccount = objRS.Fields("Account Number").Value
6097
6098 strReturn = strReturn & _
6099 " <tr>" & vbNewLine & _
6100 " <td colspan=""7"" style=""background-color: LightBlue"">" & objRS.Fields("Account Number").Value & " - " & objRS.Fields("Account Description").Value & "</td>" & vbNewline & _
6101 " </tr>" & vbNewLine
6102 End If
6103
6104 If objRS.Fields("History TRX").Value = "Yes" Then
6105 strReturn = strReturn & _
6106 " <tr>" & vbNewLine & _
6107 " <td>" & objRS.Fields("Journal Entry").Value & "</td>" & vbNewLine & _
6108 " <td><a href=""" & objRS.Fields("Document Number for Drillback").Value & """ target=""_blank"">" & objRS.Fields("Originating Control Number").Value & "</a></td>" & vbNewLine & _
6109 " <td>" & objRS.Fields("Creditors Name").Value & "</td>" & vbnewline & _
6110 " <td>" & objRS.Fields("TRX Date").Value & "</td>" & vbNewLine & _
6111 " <td>" & objRS.Fields("Reference").Value & "</td>" & vbNewLine & _
6112 " <td>" & objRS.Fields("Description").Value & "</td>" & vbNewLine & _
6113 " <td style=""text-align: right;"">" & FormatNumber(objRS.Fields("Amount").Value, 2) & "</td>" & vbNewline & _
6114 " </tr>" & vbNewLine
6115
6116 Else
6117 strReturn = strReturn & _
6118 " <tr>" & vbNewLine & _
6119 " <td><a href=""" & objRS.Fields("Journal Entry For Drillback").Value & """ target=""_blank"">" & objRS.Fields("Journal Entry").Value & "</a></td>" & vbNewLine & _
6120 " <td><a href=""" & objRS.Fields("Document Number for Drillback").Value & """ target=""_blank"">" & objRS.Fields("Originating Control Number").Value & "</a></td>" & vbNewLine & _
6121 " <td>" & objRS.Fields("Creditors Name").Value & "</td>" & vbnewline & _
6122 " <td>" & objRS.Fields("TRX Date").Value & "</td>" & vbNewLine & _
6123 " <td>" & objRS.Fields("Reference").Value & "</td>" & vbNewLine & _
6124 " <td>" & objRS.Fields("Description").Value & "</td>" & vbNewLine & _
6125 " <td style=""text-align: right;"">" & FormatNumber(objRS.Fields("Amount").Value, 2) & "</td>" & vbNewline & _
6126 " </tr>" & vbNewLine
6127
6128 End If
6129
6130
6131
6132 curSubTotal = curSubTotal + CCur(objRS.Fields("Amount").Value)
6133 curTotal = curTotal + CCur(objRS.Fields("Amount").Value)
6134 blnFirst = False
6135 objRS.MoveNext
6136 Loop
6137
6138 objRS.Close
6139
6140 If Not blnFirst Then
6141 strReturn = strReturn & _
6142 " <tr>" & vbNewLine & _
6143 " <td colspan=""7"" style=""background-color: AliceBlue; text-align: right;"">" & FormatNumber(curSubTotal, 2) & "</td>" & vbNewline & _
6144 " </tr>" & vbNewLine
6145
6146 strReturn = strReturn & _
6147 " <tr>" & vbNewLine & _
6148 " <td colspan=""7"" style=""background-color: AliceBlue; text-align: right; font-weight: bold;"">" & FormatNumber(curTotal, 2) & "</td>" & vbNewline & _
6149 " </tr>" & vbNewLine
6150
6151 End If
6152
6153 strReturn = strReturn & _
6154 "</table>"
6155
6156 AccountListingRSToHTML = strReturn
6157End Function
6158
6159Function GetAccountListingHeaderHTML()
6160 Dim strReturn
6161 strReturn = _
6162 "<table cellpadding=""0"" cellspacing=""0"" style=""width: 100%; table-layout: fixed; font-size: 100%;"">" & vbNewline & _
6163 " <tr>" & vbNewline & _
6164 " <th style=""border-bottom: 2px solid LightBlue; width: 16px;""> </th>" & vbNewline & _
6165 " <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 & _
6166 " <th style=""border-bottom: 2px solid LightBlue; width: 16px;""> </th>" & vbNewline & _
6167 " <th style=""border-bottom: 2px solid LightBlue;""> </th>" & vbNewline & _
6168 " </tr>" & vbNewline & _
6169 "</table>" & vbNewline & _
6170 "<br />"
6171
6172 GetAccountListingHeaderHTML = strReturn
6173End Function
6174
6175Function GetNominalAccountNetChange(AccountNumber, TrxDateFrom, TrxDateTo)
6176 With SQLUtilities.SQLConnect.CreateCommand
6177 .CommandType = 4 'adCmdStoredProc
6178 .CommandText = "USR_RAG_Get_Nominal_Account_Net_Change_2"
6179 .Parameters.Refresh
6180 .Parameters("@AccountNumber").Value = CStr(AccountNumber)
6181 .Parameters("@TrxDateFrom").Value = CDate(TrxDateFrom)
6182 .Parameters("@TrxDateTo").Value = CDate(TrxDateTo)
6183 .Execute
6184 GetNominalAccountNetChange = .Parameters("@NetChange").Value
6185 End With
6186End Function
6187
6188Function GetSDValues(AccountNumber, ServiceDefinitionID, TrxDateFrom, TrxDateTo, ServiceAssetIDs)
6189 With SQLUtilities.SQLConnect.CreateCommand
6190 .CommandType = 4
6191 .CommandText = "USR_RAG_Get_Surplus_Deficit_Values_6"
6192 .Parameters.Refresh
6193 .Parameters("@AccountNumber").Value = CStr(AccountNumber)
6194 .Parameters("@ServiceDefinitionID").Value = CStr(ServiceDefinitionID)
6195 .Parameters("@TrxDateFrom").Value = CDate(TrxDateFrom)
6196 .Parameters("@TrxDateTo").Value = CDate(TrxDateTo)
6197 .Parameters("@ServiceAssetIDs").Value = Cstr(ServiceAssetIDs)
6198 .Execute
6199 GetSDValues= .Parameters("@SDValue").Value
6200 End With
6201End Function
6202
6203Function GetExpenditureValues(AccountNumber, ServiceDefinitionID, TrxDateFrom, TrxDateTo, ServiceAssetIDs)
6204 With SQLUtilities.SQLConnect.CreateCommand
6205 .CommandType = 4
6206 .CommandText = "USR_RAG_Get_Surplus_Deficit_Values_6"
6207 .Parameters.Refresh
6208 .Parameters("@AccountNumber").Value = CStr(AccountNumber)
6209 .Parameters("@ServiceDefinitionID").Value = CStr(ServiceDefinitionID)
6210 .Parameters("@TrxDateFrom").Value = CDate(TrxDateFrom)
6211 .Parameters("@TrxDateTo").Value = CDate(TrxDateTo)
6212 .Parameters("@ServiceAssetIDs").Value = Cstr(ServiceAssetIDs)
6213 .Execute
6214 GetExpenditureValues= .Parameters("@Expenditure").Value
6215 End With
6216End Function
6217
6218Function GetChargeValues(AccountNumber, ServiceDefinitionID, TrxDateFrom, TrxDateTo, ServiceAssetIDs)
6219 With SQLUtilities.SQLConnect.CreateCommand
6220 .CommandType = 4
6221 .CommandText = "USR_RAG_Get_Surplus_Deficit_Values_6"
6222 .Parameters.Refresh
6223 .Parameters("@AccountNumber").Value = CStr(AccountNumber)
6224 .Parameters("@ServiceDefinitionID").Value = CStr(ServiceDefinitionID)
6225 .Parameters("@TrxDateFrom").Value = CDate(TrxDateFrom)
6226 .Parameters("@TrxDateTo").Value = CDate(TrxDateTo)
6227 .Parameters("@ServiceAssetIDs").Value = Cstr(ServiceAssetIDs)
6228 .Execute
6229 GetChargeValues= .Parameters("@Charges").Value
6230 End With
6231End Function
6232
6233Function GetAOAValues(AccountNumber, ServiceDefinitionID, TrxDateFrom, TrxDateTo, ServiceAssetIDs)
6234 With SQLUtilities.SQLConnect.CreateCommand
6235 .CommandType = 4
6236 .CommandText = "USR_RAG_Get_Admin_On_Actuals"
6237 .Parameters.Refresh
6238 .Parameters("@AccountNumber").Value = CStr(AccountNumber)
6239 .Parameters("@ServiceDefinitionID").Value = CStr(ServiceDefinitionID)
6240 .Parameters("@TrxDateFrom").Value = CDate(TrxDateFrom)
6241 .Parameters("@TrxDateTo").Value = CDate(TrxDateTo)
6242 .Parameters("@ServiceAssetIDs").Value = CStr(ServiceAssetIDs)
6243 .Execute
6244 GetAOAValues= .Parameters("@AOAValue").Value
6245 End With
6246End Function
6247
6248Function GetSchemeAccExpenditure(ServiceDefinitionID, CostCentre, CostAccount, ChargeFromDate, ChargeToDate)
6249 With SQLUtilities.SQLConnect.CreateCommand
6250 .CommandType = 4
6251 .CommandText = "usr_RAG_Get_SchemeAcc_Expenditure"
6252 .Parameters.Refresh
6253 .Parameters("@Service_Definition_ID").Value = ServiceDefinitionID
6254 .Parameters("@Cost_Centre_VC").Value = CStr(CostCentre)
6255 .Parameters("@Cost_Account_VC").Value = CStr(CostAccount)
6256 .Parameters("@Charge_From_DT").Value = CDate(ChargeFromDate)
6257 .Parameters("@Charge_To_DT").Value = CDate(ChargeToDate)
6258 .Execute
6259 GetSchemeAccExpenditure = CStr(.Parameters("@Expenditure_DC").Value)
6260 GetSchemeAccExpenditure = GetSchemeAccExpenditure & "*" & CStr(.Parameters("@Expenditure_Inflated_DC").Value)
6261 GetSchemeAccExpenditure = GetSchemeAccExpenditure & "*" & CStr(.Parameters("@Expenditure_Individual_Percentage_DC").Value)
6262 GetSchemeAccExpenditure = GetSchemeAccExpenditure & "*" & CStr(.Parameters("@Expenditure_Communal_Percentage_DC").Value)
6263 GetSchemeAccExpenditure = GetSchemeAccExpenditure & "*" & CStr(.Parameters("@Expenditure_Communal_Car_Park_Percentage_DC").Value)
6264 GetSchemeAccExpenditure = GetSchemeAccExpenditure & "*" & CStr(.Parameters("@Expenditure_Admin_DC").Value)
6265 End With
6266End Function
6267
6268Function GetSchemeAccIncome(ServiceDefinitionID, CostCentre, ChargeFromDate, ChargeToDate, AssetIDs)
6269 With SQLUtilities.SQLConnect.CreateCommand
6270 .CommandType = 4
6271 .CommandText = "usr_RAG_Get_SchemeAcc_Income_Affordable"
6272 .Parameters.Refresh
6273 .Parameters("@Service_Definition_ID").Value = ServiceDefinitionID
6274 .Parameters("@Cost_Centre_VC").Value = CStr(CostCentre)
6275 .Parameters("@Charge_From_DT").Value = CDate(ChargeFromDate)
6276 .Parameters("@Charge_To_DT").Value = CDate(ChargeToDate)
6277 .Parameters("@Asset_IDs").Value = CStr(AssetIDs)
6278 .Execute
6279 GetSchemeAccIncome = CStr(.Parameters("@Charge_DC").Value)
6280 GetSchemeAccIncome = GetSchemeAccIncome & "*" & CStr(.Parameters("@Charge_Admin_DC").Value)
6281 End With
6282End Function
6283
6284Function CreateSchemeAccDynamicsInvoices(CostCentre, CostAccount, ChargeFromDate, ChargeToDate)
6285 With SQLUtilities.SQLConnect.CreateCommand
6286 .CommandType = 4
6287 .CommandText = "usr_RAG_Get_SchemeAcc_Dynamics_Invoices"
6288 .Parameters.Refresh
6289 .Parameters("@Cost_Centre_VC").Value = CStr(CostCentre)
6290 .Parameters("@Cost_Account_VC").Value = CStr(CostAccount)
6291 .Parameters("@Charge_From_DT").Value = CDate(ChargeFromDate)
6292 .Parameters("@Charge_To_DT").Value = CDate(ChargeToDate)
6293 .Execute
6294 End With
6295End Function
6296
6297Function getSchemeAccParts(ServiceDefinitionID, ServiceCharge, AssetID)
6298 dim strSQL
6299 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)
6300 with sqlconnection.execute(strSQL)
6301 do until .eof
6302 getSchemeAccParts = .fields(0)
6303 .movenext
6304 loop
6305 end with
6306end function
6307
6308function importOrderInfo(file)
6309 Dim objExcel, objwkbk, intRow, assetID, sorCode, Qty, Comments, ContractID, strSQL
6310
6311 set objExcel = CreateObject("Excel.Application")
6312 set objwkbk = objExcel.Workbooks.Open(file)
6313
6314 intRow = 2
6315
6316 strsqla = ("Delete from RHA_USR_OrderCreate_T")
6317
6318 with sqlconnection.execute (strsqla)
6319 end with
6320
6321 do until objExcel.cells(intRow,1) = ""
6322 assetID = objExcel.Cells(intRow, 2).Value
6323 sorCode = objExcel.Cells(intRow, 3).Value
6324 Qty = objExcel.Cells(intRow, 4).Value
6325 Comments = objExcel.Cells(intRow, 5).Value
6326 ContractID = objExcel.Cells(intRow, 6).Value
6327
6328 strSQL = ("Insert Into RHA_USR_OrderCreate_T (AssetID, SORCode, Qty, Comments, ContractID) Values (" & AssetID & ",'" & sorCode & "'," & Qty & ",'" & Comments & "'," & ContractID & ")")
6329
6330 with sqlconnection.execute(strSQL)
6331 end with
6332 introw = introw + 1
6333 loop
6334
6335 objwkbk.close
6336 objExcel.Quit
6337End Function
6338
6339Function CreateOrderFile(File)
6340 Dim fso, txtstream
6341
6342 set fso = CreateObject("Scripting.FileSystemObject")
6343
6344 File = cstr(File)
6345 set txtstream = fso.CreateTextFile(File, True)
6346End Function
6347
6348Function addOrderInfoToFile(FilePath, LineInfo)
6349 dim fso, txtstream
6350
6351 set fso = CreateObject("Scripting.FileSystemObject")
6352 Set txtstream = fso.OpenTextFile(FilePath,8)
6353
6354 txtstream.Write LineInfo
6355 txtstream.Close
6356
6357End Function
6358
6359
6360
6361' /_/_/ ACL Functions 07854-655009 - /_/_/
6362
6363Private Function ACLReadLineFromCSVFile(File, Lin)
6364 Dim fso
6365 Dim txtstream
6366 Const ForReading = 1, ForWriting = 2, ForAppending = 8
6367 set fso=CreateObject("Scripting.FileSystemObject")
6368 set txtstream=fso.OpenTextFile(File, ForReading, True)
6369 For x = 1 to Lin
6370 ACLReadLineFromCSVFile = "-EOF-"
6371 if not txtstream.AtEndOfStream then
6372 ACLReadLineFromCSVFile = txtstream.ReadLine
6373 end if
6374 Next
6375 txtstream.Close
6376End Function
6377
6378Function SQLExec(VarExecute)
6379 SQLConnection.Execute(varExecute)
6380End Function
6381
6382
6383Private Function ACLSQLExecResult(VarExecute, ResCol)
6384 If ResCol = "" then
6385 SQLConnection.Execute(VarExecute)
6386 Exit Function
6387 End if
6388 With SQLConnection.Execute(varExecute)
6389 Do Until .EOF
6390 ACLSQLExecResult = .Fields( ResCol ).Value
6391 .MoveNext
6392 Loop
6393 End With
6394End Function
6395
6396
6397Private Function ACLField( FullString , Delim , Occurance )
6398 'FIELD' function
6399 ACLField = ""
6400 If Len(FullString) = Len(Delim) Or Len(FullString) < Occurance Then Exit Function
6401 Tempstring = Delim & FullString & Delim
6402 Pos2 = 1
6403 For Y = 1 To Occurance
6404 Pos1 = InStr(Pos2, Tempstring, Delim, 1)
6405 Pos2 = InStr(Pos1 + 1, Tempstring, Delim, 1)
6406 If Pos2 = 0 Then Exit Function
6407 Temp = Mid(Tempstring, Pos1 + 1, Pos2 - Pos1 - 1)
6408 Next
6409 ACLField = Temp
6410End Function
6411
6412' /_/_/ End of ACL Functions 07854-655009 - /_/_/
6413
6414
6415'****Dynamics Interface - Web Component- - START ****
6416Function CreateRentRefundAddress(varCreditorID,varAccountID,varAddress1,varAddress2,varAddress3,varCounty,varPostCode,varTelNum,varEmail,varBankName,varBankNumber,varBankSort)
6417 Dim objUtils 'As AMSDynamicsGPWeb.GPUtilities
6418 Dim objDoc 'As AMSDynamicsGPWeb.CreditorAddress
6419
6420 Set objUtils = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.GPUtilities")
6421
6422 Set objUtils = mCreateGPUtilities
6423
6424 Set objDoc = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.CreditorAddress")
6425
6426 With objDoc
6427 .CreditorID = CStr(varCreditorID)
6428 .AddressCode = CStr(varAccountID)
6429 .Address1 = CStr(varAddress1)
6430 .Address2 = CStr(varAddress2)
6431 .Address3 = CStr(varAddress3)
6432 .County = CStr(varCounty)
6433 .Postcode = CStr(varPostCode)
6434 .TelephoneNumber1 = CStr(varTelNum)
6435 .TaxScheduleID = "PS"
6436 .EmailAddress = CStr(varEmail)
6437 .EmailToAddress = ""
6438 .UserDefined1 = ""
6439 .WebsiteAddress = ""
6440 .BankAccountCountryRegion = 3
6441 .BankAccountName = CStr(varBankName)
6442 .BankAccountNumber = CStr(varBankNumber)
6443 .BankAccountSortCode = CStr(varBankSort)
6444 End With
6445
6446 On Error Resume Next
6447
6448 objUtils.Connect
6449
6450 objUtils.PostTransaction objUtils.Cast_IPostable(objDoc)
6451 If Err.Number <> 0 Then
6452 MsgBox Err.Description & vbnewline & err.source, vbCritical
6453 Else
6454 CreateRentRefundAddress = objDoc.AddressCode
6455 End If
6456
6457 objUtils.CloseConnection
6458
6459 Set objDoc = Nothing
6460 Set objUtils = Nothing
6461End Function
6462
6463Function CreateRentsInvoice(varBatchNumber,varCreditorID,varDescription,varDocumentNumber,varNetTotal,varVATTotal,TransactionID,varAccountID)
6464 Dim objUtils 'As AMSDynamicsGPWeb.GPUtilities
6465 Dim objDoc 'As AMSDynamicsGPWeb.PMTransaction
6466
6467 Set objUtils = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.GPUtilities")
6468
6469 Set ObjUtils = mCreateGPUtilities
6470
6471 Set objDoc = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.PMTransaction")
6472
6473 With objDoc
6474 .BatchNumber = CStr(varBatchNumber)
6475 .CreditorID = CStr(varCreditorID)
6476 .Description = CStr(varDescription)
6477 .DocumentDate = Now
6478 .DocumentType = 1
6479 .DocumentNumber = CStr(varDocumentNumber)
6480 .NetTotal = CStr(varNetTotal)
6481 .VATTotal = CStr(varVATTotal)
6482 .RemitToAddressID = CStr(varAccountID)
6483
6484 End With
6485
6486 mAddRentsInvoiceLines objDoc, TransactionID
6487
6488 On Error Resume Next
6489
6490 objUtils.Connect
6491
6492 objUtils.PostTransaction objUtils.Cast_IPostable(objDoc)
6493 If Err.Number <> 0 Then
6494 MsgBox Err.Description & vbnewline & err.source, vbCritical
6495 Else
6496 CreateRentsInvoice = objDoc.VoucherNumber
6497 End If
6498
6499 objUtils.CloseConnection
6500
6501 Set objDoc = Nothing
6502 Set objUtils = Nothing
6503
6504End Function
6505
6506Sub mAddRentsInvoiceLines(objDoc, TransactionID)
6507 Dim objCmd, objRS
6508 Dim objUtils
6509
6510 Set objCmd = SQLUtilities.SQLConnect.CreateCommand
6511 objCmd.CommandType = 4 'Stored Proc
6512 objCmd.CommandText = "USR_SW_Rents_Get_Invoice_Lines"
6513 objCmd.Parameters.Refresh
6514 objCmd.Parameters("@TransactionID").Value = TransactionID
6515
6516 Set objRS = objCmd.Execute
6517
6518 Do While Not (objRS.BOF Or objRS.EOF)
6519 With objDoc.TransactionLines.Add
6520 .NominalAccount = objRS.Fields("Nominal_Account_VC").Value
6521 .Reference = objRS.Fields("Reference_VC").Value
6522 .NetValue = objRS.Fields("Value_DC").Value
6523 .VATValue = objRS.Fields("VAT_Value_DC").Value
6524 .VATCode = objRS.Fields("VAT_Code_IN").Value
6525 End With
6526
6527 objRS.MoveNext
6528 Loop
6529
6530 objRS.Close
6531
6532 Set objRS = Nothing
6533 Set objCmd = Nothing
6534End Sub
6535
6536Function CreateRepairsJournal(varBatchNumber,varReference,varSourceDocument, DocumentID,varAuthorisedDate)
6537 Dim objUtils 'As AMSDynamicsGPWeb.GPUtilities
6538 Dim objDoc 'As AMSDynamicsGPWeb.GLTransaction
6539
6540 Set objUtils = mCreateGPUtilities
6541
6542 Set objDoc = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.GLTransaction")
6543
6544 With objDoc
6545 .BatchNumber = "" & varBatchNumber
6546 .Reference = "" & varReference
6547 .TransactionDate = "" & varAuthorisedDate
6548 .TransactionType = 0
6549 .SourceDocument = "" & varSourceDocument
6550 End With
6551
6552 mAddRepairsJournalLines objDoc, DocumentID
6553
6554 On Error Resume Next
6555
6556 objUtils.Connect
6557
6558 objUtils.PostTransaction objUtils.Cast_IPostable(objDoc)
6559 If Err.Number <> 0 Then
6560 'MsgBox Err.Description & vbnewline & err.source, vbCritical
6561 Else
6562 CreateRepairsJournal = objDoc.JournalEntryNumber
6563 End If
6564
6565 objUtils.CloseConnection
6566
6567 Set objDoc = Nothing
6568 Set objUtils = Nothing
6569
6570End Function
6571
6572Function CreateRentsJournal(varBatchNumber,varReference,varSourceDocument, TransactionID)
6573 Dim objUtils 'As AMSDynamicsGPWeb.GPUtilities
6574 Dim objDoc 'As AMSDynamicsGPWeb.GLTransaction
6575
6576 Set objUtils = mCreateGPUtilities
6577
6578 Set objDoc = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.GLTransaction")
6579
6580 With objDoc
6581 .BatchNumber = "" & varBatchNumber
6582 .Reference = "" & varReference
6583 .TransactionDate = Now
6584 .TransactionType = 0
6585 .SourceDocument = "" & varSourceDocument
6586 End With
6587
6588 mAddRentsJournalLines objDoc, TransactionID
6589
6590 On Error Resume Next
6591
6592 objUtils.Connect
6593
6594 objUtils.PostTransaction objUtils.Cast_IPostable(objDoc)
6595 If Err.Number <> 0 Then
6596 MsgBox Err.Description & vbnewline & err.source, vbCritical
6597 Else
6598 CreateRentsJournal = objDoc.JournalEntryNumber
6599 End If
6600
6601 objUtils.CloseConnection
6602
6603 Set objDoc = Nothing
6604 Set objUtils = Nothing
6605
6606End Function
6607
6608Function mCreateGPUtilities()
6609 Dim objCmd, objRS
6610 Dim objUtils
6611
6612 Set objCmd = SQLUtilities.SQLConnect.CreateCommand
6613 objCmd.CommandType = 4 'Stored Proc
6614 objCmd.CommandText = "USR_SW_Shared_Dynamics_GP_Integration_Settings"
6615
6616 Set objRS = objCmd.Execute
6617
6618 If Not (objRS.BOF Or objRS.EOF) Then
6619 Set objUtils = CreateObject("Ams.MicrosoftDynamicsGP.AMSDynamicsGPWeb.GPUtilities")
6620
6621 With objUtils
6622 .Server = CStr(objRS.Fields("GP_Server_VC").Value)
6623 .Connect
6624 .ChangeCompany CStr(objRS.Fields("GP_DBName_VC").Value)
6625 .CloseConnection
6626 .XMLSavePath = CStr(objRS.Fields("Document_Export_Path_VC").Value)
6627 End With
6628
6629 Set mCreateGPUtilities = objUtils
6630 End If
6631
6632 objRS.Close
6633
6634 Set objRS = Nothing
6635 Set objCmd = Nothing
6636End Function
6637
6638Sub mAddRepairsJournalLines(objDoc, DocumentID)
6639 Dim objCmd, objRS
6640 Dim objUtils
6641
6642 Set objCmd = SQLUtilities.SQLConnect.CreateCommand
6643 objCmd.CommandType = 4 'Stored Proc
6644 objCmd.CommandText = "USR_SW_Repairs_Get_Reallocation_Journal_Lines"
6645 objCmd.Parameters.Refresh
6646 objCmd.Parameters("@Document_ID").Value = DocumentID
6647
6648 Set objRS = objCmd.Execute
6649
6650 Do While Not (objRS.BOF Or objRS.EOF)
6651 With objDoc.TransactionLines.Add
6652 .NominalAccount = objRS.Fields("Nominal_Account_VC").Value
6653 .Reference = objRS.Fields("Reference_VC").Value
6654 .LineValue = objRS.Fields("Value_DC").Value
6655 End With
6656
6657 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 & "')"
6658
6659 With SQLconnection.Execute(varSQL)
6660 End With
6661
6662 objRS.MoveNext
6663 Loop
6664
6665 objRS.Close
6666
6667 Set objRS = Nothing
6668 Set objCmd = Nothing
6669End Sub
6670
6671Sub mAddRentsJournalLines(objDoc, TransactionID)
6672 Dim objCmd, objRS
6673 Dim objUtils
6674
6675 Set objCmd = SQLUtilities.SQLConnect.CreateCommand
6676 objCmd.CommandType = 4 'Stored Proc
6677 objCmd.CommandText = "USR_SW_Rents_Get_Reallocation_Journal_Lines"
6678 objCmd.Parameters.Refresh
6679 objCmd.Parameters("@TransactionID").Value = TransactionID
6680
6681 Set objRS = objCmd.Execute
6682
6683 Do While Not (objRS.BOF Or objRS.EOF)
6684 With objDoc.TransactionLines.Add
6685 .NominalAccount = objRS.Fields("Nominal_Account_VC").Value
6686 .Reference = objRS.Fields("Reference_VC").Value
6687 .LineValue = objRS.Fields("Value_DC").Value
6688 End With
6689
6690 objRS.MoveNext
6691 Loop
6692
6693 objRS.Close
6694
6695 Set objRS = Nothing
6696 Set objCmd = Nothing
6697End Sub
6698
6699Function InsertIntoRepairsUDFIProcessedDocuments(varDocumentID,varProcessedBy)
6700 varSelect = "insert into usr_SW_Repairs_UDFI_Processed_Documents_T(Document_ID,Processed_DT,Processed_By_VC) values (" & varDocumentID & ",getdate(),'" & varProcessedBy & "')"
6701
6702 With SQLConnection.Execute(varSelect)
6703 End With
6704
6705End Function
6706
6707Function InsertIntoRentsUDFIProcessedTransactions(varAccountID,varTransactionID,varProcessedBy)
6708 varSelect = "insert into usr_SW_Rents_UDFI_Processed_Transactions_T(Account_ID,Transaction_ID,Processed_DT,Processed_By_VC) values ('" & varAccountID & "','" & varTransactionID & "',getdate(),'" & varProcessedBy & "')"
6709
6710 With SQLConnection.Execute(varSelect)
6711 End With
6712
6713End Function
6714
6715Function InsertIntoRentsUDFIProcessedInvoices(varAccountID,varTransactionID,varInvoiceID,varProcessedBy)
6716 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 & "')"
6717
6718 With SQLConnection.Execute(varSelect)
6719 End With
6720
6721End Function
6722
6723
6724'***************Unite*********************
6725
6726
6727Function DeleteFromCancelledApplicationAuditTable(varApplicationID)
6728
6729 varDelete = "delete from usr_SW_Lettings_Cancelled_Application_Audit_T where Application_ID = " & varApplicationID
6730
6731 with SQLConnection.Execute(varDelete)
6732 end with
6733
6734End Function
6735
6736
6737Function UpdateEmergencyTransferTaskingAudit(varMatchID,varTaskID,varUsername)
6738
6739 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 & "')"
6740
6741 With SQLConnection.Execute(varSelect)
6742 End With
6743
6744End Function
6745
6746Function InsertIntoViewingAndSignupAuditTable(varMatchID,varOfferID,varApplicationID,varTaskID)
6747
6748 varInsert = "insert into usr_SW_Lettings_Viewing_and_Signup_T(Match_ID,Offer_ID,Application_ID,Task_ID) values (" & varMatchID & "," & varOfferID & "," & varApplicationID & "," & varTaskID & ")"
6749
6750 with SQLConnection.Execute(varInsert)
6751 end with
6752
6753End Function
6754
6755Function UpdateEpisodeAndPoliciesAuditTable(varEpisodeID,varOriginalPolicyID,varPolicyID)
6756
6757 varInsert = "insert into usr_SW_Lettings_Episode_Policy_Audit_T (Episode_ID,Original_Policy_ID,Policy_ID) values (" & varEpisodeID & "," & varOriginalPolicyID & "," & varPolicyID & ")"
6758
6759 With SQLConnection.Execute(varInsert)
6760 End With
6761
6762End Function
6763
6764Function DeleteFromEpisodePolicyAuditTable(varEpisodeID)
6765
6766 varSelect = "delete from usr_SW_Lettings_Episode_Policy_Audit_T where Episode_ID = " & varEpisodeID & ""
6767
6768 With SQLConnection.Execute(varSelect)
6769 End With
6770
6771End Function
6772
6773
6774Function UpdateGenerateActionFailedTable(varAccountID,varNextAction)
6775
6776 varInsert = "insert into usr_SW_Debt_Management_Generate_Action_Failed_T (Account_ID,Next_Action_VC) values ('" & varAccountID & "','" & varNextAction & "')"
6777
6778 With SQLConnection.Execute(varInsert)
6779 End With
6780
6781End Function
6782
6783Function DeleteFromGenerateActionFailedTable(varAccountID,varNextAction)
6784
6785 varDelete = "delete from usr_SW_Debt_Management_Generate_Action_Failed_T where Account_ID = '" & varAccountID & "' and Next_Action_VC = '" & varNextAction & "'"
6786
6787 With SQLConnection.Execute(varDelete)
6788 End With
6789
6790End Function
6791
6792Function UpdateDMTaskingAuditT(varAccountID,varWorkflowRef,varTaskID,varEpisodeID)
6793
6794 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 & "')"
6795
6796 with SQLConnection.Execute(varInsert)
6797 End with
6798End Function
6799
6800Function UpdateDMTaskingAuditTCourtOutcome(varAccountID,varWorkflowRef,varTaskID,varEpisodeID,varMonitoringLevel,varHearingDate)
6801
6802 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 & "')"
6803
6804'msgBox varInsert
6805
6806 with SQLConnection.Execute(varInsert)
6807 end with
6808End Function
6809Function UpdateDMTaskingAuditTWFDM010(varAccountID,varWorkflowRef,varTaskID,varMonitoringLevel)
6810
6811 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 & "')"
6812
6813 with SQLConnection.Execute(varInsert)
6814 End with
6815End Function
6816
6817Function UpdateCourtDetailsTrackerT(varAccountID,varEpisodeID,varCourtOrderCode,varDaysUntilEnforcement,varMoneyJudgement,varCourtOrderNumber,varTermsOfOrder,varCourtOrderCosts)
6818
6819 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 & "'"
6820
6821 with SQLConnection.Execute(varUpdate)
6822 End with
6823End Function
6824
6825Function InsertIntoCourtDetailsTrackerT(varAccountID,varEpisodeID,varCourtOrderCode,varDaysUntilEnforcement,varMoneyJudgement,varCourtOrderNumber,varTermsOfOrder,varCourtOrderCosts)
6826
6827 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())"
6828
6829 with SQLConnection.Execute(varInsert)
6830 End with
6831End Function
6832
6833Function InsertIntoGatewaySubmissionErrorsT(varXMLFile,varFileName,varResponse)
6834
6835 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())"
6836
6837 with SQLConnection.Execute(varInsert)
6838 End with
6839
6840End Function
6841
6842Function SendSMSDebtManagement(TargetNumber, MessageBody)
6843 Dim varExecute
6844
6845 SendSMSDebtManagement = False
6846
6847 'varExecute = _
6848 '"INSERT INTO Shared_SMS_Outbox_T (Status_ID,Recipient_VC,Message_VC,Sent_User_ID) VALUES(0,'" & TargetNumber & "','" & MessageBody & "',1)"
6849 'SQLConnection.Execute(varExecute)
6850 SendSMSDebtManagement = True
6851end function
6852
6853Function UpdateEvictionTrackerT(varAccountID,varAccountEpisodeID,varEvictionDate,varEvictionTime)
6854
6855 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 & "'"
6856
6857 with SQLConnection.Execute(varUpdate)
6858 End with
6859End Function
6860
6861Function UpdateEvictionAppealTrackerT(varAccountID,varAccountEpisodeID,varAppealDate,varAppealTime)
6862
6863 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 & "'"
6864
6865 with SQLConnection.Execute(varUpdate)
6866 End with
6867End Function
6868
6869Function InsertIntoEvictionTrackerT(varAccountID,varAccountEpisodeID,varEvictionDate,varEvictionTime)
6870
6871 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 & "')"
6872
6873 with SQLConnection.Execute(varInsert)
6874 End with
6875End Function
6876
6877Function InsertIntoEvictionAppealTrackerT(varAccountID,varAccountEpisodeID,varAppealDate,varAppealTime)
6878
6879 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 & "')"
6880
6881 with SQLConnection.Execute(varInsert)
6882 End with
6883End Function
6884
6885Function UpdateDebtManagementLogSuccess(varAccountID,varCurrentAction,varNextAction,varMonitoringLevel)
6886
6887 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)"
6888
6889 With SQLConnection.Execute(varUpdate)
6890 End With
6891
6892End Function
6893
6894Function UpdateDebtManagementLogFailure(varAccountID,varCurrentAction,varNextAction,varMonitoringLevel)
6895
6896 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)"
6897
6898 With SQLConnection.Execute(varUpdate)
6899 End With
6900
6901End Function
6902
6903Function PrepareXMLForSubmission(varXML)
6904
6905 HTML = replace(replace(varXML,"<","<"),">",">")
6906 PrepareXMLForSubmission = HTML
6907
6908End Function
6909
6910Function PrepareForContractors(varHTML)
6911
6912 XML = replace(replace(varHTML,"<","<"),">",">")
6913 PrepareForContractors = XML
6914
6915End Function
6916
6917Function SendXML(varSite,varRequest)
6918'msgbox varRequest
6919DIM WebRequest
6920SET WebRequest = CreateObject ("MSXML2.XMLHTTP")
6921
6922WITH WebRequest
6923 .Open "POST", varSite , False
6924 .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
6925 .setRequestHeader "SOAPAction", "http://www.mis-ams.com/GatewaySubmission"
6926 .send varRequest
6927 'If .Status >= 400 And .Status <= 599 Then msgbox( "Error Occurred : " & .Status & " - " & .statusText)
6928 SendXML = .responseText
6929
6930END WITH
6931
6932SET WebRequest = Nothing
6933
6934End Function
6935
6936Function VerifyFile(Filename)
6937Dim fso
6938Not_Found = 0
6939set fso=CreateObject("Scripting.FileSystemObject")
6940If fso.FileExists(Filename) Then
6941Not_Found = 1
6942Else
6943Not_Found = 0
6944End If
6945VerifyFile = Not_Found
6946End Function
6947
6948
6949
6950Function CheckDirectory(fldr)
6951 On Error resume Next:err.clear
6952 Dim fso, msg
6953 msg = False
6954 Set fso = CreateObject("Scripting.FileSystemObject")
6955 If fso.FolderExists(fldr) Then msg = True Else msg = False End If
6956 CheckDirectory = msg
6957End Function
6958
6959Function VoidManagementSpecTemplateImport(varFile)
6960 Dim strSQL, objApp, objWkbk, intRow, sqlDEL, Quantity, SORCode, Priority, TenRecharge, ContractID, AssetID, Location
6961
6962 sqlDEL = "Delete from usr_SW_Void_Management_Spec_Import_T"
6963 With sqlconnection.execute (sqlDEL)
6964 End With
6965
6966 set objApp = createObject("Excel.Application")
6967 set objWkbk = objApp.Workbooks.Open(varFile)
6968
6969 ContractID = objApp.Cells(3, 2).Value
6970 AssetID = objApp.Cells(4, 2).Value
6971
6972 intRow = 8
6973
6974 do until objApp.cells(intRow, 2) = ""
6975 If len(objApp.Cells(intRow, 1).Value) = 0 Then Quantity = 0 Else Quantity = objApp.Cells(intRow, 1).Value End If
6976 SORCode = objApp.Cells(intRow, 2).Value
6977 TenRecharge = replace(objApp.Cells(intRow, 4).Value ,"a",1)
6978 JobType = objApp.Cells(intRow, 6).Value
6979 Location = objApp.Cells(intRow, 7).Value
6980
6981 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 & "')"
6982
6983 With sqlconnection.execute(strsql)
6984 End With
6985
6986 intRow = intRow +1
6987 loop
6988
6989 objWkbk.close
6990 objApp.quit
6991
6992 strDEL = "delete from usr_SW_Void_Management_Spec_Import_T where Quantity_DC = 0"
6993
6994 With SQLConnection.Execute(strDEL)
6995 End With
6996
6997End Function
6998
6999Function UpdateDMJointLetterAudit(varMergeLetterID,varDataSource,varMailmergeID)
7000
7001 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 & ")"
7002
7003 With SQLConnection.Execute(varUpdate)
7004 End With
7005
7006End Function
7007
7008Function GenerateWebSecurityPassword
7009 With SQLUtilities.SQLConnect.CreateCommand
7010 .CommandType = 4 'adCmdStoredProc
7011 .CommandText = "USR_SW_TIPS_GenerateRandomPassword"
7012 .Parameters.Refresh
7013 .Execute
7014 GenerateWebSecurityPassword = .Parameters("@Password").Value
7015 End With
7016End Function
7017
7018Function UpdateWebSecurityPassword(varContactID,varNewPassword)
7019 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 & ""
7020
7021 With SQLConnection.Execute(varUpdate)
7022 End With
7023
7024End Function
7025
7026Function FilesInDirectory(varDirectory)
7027 Dim fs, fo, x, varFileListing, varSep
7028 Set fs = CreateObject("Scripting.FileSystemObject")
7029 Set fo = fs.GetFolder(varDirectory)
7030 varFileListing = ""
7031 varSep = ""
7032 For Each x In fo.files
7033 varFileListing = x.Name & varSep & varFileListing
7034 varSep = ","
7035 Next
7036 Set fo = Nothing
7037 Set fs = Nothing
7038 FilesInDirectory = varFileListing
7039End Function
7040
7041Function MoveFile(varMoveFrom,varMoveTo)
7042 On Error resume Next:err.clear
7043 Dim fso
7044 Set fso = CreateObject("Scripting.FileSystemObject")
7045 fso.MoveFile varMoveFrom, varMoveTo
7046 Set fso = Nothing
7047 If Err.Number = 0 Then MoveFile = err.description
7048End Function
7049
7050Function VerifyFile(Filename)
7051Dim fso
7052Not_Found = 0
7053set fso=CreateObject("Scripting.FileSystemObject")
7054If fso.FileExists(Filename) Then
7055Not_Found = 1
7056Else
7057Not_Found = 0
7058End If
7059VerifyFile = Not_Found
7060End Function
7061
7062Function ReadFromCSVFile(File)
7063 Dim fso
7064 Dim txtstream
7065 Const ForReading = 1, ForWriting = 2, ForAppending = 8
7066 set fso=CreateObject("Scripting.FileSystemObject")
7067 set txtstream=fso.OpenTextFile(File, ForReading, True)
7068 ReadFromCSVFile = txtstream.ReadLine
7069 txtstream.Close
7070End Function
7071
7072Function ConvertCOOPUnpaidDD(FileName)
7073
7074 dim objFSO
7075 dim COOPFile
7076 dim COOPText
7077 dim OutputFile
7078 dim lngCount
7079 dim reflen
7080
7081 Set objFSO = CreateObject("Scripting.FileSystemObject")
7082
7083 If not objFSO.FileExists(FileName) Then
7084 MSGBOX "File cannot be found",vbCritical+vbOKONly,"COOP Unpaid DD Payment File Re Format"
7085 Else
7086 Set COOPFile = objFSO.OpenTextFile(FileName, 1, True)
7087 Set OutputFile = objFSO.CreateTextFile(replace(FileName,".csv"," - reformat.csv"),2,True)
7088 lngcount = 0
7089 Do While Not COOPFile.AtEndOfStream
7090 COOPText= COOPFile.ReadLine
7091 lngCount = lngCount + 1
7092 If lngCount > 7 Then
7093 If SQLUtilities.Globals.Field(cstr(COOPText),",",1) <> "Comment:" and SQLUtilities.Globals.Field(cstr(COOPText),",",1) <> "" and SQLUtilities.Globals.Field(cstr(COOPText),",",14) <> "" then
7094 transactiondate = SQLUtilities.Globals.Field(cstr(COOPText),",",14)
7095 transactionamount = SQLUtilities.Globals.Field(cstr(COOPText),",",7)
7096 transactionreference = replace(SQLUtilities.Globals.Field(cstr(COOPText),",",1)," ","")
7097 If IsNumeric(transactionreference) = "False" Then
7098 reflen = Len(transactionreference) - 1
7099 transactionreference = Left(transactionreference,reflen)
7100 End If
7101 outputfile.Writeline transactionreference & ",unpaid " & transactiondate & ",-" & transactionamount
7102 End If
7103 End If
7104 Loop
7105 OutputFile.Close
7106 COOPFile.Close
7107 msgbox "Re Format of COOP Unpaid DD Import File Finished",vbinformation+vbokonly,"COOP Unpaid DD Payment File Re Format"
7108 End If
7109End Function
7110
7111
7112Function UpdateRobustAsbestosSurveyAuditT(varCaseID,varTaskID)
7113
7114 varSelect = "insert into usr_SW_Void_Management_Robust_Asbestos_Audit_T(Case_ID,Task_ID) values (" & varCaseID & "," & varTaskID & ")"
7115
7116 With SQLConnection.Execute(varSelect)
7117 End With
7118
7119End Function
7120
7121Function UpdateUpcomingPostInspectionAuditT(varCaseID,varTaskID)
7122
7123 varSelect = "insert into usr_SW_Void_Management_Upcoming_Post_Inspection_Audit_T(Case_ID,Task_ID) values (" & varCaseID & "," & varTaskID & ")"
7124
7125 with SQLConnection.Execute(varSelect)
7126 end with
7127
7128End Function
7129
7130Function InsertIntoEmailAuditT(varContactID,varPassword)
7131
7132 varSelect = "INSERT INTO usr_SW_TIPS_WebSecurity_EmailAudit_T (Contact_ID,Password_VC) values (" & varContactID & ",'" & varPassword & "')"
7133
7134 WITH SQLConnection.Execute(varSelect)
7135 END WITH
7136
7137END Function
7138
7139Function DeleteFromEmailAuditT(varContactID)
7140
7141 varSelect = "Delete from usr_SW_TIPS_WebSecurity_EmailAudit_T WHERE Contact_ID = " & varContactID & ""
7142
7143 WITH SQLConnection.Execute(varSelect)
7144 END WITH
7145
7146End Function
7147
7148Function GenerateWebSecurityPassword
7149 With SQLUtilities.SQLConnect.CreateCommand
7150 .CommandType = 4 'adCmdStoredProc
7151 .CommandText = "USR_SW_TIPS_GenerateRandomPassword"
7152 .Parameters.Refresh
7153 .Execute
7154 GenerateWebSecurityPassword = .Parameters("@Password").Value
7155 End With
7156End Function
7157
7158Function UpdateWebSecurityPassword(varContactID,varNewPassword)
7159 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 & ""
7160
7161 With SQLConnection.Execute(varUpdate)
7162 End With
7163
7164End Function
7165
7166Function Usr_HPM_Automated_Desktop_Task
7167
7168 Dim objCmd
7169 Dim ErrorCode
7170
7171 Set objCmd = SQLUtilities.SQLConnect.CreateCommand
7172 objCmd.CommandType = 4 'Stored Proc
7173 objCmd.CommandText = "Usr_HPM_Desktop_Task_Automation_SP"
7174 'objCmd.Parameters.Refresh
7175 'objCmd.Parameters("@TransactionID").Value = TransactionID
7176
7177 Set ErrorCode = objCmd.Execute
7178 Set objCmd = Nothing
7179
7180End Function
7181
7182
7183Function Usr_HPM_Update_DT_Timestamp(CaseID,DesktopTaskID)
7184
7185varUpdate = "UPDATE dbo.Usr_Case_Desktop_Task_Audit_T SET Desktop_Task_sent_At = GETDATE() WHERE Case_ID = " & CaseID & " AND Desktop_Task_ID = " & DesktopTaskID
7186
7187With SQLConnection.Execute(varUpdate)
7188End With
7189
7190End Function
7191
7192Function GetDateInput()
7193
7194 Dim objShell
7195
7196 Set objExplorer = CreateObject("InternetExplorer.Application")
7197 Set objShell = CreateObject("WScript.Shell")
7198
7199 Call CreateHTMLFile
7200 Call CreateSleepFile
7201
7202 objExplorer.Navigate "file:///H:\Datepicker.html"
7203 objExplorer.ToolBar = 0
7204 objExplorer.StatusBar = 0
7205 objExplorer.Width=400
7206 objExplorer.Height = 300
7207 objExplorer.Visible = 1
7208
7209 Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
7210 objShell.Run("H:\Sleep.vbs")
7211 Loop
7212
7213 GetDateInput = CDate(objExplorer.Document.Body.All.Calendar1.Value)
7214 objExplorer.Quit
7215
7216End Function
7217
7218Sub CreateSleepFile
7219 Dim MyFSO, MyFile
7220 Set MyFSO = CreateObject ("Scripting.FileSystemObject")
7221 Set MyFile = MyFSO.CreateTextFile( "H:\Sleep.vbs", True )
7222 MyFile.WriteLine( "WScript.sleep 250" )
7223 MyFile.Close
7224End Sub
7225
7226Sub CreateHTMLFile
7227 Dim MyFSO, MyFile
7228 Set MyFSO = CreateObject ("Scripting.FileSystemObject")
7229 Set MyFile = MyFSO.CreateTextFile( "H:\Datepicker.html", True )
7230 htmlFile = "<HTML>" & vbNewLine & vbNewLine & vbNewLine & _
7231 "<HEAD>" & vbNewLine & _
7232 "<TITLE>Date Picker</TITLE>" & vbNewLine & _
7233 "</HEAD>" & vbNewLine & _
7234 "<SCRIPT language=""VBScript"">" & vbNewLine & _
7235 "<!--" & vbNewLine & _
7236 "Sub OKButton_OnClick" & vbNewLine & _
7237 "OkClicked.Value = 1" & vbNewLine & _
7238 "End Sub" & vbNewLine & _
7239 "'-->" & vbNewLine & _
7240 "</SCRIPT>" & vbNewLine & _
7241 "<BODY bgcolor=""buttonface"">" & vbNewLine & _
7242 "<p align=""center"">" & vbNewLine & _
7243 "<OBJECT CLASSID=""clsid:8E27C92B-1264-101C-8A2F-040224009C02"" id=Calendar1>" & vbNewLine & _
7244 "<param name=""BackColor"" value=""-2147483633"">" & vbNewLine & _
7245 "<param name=""DayLength"" value=""1"">" & vbNewLine & _
7246 "<param name=""MonthLength"" value=""1"">" & vbNewLine & _
7247 "<param name=""DayFontColor"" value=""0"">" & vbNewLine & _
7248 "<param name=""FirstDay"" value=""7"">" & vbNewLine & _
7249 "<param name=""GridCellEffect"" value=""1"">" & vbNewLine & _
7250 "<param name=""GridFontColor"" value=""10485760"">" & vbNewLine & _
7251 "<param name=""GridLinesColor"" value=""-2147483632"">" & vbNewLine & _
7252 "<param name=""ShowDateSelectors"" value=""-1"">" & vbNewLine & _
7253 "<param name=""ShowDays"" value=""-1"">" & vbNewLine & _
7254 "<param name=""ShowHorizontalGrid"" value=""-1"">" & vbNewLine & _
7255 "<param name=""ShowTitle"" value=""-1"">" & vbNewLine & _
7256 "<param name=""ShowVerticalGrid"" value=""-1"">" & vbNewLine & _
7257 "<param name=""TitleFontColor"" value=""10485760"">" & vbNewLine & _
7258 "<param name=""ValueIsNull"" value=""0"">" & vbNewLine & _
7259 "</OBJECT>" & vbNewLine & _
7260 "<br>" & vbNewLine & _
7261 "<INPUT NAME=""OKButton"" TYPE=""BUTTON"" VALUE=""OK"" >" & vbNewLine & _
7262 "<input type=""hidden"" name=""OKClicked"" size=""20""></P>" & vbNewLine & _
7263 "</BODY>" & vbNewLine & _
7264 "</HTML>"
7265 MyFile.WriteLine(htmlFile)
7266 MyFile.Close
7267End Sub
7268
7269Function HPMNBUpdateDiaryAuditTable(ClassificationID,DiaryID)
7270
7271 crmSql = "select TOP 1 Call_ID FROM CRM_Calls_T WHERE Classification_ID = " & ClassificationID & " ORDER BY Call_ID DESC"
7272
7273 With SQLConnection.Execute(crmSql)
7274 Do Until .EOF
7275 LatestCallID = .Fields("Call_ID").Value
7276 .MoveNext
7277 Loop
7278 End With
7279
7280 auditSql = "INSERT INTO usr_SW_New_Build_Diary_CRM_Audit_T VALUES (" & DiaryID & ", " & LatestCallID & ")"
7281
7282 With SQLConnection.Execute(auditSql)
7283 End With
7284
7285End Function