1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Report
: Expired Leases printout
6 Author
: Andrew McMillan
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.
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.
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
*/
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
*/
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
*/
75 /* *********************** Procedure Settings
************************ */
77 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
78 /* Settings for
THIS-PROCEDURE
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
94 /* END WINDOW DEFINITION
*/
98 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
99 /* ************************* Included-Libraries
*********************** */
101 {inc
/method
/m-txtrep.i
}
104 /* _UIB-CODE-BLOCK-END
*/
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'
).
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:
139 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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
> </td><td colspan=6><hr></td><td> </td></tr>~n'.
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.
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> </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.
188 /* _UIB-CODE-BLOCK-END
*/
193 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
195 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
196 PROCEDURE parse-parameters
:
197 /*------------------------------------------------------------------------------
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.
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
) ).
221 /* _UIB-CODE-BLOCK-END
*/
226 &IF DEFINED(EXCLUDE-report-footers) = 0 &THEN
228 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE report-footers Procedure
229 PROCEDURE report-footers
:
230 /*------------------------------------------------------------------------------
232 ------------------------------------------------------------------------------*/
233 PUT UNFORMATTED "</table>~n".
235 PUT UNFORMATTED '
<p
><p style
="' time-font '">Report prepared at ' timeStamp .
238 /* _UIB-CODE-BLOCK-END
*/
243 &IF DEFINED(EXCLUDE-report-headers) = 0 &THEN
245 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE report-headers Procedure
246 PROCEDURE report-headers
:
247 /*------------------------------------------------------------------------------
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'.
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> </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".
280 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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 .
307 /* _UIB-CODE-BLOCK-END
*/