Add blank column, rename column.
[capital-apms-progress.git] / process / report / lseexpry.p
blob7ae6c32a6e9bcd1a88f5902e8b6a6073ddba1ae2
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r11
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File :
6 Purpose :
8 Syntax :
10 Description :
12 Author(s) :
13 Created : Deep in the mists of time
14 Notes :
15 ------------------------------------------------------------------------*/
17 /* *************************** Definitions ************************** */
19 &SCOPED-DEFINE lines-per-page 112
21 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
23 DEF VAR date-to AS DATE NO-UNDO.
24 DEF VAR exclude-monthly AS LOGI NO-UNDO INITIAL No.
25 DEF VAR preview AS LOGI NO-UNDO INITIAL No.
27 RUN parse-parameters.
30 /* Report counters */
31 DEF VAR ln AS DEC INIT 0.00 NO-UNDO.
33 /* Line definitions */
35 DEF VAR page-no AS INT INIT 1 NO-UNDO.
36 DEF VAR reset-page AS CHAR NO-UNDO.
37 DEF VAR half-line AS CHAR NO-UNDO. half-line = CHR(27) + "=".
38 DEF VAR title-font AS CHAR NO-UNDO.
39 DEF VAR time-font AS CHAR NO-UNDO.
40 DEF VAR property-font AS CHAR NO-UNDO.
41 DEF VAR lease-font AS CHAR NO-UNDO.
42 DEF VAR header-font AS CHAR NO-UNDO.
43 DEF VAR line-printer AS CHAR NO-UNDO.
44 DEF VAR i AS INT NO-UNDO.
46 DEF VAR user-name AS CHAR NO-UNDO.
47 {inc/username.i "user-name"}
49 /* _UIB-CODE-BLOCK-END */
50 &ANALYZE-RESUME
53 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
55 /* ******************** Preprocessor Definitions ******************** */
57 &Scoped-define PROCEDURE-TYPE Procedure
58 &Scoped-define DB-AWARE no
62 /* _UIB-PREPROCESSOR-BLOCK-END */
63 &ANALYZE-RESUME
67 /* *********************** Procedure Settings ************************ */
69 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
70 /* Settings for THIS-PROCEDURE
71 Type: Procedure
72 Allow:
73 Frames: 0
74 Add Fields to: Neither
75 Other Settings: CODE-ONLY COMPILE
77 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
79 /* ************************* Create Window ************************** */
81 &ANALYZE-SUSPEND _CREATE-WINDOW
82 /* DESIGN Window definition (used by the UIB)
83 CREATE WINDOW Procedure ASSIGN
84 HEIGHT = 25
85 WIDTH = 40.
86 /* END WINDOW DEFINITION */
88 &ANALYZE-RESUME
90 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
91 /* ************************* Included-Libraries *********************** */
93 {inc/method/m-txtrep.i}
94 {inc/convert.i}
96 /* _UIB-CODE-BLOCK-END */
97 &ANALYZE-RESUME
103 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
106 /* *************************** Main Block *************************** */
108 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
110 RUN leases-expiring.
112 OUTPUT CLOSE.
113 RUN view-output-file ( no ).
115 /* _UIB-CODE-BLOCK-END */
116 &ANALYZE-RESUME
119 /* ********************** Internal Procedures *********************** */
121 &IF DEFINED(EXCLUDE-carriage-return) = 0 &THEN
123 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE carriage-return Procedure
124 PROCEDURE carriage-return :
125 /*------------------------------------------------------------------------------
126 Purpose:
127 Parameters: <none>
128 Notes:
129 ------------------------------------------------------------------------------*/
131 PUT CONTROL CHR(13).
133 END PROCEDURE.
135 /* _UIB-CODE-BLOCK-END */
136 &ANALYZE-RESUME
138 &ENDIF
140 &IF DEFINED(EXCLUDE-column-header) = 0 &THEN
142 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE column-header Procedure
143 PROCEDURE column-header :
144 /*------------------------------------------------------------------------------
145 Purpose:
146 Parameters: <none>
147 Notes:
148 ------------------------------------------------------------------------------*/
150 PUT CONTROL line-printer.
151 RUN skip-line(2).
152 PUT CONTROL header-font.
153 PUT UNFORMATTED
154 SPACE(20)
155 STRING( "Space Description", "X(60)" ) SPACE(6)
156 STRING( "Area SQ.M", "X(10)" ) SPACE(8)
157 STRING( "Estimated Rental Value", "X(22)" ) SPACE(18)
158 STRING( "Current Rental", "X(20)" ).
159 PUT CONTROL line-printer.
160 RUN skip-line(1.5).
161 PUT CONTROL header-font.
162 PUT UNFORMATTED
163 SPACE(130)
164 STRING( "$", "X" ) SPACE(10)
165 STRING( "$/Sq M", "X(6)" ) SPACE(18)
166 STRING( "$", "X" ) SPACE(10)
167 STRING( "$/Sq M", "X(6)" ).
168 PUT CONTROL line-printer.
169 RUN skip-line(3).
171 END PROCEDURE.
173 /* _UIB-CODE-BLOCK-END */
174 &ANALYZE-RESUME
176 &ENDIF
178 &IF DEFINED(EXCLUDE-each-property) = 0 &THEN
180 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-property Procedure
181 PROCEDURE each-property :
182 /*------------------------------------------------------------------------------
183 Purpose:
184 Parameters: <none>
185 Notes:
186 ------------------------------------------------------------------------------*/
188 DEF VAR i AS INT NO-UNDO.
190 i = 0.
191 IF NOT( exclude-monthly ) THEN DO:
192 FOR EACH TenancyLease OF Property NO-LOCK WHERE
193 TenancyLease.LeaseStatus = 'NORM'
194 AND ( TenancyLease.LeaseEndDate = ? OR
195 TenancyLease.LeaseEndDate <= TODAY ) AND
196 CAN-FIND( Tenant WHERE
197 Tenant.Active AND Tenant.TenantCode = TenancyLease.TenantCode )
198 BY TenancyLease.LeaseEndDate:
200 i = i + 1.
201 IF i = 1 THEN RUN property-header.
202 RUN each-tenancy-lease.
203 END.
204 END.
206 FOR EACH TenancyLease OF Property NO-LOCK WHERE
207 TenancyLease.LeaseStatus = 'NORM' AND
208 NOT ( TenancyLease.LeaseEndDate = ? OR
209 TenancyLease.LeaseEndDate <= TODAY ) AND
210 TenancyLease.LeaseEndDate <= date-to AND
211 CAN-FIND( Tenant WHERE
212 Tenant.Active AND Tenant.TenantCode = TenancyLease.TenantCode )
213 BY TenancyLease.LeaseEndDate:
215 i = i + 1.
216 IF i = 1 THEN RUN property-header.
217 RUN each-tenancy-lease.
218 END.
220 IF i > 0 THEN RUN skip-line(2).
222 END PROCEDURE.
224 /* _UIB-CODE-BLOCK-END */
225 &ANALYZE-RESUME
227 &ENDIF
229 &IF DEFINED(EXCLUDE-each-rental-space) = 0 &THEN
231 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-rental-space Procedure
232 PROCEDURE each-rental-space :
233 /*------------------------------------------------------------------------------
234 Purpose:
235 Parameters: <none>
236 Notes:
237 ------------------------------------------------------------------------------*/
239 DEF VAR mrkt AS DEC NO-UNDO.
240 DEF VAR chrg AS DEC NO-UNDO.
241 DEF VAR mrkt-rate AS DEC NO-UNDO.
242 DEF VAR chrg-rate AS DEC NO-UNDO.
243 DEF VAR c-mrkt-rate AS CHAR NO-UNDO.
244 DEF VAR c-chrg-rate AS CHAR NO-UNDO.
245 DEF VAR suffix AS CHAR NO-UNDO.
247 mrkt = IF RentalSpace.MarketRental = ? THEN 0.00 ELSE RentalSpace.MarketRental.
248 chrg = IF RentalSpace.ChargedRental = ? THEN 0.00 ELSE RentalSpace.ChargedRental.
250 IF RentalSpace.AreaType = "C" THEN
251 ASSIGN
252 mrkt-rate = ( mrkt / RentalSpace.AreaSize ) / 52
253 chrg-rate = ( chrg / RentalSpace.AreaSize ) / 52
254 suffix = "pw".
255 ELSE
256 ASSIGN
257 mrkt-rate = mrkt / RentalSpace.AreaSize
258 chrg-rate = chrg / RentalSpace.AreaSize.
260 IF mrkt-rate = ? THEN mrkt-rate = 0.00. IF chrg-rate = ? THEN chrg-rate = 0.00.
261 ASSIGN
262 c-mrkt-rate = STRING( mrkt-rate, ">>>>9.99" ) + suffix
263 c-chrg-rate = STRING( chrg-rate, ">>>>9.99" ) + suffix.
265 PUT UNFORMATTED SPACE(10)
266 STRING( RentalSpace.RentalSpaceCode, "9999" ) SPACE(2)
267 STRING( RentalSpace.Description, "X(40)" ) SPACE(2)
268 STRING( RentalSpace.AreaSize, ">>>,>>9.99" ) SPACE(2)
269 STRING( mrkt, ">>>,>>>,>>9.99" ) SPACE(2)
270 STRING( c-mrkt-rate, "X(9)" ) SPACE(2)
271 STRING( chrg, ">>>,>>>,>>9.99" ) SPACE(2)
272 STRING( c-chrg-rate, "X(9)" ).
273 RUN skip-line(1).
275 END PROCEDURE.
277 /* _UIB-CODE-BLOCK-END */
278 &ANALYZE-RESUME
280 &ENDIF
282 &IF DEFINED(EXCLUDE-each-tenancy-lease) = 0 &THEN
284 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenancy-lease Procedure
285 PROCEDURE each-tenancy-lease :
286 /*------------------------------------------------------------------------------
287 Purpose:
288 Parameters: <none>
289 Notes:
290 ------------------------------------------------------------------------------*/
292 RUN lease-header.
294 FOR EACH RentalSpace OF Tenancylease NO-LOCK
295 WHERE RentalSpace.AreaStatus <> "V":
296 RUN each-rental-space.
297 END.
299 RUN skip-line(1).
301 END PROCEDURE.
303 /* _UIB-CODE-BLOCK-END */
304 &ANALYZE-RESUME
306 &ENDIF
308 &IF DEFINED(EXCLUDE-get-control-strings) = 0 &THEN
310 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-control-strings Procedure
311 PROCEDURE get-control-strings :
312 /*------------------------------------------------------------------------------
313 Purpose: Get all control strings for this report
314 Parameters: <none>
315 Notes:
316 ------------------------------------------------------------------------------*/
318 DEF VAR rows AS DEC NO-UNDO.
319 DEF VAR cols AS DEC NO-UNDO.
321 RUN make-control-string ( "PCL", "reset,portrait,a4,tm,0,lm,4",
322 OUTPUT reset-page, OUTPUT rows, OUTPUT cols ).
324 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,12",
325 OUTPUT title-font, OUTPUT rows, OUTPUT cols ).
327 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,6",
328 OUTPUT time-font, OUTPUT rows, OUTPUT cols ).
330 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,8",
331 OUTPUT header-font, OUTPUT rows, OUTPUT cols ).
333 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,10",
334 OUTPUT property-font, OUTPUT rows, OUTPUT cols ).
336 RUN make-control-string ( "PCL", "Proportional,Helvetica,Bold,Point,8",
337 OUTPUT lease-font, OUTPUT rows, OUTPUT cols ).
339 RUN make-control-string ( "PCL", "LinePrinter,lpi,9.54",
340 OUTPUT line-printer, OUTPUT rows, OUTPUT cols ).
342 END PROCEDURE.
344 /* _UIB-CODE-BLOCK-END */
345 &ANALYZE-RESUME
347 &ENDIF
349 &IF DEFINED(EXCLUDE-lease-header) = 0 &THEN
351 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE lease-header Procedure
352 PROCEDURE lease-header :
353 /*------------------------------------------------------------------------------
354 Purpose:
355 Parameters: <none>
356 Notes:
357 ------------------------------------------------------------------------------*/
359 PUT CONTROL line-printer.
360 PUT UNFORMATTED SPACE(6).
361 PUT CONTROL lease-font.
363 FIND FIRST Tenant WHERE Tenant.TenantCode = TenancyLease.TenantCode NO-LOCK NO-ERROR.
365 PUT UNFORMATTED
366 IF TenancyLease.LeaseEndDate <= TODAY OR
367 TenancyLease.LeaseEndDate = ? THEN "Monthly" ELSE
368 STRING( TenancyLease.LeaseEndDate, "99/99/9999" )
369 " - " + Tenant.Name.
370 PUT CONTROL line-printer.
371 RUN skip-line(1.5).
374 END PROCEDURE.
376 /* _UIB-CODE-BLOCK-END */
377 &ANALYZE-RESUME
379 &ENDIF
381 &IF DEFINED(EXCLUDE-leases-expiring) = 0 &THEN
383 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE leases-expiring Procedure
384 PROCEDURE leases-expiring :
385 /*------------------------------------------------------------------------------
386 Purpose:
387 Parameters: <none>
388 Notes:
389 ------------------------------------------------------------------------------*/
391 RUN get-control-strings.
392 RUN page-header.
394 FOR EACH Property NO-LOCK WHERE Property.Active
395 BY Property.Region:
396 RUN each-property.
397 END.
399 RUN page-feed.
401 END PROCEDURE.
403 /* _UIB-CODE-BLOCK-END */
404 &ANALYZE-RESUME
406 &ENDIF
408 &IF DEFINED(EXCLUDE-page-feed) = 0 &THEN
410 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-feed Procedure
411 PROCEDURE page-feed :
412 /*------------------------------------------------------------------------------
413 Purpose:
414 Parameters: <none>
415 Notes:
416 ------------------------------------------------------------------------------*/
418 page-no = page-no + 1.
419 PUT CONTROL CHR(12).
421 END PROCEDURE.
423 /* _UIB-CODE-BLOCK-END */
424 &ANALYZE-RESUME
426 &ENDIF
428 &IF DEFINED(EXCLUDE-page-header) = 0 &THEN
430 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-header Procedure
431 PROCEDURE page-header :
432 /*------------------------------------------------------------------------------
433 Purpose:
434 Parameters: <none>
435 Notes:
436 ------------------------------------------------------------------------------*/
438 RUN reset-page.
439 RUN print-title.
440 RUN column-header.
442 END PROCEDURE.
444 /* _UIB-CODE-BLOCK-END */
445 &ANALYZE-RESUME
447 &ENDIF
449 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
451 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
452 PROCEDURE parse-parameters :
453 /*------------------------------------------------------------------------------
454 Purpose:
455 ------------------------------------------------------------------------------*/
456 DEF VAR token AS CHAR NO-UNDO.
457 DEF VAR i AS INT NO-UNDO.
459 {inc/showopts.i "report-options"}
461 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
462 token = ENTRY( i, report-options, "~n" ).
464 CASE ENTRY( 1, token ):
465 WHEN "Preview" THEN preview = Yes.
466 WHEN "ExcludeMonthly" THEN exclude-monthly = Yes.
467 WHEN "UpTo" THEN ASSIGN
468 date-to = DATE( ENTRY( 2, token ) ).
470 END CASE.
472 END.
474 END PROCEDURE.
476 /* _UIB-CODE-BLOCK-END */
477 &ANALYZE-RESUME
479 &ENDIF
481 &IF DEFINED(EXCLUDE-print-title) = 0 &THEN
483 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-title Procedure
484 PROCEDURE print-title :
485 /*------------------------------------------------------------------------------
486 Purpose:
487 Parameters: <none>
488 Notes:
489 ------------------------------------------------------------------------------*/
491 PUT CONTROL line-printer.
492 RUN skip-line(2).
493 PUT CONTROL time-font.
494 PUT UNFORMATTED
495 STRING(
496 "Printed: " + STRING( TODAY, "99/99/9999" ) + " " +
497 STRING( TIME, "HH:MM:SS" ) + " for " + user-name,
498 "X(100)" ) SPACE(120)
499 STRING( "Page: " + STRING( page-no ), "X(20)" ).
500 RUN skip-line(2).
501 PUT CONTROL title-font.
502 PUT UNFORMATTED SPACE(45) STRING( "Leases Expiring Report", "X(50)" ).
503 RUN skip-line(1).
504 PUT CONTROL line-printer.
506 END PROCEDURE.
508 /* _UIB-CODE-BLOCK-END */
509 &ANALYZE-RESUME
511 &ENDIF
513 &IF DEFINED(EXCLUDE-property-header) = 0 &THEN
515 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE property-header Procedure
516 PROCEDURE property-header :
517 /*------------------------------------------------------------------------------
518 Purpose:
519 Parameters: <none>
520 Notes:
521 ------------------------------------------------------------------------------*/
523 PUT CONTROL property-font.
524 PUT UNFORMATTED STRING(
525 "(" + Property.Region + ") " +
526 STRING( Property.PropertyCode, "9999" ) + ' - ' + Property.Name,
527 "X(100)" ).
528 PUT CONTROL line-printer.
529 RUN skip-line(2).
531 END PROCEDURE.
533 /* _UIB-CODE-BLOCK-END */
534 &ANALYZE-RESUME
536 &ENDIF
538 &IF DEFINED(EXCLUDE-reset-page) = 0 &THEN
540 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-page Procedure
541 PROCEDURE reset-page :
542 /*------------------------------------------------------------------------------
543 Purpose:
544 Parameters: <none>
545 Notes:
546 ------------------------------------------------------------------------------*/
548 PUT CONTROL reset-page.
549 ln = 0.
551 END PROCEDURE.
553 /* _UIB-CODE-BLOCK-END */
554 &ANALYZE-RESUME
556 &ENDIF
558 &IF DEFINED(EXCLUDE-skip-line) = 0 &THEN
560 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-line Procedure
561 PROCEDURE skip-line :
562 /*------------------------------------------------------------------------------
563 Purpose:
564 Parameters: <none>
565 Notes:
566 ------------------------------------------------------------------------------*/
568 DEF INPUT PARAMETER n AS DEC NO-UNDO.
570 IF ln + n >= {&lines-per-page} THEN
572 RUN page-feed.
573 RUN page-header.
574 RETURN.
575 END.
577 DEF VAR int-part AS INT NO-UNDO.
578 DEF VAR dec-part AS DEC NO-UNDO.
580 int-part = TRUNCATE( n, 0 ).
581 IF int-part < 0 THEN RETURN.
582 dec-part = n - int-part.
583 IF int-part = 0 AND dec-part = 0 THEN RETURN.
585 /* Need to have this like the following - do not touch */
586 IF int-part <> 0 THEN PUT CONTROL FILL( CHR(10), int-part ).
587 IF dec-part <> 0 THEN PUT CONTROL half-line.
589 ln = ln + n.
591 RUN carriage-return.
593 END PROCEDURE.
595 /* _UIB-CODE-BLOCK-END */
596 &ANALYZE-RESUME
598 &ENDIF
600 &IF DEFINED(EXCLUDE-skip-to-line) = 0 &THEN
602 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-to-line Procedure
603 PROCEDURE skip-to-line :
604 /*------------------------------------------------------------------------------
605 Purpose:
606 Parameters: <none>
607 Notes:
608 ------------------------------------------------------------------------------*/
610 DEF INPUT PARAMETER line-no AS DEC NO-UNDO.
612 DEF VAR int-part AS INT NO-UNDO.
613 DEF VAR dec-part AS DEC NO-UNDO.
615 int-part = TRUNCATE( line-no - ln, 0 ).
616 IF int-part < 0 THEN RETURN.
617 dec-part = ( line-no - ln ) - int-part.
618 IF int-part = 0 AND dec-part = 0 THEN RETURN.
620 IF int-part <> 0 THEN PUT CONTROL FILL( CHR(10), int-part ).
621 IF dec-part <> 0 THEN PUT CONTROL half-line.
623 ln = line-no.
625 RUN carriage-return.
627 END PROCEDURE.
629 /* _UIB-CODE-BLOCK-END */
630 &ANALYZE-RESUME
632 &ENDIF