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 ------------------------------------------------------------------------*/
13 /* *************************** Definitions
************************** */
15 {inc
/topic
/tpperson.i
}
16 DEF VAR FullName
AS CHAR NO-UNDO.
17 DEF VAR type-list
AS CHAR NO-UNDO.
18 DEF VAR filter-value
AS CHAR NO-UNDO.
19 DEF VAR contact-type
AS CHAR NO-UNDO.
21 &SCOPED-DEFINE FILTER-PHRASE TRUE
24 {inc
/ofc-set.i
"Contacts-Staff" "staff-contact-type"}
25 IF NOT AVAILABLE(OfficeSetting
) THEN staff-contact-type
= "SF".
27 /* _UIB-CODE-BLOCK-END
*/
31 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
33 /* ******************** Preprocessor Definitions
******************** */
35 &Scoped-define PROCEDURE-TYPE SmartBrowser
37 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
39 /* Name of first Frame and
/or Browse and
/or first Query
*/
40 &Scoped-define FRAME-NAME F-Main
41 &Scoped-define BROWSE-NAME br_table
43 /* Internal Tables
(found by Frame
, Query
& Browse Queries) */
44 &Scoped-define INTERNAL-TABLES Contact Person
46 /* Define KEY-PHRASE in case it is used by any query.
*/
47 &Scoped-define KEY-PHRASE TRUE
49 /* Definitions for
BROWSE br_table
*/
50 &Scoped-define FIELDS-IN-QUERY-br_table ~
51 Person.FirstName
+ ' '
+ Person.LastName @ FullName Person.Company ~
53 &Scoped-define ENABLED-FIELDS-IN-QUERY-br_table
54 &Scoped-define FIELD-PAIRS-IN-QUERY-br_table
55 &Scoped-define OPEN-QUERY-br_table OPEN QUERY br_table FOR EACH Contact WHERE ~{&KEY-PHRASE} ~
56 AND Contact.ContactType
= contact-type
NO-LOCK, ~
57 FIRST Person
OF Contact
NO-LOCK ~
59 &Scoped-define TABLES-IN-QUERY-br_table Contact Person
60 &Scoped-define FIRST-TABLE-IN-QUERY-br_table Contact
63 /* Definitions for
FRAME F-Main
*/
65 /* Standard List Definitions
*/
66 &Scoped-Define ENABLED-OBJECTS br_table
68 /* Custom List Definitions
*/
69 /* List-1
,List-2
,List-3
,List-4
,List-5
,List-6
*/
71 /* _UIB-PREPROCESSOR-BLOCK-END
*/
75 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" B-table-Win _INLINE
76 /* Actions
: ? adm
/support
/keyedit.w ? ? ?
*/
82 PersonCode||y|TTPL.Contact.PersonCode
85 **************************
86 * Set attributes related to FOREIGN
KEYS
88 RUN set-attribute-list
(
90 Keys-Supplied
= "PersonCode"'
:U
).
92 /* Tell the ADM to use the OPEN-QUERY-CASES.
*/
93 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
94 /**************************
96 /* _UIB-CODE-BLOCK-END
*/
99 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Advanced Query Options" B-table-Win _INLINE
100 /* Actions
: ? adm
/support
/advqedit.w ? ? ?
*/
106 Company Name|||TTPL.Person.Company|yes
107 Last Name|y||TTPL.Person.LastName|yes
110 ************************
111 * Set attributes related to SORTBY-OPTIONS
*/
112 RUN set-attribute-list
(
113 'SortBy-Options
= "Company Name,Last Name",
114 Sort-Case
= Last Name'
:U
).
116 /* Tell the ADM to use the OPEN-QUERY-CASES.
*/
117 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
119 /* This SmartObject is a valid SortBy-Target.
*/
120 &IF '{&user-supported-links}':U ne '':U &THEN
121 &Scoped-define user-supported-links {&user-supported-links},SortBy-Target
123 &Scoped-define user-supported-links SortBy-Target
126 /************************
129 </FILTER-ATTRIBUTES
> */
131 /* _UIB-CODE-BLOCK-END
*/
135 /* *********************** Control Definitions
********************** */
138 /* Definitions of the field level widgets
*/
139 /* Query definitions
*/
141 DEFINE QUERY br_table
FOR
146 /* Browse definitions
*/
147 DEFINE BROWSE br_table
148 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br_table B-table-Win _STRUCTURED
149 QUERY br_table
NO-LOCK DISPLAY
150 Person.FirstName
+ ' '
+ Person.LastName @ FullName
COLUMN-LABEL "Full Name" FORMAT "X(25)"
151 Person.Company
FORMAT "X(60)"
152 Person.Preferred
FORMAT "X(20)"
153 /* _UIB-CODE-BLOCK-END
*/
155 WITH NO-ASSIGN SEPARATORS SIZE 80.57 BY 14.8
159 /* ************************ Frame Definitions
*********************** */
162 br_table
AT ROW 1 COL 1
163 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
164 SIDE-LABELS NO-UNDERLINE THREE-D
165 AT COL 1 ROW 1 SCROLLABLE
169 /* *********************** Procedure Settings
************************ */
171 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
172 /* Settings for
THIS-PROCEDURE
176 Add Fields to
: EXTERNAL-TABLES
177 Other Settings
: PERSISTENT-ONLY
COMPILE
180 /* This procedure should always be
RUN PERSISTENT. Report the error
, */
181 /* then cleanup and return.
*/
182 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
183 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
184 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
188 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
190 /* ************************* Create Window
************************** */
192 &ANALYZE-SUSPEND _CREATE-WINDOW
193 /* DESIGN Window definition
(used by the UIB
)
194 CREATE WINDOW B-table-Win
ASSIGN
197 /* END WINDOW DEFINITION
*/
202 /* *************** Runtime Attributes and UIB Settings
************** */
204 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
205 /* SETTINGS
FOR WINDOW B-table-Win
206 NOT-VISIBLE
,,RUN-PERSISTENT
*/
207 /* SETTINGS
FOR FRAME F-Main
208 NOT-VISIBLE Size-to-Fit
*/
209 /* BROWSE-TAB br_table
1 F-Main
*/
211 FRAME F-Main
:SCROLLABLE = FALSE
212 FRAME F-Main
:HIDDEN = TRUE.
214 /* _RUN-TIME-ATTRIBUTES-END
*/
218 /* Setting information for Queries and Browse Widgets fields
*/
220 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br_table
221 /* Query rebuild information for
BROWSE br_table
222 _TblList
= "TTPL.Contact,TTPL.Person OF TTPL.Contact"
223 _Options
= "NO-LOCK KEY-PHRASE SORTBY-PHRASE"
224 _TblOptList
= ", FIRST"
225 _Where
[1] = "Contact.ContactType = contact-type"
226 _FldNameList
[1] > "_<CALC>"
227 "Person.FirstName + ' ' + Person.LastName @ FullName" "Full Name" "X(25)" ? ? ? ? ? ? ? no ?
228 _FldNameList
[2] > TTPL.Person.Company
229 "Person.Company" ?
"X(60)" "character" ? ? ? ? ? ? no ?
230 _FldNameList
[3] > TTPL.Person.Preferred
231 "Person.Preferred" ?
"X(20)" "character" ? ? ? ? ? ? no ?
233 */ /* BROWSE br_table
*/
236 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
237 /* Query rebuild information for
FRAME F-Main
240 */ /* FRAME F-Main
*/
246 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB B-table-Win
247 /* ************************* Included-Libraries
*********************** */
249 {src
/adm
/method
/browser.i
}
250 {inc
/method
/m-selvwr.i
}
252 /* _UIB-CODE-BLOCK-END
*/
258 /* ************************ Control Triggers
************************ */
260 &Scoped-define BROWSE-NAME br_table
261 &Scoped-define SELF-NAME br_table
262 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
263 ON ROW-ENTRY
OF br_table
IN FRAME F-Main
265 /* This code displays initial values for newly added or copied rows.
*/
266 {src
/adm
/template
/brsentry.i
}
269 /* _UIB-CODE-BLOCK-END
*/
273 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
274 ON ROW-LEAVE
OF br_table
IN FRAME F-Main
276 /* Do not disable this code or no updates will take place except
277 by pressing the Save button on an Update SmartPanel.
*/
278 {src
/adm
/template
/brsleave.i
}
281 /* _UIB-CODE-BLOCK-END
*/
285 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
286 ON VALUE-CHANGED
OF br_table
IN FRAME F-Main
288 /* This ADM trigger code must be preserved in order to notify other
289 objects when the browser's current row changes.
*/
290 {src
/adm
/template
/brschnge.i
}
294 /* _UIB-CODE-BLOCK-END
*/
300 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK B-table-Win
303 /* *************************** Main Block
*************************** */
305 &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
306 RUN dispatch
IN THIS-PROCEDURE ('initialize'
:U
).
309 RUN set-attribute-list
( 'SortBy-Case
= Last name
, SortBy-Options
= Company name|Last name'
:U
).
312 FOR EACH ContactType
NO-LOCK:
313 type-list
= type-list
+ IF type-list
= "" THEN "" ELSE "|".
314 type-list
= type-list
+ STRING( ContactType.ContactType
, "X(4)") + " - " + TRIM( ContactType.Description
).
317 RUN set-attribute-list
( 'FilterBy-Style
= Combo-Box'
:U
).
318 RUN set-attribute-list
( 'FilterBy-Options
= '
:U
+ type-list
).
319 /* RUN set-attribute-list
( 'Filter-Value
= '
:U
).
*/
321 /* _UIB-CODE-BLOCK-END
*/
325 /* ********************** Internal Procedures
*********************** */
327 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-open-query-cases B-table-Win adm/support/_adm-opn.p
328 PROCEDURE adm-open-query-cases
:
329 /*------------------------------------------------------------------------------
330 Purpose
: Opens different cases of the query based on attributes
331 such as the 'Key-Name'
, or 'SortBy-Case'
333 ------------------------------------------------------------------------------*/
335 /* No Foreign keys are accepted by this SmartObject.
*/
337 RUN get-attribute
('SortBy-Case'
:U
).
339 WHEN 'Company Name'
:U
THEN DO:
340 &Scope SORTBY-PHRASE BY Person.Company
341 {&OPEN-QUERY-{&BROWSE-NAME}}
343 WHEN 'Last Name'
:U
THEN DO:
344 &Scope SORTBY-PHRASE BY Person.LastName
345 {&OPEN-QUERY-{&BROWSE-NAME}}
348 &Undefine SORTBY-PHRASE
349 {&OPEN-QUERY-{&BROWSE-NAME}}
350 END.
/* OTHERWISE...
*/
355 /* _UIB-CODE-BLOCK-END
*/
359 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available B-table-Win _ADM-ROW-AVAILABLE
360 PROCEDURE adm-row-available
:
361 /*------------------------------------------------------------------------------
362 Purpose
: Dispatched to this procedure when the Record-
363 Source has a new row available. This procedure
364 tries to get the new row
(or foriegn keys
) from
365 the Record-Source and process it.
367 ------------------------------------------------------------------------------*/
369 /* Define variables needed by this internal procedure.
*/
370 {src
/adm
/template
/row-head.i
}
372 /* Process the newly available records
(i.e. display fields
,
373 open queries
, and
/or pass records on to any RECORD-TARGETS
).
*/
374 {src
/adm
/template
/row-end.i
}
378 /* _UIB-CODE-BLOCK-END
*/
382 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI B-table-Win _DEFAULT-DISABLE
383 PROCEDURE disable_UI
:
384 /*------------------------------------------------------------------------------
385 Purpose
: DISABLE the User Interface
387 Notes
: Here we clean-up the user-interface by deleting
388 dynamic widgets we have created and
/or hide
389 frames. This procedure is usually called when
390 we are ready to
"clean-up" after running.
391 ------------------------------------------------------------------------------*/
392 /* Hide all frames.
*/
394 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
397 /* _UIB-CODE-BLOCK-END
*/
401 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-open-query-cases B-table-Win
402 PROCEDURE local-open-query-cases
:
403 /*------------------------------------------------------------------------------
404 Purpose
: Override standard ADM method
406 ------------------------------------------------------------------------------*/
408 /* No Foreign keys are accepted by this SmartObject.
*/
410 &Scope TABLE-PHRASE FOR EACH Contact WHERE ~
411 Contact.ContactType
= contact-type
NO-LOCK, ~
412 FIRST Person
OF Contact
NO-LOCK
414 RUN notify
( 'set-busy
,container-source'
:U
).
415 RUN get-attribute
('SortBy-Case'
:U
).
417 WHEN 'Company Name'
:U
THEN DO:
418 &Scope SORTBY-PHRASE BY Person.Company
419 &Scope FILTER-PHRASE Person.Company BEGINS filter-value
420 OPEN QUERY {&BROWSE-NAME} {&TABLE-PHRASE} WHERE {&FILTER-PHRASE} {&SORTBY-PHRASE}.
422 WHEN 'Last Name'
:U
THEN DO:
423 &Scope SORTBY-PHRASE BY Person.LastName
424 &Scope FILTER-PHRASE Person.LastName BEGINS filter-value
425 OPEN QUERY {&BROWSE-NAME} {&TABLE-PHRASE} WHERE {&FILTER-PHRASE} {&SORTBY-PHRASE}.
428 &Undefine SORTBY-PHRASE
429 &Scope FILTER-PHRASE TRUE
430 OPEN QUERY {&BROWSE-NAME} {&TABLE-PHRASE} WHERE {&FILTER-PHRASE} {&SORTBY-PHRASE}.
433 RUN notify
( 'set-idle
,container-source'
:U
).
437 /* _UIB-CODE-BLOCK-END
*/
441 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key B-table-Win adm/support/_key-snd.p
443 /*------------------------------------------------------------------------------
444 Purpose
: Sends a requested
KEY value back to the calling
446 Parameters
: <see adm
/template
/sndkytop.i
>
447 ------------------------------------------------------------------------------*/
449 /* Define variables needed by this internal procedure.
*/
450 {src
/adm
/template
/sndkytop.i
}
452 /* Return the key value associated with each key case.
*/
453 {src
/adm
/template
/sndkycas.i
"PersonCode" "Contact" "PersonCode"}
455 /* Close the
CASE statement and end the procedure.
*/
456 {src
/adm
/template
/sndkyend.i
}
460 /* _UIB-CODE-BLOCK-END
*/
464 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records B-table-Win _ADM-SEND-RECORDS
465 PROCEDURE send-records
:
466 /*------------------------------------------------------------------------------
467 Purpose
: Send record
ROWID's for all tables used by
469 Parameters
: see template
/snd-head.i
470 ------------------------------------------------------------------------------*/
472 /* Define variables needed by this internal procedure.
*/
473 {src
/adm
/template
/snd-head.i
}
475 /* For each requested table
, put it's
ROWID in the output list.
*/
476 {src
/adm
/template
/snd-list.i
"Contact"}
477 {src
/adm
/template
/snd-list.i
"Person"}
479 /* Deal with any unexpected table requests before closing.
*/
480 {src
/adm
/template
/snd-end.i
}
484 /* _UIB-CODE-BLOCK-END
*/
488 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed B-table-Win
489 PROCEDURE state-changed
:
490 /* -----------------------------------------------------------
494 -------------------------------------------------------------*/
495 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
496 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
499 /* Object instance CASEs can go here to replace standard behavior
501 {src
/adm
/template
/bstates.i
}
505 /* _UIB-CODE-BLOCK-END
*/
509 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-Filter-Value B-table-Win
510 PROCEDURE use-Filter-Value
:
511 /*------------------------------------------------------------------------------
513 ------------------------------------------------------------------------------*/
514 DEF INPUT PARAMETER new-filter-value
AS CHAR NO-UNDO.
516 filter-value
= new-filter-value.
520 /* _UIB-CODE-BLOCK-END
*/
524 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-FilterBy-Case B-table-Win
525 PROCEDURE use-FilterBy-Case
:
526 /*------------------------------------------------------------------------------
528 ------------------------------------------------------------------------------*/
529 DEF INPUT PARAMETER new-case
AS CHAR NO-UNDO.
531 contact-type
= TRIM( SUBSTR( new-case
, 1, 4 ) ).
532 IF contact-type
= "SF" THEN contact-type
= staff-contact-type.
536 /* _UIB-CODE-BLOCK-END
*/