Add blank column, rename column.
[capital-apms-progress.git] / process / report / warden-summary.p
blobaa60f2ea8cbdec6e7b139338f8ed8d61266a154d
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Report: Current Income and Budgetted Expenditure
6 Author: Andrew McMillan
7 Date: 2/2/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 property-1 AS INT NO-UNDO INIT 0.
14 DEF VAR property-n AS INT NO-UNDO INIT 99999.
15 DEF VAR selection-style AS CHAR NO-UNDO.
16 DEF VAR contact-types AS CHAR NO-UNDO.
17 RUN parse-parameters.
19 DEF VAR property-code AS INT NO-UNDO.
20 DEF VAR property-name AS CHAR NO-UNDO.
21 DEF VAR entity-name AS CHAR NO-UNDO.
22 DEF VAR last-entity AS CHAR NO-UNDO.
24 DEF VAR user-name AS CHAR NO-UNDO.
25 {inc/username.i "user-name"}
26 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
27 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
29 DEF VAR pr-line AS CHAR INIT "" NO-UNDO. /* used everywhere to hold print line */
31 DEF VAR title-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
32 DEF VAR time-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
33 DEF VAR break1-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,lpi,7,bold".
34 DEF VAR break2-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
35 DEF VAR base-font AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,17,lpi,8.5,bold".
37 {inc/ofc-this.i}
39 /* _UIB-CODE-BLOCK-END */
40 &ANALYZE-RESUME
43 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
45 /* ******************** Preprocessor Definitions ******************** */
47 &Scoped-define PROCEDURE-TYPE Procedure
51 /* _UIB-PREPROCESSOR-BLOCK-END */
52 &ANALYZE-RESUME
55 /* ************************ Function Prototypes ********************** */
57 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-person Procedure
58 FUNCTION get-person RETURNS CHARACTER
59 ( INPUT person-code AS INT ) FORWARD.
61 /* _UIB-CODE-BLOCK-END */
62 &ANALYZE-RESUME
65 /* *********************** Procedure Settings ************************ */
67 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
68 /* Settings for THIS-PROCEDURE
69 Type: Procedure
70 Allow:
71 Frames: 0
72 Add Fields to: Neither
73 Other Settings: CODE-ONLY COMPILE
75 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
77 /* ************************* Create Window ************************** */
79 &ANALYZE-SUSPEND _CREATE-WINDOW
80 /* DESIGN Window definition (used by the UIB)
81 CREATE WINDOW Procedure ASSIGN
82 HEIGHT = .08
83 WIDTH = 32.57.
84 /* END WINDOW DEFINITION */
86 &ANALYZE-RESUME
90 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
91 /* ************************* Included-Libraries *********************** */
93 {inc/method/m-txtrep.i}
94 {inc/persndtl.i}
96 /* _UIB-CODE-BLOCK-END */
97 &ANALYZE-RESUME
101 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
104 /* *************************** Main Block *************************** */
106 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
108 RUN pclrep-start( preview, "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9").
110 IF selection-style = "OneProperty" THEN
111 RUN for-one-property.
112 ELSE
113 RUN for-each-property.
115 OUTPUT CLOSE.
117 RUN pclrep-finish.
119 /* _UIB-CODE-BLOCK-END */
120 &ANALYZE-RESUME
123 /* ********************** Internal Procedures *********************** */
125 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-contact Procedure
126 PROCEDURE each-contact :
127 /*------------------------------------------------------------------------------
128 Purpose:
129 ------------------------------------------------------------------------------*/
130 DEF VAR line AS CHAR NO-UNDO INITIAL "".
131 DEF VAR this-entity AS CHAR NO-UNDO.
133 this-entity = EntityContact.EntityType + STRING(EntityContact.EntityCode, "99999") + entity-name + STRING(EntityContact.PersonCode).
134 IF last-entity = this-entity THEN RETURN.
136 FIND EntityContactType WHERE EntityContactType.EntityContactType = EntityContact.EntityContactType NO-LOCK.
137 line = STRING( EntityContactType.Description, "X(20)").
138 line = line + EntityContact.EntityType + STRING(EntityContact.EntityCode, "99999") + " ".
139 line = line + STRING( entity-name, "X(30)") + " ".
140 line = line + STRING( get-person(EntityContact.PersonCode), "X(30)").
141 line = line + STRING( get-phone-nos(EntityContact.PersonCode), "X(30)").
142 RUN pclrep-line( base-font, " " + line ).
144 last-entity = this-entity.
146 END PROCEDURE.
148 /* _UIB-CODE-BLOCK-END */
149 &ANALYZE-RESUME
152 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-property Procedure
153 PROCEDURE each-property :
154 /*------------------------------------------------------------------------------
155 Purpose: Print the wardens for the property
156 ------------------------------------------------------------------------------*/
157 DEF INPUT PARAMETER property-code AS INT NO-UNDO.
159 DEF VAR need-header AS LOGI INITIAL Yes NO-UNDO.
161 entity-name = property-name.
162 FOR EACH EntityContact NO-LOCK WHERE EntityContact.EntityType = "P"
163 AND EntityContact.EntityCode = Property.PropertyCode:
164 IF contact-types <> "" AND NOT CAN-DO( contact-types, STRING(EntityContact.EntityContactType)) THEN NEXT.
165 IF need-header THEN DO:
166 RUN pclrep-line( break1-font, STRING( property-code, "99999") + " - " + property-name ).
167 RUN pclrep-down-by( 0.3 ).
168 RUN pclrep-line( break2-font, "Building Contacts").
169 need-header = ?.
170 END.
171 RUN each-contact.
172 END.
174 FOR EACH Tenant NO-LOCK WHERE Tenant.Active AND Tenant.EntityType = "P"
175 AND Tenant.EntityCode = Property.PropertyCode
176 AND CAN-FIND( TenancyLease OF Tenant WHERE TenancyLease.LeaseStatus <> "PAST"):
177 entity-name = Tenant.Name.
178 FOR EACH EntityContact NO-LOCK WHERE EntityContact.EntityType = "T"
179 AND EntityContact.EntityCode = Tenant.TenantCode:
180 IF contact-types <> "" AND NOT CAN-DO( contact-types, STRING(EntityContact.EntityContactType)) THEN NEXT.
181 IF need-header <> No THEN DO:
182 IF need-header THEN DO:
183 RUN pclrep-line( break1-font, STRING( property-code, "99999") + " - " + property-name ).
184 RUN pclrep-down-by( 0.3 ).
185 END.
186 ELSE
187 RUN pclrep-down-by( 0.7 ).
188 RUN pclrep-line( break2-font, "Tenant Contacts").
189 need-header = No.
190 END.
191 RUN each-contact.
192 END.
193 END.
195 IF need-header <> Yes THEN RUN pclrep-page-break.
197 END PROCEDURE.
199 /* _UIB-CODE-BLOCK-END */
200 &ANALYZE-RESUME
203 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-each-property Procedure
204 PROCEDURE for-each-property :
205 /*------------------------------------------------------------------------------
206 Purpose:
207 ------------------------------------------------------------------------------*/
209 FOR EACH Property WHERE Property.PropertyCode >= property-1
210 AND Property.PropertyCode <= property-n
211 AND Property.Active NO-LOCK:
212 property-code = Property.PropertyCode.
213 property-name = Property.Name.
214 RUN each-property( property-code ).
215 END.
217 END PROCEDURE.
219 /* _UIB-CODE-BLOCK-END */
220 &ANALYZE-RESUME
223 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-one-property Procedure
224 PROCEDURE for-one-property :
225 /*------------------------------------------------------------------------------
226 Purpose:
227 ------------------------------------------------------------------------------*/
229 FIND Property WHERE Property.PropertyCode = property-1 NO-LOCK NO-ERROR.
230 IF NOT AVAILABLE Property THEN DO:
231 RUN pclrep-line( base-font + ",bold", "Property " + STRING(property-1) + " not on file!").
232 RETURN.
233 END.
235 property-code = Property.PropertyCode.
236 property-name = Property.Name.
237 RUN each-property( property-code ).
239 END PROCEDURE.
241 /* _UIB-CODE-BLOCK-END */
242 &ANALYZE-RESUME
245 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
246 PROCEDURE inst-page-footer :
247 /*------------------------------------------------------------------------------
248 Purpose: Print any page footer
249 ------------------------------------------------------------------------------*/
251 END PROCEDURE.
253 /* _UIB-CODE-BLOCK-END */
254 &ANALYZE-RESUME
257 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
258 PROCEDURE inst-page-header :
259 /*------------------------------------------------------------------------------
260 Purpose: Print any page header
261 ------------------------------------------------------------------------------*/
263 RUN pclrep-line( "univers,Point,6,bold,Proportional", TimeStamp).
264 RUN pclrep-line( "", "" ).
265 RUN pclrep-line( "univers,Point,12,bold,Proportional",
266 "Building Act Details" ).
267 RUN pclrep-line( "", "" ).
269 /* Put any column headers here */
270 pr-line = " Contact Type Entity Name Person Telephones" .
271 RUN pclrep-line( base-font, pr-line ).
272 RUN pclrep-down-by(1).
274 END PROCEDURE.
276 /* _UIB-CODE-BLOCK-END */
277 &ANALYZE-RESUME
280 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
281 PROCEDURE parse-parameters :
282 /*------------------------------------------------------------------------------
283 Purpose:
284 ------------------------------------------------------------------------------*/
285 DEF VAR token AS CHAR NO-UNDO.
286 DEF VAR i AS INT NO-UNDO.
287 DEF VAR fin-year AS INT NO-UNDO.
289 {inc/showopts.i "report-options"}
291 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
292 token = ENTRY( i, report-options, "~n" ).
294 CASE ENTRY( 1, token ):
295 WHEN "Preview" THEN preview = Yes.
296 WHEN "Selection" THEN selection-style = ENTRY(2,token).
297 WHEN "ContactTypes" THEN contact-types = SUBSTRING( token, INDEX(token,",") + 1).
298 WHEN "Properties" THEN ASSIGN
299 property-1 = INT( ENTRY(2,token) )
300 property-n = INT( ENTRY(3,token) ).
301 END CASE.
302 END.
304 END PROCEDURE.
306 /* _UIB-CODE-BLOCK-END */
307 &ANALYZE-RESUME
310 /* ************************ Function Implementations ***************** */
312 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-person Procedure
313 FUNCTION get-person RETURNS CHARACTER
314 ( INPUT person-code AS INT ) :
315 /*------------------------------------------------------------------------------
316 Purpose: Return the details of the warden
317 ------------------------------------------------------------------------------*/
318 DEF BUFFER MyPerson FOR Person.
319 DEF BUFFER MyPhone FOR PhoneDetail.
320 DEF BUFFER MyAddress FOR PostalDetail.
322 FIND MyPerson WHERE MyPerson.PersonCode = person-code NO-LOCK NO-ERROR.
323 IF AVAILABLE(MyPerson) THEN
324 RETURN MyPerson.FirstName + " " + MyPerson.LastName .
326 RETURN "Can't find a name for person " + STRING(person-code).
328 END FUNCTION.
330 /* _UIB-CODE-BLOCK-END */
331 &ANALYZE-RESUME