Add blank column, rename column.
[capital-apms-progress.git] / process / report / to-do.p
blob29fcae71eec0fe9c717c1279220863d897c9fb37
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 person-1 AS INT NO-UNDO INIT 0.
15 DEF VAR person-n AS INT NO-UNDO INIT 99999.
16 DEF VAR period-1 AS DATE NO-UNDO.
17 DEF VAR period-n AS DATE NO-UNDO.
18 DEF VAR selection-style AS CHAR NO-UNDO.
19 RUN parse-parameters.
21 DEF VAR user-name AS CHAR NO-UNDO.
22 {inc/username.i "user-name"}
23 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
24 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
26 DEF VAR pr-line AS CHAR INIT "" NO-UNDO. /* used everywhere to hold print line */
27 DEF VAR person-code AS INT NO-UNDO.
28 DEF VAR person-name AS CHAR NO-UNDO.
30 DEF VAR title-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
31 DEF VAR time-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
32 DEF VAR break1-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,lpi,7,bold".
33 DEF VAR break2-font AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
34 DEF VAR base-font AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,17,lpi,8.5,bold".
36 {inc/ofc-this.i}
38 DEF TEMP-TABLE TaskDue NO-UNDO
39 FIELD DueDate AS DATE
40 FIELD FlowTaskNo AS INT
41 INDEX XPKDueTasks AS PRIMARY UNIQUE DueDate FlowTaskNo.
43 /* _UIB-CODE-BLOCK-END */
44 &ANALYZE-RESUME
47 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
49 /* ******************** Preprocessor Definitions ******************** */
51 &Scoped-define PROCEDURE-TYPE Procedure
55 /* _UIB-PREPROCESSOR-BLOCK-END */
56 &ANALYZE-RESUME
60 /* *********************** Procedure Settings ************************ */
62 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
63 /* Settings for THIS-PROCEDURE
64 Type: Procedure
65 Allow:
66 Frames: 0
67 Add Fields to: Neither
68 Other Settings: CODE-ONLY COMPILE
70 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
72 /* ************************* Create Window ************************** */
74 &ANALYZE-SUSPEND _CREATE-WINDOW
75 /* DESIGN Window definition (used by the UIB)
76 CREATE WINDOW Procedure ASSIGN
77 HEIGHT = .08
78 WIDTH = 32.57.
79 /* END WINDOW DEFINITION */
81 &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
97 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
100 /* *************************** Main Block *************************** */
102 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
104 RUN pclrep-start( preview, "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9").
106 IF selection-style = "Me" THEN RUN for-one-person( person-1 ).
107 ELSE IF selection-style = "Manager" THEN RUN for-one-person( person-1 ).
108 ELSE DO:
109 RUN preselect-people.
110 RUN for-each-person.
111 END.
113 OUTPUT CLOSE.
115 RUN pclrep-finish.
117 /* _UIB-CODE-BLOCK-END */
118 &ANALYZE-RESUME
121 /* ********************** Internal Procedures *********************** */
123 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-each-property Procedure
124 PROCEDURE for-each-property :
125 /*------------------------------------------------------------------------------
126 Purpose:
127 ------------------------------------------------------------------------------*/
128 FOR EACH FlowTask WHERE FlowTask.ActivityStatus <> "DONE"
129 AND FlowTask.EntityType = "P"
130 AND FlowTask.EntityCode = Property.PropertyCode NO-LOCK:
131 IF FlowTask.DueDate < period-1 OR FlowTask.DueDate > period-n THEN NEXT.
132 IF CAN-FIND( TaskDue OF FlowTask ) THEN NEXT.
133 CREATE TaskDue.
134 TaskDue.DueDate = FlowTask.DueDate.
135 TaskDue.FlowTaskNo = FlowTask.FlowTaskNo.
136 END.
137 FOR EACH Tenant WHERE Tenant.Active AND Tenant.EntityType = "P"
138 AND Tenant.EntityCode = Property.PropertyCode NO-LOCK:
139 FOR EACH FlowTask WHERE FlowTask.ActivityStatus <> "DONE"
140 AND FlowTask.EntityType = "T"
141 AND FlowTask.EntityCode = Tenant.TenantCode NO-LOCK:
142 IF FlowTask.DueDate < period-1 OR FlowTask.DueDate > period-n THEN NEXT.
143 IF CAN-FIND( TaskDue OF FlowTask ) THEN NEXT.
144 CREATE TaskDue.
145 TaskDue.DueDate = FlowTask.DueDate.
146 TaskDue.FlowTaskNo = FlowTask.FlowTaskNo.
147 END.
148 END.
150 END PROCEDURE.
152 /* _UIB-CODE-BLOCK-END */
153 &ANALYZE-RESUME
156 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-each-task Procedure
157 PROCEDURE for-each-task :
158 /*------------------------------------------------------------------------------
159 Purpose:
160 ------------------------------------------------------------------------------*/
161 DEF VAR entity-desc AS CHAR NO-UNDO.
163 entity-desc = get-entity-name( FlowTask.EntityType, FlowTask.EntityCode ).
164 pr-line = null-str( STRING( FlowTask.DueDate, "99/99/9999"), "??/??/????") + " "
165 + STRING( FlowTask.ActivityStatus,"X(5)")
166 + STRING( FlowTask.FlowTaskType, "X(5)" )
167 + STRING( FlowTask.Description, "X(15)" ) + " "
168 + STRING( FlowTask.EntityType, "X")
169 + STRING( FlowTask.EntityCode, "99999") + " "
170 + entity-desc.
171 RUN pclrep-line( base-font, pr-line ).
173 END PROCEDURE.
175 /* _UIB-CODE-BLOCK-END */
176 &ANALYZE-RESUME
179 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE for-one-person Procedure
180 PROCEDURE for-one-person :
181 /*------------------------------------------------------------------------------
182 Purpose:
183 ------------------------------------------------------------------------------*/
184 DEF INPUT PARAMETER this-person AS INT NO-UNDO.
186 person-code = this-person.
187 FIND Person WHERE Person.PersonCode = this-person NO-LOCK NO-ERROR.
188 IF NOT AVAILABLE(Person) THEN RETURN.
189 person-name = Person.FirstName + " " + Person.LastName .
191 RUN pclrep-line( break1-font, "Tasks for " + person-name ).
193 FOR EACH FlowTask WHERE FlowTask.ActivityStatus <> "DONE"
194 AND FlowTask.AllocatedTo = this-person NO-LOCK:
195 IF FlowTask.DueDate < period-1 OR FlowTask.DueDate > period-n THEN NEXT.
196 IF CAN-FIND( TaskDue OF FlowTask ) THEN NEXT.
197 CREATE TaskDue.
198 TaskDue.DueDate = FlowTask.DueDate.
199 TaskDue.FlowTaskNo = FlowTask.FlowTaskNo.
200 END.
202 FOR EACH Property WHERE Property.Active AND Property.Manager = this-person NO-LOCK:
203 RUN for-each-property.
204 END.
206 FOR EACH Property WHERE Property.Active AND Property.Administrator = this-person NO-LOCK:
207 RUN for-each-property.
208 END.
210 FOR EACH TaskDue:
211 FIND FlowTask OF TaskDue NO-LOCK NO-ERROR.
212 IF AVAILABLE(FlowTask) THEN RUN for-each-task.
213 DELETE TaskDue.
214 END.
216 END PROCEDURE.
218 /* _UIB-CODE-BLOCK-END */
219 &ANALYZE-RESUME
222 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
223 PROCEDURE inst-page-footer :
224 /*------------------------------------------------------------------------------
225 Purpose: Print any page footer
226 ------------------------------------------------------------------------------*/
228 END PROCEDURE.
230 /* _UIB-CODE-BLOCK-END */
231 &ANALYZE-RESUME
234 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
235 PROCEDURE inst-page-header :
236 /*------------------------------------------------------------------------------
237 Purpose: Print any page header
238 ------------------------------------------------------------------------------*/
240 RUN pclrep-line( "univers,Point,6,bold,Proportional", TimeStamp).
241 RUN pclrep-line( "", "" ).
242 RUN pclrep-line( "univers,Point,12,bold,Proportional",
243 "To Do list for "
244 + TRIM(STRING(person-code))
245 + " - "
246 + person-name ).
247 RUN pclrep-line( "", "" ).
249 /* Put any column headers here */
250 pr-line = " Due By Stat Type Description Entity/Description" .
252 RUN pclrep-line( base-font, pr-line ).
253 RUN pclrep-down-by(1).
255 END PROCEDURE.
257 /* _UIB-CODE-BLOCK-END */
258 &ANALYZE-RESUME
261 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
262 PROCEDURE parse-parameters :
263 /*------------------------------------------------------------------------------
264 Purpose:
265 ------------------------------------------------------------------------------*/
266 DEF VAR token AS CHAR NO-UNDO.
267 DEF VAR i AS INT NO-UNDO.
268 DEF VAR fin-year AS INT NO-UNDO.
270 {inc/showopts.i "report-options"}
271 period-1 = TODAY - 180.
272 period-n = TODAY + 90.
274 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
275 token = ENTRY( i, report-options, "~n" ).
277 CASE ENTRY( 1, token ):
278 WHEN "Preview" THEN preview = Yes.
279 WHEN "Manager" THEN person-1 = INT( ENTRY(2,token) ).
280 WHEN "Selection" THEN selection-style = ENTRY(2,token).
281 WHEN "Period" THEN ASSIGN
282 period-1 = DATE( ENTRY(2,token) )
283 period-n = DATE( ENTRY(3,token) ).
284 WHEN "Person" THEN ASSIGN
285 person-1 = INT( ENTRY(2,token) )
286 person-n = INT( ENTRY(3,token) ).
287 END CASE.
289 END.
291 END PROCEDURE.
293 /* _UIB-CODE-BLOCK-END */
294 &ANALYZE-RESUME
297 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE preselect-people Procedure
298 PROCEDURE preselect-people :
299 /*------------------------------------------------------------------------------
300 Purpose:
301 ------------------------------------------------------------------------------*/
303 END PROCEDURE.
305 /* _UIB-CODE-BLOCK-END */
306 &ANALYZE-RESUME