1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Report
: To Do List printout
(and export
)
6 Author
: Andrew McMillan
8 ------------------------------------------------------------------------*/
10 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
12 DEF VAR preview
AS LOGI
NO-UNDO INIT No.
13 DEF VAR show-rebates
AS LOGI
NO-UNDO INIT No.
14 DEF VAR period-1
AS DATE NO-UNDO INIT ?.
15 DEF VAR period-n
AS DATE NO-UNDO INIT ?.
16 DEF VAR selection-style
AS CHAR NO-UNDO.
17 DEF VAR half-line
AS CHAR NO-UNDO.
18 DEF VAR ln
AS DEC INIT 0.00 NO-UNDO.
19 DEF VAR output-to-pdf
AS LOG INIT NO.
20 DEF VAR sort-order
AS CHAR INIT "D".
21 DEF VAR line-c
AS INT NO-UNDO.
22 DEF VAR recs-per-page
AS INT NO-UNDO.
24 DEF VAR reset-page
AS CHAR NO-UNDO.
28 DEF VAR user-name
AS CHAR NO-UNDO.
29 {inc
/username.i
"user-name"}
30 DEF VAR timeStamp
AS CHAR FORMAT "X(44)" NO-UNDO.
31 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
33 DEF VAR pr-line
AS CHAR INIT "" NO-UNDO.
/* used everywhere to hold print line
*/
35 DEF VAR title-font
AS CHAR NO-UNDO INITIAL "Proportional,Helvetica,Bold,Point,12".
36 DEF VAR time-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
37 DEF VAR break1-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,lpi,7,bold".
38 DEF VAR break2-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
39 DEF VAR base-font
AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,18,lpi,9,light".
40 DEF VAR header-font
AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,18,lpi,9,bold".
44 /* _UIB-CODE-BLOCK-END
*/
48 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
50 /* ******************** Preprocessor Definitions
******************** */
52 &Scoped-define PROCEDURE-TYPE Procedure
53 &Scoped-define DB-AWARE no
57 /* _UIB-PREPROCESSOR-BLOCK-END
*/
62 /* *********************** Procedure Settings
************************ */
64 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
65 /* Settings for
THIS-PROCEDURE
69 Add Fields to
: Neither
70 Other Settings
: CODE-ONLY
COMPILE
72 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
74 /* ************************* Create Window
************************** */
76 &ANALYZE-SUSPEND _CREATE-WINDOW
77 /* DESIGN Window definition
(used by the UIB
)
78 CREATE WINDOW Procedure
ASSIGN
81 /* END WINDOW DEFINITION
*/
85 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
86 /* ************************* Included-Libraries
*********************** */
88 {inc
/method
/m-txtrep.i
}
92 /* _UIB-CODE-BLOCK-END
*/
99 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
102 /* *************************** Main Block
*************************** */
104 IF output-to-pdf
THEN DO:
105 RUN txtrep-pdf-filename
( "Tenant-Calls-Report" ).
106 RUN txtrep-output-mode
("pdf").
109 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
111 DEFINE QUERY q
FOR TenantCall
, Tenant
, Creditor
, ServiceType.
113 RUN pclrep-start
( preview
, "reset,landscape,tm,2,a4,lm,6,courier,cpi,18,lpi,9" ).
117 period-1
= DATE( 1, 1, 1960 ).
121 IF selection-style
= "Closed" THEN
122 RUN setup-closed-calls.
123 ELSE IF selection-style
= "Open" THEN
124 RUN setup-open-calls.
130 DO WHILE AVAILABLE(TenantCall
):
134 IF line-c
= recs-per-page
THEN DO:
135 PUT UNFORMATTED CHR(12).
147 IF NOT output-to-pdf
THEN
150 /* RUN view-output-file
( preview
).
*/
152 /* _UIB-CODE-BLOCK-END
*/
156 /* ********************** Internal Procedures
*********************** */
158 &IF DEFINED(EXCLUDE-each-call) = 0 &THEN
160 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-call Procedure
161 PROCEDURE each-call
:
162 /*------------------------------------------------------------------------------
164 ------------------------------------------------------------------------------*/
166 DEF VAR problem-text
AS CHAR NO-UNDO.
168 PUT UNFORMATTED STRING( TenantCall.DateOfCall
,"99/99/9999" ) ", " STRING( TenantCall.TimeOfCall
, 'HH
:MM'
) SPACE(3).
169 PUT UNFORMATTED STRING( TenantCall.CallStatusCode
, "X(7)" ) SPACE(3).
170 IF AVAILABLE(Tenant
) THEN
171 PUT UNFORMATTED STRING( Tenant.Name
, "X(20)" ) SPACE(3).
173 PUT UNFORMATTED SPACE(23).
175 PUT UNFORMATTED STRING( TenantCall.PropertyCode
, "99999" ) SPACE(5).
176 PUT UNFORMATTED STRING( TenantCall.OrderNo
, "99999" ) SPACE(5).
178 IF AVAILABLE(ServiceType
) THEN
179 PUT UNFORMATTED STRING( ServiceType.AccountCode
, "9999.99" ) SPACE(3).
181 PUT UNFORMATTED SPACE(10).
183 problem-text
= TenantCall.Problem.
184 problem-text
= REPLACE( problem-text
, "~n", " ").
185 PUT UNFORMATTED STRING( problem-text
, "X(60)" ) SPACE(3).
187 IF AVAILABLE(Creditor
) THEN
188 PUT UNFORMATTED STRING( Creditor.Name
, "X(30)" ) SPACE(3).
190 PUT UNFORMATTED SPACE(33).
192 PUT UNFORMATTED "~n".
196 /* _UIB-CODE-BLOCK-END
*/
201 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
203 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
204 PROCEDURE parse-parameters
:
205 /*------------------------------------------------------------------------------
207 ------------------------------------------------------------------------------*/
208 DEF VAR token
AS CHAR NO-UNDO.
209 DEF VAR i
AS INT NO-UNDO.
211 {inc
/showopts.i
"report-options"}
212 period-1
= TODAY - 180.
213 period-n
= TODAY + 90.
215 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
216 token
= ENTRY( i
, report-options
, "~n" ).
218 CASE ENTRY( 1, token
):
219 WHEN "Preview" THEN preview
= Yes.
220 WHEN "SortOrder" THEN sort-order
= ENTRY(2,token
).
221 WHEN "Selection" THEN selection-style
= ENTRY(2,token
).
222 WHEN "Period" THEN ASSIGN
223 period-1
= DATE( ENTRY(2,token
) )
224 period-n
= DATE( ENTRY(3,token
) ).
225 WHEN "OutputPDF" THEN output-to-pdf
= YES.
232 /* _UIB-CODE-BLOCK-END
*/
237 &IF DEFINED(EXCLUDE-report-footers) = 0 &THEN
239 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE report-footers Procedure
240 PROCEDURE report-footers
:
241 /*------------------------------------------------------------------------------
243 ------------------------------------------------------------------------------*/
246 PUT UNFORMATTED "Report prepared at " timeStamp.
250 /* _UIB-CODE-BLOCK-END
*/
255 &IF DEFINED(EXCLUDE-report-headers) = 0 &THEN
257 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE report-headers Procedure
258 PROCEDURE report-headers
:
259 /*------------------------------------------------------------------------------
261 ------------------------------------------------------------------------------*/
263 RUN pclrep-line
( title-font
, "" ).
264 PUT UNFORMATTED " Tenant Calls Listing - ".
265 IF selection-style
= 'Closed'
THEN
266 PUT UNFORMATTED "Closed calls".
267 ELSE IF selection-style
= 'Open'
THEN
268 PUT UNFORMATTED "Open calls".
270 PUT UNFORMATTED "All calls".
272 IF period-1
<> ?
AND period-n
<> ?
THEN
273 PUT UNFORMATTED " (from " STRING( period-1
, "99/99/9999" ) " to " STRING( period-n
, "99/99/9999" ) ")".
275 RUN pclrep-line
( header-font
, "" ).
279 "Date/Time" SPACE(11)
286 "Contractor" SPACE(23).
288 RUN pclrep-line
( base-font
, "" ).
292 /* _UIB-CODE-BLOCK-END
*/
297 &IF DEFINED(EXCLUDE-skip-line) = 0 &THEN
299 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-line Procedure
300 PROCEDURE skip-line
:
301 /*------------------------------------------------------------------------------
305 ------------------------------------------------------------------------------*/
307 DEF INPUT PARAMETER n
AS DEC NO-UNDO.
309 DEF VAR int-part
AS INT NO-UNDO.
310 DEF VAR dec-part
AS DEC NO-UNDO.
312 int-part
= TRUNCATE( n
, 0 ).
313 IF int-part
< 0 THEN RETURN.
314 dec-part
= n
- int-part.
315 IF int-part
= 0 AND dec-part
= 0 THEN RETURN.
317 /* Need to have this like the following
- do not touch
*/
318 IF int-part
<> 0 THEN PUT CONTROL FILL( CHR(10), int-part
).
319 IF dec-part
<> 0 THEN PUT CONTROL half-line.
327 /* _UIB-CODE-BLOCK-END
*/
332 &IF DEFINED(EXCLUDE-carriage-return) = 0 &THEN
334 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE carriage-return Procedure
335 PROCEDURE carriage-return
:
336 /*------------------------------------------------------------------------------
340 ------------------------------------------------------------------------------*/
346 /* _UIB-CODE-BLOCK-END
*/
351 &IF DEFINED(EXCLUDE-get-control-strings) = 0 &THEN
353 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-control-strings Procedure
354 PROCEDURE get-control-strings
:
355 /*------------------------------------------------------------------------------
356 Purpose
: Get all control strings for this report
357 ------------------------------------------------------------------------------*/
359 DEF VAR rows
AS DEC NO-UNDO.
360 DEF VAR cols
AS DEC NO-UNDO.
362 RUN make-control-string
( "PCL", "reset,simplex,landscape,a4,tm,0,lm,6",
363 OUTPUT reset-page
, OUTPUT rows
, OUTPUT cols
).
367 /* _UIB-CODE-BLOCK-END
*/
372 &IF DEFINED(EXCLUDE-setup-closed-calls) = 0 &THEN
374 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE setup-closed-calls Procedure
375 PROCEDURE setup-closed-calls
:
376 /*------------------------------------------------------------------------------
377 Purpose
: Closed calls
378 ------------------------------------------------------------------------------*/
383 FOR EACH TenantCall
WHERE TenantCall.CallStatusCode
= 'Closed'
AND
384 TenantCall.DateOfCall
>= period-1
AND TenantCall.DateOfCall
<= period-n
,
385 FIRST Tenant
WHERE TenantCall.TenantCode
= Tenant.TenantCode
OUTER-JOIN,
386 FIRST Creditor
WHERE Creditor.CreditorCode
= TenantCall.CreditorCode
OUTER-JOIN,
387 FIRST ServiceType
WHERE ServiceType.ServiceType
= TenantCall.CallCategoryCode
OUTER-JOIN
388 BY TenantCall.DateOfCall.
391 FOR EACH TenantCall
WHERE TenantCall.CallStatusCode
= 'Closed'
AND
392 TenantCall.DateOfCall
>= period-1
AND TenantCall.DateOfCall
<= period-n
,
393 FIRST Tenant
WHERE TenantCall.TenantCode
= Tenant.TenantCode
OUTER-JOIN,
394 FIRST Creditor
WHERE Creditor.CreditorCode
= TenantCall.CreditorCode
OUTER-JOIN,
395 FIRST ServiceType
WHERE ServiceType.ServiceType
= TenantCall.CallCategoryCode
OUTER-JOIN
396 BY TenantCall.PropertyCode.
399 FOR EACH TenantCall
WHERE TenantCall.CallStatusCode
= 'Closed'
AND
400 TenantCall.DateOfCall
>= period-1
AND TenantCall.DateOfCall
<= period-n
,
401 FIRST Tenant
WHERE TenantCall.TenantCode
= Tenant.TenantCode
OUTER-JOIN,
402 FIRST Creditor
WHERE Creditor.CreditorCode
= TenantCall.CreditorCode
OUTER-JOIN,
403 FIRST ServiceType
WHERE ServiceType.ServiceType
= TenantCall.CallCategoryCode
OUTER-JOIN
404 BY ServiceType.AccountCode.
409 /* _UIB-CODE-BLOCK-END
*/
414 &IF DEFINED(EXCLUDE-setup-open-calls) = 0 &THEN
416 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE setup-open-calls Procedure
417 PROCEDURE setup-open-calls
:
418 /*------------------------------------------------------------------------------
420 ------------------------------------------------------------------------------*/
425 FOR EACH TenantCall
WHERE TenantCall.CallStatusCode
<> 'Closed'
AND
426 TenantCall.DateOfCall
>= period-1
AND TenantCall.DateOfCall
<= period-n
,
427 FIRST Tenant
WHERE TenantCall.TenantCode
= Tenant.TenantCode
OUTER-JOIN,
428 FIRST Creditor
WHERE Creditor.CreditorCode
= TenantCall.CreditorCode
OUTER-JOIN,
429 FIRST ServiceType
WHERE ServiceType.ServiceType
= TenantCall.CallCategoryCode
OUTER-JOIN
430 BY TenantCall.DateOfCall.
433 FOR EACH TenantCall
WHERE TenantCall.CallStatusCode
<> 'Closed'
AND
434 TenantCall.DateOfCall
>= period-1
AND TenantCall.DateOfCall
<= period-n
,
435 FIRST Tenant
WHERE TenantCall.TenantCode
= Tenant.TenantCode
OUTER-JOIN,
436 FIRST Creditor
WHERE Creditor.CreditorCode
= TenantCall.CreditorCode
OUTER-JOIN,
437 FIRST ServiceType
WHERE ServiceType.ServiceType
= TenantCall.CallCategoryCode
OUTER-JOIN
438 BY TenantCall.PropertyCode.
441 FOR EACH TenantCall
WHERE TenantCall.CallStatusCode
<> 'Closed'
AND
442 TenantCall.DateOfCall
>= period-1
AND TenantCall.DateOfCall
<= period-n
,
443 FIRST Tenant
WHERE TenantCall.TenantCode
= Tenant.TenantCode
OUTER-JOIN,
444 FIRST Creditor
WHERE Creditor.CreditorCode
= TenantCall.CreditorCode
OUTER-JOIN,
445 FIRST ServiceType
WHERE ServiceType.ServiceType
= TenantCall.CallCategoryCode
OUTER-JOIN
446 BY ServiceType.AccountCode.
451 /* _UIB-CODE-BLOCK-END
*/
456 &IF DEFINED(EXCLUDE-setup-all-calls) = 0 &THEN
458 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE setup-all-calls Procedure
459 PROCEDURE setup-all-calls
:
460 /*------------------------------------------------------------------------------
461 Purpose
: Get all control strings for this report
462 ------------------------------------------------------------------------------*/
467 FOR EACH TenantCall
WHERE TenantCall.DateOfCall
>= period-1
AND TenantCall.DateOfCall
<= period-n
,
468 FIRST Tenant
WHERE TenantCall.TenantCode
= Tenant.TenantCode
OUTER-JOIN,
469 FIRST Creditor
WHERE Creditor.CreditorCode
= TenantCall.CreditorCode
OUTER-JOIN,
470 FIRST ServiceType
WHERE ServiceType.ServiceType
= TenantCall.CallCategoryCode
OUTER-JOIN
471 BY TenantCall.DateOfCall.
474 FOR EACH TenantCall
WHERE TenantCall.DateOfCall
>= period-1
AND TenantCall.DateOfCall
<= period-n
,
475 FIRST Tenant
WHERE TenantCall.TenantCode
= Tenant.TenantCode
OUTER-JOIN,
476 FIRST Creditor
WHERE Creditor.CreditorCode
= TenantCall.CreditorCode
OUTER-JOIN,
477 FIRST ServiceType
WHERE ServiceType.ServiceType
= TenantCall.CallCategoryCode
OUTER-JOIN
478 BY TenantCall.PropertyCode.
481 FOR EACH TenantCall
WHERE TenantCall.DateOfCall
>= period-1
AND TenantCall.DateOfCall
<= period-n
,
482 FIRST Tenant
WHERE TenantCall.TenantCode
= Tenant.TenantCode
OUTER-JOIN,
483 FIRST Creditor
WHERE Creditor.CreditorCode
= TenantCall.CreditorCode
OUTER-JOIN,
484 FIRST ServiceType
WHERE ServiceType.ServiceType
= TenantCall.CallCategoryCode
OUTER-JOIN
485 BY ServiceType.AccountCode.
490 /* _UIB-CODE-BLOCK-END
*/