Really, this should be it, for the passing income.
[capital-apms-progress.git] / vwr / mnt / v-order.w
blob7bb52aebfa3ce34eefe463cffc04be2b87d40a4f
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 /*------------------------------------------------------------------------
9 ------------------------------------------------------------------------*/
11 CREATE WIDGET-POOL.
13 /* *************************** Definitions ************************** */
15 /* Parameters Definitions --- */
17 /* Local Variable Definitions --- */
19 DEF VAR mode AS CHAR NO-UNDO.
20 DEF VAR prev-amount AS DEC NO-UNDO.
21 DEF VAR pdf-support AS LOGICAL INIT YES NO-UNDO.
22 DEF VAR pdf-printing AS LOGICAL INIT NO NO-UNDO.
24 {inc/ofc-this.i}
25 {inc/ofc-set.i "Project-Groups-Property" "property-groups"}
26 IF NOT AVAILABLE(OfficeSetting) THEN property-groups = "PROPEX,TENEX,OWNEX".
27 {inc/ofc-set.i "Project-Groups-Company" "company-groups"}
28 IF NOT AVAILABLE(OfficeSetting) THEN company-groups = "ADMIN".
30 /* Determine if PDF printing is supported */
31 {inc/ofc-set.i "PDF-Output-Directory" "pdf-output-directory"}
32 IF NOT AVAILABLE(OfficeSetting) THEN
33 pdf-support = NO.
35 {inc/ofc-set.i "Company-Order-Approvers" "company-order-approvers"}
36 IF NOT AVAILABLE(OfficeSetting) THEN company-order-approvers = "".
37 DEF VAR company-approver1 AS CHAR NO-UNDO INITIAL "".
38 DEF VAR company-approver2 AS CHAR NO-UNDO INITIAL "".
39 company-approver1 = ENTRY( 1, company-order-approvers ).
40 IF NUM-ENTRIES( company-order-approvers) > 1 THEN
41 company-approver2 = ENTRY( 2, company-order-approvers ).
43 DEF VAR entity-type AS CHAR NO-UNDO INITIAL "J".
44 DEF VAR entity-code AS INT NO-UNDO.
46 /* _UIB-CODE-BLOCK-END */
47 &ANALYZE-RESUME
50 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
52 /* ******************** Preprocessor Definitions ******************** */
54 &Scoped-define PROCEDURE-TYPE SmartViewer
55 &Scoped-define DB-AWARE no
57 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
59 /* Name of first Frame and/or Browse and/or first Query */
60 &Scoped-define FRAME-NAME F-Main
62 /* External Tables */
63 &Scoped-define EXTERNAL-TABLES Order
64 &Scoped-define FIRST-EXTERNAL-TABLE Order
67 /* Need to scope the external tables to this procedure */
68 DEFINE QUERY external_tables FOR Order.
69 /* Standard List Definitions */
70 &Scoped-Define ENABLED-FIELDS Order.EntityCode Order.OrderCode ~
71 Order.OrderDate Order.FirstApprover Order.SecondApprover Order.CreditorCode ~
72 Order.OrderAmount Order.QuotedAmount Order.ApprovedAmount Order.TaxAmount ~
73 Order.Description Order.OverridePaid
74 &Scoped-define ENABLED-TABLES Order
75 &Scoped-define FIRST-ENABLED-TABLE Order
76 &Scoped-define DISPLAYED-TABLES Order
77 &Scoped-define FIRST-DISPLAYED-TABLE Order
78 &Scoped-Define ENABLED-OBJECTS cmb_Account BtnCalculate tgl_set_paid ~
79 tgl_supplier fil_copies RECT-3 RECT-4
80 &Scoped-Define DISPLAYED-FIELDS Order.EntityType Order.EntityCode ~
81 Order.OrderCode Order.OrderDate Order.FirstApprover Order.SecondApprover ~
82 Order.CreditorCode Order.OrderAmount Order.QuotedAmount ~
83 Order.ApprovedAmount Order.TaxAmount Order.Description Order.OverridePaid
84 &Scoped-Define DISPLAYED-OBJECTS fil_EntityName cmb_Account fil_Approver1 ~
85 fil_InBudget-1 fil_OverBudget-1 fil_Approver2 fil_InBudget-2 ~
86 fil_OverBudget-2 fil_Creditor fil_YTD-Spent fil_Wait-Appvl fil_OS-Orders ~
87 fil_Total-Committed fil_YTD-Budget fil_FY-Budget tgl_set_paid tgl_supplier ~
88 fil_copies
90 /* Custom List Definitions */
91 /* ADM-CREATE-FIELDS,ADM-ASSIGN-FIELDS,List-3,List-4,List-5,List-6 */
93 /* _UIB-PREPROCESSOR-BLOCK-END */
94 &ANALYZE-RESUME
97 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" V-table-Win _INLINE
98 /* Actions: ? adm/support/keyedit.w ? ? ? */
99 /* STRUCTURED-DATA
100 <KEY-OBJECT>
101 THIS-PROCEDURE
102 </KEY-OBJECT>
103 <FOREIGN-KEYS>
104 PropertyCode||y|TTPL.Order.EntityCode
105 ProjectCode||y|TTPL.Order.EntityCode
106 OrderCode||y|TTPL.Order.OrderCode
107 </FOREIGN-KEYS>
108 <EXECUTING-CODE>
109 **************************
110 * Set attributes related to FOREIGN KEYS
112 RUN set-attribute-list (
113 'Keys-Accepted = ,
114 Keys-Supplied = "PropertyCode,ProjectCode,OrderCode"':U).
115 /**************************
116 </EXECUTING-CODE> */
117 /* _UIB-CODE-BLOCK-END */
118 &ANALYZE-RESUME
121 /* *********************** Control Definitions ********************** */
124 /* Definitions of the field level widgets */
125 DEFINE BUTTON BtnCalculate
126 LABEL "&Calculate"
127 SIZE 9 BY .75
128 BGCOLOR 8 .
130 DEFINE VARIABLE cmb_Account AS CHARACTER FORMAT "X(256)":U
131 LABEL "Account"
132 VIEW-AS COMBO-BOX INNER-LINES 20
133 DROP-DOWN-LIST
134 SIZE 65.72 BY 1 NO-UNDO.
136 DEFINE VARIABLE fil_Approver1 AS CHARACTER FORMAT "X(256)":U
137 VIEW-AS FILL-IN
138 SIZE 24 BY 1 NO-UNDO.
140 DEFINE VARIABLE fil_Approver2 AS CHARACTER FORMAT "X(256)":U
141 VIEW-AS FILL-IN
142 SIZE 24 BY 1 NO-UNDO.
144 DEFINE VARIABLE fil_copies AS INTEGER FORMAT "9":U INITIAL 0
145 VIEW-AS FILL-IN
146 SIZE 2.57 BY .8 NO-UNDO.
148 DEFINE VARIABLE fil_Creditor AS CHARACTER FORMAT "X(256)":U
149 VIEW-AS FILL-IN
150 SIZE 56.57 BY 1 NO-UNDO.
152 DEFINE VARIABLE fil_EntityName AS CHARACTER FORMAT "X(256)":U
153 VIEW-AS FILL-IN
154 SIZE 56.57 BY 1 NO-UNDO.
156 DEFINE VARIABLE fil_FY-Budget AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U INITIAL 0
157 LABEL "F/Y Budget"
158 VIEW-AS FILL-IN
159 SIZE 15.43 BY 1.05
160 FONT 8 NO-UNDO.
162 DEFINE VARIABLE fil_InBudget-1 AS DECIMAL FORMAT "->,>>>,>>9.99":U INITIAL 0
163 LABEL "In budget"
164 VIEW-AS FILL-IN
165 SIZE 10.29 BY 1 NO-UNDO.
167 DEFINE VARIABLE fil_InBudget-2 AS DECIMAL FORMAT "->,>>>,>>9.99":U INITIAL 0
168 LABEL "In budget"
169 VIEW-AS FILL-IN
170 SIZE 10.29 BY 1 NO-UNDO.
172 DEFINE VARIABLE fil_OS-Orders AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U INITIAL 0
173 LABEL "O/S Orders"
174 VIEW-AS FILL-IN
175 SIZE 15.43 BY 1.05
176 FONT 8 NO-UNDO.
178 DEFINE VARIABLE fil_OverBudget-1 AS DECIMAL FORMAT "->,>>>,>>9.99":U INITIAL 0
179 LABEL "Over"
180 VIEW-AS FILL-IN
181 SIZE 10.29 BY 1 NO-UNDO.
183 DEFINE VARIABLE fil_OverBudget-2 AS DECIMAL FORMAT "->,>>>,>>9.99":U INITIAL 0
184 LABEL "Over"
185 VIEW-AS FILL-IN
186 SIZE 10.29 BY 1 NO-UNDO.
188 DEFINE VARIABLE fil_Total-Committed AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U INITIAL 0
189 LABEL "Total"
190 VIEW-AS FILL-IN
191 SIZE 15.43 BY 1.05
192 FONT 8 NO-UNDO.
194 DEFINE VARIABLE fil_Wait-Appvl AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U INITIAL 0
195 LABEL "Waiting appvl"
196 VIEW-AS FILL-IN
197 SIZE 15.43 BY 1.05
198 FONT 8 NO-UNDO.
200 DEFINE VARIABLE fil_YTD-Budget AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U INITIAL 0
201 LABEL "YTD Budget"
202 VIEW-AS FILL-IN
203 SIZE 15.43 BY 1.05
204 FONT 8 NO-UNDO.
206 DEFINE VARIABLE fil_YTD-Spent AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U INITIAL 0
207 LABEL "YTD spent"
208 VIEW-AS FILL-IN
209 SIZE 15.43 BY 1.05
210 FONT 8 NO-UNDO.
212 DEFINE RECTANGLE RECT-3
213 EDGE-PIXELS 1 GRAPHIC-EDGE
214 SIZE 15.43 BY .1
215 BGCOLOR 0 FGCOLOR 0 .
217 DEFINE RECTANGLE RECT-4
218 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
219 SIZE 78.29 BY 18.
221 DEFINE VARIABLE tgl_set_paid AS LOGICAL INITIAL no
222 LABEL ""
223 VIEW-AS TOGGLE-BOX
224 SIZE 2.57 BY .8
225 FONT 10 NO-UNDO.
227 DEFINE VARIABLE tgl_supplier AS LOGICAL INITIAL no
228 LABEL "Print supplier copy"
229 VIEW-AS TOGGLE-BOX
230 SIZE 16 BY .8
231 FONT 10.
234 /* ************************ Frame Definitions *********************** */
236 DEFINE FRAME F-Main
237 Order.EntityType AT ROW 1.2 COL 9.29 COLON-ALIGNED
238 LABEL "Owner"
239 VIEW-AS FILL-IN
240 SIZE 2.14 BY 1
241 Order.EntityCode AT ROW 1.2 COL 11 COLON-ALIGNED NO-LABEL
242 VIEW-AS FILL-IN
243 SIZE 6.57 BY 1
244 fil_EntityName AT ROW 1.2 COL 20.14 COLON-ALIGNED NO-LABEL
245 Order.OrderCode AT ROW 2.2 COL 11 COLON-ALIGNED
246 LABEL "Order Code"
247 VIEW-AS FILL-IN
248 SIZE 6.57 BY 1
249 Order.OrderDate AT ROW 2.2 COL 64.72 COLON-ALIGNED
250 VIEW-AS FILL-IN
251 SIZE 12 BY 1
252 cmb_Account AT ROW 3.2 COL 11 COLON-ALIGNED
253 Order.FirstApprover AT ROW 4.2 COL 11 COLON-ALIGNED
254 LABEL "Approver 1"
255 VIEW-AS FILL-IN
256 SIZE 5.43 BY 1
257 fil_Approver1 AT ROW 4.2 COL 19 COLON-ALIGNED NO-LABEL
258 fil_InBudget-1 AT ROW 4.2 COL 51.57 COLON-ALIGNED
259 fil_OverBudget-1 AT ROW 4.2 COL 66.43 COLON-ALIGNED
260 Order.SecondApprover AT ROW 5.2 COL 11 COLON-ALIGNED
261 LABEL "Approver 2"
262 VIEW-AS FILL-IN
263 SIZE 5.43 BY 1
264 fil_Approver2 AT ROW 5.2 COL 19 COLON-ALIGNED NO-LABEL
265 fil_InBudget-2 AT ROW 5.2 COL 51.57 COLON-ALIGNED
266 fil_OverBudget-2 AT ROW 5.2 COL 66.43 COLON-ALIGNED
267 Order.CreditorCode AT ROW 6.6 COL 11 COLON-ALIGNED
268 VIEW-AS FILL-IN
269 SIZE 6.43 BY 1
270 fil_Creditor AT ROW 6.6 COL 20.14 COLON-ALIGNED NO-LABEL
271 Order.OrderAmount AT ROW 8 COL 11 COLON-ALIGNED
272 LABEL "Order"
273 VIEW-AS FILL-IN
274 SIZE 15.43 BY 1
275 Order.QuotedAmount AT ROW 8 COL 35 COLON-ALIGNED
276 LABEL "Quote" FORMAT "->>>,>>>,>>9.99"
277 VIEW-AS FILL-IN
278 SIZE 15.43 BY 1
279 Order.ApprovedAmount AT ROW 8 COL 61 COLON-ALIGNED
280 LABEL "Approved"
281 VIEW-AS FILL-IN
282 SIZE 15.43 BY 1
283 Order.TaxAmount AT ROW 9.25 COL 61 COLON-ALIGNED
284 LABEL "Tax"
285 VIEW-AS FILL-IN
286 SIZE 15.43 BY 1.05
287 Order.Description AT ROW 9.6 COL 1.57 NO-LABEL
288 VIEW-AS EDITOR SCROLLBAR-VERTICAL
289 SIZE 50.86 BY 8.2
290 FONT 8
291 BtnCalculate AT ROW 10.25 COL 67
292 fil_YTD-Spent AT ROW 11 COL 61 COLON-ALIGNED
293 fil_Wait-Appvl AT ROW 12 COL 61 COLON-ALIGNED
294 fil_OS-Orders AT ROW 13 COL 61 COLON-ALIGNED
295 fil_Total-Committed AT ROW 14.2 COL 61 COLON-ALIGNED
296 fil_YTD-Budget AT ROW 15.75 COL 61 COLON-ALIGNED
297 fil_FY-Budget AT ROW 16.75 COL 61 COLON-ALIGNED
298 Order.OverridePaid AT ROW 17.8 COL 10.14 COLON-ALIGNED
299 LABEL "Journalled"
300 VIEW-AS FILL-IN
301 SIZE 13.14 BY 1
302 tgl_set_paid AT ROW 18 COL 1.86
303 tgl_supplier AT ROW 18 COL 35.86
304 fil_copies AT ROW 18 COL 58.29 COLON-ALIGNED NO-LABEL
305 RECT-3 AT ROW 14.05 COL 63
306 RECT-4 AT ROW 1 COL 1
307 "Print" VIEW-AS TEXT
308 SIZE 3.57 BY .8 AT ROW 18 COL 56.86
309 FONT 10
310 "Description" VIEW-AS TEXT
311 SIZE 8 BY .8 AT ROW 8.8 COL 2.14
312 FONT 10
313 "office copies of order." VIEW-AS TEXT
314 SIZE 14.14 BY .8 AT ROW 18 COL 63.43
315 FONT 10
316 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
317 SIDE-LABELS NO-UNDERLINE THREE-D
318 AT COL 1 ROW 1 SCROLLABLE
319 FONT 10.
322 /* *********************** Procedure Settings ************************ */
324 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
325 /* Settings for THIS-PROCEDURE
326 Type: SmartViewer
327 External Tables: TTPL.Order
328 Allow: Basic,DB-Fields
329 Frames: 1
330 Add Fields to: EXTERNAL-TABLES
331 Other Settings: PERSISTENT-ONLY COMPILE
334 /* This procedure should always be RUN PERSISTENT. Report the error, */
335 /* then cleanup and return. */
336 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
337 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT.":U
338 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
339 RETURN.
340 END.
342 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
344 /* ************************* Create Window ************************** */
346 &ANALYZE-SUSPEND _CREATE-WINDOW
347 /* DESIGN Window definition (used by the UIB)
348 CREATE WINDOW V-table-Win ASSIGN
349 HEIGHT = 21.95
350 WIDTH = 84.14.
351 /* END WINDOW DEFINITION */
353 &ANALYZE-RESUME
355 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB V-table-Win
356 /* ************************* Included-Libraries *********************** */
358 {src/adm/method/viewer.i}
359 {inc/method/m-mntvwr.i}
360 {inc/entity.i}
362 /* _UIB-CODE-BLOCK-END */
363 &ANALYZE-RESUME
368 /* *********** Runtime Attributes and AppBuilder Settings *********** */
370 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
371 /* SETTINGS FOR WINDOW V-table-Win
372 VISIBLE,,RUN-PERSISTENT */
373 /* SETTINGS FOR FRAME F-Main
374 NOT-VISIBLE Size-to-Fit */
375 ASSIGN
376 FRAME F-Main:SCROLLABLE = FALSE
377 FRAME F-Main:HIDDEN = TRUE.
379 /* SETTINGS FOR FILL-IN Order.ApprovedAmount IN FRAME F-Main
380 EXP-LABEL */
381 /* SETTINGS FOR FILL-IN Order.EntityCode IN FRAME F-Main
382 EXP-LABEL */
383 /* SETTINGS FOR FILL-IN Order.EntityType IN FRAME F-Main
384 NO-ENABLE EXP-LABEL */
385 /* SETTINGS FOR FILL-IN fil_Approver1 IN FRAME F-Main
386 NO-ENABLE */
387 /* SETTINGS FOR FILL-IN fil_Approver2 IN FRAME F-Main
388 NO-ENABLE */
389 /* SETTINGS FOR FILL-IN fil_Creditor IN FRAME F-Main
390 NO-ENABLE */
391 /* SETTINGS FOR FILL-IN fil_EntityName IN FRAME F-Main
392 NO-ENABLE */
393 /* SETTINGS FOR FILL-IN fil_FY-Budget IN FRAME F-Main
394 NO-ENABLE */
395 /* SETTINGS FOR FILL-IN fil_InBudget-1 IN FRAME F-Main
396 NO-ENABLE */
397 /* SETTINGS FOR FILL-IN fil_InBudget-2 IN FRAME F-Main
398 NO-ENABLE */
399 /* SETTINGS FOR FILL-IN fil_OS-Orders IN FRAME F-Main
400 NO-ENABLE */
401 /* SETTINGS FOR FILL-IN fil_OverBudget-1 IN FRAME F-Main
402 NO-ENABLE */
403 /* SETTINGS FOR FILL-IN fil_OverBudget-2 IN FRAME F-Main
404 NO-ENABLE */
405 /* SETTINGS FOR FILL-IN fil_Total-Committed IN FRAME F-Main
406 NO-ENABLE */
407 /* SETTINGS FOR FILL-IN fil_Wait-Appvl IN FRAME F-Main
408 NO-ENABLE */
409 /* SETTINGS FOR FILL-IN fil_YTD-Budget IN FRAME F-Main
410 NO-ENABLE */
411 /* SETTINGS FOR FILL-IN fil_YTD-Spent IN FRAME F-Main
412 NO-ENABLE */
413 /* SETTINGS FOR FILL-IN Order.FirstApprover IN FRAME F-Main
414 EXP-LABEL */
415 /* SETTINGS FOR FILL-IN Order.OrderAmount IN FRAME F-Main
416 EXP-LABEL */
417 /* SETTINGS FOR FILL-IN Order.OrderCode IN FRAME F-Main
418 EXP-LABEL */
419 /* SETTINGS FOR FILL-IN Order.OverridePaid IN FRAME F-Main
420 EXP-LABEL */
421 /* SETTINGS FOR FILL-IN Order.QuotedAmount IN FRAME F-Main
422 EXP-LABEL EXP-FORMAT */
423 /* SETTINGS FOR FILL-IN Order.SecondApprover IN FRAME F-Main
424 EXP-LABEL */
425 /* SETTINGS FOR FILL-IN Order.TaxAmount IN FRAME F-Main
426 EXP-LABEL */
427 /* _RUN-TIME-ATTRIBUTES-END */
428 &ANALYZE-RESUME
431 /* Setting information for Queries and Browse Widgets fields */
433 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
434 /* Query rebuild information for FRAME F-Main
435 _Options = "NO-LOCK"
436 _Query is NOT OPENED
437 */ /* FRAME F-Main */
438 &ANALYZE-RESUME
444 /* ************************ Control Triggers ************************ */
446 &Scoped-define SELF-NAME BtnCalculate
447 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL BtnCalculate V-table-Win
448 ON CHOOSE OF BtnCalculate IN FRAME F-Main /* Calculate */
450 RUN show-budget-info.
451 END.
453 /* _UIB-CODE-BLOCK-END */
454 &ANALYZE-RESUME
457 &Scoped-define SELF-NAME cmb_Account
458 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cmb_Account V-table-Win
459 ON VALUE-CHANGED OF cmb_Account IN FRAME F-Main /* Account */
461 RUN account-value-changed.
462 END.
464 /* _UIB-CODE-BLOCK-END */
465 &ANALYZE-RESUME
468 &Scoped-define SELF-NAME Order.CreditorCode
469 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Order.CreditorCode V-table-Win
470 ON LEAVE OF Order.CreditorCode IN FRAME F-Main /* Creditor */
472 {inc/selcde/cdcrd.i "fil_Creditor"}
473 END.
475 /* _UIB-CODE-BLOCK-END */
476 &ANALYZE-RESUME
479 &Scoped-define SELF-NAME Order.EntityCode
480 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Order.EntityCode V-table-Win
481 ON LEAVE OF Order.EntityCode IN FRAME F-Main /* Code */
483 IF SELF:MODIFIED THEN RUN entity-code-changed.
484 END.
486 /* _UIB-CODE-BLOCK-END */
487 &ANALYZE-RESUME
490 &Scoped-define SELF-NAME Order.EntityType
491 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Order.EntityType V-table-Win
492 ON LEAVE OF Order.EntityType IN FRAME F-Main /* Owner */
494 IF SELF:MODIFIED THEN RUN get-accounts.
495 END.
497 /* _UIB-CODE-BLOCK-END */
498 &ANALYZE-RESUME
501 &Scoped-define SELF-NAME fil_Approver1
502 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Approver1 V-table-Win
503 ON U1 OF fil_Approver1 IN FRAME F-Main
505 {inc/selfil/sfapp1.i "Order" "FirstApprover"}
506 END.
508 /* _UIB-CODE-BLOCK-END */
509 &ANALYZE-RESUME
512 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Approver1 V-table-Win
513 ON U2 OF fil_Approver1 IN FRAME F-Main
515 {inc/selfil/sfapp2.i "Order" "FirstApprover"}
516 DO WITH FRAME {&FRAME-NAME}:
517 RUN update-approver-limits( Order.FirstApprover:SCREEN-VALUE, fil_InBudget-1:HANDLE, fil_OverBudget-1:HANDLE ).
518 END.
519 END.
521 /* _UIB-CODE-BLOCK-END */
522 &ANALYZE-RESUME
525 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Approver1 V-table-Win
526 ON U3 OF fil_Approver1 IN FRAME F-Main
528 {inc/selfil/sfapp3.i "Order" "FirstApprover"}
529 END.
531 /* _UIB-CODE-BLOCK-END */
532 &ANALYZE-RESUME
535 &Scoped-define SELF-NAME fil_Approver2
536 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Approver2 V-table-Win
537 ON U1 OF fil_Approver2 IN FRAME F-Main
539 {inc/selfil/sfapp1.i "Order" "SecondApprover"}
540 END.
542 /* _UIB-CODE-BLOCK-END */
543 &ANALYZE-RESUME
546 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Approver2 V-table-Win
547 ON U2 OF fil_Approver2 IN FRAME F-Main
549 {inc/selfil/sfapp2.i "Order" "SecondApprover"}
550 DO WITH FRAME {&FRAME-NAME}:
551 RUN update-approver-limits( Order.SecondApprover:SCREEN-VALUE, fil_InBudget-2:HANDLE, fil_OverBudget-2:HANDLE ).
552 END.
553 END.
555 /* _UIB-CODE-BLOCK-END */
556 &ANALYZE-RESUME
559 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Approver2 V-table-Win
560 ON U3 OF fil_Approver2 IN FRAME F-Main
562 {inc/selfil/sfapp3.i "Order" "SecondApprover"}
563 END.
565 /* _UIB-CODE-BLOCK-END */
566 &ANALYZE-RESUME
569 &Scoped-define SELF-NAME fil_Creditor
570 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Creditor V-table-Win
571 ON U1 OF fil_Creditor IN FRAME F-Main
573 {inc/selfil/sfcrd1.i "Order" "CreditorCode"}
574 END.
576 /* _UIB-CODE-BLOCK-END */
577 &ANALYZE-RESUME
580 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Creditor V-table-Win
581 ON U2 OF fil_Creditor IN FRAME F-Main
583 {inc/selfil/sfcrd2.i "Order" "CreditorCode"}
584 END.
586 /* _UIB-CODE-BLOCK-END */
587 &ANALYZE-RESUME
590 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL fil_Creditor V-table-Win
591 ON U3 OF fil_Creditor IN FRAME F-Main
593 {inc/selfil/sfcrd3.i "Order" "CreditorCode"}
594 END.
596 /* _UIB-CODE-BLOCK-END */
597 &ANALYZE-RESUME
600 &Scoped-define SELF-NAME Order.FirstApprover
601 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Order.FirstApprover V-table-Win
602 ON LEAVE OF Order.FirstApprover IN FRAME F-Main /* Approver 1 */
604 {inc/selcde/cdapp.i "fil_Approver1"}
605 END.
607 /* _UIB-CODE-BLOCK-END */
608 &ANALYZE-RESUME
611 &Scoped-define SELF-NAME Order.OrderAmount
612 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Order.OrderAmount V-table-Win
613 ON LEAVE OF Order.OrderAmount IN FRAME F-Main /* Order */
615 IF NOT SELF:MODIFIED THEN RETURN.
616 DO WITH FRAME {&FRAME-NAME}:
617 ASSIGN Order.QuotedAmount:SCREEN-VALUE = SELF:SCREEN-VALUE
618 Order.ApprovedAmount:SCREEN-VALUE = SELF:SCREEN-VALUE.
619 Order.TaxAmount:SCREEN-VALUE = STRING( (INPUT {&SELF-NAME} * Office.GST) / 100, Order.TaxAmount:FORMAT) .
620 END.
621 END.
623 /* _UIB-CODE-BLOCK-END */
624 &ANALYZE-RESUME
627 &Scoped-define SELF-NAME Order.OrderCode
628 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Order.OrderCode V-table-Win
629 ON ANY-PRINTABLE OF Order.OrderCode IN FRAME F-Main /* Order Code */
631 IF CHR( LASTKEY ) = SELF:SCREEN-VALUE THEN
633 APPLY LASTKEY TO SELF.
634 SELF:MODIFIED = No.
635 RETURN NO-APPLY.
636 END.
637 END.
639 /* _UIB-CODE-BLOCK-END */
640 &ANALYZE-RESUME
643 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Order.OrderCode V-table-Win
644 ON LEAVE OF Order.OrderCode IN FRAME F-Main /* Order Code */
646 IF SELF:MODIFIED THEN
648 run order-number-changed.
649 SELF:MODIFIED = No.
650 END.
651 END.
653 /* _UIB-CODE-BLOCK-END */
654 &ANALYZE-RESUME
657 &Scoped-define SELF-NAME Order.SecondApprover
658 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Order.SecondApprover V-table-Win
659 ON LEAVE OF Order.SecondApprover IN FRAME F-Main /* Approver 2 */
661 {inc/selcde/cdapp.i "fil_Approver2"}
662 END.
664 /* _UIB-CODE-BLOCK-END */
665 &ANALYZE-RESUME
668 &Scoped-define SELF-NAME tgl_set_paid
669 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL tgl_set_paid V-table-Win
670 ON VALUE-CHANGED OF tgl_set_paid IN FRAME F-Main
672 RUN set-paid-changed.
673 END.
675 /* _UIB-CODE-BLOCK-END */
676 &ANALYZE-RESUME
679 &Scoped-define SELF-NAME tgl_supplier
680 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL tgl_supplier V-table-Win
681 ON VALUE-CHANGED OF tgl_supplier IN FRAME F-Main /* Print supplier copy */
683 RUN supplier-copies-changed.
684 END.
686 /* _UIB-CODE-BLOCK-END */
687 &ANALYZE-RESUME
690 &UNDEFINE SELF-NAME
692 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK V-table-Win
695 /* *************************** Main Block *************************** */
697 /* _UIB-CODE-BLOCK-END */
698 &ANALYZE-RESUME
701 /* ********************** Internal Procedures *********************** */
703 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE account-value-changed V-table-Win
704 PROCEDURE account-value-changed :
705 /*------------------------------------------------------------------------------
706 Purpose:
707 ------------------------------------------------------------------------------*/
708 /* RUN show-budget-info. */
709 END PROCEDURE.
711 /* _UIB-CODE-BLOCK-END */
712 &ANALYZE-RESUME
714 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-find-using-key V-table-Win adm/support/_key-fnd.p
715 PROCEDURE adm-find-using-key :
716 /*------------------------------------------------------------------------------
717 Purpose: Finds the current record using the contents of
718 the 'Key-Name' and 'Key-Value' attributes.
719 Parameters: <none>
720 ------------------------------------------------------------------------------*/
722 /* No Foreign keys are accepted by this SmartObject. */
724 END PROCEDURE.
726 /* _UIB-CODE-BLOCK-END */
727 &ANALYZE-RESUME
729 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available V-table-Win _ADM-ROW-AVAILABLE
730 PROCEDURE adm-row-available :
731 /*------------------------------------------------------------------------------
732 Purpose: Dispatched to this procedure when the Record-
733 Source has a new row available. This procedure
734 tries to get the new row (or foriegn keys) from
735 the Record-Source and process it.
736 Parameters: <none>
737 ------------------------------------------------------------------------------*/
739 /* Define variables needed by this internal procedure. */
740 {src/adm/template/row-head.i}
742 /* Create a list of all the tables that we need to get. */
743 {src/adm/template/row-list.i "Order"}
745 /* Get the record ROWID's from the RECORD-SOURCE. */
746 {src/adm/template/row-get.i}
748 /* FIND each record specified by the RECORD-SOURCE. */
749 {src/adm/template/row-find.i "Order"}
751 /* Process the newly available records (i.e. display fields,
752 open queries, and/or pass records on to any RECORD-TARGETS). */
753 {src/adm/template/row-end.i}
755 END PROCEDURE.
757 /* _UIB-CODE-BLOCK-END */
758 &ANALYZE-RESUME
760 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cancel-changes V-table-Win
761 PROCEDURE cancel-changes :
762 /*------------------------------------------------------------------------------
763 Purpose:
764 Parameters: <none>
765 Notes:
766 ------------------------------------------------------------------------------*/
768 RUN notify( 'hide, CONTAINER-SOURCE':U ).
769 IF mode = "Add" THEN
770 RUN delete-order.
771 ELSE
772 RUN check-modified( "CLEAR" ).
773 RUN dispatch( 'exit':U ).
775 END PROCEDURE.
777 /* _UIB-CODE-BLOCK-END */
778 &ANALYZE-RESUME
780 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE confirm-changes V-table-Win
781 PROCEDURE confirm-changes :
782 /*------------------------------------------------------------------------------
783 Purpose:
784 ------------------------------------------------------------------------------*/
786 prev-amount = Order.ApprovedAmount.
788 RUN verify-order.
789 IF RETURN-VALUE = "FAIL" THEN RETURN.
791 RUN dispatch( 'update-record':U ).
792 RUN print-order.
793 IF mode = "Add" THEN RUN notify( 'open-query, RECORD-SOURCE':U ).
794 RUN dispatch( 'exit':U ).
796 END PROCEDURE.
798 /* _UIB-CODE-BLOCK-END */
799 &ANALYZE-RESUME
801 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE delete-order V-table-Win
802 PROCEDURE delete-order :
803 /*------------------------------------------------------------------------------
804 Purpose:
805 ------------------------------------------------------------------------------*/
807 FIND CURRENT Order EXCLUSIVE-LOCK NO-ERROR.
808 IF AVAILABLE Order THEN DELETE Order.
810 END PROCEDURE.
812 /* _UIB-CODE-BLOCK-END */
813 &ANALYZE-RESUME
815 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI V-table-Win _DEFAULT-DISABLE
816 PROCEDURE disable_UI :
817 /*------------------------------------------------------------------------------
818 Purpose: DISABLE the User Interface
819 Parameters: <none>
820 Notes: Here we clean-up the user-interface by deleting
821 dynamic widgets we have created and/or hide
822 frames. This procedure is usually called when
823 we are ready to "clean-up" after running.
824 ------------------------------------------------------------------------------*/
825 /* Hide all frames. */
826 HIDE FRAME F-Main.
827 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
828 END PROCEDURE.
830 /* _UIB-CODE-BLOCK-END */
831 &ANALYZE-RESUME
833 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE entity-code-changed V-table-Win
834 PROCEDURE entity-code-changed :
835 /*------------------------------------------------------------------------------
836 Purpose:
837 ------------------------------------------------------------------------------*/
838 DO WITH FRAME {&FRAME-NAME}:
839 fil_EntityName = get-entity-name( INPUT Order.EntityType, INPUT Order.EntityCode ).
840 IF ( INPUT Order.EntityType = "J" ) THEN run get-accounts.
842 DEF BUFFER LastOrder FOR Order.
843 FIND LAST LastOrder WHERE LastOrder.EntityType = entity-type
844 AND LastOrder.EntityCode = entity-code
845 USE-INDEX XAK2Orders NO-LOCK NO-ERROR.
846 Order.OrderCode:SCREEN-VALUE = STRING((IF AVAILABLE LastOrder THEN LastOrder.OrderCode ELSE 0) + 1) .
848 END.
849 END PROCEDURE.
851 /* _UIB-CODE-BLOCK-END */
852 &ANALYZE-RESUME
854 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-account V-table-Win
855 PROCEDURE get-account :
856 /*------------------------------------------------------------------------------
857 Purpose:
858 ------------------------------------------------------------------------------*/
859 DEF OUTPUT PARAMETER account-code LIKE ChartOfAccount.AccountCode NO-UNDO.
860 DEF OUTPUT PARAMETER account-description AS CHAR NO-UNDO INITIAL ?.
862 DO WITH FRAME {&FRAME-NAME}:
863 account-code = DEC( TRIM( ENTRY( 1, cmb_account:SCREEN-VALUE, "-" ) ) ).
865 account-description = get-entity-account( INPUT Order.EntityType, INPUT Order.EntityCode, account-code ).
866 IF account-description = "* * * Unknown * * *" THEN RETURN "FAIL".
867 END.
869 END PROCEDURE.
871 /* _UIB-CODE-BLOCK-END */
872 &ANALYZE-RESUME
874 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-accounts V-table-Win
875 PROCEDURE get-accounts :
876 /*------------------------------------------------------------------------------
877 Purpose:
878 ------------------------------------------------------------------------------*/
879 DEF VAR item AS CHAR NO-UNDO.
880 DEF VAR account-codes AS CHAR NO-UNDO.
881 DEF VAR account-descriptions AS CHAR NO-UNDO.
882 DEF VAR group-list AS CHAR NO-UNDO INITIAL "".
883 DEF VAR i AS INTEGER NO-UNDO.
884 DEF VAR et AS CHAR NO-UNDO INITIAL "J".
886 DO WITH FRAME {&FRAME-NAME}:
888 cmb_Account:LIST-ITEMS = "".
890 IF AVAILABLE(Order) THEN et = INPUT Order.EntityType.
891 ELSE et = entity-type.
892 IF et = "J" THEN DO:
893 FIND Project WHERE Project.ProjectCode = entity-code NO-LOCK NO-ERROR.
894 IF NOT AVAILABLE Project THEN RETURN.
896 /* most projects, the budgets must exist */
897 FOR EACH ProjectBudget NO-LOCK OF Project WHERE ProjectBudget.OriginalBudget <> 0
898 OR ProjectBudget.CommittedBudget <> 0
899 OR ProjectBudget.UnCommittedBudget <> 0
900 OR ProjectBudget.Adjustment <> 0
901 OR ProjectBudget.AgreedVariation <> 0:
902 item = TRIM(ProjectBudget.Description).
903 IF item = "" OR item = ? THEN DO:
904 FIND ChartOfAccount OF ProjectBudget NO-LOCK NO-ERROR.
905 IF AVAILABLE(ChartOfAccount) THEN item = ChartOfAccount.Name.
906 END.
907 account-descriptions = account-descriptions
908 + (IF account-codes = "" THEN "" ELSE "~n")
909 + " - " + item.
910 account-codes = account-codes + (IF account-codes = "" THEN "" ELSE ",")
911 + STRING( ProjectBudget.AccountCode, "9999.99" ).
912 END.
913 END.
914 ELSE DO:
915 IF et = "P" THEN
916 group-list = property-groups.
917 ELSE IF et = "L" THEN
918 group-list = company-groups.
920 DO i = 1 TO NUM-ENTRIES(group-list):
921 FOR EACH ChartOfAccount WHERE ChartOfAccount.AccountGroupCode = ENTRY( i, group-list) NO-LOCK:
922 IF LOOKUP( STRING(ChartOfAccount.AccountCode, "9999.99"), account-codes) = 0 THEN DO:
923 account-descriptions = account-descriptions + (IF account-codes = "" THEN "" ELSE "~n")
924 + " - " + ChartOfAccount.Name.
925 account-codes = account-codes + (IF account-codes = "" THEN "" ELSE ",")
926 + STRING( ChartOfAccount.AccountCode, "9999.99" ).
927 END.
928 END.
929 END.
930 END.
932 /* MESSAGE et group-list SKIP account-codes. */
934 /* add them into the combo box. */
935 cmb_account:DELIMITER = "~n".
936 DO i = 1 TO NUM-ENTRIES(account-codes):
937 item = ENTRY( i, account-codes) + ENTRY(i, account-descriptions,"~n").
938 IF cmb_account:ADD-LAST( item ) THEN .
939 END.
941 END.
943 END PROCEDURE.
945 /* _UIB-CODE-BLOCK-END */
946 &ANALYZE-RESUME
948 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-parent-keys V-table-Win
949 PROCEDURE get-parent-keys :
950 /*------------------------------------------------------------------------------
951 Purpose:
952 ------------------------------------------------------------------------------*/
954 DEF VAR c-recsrc AS CHAR NO-UNDO.
955 DEF VAR parent-hdl AS HANDLE NO-UNDO.
956 DEF VAR rowid-list AS CHAR NO-UNDO.
958 RUN get-link-handle IN adm-broker-hdl( THIS-PROCEDURE, 'RECORD-SOURCE':U, OUTPUT c-recsrc ).
960 parent-hdl = WIDGET-HANDLE(c-recsrc).
961 IF NOT VALID-HANDLE( parent-hdl ) THEN RETURN.
963 RUN get-attribute IN parent-hdl ('Key-Name':U).
964 CASE RETURN-VALUE:
965 WHEN "PropertyCode" THEN entity-type = "P".
966 WHEN "ProjectCode" THEN entity-type = "J".
967 WHEN "CompanyCode" THEN entity-type = "L".
968 OTHERWISE entity-type = "J".
969 END CASE.
971 /* MESSAGE RETURN-VALUE entity-type. */
973 RUN get-attribute IN parent-hdl ('Key-Value':U).
974 entity-code = INT(RETURN-VALUE).
976 /* MESSAGE entity-code . */
978 END PROCEDURE.
980 /* _UIB-CODE-BLOCK-END */
981 &ANALYZE-RESUME
983 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-assign-statement V-table-Win
984 PROCEDURE inst-assign-statement :
985 /*------------------------------------------------------------------------------
986 Purpose:
987 ------------------------------------------------------------------------------*/
988 DEF VAR account-code AS DEC NO-UNDO.
989 DEF VAR junk AS CHAR NO-UNDO.
991 IF NOT AVAILABLE(Order) THEN RETURN.
993 DO WITH FRAME {&FRAME-NAME}:
994 RUN get-account( OUTPUT account-code, OUTPUT junk).
995 Order.AccountCode = account-code.
997 ASSIGN FRAME {&FRAME-NAME} tgl_set_paid.
998 IF NOT tgl_set_paid THEN Order.OverridePaid = ? .
1000 IF Order.EntityType = ? OR Order.EntityType = "" THEN DO:
1001 FIND Project WHERE Project.ProjectCode = Order.ProjectCode NO-LOCK NO-ERROR.
1002 IF AVAILABLE(Project) AND Project.ExpenditureType = "G" THEN DO:
1003 Order.EntityType = Project.EntityType.
1004 Order.EntityCode = Project.EntityCode.
1005 END.
1006 ELSE DO:
1007 Order.EntityType = "J".
1008 Order.EntityCode = Order.ProjectCode.
1009 END.
1010 END.
1011 END.
1014 END PROCEDURE.
1016 /* _UIB-CODE-BLOCK-END */
1017 &ANALYZE-RESUME
1019 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-disable-fields V-table-Win
1020 PROCEDURE inst-disable-fields :
1021 /*------------------------------------------------------------------------------
1022 Purpose:
1023 ------------------------------------------------------------------------------*/
1024 cmb_Account:SENSITIVE IN FRAME {&FRAME-NAME} = NO.
1025 RUN set-link-attributes IN sys-mgr( THIS-PROCEDURE,
1026 "*", "SENSITIVE = No" ).
1027 END PROCEDURE.
1029 /* _UIB-CODE-BLOCK-END */
1030 &ANALYZE-RESUME
1032 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-display-fields V-table-Win
1033 PROCEDURE inst-display-fields :
1034 /*------------------------------------------------------------------------------
1035 Purpose:
1036 ------------------------------------------------------------------------------*/
1037 DEF VAR item AS CHAR NO-UNDO.
1038 DEF VAR et AS CHAR NO-UNDO.
1041 DO WITH FRAME {&FRAME-NAME}:
1042 IF INPUT Order.EntityType <> entity-type THEN DO:
1043 entity-type = INPUT Order.EntityType.
1044 RUN get-accounts.
1045 END.
1048 item = cmb_Account:ENTRY(1).
1049 IF INPUT Order.EntityType = "J" THEN DO:
1050 FIND ProjectBudget WHERE ProjectBudget.ProjectCode = (INPUT Order.EntityCode)
1051 AND ProjectBudget.AccountCode = Order.AccountCode NO-LOCK NO-ERROR.
1053 IF AVAILABLE(ProjectBudget) THEN DO:
1054 item = STRING( ProjectBudget.AccountCode, "9999.99" ) + " - ".
1055 IF ProjectBudget.Description = "" OR ProjectBudget.Description = ? AND
1056 CAN-FIND( ChartOfAccount WHERE ChartOfAccount.AccountCode = Order.AccountCode )
1057 THEN DO:
1058 FIND ChartOfAccount WHERE ChartOfAccount.AccountCode = Order.AccountCode NO-LOCK.
1059 item = item + ChartOfAccount.Name.
1060 END.
1061 ELSE
1062 item = item + projectBudget.Description .
1063 END.
1064 ELSE DO:
1065 FIND ChartOfAccount WHERE ChartOfAccount.AccountCode = Order.AccountCode NO-LOCK NO-ERROR.
1066 IF AVAILABLE ChartOfAccount THEN
1067 item = STRING( ChartOfAccount.AccountCode, "9999.99" ) + " - " + ChartOfAccount.Name.
1068 END.
1069 END.
1070 ELSE DO:
1071 FIND ChartOfAccount WHERE ChartOfAccount.AccountCode = Order.AccountCode NO-LOCK NO-ERROR.
1072 IF AVAILABLE ChartOfAccount THEN
1073 item = STRING( ChartOfAccount.AccountCode, "9999.99" ) + " - " + ChartOfAccount.Name.
1074 END.
1076 cmb_Account:SCREEN-VALUE = item.
1078 RUN update-approver-limits( Order.FirstApprover:SCREEN-VALUE, fil_InBudget-1:HANDLE, fil_OverBudget-1:HANDLE ).
1079 RUN update-approver-limits( Order.SecondApprover:SCREEN-VALUE, fil_InBudget-2:HANDLE, fil_OverBudget-2:HANDLE ).
1081 END.
1083 END PROCEDURE.
1085 /* _UIB-CODE-BLOCK-END */
1086 &ANALYZE-RESUME
1088 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-enable-fields V-table-Win
1089 PROCEDURE inst-enable-fields :
1090 /*------------------------------------------------------------------------------
1091 Purpose:
1092 ------------------------------------------------------------------------------*/
1094 DO WITH FRAME {&FRAME-NAME}:
1095 Order.EntityType:SENSITIVE = mode = "Add".
1096 Order.EntityCode:SENSITIVE = mode = "Add".
1097 Order.OrderCode:SENSITIVE = mode = "Add".
1098 END.
1100 RUN set-paid-changed.
1102 END PROCEDURE.
1104 /* _UIB-CODE-BLOCK-END */
1105 &ANALYZE-RESUME
1107 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-initialize V-table-Win
1108 PROCEDURE inst-initialize :
1109 /*------------------------------------------------------------------------------
1110 Purpose:
1111 ------------------------------------------------------------------------------*/
1113 fil_copies = (IF mode = "View" THEN 0 ELSE 1).
1114 tgl_supplier = (mode = "Add").
1115 DISPLAY fil_Copies tgl_supplier WITH FRAME {&FRAME-NAME}.
1117 IF mode <> "Add" THEN
1118 tgl_set_paid = (Order.OverridePaid <> ?).
1119 ELSE
1120 tgl_set_paid = No.
1122 DISPLAY tgl_set_paid WITH FRAME {&FRAME-NAME}.
1123 RUN set-paid-changed.
1125 IF mode = "Add" THEN DO:
1126 have-records = Yes.
1127 RUN dispatch( 'add-record':U ).
1128 END.
1129 ELSE IF mode = "View" THEN
1130 RUN dispatch( 'disable-fields':U ).
1131 ELSE
1132 RUN dispatch( 'enable-fields':U ).
1134 END PROCEDURE.
1136 /* _UIB-CODE-BLOCK-END */
1137 &ANALYZE-RESUME
1139 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-row-available V-table-Win
1140 PROCEDURE inst-row-available :
1141 /*------------------------------------------------------------------------------
1142 Purpose:
1143 ------------------------------------------------------------------------------*/
1145 IF AVAILABLE(Order) AND Order.EntityType = ? OR Order.EntityType = "" THEN DO:
1146 FIND CURRENT Order EXCLUSIVE-LOCK.
1147 FIND Project WHERE Project.ProjectCode = Order.ProjectCode NO-LOCK NO-ERROR.
1148 IF AVAILABLE(Project) AND Project.ExpenditureType = "G" THEN DO:
1149 Order.EntityType = Project.EntityType.
1150 Order.EntityCode = Project.EntityCode.
1151 END.
1152 ELSE DO:
1153 Order.EntityType = "J".
1154 Order.EntityCode = Order.ProjectCode.
1155 END.
1156 FIND CURRENT Order NO-LOCK.
1157 DISPLAY Order.EntityType Order.EntityCode WITH FRAME {&FRAME-NAME}.
1159 IF Order.EntityType <> entity-type THEN DO:
1160 entity-type = Order.EntityType.
1161 RUN get-accounts.
1162 END.
1163 END.
1165 END PROCEDURE.
1167 /* _UIB-CODE-BLOCK-END */
1168 &ANALYZE-RESUME
1170 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-end-update V-table-Win
1171 PROCEDURE local-end-update :
1172 /*------------------------------------------------------------------------------
1173 Purpose: Override standard ADM method
1174 Notes:
1175 ------------------------------------------------------------------------------*/
1177 /* Code placed here will execute PRIOR to standard behavior. */
1178 ERROR-STATUS:ERROR = No.
1180 /* Dispatch standard ADM method. */
1181 RUN dispatch IN THIS-PROCEDURE ( INPUT 'end-update':U ) .
1183 /* Code placed here will execute AFTER standard behavior. */
1185 END PROCEDURE.
1187 /* _UIB-CODE-BLOCK-END */
1188 &ANALYZE-RESUME
1190 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE order-number-changed V-table-Win
1191 PROCEDURE order-number-changed :
1192 /*------------------------------------------------------------------------------
1193 Purpose:
1194 Parameters: <none>
1195 Notes:
1196 ------------------------------------------------------------------------------*/
1198 fil_copies = 1.
1199 DISPLAY fil_Copies WITH FRAME {&FRAME-NAME}.
1201 END PROCEDURE.
1203 /* _UIB-CODE-BLOCK-END */
1204 &ANALYZE-RESUME
1206 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE override-add-record V-table-Win
1207 PROCEDURE override-add-record :
1208 /*------------------------------------------------------------------------------
1209 Purpose:
1210 ------------------------------------------------------------------------------*/
1211 DEF VAR last-order AS INT NO-UNDO INITIAL 0.
1213 DO WITH FRAME {&FRAME-NAME}:
1215 IF entity-type = "J" THEN DO:
1216 FIND Project WHERE Project.ProjectCode = entity-code NO-LOCK NO-ERROR.
1217 IF AVAILABLE Project THEN DO:
1218 IF Project.ExpenditureType = "G" THEN DO:
1219 ASSIGN
1220 entity-type = Project.EntityType.
1221 entity-code = Project.EntityCode.
1222 /* MESSAGE entity-type entity-code. */
1223 END.
1224 END.
1225 END.
1227 ON FIND OF Order OVERRIDE DO: END.
1228 DEF BUFFER LastOrder FOR Order.
1229 FOR EACH LastOrder WHERE LastOrder.EntityType = entity-type
1230 AND LastOrder.EntityCode = entity-code
1231 BY LastOrder.OrderCode DESCENDING:
1232 last-order = LastOrder.OrderCode.
1233 LEAVE.
1234 END.
1235 ON FIND OF Order REVERT.
1237 /* MESSAGE entity-type entity-code last-order. */
1239 CREATE Order.
1240 ASSIGN
1241 Order.EntityType = entity-type
1242 Order.EntityCode = entity-code
1243 Order.ProjectCode = entity-code
1244 Order.AccountCode = 0000.00
1245 Order.OrderDate = TODAY
1246 Order.OrderCode = last-order + 1 .
1249 IF entity-type = "J" THEN DO:
1250 FIND Project WHERE Project.ProjectCode = entity-code NO-LOCK NO-ERROR.
1251 IF AVAILABLE Project THEN DO:
1252 Order.ProjectCode = entity-code.
1253 Order.FirstApprover = Project.FirstApprover.
1254 Order.SecondApprover = Project.SecondApprover.
1255 END.
1256 END.
1257 ELSE IF entity-type = "P" THEN DO:
1258 FIND Property WHERE Property.PropertyCode = entity-code NO-LOCK NO-ERROR.
1259 IF AVAILABLE Property THEN DO:
1260 FIND LAST LastOrder WHERE LastOrder.EntityType = "P"
1261 AND LastOrder.EntityCode = Property.PropertyCode
1262 USE-INDEX XAK2Orders NO-LOCK NO-ERROR.
1263 FIND FIRST Approver WHERE Approver.PersonCode = Property.Manager NO-LOCK NO-ERROR.
1264 IF AVAILABLE(Approver) THEN Order.FirstApprover = Approver.ApproverCode.
1265 FIND FIRST Approver WHERE Approver.PersonCode = Property.Administrator NO-LOCK NO-ERROR.
1266 IF AVAILABLE(Approver) THEN Order.SecondApprover = Approver.ApproverCode.
1267 END.
1268 END.
1269 ELSE IF entity-type = "L" THEN DO:
1270 FIND Company WHERE Company.CompanyCode = entity-code NO-LOCK NO-ERROR.
1271 IF AVAILABLE Company THEN DO:
1272 Order.FirstApprover = company-approver1.
1273 Order.SecondApprover = company-approver2.
1274 END.
1275 END.
1278 RUN dispatch( 'enable-fields':U ).
1279 RUN dispatch( 'display-fields':U ).
1281 CURRENT-WINDOW:TITLE = "Adding a new Order " + entity-type + STRING(entity-code, "99999").
1283 END.
1285 END PROCEDURE.
1287 /* _UIB-CODE-BLOCK-END */
1288 &ANALYZE-RESUME
1290 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE override-row-available V-table-Win
1291 PROCEDURE override-row-available :
1292 /*------------------------------------------------------------------------------
1293 Purpose:
1294 ------------------------------------------------------------------------------*/
1295 IF ( mode <> "Add" ) THEN RUN adm-row-available.
1296 END PROCEDURE.
1298 /* _UIB-CODE-BLOCK-END */
1299 &ANALYZE-RESUME
1301 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-destroy V-table-Win
1302 PROCEDURE pre-destroy :
1303 /*------------------------------------------------------------------------------
1304 Purpose:
1305 Parameters: <none>
1306 Notes:
1307 ------------------------------------------------------------------------------*/
1309 IF LAST-EVENT:FUNCTION = "WINDOW-CLOSE":U THEN RUN cancel-changes.
1311 END PROCEDURE.
1313 /* _UIB-CODE-BLOCK-END */
1314 &ANALYZE-RESUME
1316 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-initialize V-table-Win
1317 PROCEDURE pre-initialize :
1318 /*------------------------------------------------------------------------------
1319 Purpose:
1320 Parameters: <none>
1321 Notes:
1322 ------------------------------------------------------------------------------*/
1324 RUN get-parent-keys.
1325 RUN get-accounts.
1327 END PROCEDURE.
1329 /* _UIB-CODE-BLOCK-END */
1330 &ANALYZE-RESUME
1332 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-order V-table-Win
1333 PROCEDURE print-order :
1334 /*------------------------------------------------------------------------------
1335 Purpose:
1336 ------------------------------------------------------------------------------*/
1337 DEF VAR report-options AS CHAR NO-UNDO.
1339 ASSIGN FRAME {&FRAME-NAME} tgl_supplier fil_copies.
1341 IF fil_copies > 0 OR tgl_supplier THEN DO:
1342 MESSAGE "Reprint to PDF?" VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO
1343 TITLE "PDF Printing ?" UPDATE pdf-printing.
1345 report-options = "Entity," + Order.EntityType + "," + STRING(Order.EntityCode)
1346 + "~nOrders," + STRING(Order.OrderCode)
1347 + (IF tgl_Supplier THEN "~nSupplierCopy" ELSE "")
1348 + (IF pdf-printing THEN "~nOutputPDF" ELSE "")
1349 + "~nInternalCopies," + STRING( fil_copies ).
1350 RUN process/report/orderfrm.p( report-options ).
1351 END.
1353 END PROCEDURE.
1355 /* _UIB-CODE-BLOCK-END */
1356 &ANALYZE-RESUME
1358 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key V-table-Win adm/support/_key-snd.p
1359 PROCEDURE send-key :
1360 /*------------------------------------------------------------------------------
1361 Purpose: Sends a requested KEY value back to the calling
1362 SmartObject.
1363 Parameters: <see adm/template/sndkytop.i>
1364 ------------------------------------------------------------------------------*/
1366 /* Define variables needed by this internal procedure. */
1367 {src/adm/template/sndkytop.i}
1369 /* Return the key value associated with each key case. */
1370 {src/adm/template/sndkycas.i "PropertyCode" "Order" "EntityCode"}
1371 {src/adm/template/sndkycas.i "ProjectCode" "Order" "EntityCode"}
1372 {src/adm/template/sndkycas.i "OrderCode" "Order" "OrderCode"}
1374 /* Close the CASE statement and end the procedure. */
1375 {src/adm/template/sndkyend.i}
1377 END PROCEDURE.
1379 /* _UIB-CODE-BLOCK-END */
1380 &ANALYZE-RESUME
1382 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records V-table-Win _ADM-SEND-RECORDS
1383 PROCEDURE send-records :
1384 /*------------------------------------------------------------------------------
1385 Purpose: Send record ROWID's for all tables used by
1386 this file.
1387 Parameters: see template/snd-head.i
1388 ------------------------------------------------------------------------------*/
1390 /* Define variables needed by this internal procedure. */
1391 {src/adm/template/snd-head.i}
1393 /* For each requested table, put it's ROWID in the output list. */
1394 {src/adm/template/snd-list.i "Order"}
1396 /* Deal with any unexpected table requests before closing. */
1397 {src/adm/template/snd-end.i}
1399 END PROCEDURE.
1401 /* _UIB-CODE-BLOCK-END */
1402 &ANALYZE-RESUME
1404 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-paid-changed V-table-Win
1405 PROCEDURE set-paid-changed :
1406 /*------------------------------------------------------------------------------
1407 Purpose:
1408 ------------------------------------------------------------------------------*/
1409 DO WITH FRAME {&FRAME-NAME}:
1411 /* ASSIGN FRAME {&FRAME-NAME} Order.OverridePaid. */
1413 Order.OverridePaid:SENSITIVE = INPUT tgl_set_paid .
1414 IF INPUT tgl_set_paid = No THEN
1415 DISPLAY ? @ Order.OverridePaid.
1416 ELSE
1417 DISPLAY Order.OverridePaid.
1419 END.
1421 END PROCEDURE.
1423 /* _UIB-CODE-BLOCK-END */
1424 &ANALYZE-RESUME
1426 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE show-budget-info V-table-Win
1427 PROCEDURE show-budget-info :
1428 /*------------------------------------------------------------------------------
1429 Purpose:
1430 ------------------------------------------------------------------------------*/
1431 DEF VAR m1 AS INT NO-UNDO.
1432 DEF VAR m2 AS INT NO-UNDO.
1433 DEF VAR m3 AS INT NO-UNDO.
1435 DEF VAR et AS CHAR NO-UNDO.
1436 DEF VAR ec AS INT NO-UNDO.
1437 DEF VAR ac AS DEC NO-UNDO.
1438 DEF VAR ac-desc AS CHAR NO-UNDO.
1440 IF NOT AVAILABLE(Order) THEN RETURN.
1443 DO WITH FRAME {&FRAME-NAME}:
1444 fil_YTD-Budget = 0.
1445 fil_FY-Budget = 0.
1447 fil_Total-Committed = 0.
1448 fil_Wait-Appvl = 0.
1449 fil_OS-Orders = 0.
1450 fil_YTD-Spent = 0.
1452 FIND Month WHERE Month.StartDate <= TODAY AND Month.EndDate >= TODAY NO-LOCK.
1453 m2 = Month.MonthCode.
1454 FIND FinancialYear OF Month NO-LOCK.
1455 IF Order.EntityType = 'J' THEN DO:
1456 FIND FIRST Month NO-LOCK. m1 = Month.MonthCode.
1457 END.
1458 ELSE DO:
1459 FIND FIRST Month OF FinancialYear NO-LOCK. m1 = Month.MonthCode.
1460 END.
1461 FIND LAST Month OF FinancialYear NO-LOCK. m3 = Month.MonthCode.
1463 RUN get-account( OUTPUT ac, OUTPUT ac-desc ).
1464 et = INPUT Order.EntityType.
1465 ec = INPUT Order.EntityCode.
1467 /* OUTPUT TO tmp.txt . */
1469 FOR EACH AccountBalance WHERE AccountBalance.EntityType = et
1470 AND AccountBalance.EntityCode = ec
1471 AND AccountBalance.AccountCode = ac
1472 AND AccountBalance.MonthCode >= m1
1473 AND AccountBalance.MonthCode <= m3 NO-LOCK:
1474 fil_FY-Budget = fil_FY-Budget + AccountBalance.Budget.
1475 IF AccountBalance.MonthCode <= m2 THEN DO:
1476 fil_YTD-Budget = fil_YTD-Budget + AccountBalance.Budget.
1477 fil_YTD-Spent = fil_YTD-Spent + AccountBalance.Balance.
1478 END.
1480 MESSAGE "AB:" AccountBalance.EntityType AccountBalance.EntityCode AccountBalance.AccountCode
1481 AccountBalance.MonthCode AccountBalance.Budget AccountBalance.Balance .
1483 END.
1484 DEF BUFFER tmp_Order FOR Order.
1485 FOR EACH tmp_Order WHERE tmp_Order.EntityType = et
1486 AND tmp_Order.EntityCode = ec
1487 AND tmp_Order.AccountCode = ac
1488 AND ROWID(tmp_Order) <> ROWID(Order) NO-LOCK:
1489 fil_OS-Orders = fil_OS-Orders + tmp_Order.ApprovedAmount .
1491 MESSAGE "tmpOrder:" tmp_Order.EntityType tmp_Order.EntityCode tmp_Order.AccountCode ac
1492 tmp_Order.OrderCode tmp_Order.ApprovedAmount .
1494 FOR EACH Voucher WHERE Voucher.EntityType = et
1495 AND Voucher.EntityCode = ec
1496 AND Voucher.OrderCode = tmp_Order.OrderCode NO-LOCK:
1497 IF Voucher.VoucherStatus = "U" THEN DO:
1498 fil_Wait-Appvl = fil_Wait-Appvl + Voucher.GoodsValue.
1499 END.
1500 IF Voucher.VoucherStatus <> "C" THEN DO:
1501 fil_OS-Orders = fil_OS-Orders - Voucher.GoodsValue.
1502 END.
1503 END.
1504 END.
1506 fil_OS-Orders = fil_OS-Orders + INPUT Order.ApprovedAmount .
1508 MESSAGE "my_Order:" Order.EntityType Order.EntityCode Order.AccountCode ac
1509 INPUT Order.OrderCode INPUT Order.ApprovedAmount .
1511 FOR EACH Voucher WHERE Voucher.EntityType = et
1512 AND Voucher.EntityCode = ec
1513 AND Voucher.OrderCode = INPUT Order.OrderCode NO-LOCK:
1514 IF Voucher.VoucherStatus = "U" THEN DO:
1515 fil_Wait-Appvl = fil_Wait-Appvl + Voucher.GoodsValue.
1516 END.
1517 IF Voucher.VoucherStatus <> "C" THEN DO:
1518 fil_OS-Orders = fil_OS-Orders - Voucher.GoodsValue.
1519 END.
1520 END.
1521 /* OUTPUT CLOSE. */
1523 fil_Total-Committed = fil_YTD-Spent + fil_OS-Orders + fil_Wait-Appvl.
1524 DISPLAY fil_YTD-Budget fil_FY-Budget fil_OS-Orders
1525 fil_Total-Committed fil_Wait-Appvl fil_YTD-Spent.
1527 END.
1528 END PROCEDURE.
1530 /* _UIB-CODE-BLOCK-END */
1531 &ANALYZE-RESUME
1533 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed V-table-Win
1534 PROCEDURE state-changed :
1535 /* -----------------------------------------------------------
1536 Purpose:
1537 Parameters: <none>
1538 Notes:
1539 -------------------------------------------------------------*/
1540 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
1541 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
1543 CASE p-state:
1544 /* Object instance CASEs can go here to replace standard behavior
1545 or add new cases. */
1546 {src/adm/template/vstates.i}
1547 END CASE.
1548 END PROCEDURE.
1550 /* _UIB-CODE-BLOCK-END */
1551 &ANALYZE-RESUME
1553 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE supplier-copies-changed V-table-Win
1554 PROCEDURE supplier-copies-changed :
1555 /*------------------------------------------------------------------------------
1556 Purpose:
1557 Parameters: <none>
1558 Notes:
1559 ------------------------------------------------------------------------------*/
1560 RETURN. /* this is no longer relevant */
1561 DO WITH FRAME {&FRAME-NAME}:
1563 ASSIGN FRAME {&FRAME-NAME} fil_copies.
1565 IF INPUT tgl_supplier = No THEN
1566 fil_Copies = IF fil_Copies = 0 THEN 0 ELSE fil_copies - 1.
1567 ELSE
1568 fil_Copies = fil_Copies + 1.
1570 DISPLAY fil_copies WITH FRAME {&FRAME-NAME}.
1572 END.
1574 END PROCEDURE.
1576 /* _UIB-CODE-BLOCK-END */
1577 &ANALYZE-RESUME
1579 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-approver-limits V-table-Win
1580 PROCEDURE update-approver-limits :
1581 /*------------------------------------------------------------------------------
1582 Purpose:
1583 ------------------------------------------------------------------------------*/
1584 DEF INPUT PARAMETER appvr AS CHAR NO-UNDO.
1585 DEF INPUT PARAMETER in-budget-hdl AS HANDLE NO-UNDO.
1586 DEF INPUT PARAMETER over-budget-hdl AS HANDLE NO-UNDO.
1588 DEF BUFFER tmp_Appvr FOR Approver.
1590 FIND tmp_Appvr WHERE tmp_Appvr.ApproverCode = appvr NO-LOCK NO-ERROR.
1591 IF NOT AVAILABLE(tmp_Appvr) THEN RETURN.
1593 in-budget-hdl:SCREEN-VALUE = STRING( tmp_Appvr.ApprovalLimit, in-budget-hdl:FORMAT ).
1594 over-budget-hdl:SCREEN-VALUE = STRING( tmp_Appvr.OverBudgetLimit, over-budget-hdl:FORMAT ).
1596 END PROCEDURE.
1598 /* _UIB-CODE-BLOCK-END */
1599 &ANALYZE-RESUME
1601 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-mode V-table-Win
1602 PROCEDURE use-mode :
1603 /*------------------------------------------------------------------------------
1604 Purpose:
1605 ------------------------------------------------------------------------------*/
1606 DEF INPUT PARAMETER new-mode AS CHAR NO-UNDO.
1607 mode = new-mode.
1608 END PROCEDURE.
1610 /* _UIB-CODE-BLOCK-END */
1611 &ANALYZE-RESUME
1613 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-order V-table-Win
1614 PROCEDURE verify-order :
1615 /*------------------------------------------------------------------------------
1616 Purpose:
1617 ------------------------------------------------------------------------------*/
1619 DO WITH FRAME {&FRAME-NAME}:
1621 CASE INPUT Order.EntityType:
1622 WHEN "J" THEN DO:
1623 FIND Project WHERE Project.ProjectCode = INPUT Order.EntityCode NO-LOCK NO-ERROR.
1624 IF NOT AVAILABLE(Project) THEN DO:
1625 MESSAGE "The project code is invalid." VIEW-AS ALERT-BOX ERROR
1626 TITLE "Invalid Project Code".
1627 APPLY 'ENTRY':U TO Order.EntityCode.
1628 RETURN "FAIL".
1629 END.
1630 END.
1631 WHEN "P" THEN DO:
1632 FIND Property WHERE Property.PropertyCode = INPUT Order.EntityCode NO-LOCK NO-ERROR.
1633 IF NOT AVAILABLE(Property) THEN DO:
1634 MESSAGE "The project code is invalid." VIEW-AS ALERT-BOX ERROR
1635 TITLE "Invalid Property Code".
1636 APPLY 'ENTRY':U TO Order.EntityCode.
1637 RETURN "FAIL".
1638 END.
1639 END.
1640 WHEN "L" THEN DO:
1641 FIND Company WHERE Company.CompanyCode = INPUT Order.EntityCode NO-LOCK NO-ERROR.
1642 IF NOT AVAILABLE(Company) THEN DO:
1643 MESSAGE "The project code is invalid." VIEW-AS ALERT-BOX ERROR
1644 TITLE "Invalid Company Code".
1645 APPLY 'ENTRY':U TO Order.EntityCode.
1646 RETURN "FAIL".
1647 END.
1648 END.
1649 OTHERWISE DO:
1650 MESSAGE "The entity type is invalid." VIEW-AS ALERT-BOX ERROR
1651 TITLE "Invalid Entity Type".
1652 APPLY 'ENTRY':U TO Order.EntityType.
1653 RETURN "FAIL".
1654 END.
1655 END CASE.
1657 IF INPUT Order.EntityType = "J" AND Project.ExpenditureType = "M" THEN DO:
1658 MESSAGE "Orders cannot be put against 'Major' projects" SKIP
1659 "but must be created against their sub-projects."
1660 VIEW-AS ALERT-BOX ERROR TITLE "Invalid Project Expense Type".
1661 APPLY 'ENTRY':U TO Order.EntityCode.
1662 RETURN "FAIL".
1663 END.
1665 IF TRIM(INPUT Order.Description) = "" THEN DO:
1666 MESSAGE "You must enter a description" VIEW-AS ALERT-BOX ERROR
1667 TITLE "No description".
1668 APPLY 'ENTRY':U TO Order.Description.
1669 RETURN "FAIL".
1670 END.
1672 IF INPUT Order.OrderCode = 0 THEN DO:
1673 MESSAGE "You must enter an order number" VIEW-AS ALERT-BOX ERROR
1674 TITLE "No order number entered".
1675 APPLY 'ENTRY':U TO Order.OrderCode.
1676 RETURN "FAIL".
1677 END.
1679 IF mode = "Add" AND INPUT Order.OrderCode <> Order.OrderCode AND
1680 CAN-FIND( Order WHERE
1681 Order.EntityType = INPUT Order.EntityType AND
1682 Order.EntityCode = INPUT Order.EntityCode AND
1683 Order.OrderCode = INPUT Order.OrderCode ) THEN
1685 MESSAGE
1686 "An order already exists for" INPUT Order.EntityType INPUT Order.EntityCode SKIP
1687 "and order code" INPUT Order.OrderCode
1688 VIEW-AS ALERT-BOX ERROR TITLE "Duplicate Order Error".
1689 APPLY 'ENTRY':U TO Order.OrderCode.
1690 RETURN "FAIL".
1691 END.
1693 DEF VAR account-code AS DEC NO-UNDO.
1694 DEF VAR account-description AS CHAR NO-UNDO.
1695 RUN get-account( OUTPUT account-code, OUTPUT account-description).
1696 IF RETURN-VALUE = "FAIL" THEN DO:
1697 MESSAGE "You need to select an account." VIEW-AS ALERT-BOX ERROR
1698 TITLE "No account selected".
1699 APPLY 'ENTRY':U TO cmb_Account.
1700 RETURN "FAIL".
1701 END.
1703 IF NOT CAN-FIND( FIRST Creditor WHERE Creditor.CreditorCode = INPUT Order.CreditorCode ) THEN DO:
1704 MESSAGE "You need to choose a creditor for this order" VIEW-AS ALERT-BOX ERROR
1705 TITLE "No Creditor selected".
1706 APPLY 'ENTRY':U TO Order.CreditorCode.
1707 RETURN "FAIL".
1708 END.
1710 IF INPUT Order.EntityType = "J" AND Project.ExpenditureType <> "G" THEN DO:
1711 RUN verify-order-amount( account-code ).
1712 IF RETURN-VALUE = "FAIL" THEN RETURN RETURN-VALUE.
1713 END.
1715 END.
1717 END PROCEDURE.
1719 /* _UIB-CODE-BLOCK-END */
1720 &ANALYZE-RESUME
1722 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-order-amount V-table-Win
1723 PROCEDURE verify-order-amount :
1724 /*------------------------------------------------------------------------------
1725 Purpose:
1726 ------------------------------------------------------------------------------*/
1727 DEF INPUT PARAMETER ac AS DEC NO-UNDO.
1729 DEF BUFFER PBJ FOR ProjectBudget.
1731 DO WITH FRAME {&FRAME-NAME}:
1733 FIND PBJ WHERE PBJ.ProjectCode = INPUT Order.EntityCode
1734 AND PBJ.AccountCode = ac NO-LOCK NO-ERROR.
1736 IF NOT AVAILABLE(PBJ) THEN DO:
1737 MESSAGE "Record not available".
1738 END.
1740 DEF VAR threshold AS DEC NO-UNDO.
1741 DEF VAR max-amount AS DEC NO-UNDO.
1743 IF PBJ.CommittedBudget <> 0 THEN
1744 threshold = PBJ.CommittedBudget + PBJ.UncommittedBudget .
1745 ELSE
1746 threshold = PBJ.OriginalBudget.
1748 threshold = threshold + PBJ.Adjustment + PBJ.AgreedVariation.
1749 max-amount = threshold - prev-amount .
1750 IF max-amount < 0 THEN max-amount = 0.
1752 IF (( (INPUT Order.ApprovedAmount) - Order.ApprovedAmount) > max-amount ) THEN DO:
1753 MESSAGE "The total orders for project budget" STRING( INPUT Order.EntityCode ) + "/" + STRING( PBJ.AccountCode, "9999.99" ) SKIP
1754 "will exceed the budget of" TRIM( STRING( threshold, "$>>>,>>>,>>9.99CR" )) + "." SKIP(1)
1755 "To remain within budget, this order can have" SKIP
1756 "a maximum approved amount of "
1757 TRIM( STRING( max-amount + Order.ApprovedAmount, "$>>>,>>>,>>9.99CR" ) ) + "."
1758 VIEW-AS ALERT-BOX ERROR TITLE "Budget Exceeded.".
1759 APPLY 'ENTRY':U TO Order.ApprovedAmount.
1760 RETURN "FAIL".
1761 END.
1763 END.
1765 END PROCEDURE.
1767 /* _UIB-CODE-BLOCK-END */
1768 &ANALYZE-RESUME