1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS B-table-Win
8 /*------------------------------------------------------------------------
9 ------------------------------------------------------------------------*/
11 /* *************************** Definitions
************************** */
13 {inc
/topic
/tptenant.i
}
15 DEF VAR related-entity
AS CHAR FORMAT "X(8)" COLUMN-LABEL "Entity" NO-UNDO.
16 DEF VAR tenant-balance
AS DEC FORMAT '
->,>>>,>>9.99'
COLUMN-LABEL "Balance" NO-UNDO.
17 DEF VAR active-flag
AS LOGI
NO-UNDO.
18 DEF VAR entity-code
AS CHAR NO-UNDO FORMAT "X(8)".
19 DEF VAR filter-at
AS CHAR NO-UNDO.
21 DEF VAR gap-1
AS CHAR FORMAT "X" LABEL "" NO-UNDO.
22 DEF VAR gap-2
AS CHAR FORMAT "X" LABEL "" NO-UNDO.
23 DEF VAR gap-3
AS CHAR FORMAT "X" LABEL "" NO-UNDO.
26 {inc
/ofc-acct.i
"DEBTORS" "sundry-debtors"}
28 /* _UIB-CODE-BLOCK-END
*/
32 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
34 /* ******************** Preprocessor Definitions
******************** */
36 &Scoped-define PROCEDURE-TYPE SmartBrowser
38 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
40 /* Name of first Frame and
/or Browse and
/or first Query
*/
41 &Scoped-define FRAME-NAME F-Main
42 &Scoped-define BROWSE-NAME br_table
44 /* Internal Tables
(found by Frame
, Query
& Browse Queries) */
45 &Scoped-define INTERNAL-TABLES Tenant
47 /* Define KEY-PHRASE in case it is used by any query.
*/
48 &Scoped-define KEY-PHRASE TRUE
50 /* Definitions for
BROWSE br_table
*/
51 &Scoped-define FIELDS-IN-QUERY-br_table Tenant.TenantCode Tenant.Active ~
52 Tenant.EntityType
+ STRING( Tenant.EntityCode
, IF Tenant.EntityType
= 'L'
THEN '
999'
ELSE '
99999'
) @ related-entity ~
53 gap-3 @ gap-3 Tenant.Name
54 &Scoped-define ENABLED-FIELDS-IN-QUERY-br_table Tenant.Active
55 &Scoped-define FIELD-PAIRS-IN-QUERY-br_table~
56 ~
{&FP1}Active ~{&FP2}Active ~{&FP3}
57 &Scoped-define ENABLED-TABLES-IN-QUERY-br_table Tenant
58 &Scoped-define FIRST-ENABLED-TABLE-IN-QUERY-br_table Tenant
59 &Scoped-define OPEN-QUERY-br_table OPEN QUERY br_table FOR EACH Tenant WHERE ~{&KEY-PHRASE} ~
60 AND ( active-flag
= ?
OR Tenant.Active
= active-flag
) AND ~
61 Tenant.Name
MATCHES filter-at
NO-LOCK ~
63 &Scoped-define TABLES-IN-QUERY-br_table Tenant
64 &Scoped-define FIRST-TABLE-IN-QUERY-br_table Tenant
67 /* Definitions for
FRAME F-Main
*/
69 /* Standard List Definitions
*/
70 &Scoped-Define ENABLED-OBJECTS br_table
72 /* Custom List Definitions
*/
73 /* List-1
,List-2
,List-3
,List-4
,List-5
,List-6
*/
75 /* _UIB-PREPROCESSOR-BLOCK-END
*/
79 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" B-table-Win _INLINE
80 /* Actions
: ? adm
/support
/keyedit.w ? ? ?
*/
86 TenantCode||y|TTPL.Tenant.TenantCode
87 NoteCode||y|TTPL.Tenant.NoteCode
90 **************************
91 * Set attributes related to FOREIGN
KEYS
93 RUN set-attribute-list
(
95 Keys-Supplied
= "TenantCode,NoteCode"'
:U
).
97 /* Tell the ADM to use the OPEN-QUERY-CASES.
*/
98 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
99 /**************************
101 /* _UIB-CODE-BLOCK-END
*/
104 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Advanced Query Options" B-table-Win _INLINE
105 /* Actions
: ? adm
/support
/advqedit.w ? ? ?
*/
111 Name|y||TTPL.Tenant.Name|yes
112 Code|||TTPL.Tenant.TenantCode|yes
113 Property|||TTPL.Tenant.EntityType|no
,TTPL.Tenant.EntityCode|yes
116 ************************
117 * Set attributes related to SORTBY-OPTIONS
*/
118 RUN set-attribute-list
(
119 'SortBy-Options
= "Name,Code,Property",
120 SortBy-Case
= Name'
:U
).
122 /* Tell the ADM to use the OPEN-QUERY-CASES.
*/
123 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
125 /* This SmartObject is a valid SortBy-Target.
*/
126 &IF '{&user-supported-links}':U ne '':U &THEN
127 &Scoped-define user-supported-links {&user-supported-links},SortBy-Target
129 &Scoped-define user-supported-links SortBy-Target
132 /************************
135 </FILTER-ATTRIBUTES
> */
137 /* _UIB-CODE-BLOCK-END
*/
141 /* *********************** Control Definitions
********************** */
144 /* Definitions of the field level widgets
*/
145 /* Query definitions
*/
147 DEFINE QUERY br_table
FOR
149 FIELDS(Tenant.TenantCode
154 Tenant.Name
) SCROLLING.
157 /* Browse definitions
*/
158 DEFINE BROWSE br_table
159 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br_table B-table-Win _STRUCTURED
160 QUERY br_table
NO-LOCK DISPLAY
161 Tenant.TenantCode
COLUMN-LABEL "Tenant" FORMAT ">99999"
162 Tenant.Active
COLUMN-LABEL "A" FORMAT "Y/N"
163 Tenant.EntityType
+ STRING( Tenant.EntityCode
, IF Tenant.EntityType
= 'L'
THEN '
999'
ELSE '
99999'
) @ related-entity
165 Tenant.Name
FORMAT "X(70)"
168 /* _UIB-CODE-BLOCK-END
*/
170 WITH NO-ASSIGN NO-ROW-MARKERS SEPARATORS SIZE 78.86 BY 13.4
174 /* ************************ Frame Definitions
*********************** */
177 br_table
AT ROW 1 COL 1
178 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
179 SIDE-LABELS NO-UNDERLINE THREE-D
180 AT COL 1 ROW 1 SCROLLABLE
184 /* *********************** Procedure Settings
************************ */
186 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
187 /* Settings for
THIS-PROCEDURE
191 Add Fields to
: EXTERNAL-TABLES
192 Other Settings
: PERSISTENT-ONLY
COMPILE
195 /* This procedure should always be
RUN PERSISTENT. Report the error
, */
196 /* then cleanup and return.
*/
197 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
198 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
199 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
203 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
205 /* ************************* Create Window
************************** */
207 &ANALYZE-SUSPEND _CREATE-WINDOW
208 /* DESIGN Window definition
(used by the UIB
)
209 CREATE WINDOW B-table-Win
ASSIGN
212 /* END WINDOW DEFINITION
*/
217 /* *************** Runtime Attributes and UIB Settings
************** */
219 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
220 /* SETTINGS
FOR WINDOW B-table-Win
221 NOT-VISIBLE
,,RUN-PERSISTENT
*/
222 /* SETTINGS
FOR FRAME F-Main
223 NOT-VISIBLE Size-to-Fit
*/
224 /* BROWSE-TAB br_table
1 F-Main
*/
226 FRAME F-Main
:SCROLLABLE = FALSE
227 FRAME F-Main
:HIDDEN = TRUE.
229 /* _RUN-TIME-ATTRIBUTES-END
*/
233 /* Setting information for Queries and Browse Widgets fields
*/
235 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br_table
236 /* Query rebuild information for
BROWSE br_table
237 _TblList
= "TTPL.Tenant"
238 _Options
= "NO-LOCK KEY-PHRASE SORTBY-PHRASE"
240 _Where
[1] = "( active-flag = ? OR Tenant.Active = active-flag ) AND
241 Tenant.Name MATCHES filter-at"
242 _FldNameList
[1] > TTPL.Tenant.TenantCode
243 "TenantCode" "Tenant" ">99999" "integer" ? ? ? ? ? ? no ?
244 _FldNameList
[2] > TTPL.Tenant.Active
245 "Active" "A" "Y/N" "logical" ? ? ? ? ? ? yes ?
246 _FldNameList
[3] > "_<CALC>"
247 "Tenant.EntityType + STRING( Tenant.EntityCode, IF Tenant.EntityType = 'L' THEN '999' ELSE '99999' ) @ related-entity" ? ? ? ? ? ? ? ? ? no ?
248 _FldNameList
[4] > "_<CALC>"
249 "gap-3 @ gap-3" ? ? ? ? ? ? ? ? ? no ?
250 _FldNameList
[5] > TTPL.Tenant.Name
251 "Name" ?
"X(70)" "character" ? ? ? ? ? ? no ?
253 */ /* BROWSE br_table
*/
256 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
257 /* Query rebuild information for
FRAME F-Main
260 */ /* FRAME F-Main
*/
266 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB B-table-Win
267 /* ************************* Included-Libraries
*********************** */
269 {src
/adm
/method
/browser.i
}
270 {inc
/method
/m-selvwr.i
}
272 /* _UIB-CODE-BLOCK-END
*/
278 /* ************************ Control Triggers
************************ */
280 &Scoped-define BROWSE-NAME br_table
281 &Scoped-define SELF-NAME br_table
282 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
283 ON ROW-ENTRY
OF br_table
IN FRAME F-Main
285 /* This code displays initial values for newly added or copied rows.
*/
286 {src
/adm
/template
/brsentry.i
}
289 /* _UIB-CODE-BLOCK-END
*/
293 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
294 ON ROW-LEAVE
OF br_table
IN FRAME F-Main
296 /* Do not disable this code or no updates will take place except
297 by pressing the Save button on an Update SmartPanel.
*/
298 {src
/adm
/template
/brsleave.i
}
301 /* _UIB-CODE-BLOCK-END
*/
305 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
306 ON VALUE-CHANGED
OF br_table
IN FRAME F-Main
308 /* This ADM trigger code must be preserved in order to notify other
309 objects when the browser's current row changes.
*/
310 {src
/adm
/template
/brschnge.i
}
314 /* _UIB-CODE-BLOCK-END
*/
320 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK B-table-Win
323 /* *************************** Main Block
*************************** */
325 &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
326 RUN dispatch
IN THIS-PROCEDURE ('initialize'
:U
).
329 Tenant.Active
:READ-ONLY IN BROWSE {&BROWSE-NAME} = Yes.
331 RUN set-attribute-list
( 'FilterBy-Options
= All|Active|Inactive
, FilterBy-Case
= Active'
:U
).
332 RUN set-attribute-list
( 'Filter-Value
= '
).
333 RUN set-attribute-list
( 'SearchBy-Case
= '
).
335 /* _UIB-CODE-BLOCK-END
*/
339 /* ********************** Internal Procedures
*********************** */
341 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-open-query-cases B-table-Win adm/support/_adm-opn.p
342 PROCEDURE adm-open-query-cases
:
343 /*------------------------------------------------------------------------------
344 Purpose
: Opens different cases of the query based on attributes
345 such as the 'Key-Name'
, or 'SortBy-Case'
347 ------------------------------------------------------------------------------*/
349 /* No Foreign keys are accepted by this SmartObject.
*/
351 RUN get-attribute
('SortBy-Case'
:U
).
353 WHEN 'Name'
:U
THEN DO:
354 &Scope SORTBY-PHRASE BY Tenant.Name
355 {&OPEN-QUERY-{&BROWSE-NAME}}
357 WHEN 'Code'
:U
THEN DO:
358 &Scope SORTBY-PHRASE BY Tenant.TenantCode
359 {&OPEN-QUERY-{&BROWSE-NAME}}
361 WHEN 'Property'
:U
THEN DO:
362 &Scope SORTBY-PHRASE BY Tenant.EntityType DESCENDING BY Tenant.EntityCode
363 {&OPEN-QUERY-{&BROWSE-NAME}}
366 &Undefine SORTBY-PHRASE
367 {&OPEN-QUERY-{&BROWSE-NAME}}
368 END.
/* OTHERWISE...
*/
373 /* _UIB-CODE-BLOCK-END
*/
377 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available B-table-Win _ADM-ROW-AVAILABLE
378 PROCEDURE adm-row-available
:
379 /*------------------------------------------------------------------------------
380 Purpose
: Dispatched to this procedure when the Record-
381 Source has a new row available. This procedure
382 tries to get the new row
(or foriegn keys
) from
383 the Record-Source and process it.
385 ------------------------------------------------------------------------------*/
387 /* Define variables needed by this internal procedure.
*/
388 {src
/adm
/template
/row-head.i
}
390 /* Process the newly available records
(i.e. display fields
,
391 open queries
, and
/or pass records on to any RECORD-TARGETS
).
*/
392 {src
/adm
/template
/row-end.i
}
396 /* _UIB-CODE-BLOCK-END
*/
400 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI B-table-Win _DEFAULT-DISABLE
401 PROCEDURE disable_UI
:
402 /*------------------------------------------------------------------------------
403 Purpose
: DISABLE the User Interface
405 Notes
: Here we clean-up the user-interface by deleting
406 dynamic widgets we have created and
/or hide
407 frames. This procedure is usually called when
408 we are ready to
"clean-up" after running.
409 ------------------------------------------------------------------------------*/
410 /* Hide all frames.
*/
412 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
415 /* _UIB-CODE-BLOCK-END
*/
419 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key B-table-Win adm/support/_key-snd.p
421 /*------------------------------------------------------------------------------
422 Purpose
: Sends a requested
KEY value back to the calling
424 Parameters
: <see adm
/template
/sndkytop.i
>
425 ------------------------------------------------------------------------------*/
427 /* Define variables needed by this internal procedure.
*/
428 {src
/adm
/template
/sndkytop.i
}
430 /* Return the key value associated with each key case.
*/
431 {src
/adm
/template
/sndkycas.i
"TenantCode" "Tenant" "TenantCode"}
432 {src
/adm
/template
/sndkycas.i
"NoteCode" "Tenant" "NoteCode"}
434 /* Close the
CASE statement and end the procedure.
*/
435 {src
/adm
/template
/sndkyend.i
}
439 /* _UIB-CODE-BLOCK-END
*/
443 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records B-table-Win _ADM-SEND-RECORDS
444 PROCEDURE send-records
:
445 /*------------------------------------------------------------------------------
446 Purpose
: Send record
ROWID's for all tables used by
448 Parameters
: see template
/snd-head.i
449 ------------------------------------------------------------------------------*/
451 /* Define variables needed by this internal procedure.
*/
452 {src
/adm
/template
/snd-head.i
}
454 /* For each requested table
, put it's
ROWID in the output list.
*/
455 {src
/adm
/template
/snd-list.i
"Tenant"}
457 /* Deal with any unexpected table requests before closing.
*/
458 {src
/adm
/template
/snd-end.i
}
462 /* _UIB-CODE-BLOCK-END
*/
466 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed B-table-Win
467 PROCEDURE state-changed
:
468 /* -----------------------------------------------------------
472 -------------------------------------------------------------*/
473 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
474 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
477 /* Object instance CASEs can go here to replace standard behavior
479 {src
/adm
/template
/bstates.i
}
483 /* _UIB-CODE-BLOCK-END
*/
487 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-Filter-Value B-table-Win
488 PROCEDURE use-Filter-Value
:
489 /*------------------------------------------------------------------------------
493 ------------------------------------------------------------------------------*/
495 DEF INPUT PARAMETER new-filter
AS CHAR NO-UNDO.
496 filter-at
= new-filter
+ '
*'.
500 /* _UIB-CODE-BLOCK-END
*/
504 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-FilterBy-Case B-table-Win
505 PROCEDURE use-FilterBy-Case
:
506 /*------------------------------------------------------------------------------
510 ------------------------------------------------------------------------------*/
512 DEF INPUT PARAMETER new-case
AS CHAR NO-UNDO.
514 IF new-case
= "All" THEN active-flag
= ?.
515 ELSE active-flag
= ( new-case
= "Active" ).
519 /* _UIB-CODE-BLOCK-END
*/
523 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-SearchBy-Case B-table-Win
524 PROCEDURE use-SearchBy-Case
:
525 /*------------------------------------------------------------------------------
529 ------------------------------------------------------------------------------*/
531 DEF INPUT PARAMETER new-filter
AS CHAR NO-UNDO.
532 filter-at
= new-filter
+ '
*'.
536 /* _UIB-CODE-BLOCK-END
*/