1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI ADM1
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS V-table-Win
8 /*------------------------------------------------------------------------
9 ------------------------------------------------------------------------*/
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.
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
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
*/
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
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 ~
90 /* Custom List Definitions
*/
91 /* ADM-CREATE-FIELDS
,ADM-ASSIGN-FIELDS
,List-3
,List-4
,List-5
,List-6
*/
93 /* _UIB-PREPROCESSOR-BLOCK-END
*/
97 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" V-table-Win _INLINE
98 /* Actions
: ? adm
/support
/keyedit.w ? ? ?
*/
104 PropertyCode||y|TTPL.Order.EntityCode
105 ProjectCode||y|TTPL.Order.EntityCode
106 OrderCode||y|TTPL.Order.OrderCode
109 **************************
110 * Set attributes related to FOREIGN
KEYS
112 RUN set-attribute-list
(
114 Keys-Supplied
= "PropertyCode,ProjectCode,OrderCode"'
:U
).
115 /**************************
117 /* _UIB-CODE-BLOCK-END
*/
121 /* *********************** Control Definitions
********************** */
124 /* Definitions of the field level widgets
*/
125 DEFINE BUTTON BtnCalculate
130 DEFINE VARIABLE cmb_Account
AS CHARACTER FORMAT "X(256)":U
132 VIEW-AS COMBO-BOX INNER-LINES 20
134 SIZE 65.72 BY 1 NO-UNDO.
136 DEFINE VARIABLE fil_Approver1
AS CHARACTER FORMAT "X(256)":U
138 SIZE 24 BY 1 NO-UNDO.
140 DEFINE VARIABLE fil_Approver2
AS CHARACTER FORMAT "X(256)":U
142 SIZE 24 BY 1 NO-UNDO.
144 DEFINE VARIABLE fil_copies
AS INTEGER FORMAT "9":U
INITIAL 0
146 SIZE 2.57 BY .8 NO-UNDO.
148 DEFINE VARIABLE fil_Creditor
AS CHARACTER FORMAT "X(256)":U
150 SIZE 56.57 BY 1 NO-UNDO.
152 DEFINE VARIABLE fil_EntityName
AS CHARACTER FORMAT "X(256)":U
154 SIZE 56.57 BY 1 NO-UNDO.
156 DEFINE VARIABLE fil_FY-Budget
AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U
INITIAL 0
162 DEFINE VARIABLE fil_InBudget-1
AS DECIMAL FORMAT "->,>>>,>>9.99":U
INITIAL 0
165 SIZE 10.29 BY 1 NO-UNDO.
167 DEFINE VARIABLE fil_InBudget-2
AS DECIMAL FORMAT "->,>>>,>>9.99":U
INITIAL 0
170 SIZE 10.29 BY 1 NO-UNDO.
172 DEFINE VARIABLE fil_OS-Orders
AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U
INITIAL 0
178 DEFINE VARIABLE fil_OverBudget-1
AS DECIMAL FORMAT "->,>>>,>>9.99":U
INITIAL 0
181 SIZE 10.29 BY 1 NO-UNDO.
183 DEFINE VARIABLE fil_OverBudget-2
AS DECIMAL FORMAT "->,>>>,>>9.99":U
INITIAL 0
186 SIZE 10.29 BY 1 NO-UNDO.
188 DEFINE VARIABLE fil_Total-Committed
AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U
INITIAL 0
194 DEFINE VARIABLE fil_Wait-Appvl
AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U
INITIAL 0
195 LABEL "Waiting appvl"
200 DEFINE VARIABLE fil_YTD-Budget
AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U
INITIAL 0
206 DEFINE VARIABLE fil_YTD-Spent
AS DECIMAL FORMAT "-ZZ,ZZZ,ZZ9.99":U
INITIAL 0
212 DEFINE RECTANGLE RECT-3
213 EDGE-PIXELS 1 GRAPHIC-EDGE
215 BGCOLOR 0 FGCOLOR 0 .
217 DEFINE RECTANGLE RECT-4
218 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
221 DEFINE VARIABLE tgl_set_paid
AS LOGICAL INITIAL no
227 DEFINE VARIABLE tgl_supplier
AS LOGICAL INITIAL no
228 LABEL "Print supplier copy"
234 /* ************************ Frame Definitions
*********************** */
237 Order.EntityType
AT ROW 1.2 COL 9.29 COLON-ALIGNED
241 Order.EntityCode
AT ROW 1.2 COL 11 COLON-ALIGNED NO-LABEL
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
249 Order.OrderDate
AT ROW 2.2 COL 64.72 COLON-ALIGNED
252 cmb_Account
AT ROW 3.2 COL 11 COLON-ALIGNED
253 Order.FirstApprover
AT ROW 4.2 COL 11 COLON-ALIGNED
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
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
270 fil_Creditor
AT ROW 6.6 COL 20.14 COLON-ALIGNED NO-LABEL
271 Order.OrderAmount
AT ROW 8 COL 11 COLON-ALIGNED
275 Order.QuotedAmount
AT ROW 8 COL 35 COLON-ALIGNED
276 LABEL "Quote" FORMAT "->>>,>>>,>>9.99"
279 Order.ApprovedAmount
AT ROW 8 COL 61 COLON-ALIGNED
283 Order.TaxAmount
AT ROW 9.25 COL 61 COLON-ALIGNED
287 Order.Description
AT ROW 9.6 COL 1.57 NO-LABEL
288 VIEW-AS EDITOR SCROLLBAR-VERTICAL
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
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
308 SIZE 3.57 BY .8 AT ROW 18 COL 56.86
310 "Description" VIEW-AS TEXT
311 SIZE 8 BY .8 AT ROW 8.8 COL 2.14
313 "office copies of order." VIEW-AS TEXT
314 SIZE 14.14 BY .8 AT ROW 18 COL 63.43
316 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
317 SIDE-LABELS NO-UNDERLINE THREE-D
318 AT COL 1 ROW 1 SCROLLABLE
322 /* *********************** Procedure Settings
************************ */
324 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
325 /* Settings for
THIS-PROCEDURE
327 External Tables
: TTPL.Order
328 Allow
: Basic
,DB-Fields
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.
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
351 /* END WINDOW DEFINITION
*/
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
}
362 /* _UIB-CODE-BLOCK-END
*/
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
*/
376 FRAME F-Main
:SCROLLABLE = FALSE
377 FRAME F-Main
:HIDDEN = TRUE.
379 /* SETTINGS
FOR FILL-IN Order.ApprovedAmount
IN FRAME F-Main
381 /* SETTINGS
FOR FILL-IN Order.EntityCode
IN FRAME F-Main
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
387 /* SETTINGS
FOR FILL-IN fil_Approver2
IN FRAME F-Main
389 /* SETTINGS
FOR FILL-IN fil_Creditor
IN FRAME F-Main
391 /* SETTINGS
FOR FILL-IN fil_EntityName
IN FRAME F-Main
393 /* SETTINGS
FOR FILL-IN fil_FY-Budget
IN FRAME F-Main
395 /* SETTINGS
FOR FILL-IN fil_InBudget-1
IN FRAME F-Main
397 /* SETTINGS
FOR FILL-IN fil_InBudget-2
IN FRAME F-Main
399 /* SETTINGS
FOR FILL-IN fil_OS-Orders
IN FRAME F-Main
401 /* SETTINGS
FOR FILL-IN fil_OverBudget-1
IN FRAME F-Main
403 /* SETTINGS
FOR FILL-IN fil_OverBudget-2
IN FRAME F-Main
405 /* SETTINGS
FOR FILL-IN fil_Total-Committed
IN FRAME F-Main
407 /* SETTINGS
FOR FILL-IN fil_Wait-Appvl
IN FRAME F-Main
409 /* SETTINGS
FOR FILL-IN fil_YTD-Budget
IN FRAME F-Main
411 /* SETTINGS
FOR FILL-IN fil_YTD-Spent
IN FRAME F-Main
413 /* SETTINGS
FOR FILL-IN Order.FirstApprover
IN FRAME F-Main
415 /* SETTINGS
FOR FILL-IN Order.OrderAmount
IN FRAME F-Main
417 /* SETTINGS
FOR FILL-IN Order.OrderCode
IN FRAME F-Main
419 /* SETTINGS
FOR FILL-IN Order.OverridePaid
IN FRAME F-Main
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
425 /* SETTINGS
FOR FILL-IN Order.TaxAmount
IN FRAME F-Main
427 /* _RUN-TIME-ATTRIBUTES-END
*/
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
437 */ /* FRAME F-Main
*/
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.
453 /* _UIB-CODE-BLOCK-END
*/
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.
464 /* _UIB-CODE-BLOCK-END
*/
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"}
475 /* _UIB-CODE-BLOCK-END
*/
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.
486 /* _UIB-CODE-BLOCK-END
*/
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.
497 /* _UIB-CODE-BLOCK-END
*/
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"}
508 /* _UIB-CODE-BLOCK-END
*/
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 ).
521 /* _UIB-CODE-BLOCK-END
*/
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"}
531 /* _UIB-CODE-BLOCK-END
*/
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"}
542 /* _UIB-CODE-BLOCK-END
*/
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 ).
555 /* _UIB-CODE-BLOCK-END
*/
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"}
565 /* _UIB-CODE-BLOCK-END
*/
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"}
576 /* _UIB-CODE-BLOCK-END
*/
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"}
586 /* _UIB-CODE-BLOCK-END
*/
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"}
596 /* _UIB-CODE-BLOCK-END
*/
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"}
607 /* _UIB-CODE-BLOCK-END
*/
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) .
623 /* _UIB-CODE-BLOCK-END
*/
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.
639 /* _UIB-CODE-BLOCK-END
*/
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.
653 /* _UIB-CODE-BLOCK-END
*/
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"}
664 /* _UIB-CODE-BLOCK-END
*/
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.
675 /* _UIB-CODE-BLOCK-END
*/
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.
686 /* _UIB-CODE-BLOCK-END
*/
692 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK V-table-Win
695 /* *************************** Main Block
*************************** */
697 /* _UIB-CODE-BLOCK-END
*/
701 /* ********************** Internal Procedures
*********************** */
703 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE account-value-changed V-table-Win
704 PROCEDURE account-value-changed
:
705 /*------------------------------------------------------------------------------
707 ------------------------------------------------------------------------------*/
708 /* RUN show-budget-info.
*/
711 /* _UIB-CODE-BLOCK-END
*/
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.
720 ------------------------------------------------------------------------------*/
722 /* No Foreign keys are accepted by this SmartObject.
*/
726 /* _UIB-CODE-BLOCK-END
*/
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.
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
}
757 /* _UIB-CODE-BLOCK-END
*/
760 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cancel-changes V-table-Win
761 PROCEDURE cancel-changes
:
762 /*------------------------------------------------------------------------------
766 ------------------------------------------------------------------------------*/
768 RUN notify
( 'hide
, CONTAINER-SOURCE'
:U
).
772 RUN check-modified
( "CLEAR" ).
773 RUN dispatch
( 'exit'
:U
).
777 /* _UIB-CODE-BLOCK-END
*/
780 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE confirm-changes V-table-Win
781 PROCEDURE confirm-changes
:
782 /*------------------------------------------------------------------------------
784 ------------------------------------------------------------------------------*/
786 prev-amount
= Order.ApprovedAmount.
789 IF RETURN-VALUE = "FAIL" THEN RETURN.
791 RUN dispatch
( 'update-record'
:U
).
793 IF mode
= "Add" THEN RUN notify
( 'open-query
, RECORD-SOURCE'
:U
).
794 RUN dispatch
( 'exit'
:U
).
798 /* _UIB-CODE-BLOCK-END
*/
801 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE delete-order V-table-Win
802 PROCEDURE delete-order
:
803 /*------------------------------------------------------------------------------
805 ------------------------------------------------------------------------------*/
807 FIND CURRENT Order
EXCLUSIVE-LOCK NO-ERROR.
808 IF AVAILABLE Order
THEN DELETE Order.
812 /* _UIB-CODE-BLOCK-END
*/
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
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.
*/
827 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
830 /* _UIB-CODE-BLOCK-END
*/
833 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE entity-code-changed V-table-Win
834 PROCEDURE entity-code-changed
:
835 /*------------------------------------------------------------------------------
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) .
851 /* _UIB-CODE-BLOCK-END
*/
854 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-account V-table-Win
855 PROCEDURE get-account
:
856 /*------------------------------------------------------------------------------
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".
871 /* _UIB-CODE-BLOCK-END
*/
874 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-accounts V-table-Win
875 PROCEDURE get-accounts
:
876 /*------------------------------------------------------------------------------
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.
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.
907 account-descriptions
= account-descriptions
908 + (IF account-codes
= "" THEN "" ELSE "~n")
910 account-codes
= account-codes
+ (IF account-codes
= "" THEN "" ELSE ",")
911 + STRING( ProjectBudget.AccountCode
, "9999.99" ).
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" ).
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 .
945 /* _UIB-CODE-BLOCK-END
*/
948 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-parent-keys V-table-Win
949 PROCEDURE get-parent-keys
:
950 /*------------------------------------------------------------------------------
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
).
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".
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 .
*/
980 /* _UIB-CODE-BLOCK-END
*/
983 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-assign-statement V-table-Win
984 PROCEDURE inst-assign-statement
:
985 /*------------------------------------------------------------------------------
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.
1007 Order.EntityType
= "J".
1008 Order.EntityCode
= Order.ProjectCode.
1016 /* _UIB-CODE-BLOCK-END
*/
1019 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-disable-fields V-table-Win
1020 PROCEDURE inst-disable-fields
:
1021 /*------------------------------------------------------------------------------
1023 ------------------------------------------------------------------------------*/
1024 cmb_Account
:SENSITIVE IN FRAME {&FRAME-NAME} = NO.
1025 RUN set-link-attributes
IN sys-mgr
( THIS-PROCEDURE,
1026 "*", "SENSITIVE = No" ).
1029 /* _UIB-CODE-BLOCK-END
*/
1032 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-display-fields V-table-Win
1033 PROCEDURE inst-display-fields
:
1034 /*------------------------------------------------------------------------------
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.
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
)
1058 FIND ChartOfAccount
WHERE ChartOfAccount.AccountCode
= Order.AccountCode
NO-LOCK.
1059 item
= item
+ ChartOfAccount.Name.
1062 item
= item
+ projectBudget.Description .
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.
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.
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 ).
1085 /* _UIB-CODE-BLOCK-END
*/
1088 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-enable-fields V-table-Win
1089 PROCEDURE inst-enable-fields
:
1090 /*------------------------------------------------------------------------------
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".
1100 RUN set-paid-changed.
1104 /* _UIB-CODE-BLOCK-END
*/
1107 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-initialize V-table-Win
1108 PROCEDURE inst-initialize
:
1109 /*------------------------------------------------------------------------------
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
<> ?
).
1122 DISPLAY tgl_set_paid
WITH FRAME {&FRAME-NAME}.
1123 RUN set-paid-changed.
1125 IF mode
= "Add" THEN DO:
1127 RUN dispatch
( 'add-record'
:U
).
1129 ELSE IF mode
= "View" THEN
1130 RUN dispatch
( 'disable-fields'
:U
).
1132 RUN dispatch
( 'enable-fields'
:U
).
1136 /* _UIB-CODE-BLOCK-END
*/
1139 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-row-available V-table-Win
1140 PROCEDURE inst-row-available
:
1141 /*------------------------------------------------------------------------------
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.
1153 Order.EntityType
= "J".
1154 Order.EntityCode
= Order.ProjectCode.
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.
1167 /* _UIB-CODE-BLOCK-END
*/
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
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.
*/
1187 /* _UIB-CODE-BLOCK-END
*/
1190 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE order-number-changed V-table-Win
1191 PROCEDURE order-number-changed
:
1192 /*------------------------------------------------------------------------------
1196 ------------------------------------------------------------------------------*/
1199 DISPLAY fil_Copies
WITH FRAME {&FRAME-NAME}.
1203 /* _UIB-CODE-BLOCK-END
*/
1206 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE override-add-record V-table-Win
1207 PROCEDURE override-add-record
:
1208 /*------------------------------------------------------------------------------
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:
1220 entity-type
= Project.EntityType.
1221 entity-code
= Project.EntityCode.
1222 /* MESSAGE entity-type entity-code.
*/
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.
1235 ON FIND OF Order
REVERT.
1237 /* MESSAGE entity-type entity-code last-order.
*/
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.
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.
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.
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").
1287 /* _UIB-CODE-BLOCK-END
*/
1290 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE override-row-available V-table-Win
1291 PROCEDURE override-row-available
:
1292 /*------------------------------------------------------------------------------
1294 ------------------------------------------------------------------------------*/
1295 IF ( mode
<> "Add" ) THEN RUN adm-row-available.
1298 /* _UIB-CODE-BLOCK-END
*/
1301 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-destroy V-table-Win
1302 PROCEDURE pre-destroy
:
1303 /*------------------------------------------------------------------------------
1307 ------------------------------------------------------------------------------*/
1309 IF LAST-EVENT:FUNCTION = "WINDOW-CLOSE":U
THEN RUN cancel-changes.
1313 /* _UIB-CODE-BLOCK-END
*/
1316 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-initialize V-table-Win
1317 PROCEDURE pre-initialize
:
1318 /*------------------------------------------------------------------------------
1322 ------------------------------------------------------------------------------*/
1324 RUN get-parent-keys.
1329 /* _UIB-CODE-BLOCK-END
*/
1332 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-order V-table-Win
1333 PROCEDURE print-order
:
1334 /*------------------------------------------------------------------------------
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
).
1355 /* _UIB-CODE-BLOCK-END
*/
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
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
}
1379 /* _UIB-CODE-BLOCK-END
*/
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
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
}
1401 /* _UIB-CODE-BLOCK-END
*/
1404 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-paid-changed V-table-Win
1405 PROCEDURE set-paid-changed
:
1406 /*------------------------------------------------------------------------------
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.
1417 DISPLAY Order.OverridePaid.
1423 /* _UIB-CODE-BLOCK-END
*/
1426 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE show-budget-info V-table-Win
1427 PROCEDURE show-budget-info
:
1428 /*------------------------------------------------------------------------------
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}:
1447 fil_Total-Committed
= 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.
1459 FIND FIRST Month
OF FinancialYear
NO-LOCK. m1
= Month.MonthCode.
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.
1480 MESSAGE "AB:" AccountBalance.EntityType AccountBalance.EntityCode AccountBalance.AccountCode
1481 AccountBalance.MonthCode AccountBalance.Budget AccountBalance.Balance .
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.
1500 IF Voucher.VoucherStatus
<> "C" THEN DO:
1501 fil_OS-Orders
= fil_OS-Orders
- Voucher.GoodsValue.
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.
1517 IF Voucher.VoucherStatus
<> "C" THEN DO:
1518 fil_OS-Orders
= fil_OS-Orders
- Voucher.GoodsValue.
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.
1530 /* _UIB-CODE-BLOCK-END
*/
1533 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed V-table-Win
1534 PROCEDURE state-changed
:
1535 /* -----------------------------------------------------------
1539 -------------------------------------------------------------*/
1540 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
1541 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
1544 /* Object instance CASEs can go here to replace standard behavior
1545 or add new cases.
*/
1546 {src
/adm
/template
/vstates.i
}
1550 /* _UIB-CODE-BLOCK-END
*/
1553 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE supplier-copies-changed V-table-Win
1554 PROCEDURE supplier-copies-changed
:
1555 /*------------------------------------------------------------------------------
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.
1568 fil_Copies
= fil_Copies
+ 1.
1570 DISPLAY fil_copies
WITH FRAME {&FRAME-NAME}.
1576 /* _UIB-CODE-BLOCK-END
*/
1579 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-approver-limits V-table-Win
1580 PROCEDURE update-approver-limits
:
1581 /*------------------------------------------------------------------------------
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 ).
1598 /* _UIB-CODE-BLOCK-END
*/
1601 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-mode V-table-Win
1602 PROCEDURE use-mode
:
1603 /*------------------------------------------------------------------------------
1605 ------------------------------------------------------------------------------*/
1606 DEF INPUT PARAMETER new-mode
AS CHAR NO-UNDO.
1610 /* _UIB-CODE-BLOCK-END
*/
1613 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-order V-table-Win
1614 PROCEDURE verify-order
:
1615 /*------------------------------------------------------------------------------
1617 ------------------------------------------------------------------------------*/
1619 DO WITH FRAME {&FRAME-NAME}:
1621 CASE INPUT Order.EntityType
:
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.
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.
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.
1650 MESSAGE "The entity type is invalid." VIEW-AS ALERT-BOX ERROR
1651 TITLE "Invalid Entity Type".
1652 APPLY '
ENTRY'
:U
TO Order.EntityType.
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.
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.
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.
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
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.
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.
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.
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.
1719 /* _UIB-CODE-BLOCK-END
*/
1722 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-order-amount V-table-Win
1723 PROCEDURE verify-order-amount
:
1724 /*------------------------------------------------------------------------------
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".
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 .
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.
1767 /* _UIB-CODE-BLOCK-END
*/