1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 &IF DEFINED(UIB_IS_RUNNING) &THEN
8 DEF VAR report-options
AS CHAR NO-UNDO INITIAL "".
10 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
13 DEF VAR ctype-list
AS CHAR NO-UNDO.
14 DEF VAR ptype-list
AS CHAR NO-UNDO.
15 DEF VAR phtype-list
AS CHAR NO-UNDO INIT "BUS,FAX,MOB".
16 DEF VAR include-types
AS LOGI
NO-UNDO INIT Yes.
17 DEF VAR merge-list
AS LOGI
NO-UNDO INIT No.
18 DEF VAR page-per-tenant
AS LOGI
NO-UNDO INIT No.
19 DEF VAR entity-type
AS CHAR NO-UNDO INIT "".
20 DEF VAR entity-code
AS INT NO-UNDO.
21 DEF VAR entity-to
AS INT NO-UNDO.
22 DEF VAR entity-description
AS CHAR NO-UNDO.
24 DEF VAR preview
AS LOGI
NO-UNDO INIT No.
25 DEF VAR user-name
AS CHAR NO-UNDO.
26 DEF VAR timeStamp
AS CHAR FORMAT "X(44)" NO-UNDO.
27 DEF VAR out-line
AS CHAR NO-UNDO.
29 DEF TEMP-TABLE ListContact
NO-UNDO
30 FIELD PersonCode
AS INT
32 FIELD LastName
AS CHAR
34 FIELD ContactType
AS CHAR
35 FIELD Phone
AS CHAR EXTENT 3
36 FIELD JobTitle
AS CHAR
37 FIELD Department
AS CHAR
38 INDEX XPKListContact
IS UNIQUE PRIMARY PersonCode
39 INDEX XAK1ListContact Company Lastname.
41 /* _UIB-CODE-BLOCK-END
*/
45 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
47 /* ******************** Preprocessor Definitions
******************** */
49 &Scoped-define PROCEDURE-TYPE Procedure
50 &Scoped-define DB-AWARE no
54 /* _UIB-PREPROCESSOR-BLOCK-END
*/
59 /* *********************** Procedure Settings
************************ */
61 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
62 /* Settings for
THIS-PROCEDURE
66 Add Fields to
: Neither
67 Other Settings
: CODE-ONLY
COMPILE
69 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
71 /* ************************* Create Window
************************** */
73 &ANALYZE-SUSPEND _CREATE-WINDOW
74 /* DESIGN Window definition
(used by the UIB
)
75 CREATE WINDOW Procedure
ASSIGN
78 /* END WINDOW DEFINITION
*/
82 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
83 /* ************************* Included-Libraries
*********************** */
85 {inc
/method
/m-txtrep.i
}
89 /* _UIB-CODE-BLOCK-END
*/
96 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
99 /* *************************** Main Block
*************************** */
100 {inc
/username.i
"user-name"}
101 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
103 RUN parse-parameters.
105 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
107 RUN pclrep-start
( preview
, "reset,landscape,tm,2,a4,lm,6,courier,cpi,18,lpi,9").
111 ELSE IF entity-type
<> "" THEN
120 /* _UIB-CODE-BLOCK-END
*/
124 /* ********************** Internal Procedures
*********************** */
126 &IF DEFINED(EXCLUDE-clear-list-contacts) = 0 &THEN
128 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE clear-list-contacts Procedure
129 PROCEDURE clear-list-contacts
:
130 /*------------------------------------------------------------------------------
132 ------------------------------------------------------------------------------*/
133 FOR EACH ListContact
:
138 /* _UIB-CODE-BLOCK-END
*/
143 &IF DEFINED(EXCLUDE-contact-listing) = 0 &THEN
145 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE contact-listing Procedure
146 PROCEDURE contact-listing
:
147 /*------------------------------------------------------------------------------
149 ------------------------------------------------------------------------------*/
150 DEF VAR use-contact-type
AS LOGI
NO-UNDO.
152 FOR EACH ContactType
NO-LOCK:
154 use-contact-type
= LOOKUP( ContactType.ContactType
, ctype-list
) <> 0.
155 IF NOT include-types
THEN use-contact-type
= NOT use-contact-type.
156 IF NOT use-contact-type
THEN NEXT.
157 RUN each-contact-type.
163 /* _UIB-CODE-BLOCK-END
*/
168 &IF DEFINED(EXCLUDE-each-contact) = 0 &THEN
170 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-contact Procedure
171 PROCEDURE each-contact
:
172 /*------------------------------------------------------------------------------
174 ------------------------------------------------------------------------------*/
175 DEF INPUT PARAMETER ct-type
AS CHAR NO-UNDO.
176 DEF INPUT PARAMETER person-code
AS INT NO-UNDO.
178 DEF BUFFER Psn
FOR Person.
179 DEF BUFFER Ctc
FOR Contact.
180 DEF VAR phone-no
AS CHAR EXTENT 3 NO-UNDO.
181 DEF VAR contact-types
AS CHAR NO-UNDO.
182 DEF VAR i
AS INT NO-UNDO.
184 FIND Psn
WHERE Psn.PersonCode
= person-code
NO-LOCK NO-ERROR.
185 IF NOT AVAILABLE(Psn
) THEN RETURN.
187 IF entity-type
<> "" THEN
188 phone-no
[1] = get-phone-nos
( Psn.PersonCode
).
189 ELSE DO i
= 1 TO NUM-ENTRIES( phtype-list
):
190 FIND PhoneDetail
WHERE
191 PhoneDetail.PersonCode
= Psn.PersonCode
AND
192 PhoneDetail.PhoneType
= ENTRY( i
, phtype-list
)
196 IF AVAILABLE PhoneDetail
THEN
197 RUN combine-phone
( PhoneDetail.cCountryCode
, PhoneDetail.cSTDCode
, PhoneDetail.Number
,
198 OUTPUT phone-no
[i
] ).
202 FOR EACH Ctc
WHERE Ctc.PersonCode
= Psn.PersonCode
:
203 contact-types
= contact-types
+ Ctc.ContactType
+ ", ".
205 contact-types
= TRIM(contact-types
, ", ").
207 out-line
= SPC
( 2 ) + STRING(person-code
,">>>>9 ")
208 + STRING( null-str
(ct-type
,"?"), "X(4)") + SPC
( 2 )
209 + STRING( null-str
(Psn.FirstName
, ""), "X(15)" ) + SPC
( 1 )
210 + STRING( null-str
(Psn.LastName
, ""), "X(15)" ) + SPC
( 1 ) .
212 IF entity-type
<> "" THEN
214 + STRING( null-str
(phone-no
[1], ""), "X(92)" ) + SPC
( 1 )
215 + STRING( null-str
(Psn.JobTitle
, ""), "X(40)" ) + SPC
( 1 ).
218 + STRING( null-str
(phone-no
[1], ""), "X(20)" ) + SPC
( 1 )
219 + STRING( null-str
(phone-no
[2], ""), "X(20)" ) + SPC
( 1 )
220 + STRING( null-str
(phone-no
[3], ""), "X(20)" ) + SPC
( 1 )
221 + STRING( null-str
(Psn.JobTitle
, ""), "X(40)" ) + SPC
( 1 )
222 + STRING( null-str
(contact-types
, ""), "X(40)" ) .
225 RUN pclrep-line
( "courier,Fixed,cpi,18,lpi,9,Normal", out-line
).
229 /* _UIB-CODE-BLOCK-END
*/
234 &IF DEFINED(EXCLUDE-each-contact-type) = 0 &THEN
236 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-contact-type Procedure
237 PROCEDURE each-contact-type
:
238 /*------------------------------------------------------------------------------
240 ------------------------------------------------------------------------------*/
242 RUN clear-list-contacts.
243 FOR EACH Contact
OF ContactType
NO-LOCK:
244 RUN make-list-contact
( Contact.ContactType
, Contact.PersonCode
, ?
).
247 IF NOT CAN-FIND( FIRST ListContact
) THEN RETURN.
248 RUN pclrep-line
( "Helvetica,Point,12,Bold,Proportional", ContactType.Description
+ " (" + ContactType.ContactType
+ ")" ).
249 RUN pclrep-line
( ?
, "" ).
251 RUN output-list-contacts.
252 RUN pclrep-line
( ?
, "" ).
256 /* _UIB-CODE-BLOCK-END
*/
261 &IF DEFINED(EXCLUDE-each-entity) = 0 &THEN
263 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-entity Procedure
264 PROCEDURE each-entity
:
265 /*------------------------------------------------------------------------------
267 ------------------------------------------------------------------------------*/
268 IF NOT( page-per-tenant
) THEN DO:
269 RUN pclrep-line
( "Helvetica,Point,12,Bold,Proportional", entity-description
+ " (" + entity-type
+ STRING(entity-code
) + ")" ).
270 RUN pclrep-line
( ?
, "" ).
273 FOR EACH Tenant
WHERE Tenant.EntityType
= entity-type
274 AND Tenant.EntityCode
= entity-code
275 AND Tenant.Active
NO-LOCK:
278 IF NOT( page-per-tenant
) THEN DO:
279 RUN pclrep-page-break.
284 /* _UIB-CODE-BLOCK-END
*/
289 &IF DEFINED(EXCLUDE-each-tenant) = 0 &THEN
291 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-tenant Procedure
292 PROCEDURE each-tenant
:
293 /*------------------------------------------------------------------------------
295 ------------------------------------------------------------------------------*/
296 DEF VAR person-address
AS CHAR NO-UNDO.
297 DEF VAR tenant-name
AS CHAR NO-UNDO.
299 IF page-per-tenant
THEN DO:
300 RUN pclrep-line
( "Helvetica,Point,12,Bold,Proportional", entity-description
+ " (" + entity-type
+ STRING(entity-code
) + ")" ).
301 RUN pclrep-line
( ?
, "" ).
304 RUN clear-list-contacts.
305 tenant-name
= (IF Tenant.LegalName
<> "" THEN Tenant.LegalName
ELSE Tenant.Name
).
306 RUN process
/getaddr.p
( "PERSON", Tenant.BillingContact
, ptype-list
, OUTPUT person-address
).
307 person-address
= TRIM( TRIM( REPLACE( REPLACE( person-address
, CHR(13), ""), "~n", "," ), "," ) ).
309 RUN make-list-contact
( "ACCT", Tenant.BillingContact
, person-address
).
310 RUN make-list-contact
( "PROP", Tenant.PropertyContact
, person-address
).
311 RUN make-list-contact
( "AH-1", Tenant.AH1Contact
, person-address
).
312 RUN make-list-contact
( "AH-2", Tenant.AH2Contact
, person-address
).
313 FOR EACH EntityContact
WHERE EntityContact.EntityType
= "T"
314 AND EntityContact.EntityCode
= Tenant.TenantCode
NO-LOCK:
315 RUN make-list-contact
( EntityContact.EntityContactType
, EntityContact.PersonCode
, person-address
).
318 IF NOT CAN-FIND( FIRST ListContact
) THEN RETURN.
320 RUN pclrep-line
( "Helvetica,Point,8,Normal,Proportional", tenant-name
+ (IF person-address
<> "" THEN ", " + person-address
ELSE "") ).
321 RUN pclrep-line
( ?
, "" ).
323 RUN output-list-contacts.
324 RUN pclrep-line
( ?
, "" ).
326 IF page-per-tenant
THEN DO:
327 RUN pclrep-page-break.
332 /* _UIB-CODE-BLOCK-END
*/
337 &IF DEFINED(EXCLUDE-entity-contacts) = 0 &THEN
339 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE entity-contacts Procedure
340 PROCEDURE entity-contacts
:
341 /*------------------------------------------------------------------------------
343 ------------------------------------------------------------------------------*/
344 DEF VAR entity-from
AS INT NO-UNDO.
346 IF entity-type
= "P" THEN DO:
347 entity-from
= entity-code.
348 FOR EACH Property
WHERE Property.PropertyCode
>= entity-from
349 AND Property.PropertyCode
<= entity-to
350 AND Property.Active
NO-LOCK:
351 entity-description
= Property.Name.
352 entity-code
= Property.PropertyCode .
362 /* _UIB-CODE-BLOCK-END
*/
367 &IF DEFINED(EXCLUDE-inst-page-footer) = 0 &THEN
369 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
370 PROCEDURE inst-page-footer
:
371 /*------------------------------------------------------------------------------
372 Purpose
: Print any page footer
373 ------------------------------------------------------------------------------*/
377 /* _UIB-CODE-BLOCK-END
*/
382 &IF DEFINED(EXCLUDE-inst-page-header) = 0 &THEN
384 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
385 PROCEDURE inst-page-header
:
386 /*------------------------------------------------------------------------------
387 Purpose
: Print any page header
388 ------------------------------------------------------------------------------*/
390 RUN pclrep-line
( "univers,Point,7,bold,proportional", TimeStamp
).
391 RUN pclrep-line
( "univers,Point,12,bold,proportional", FILL( " ", 45) + "Contact Listing").
393 IF merge-list
THEN DO:
394 RUN pclrep-line
( "", "").
395 RUN pclrep-line
( "courier,Fixed,cpi,18,lpi,9,Bold", "Contact Types: " + ctype-list
).
398 RUN pclrep-line
( "", "").
399 out-line
= SPC
( 6 ) +
400 STRING( "First Name", "X(15)" ) + SPC
( 3 ) +
401 STRING( "Last Name", "X(15)" ) + SPC
( 3 ).
403 IF entity-type
<> "" THEN
404 out-line
= out-line
+ STRING( "Phone Nos.", "X(92)" ) + SPC
( 1 )
405 + STRING( "Position title", "X(41)" ) + "~n" .
407 out-line
= out-line
+ STRING( "Business", "X(20)" ) + SPC
( 1 ) +
408 STRING( "Facsimile", "X(20)" ) + SPC
( 1 ) +
409 STRING( "Mobile", "X(18)" ) + SPC
( 1 ) +
410 STRING( "Position title", "X(41)" )
411 + "Contact types~n" .
413 RUN pclrep-line
( "courier,Fixed,cpi,18,lpi,9,Bold", out-line
).
418 /* _UIB-CODE-BLOCK-END
*/
423 &IF DEFINED(EXCLUDE-make-list-contact) = 0 &THEN
425 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE make-list-contact Procedure
426 PROCEDURE make-list-contact
:
427 /*------------------------------------------------------------------------------
429 ------------------------------------------------------------------------------*/
430 DEF INPUT PARAMETER contact-type
AS CHAR NO-UNDO.
431 DEF INPUT PARAMETER person-code
AS INT NO-UNDO.
432 DEF INPUT PARAMETER person-address
AS CHAR NO-UNDO.
434 IF NOT CAN-DO( ctype-list
, contact-type
) THEN RETURN.
435 FIND FIRST Person
WHERE Person.PersonCode
= person-code
NO-LOCK NO-ERROR.
436 IF AVAILABLE(Person
) THEN DO:
437 IF TRIM(null-str
(Person.Company
,"")) = ""
438 AND TRIM(null-str
(Person.FirstName
,"")) = ""
439 AND null-str
(Person.LastName
,"") = ""
442 FIND ListContact
WHERE ListContact.PersonCode
= Person.PersonCode
NO-ERROR.
443 IF AVAILABLE(ListContact
) THEN RETURN.
445 ListContact.PersonCode
= Person.PersonCode.
446 ListContact.LastName
= Person.LastName.
447 ListContact.ContactType
= contact-type.
448 IF person-address
= ?
THEN DO:
449 RUN process
/getaddr.p
( "PERSON", Person.PersonCode
, ptype-list
, OUTPUT person-address
).
450 person-address
= TRIM( TRIM( REPLACE( REPLACE( person-address
, CHR(13), ""), "~n", ", " ), ", " ) ).
451 IF person-address
= ?
THEN person-address
= "".
453 ListContact.Address
= person-address.
454 ListContact.Company
= null-str
( Person.Company
, "")
455 + (IF ListContact.Address
<> "" THEN ", " ELSE "")
456 + ListContact.Address.
458 IF entity-type
<> "" AND AVAILABLE(Tenant
) THEN
459 ListContact.Company
= "T" + STRING(Tenant.TenantCode
) + " - " + ListContact.Company.
464 /* _UIB-CODE-BLOCK-END
*/
469 &IF DEFINED(EXCLUDE-merge-contacts) = 0 &THEN
471 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE merge-contacts Procedure
472 PROCEDURE merge-contacts
:
473 /*------------------------------------------------------------------------------
475 ------------------------------------------------------------------------------*/
476 DEF VAR use-contact-type
AS LOGI
NO-UNDO.
477 DEF VAR person-address
AS CHAR NO-UNDO.
479 FOR EACH Contact
NO-LOCK:
480 IF CAN-FIND(FIRST ListContact
WHERE ListContact.PersonCode
= Contact.PersonCode
) THEN NEXT.
481 use-contact-type
= LOOKUP( Contact.ContactType
, ctype-list
) <> 0.
482 IF NOT include-types
THEN use-contact-type
= NOT use-contact-type.
483 IF NOT use-contact-type
THEN NEXT.
485 RUN make-list-contact
( "", Contact.PersonCode
, ?
).
488 RUN output-list-contacts.
492 /* _UIB-CODE-BLOCK-END
*/
497 &IF DEFINED(EXCLUDE-output-list-contacts) = 0 &THEN
499 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE output-list-contacts Procedure
500 PROCEDURE output-list-contacts
:
501 /*------------------------------------------------------------------------------
503 ------------------------------------------------------------------------------*/
505 FOR EACH ListContact
, FIRST Person
WHERE ListContact.PersonCode
=Person.PersonCode
506 BREAK BY ListContact.Company
:
507 IF FIRST-OF( ListContact.Company
) THEN
508 RUN pclrep-line
( "Helvetica,Point,8,Normal,Proportional", ListContact.Company
).
510 RUN each-contact
( ListContact.ContactType
, ListContact.PersonCode
).
512 IF LAST-OF( ListContact.Company
) THEN RUN pclrep-line
( ?
, "" ).
518 /* _UIB-CODE-BLOCK-END
*/
523 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
525 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
526 PROCEDURE parse-parameters
:
527 /*------------------------------------------------------------------------------
531 ------------------------------------------------------------------------------*/
533 DEF VAR i
AS INT NO-UNDO.
534 DEF VAR token
AS CHAR NO-UNDO.
536 {inc
/showopts.i
"report-options"}
538 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
539 token
= ENTRY( i
, report-options
, "~n" ).
541 CASE ENTRY( 1, token
):
542 WHEN "ContactTypes" THEN ctype-list
= SUBSTR( token
, INDEX( token
, "," ) + 1 ).
543 WHEN "PostalTypes" THEN ptype-list
= SUBSTR( token
, INDEX( token
, "," ) + 1 ).
544 WHEN "Exclude" THEN include-types
= ENTRY( 2, token
) <> "Yes".
545 WHEN "Preview" THEN preview
= Yes.
546 WHEN "Merge" THEN merge-list
= Yes.
547 WHEN "PagePerTenant" THEN page-per-tenant
= Yes.
548 WHEN "Entity" THEN DO:
549 entity-type
= ENTRY( 2, token
).
550 entity-code
= INT( ENTRY( 3,token
)).
551 IF NUM-ENTRIES(token
) = 4 THEN
552 entity-to
= INT( ENTRY( 4,token
)).
554 entity-to
= entity-code.
555 IF entity-to
< entity-code
THEN entity-to
= entity-code.
562 FIND Property
WHERE Property.PropertyCode
= entity-code
NO-LOCK.
563 entity-description
= Property.Name.
566 FIND Company
WHERE Company.CompanyCode
= entity-code
NO-LOCK.
567 entity-description
= Company.LegalName .
576 /* _UIB-CODE-BLOCK-END
*/