-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnf_Letters.lss
3304 lines (2555 loc) · 86.8 KB
/
Enf_Letters.lss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Option Public
Option Declare
Use "tasks"
Use "SignOffCase"
'*****************************************************************************************
' Amendments
'
' Nov 2002
'
' amended to print letterhead logos instead of using pre-printed stationary
' signature now printed from BMP files as are logos
' letterhead only printed if useletterhead flag on letter = y
'
' Amended also to use signatory name instead of doc id for lookup
'
'********************************************************************************************
Dim ws As notesuiworkspace
Dim session As notessession
Dim db As notesdatabase
Dim dc As notesdocumentcollection
Dim view As notesview
Dim sigvw As notesview
Dim logovw As notesview
Dim foldview As notesview
Dim delview As notesview
Dim seldoc As notesdocument
Dim ldoc As notesdocument
Dim idoc As notesdocument
Dim cdoc As notesdocument
Dim courtdoc As notesdocument
Dim prdoc As notesdocument
Dim printerdoc As notesdocument
Dim newdoc As notesdocument
Dim sigdoc As notesdocument
Dim folddoc As notesdocument
Dim uidoc As notesuidocument
Dim ni As NotesItem
Dim rti As Variant
Dim emb As notesembeddedobject
' letter parameters
Dim letterlist() As String
Dim signatory As String
Dim letterdate As Variant
Dim expirydate As Variant
Dim runopt As String
Dim sigstr As String
Dim nocopies As Integer
Dim noncase As String
Dim scottish As String
Dim sicyear As String
' error code
Dim status As Integer
' list of case + letter document ids
Dim ids() As String
' document counters
Dim docidno As Integer
Dim numdocs As Integer
' contrbutor contact & address (arrays)
Dim contact As Variant
Dim caddress As Variant
Dim foraddress As Variant
Dim for2address As Variant
Dim for2start As Integer
' general text handling
Dim ltext As String
Dim mtext As String
Dim ptext As String
Dim sbtext As String
Dim endcom As Integer
' Print parameters
Dim filenum As Integer
Dim fname As String
Dim printer As String
Dim testprint As String
Dim dtype As String
Dim orient As String
Dim twidth As Integer
Dim lmargin As Double
Dim tmargin As Double
Dim pointsize As Integer
Dim tray As String
Dim trayint As String ' String deliberately - its just a naming convention DJS 25/02/2014
Dim paper As String
Dim duplex As String
Dim xcoord As Long ' current xcoord for printing
Dim ycoord As Long ' current y coord
Dim scoord As Long
Dim yinc As Long ' amount to increment ycoord after each line
Dim lineno As Integer ' current line numer
Dim maxlineno As Integer ' maximum line number allowed
Dim startx As Long ' start xcoord for page
Dim starty As Long ' start ycoord for page
Dim pageno As Integer ' current page number
' formatting bold etc
Dim fmt() As String
Dim fmtpos() As Integer
Dim ulon() As Integer
Dim boldon As Integer
Dim italicon As Integer
Dim underlineon As Integer
Dim underlinewason As Integer
' formatting inquiry period details
Dim inqperiod As String
Dim imonth As String
' formatting dates
Dim indate As Variant
Dim formatdate As String
' justifing text
Dim factor As Double
Dim maxfactor As Double
Dim nspace As Integer
' general array for view search by key
Dim ka() As String
Dim inquiry_code As String
Dim period As String
' variables for checking that the letter chosen is appropriate for the stage reached by the case(s)
Dim checkstage As Integer
Dim ltype As Integer
Dim ltypetext As String
Dim errorstub As String
Dim errortext As String
Sub Initialize
Set session = New NotesSession
Set db = session.CurrentDatabase
errorstub = db.Title & ". Script Library: letters. Sub/function "
End Sub
Sub printletters()
'******************************************************************************************
'
' printletters
'
' print letters for all doc whose uids are in ids()
'
'******************************************************************************************
Dim i As Integer
status = 0
' Internal Notes constants that give information about the current module
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
' lookup printer details
Call getprinter()
If status <> 0 Then Exit Sub
' open output file & initialise printer
Call openprint()
If status <> 0 Then Exit Sub
' loop through all printletter documents
numdocs = Ubound(ids)
For docidno = 0 To numdocs
' get next document
Call getnextdoc()
If status <> 0 Then
Close #filenum
Exit Sub
End If
'print letter
For i% = 1 To nocopies
Call printcurdoc()
If status <> 0 Then
Close #filenum
Exit Sub
End If
Next
Next
' send file to printer
Close #filenum
Filecopy fname, printer
End Sub
Sub createnoncase
'******************************************************************************************
' main entry point
' create non case letter from non case template
'******************************************************************************************
Set ws = New notesuiworkspace
Set session = New notessession
Set db = session.currentdatabase
status = 0
runopt = "seldoc"
dtype = "doc"
noncase = "y"
' Internal Notes constants that give information about the current module
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
' set view for logo docs
Set logovw = db.getview("logos")
If logovw Is Nothing Then
Messagebox "Error: View: logos not found",16,errorstub & errortext
Exit Sub
End If
' set view for signature docs
Set sigvw = db.getview("staff")
If sigvw Is Nothing Then
Messagebox "Error: View: staff not found",16,errorstub & errortext
Exit Sub
End If
' set letter parameters
Call getletter()
If status <> 0 Then Exit Sub
' set up letter document & fields
Set newdoc = db.createdocument
Call ldoc.copyallitems(newdoc, True)
newdoc.form = "noncaseletter"
newdoc.dated = letterdate
newdoc.signatory = signatory
' newdoc.signatoryid = signatoryid
' replace field keywords
Call replacefields()
If status <> 0 Then Exit Sub
Set uidoc = ws.editdocument(True, newdoc)
End Sub
Sub getprinter
'************************************************************************
' lookup letter printer details
'***********************************************************************
status = 0
' Internal Notes constants that give information about the current module
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
Set view = db.getview("printers")
If view Is Nothing Then
Beep
Msgbox "Error: Unable to access view 'printers'", 16, errorstub & errortext
status = 1
Exit Sub
End If
Set printerdoc = view.getfirstdocument
If printerdoc Is Nothing Then
Beep
Msgbox "Error: Unable to access printers document", 16, errorstub & errortext
status = 1
Exit Sub
End If
printer = printerdoc.letterprinter(0)
tray = Lcase(printerdoc.lettertraynum(0))
trayint = printerdoc.lettertrayint(0) ' Newly calculated on the printer config doc DJS 25/02/2014
paper = Lcase(printerdoc.letterpaper(0))
End Sub
Sub printletterdoc
'******************************************************************************
'
' Main Entry Point
'
' print currently open document
'
'*****************************************************************************
Set ws = New notesuiworkspace
Set session = New notessession
Set db = session.currentdatabase
status = 0
runopt = "seldoc"
dtype = "doc"
nocopies = 1
' Internal Notes constants that give information about the current module
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
' get id of current document
Set uidoc = ws.currentdocument
If uidoc Is Nothing Then
Beep
status = 1
Msgbox "Error: Unable to access current UI document",16,errorstub & errortext
Exit Sub
End If
Set seldoc = uidoc.document
If seldoc Is Nothing Then
Beep
status = 1
Msgbox "Error: Unable to access current document",16,errorstub & errortext
Exit Sub
End If
' print
Redim ids(0)
Call printletters()
If status <> 0 Then Exit Sub
Msgbox "Letter printed successfully", 64, " Information"
End Sub
Sub getprofiledoc
'********************************************************************
' get profile docuement & disable deselect agent
'********************************************************************
status = 0
' Internal Notes constants that give information about the current module
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
Set prdoc = db.getprofiledocument("dbprofile")
If prdoc Is Nothing Then
Beep
status = 1
Msgbox "Error: Unable to access dbprofile document", 16, errorstub & errortext
Exit Sub
End If
prdoc.deselect = "n"
End Sub
Sub letterhead()
' *******************************************************************
' print letterheading
'********************************************************************
Dim px As Long
Dim py As Long
Dim ly As Long
Dim iheight As Long
Dim afont As String
Dim add1 As String ' ons address details for letterhead
Dim add2 As String
Dim add3 As String
' select new or old letter heading
' depending on date letter created
%REM OBSOLETE CODE - CHECKING FOR BEFORE NOV 2002 DJS 09/06/2016 - requirement To change ONS URL so hold In dbprofile
If Fix(seldoc.created) < Cdat("21 November, 2002") Then
' print ons logo
ptext = ""
px = 0.35*600
py = 0.4*600
Call printbmp(px, py,"Old Logo", iheight)
Print #filenum, ptext
' print ons details in centre of letterhead
afont = Chr$(27) & "(s1p7.5v0s0bs16602T"
add1 = "Office for National Statistics " & Chr$(249) & " Government Buildings " & Chr$(249) & " Cardiff Road" & Chr$(249) & "Newport "
add2 = "Gwent " & Chr$(249) & " NP10 8XG " & Chr$(249) & " Tel: 01633 815696" & Chr$(249) & " Fax: 01633 652747"
add3 = "E-mail: [email protected] " & Chr$(249) & " www.statistics.gov.uk"
px = 3.8 * 600
py = ly + 0.7 * 600
ptext = Chr$(27) & "*p" & px & "x" & py & "y" & Chr$(27) & afont & add1 & Chr$(13)
ptext = ptext & Chr$(27) & "*p" & px & "x" & py + 65 & "Y" &_
add2 & Chr$(13)
ptext = ptext & Chr$(27) & "*p" & px & "x" & py + 130 & "Y" &_
add3 & Chr$(13)
Print #filenum,ptext
' print a line underneath ons details
ptext = Chr$(27) & "*p" & px & "x" & py + 150 & "Y" & Chr$(27) & "*c2160A" & Chr$(27) & "*c5B" &_
Chr$(27) & "*c0P"
Print #filenum, ptext
' calculate new yccord and lineno if margin insufficient
If tmargin < 1.2 Then
ycoord = (1.2 * 600) + yinc
lineno = Fix((1.2 - tmargin) * 600/yinc) + 1
End If
Else
%END REM
' print logos on letterhead
' crest first then ons logo
ptext = ""
px = 0.75 * 600
py = 0.25 * 600
Call printbmp(px, py,"Crest", iheight)
Print #filenum, ptext
' set crest font
afont = Chr$(27) & "(s1p7.5v0s0bs169013T"
%REM DJS 16/02/2012 - WEASLEY STUFF
' print ons text underneath crest
ptext = Chr$(27) & "*p" & px - 100 & "x" & Chr$(27) & afont & "Office for National Statistics" & Chr$(13)
ptext = ptext & Chr$(27) & "*p" & px & "x" & py + 620 & "Y" &_
"A Government Agency" & Chr$(13)
Print #filenum, ptext
%END REM
' print ons details in centre of letterhead
' set address font
Call getprofile() ' DJS 09/06/2016 - requirement to change ONS URL so hold in dbprofile
afont = Chr$(27) & "(s1p7.5v0s0bs16602T"
add1 = "Office for National Statistics " & Chr$(249) & " Government Buildings " & Chr$(249) & " Cardiff Road"
add2 = "Newport " & Chr$(249) & " Gwent " & Chr$(249) & " NP10 8XG "
' add3 = "www.statistics.gov.uk" ' DJS 09/06/2016 - requirement To change ONS URL so hold In dbprofile
add3 = prdoc.onswebsite(0) ' DJS 09/06/2016 - requirement To change ONS URL so hold In dbprofile
px = px + (1.375 * 600)
py = py + 400
ptext = Chr$(27) & "*p" & px & "x" & py & "y" & Chr$(27) & afont & add1 & Chr$(13)
ptext = ptext & Chr$(27) & "*p" & (px + 450) & "x" & py + 75 & "Y" &_
add2 & Chr$(13)
ptext = ptext & Chr$(27) & "*p" & (px + 600) & "x" & py + 150 & "Y" &_
add3 & Chr$(13)
Print #filenum,ptext
' print a line underneath ons details
ptext = Chr$(27) & "*p" & px & "x" & py + 170 & "Y" & Chr$(27) & "*c1874A" & Chr$(27) & "*c5B" &_
Chr$(27) & "*c0P"
Print #filenum, ptext
' adjust xcoord to print ons logo on right of document
py = py - 200
px = px + ( 3.875 * 600)
ptext = ""
Call printbmp(px, py, "Logo", iheight)
Print #filenum, ptext
' calculate new yccord and lineno if margin insufficient
If tmargin < 1.25 Then
ycoord = (1.25 * 600) + yinc
lineno = Fix((1.25 - tmargin) * 600/yinc) + 1
End If
' END OF REMMED OUT IF DJS 09/06/2016 - requirement To change ONS URL so hold In dbprofile End If
End Sub
Sub printletterdocs
'*************************************************************************************
'
' Main Entry Point
'
' Print list of letter documents currently selected in a view by user
'*************************************************************************************
Set ws = New notesuiworkspace
Set session = New notessession
Set db = session.currentdatabase
Dim nlc As Integer
Dim i As Integer
status = 0
runopt = "seldoc"
dtype = "list"
nocopies = 1
' Internal Notes constants that give information about the current module
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
' get profile document to set flag for deselect agent
Call getprofiledoc()
If status <> 0 Then Exit Sub
' set view for logo docs
Set logovw = db.getview("logos")
If logovw Is Nothing Then
Messagebox "Error: Logo docs view not found",16,errorstub & errortext
Exit Sub
End If
' set view for signature docs
Set sigvw = db.getview("staff")
If sigvw Is Nothing Then
Messagebox "Error: View: staff not found",16,errorstub & errortext
Exit Sub
End If
' get selected document ids into ids array
Redim ids(0)
Set dc = db.unprocesseddocuments
If dc.count = 0 Then
Beep
Msgbox "Error: A Letter document must be selected first", 16, errorstub & errortext
status = 1
Exit Sub
End If
nlc% = -1
For i% = 1 To dc.count
Set seldoc = dc.getnthdocument(i%)
If seldoc.form(0) = "printletter" _
Or seldoc.form(0) = "noncaseletter" Then
nlc% = nlc% + 1
Redim Preserve ids(nlc%)
ids(nlc%) = seldoc.universalid
End If
Next
If nlc% = -1 Then
Beep
Msgbox "Error: No Letter documents have been selected ", 16, errorstub & errortext
status = 1
Exit Sub
End If
If nlc% <> dc.count-1 Then
Beep
Msgbox "Warning: Some non-letter documents were selected and have been ignored", 48, errorstub & errortext
End If
' print
Call printletters()
If status <> 0 Then Exit Sub
' enable deselect agent
prdoc.deselect = "y"
Msgbox "Letter(s) printed successfully", 64, " Information"
End Sub
Sub getnextdoc
'*******************************************************************************************
'
' retrieve document from ids list
'
' element to retrieve in docidno
'
'*******************************************************************************************
status = 0
' Internal Notes constants that give information about the current module
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
' if a single document or test then doc already in seldoc
If dtype = "doc" Or testprint = "y" Then Exit Sub
' get document using approriate id
Set seldoc = db.getdocumentbyunid(ids(docidno))
If seldoc Is Nothing Then
Beep
status = 1
Msgbox "Error: Unable to access document no: " & docidno & " ID:" & ids(docidno), 16, errorstub & errortext
Exit Sub
End If
End Sub
Sub createletters
'******************************************************************************************
' createletters
' create letters for case detail documents
' held in array ids
'******************************************************************************************
Dim profiledoc As NotesDocument
Dim sendto As Variant
Dim copyto As Variant
Dim recipient As String
Dim actionrequired As String
Dim i As Integer
Dim ignoresetdates As Integer
Dim subject As String
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
' loop through selected documents
numdocs = Ubound(ids)
For docidno = 0 To numdocs
' get selected document
Call getnextdoc()
If status <> 0 Then Exit Sub
' get company/inquiry details etc
Call getdetails()
If status <> 0 Then Exit Sub
' set up letter document & fields
Set newdoc = db.createdocument
Call ldoc.copyallitems(newdoc, True)
newdoc.form = "printletter"
' POINTED OUT THAT THE CREATOR, DATE AND TIME ARE BEING PICKED UP FROM THE TEMPLATE DJS 17/10/2012
Dim nncreator As New Notesname(session.UserName) ' DJS 17/10/2012
newdoc.creator = nncreator.Abbreviated ' DJS 17/10/2012
newdoc.date = Now ' DJS 17/10/2012
newdoc.time = Now ' DJS 17/10/2012
newdoc.reference = seldoc.reference(0)
newdoc.name = seldoc.name(0)
newdoc.inquiry_code = seldoc.inquiry_code(0)
newdoc.period = seldoc.period(0)
newdoc.serial_no = seldoc.serial_no(0)
newdoc.dated = letterdate
newdoc.expiry = expirydate
' newdoc.signatoryid = signatoryid
newdoc.signatory = signatory
' POTENTIALLY IF THIS BECOMES NECESSARY MAKE THE LETTER A RESPONSE TO THE ENFORCEMENT FORM
' THE REASON IS THAT EVEN THOUGH I HAVE TWEAKED THE BY REFERENCE VIEW TO SORT THE LETTERS
' CORRECTLY IF THERE ARE MULTIPLE CASES FOR THE SAME RU REFERENCE, THERE IS STILL A MARGINAL ISSUE
' OF MULTIPLE CASES FOR THE SAME RUREF, INQUIRY, PERIOD . . . . . .SIGH !
' Call newdoc.MakeResponse(seldoc) ' DJS 14/05/2012
' replace field keywords
Call replacefields()
If status <> 0 Then Exit Sub
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
' save and update case
If testprint <>"y" And ldoc.printonly(0) = "n" Then
Call newdoc.save(True, False)
%REM
'**************************************************************************************************************************
lettertype field values
Warning
Final Warning
Solicitor
Witness Statements
2nd Prosecution
Other
Non Case
' HACK TO SET THE STATUS DJS 25/01/.2012
%END REM
ignoresetdates = 0 ' DO NOT OVERWRITE DATES IF INCORRECT LETTER CHOSEN DJS 09/05/2012
Select Case seldoc.status(0)
Case "Questionnaire Issued" :
If(ldoc.lettertype(0) = "Warning") Then ' ALL THE LETTER TYPE/STATUS CROSS CHECKS ADDED 09/05/2012 DJS
seldoc.status = "Warning Letter Issued"
seldoc.WarningLetterIssuedby = session.UserName ' V022 DJS 22/10/2015
Else
Messagebox "Only Warning Letters are valid at status " & seldoc.status(0) & ", you have selected a " & ldoc.lettertype(0) &_
" letter " & ldoc.lettername(0) & " which will be printed but the workflow will not be moved on.",48,errorstub & errortext
ignoresetdates = 1 ' TELL CODE TO IGNORE DATE SETTING DJS 09/05/2012
End If
Case "Warning Letter Issued" :
If(ldoc.lettertype(0) = "Final Warning") Then
seldoc.status = "Final Warning Letter Issued"
seldoc.FinalWarningLetterIssuedby = session.UserName ' V022 DJS 22/10/2015
Else
Messagebox "Only Final Warning Letters are valid at status " & seldoc.status(0) & ", you have selected a " & ldoc.lettertype(0) &_
" letter " & ldoc.lettername(0) & " which will be printed but the workflow will not be moved on.",48,errorstub & errortext
ignoresetdates = 1 ' TELL CODE TO IGNORE DATE SETTING DJS 09/05/2012
End If
Case "Final Warning Letter Issued" :
If(ldoc.lettertype(0) = "Solicitor") Then
seldoc.status = "Instruction To Solicitor Issued"
seldoc.InstructionToSolicitorIssuedby = session.UserName ' V022 DJS 22/10/2015
' NEW CODE IN SCRIPT LIBRARY SIGNOFFCASE
Call solicitorletternotification(seldoc) ' DJS 23/04/2012
Else
Messagebox "Only Solicitors Letters are valid at status " & seldoc.status(0) & ", you have selected a " & ldoc.lettertype(0) &_
" letter " & ldoc.lettername(0) & " which will be printed but the workflow will not be moved on.",48,errorstub & errortext
ignoresetdates = 1 ' TELL CODE TO IGNORE DATE SETTING DJS 09/05/2012
End If
Case "Awaiting Court Action" :
If(ldoc.lettertype(0) <> "2nd Prosecution") Then
Messagebox "Only 2nd Prosecution Letters are valid at status " & seldoc.status(0) & ", you have selected a " & ldoc.lettertype(0) &_
" letter " & ldoc.lettername(0) & " which will be printed but the workflow will not be moved on.",48,errorstub & errortext
ignoresetdates = 1 ' TELL CODE TO IGNORE DATE SETTING DJS 09/05/2012
End If
Case "New", "Awaiting Approval", "Returned To Originator", "Approved", "Complete", "Closed"
Messagebox "At the current workflow status: " & seldoc.status(0) & ", it is not appropriate to issue a " & ldoc.lettertype(0) &_
" letter '" & ldoc.lettername(0) & "'. However it will be printed but this will not affect the workflow.",48,errorstub & errortext
ignoresetdates = 1 ' ADDED FOR COMPLETENESS 15/05/2012 DJS
End Select
Call log_it( seldoc.status(0) ,seldoc,errorstub & errortext ) ' Too important to not nail down
' update dates on case details if required
If ldoc.setdatefield(0) <> "none" And ignoresetdates = 0 Then ' TELL CODE TO IGNORE DATE SETTING DJS 09/05/2012
' THESE VALUES on LDOC ARE HELD IN THE COMPUTED FIELDS ON THE LETTER FORM/DOCUMENT
' IF THEY NEED TO CHANGE THEN REMEMBER TO REFRESH THE EXISTING DOCS DJS 20/04/2012
Set ni = seldoc.replaceitemvalue(ldoc.setdatefield(0), letterdate)
Set ni = seldoc.replaceitemvalue(ldoc.setexpiryfield(0), expirydate)
seldoc.expiredaction = ""
seldoc.letterissued = "Yes"
Call seldoc.save(True, False)
End If
End If
If ldoc.printonly(0) = "y" Then
Set seldoc = newdoc
' lookup printer details
Call getprinter()
If status <> 0 Then Exit Sub
' open output file & initialise printer
Call openprint()
If status <> 0 Then Exit Sub
'print letter
For i% = 1 To nocopies
Call printcurdoc()
If status <> 0 Then
Close #filenum
Exit Sub
End If
Next
' send file to printer
Close #filenum
Filecopy fname, printer
End If
' store id of letter document for printing later
ids(docidno) = newdoc.universalid
Next
' keep document for printing if a single document
If dtype = "doc" Or testprint = "y" Then
Set seldoc = newdoc
End If
' print letters
If (ldoc.autoprint(0) = "y" Or testprint = "y") And ldoc.printonly(0) = "n" Then
Call printletters()
If status <> 0 Then Exit Sub
End If
End Sub
Sub getprofile
'********************************************************************
' get profile document only, the other one sets a flag I do not want to interfere with DJS 09/06/2016 - requirement to change ONS URL so hold in dbprofile
'********************************************************************
status = 0
' Internal Notes constants that give information about the current module
errortext = LCase(LSI_Info(2)) & " called by " & LCase(LSI_Info(12))
Set prdoc = db.getprofiledocument("dbprofile")
If prdoc Is Nothing Then
Beep
status = 1
MsgBox "Error: Unable to access dbprofile document", 16, errorstub & errortext
Exit Sub
End If
End Sub
Sub createletterdoc
'******************************************************************************
'
' Main Entry Point
'
' create letter for currently open case document
'
'*****************************************************************************
Set ws = New notesuiworkspace
Set session = New notessession
Set db = session.currentdatabase
status = 0
runopt = "seldoc"
dtype = "doc"
noncase = "n"
' Internal Notes constants that give information about the current module
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
' get current document
Set uidoc = ws.currentdocument
If uidoc Is Nothing Then
Beep
status = 1
Msgbox "Error: Unable to access current UI document",16,errorstub & errortext
Exit Sub
End If
Set seldoc = uidoc.document
If seldoc Is Nothing Then
Beep
status = 1
Msgbox "Error: Unable to access current document",16,errorstub & errortext
Exit Sub
End If
' set letter parameters
Call getletter()
If status <> 0 Then Exit Sub
' create letter & print
Redim ids(0)
Call createletters()
If status <> 0 Then Exit Sub
Call ws.viewrefresh
Msgbox "Letter created successfully", 64, " Information"
End Sub
Sub jtext
'**********************************************************************************************
' calculates number of spaces for padding centre and right justification
' for text held in mtext
'**********************************************************************************************
Dim y As Integer
status = 0
' remove format effectors in string
ptext = mtext
y% = Instr(ptext, "^")
Do While y% > 0
ptext = Left$(ptext, y%-1) & Mid$(ptext, y%+2)
y% = Instr(y% + 2, ptext, "^")
Loop
' set factor depending on number of capitals in text
' nlower% = Len(ptext)
' For i% = 1 To Len(ptext)
' nlower% = nlower% + (Asc(Mid$(ptext, i%, 1)) >= 64 And Asc(Mid$(ptext, i%, 1)) <=90)
' Next
' factor = Log(1 + 9*nlower%/Len(ptext))/Log(10) * maxfactor
' factor = nlower%/Len(ptext) * maxfactor
factor = maxfactor
nspace = ldoc.twidth(0) - Len(ptext)
If nspace <= 0 Then
nspace = 1
Else
nspace = nspace + Int(nspace*factor)
End If
End Sub
Sub pagenum()
'******************************************************************************
' put page number at bottom left of page
'******************************************************************************
pageno = pageno + 1
ycoord = starty + (maxlineno+1) * yinc
If seldoc.numberpages(0) = "y" Then
Print #filenum, Chr$(27) & "*p" & xcoord & "x" & ycoord & "Y" & pageno
End If
End Sub
Sub replacepound(text As String)
Dim p As Integer
p% = Instr(text,Chr$(144))
Do While p% > 0
' Mid$(text,p%,1) = Chr$(156)
Mid$(text,p%,1) = Chr$(163)
p% = Instr(text,Chr$(144))
Loop
p% = Instr(text,Chr$(163))
Do While p% > 0
Mid$(text,p%,1) = Chr$(156)
p% = Instr(text,Chr$(163))
Loop
End Sub
Sub getletterhead
Dim oldlogodoc As NotesDocument
Dim logodoc As NotesDocument
Dim crestdoc As NotesDocument
' Internal Notes constants that give information about the current module
errortext = Lcase(Lsi_info(2)) & " called by " & Lcase(Lsi_info(12))
Set sigvw = db.getview("staff")
If sigvw Is Nothing Then
Messagebox "Error: Signature docs view not found",16,errorstub & errortext
Exit Sub
End If
Set oldlogodoc = sigvw.getdocumentbykey("Old Logo", True)
If oldlogodoc Is Nothing Then
Messagebox "Error: Old ONS Logo document not found",16,errorstub & errortext
Exit Sub
End If
Set logodoc = sigvw.getdocumentbykey("Logo", True)
If logodoc Is Nothing Then