Really, this should be it, for the passing income.
[capital-apms-progress.git] / vwr / mnt / v-prjbdg.w
blobcbd35d12b9e76ef78cf7fb130c23639b402a27e8
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI ADM1
2 &ANALYZE-RESUME
3 /* Connected Databases
4 ttpl PROGRESS
5 */
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS V-table-Win
8 /*------------------------------------------------------------------------
10 File:
12 Description: from VIEWER.W - Template for SmartViewer Objects
14 Input Parameters:
15 <none>
17 Output Parameters:
18 <none>
20 ------------------------------------------------------------------------*/
21 /* This .W file was created with the Progress UIB. */
22 /*----------------------------------------------------------------------*/
24 /* Create an unnamed pool to store all the widgets created
25 by this procedure. This is a good default which assures
26 that this procedure's triggers and internal procedures
27 will execute in this procedure's storage, and that proper
28 cleanup will occur on deletion of the procedure. */
30 CREATE WIDGET-POOL.
32 /* *************************** Definitions ************************** */
34 /* Parameters Definitions --- */
36 /* Local Variable Definitions --- */
38 DEF VAR mode AS CHAR NO-UNDO.
40 /* _UIB-CODE-BLOCK-END */
41 &ANALYZE-RESUME
44 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
46 /* ******************** Preprocessor Definitions ******************** */
48 &Scoped-define PROCEDURE-TYPE SmartViewer
49 &Scoped-define DB-AWARE no
51 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
53 /* Name of first Frame and/or Browse and/or first Query */
54 &Scoped-define FRAME-NAME F-Main
56 /* External Tables */
57 &Scoped-define EXTERNAL-TABLES ProjectBudget
58 &Scoped-define FIRST-EXTERNAL-TABLE ProjectBudget
61 /* Need to scope the external tables to this procedure */
62 DEFINE QUERY external_tables FOR ProjectBudget.
63 /* Standard List Definitions */
64 &Scoped-Define ENABLED-FIELDS ProjectBudget.AccountCode ~
65 ProjectBudget.Description ProjectBudget.OriginalBudget ~
66 ProjectBudget.EntityType ProjectBudget.EntityCode ~
67 ProjectBudget.EntityAccount ProjectBudget.AllowPosting ~
68 ProjectBudget.HighVolume
69 &Scoped-define ENABLED-TABLES ProjectBudget
70 &Scoped-define FIRST-ENABLED-TABLE ProjectBudget
71 &Scoped-define DISPLAYED-TABLES ProjectBudget
72 &Scoped-define FIRST-DISPLAYED-TABLE ProjectBudget
73 &Scoped-Define ENABLED-OBJECTS cmb_Category RECT-2
74 &Scoped-Define DISPLAYED-FIELDS ProjectBudget.AccountCode ~
75 ProjectBudget.Description ProjectBudget.OriginalBudget ~
76 ProjectBudget.AgreedVariation ProjectBudget.Adjustment ~
77 ProjectBudget.EntityType ProjectBudget.EntityCode ~
78 ProjectBudget.EntityAccount ProjectBudget.UncommittedBudget ~
79 ProjectBudget.CommittedBudget ProjectBudget.AllowPosting ~
80 ProjectBudget.HighVolume
81 &Scoped-Define DISPLAYED-OBJECTS cmb_Category fil_Entity fil_EAccount
83 /* Custom List Definitions */
84 /* ADM-CREATE-FIELDS,ADM-ASSIGN-FIELDS,List-3,List-4,List-5,List-6 */
86 /* _UIB-PREPROCESSOR-BLOCK-END */
87 &ANALYZE-RESUME
90 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" V-table-Win _INLINE
91 /* Actions: ? adm/support/keyedit.w ? ? ? */
92 /* STRUCTURED-DATA
93 <KEY-OBJECT>
94 THIS-PROCEDURE
95 </KEY-OBJECT>
96 <FOREIGN-KEYS>
97 </FOREIGN-KEYS>
98 <EXECUTING-CODE>
99 **************************
100 * Set attributes related to FOREIGN KEYS
102 RUN set-attribute-list (
103 'Keys-Accepted = "",
104 Keys-Supplied = ""':U).
105 /**************************
106 </EXECUTING-CODE> */
108 /* _UIB-CODE-BLOCK-END */
109 &ANALYZE-RESUME
112 /* *********************** Control Definitions ********************** */
115 /* Definitions of the field level widgets */
116 DEFINE VARIABLE cmb_Category AS CHARACTER FORMAT "X(256)":U
117 LABEL "Expense Category"
118 VIEW-AS COMBO-BOX INNER-LINES 15
119 LIST-ITEMS "Item 1"
120 DROP-DOWN-LIST
121 SIZE 48.43 BY 1.05 NO-UNDO.
123 DEFINE VARIABLE fil_EAccount AS CHARACTER FORMAT "X(256)":U
124 VIEW-AS FILL-IN
125 SIZE 48.57 BY 1 NO-UNDO.
127 DEFINE VARIABLE fil_Entity AS CHARACTER FORMAT "X(256)":U
128 VIEW-AS FILL-IN
129 SIZE 48.57 BY 1 NO-UNDO.
131 DEFINE RECTANGLE RECT-2
132 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
133 SIZE 75 BY 11.
136 /* ************************ Frame Definitions *********************** */
138 DEFINE FRAME F-Main
139 ProjectBudget.AccountCode AT ROW 1.5 COL 12.14 COLON-ALIGNED
140 VIEW-AS FILL-IN
141 SIZE 9.14 BY 1
142 ProjectBudget.Description AT ROW 1.5 COL 24 COLON-ALIGNED NO-LABEL
143 VIEW-AS FILL-IN
144 SIZE 48.43 BY 1
145 cmb_Category AT ROW 2.6 COL 24.14 COLON-ALIGNED
146 ProjectBudget.OriginalBudget AT ROW 6.5 COL 24.14 COLON-ALIGNED
147 LABEL "Original Budget" FORMAT "->>>,>>>,>>9.99"
148 VIEW-AS FILL-IN
149 SIZE 16.57 BY 1
150 ProjectBudget.AgreedVariation AT ROW 7.5 COL 24.14 COLON-ALIGNED
151 LABEL "Agreed Variation" FORMAT "->>>,>>>,>>9.99"
152 VIEW-AS FILL-IN
153 SIZE 16.57 BY 1
154 BGCOLOR 16
155 ProjectBudget.Adjustment AT ROW 7.5 COL 55.14 COLON-ALIGNED
156 VIEW-AS FILL-IN
157 SIZE 16.43 BY 1
158 BGCOLOR 16
159 ProjectBudget.EntityType AT ROW 4 COL 12.14 COLON-ALIGNED
160 LABEL "Entity"
161 VIEW-AS FILL-IN
162 SIZE 2.43 BY 1
163 ProjectBudget.EntityCode AT ROW 4 COL 14.43 COLON-ALIGNED NO-LABEL
164 VIEW-AS FILL-IN
165 SIZE 6.72 BY 1
166 fil_Entity AT ROW 4 COL 24.14 COLON-ALIGNED NO-LABEL
167 ProjectBudget.EntityAccount AT ROW 5 COL 12.14 COLON-ALIGNED NO-LABEL
168 VIEW-AS FILL-IN
169 SIZE 9.14 BY 1
170 fil_EAccount AT ROW 5 COL 24.14 COLON-ALIGNED NO-LABEL
171 ProjectBudget.UncommittedBudget AT ROW 10 COL 24.14 COLON-ALIGNED
172 LABEL "Uncommitted Budget"
173 VIEW-AS FILL-IN
174 SIZE 16.43 BY .9
175 BGCOLOR 16
176 ProjectBudget.CommittedBudget AT ROW 9 COL 24.14 COLON-ALIGNED
177 LABEL "Committed Budget" FORMAT "->>>,>>>,>>9.99"
178 VIEW-AS FILL-IN
179 SIZE 16.57 BY 1
180 BGCOLOR 16
181 ProjectBudget.AllowPosting AT ROW 9 COL 51.14
182 LABEL "Allow direct posting"
183 VIEW-AS TOGGLE-BOX
184 SIZE 15.72 BY 1
185 ProjectBudget.HighVolume AT ROW 10 COL 51.14
186 VIEW-AS TOGGLE-BOX
187 SIZE 11.72 BY 1
188 RECT-2 AT ROW 1 COL 1
189 "Entity Account:" VIEW-AS TEXT
190 SIZE 10.86 BY 1 AT ROW 4 COL 3
191 FONT 10
192 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
193 SIDE-LABELS NO-UNDERLINE THREE-D
194 AT COL 1 ROW 1 SCROLLABLE
195 FONT 10.
198 /* *********************** Procedure Settings ************************ */
200 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
201 /* Settings for THIS-PROCEDURE
202 Type: SmartViewer
203 External Tables: TTPL.ProjectBudget
204 Allow: Basic,DB-Fields
205 Frames: 1
206 Add Fields to: EXTERNAL-TABLES
207 Other Settings: PERSISTENT-ONLY COMPILE
210 /* This procedure should always be RUN PERSISTENT. Report the error, */
211 /* then cleanup and return. */
212 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
213 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT.":U
214 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
215 RETURN.
216 END.
218 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
220 /* ************************* Create Window ************************** */
222 &ANALYZE-SUSPEND _CREATE-WINDOW
223 /* DESIGN Window definition (used by the UIB)
224 CREATE WINDOW V-table-Win ASSIGN
225 HEIGHT = 13.25
226 WIDTH = 75.14.
227 /* END WINDOW DEFINITION */
229 &ANALYZE-RESUME
231 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB V-table-Win
232 /* ************************* Included-Libraries *********************** */
234 {src/adm/method/viewer.i}
235 {inc/method/m-mntvwr.i}
237 /* _UIB-CODE-BLOCK-END */
238 &ANALYZE-RESUME
243 /* *********** Runtime Attributes and AppBuilder Settings *********** */
245 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
246 /* SETTINGS FOR WINDOW V-table-Win
247 VISIBLE,,RUN-PERSISTENT */
248 /* SETTINGS FOR FRAME F-Main
249 NOT-VISIBLE Size-to-Fit Custom */
250 ASSIGN
251 FRAME F-Main:SCROLLABLE = FALSE
252 FRAME F-Main:HIDDEN = TRUE.
254 /* SETTINGS FOR FILL-IN ProjectBudget.Adjustment IN FRAME F-Main
255 NO-ENABLE */
256 /* SETTINGS FOR FILL-IN ProjectBudget.AgreedVariation IN FRAME F-Main
257 NO-ENABLE EXP-LABEL EXP-FORMAT */
258 /* SETTINGS FOR TOGGLE-BOX ProjectBudget.AllowPosting IN FRAME F-Main
259 EXP-LABEL */
260 /* SETTINGS FOR FILL-IN ProjectBudget.CommittedBudget IN FRAME F-Main
261 NO-ENABLE EXP-LABEL EXP-FORMAT */
262 /* SETTINGS FOR FILL-IN ProjectBudget.Description IN FRAME F-Main
263 EXP-LABEL */
264 /* SETTINGS FOR FILL-IN ProjectBudget.EntityAccount IN FRAME F-Main
265 EXP-LABEL */
266 /* SETTINGS FOR FILL-IN ProjectBudget.EntityCode IN FRAME F-Main
267 EXP-LABEL */
268 /* SETTINGS FOR FILL-IN ProjectBudget.EntityType IN FRAME F-Main
269 EXP-LABEL */
270 /* SETTINGS FOR FILL-IN fil_EAccount IN FRAME F-Main
271 NO-ENABLE */
272 /* SETTINGS FOR FILL-IN fil_Entity IN FRAME F-Main
273 NO-ENABLE */
274 /* SETTINGS FOR FILL-IN ProjectBudget.OriginalBudget IN FRAME F-Main
275 EXP-LABEL EXP-FORMAT */
276 /* SETTINGS FOR FILL-IN ProjectBudget.UncommittedBudget IN FRAME F-Main
277 NO-ENABLE EXP-LABEL */
278 /* _RUN-TIME-ATTRIBUTES-END */
279 &ANALYZE-RESUME
282 /* Setting information for Queries and Browse Widgets fields */
284 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
285 /* Query rebuild information for FRAME F-Main
286 _Options = "NO-LOCK"
287 _Query is NOT OPENED
288 */ /* FRAME F-Main */
289 &ANALYZE-RESUME
295 /* ************************ Control Triggers ************************ */
297 &Scoped-define SELF-NAME ProjectBudget.AccountCode
298 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ProjectBudget.AccountCode V-table-Win
299 ON LEAVE OF ProjectBudget.AccountCode IN FRAME F-Main /* Account */
301 /* If the given account does not exist then allow the user
302 to specify a description */
304 IF NOT SELF:MODIFIED THEN RETURN.
306 IF CAN-FIND( ChartOfAccount WHERE
307 ChartOfAccount.AccountCode = INPUT {&SELF-NAME} ) THEN
309 {inc/selcde/cdcoa.i "ProjectBudget.Description"}
310 END.
311 ELSE
313 BELL.
314 ProjectBudget.Description:SCREEN-VALUE = "".
315 SELF:MODIFIED = No.
316 IF LAST-EVENT:LABEL = "TAB" THEN
318 APPLY 'ENTRY':U TO ProjectBudget.Description.
319 RETURN NO-APPLY.
320 END.
321 END.
323 END.
325 /* _UIB-CODE-BLOCK-END */
326 &ANALYZE-RESUME
329 &Scoped-define SELF-NAME cmb_Category
330 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_Category V-table-Win
331 ON U1 OF cmb_Category IN FRAME F-Main /* Expense Category */
333 {inc/selcmb/scpxct1.i "ProjectBudget" "ProjectExpenseCategory"}
334 END.
336 /* _UIB-CODE-BLOCK-END */
337 &ANALYZE-RESUME
340 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_Category V-table-Win
341 ON U2 OF cmb_Category IN FRAME F-Main /* Expense Category */
343 {inc/selcmb/scpxct2.i "ProjectBudget" "ProjectExpenseCategory"}
344 END.
346 /* _UIB-CODE-BLOCK-END */
347 &ANALYZE-RESUME
350 &Scoped-define SELF-NAME ProjectBudget.Description
351 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ProjectBudget.Description V-table-Win
352 ON U1 OF ProjectBudget.Description IN FRAME F-Main /* Description */
354 {inc/selfil/sfcoa1.i "ProjectBudget" "AccountCode"}
355 END.
357 /* _UIB-CODE-BLOCK-END */
358 &ANALYZE-RESUME
361 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ProjectBudget.Description V-table-Win
362 ON U2 OF ProjectBudget.Description IN FRAME F-Main /* Description */
364 {inc/selfil/sfcoa2.i "ProjectBudget" "AccountCode"}
365 END.
367 /* _UIB-CODE-BLOCK-END */
368 &ANALYZE-RESUME
371 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ProjectBudget.Description V-table-Win
372 ON U3 OF ProjectBudget.Description IN FRAME F-Main /* Description */
374 {inc/selfil/sfcoa3.i "ProjectBudget" "AccountCode"}
375 END.
377 /* _UIB-CODE-BLOCK-END */
378 &ANALYZE-RESUME
381 &Scoped-define SELF-NAME ProjectBudget.EntityAccount
382 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ProjectBudget.EntityAccount V-table-Win
383 ON LEAVE OF ProjectBudget.EntityAccount IN FRAME F-Main /* Account */
385 IF {&SELF-NAME}:MODIFIED THEN DO:
387 DEF VAR old-val AS CHAR NO-UNDO.
388 DEF VAR curr-val AS CHAR NO-UNDO.
390 DEF BUFFER tmp_ChartOfAccount FOR ChartOfAccount.
392 old-val = ENTRY( 2, {&SELF-NAME}:PRIVATE-DATA ).
393 curr-val = {&SELF-NAME}:SCREEN-VALUE.
395 IF old-val <> curr-val THEN DO WITH FRAME {&FRAME-NAME}:
397 DEF BUFFER tmp_ProjectBudget FOR ProjectBudget.
398 IF (INPUT ProjectBudget.EntityType) = "J" AND CAN-FIND(ProjectBudget WHERE ProjectBudget.ProjectCode = (INPUT ProjectBudget.EntityCode)
399 AND ProjectBudget.AccountCode = INPUT {&SELF-NAME} )
400 THEN DO:
401 FIND FIRST tmp_ProjectBudget NO-LOCK WHERE tmp_ProjectBudget.ProjectCode = (INPUT ProjectBudget.EntityCode)
402 AND tmp_ProjectBudget.AccountCode = INPUT {&SELF-NAME} NO-ERROR.
403 IF AVAILABLE(tmp_ProjectBudget) THEN DO:
404 fil_EAccount = tmp_ProjectBudget.Description.
405 DISPLAY fil_EAccount.
406 END.
407 END.
408 ELSE
409 FIND FIRST tmp_ChartOfAccount WHERE tmp_ChartOfAccount.AccountCode = INPUT {&SELF-NAME}
410 NO-LOCK NO-ERROR.
412 IF NOT AVAILABLE( tmp_ChartOfAccount )
413 AND NOT AVAILABLE( tmp_ProjectBudget )
414 THEN DO:
415 DEF VAR old-id AS ROWID NO-UNDO.
416 old-id = TO-ROWID( ENTRY( 1, {&SELF-NAME}:PRIVATE-DATA ) ).
418 MESSAGE "There is no ChartOfAccount or ProjectBudget available with code " INPUT {&SELF-NAME}
419 VIEW-AS ALERT-BOX ERROR.
421 FIND FIRST tmp_ChartOfAccount WHERE ROWID( tmp_ChartOfAccount ) = old-id NO-LOCK NO-ERROR.
423 IF AVAILABLE tmp_ChartOfAccount THEN
424 DISPLAY tmp_ChartOfAccount.AccountCode @ {&SELF-NAME}.
425 ELSE
426 DISPLAY {&SELF-NAME}.
428 END.
429 ELSE DO:
431 DEF VAR spd AS CHAR NO-UNDO.
432 spd = {&SELF-NAME}:PRIVATE-DATA.
433 ENTRY( 1, spd ) = STRING( ROWID( tmp_ChartOfAccount ) ).
434 ENTRY( 2, spd ) = {&SELF-NAME}:SCREEN-VALUE.
435 {&SELF-NAME}:PRIVATE-DATA = spd.
437 fil_EAccount:PRIVATE-DATA = STRING( ROWID( tmp_ChartOfAccount ) ).
439 DEF VAR enabled AS LOGI NO-UNDO.
440 enabled = fil_EAccount:SENSITIVE.
442 fil_EAccount:SENSITIVE = TRUE.
443 APPLY 'U2':U TO fil_EAccount.
444 fil_EAccount:SENSITIVE = enabled.
446 /* Tab past the select button for valid codes if tab was pressed*/
447 IF LOOKUP( LAST-EVENT:LABEL, 'TAB,ENTER':U ) <> 0 THEN DO:
448 DEF VAR next-tab AS HANDLE NO-UNDO.
450 next-tab = {&SELF-NAME}:NEXT-TAB-ITEM.
451 DO WHILE NOT next-tab:SENSITIVE:
452 next-tab = next-tab:NEXT-TAB-ITEM.
453 END.
455 IF VALID-HANDLE( next-tab ) AND next-tab:TYPE = 'BUTTON':U
456 AND next-tab:DYNAMIC THEN
457 DO:
458 APPLY 'TAB':U TO next-tab.
459 RETURN NO-APPLY.
460 END.
461 END.
462 END.
463 END.
465 END. /* Of check if modified */
466 END.
468 /* _UIB-CODE-BLOCK-END */
469 &ANALYZE-RESUME
472 &Scoped-define SELF-NAME ProjectBudget.EntityCode
473 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ProjectBudget.EntityCode V-table-Win
474 ON LEAVE OF ProjectBudget.EntityCode IN FRAME F-Main /* Code */
476 CASE ProjectBudget.EntityType:SCREEN-VALUE:
477 WHEN 'P' THEN DO: {inc/selcde/cdpro.i "fil_Entity"} END.
478 WHEN 'L' THEN DO: {inc/selcde/cdcmp.i "fil_Entity"} END.
479 WHEN 'J' THEN DO: {inc/selcde/cdprj.i "fil_Entity"} END.
480 END CASE.
481 END.
483 /* _UIB-CODE-BLOCK-END */
484 &ANALYZE-RESUME
487 &Scoped-define SELF-NAME ProjectBudget.EntityType
488 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ProjectBudget.EntityType V-table-Win
489 ON ANY-PRINTABLE OF ProjectBudget.EntityType IN FRAME F-Main /* Entity */
491 APPLY CAPS( CHR( LASTKEY ) ) TO SELF.
492 RETURN NO-APPLY.
493 END.
495 /* _UIB-CODE-BLOCK-END */
496 &ANALYZE-RESUME
499 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ProjectBudget.EntityType V-table-Win
500 ON LEAVE OF ProjectBudget.EntityType IN FRAME F-Main /* Entity */
502 IF SELF:MODIFIED THEN
504 RUN verify-type.
505 IF RETURN-VALUE = "FAIL" THEN RETURN NO-APPLY.
506 END.
507 END.
509 /* _UIB-CODE-BLOCK-END */
510 &ANALYZE-RESUME
513 &Scoped-define SELF-NAME fil_EAccount
514 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_EAccount V-table-Win
515 ON U1 OF fil_EAccount IN FRAME F-Main
517 DO WITH FRAME {&FRAME-NAME}:
518 IF INPUT ProjectBudget.EntityType = "J" THEN DO:
519 {inc/selfil/sfpbj1.i "ProjectBudget" "EntityAccount"}
520 END.
521 ELSE DO:
522 {inc/selfil/sfcoa1.i "ProjectBudget" "EntityAccount"}
523 END.
524 END.
525 END.
527 /* _UIB-CODE-BLOCK-END */
528 &ANALYZE-RESUME
531 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_EAccount V-table-Win
532 ON U2 OF fil_EAccount IN FRAME F-Main
534 IF INPUT ProjectBudget.EntityType = "J" THEN DO:
535 {inc/selfil/sfpbj2.i "ProjectBudget" "EntityAccount"}
536 END.
537 ELSE DO:
538 {inc/selfil/sfcoa2.i "ProjectBudget" "EntityAccount"}
539 END.
540 END.
542 /* _UIB-CODE-BLOCK-END */
543 &ANALYZE-RESUME
546 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_EAccount V-table-Win
547 ON U3 OF fil_EAccount IN FRAME F-Main
549 IF INPUT ProjectBudget.EntityType = "J" THEN DO:
550 {inc/selfil/sfpbj3.i "ProjectBudget" "EntityAccount"}
551 END.
552 ELSE DO:
553 {inc/selfil/sfcoa3.i "ProjectBudget" "EntityAccount"}
554 END.
555 END.
557 /* _UIB-CODE-BLOCK-END */
558 &ANALYZE-RESUME
561 &Scoped-define SELF-NAME fil_Entity
562 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Entity V-table-Win
563 ON U1 OF fil_Entity IN FRAME F-Main
565 CASE ProjectBudget.EntityType:SCREEN-VALUE:
566 WHEN 'P' THEN DO: {inc/selfil/sfpro1.i "ProjectBudget" "EntityCode"} END.
567 WHEN 'L' THEN DO: {inc/selfil/sfcmp1.i "ProjectBudget" "EntityCode"} END.
568 WHEN 'J' THEN DO: {inc/selfil/sfprj1.i "ProjectBudget" "EntityCode"} END.
569 END CASE.
570 END.
572 /* _UIB-CODE-BLOCK-END */
573 &ANALYZE-RESUME
576 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Entity V-table-Win
577 ON U2 OF fil_Entity IN FRAME F-Main
579 CASE ProjectBudget.EntityType:SCREEN-VALUE:
580 WHEN 'P' THEN DO: {inc/selfil/sfpro2.i "ProjectBudget" "EntityCode"} END.
581 WHEN 'L' THEN DO: {inc/selfil/sfcmp2.i "ProjectBudget" "EntityCode"} END.
582 WHEN 'J' THEN DO: {inc/selfil/sfprj1.i "ProjectBudget" "EntityCode"} END.
583 END CASE.
584 END.
586 /* _UIB-CODE-BLOCK-END */
587 &ANALYZE-RESUME
590 &UNDEFINE SELF-NAME
592 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK V-table-Win
595 /* *************************** Main Block *************************** */
597 &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
598 RUN dispatch IN THIS-PROCEDURE ('initialize':U).
599 &ENDIF
601 /************************ INTERNAL PROCEDURES ********************/
603 /* _UIB-CODE-BLOCK-END */
604 &ANALYZE-RESUME
607 /* ********************** Internal Procedures *********************** */
609 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available V-table-Win _ADM-ROW-AVAILABLE
610 PROCEDURE adm-row-available :
611 /*------------------------------------------------------------------------------
612 Purpose: Dispatched to this procedure when the Record-
613 Source has a new row available. This procedure
614 tries to get the new row (or foriegn keys) from
615 the Record-Source and process it.
616 Parameters: <none>
617 ------------------------------------------------------------------------------*/
619 /* Define variables needed by this internal procedure. */
620 {src/adm/template/row-head.i}
622 /* Create a list of all the tables that we need to get. */
623 {src/adm/template/row-list.i "ProjectBudget"}
625 /* Get the record ROWID's from the RECORD-SOURCE. */
626 {src/adm/template/row-get.i}
628 /* FIND each record specified by the RECORD-SOURCE. */
629 {src/adm/template/row-find.i "ProjectBudget"}
631 /* Process the newly available records (i.e. display fields,
632 open queries, and/or pass records on to any RECORD-TARGETS). */
633 {src/adm/template/row-end.i}
635 END PROCEDURE.
637 /* _UIB-CODE-BLOCK-END */
638 &ANALYZE-RESUME
640 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cancel-changes V-table-Win
641 PROCEDURE cancel-changes :
642 /*------------------------------------------------------------------------------
643 Purpose:
644 Parameters: <none>
645 Notes:
646 ------------------------------------------------------------------------------*/
648 RUN notify( 'hide, CONTAINER-SOURCE':U ).
649 IF mode = "Add" THEN RUN delete-budget. ELSE RUN check-modified( "CLEAR" ).
650 RUN dispatch( 'exit':U ).
652 END PROCEDURE.
654 /* _UIB-CODE-BLOCK-END */
655 &ANALYZE-RESUME
657 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE confirm-changes V-table-Win
658 PROCEDURE confirm-changes :
659 /*------------------------------------------------------------------------------
660 Purpose:
661 Parameters: <none>
662 Notes:
663 ------------------------------------------------------------------------------*/
665 RUN verify-budget.
666 IF RETURN-VALUE = "FAIL" THEN RETURN.
668 RUN notify( 'hide, CONTAINER-SOURCE':U ).
669 RUN dispatch( 'update-record':U ).
670 IF mode = "Add" THEN RUN notify( 'open-query, RECORD-SORUCE':U ).
671 RUN dispatch( 'exit':U ).
673 END PROCEDURE.
675 /* _UIB-CODE-BLOCK-END */
676 &ANALYZE-RESUME
678 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE delete-budget V-table-Win
679 PROCEDURE delete-budget :
680 /*------------------------------------------------------------------------------
681 Purpose:
682 Parameters: <none>
683 Notes:
684 ------------------------------------------------------------------------------*/
686 FIND CURRENT ProjectBudget EXCLUSIVE-LOCK NO-ERROR.
687 IF AVAILABLE ProjectBudget THEN DELETE ProjectBudget.
689 END PROCEDURE.
691 /* _UIB-CODE-BLOCK-END */
692 &ANALYZE-RESUME
694 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI V-table-Win _DEFAULT-DISABLE
695 PROCEDURE disable_UI :
696 /*------------------------------------------------------------------------------
697 Purpose: DISABLE the User Interface
698 Parameters: <none>
699 Notes: Here we clean-up the user-interface by deleting
700 dynamic widgets we have created and/or hide
701 frames. This procedure is usually called when
702 we are ready to "clean-up" after running.
703 ------------------------------------------------------------------------------*/
704 /* Hide all frames. */
705 HIDE FRAME F-Main.
706 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
707 END PROCEDURE.
709 /* _UIB-CODE-BLOCK-END */
710 &ANALYZE-RESUME
712 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-project V-table-Win
713 PROCEDURE get-project :
714 /*------------------------------------------------------------------------------
715 Purpose:
716 Parameters: <none>
717 Notes:
718 ------------------------------------------------------------------------------*/
720 DEF VAR c-recsrc AS CHAR NO-UNDO.
721 DEF VAR rowid-list AS CHAR NO-UNDO.
723 RUN get-link-handle IN adm-broker-hdl( THIS-PROCEDURE, 'RECORD-SOURCE':U, OUTPUT c-recsrc ).
724 RUN send-records IN WIDGET-HANDLE( c-recsrc ) ( "Project", OUTPUT rowid-list ).
725 FIND Project WHERE ROWID( Project ) = TO-ROWID( rowid-list ) NO-LOCK NO-ERROR.
727 END PROCEDURE.
729 /* _UIB-CODE-BLOCK-END */
730 &ANALYZE-RESUME
732 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-display-fields V-table-Win
733 PROCEDURE inst-display-fields :
734 /*------------------------------------------------------------------------------
735 Purpose:
736 Parameters: <none>
737 Notes:
738 ------------------------------------------------------------------------------*/
740 RUN update-entity-button.
741 RUN update-account-button.
743 END PROCEDURE.
745 /* _UIB-CODE-BLOCK-END */
746 &ANALYZE-RESUME
748 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-enable-fields V-table-Win
749 PROCEDURE inst-enable-fields :
750 /*------------------------------------------------------------------------------
751 Purpose:
752 Parameters: <none>
753 Notes:
754 ------------------------------------------------------------------------------*/
756 DO WITH FRAME {&FRAME-NAME}:
758 DEF VAR default-budget AS LOGI NO-UNDO.
760 /* Check to see if this is the default budget */
761 FIND Project WHERE Project.ProjectCode = ProjectBudget.ProjectCode
762 NO-LOCK NO-ERROR.
763 default-budget = Project.EntityAccount = ProjectBudget.AccountCode.
765 /* ProjectBudget.AccountCode:SENSITIVE = mode = "Add".
766 ProjectBudget.EntityType:SENSITIVE = mode = "Add".
767 ProjectBudget.EntityCode:SENSITIVE = mode = "Add".
768 ProjectBudget.EntityAccount:SENSITIVE = mode = "Add". */
770 /* RUN set-link-attributes IN sys-mgr(
771 THIS-PROCEDURE,
772 STRING( ProjectBudget.Description:HANDLE ),
773 "HIDDEN = " + IF mode = "Add" THEN "No" ELSE "Yes" ). */
775 /* RUN set-link-attributes IN sys-mgr(
776 THIS-PROCEDURE,
777 STRING( fil_Entity:HANDLE ),
778 "HIDDEN = " + IF mode = "Add" THEN "No" ELSE "Yes" ). */
780 /* RUN set-link-attributes IN sys-mgr(
781 THIS-PROCEDURE,
782 STRING( fil_EAccount:HANDLE ),
783 "HIDDEN = " + IF mode = "Add" THEN "No" ELSE "Yes" ). */
785 ProjectBudget.Adjustment:SENSITIVE = NOT default-budget.
787 END.
789 END PROCEDURE.
791 /* _UIB-CODE-BLOCK-END */
792 &ANALYZE-RESUME
794 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-initialize V-table-Win
795 PROCEDURE inst-initialize :
796 /*------------------------------------------------------------------------------
797 Purpose:
798 Parameters: <none>
799 Notes:
800 ------------------------------------------------------------------------------*/
802 DEF VAR can-edit AS LOGI NO-UNDO.
804 can-edit = AVAILABLE Project AND NOT Project.BudgetsFrozen.
806 IF mode = "Add" THEN
808 IF can-edit THEN
810 have-records = Yes.
811 RUN dispatch( 'add-record':U ).
812 END.
813 ELSE
815 MESSAGE
816 "All budget changes have been frozen for this project!" SKIP
817 "The add has been cancelled."
818 VIEW-AS ALERT-BOX ERROR TITLE "Add Error".
819 RUN set-attribute-list ( 'mode = Maintain' ).
820 RUN dispatch( 'disable-fields':U ).
821 END.
822 END.
823 ELSE RUN dispatch( IF can-edit THEN 'enable-fields' ELSE 'disable-fields':U ).
825 END PROCEDURE.
827 /* _UIB-CODE-BLOCK-END */
828 &ANALYZE-RESUME
830 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE override-add-record V-table-Win
831 PROCEDURE override-add-record :
832 /*------------------------------------------------------------------------------
833 Purpose:
834 ------------------------------------------------------------------------------*/
835 DEF VAR account-default AS DEC NO-UNDO INITIAL 1.
837 IF NOT AVAILABLE Project THEN
839 RUN dispatch( 'disable-fields':U ).
840 RETURN.
841 END.
843 FIND LAST ProjectBudget OF Project WHERE ProjectBudget.AccountCode < 100 NO-LOCK NO-ERROR.
844 IF AVAILABLE(ProjectBudget) THEN account-default = INT(ProjectBudget.AccountCode) + 1.
847 CREATE ProjectBudget.
848 ASSIGN
849 ProjectBudget.ProjectCode = Project.ProjectCode
850 ProjectBudget.AccountCode = account-default
851 ProjectBudget.EntityType = Project.EntityType
852 ProjectBudget.EntityCode = Project.EntityCode
853 ProjectBudget.EntityAccount = Project.EntityAccount.
855 RUN dispatch( 'enable-fields':U ).
856 RUN dispatch( 'display-fields':U ).
858 CURRENT-WINDOW:TITLE = "Adding a new Budget to Project " + STRING( Project.ProjectCode ).
860 END PROCEDURE.
862 /* _UIB-CODE-BLOCK-END */
863 &ANALYZE-RESUME
865 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-destroy V-table-Win
866 PROCEDURE pre-destroy :
867 /*------------------------------------------------------------------------------
868 Purpose:
869 Parameters: <none>
870 Notes:
871 ------------------------------------------------------------------------------*/
873 IF LAST-EVENT:FUNCTION = "WINDOW-CLOSE":U THEN RUN cancel-changes.
875 END PROCEDURE.
877 /* _UIB-CODE-BLOCK-END */
878 &ANALYZE-RESUME
880 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-initialize V-table-Win
881 PROCEDURE pre-initialize :
882 /*------------------------------------------------------------------------------
883 Purpose:
884 Parameters: <none>
885 Notes:
886 ------------------------------------------------------------------------------*/
888 RUN get-project.
890 END PROCEDURE.
892 /* _UIB-CODE-BLOCK-END */
893 &ANALYZE-RESUME
895 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records V-table-Win _ADM-SEND-RECORDS
896 PROCEDURE send-records :
897 /*------------------------------------------------------------------------------
898 Purpose: Send record ROWID's for all tables used by
899 this file.
900 Parameters: see template/snd-head.i
901 ------------------------------------------------------------------------------*/
903 /* Define variables needed by this internal procedure. */
904 {src/adm/template/snd-head.i}
906 /* For each requested table, put it's ROWID in the output list. */
907 {src/adm/template/snd-list.i "ProjectBudget"}
909 /* Deal with any unexpected table requests before closing. */
910 {src/adm/template/snd-end.i}
912 END PROCEDURE.
914 /* _UIB-CODE-BLOCK-END */
915 &ANALYZE-RESUME
917 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed V-table-Win
918 PROCEDURE state-changed :
919 /* -----------------------------------------------------------
920 Purpose:
921 Parameters: <none>
922 Notes:
923 -------------------------------------------------------------*/
924 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
925 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
927 CASE p-state:
928 /* Object instance CASEs can go here to replace standard behavior
929 or add new cases. */
930 {src/adm/template/vstates.i}
931 END CASE.
932 END PROCEDURE.
934 /* _UIB-CODE-BLOCK-END */
935 &ANALYZE-RESUME
937 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE type-changed V-table-Win
938 PROCEDURE type-changed :
939 /*------------------------------------------------------------------------------
940 Purpose:
941 Parameters: <none>
942 Notes:
943 ------------------------------------------------------------------------------*/
945 DO WITH FRAME {&FRAME-NAME}:
947 /* Reset the entity */
948 ProjectBudget.EntityCode:PRIVATE-DATA = ",".
949 ProjectBudget.EntityCode:SCREEN-VALUE = STRING( 0 ).
950 ProjectBudget.EntityCode:MODIFIED = No.
951 fil_Entity:PRIVATE-DATA = "".
952 fil_Entity:SCREEN-VALUE = "".
954 /* Reset the entity account */
955 ProjectBudget.EntityAccount:PRIVATE-DATA = ",".
956 ProjectBudget.EntityAccount:SCREEN-VALUE = STRING( 0.00 ).
957 ProjectBudget.EntityAccount:MODIFIED = No.
958 fil_EAccount:PRIVATE-DATA = "".
959 fil_EAccount:SCREEN-VALUE = "".
961 RUN update-entity-button.
962 RUN update-account-button.
964 END.
966 END PROCEDURE.
968 /* _UIB-CODE-BLOCK-END */
969 &ANALYZE-RESUME
971 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-account-button V-table-Win
972 PROCEDURE update-account-button :
973 /*------------------------------------------------------------------------------
974 Purpose:
975 Parameters: <none>
976 Notes:
977 ------------------------------------------------------------------------------*/
979 DO WITH FRAME {&FRAME-NAME}:
981 DEF VAR account-group AS CHAR NO-UNDO.
983 CASE INPUT ProjectBudget.EntityType:
984 WHEN 'P' THEN account-group = 'PROPEX'.
985 WHEN 'L' THEN account-group = 'ADMIN '.
986 WHEN 'J' THEN account-group = 'ADMIN '.
987 END CASE.
989 IF account-group <> "" THEN
991 FIND AccountGroup WHERE AccountGroup.AccountGroupCode = account-group
992 NO-LOCK NO-ERROR.
993 IF NOT AVAILABLE AccountGroup THEN RETURN.
995 RUN set-link-attributes IN sys-mgr (
996 THIS-PROCEDURE,
997 STRING( fil_EAccount:HANDLE ),
998 "FUNCTION = " +
999 "FilterBy-Case = " + account-group + " - " + AccountGroup.Name ).
1000 END.
1002 END.
1004 END PROCEDURE.
1006 /* _UIB-CODE-BLOCK-END */
1007 &ANALYZE-RESUME
1009 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-entity-button V-table-Win
1010 PROCEDURE update-entity-button :
1011 /*------------------------------------------------------------------------------
1012 Purpose:
1013 Parameters: <none>
1014 Notes:
1015 ------------------------------------------------------------------------------*/
1017 DO WITH FRAME {&FRAME-NAME}:
1019 DEF VAR node-name AS CHAR NO-UNDO.
1020 DEF VAR vwr-name AS CHAR NO-UNDO.
1021 DEF VAR filter-panel AS CHAR NO-UNDO.
1022 DEF VAR sort-panel AS CHAR NO-UNDO.
1024 FIND EntityType WHERE EntityType.EntityType = INPUT ProjectBudget.EntityType
1025 NO-LOCK NO-ERROR.
1026 ProjectBudget.EntityType:LABEL = IF AVAILABLE EntityType THEN
1027 EntityType.Description ELSE "Entity".
1029 CASE INPUT ProjectBudget.EntityType:
1030 WHEN 'P' THEN ASSIGN
1031 node-name = 'w-selpro' vwr-name = 'b-selpro'
1032 filter-panel = "Yes" sort-panel = "Yes".
1033 WHEN 'L' THEN ASSIGN
1034 node-name = 'w-selcmp' vwr-name = 'b-selcmp'
1035 filter-panel = "No" sort-panel = "Yes".
1036 WHEN 'J' THEN ASSIGN
1037 node-name = 'w-selprj' vwr-name = 'b-selprj'
1038 filter-panel = "No" sort-panel = "Yes".
1039 END CASE.
1041 RUN set-link-attributes IN sys-mgr(
1042 THIS-PROCEDURE,
1043 STRING( fil_Entity:HANDLE ),
1044 "TARGET = " + node-name + "," +
1045 "VIEWER = " + vwr-name + "," +
1046 "FILTER-PANEL = " + filter-panel + "," +
1047 "SORT-PANEL = " + sort-panel ).
1049 END.
1051 END PROCEDURE.
1053 /* _UIB-CODE-BLOCK-END */
1054 &ANALYZE-RESUME
1056 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-mode V-table-Win
1057 PROCEDURE use-mode :
1058 /*------------------------------------------------------------------------------
1059 Purpose:
1060 Parameters: <none>
1061 Notes:
1062 ------------------------------------------------------------------------------*/
1063 DEF INPUT PARAMETER new-mode AS CHAR NO-UNDO.
1064 mode = new-mode.
1066 END PROCEDURE.
1068 /* _UIB-CODE-BLOCK-END */
1069 &ANALYZE-RESUME
1071 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-budget V-table-Win
1072 PROCEDURE verify-budget :
1073 /*------------------------------------------------------------------------------
1074 Purpose:
1075 Parameters: <none>
1076 Notes:
1077 ------------------------------------------------------------------------------*/
1079 DO WITH FRAME {&FRAME-NAME}:
1081 DEF BUFFER OtherBudget FOR ProjectBudget.
1083 IF NOT ((INPUT ProjectBudget.EntityType = "J") AND CAN-FIND( OtherBudget WHERE OtherBudget.ProjectCode = INPUT ProjectBudget.EntityCode
1084 AND OtherBudget.AccountCode = INPUT ProjectBudget.EntityAccount))
1085 AND NOT ((INPUT ProjectBudget.EntityType <> "J") AND CAN-FIND(ChartOfAccount WHERE ChartOfAccount.AccountCode = INPUT ProjectBudget.EntityAccount))
1086 THEN DO:
1087 MESSAGE "You must enter an account for this project"
1088 VIEW-AS ALERT-BOX ERROR TITLE "No Account Selected".
1089 APPLY 'ENTRY':U TO ProjectBudget.EntityAccount.
1090 RETURN "FAIL".
1091 END.
1093 IF CAN-FIND( OtherBudget WHERE
1094 OtherBudget.ProjectCode = Project.ProjectCode AND
1095 OtherBudget.AccountCode = INPUT ProjectBudget.AccountCode AND
1096 ROWID( OtherBudget ) <> ROWID( ProjectBudget ) ) THEN
1098 MESSAGE
1099 "Another budget already exists for project " + STRING( Project.ProjectCode ) SKIP
1100 "and account" ProjectBudget.AccountCode:SCREEN-VALUE + "." SKIP(1)
1101 "Please change the account code."
1102 VIEW-AS ALERT-BOX ERROR TITLE "Duplicate budget".
1103 APPLY 'ENTRY':U TO ProjectBudget.AccountCode.
1104 RETURN "FAIL".
1105 END.
1107 IF fil_Entity:SCREEN-VALUE = "" THEN
1109 MESSAGE
1110 "You must select a" ProjectBudget.EntityType:LABEL "for this" SKIP
1111 "Project Budget"
1112 VIEW-AS ALERT-BOX ERROR TITLE "No " + ProjectBudget.EntityType:LABEL + " selected".
1113 APPLY 'ENTRY' TO ProjectBudget.EntityType.
1114 RETURN "FAIL".
1115 END.
1117 END.
1119 END PROCEDURE.
1121 /* _UIB-CODE-BLOCK-END */
1122 &ANALYZE-RESUME
1124 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-type V-table-Win
1125 PROCEDURE verify-type :
1126 /*------------------------------------------------------------------------------
1127 Purpose:
1128 Parameters: <none>
1129 Notes:
1130 ------------------------------------------------------------------------------*/
1132 DO WITH FRAME {&FRAME-NAME}:
1134 IF LOOKUP( INPUT ProjectBudget.EntityType, "P,L,J" ) = 0 THEN
1135 RETURN "FAIL".
1136 RUN type-changed.
1137 ProjectBudget.EntityType:MODIFIED = No.
1139 END.
1141 END PROCEDURE.
1143 /* _UIB-CODE-BLOCK-END */
1144 &ANALYZE-RESUME