Added capital works blank section. Synced calling screen.
[capital-apms-progress.git] / process / report / tenant-calls.p
blob50a9405479023fb39e60bd0993828a41d971a39b
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Report: To Do List printout (and export)
6 Author: Andrew McMillan
7 Date: 21/3/1999
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.
26 RUN parse-parameters.
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".
42 {inc/ofc-this.i}
44 /* _UIB-CODE-BLOCK-END */
45 &ANALYZE-RESUME
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 */
58 &ANALYZE-RESUME
62 /* *********************** Procedure Settings ************************ */
64 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
65 /* Settings for THIS-PROCEDURE
66 Type: Procedure
67 Allow:
68 Frames: 0
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
79 HEIGHT = 28.25
80 WIDTH = 36.29.
81 /* END WINDOW DEFINITION */
83 &ANALYZE-RESUME
85 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
86 /* ************************* Included-Libraries *********************** */
88 {inc/method/m-txtrep.i}
89 {inc/null.i}
90 {inc/entity.i}
92 /* _UIB-CODE-BLOCK-END */
93 &ANALYZE-RESUME
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").
107 END.
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" ).
114 RUN report-headers.
116 IF period-1 = ? THEN
117 period-1 = DATE( 1, 1, 1960 ).
118 IF period-n = ? THEN
119 period-n = TODAY.
121 IF selection-style = "Closed" THEN
122 RUN setup-closed-calls.
123 ELSE IF selection-style = "Open" THEN
124 RUN setup-open-calls.
125 ELSE
126 RUN setup-all-calls.
128 recs-per-page = 59.
129 GET FIRST q.
130 DO WHILE AVAILABLE(TenantCall):
131 RUN each-call.
133 line-c = line-c + 1.
134 IF line-c = recs-per-page THEN DO:
135 PUT UNFORMATTED CHR(12).
136 line-c = 0.
137 recs-per-page = 67.
138 END.
140 GET NEXT q.
141 END.
143 RUN report-footers.
145 OUTPUT CLOSE.
147 IF NOT output-to-pdf THEN
148 RUN pclrep-finish.
150 /* RUN view-output-file( preview ). */
152 /* _UIB-CODE-BLOCK-END */
153 &ANALYZE-RESUME
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 /*------------------------------------------------------------------------------
163 Purpose:
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).
172 ELSE
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).
180 ELSE
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).
189 ELSE
190 PUT UNFORMATTED SPACE(33).
192 PUT UNFORMATTED "~n".
194 END PROCEDURE.
196 /* _UIB-CODE-BLOCK-END */
197 &ANALYZE-RESUME
199 &ENDIF
201 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
203 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
204 PROCEDURE parse-parameters :
205 /*------------------------------------------------------------------------------
206 Purpose:
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.
226 END CASE.
228 END.
230 END PROCEDURE.
232 /* _UIB-CODE-BLOCK-END */
233 &ANALYZE-RESUME
235 &ENDIF
237 &IF DEFINED(EXCLUDE-report-footers) = 0 &THEN
239 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE report-footers Procedure
240 PROCEDURE report-footers :
241 /*------------------------------------------------------------------------------
242 Purpose:
243 ------------------------------------------------------------------------------*/
245 RUN skip-line(1).
246 PUT UNFORMATTED "Report prepared at " timeStamp.
248 END PROCEDURE.
250 /* _UIB-CODE-BLOCK-END */
251 &ANALYZE-RESUME
253 &ENDIF
255 &IF DEFINED(EXCLUDE-report-headers) = 0 &THEN
257 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE report-headers Procedure
258 PROCEDURE report-headers :
259 /*------------------------------------------------------------------------------
260 Purpose:
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".
269 ELSE
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, "" ).
276 RUN skip-line(2).
278 PUT UNFORMATTED
279 "Date/Time" SPACE(11)
280 "Status" SPACE(4)
281 "Tenant" SPACE(17)
282 "Building" SPACE(2)
283 "Order No" SPACE(2)
284 "Account" SPACE(3)
285 "Problem" SPACE(56)
286 "Contractor" SPACE(23).
288 RUN pclrep-line( base-font, "" ).
290 END PROCEDURE.
292 /* _UIB-CODE-BLOCK-END */
293 &ANALYZE-RESUME
295 &ENDIF
297 &IF DEFINED(EXCLUDE-skip-line) = 0 &THEN
299 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-line Procedure
300 PROCEDURE skip-line :
301 /*------------------------------------------------------------------------------
302 Purpose:
303 Parameters: <none>
304 Notes:
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.
321 ln = ln + n.
323 RUN carriage-return.
325 END PROCEDURE.
327 /* _UIB-CODE-BLOCK-END */
328 &ANALYZE-RESUME
330 &ENDIF
332 &IF DEFINED(EXCLUDE-carriage-return) = 0 &THEN
334 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE carriage-return Procedure
335 PROCEDURE carriage-return :
336 /*------------------------------------------------------------------------------
337 Purpose:
338 Parameters: <none>
339 Notes:
340 ------------------------------------------------------------------------------*/
342 PUT CONTROL CHR(13).
344 END PROCEDURE.
346 /* _UIB-CODE-BLOCK-END */
347 &ANALYZE-RESUME
349 &ENDIF
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 ).
365 END PROCEDURE.
367 /* _UIB-CODE-BLOCK-END */
368 &ANALYZE-RESUME
370 &ENDIF
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 ------------------------------------------------------------------------------*/
380 CASE sort-order:
381 WHEN "D" THEN
382 OPEN QUERY q
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.
389 WHEN "B" THEN
390 OPEN QUERY q
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.
397 WHEN "A" THEN
398 OPEN QUERY q
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.
405 END.
407 END PROCEDURE.
409 /* _UIB-CODE-BLOCK-END */
410 &ANALYZE-RESUME
412 &ENDIF
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 /*------------------------------------------------------------------------------
419 Purpose: Open calls
420 ------------------------------------------------------------------------------*/
422 CASE sort-order:
423 WHEN "D" THEN
424 OPEN QUERY q
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.
431 WHEN "B" THEN
432 OPEN QUERY q
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.
439 WHEN "A" THEN
440 OPEN QUERY q
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.
447 END.
449 END PROCEDURE.
451 /* _UIB-CODE-BLOCK-END */
452 &ANALYZE-RESUME
454 &ENDIF
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 ------------------------------------------------------------------------------*/
464 CASE sort-order:
465 WHEN "D" THEN
466 OPEN QUERY q
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.
472 WHEN "B" THEN
473 OPEN QUERY q
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.
479 WHEN "A" THEN
480 OPEN QUERY q
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.
486 END.
488 END PROCEDURE.
490 /* _UIB-CODE-BLOCK-END */
491 &ANALYZE-RESUME
493 &ENDIF