Correct rental PSM. Hopefully also fix recoverables/one-offs.
[capital-apms-progress.git] / vwr / sel / b-seltnt.w
blobd2778ed393cd6ae51e86df7068a2c2a7686d443c
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
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 B-table-Win
8 /*------------------------------------------------------------------------
9 ------------------------------------------------------------------------*/
10 CREATE WIDGET-POOL.
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.
25 {inc/ofc-this.i}
26 {inc/ofc-acct.i "DEBTORS" "sundry-debtors"}
28 /* _UIB-CODE-BLOCK-END */
29 &ANALYZE-RESUME
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 ~
62 ~{&SORTBY-PHRASE}.
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 */
76 &ANALYZE-RESUME
79 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" B-table-Win _INLINE
80 /* Actions: ? adm/support/keyedit.w ? ? ? */
81 /* STRUCTURED-DATA
82 <KEY-OBJECT>
83 &BROWSE-NAME
84 </KEY-OBJECT>
85 <FOREIGN-KEYS>
86 TenantCode||y|TTPL.Tenant.TenantCode
87 NoteCode||y|TTPL.Tenant.NoteCode
88 </FOREIGN-KEYS>
89 <EXECUTING-CODE>
90 **************************
91 * Set attributes related to FOREIGN KEYS
93 RUN set-attribute-list (
94 'Keys-Accepted = ,
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 /**************************
100 </EXECUTING-CODE> */
101 /* _UIB-CODE-BLOCK-END */
102 &ANALYZE-RESUME
104 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Advanced Query Options" B-table-Win _INLINE
105 /* Actions: ? adm/support/advqedit.w ? ? ? */
106 /* STRUCTURED-DATA
107 <KEY-OBJECT>
108 &BROWSE-NAME
109 </KEY-OBJECT>
110 <SORTBY-OPTIONS>
111 Name|y||TTPL.Tenant.Name|yes
112 Code|||TTPL.Tenant.TenantCode|yes
113 Property|||TTPL.Tenant.EntityType|no,TTPL.Tenant.EntityCode|yes
114 </SORTBY-OPTIONS>
115 <SORTBY-RUN-CODE>
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
128 &ELSE
129 &Scoped-define user-supported-links SortBy-Target
130 &ENDIF
132 /************************
133 </SORTBY-RUN-CODE>
134 <FILTER-ATTRIBUTES>
135 </FILTER-ATTRIBUTES> */
137 /* _UIB-CODE-BLOCK-END */
138 &ANALYZE-RESUME
141 /* *********************** Control Definitions ********************** */
144 /* Definitions of the field level widgets */
145 /* Query definitions */
146 &ANALYZE-SUSPEND
147 DEFINE QUERY br_table FOR
148 Tenant
149 FIELDS(Tenant.TenantCode
150 Tenant.Active
151 Tenant.EntityType
152 Tenant.EntityCode
153 Tenant.EntityType
154 Tenant.Name) SCROLLING.
155 &ANALYZE-RESUME
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
164 gap-3 @ gap-3
165 Tenant.Name FORMAT "X(70)"
166 ENABLE
167 Tenant.Active
168 /* _UIB-CODE-BLOCK-END */
169 &ANALYZE-RESUME
170 WITH NO-ASSIGN NO-ROW-MARKERS SEPARATORS SIZE 78.86 BY 13.4
171 BGCOLOR 15 .
174 /* ************************ Frame Definitions *********************** */
176 DEFINE FRAME F-Main
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
181 FGCOLOR 0 .
184 /* *********************** Procedure Settings ************************ */
186 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
187 /* Settings for THIS-PROCEDURE
188 Type: SmartBrowser
189 Allow: Basic,Browse
190 Frames: 1
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.
200 RETURN.
201 END.
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
210 HEIGHT = 16.1
211 WIDTH = 80.
212 /* END WINDOW DEFINITION */
214 &ANALYZE-RESUME
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 */
225 ASSIGN
226 FRAME F-Main:SCROLLABLE = FALSE
227 FRAME F-Main:HIDDEN = TRUE.
229 /* _RUN-TIME-ATTRIBUTES-END */
230 &ANALYZE-RESUME
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"
239 _TblOptList = "USED"
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 ?
252 _Query is NOT OPENED
253 */ /* BROWSE br_table */
254 &ANALYZE-RESUME
256 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
257 /* Query rebuild information for FRAME F-Main
258 _Options = "NO-LOCK"
259 _Query is NOT OPENED
260 */ /* FRAME F-Main */
261 &ANALYZE-RESUME
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 */
273 &ANALYZE-RESUME
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}
287 END.
289 /* _UIB-CODE-BLOCK-END */
290 &ANALYZE-RESUME
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}
299 END.
301 /* _UIB-CODE-BLOCK-END */
302 &ANALYZE-RESUME
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}
312 END.
314 /* _UIB-CODE-BLOCK-END */
315 &ANALYZE-RESUME
318 &UNDEFINE SELF-NAME
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).
327 &ENDIF
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 */
336 &ANALYZE-RESUME
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'
346 Parameters: <none>
347 ------------------------------------------------------------------------------*/
349 /* No Foreign keys are accepted by this SmartObject. */
351 RUN get-attribute ('SortBy-Case':U).
352 CASE RETURN-VALUE:
353 WHEN 'Name':U THEN DO:
354 &Scope SORTBY-PHRASE BY Tenant.Name
355 {&OPEN-QUERY-{&BROWSE-NAME}}
356 END.
357 WHEN 'Code':U THEN DO:
358 &Scope SORTBY-PHRASE BY Tenant.TenantCode
359 {&OPEN-QUERY-{&BROWSE-NAME}}
360 END.
361 WHEN 'Property':U THEN DO:
362 &Scope SORTBY-PHRASE BY Tenant.EntityType DESCENDING BY Tenant.EntityCode
363 {&OPEN-QUERY-{&BROWSE-NAME}}
364 END.
365 OTHERWISE DO:
366 &Undefine SORTBY-PHRASE
367 {&OPEN-QUERY-{&BROWSE-NAME}}
368 END. /* OTHERWISE...*/
369 END CASE.
371 END PROCEDURE.
373 /* _UIB-CODE-BLOCK-END */
374 &ANALYZE-RESUME
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.
384 Parameters: <none>
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}
394 END PROCEDURE.
396 /* _UIB-CODE-BLOCK-END */
397 &ANALYZE-RESUME
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
404 Parameters: <none>
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. */
411 HIDE FRAME F-Main.
412 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
413 END PROCEDURE.
415 /* _UIB-CODE-BLOCK-END */
416 &ANALYZE-RESUME
419 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key B-table-Win adm/support/_key-snd.p
420 PROCEDURE send-key :
421 /*------------------------------------------------------------------------------
422 Purpose: Sends a requested KEY value back to the calling
423 SmartObject.
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}
437 END PROCEDURE.
439 /* _UIB-CODE-BLOCK-END */
440 &ANALYZE-RESUME
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
447 this file.
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}
460 END PROCEDURE.
462 /* _UIB-CODE-BLOCK-END */
463 &ANALYZE-RESUME
466 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed B-table-Win
467 PROCEDURE state-changed :
468 /* -----------------------------------------------------------
469 Purpose:
470 Parameters: <none>
471 Notes:
472 -------------------------------------------------------------*/
473 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
474 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
476 CASE p-state:
477 /* Object instance CASEs can go here to replace standard behavior
478 or add new cases. */
479 {src/adm/template/bstates.i}
480 END CASE.
481 END PROCEDURE.
483 /* _UIB-CODE-BLOCK-END */
484 &ANALYZE-RESUME
487 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-Filter-Value B-table-Win
488 PROCEDURE use-Filter-Value :
489 /*------------------------------------------------------------------------------
490 Purpose:
491 Parameters: <none>
492 Notes:
493 ------------------------------------------------------------------------------*/
495 DEF INPUT PARAMETER new-filter AS CHAR NO-UNDO.
496 filter-at = new-filter + '*'.
498 END PROCEDURE.
500 /* _UIB-CODE-BLOCK-END */
501 &ANALYZE-RESUME
504 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-FilterBy-Case B-table-Win
505 PROCEDURE use-FilterBy-Case :
506 /*------------------------------------------------------------------------------
507 Purpose:
508 Parameters: <none>
509 Notes:
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" ).
517 END PROCEDURE.
519 /* _UIB-CODE-BLOCK-END */
520 &ANALYZE-RESUME
523 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-SearchBy-Case B-table-Win
524 PROCEDURE use-SearchBy-Case :
525 /*------------------------------------------------------------------------------
526 Purpose:
527 Parameters: <none>
528 Notes:
529 ------------------------------------------------------------------------------*/
531 DEF INPUT PARAMETER new-filter AS CHAR NO-UNDO.
532 filter-at = new-filter + '*'.
534 END PROCEDURE.
536 /* _UIB-CODE-BLOCK-END */
537 &ANALYZE-RESUME