Add blank column, rename column.
[capital-apms-progress.git] / process / report / expired-leases.p
blobac64205ef925d3c9440f1b6160ac88e3e3941fd4
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Report: Expired Leases printout
6 Author: Andrew McMillan
7 Date: 13/8/2001
8 ------------------------------------------------------------------------*/
10 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
12 DEF VAR date-from AS DATE NO-UNDO.
13 DEF VAR date-to AS DATE NO-UNDO.
14 DEF VAR end-month-first AS DATE NO-UNDO.
15 DEF VAR end-month-last AS DATE NO-UNDO.
16 RUN parse-parameters.
18 DEF VAR myuser-name AS CHAR NO-UNDO.
19 {inc/username.i "myuser-name"}
20 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
21 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + myuser-name.
23 DEF VAR pr-line AS CHAR INIT "" NO-UNDO. /* used everywhere to hold print line */
24 DEF VAR rowcounter AS INT INIT 0.
26 DEF VAR last-property AS INT NO-UNDO INITIAL -1.
28 DEF VAR title-font AS CHAR NO-UNDO INITIAL "font-family: sans-serif; font-weight: 700; font-size: 14pt".
29 DEF VAR time-font AS CHAR NO-UNDO INITIAL "font-family: tahoma,sans-serif; font-size: 6pt;".
30 DEF VAR break1-font AS CHAR NO-UNDO INITIAL "font-family: serif; font-size: 12pt; font-weight: 700;".
31 DEF VAR break2-font AS CHAR NO-UNDO INITIAL "font-family: serif; font-size: 10pt; font-weight: 700;".
32 DEF VAR base-font AS CHAR NO-UNDO INITIAL "font-family: serif; font-size: 9pt;".
34 DEF VAR use-rental-spaces AS LOGI NO-UNDO INITIAL No.
36 {inc/ofc-this.i}
37 {inc/ofc-set-l.i "Use-Rent-Charges" "use-rent-charges"}
38 {inc/ofc-set.i "RentCharge-Outgoings" "og-rentcharge-type"}
39 IF NOT AVAILABLE(OfficeSetting) THEN og-rentcharge-type = "".
41 DEF VAR gst-applies AS LOGI NO-UNDO.
42 gst-applies = Office.GST <> ?.
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
61 /* ************************ Function Prototypes ********************** */
63 &IF DEFINED(EXCLUDE-get-area) = 0 &THEN
65 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-area Procedure
66 FUNCTION get-area RETURNS DECIMAL
67 ( /* parameter-definitions */ ) FORWARD.
69 /* _UIB-CODE-BLOCK-END */
70 &ANALYZE-RESUME
72 &ENDIF
75 /* *********************** Procedure Settings ************************ */
77 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
78 /* Settings for THIS-PROCEDURE
79 Type: Procedure
80 Allow:
81 Frames: 0
82 Add Fields to: Neither
83 Other Settings: CODE-ONLY COMPILE
85 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
87 /* ************************* Create Window ************************** */
89 &ANALYZE-SUSPEND _CREATE-WINDOW
90 /* DESIGN Window definition (used by the UIB)
91 CREATE WINDOW Procedure ASSIGN
92 HEIGHT = 28.25
93 WIDTH = 36.29.
94 /* END WINDOW DEFINITION */
96 &ANALYZE-RESUME
98 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
99 /* ************************* Included-Libraries *********************** */
101 {inc/method/m-txtrep.i}
102 {inc/null.i}
104 /* _UIB-CODE-BLOCK-END */
105 &ANALYZE-RESUME
111 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
114 /* *************************** Main Block *************************** */
116 /* Re-initialise with a more appropriate suffix for HTML files */
117 txtrep-file-suffix = ".html".
118 RUN txtrep-initialise.
120 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
122 /* RUN pclrep-start( preview, "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9"). */
123 RUN htmlrep-start('Expired Leases').
125 RUN report-headers.
127 FOR EACH TenancyLease NO-LOCK WHERE TenancyLease.LeaseStatus = "PAST"
128 AND TenancyLease.LeaseEndDate >= date-from,
129 FIRST Tenant OF TenancyLease NO-LOCK,
130 FIRST Property OF TenancyLease NO-LOCK:
131 RUN each-lease.
132 END.
133 RUN report-footers.
135 OUTPUT CLOSE.
137 RUN htmlrep-finish.
139 /* _UIB-CODE-BLOCK-END */
140 &ANALYZE-RESUME
143 /* ********************** Internal Procedures *********************** */
145 &IF DEFINED(EXCLUDE-each-lease) = 0 &THEN
147 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-lease Procedure
148 PROCEDURE each-lease :
149 /*------------------------------------------------------------------------------
150 Purpose:
151 ------------------------------------------------------------------------------*/
152 DEF VAR lterm AS CHAR NO-UNDO.
153 DEF VAR total-area AS DEC NO-UNDO INITIAL 0.
154 DEF VAR total-rental AS DEC NO-UNDO INITIAL 0.
156 IF TenancyLease.LeaseEndDate > date-to THEN RETURN.
157 IF TenancyLease.LeaseEndDate < date-from THEN RETURN.
159 IF last-property <> Property.PropertyCode THEN DO:
160 IF last-property > 0 THEN DO:
161 PUT UNFORMATTED '<tr><td>&nbsp;</td><td colspan=6><hr></td><td>&nbsp;</td></tr>~n'.
162 END.
163 PUT UNFORMATTED '<tr class=property>~n'.
164 PUT UNFORMATTED "<td align=right class=property>P" STRING(Property.PropertyCode) "</td>~n".
165 PUT UNFORMATTED "<td colspan=6 class=property>" Property.Name "</td>~n".
166 PUT CONTROL "</tr>~n".
167 last-property = Property.PropertyCode.
168 END.
169 lterm = STRING(TenancyLease.TermYears) + "y".
170 IF TenancyLease.TermMonths > 0 THEN lterm = lterm + STRING(TenancyLease.TermMonths) + "m".
171 IF TenancyLease.TermDays > 0 THEN lterm = lterm + STRING(TenancyLease.TermDays) + "d".
173 total-area = get-area().
175 PUT UNFORMATTED '<tr class=row' (rowcounter MODULO 2) '>~n'.
176 PUT UNFORMATTED "<td>&nbsp;</td>~n".
177 PUT UNFORMATTED "<td align=right>" STRING(Tenant.TenantCode) "</td>~n".
178 PUT UNFORMATTED "<td>" Tenant.Name "</td>~n".
179 PUT UNFORMATTED "<td>" TenancyLease.AreaDescription "</td>~n".
180 PUT UNFORMATTED "<td>" lterm "</td>~n".
181 PUT UNFORMATTED "<td align=center>" STRING( TenancyLease.LeaseEndDate, '99/99/9999') "</td>~n".
182 PUT UNFORMATTED "<td align=right>" STRING( total-area, ">>,>>9.99") "</td>~n".
183 /* PUT UNFORMATTED "<td align=right>" STRING( total-rental, ">>,>>>,>>9.99") "</td>~n". */
184 PUT CONTROL "</tr>~n".
185 rowcounter = rowcounter + 1.
186 END PROCEDURE.
188 /* _UIB-CODE-BLOCK-END */
189 &ANALYZE-RESUME
191 &ENDIF
193 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
195 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
196 PROCEDURE parse-parameters :
197 /*------------------------------------------------------------------------------
198 Purpose:
199 ------------------------------------------------------------------------------*/
200 DEF VAR token AS CHAR NO-UNDO.
201 DEF VAR i AS INT NO-UNDO.
203 {inc/showopts.i "report-options"}
204 date-from = TODAY - 110.
205 date-to = TODAY.
207 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
208 token = ENTRY( i, report-options, "~n" ).
210 CASE ENTRY( 1, token ):
211 WHEN "DateFrom" THEN ASSIGN
212 date-from = DATE( ENTRY(2,token) ).
213 WHEN "DateTo" THEN ASSIGN
214 date-to = DATE( ENTRY(2,token) ).
215 END CASE.
217 END.
219 END PROCEDURE.
221 /* _UIB-CODE-BLOCK-END */
222 &ANALYZE-RESUME
224 &ENDIF
226 &IF DEFINED(EXCLUDE-report-footers) = 0 &THEN
228 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE report-footers Procedure
229 PROCEDURE report-footers :
230 /*------------------------------------------------------------------------------
231 Purpose:
232 ------------------------------------------------------------------------------*/
233 PUT UNFORMATTED "</table>~n".
235 PUT UNFORMATTED '<p><p style="' time-font '">Report prepared at ' timeStamp .
236 END PROCEDURE.
238 /* _UIB-CODE-BLOCK-END */
239 &ANALYZE-RESUME
241 &ENDIF
243 &IF DEFINED(EXCLUDE-report-headers) = 0 &THEN
245 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE report-headers Procedure
246 PROCEDURE report-headers :
247 /*------------------------------------------------------------------------------
248 Purpose:
249 ------------------------------------------------------------------------------*/
251 PUT UNFORMATTED '<style type="text/css"><!--~n'.
252 PUT UNFORMATTED '.base, p, td ~{' base-font '}~n'.
253 PUT UNFORMATTED '.title ~{' title-font '}~n'.
254 PUT UNFORMATTED '.property ~{ background: #fcfef4; ' break1-font ' }~n'.
255 PUT UNFORMATTED '.row0 ~{ background: #f0f0c0; }~n'.
256 PUT UNFORMATTED '.row1 ~{ background: #fafbe8; }~n'.
257 PUT UNFORMATTED '.break1 ~{' break1-font '}~n'.
258 PUT UNFORMATTED '.break2 ~{' break2-font '}~n'.
259 PUT UNFORMATTED '--></style>~n'.
261 RUN htmlrep-body.
262 PUT UNFORMATTED '<h2 style="' + title-font + '">Leases Expired between ' STRING(date-from, '99/99/9999') ' and ' STRING(date-to,'99/99/9999') '</h2>~n'.
265 PUT UNFORMATTED "<table>~n".
267 PUT UNFORMATTED "<tr>~n".
268 PUT UNFORMATTED "<th>&nbsp;</th>~n".
269 PUT UNFORMATTED "<th>Code</th>~n".
270 PUT UNFORMATTED "<th align=left>Tenant</th>~n".
271 PUT UNFORMATTED "<th align=left>Area Rented</th>~n".
272 PUT UNFORMATTED "<th>Terms</th>~n".
273 PUT UNFORMATTED "<th>Lease Ended</th>~n".
274 PUT UNFORMATTED "<th>Area</th>~n".
275 /* PUT UNFORMATTED "<th>Rental</th>~n". */
276 PUT CONTROL "</tr>~n".
278 END PROCEDURE.
280 /* _UIB-CODE-BLOCK-END */
281 &ANALYZE-RESUME
283 &ENDIF
285 /* ************************ Function Implementations ***************** */
287 &IF DEFINED(EXCLUDE-get-area) = 0 &THEN
289 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-area Procedure
290 FUNCTION get-area RETURNS DECIMAL
291 ( /* parameter-definitions */ ) :
292 /*------------------------------------------------------------------------------
293 Purpose:
294 Notes:
295 ------------------------------------------------------------------------------*/
296 DEF VAR total-area AS DEC NO-UNDO.
298 FOR EACH RentalSpace OF TenancyLease NO-LOCK:
299 IF CAN-DO("C,N,S", RentalSpace.AreaType ) THEN NEXT.
300 total-area = total-area + RentalSpace.AreaSize .
301 END.
303 RETURN total-area.
305 END FUNCTION.
307 /* _UIB-CODE-BLOCK-END */
308 &ANALYZE-RESUME
310 &ENDIF