1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 &SCOPED-DEFINE trn-per-page 58
8 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
10 DEF VAR entity-type
AS CHAR NO-UNDO INITIAL "J".
11 DEF VAR entity-code
AS INT NO-UNDO.
12 DEF VAR order-list
AS CHAR NO-UNDO.
13 DEF VAR no-of-copies
AS INT NO-UNDO INITIAL 0.
14 DEF VAR supplier-copy
AS LOGI
NO-UNDO INITIAL No.
15 DEF VAR output-to-pdf
AS LOGI
NO-UNDO INITIAL NO.
16 DEF VAR email-address
AS CHAR NO-UNDO.
17 DEF VAR notes-out-codes
AS CHAR NO-UNDO.
21 DEF VAR ln
AS DEC INIT 0.00 NO-UNDO.
23 /* Line definitions
*/
25 DEF VAR date-in-words
AS CHAR NO-UNDO.
26 DEF VAR creditor-address
AS CHAR NO-UNDO EXTENT 7.
27 DEF VAR property-address
AS CHAR NO-UNDO EXTENT 3.
28 DEF VAR creditor-phones
AS CHAR NO-UNDO EXTENT 2.
29 DEF VAR trn-line
AS CHAR NO-UNDO.
30 DEF VAR trn-no
AS INT NO-UNDO.
31 DEF VAR regarding
AS CHAR NO-UNDO.
32 DEF VAR client-code
AS CHAR NO-UNDO.
33 DEF VAR entity-name
AS CHAR NO-UNDO.
34 DEF VAR account-name
AS CHAR NO-UNDO.
35 DEF VAR contact-name
AS CHAR NO-UNDO.
36 DEF VAR contact-phone
AS CHAR NO-UNDO.
37 DEF VAR call-description
AS CHAR NO-UNDO.
39 DEF VAR reset-page
AS CHAR NO-UNDO.
40 DEF VAR half-line
AS CHAR NO-UNDO. half-line
= CHR(27) + "=".
41 DEF VAR time-font
AS CHAR NO-UNDO.
42 DEF VAR title-font
AS CHAR NO-UNDO.
43 DEF VAR num-font
AS CHAR NO-UNDO.
44 DEF VAR prompt-font
AS CHAR NO-UNDO.
45 DEF VAR re-font
AS CHAR NO-UNDO.
46 DEF VAR creditor-address-font
AS CHAR NO-UNDO.
47 DEF VAR body-font
AS CHAR NO-UNDO.
48 DEF VAR line-printer
AS CHAR NO-UNDO.
49 DEF VAR order-body-font
AS CHAR NO-UNDO.
50 DEF VAR stamp-font
AS CHAR NO-UNDO.
52 DEF VAR page-no
AS INT NO-UNDO.
54 DEF VAR logo-codes
AS CHAR NO-UNDO.
55 DEF VAR copy-no
AS INT NO-UNDO.
57 DEF VAR time-stamp
AS CHAR NO-UNDO.
58 DEF VAR user-name
AS CHAR NO-UNDO.
59 {inc
/username.i
"user-name"}
63 STRING( TODAY, "99/99/9999" ) + " " + STRING( TIME, "HH:MM:SS" ) +
66 {inc
/ofc-set.i
"Order-notes-routine" "order-notes-routine"}
67 IF NOT AVAILABLE(OfficeSetting
) THEN
68 order-notes-routine
= "".
70 /* _UIB-CODE-BLOCK-END
*/
74 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
76 /* ******************** Preprocessor Definitions
******************** */
78 &Scoped-define PROCEDURE-TYPE Procedure
79 &Scoped-define DB-AWARE no
83 /* _UIB-PREPROCESSOR-BLOCK-END
*/
88 /* *********************** Procedure Settings
************************ */
90 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
91 /* Settings for
THIS-PROCEDURE
95 Add Fields to
: Neither
96 Other Settings
: CODE-ONLY
COMPILE
98 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
100 /* ************************* Create Window
************************** */
102 &ANALYZE-SUSPEND _CREATE-WINDOW
103 /* DESIGN Window definition
(used by the UIB
)
104 CREATE WINDOW Procedure
ASSIGN
107 /* END WINDOW DEFINITION
*/
111 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
112 /* ************************* Included-Libraries
*********************** */
114 {inc
/method
/m-txtrep.i
}
115 {inc
/method
/m-hpgl.i
}
120 /* _UIB-CODE-BLOCK-END
*/
127 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
130 /* *************************** Main Block
*************************** */
132 DEF VAR preview
AS LOGI
INIT No
NO-UNDO.
134 IF output-to-pdf
THEN DO:
135 RUN txtrep-output-mode
( "pdf" ).
136 RUN hpgl-output-mode
( "pdf" ).
139 RUN get-control-strings.
142 If printing then send all orders to one file
, otherwise for PDF output
143 see the procedure in this file called purchase-orders
().
145 IF NOT output-to-pdf
THEN
146 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
150 IF NOT output-to-pdf
THEN DO:
152 RUN view-output-file
( preview
).
155 /* _UIB-CODE-BLOCK-END
*/
159 /* ********************** Internal Procedures
*********************** */
161 &IF DEFINED(EXCLUDE-carriage-return) = 0 &THEN
163 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE carriage-return Procedure
164 PROCEDURE carriage-return
:
165 /*------------------------------------------------------------------------------
169 ------------------------------------------------------------------------------*/
175 /* _UIB-CODE-BLOCK-END
*/
180 &IF DEFINED(EXCLUDE-each-order) = 0 &THEN
182 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-order Procedure
183 PROCEDURE each-order
:
184 /*------------------------------------------------------------------------------
186 ------------------------------------------------------------------------------*/
187 RUN get-order-details.
188 RUN get-creditor-details.
189 DO copy-no
= 1 TO no-of-copies
:
202 /* _UIB-CODE-BLOCK-END
*/
207 &IF DEFINED(EXCLUDE-get-account-figures) = 0 &THEN
209 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-account-figures Procedure
210 PROCEDURE get-account-figures
:
211 /*------------------------------------------------------------------------------
213 ------------------------------------------------------------------------------*/
214 DEF OUTPUT PARAMETER YTD-Budget
AS DEC NO-UNDO INITIAL 0.0 .
215 DEF OUTPUT PARAMETER FY-Budget
AS DEC NO-UNDO INITIAL 0.0 .
216 DEF OUTPUT PARAMETER Total-Committed
AS DEC NO-UNDO INITIAL 0.0 .
217 DEF OUTPUT PARAMETER Wait-Appvl
AS DEC NO-UNDO INITIAL 0.0 .
218 DEF OUTPUT PARAMETER OS-Orders
AS DEC NO-UNDO INITIAL 0.0 .
219 DEF OUTPUT PARAMETER YTD-Spent
AS DEC NO-UNDO INITIAL 0.0 .
221 DEF VAR m1
AS INT NO-UNDO.
222 DEF VAR m2
AS INT NO-UNDO.
223 DEF VAR m3
AS INT NO-UNDO.
225 DEF VAR et
AS CHAR NO-UNDO.
226 DEF VAR ec
AS INT NO-UNDO.
227 DEF VAR ac
AS DEC NO-UNDO.
229 /* DEF BUFFER tmp_Project
FOR Project.
*/
231 FIND Month
WHERE Month.StartDate
<= TODAY AND Month.EndDate
>= TODAY NO-LOCK.
232 m2
= Month.MonthCode.
233 FIND FinancialYear
OF Month
NO-LOCK.
234 IF Order.EntityType
= 'J'
THEN DO:
235 FIND FIRST Month
NO-LOCK. m1
= Month.MonthCode.
238 FIND FIRST Month
OF FinancialYear
NO-LOCK. m1
= Month.MonthCode.
240 FIND LAST Month
OF FinancialYear
NO-LOCK. m3
= Month.MonthCode.
242 ac
= Order.AccountCode.
243 et
= Order.EntityType.
244 ec
= Order.EntityCode.
246 FOR EACH AccountBalance
WHERE AccountBalance.EntityType
= et
247 AND AccountBalance.EntityCode
= ec
248 AND AccountBalance.AccountCode
= ac
249 AND AccountBalance.MonthCode
>= m1
250 AND AccountBalance.MonthCode
<= m3
NO-LOCK:
251 FY-Budget
= FY-Budget
+ AccountBalance.Budget.
252 IF AccountBalance.MonthCode
<= m2
THEN DO:
253 YTD-Budget
= YTD-Budget
+ AccountBalance.Budget.
254 YTD-Spent
= YTD-Spent
+ AccountBalance.Balance.
258 DEF BUFFER tmp_Order
FOR Order.
259 FOR EACH tmp_Order
WHERE tmp_Order.EntityType
= et
260 AND tmp_Order.EntityCode
= ec
261 AND tmp_Order.AccountCode
= ac
262 AND ROWID(tmp_Order
) <> ROWID(Order
) NO-LOCK:
263 OS-Orders
= OS-Orders
+ tmp_Order.ApprovedAmount .
264 FOR EACH Voucher
WHERE Voucher.EntityType
= et
265 AND Voucher.EntityCode
= ec
266 AND Voucher.OrderCode
= tmp_Order.OrderCode
NO-LOCK:
267 IF Voucher.VoucherStatus
= "U" THEN DO:
268 Wait-Appvl
= Wait-Appvl
+ Voucher.GoodsValue.
270 IF Voucher.VoucherStatus
<> "C" THEN DO:
271 OS-Orders
= OS-Orders
- Voucher.GoodsValue.
277 OS-Orders
= OS-Orders
+ Order.ApprovedAmount .
278 FOR EACH Voucher
WHERE Voucher.EntityType
= et
279 AND Voucher.EntityCode
= ec
280 AND Voucher.OrderCode
= Order.OrderCode
NO-LOCK:
281 IF Voucher.VoucherStatus
= "U" THEN
282 Wait-Appvl
= Wait-Appvl
+ Voucher.GoodsValue.
283 ELSE IF Voucher.VoucherStatus
<> "C" THEN DO:
284 OS-Orders
= OS-Orders
- Voucher.GoodsValue.
288 Total-Committed
= YTD-Spent
+ OS-Orders
+ Wait-Appvl.
292 /* _UIB-CODE-BLOCK-END
*/
297 &IF DEFINED(EXCLUDE-get-control-strings) = 0 &THEN
299 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-control-strings Procedure
300 PROCEDURE get-control-strings
:
301 /*------------------------------------------------------------------------------
302 Purpose
: Get all control strings for this report
305 ------------------------------------------------------------------------------*/
306 DEF VAR rows
AS DEC NO-UNDO.
307 DEF VAR cols
AS DEC NO-UNDO.
309 RUN make-control-string
( "PCL", "reset,simplex,portrait,a4,tm,0,lm,6",
310 OUTPUT reset-page
, OUTPUT rows
, OUTPUT cols
).
312 RUN make-control-string
( "PCL", "Helvetica,Point,20,Bold,Proportional,lpi,3.6",
313 OUTPUT title-font
, OUTPUT rows
, OUTPUT cols
).
315 RUN make-control-string
( "PCL", "Times,Point,6,Normal,Proportional,lpi,12",
316 OUTPUT time-font
, OUTPUT rows
, OUTPUT cols
).
318 RUN make-control-string
( "PCL", "Helvetica,Point,12,Proportional,Bold,lpi,6",
319 OUTPUT prompt-font
, OUTPUT rows
, OUTPUT cols
).
321 RUN make-control-string
( "PCL", "Times,Point,16,Bold,Proportional,lpi,4.5",
322 OUTPUT num-font
, OUTPUT rows
, OUTPUT cols
).
324 RUN make-control-string
( "PCL", "Helvetica,Point,14,Proportional,Bold,lpi,5",
325 OUTPUT re-font
, OUTPUT rows
, OUTPUT cols
).
327 RUN make-control-string
( "PCL", "Helvetica,Point,10,Proportional,Normal,lpi,7",
328 OUTPUT creditor-address-font
, OUTPUT rows
, OUTPUT cols
).
330 RUN make-control-string
( "PCL", "Courier,fixed,Point,10,normal,lpi,7",
331 OUTPUT order-body-font
, OUTPUT rows
, OUTPUT cols
).
333 RUN make-control-string
( "PCL", "Courier,fixed,cpi,14,lpi,6,normal",
334 OUTPUT line-printer
, OUTPUT rows
, OUTPUT cols
).
336 RUN make-control-string
( "PCL", "Times,Point,4,Proportional,Normal,lpi,17",
337 OUTPUT stamp-font
, OUTPUT rows
, OUTPUT cols
).
341 /* _UIB-CODE-BLOCK-END
*/
346 &IF DEFINED(EXCLUDE-get-creditor-details) = 0 &THEN
348 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-creditor-details Procedure
349 PROCEDURE get-creditor-details
:
350 /*------------------------------------------------------------------------------
352 ------------------------------------------------------------------------------*/
354 DEF VAR i
AS INT NO-UNDO.
355 DEF VAR addr
AS CHAR NO-UNDO.
357 FIND Creditor
WHERE Creditor.CreditorCode
= Order.CreditorCode
NO-LOCK NO-ERROR.
359 RUN process
/getaddr.p
( "C", Creditor.CreditorCode
, "PYMT,MAIN", OUTPUT addr
).
360 DO i
= 1 TO 7: creditor-address
[i
] = "".
END.
361 DO i
= 1 TO NUM-ENTRIES( addr
, CHR(10) ):
362 creditor-address
[i
] = ENTRY( i
, addr
, CHR(10) ).
365 creditor-phones
[1] = "".
366 FIND FIRST PhoneDetail
WHERE PhoneDetail.PersonCode
= Creditor.PaymentContact
367 AND PhoneType
= 'BUS'
NO-LOCK NO-ERROR.
368 IF AVAILABLE(PhoneDetail
) THEN DO:
369 RUN combine-phone
( PhoneDetail.cCountryCode
, PhoneDetail.cSTDCode
, PhoneDetail.Number
,
370 OUTPUT creditor-phones
[1] ).
371 creditor-phones
[1] = "Bus: " + creditor-phones
[1].
374 FIND FIRST PhoneDetail
WHERE PhoneDetail.PersonCode
= Creditor.PaymentContact
375 AND PhoneType
= 'FAX'
NO-LOCK NO-ERROR.
376 creditor-phones
[2] = "".
377 IF AVAILABLE(PhoneDetail
) THEN DO:
378 RUN combine-phone
( PhoneDetail.cCountryCode
, PhoneDetail.cSTDCode
, PhoneDetail.Number
,
379 OUTPUT creditor-phones
[2] ).
380 creditor-phones
[2] = "Fax: " + creditor-phones
[2].
383 creditor-address
[i
] = creditor-phones
[1].
384 creditor-address
[i
+ 1] = creditor-phones
[2].
388 /* _UIB-CODE-BLOCK-END
*/
393 &IF DEFINED(EXCLUDE-get-order-details) = 0 &THEN
395 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-order-details Procedure
396 PROCEDURE get-order-details
:
397 /*------------------------------------------------------------------------------
399 ------------------------------------------------------------------------------*/
400 IF NOT AVAILABLE Order
THEN RETURN.
402 entity-name
= get-entity-name
( entity-type
, entity-code
).
403 client-code
= get-entity-client
( entity-type
, entity-code
).
404 account-name
= get-entity-account
( entity-type
, entity-code
, Order.AccountCode
).
406 IF entity-type
= 'P'
THEN DO:
407 FIND FIRST Property
WHERE Property.PropertyCode
= entity-code
NO-LOCK.
408 property-address
[1] = ENTRY( 1, Property.StreetAddress
).
409 property-address
[2] = TRIM(SUBSTRING( Property.StreetAddress
, LENGTH(property-address
[1]) + 2) ).
413 FIND FIRST TenantCall
OF Property
WHERE TenantCall.OrderNo
= Order.OrderCode
NO-LOCK.
414 IF AVAILABLE(TenantCall
) THEN DO:
415 contact-name
= TenantCall.ContactName.
416 contact-phone
= TenantCall.ContactPhone.
417 call-description
= TenantCall.Description.
421 property-address
[1] = ''.
422 property-address
[2] = ''.
426 call-description
= ''.
430 RUN client-logo
( entity-type
, entity-code
, client-code
).
431 RUN client-address
( entity-type
, entity-code
, client-code
).
433 RUN hpgl-moveto
(0,260).
434 RUN hpgl-get-codes
( yes
, yes
, OUTPUT logo-codes
).
438 /* _UIB-CODE-BLOCK-END
*/
443 &IF DEFINED(EXCLUDE-next-line) = 0 &THEN
445 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE next-line Procedure
446 PROCEDURE next-line
:
447 /*------------------------------------------------------------------------------
451 ------------------------------------------------------------------------------*/
455 IF trn-no
> {&trn-per-page} THEN
464 /* _UIB-CODE-BLOCK-END
*/
469 &IF DEFINED(EXCLUDE-order-body) = 0 &THEN
471 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE order-body Procedure
472 PROCEDURE order-body
:
473 /*------------------------------------------------------------------------------
475 ------------------------------------------------------------------------------*/
479 DEf
VAR i
AS INT NO-UNDO.
480 DEF VAR order-text
AS CHAR NO-UNDO.
482 RUN pcl-moveto
( 27, 11 ).
RUN carriage-return.
483 PUT CONTROL creditor-address-font.
484 PUT UNFORMATTED "Description".
487 PUT CONTROL order-body-font.
489 RUN word-wrap
( Order.Description
, {&wrap-width}, OUTPUT order-text ).
491 DO i
= 1 TO NUM-ENTRIES( order-text
, "~n" ):
493 PUT UNFORMATTED ENTRY( i
, order-text
, "~n" ).
497 IF Order.OrderAmount
> 0 THEN DO:
498 DEF VAR amount-out
AS CHAR NO-UNDO.
499 RUN pcl-moveto
( 61, 11 ).
RUN carriage-return.
500 PUT CONTROL num-font.
501 PUT UNFORMATTED SPACE(59) "AMOUNT: ".
RUN carriage-return.
502 amount-out
= TRIM(STRING( Order.OrderAmount
, "$>>>,>>>,>>9.99" )).
503 PUT UNFORMATTED SPACE(77) SPACE( 2 * (14 - LENGTH(amount-out
))) amount-out.
505 IF Order.TaxAmount
<> ?
AND Order.TaxAmount
<> 0 THEN DO:
506 PUT UNFORMATTED " plus GST of " TRIM( STRING( Order.TaxAmount
, "$>>>,>>>,>>9.99" ) ).
513 DEF VAR box-codes
AS CHAR NO-UNDO.
515 RUN hpgl-moveto
(23,107).
517 RUN hpgl-set-line-type
( 2, 1, 1 ).
518 RUN hpgl-set-line-width
( 0.25 ).
519 RUN hpgl-box-relative
(167,63).
521 RUN hpgl-moveto
(127,89).
523 RUN hpgl-set-line-width
( 1 ).
524 RUN hpgl-box-relative
(63,11).
526 RUN hpgl-moveto
(0,260).
527 RUN hpgl-get-codes
( yes
, NO, OUTPUT box-codes
).
529 PUT CONTROL box-codes.
534 /* _UIB-CODE-BLOCK-END
*/
539 &IF DEFINED(EXCLUDE-page-feed) = 0 &THEN
541 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-feed Procedure
542 PROCEDURE page-feed
:
543 /*------------------------------------------------------------------------------
547 ------------------------------------------------------------------------------*/
550 page-no
= page-no
+ 1.
554 /* _UIB-CODE-BLOCK-END
*/
559 &IF DEFINED(EXCLUDE-page-footer) = 0 &THEN
561 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-footer Procedure
562 PROCEDURE page-footer
:
563 /*------------------------------------------------------------------------------
565 ------------------------------------------------------------------------------*/
567 IF copy-no
= 1 AND supplier-copy
THEN
568 RUN page-footer-creditor.
570 RUN page-footer-copy.
574 /* _UIB-CODE-BLOCK-END
*/
579 &IF DEFINED(EXCLUDE-page-footer-copy) = 0 &THEN
581 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-footer-copy Procedure
582 PROCEDURE page-footer-copy
:
583 /*------------------------------------------------------------------------------
585 ------------------------------------------------------------------------------*/
586 DEF VAR YTD-Budget
AS DEC NO-UNDO .
587 DEF VAR FY-Budget
AS DEC NO-UNDO .
588 DEF VAR Total-Committed
AS DEC NO-UNDO .
589 DEF VAR Wait-Appvl
AS DEC NO-UNDO .
590 DEF VAR OS-Orders
AS DEC NO-UNDO .
591 DEF VAR YTD-Spent
AS DEC NO-UNDO .
593 RUN get-account-figures
( OUTPUT YTD-Budget
, OUTPUT FY-Budget
, OUTPUT Total-Committed
,
594 OUTPUT Wait-Appvl
, OUTPUT OS-Orders
, OUTPUT YTD-Spent
).
595 PUT CONTROL line-printer.
596 RUN pcl-moveto
( 56, 10 ).
RUN carriage-return.
597 PUT UNFORMATTED "Account coding: " + STRING(Order.AccountCode
, "9999.99")
598 SPACE(3) account-name.
601 PUT CONTROL title-font.
PUT UNFORMATTED FILL( "__", 60 ).
PUT CONTROL line-printer.
604 PUT UNFORMATTED "Total Paid Year to date: " + STRING(YTD-Spent
, "->>>,>>>,>>9.99")
605 SPACE(20) "Full Year Budget: " + STRING(FY-Budget
,"->>>,>>>,>>9.99").
608 PUT UNFORMATTED "Vouchers awaiting approval: " + STRING(Wait-Appvl
, "->>>,>>>,>>9.99")
609 SPACE(20) "YTD Budget: " + STRING(YTD-Budget
,"->>>,>>>,>>9.99").
612 PUT UNFORMATTED "Orders not yet invoiced: " + STRING(OS-Orders
, "->>>,>>>,>>9.99")
613 SPACE(20) "Total Committed: " + STRING(Total-Committed
,"->>>,>>>,>>9.99").
615 PUT CONTROL title-font.
PUT UNFORMATTED FILL( "__", 60 ).
PUT CONTROL line-printer.
618 PUT CONTROL prompt-font.
619 PUT UNFORMATTED "__________ : Ordered from supplier".
621 PUT UNFORMATTED SPACE(55) "__________ ____/_____/_____ : Order requested".
624 PUT UNFORMATTED "__________ : Copy to accounts".
626 PUT UNFORMATTED SPACE(55) "__________ ____/_____/_____ : Order approved".
629 PUT UNFORMATTED "__________ : Filing Code".
631 PUT CONTROL stamp-font.
632 PUT UNFORMATTED time-stamp.
634 /* PUT CONTROL line-printer.
635 RUN pcl-moveto
( 103, 10 ).
*/
640 /* _UIB-CODE-BLOCK-END
*/
645 &IF DEFINED(EXCLUDE-page-footer-creditor) = 0 &THEN
647 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-footer-creditor Procedure
648 PROCEDURE page-footer-creditor
:
649 /*------------------------------------------------------------------------------
653 ------------------------------------------------------------------------------*/
655 IF order-notes-routine
<> "" THEN DO:
657 IF output-to-pdf
THEN
658 RUN VALUE(order-notes-routine
) ( "pdf" ).
660 RUN VALUE(order-notes-routine
) ( "hpgl" ).
661 RUN hpgl-append
( RETURN-VALUE ).
662 RUN hpgl-get-codes
( YES, YES, OUTPUT notes-out-codes
).
663 PUT CONTROL notes-out-codes.
665 PUT CONTROL line-printer.
666 RUN pcl-moveto
( 65, 11 ).
RUN carriage-return.
670 PUT CONTROL line-printer.
671 RUN pcl-moveto
( 63, 11 ).
RUN carriage-return.
673 PUT CONTROL prompt-font.
674 PUT UNFORMATTED "Please note: Any works exceeding $550.00 (including GST) in value requires written".
676 PUT UNFORMATTED "approval by an authorized representative of the George Group prior to acceptance of".
678 PUT UNFORMATTED "quotation & commencement of works.".
684 /* _UIB-CODE-BLOCK-END
*/
689 &IF DEFINED(EXCLUDE-page-header) = 0 &THEN
691 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-header Procedure
692 PROCEDURE page-header
:
693 /*------------------------------------------------------------------------------
697 ------------------------------------------------------------------------------*/
706 /* _UIB-CODE-BLOCK-END
*/
711 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
713 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
714 PROCEDURE parse-parameters
:
715 /*------------------------------------------------------------------------------
717 ------------------------------------------------------------------------------*/
718 DEF VAR token
AS CHAR NO-UNDO.
719 DEF VAR i
AS INT NO-UNDO.
721 {inc
/showopts.i
"report-options"}
723 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
724 token
= ENTRY( i
, report-options
, "~n" ).
726 CASE ENTRY( 1, token
):
727 WHEN "SupplierCopy" THEN supplier-copy
= Yes.
728 WHEN "InternalCopies" THEN no-of-copies
= INT( ENTRY(2,token
) ).
729 WHEN "OutputPDF" THEN output-to-pdf
= YES.
730 WHEN "EmailAddress" THEN email-address
= ENTRY( 2, token
).
731 WHEN "Entity" THEN ASSIGN
732 entity-type
= ENTRY(2,token
)
733 entity-code
= INT( ENTRY(3,token
) ) .
735 order-list
= SUBSTRING(token
, INDEX(token
,",") + 1).
739 IF supplier-copy
THEN no-of-copies
= no-of-copies
+ 1.
741 /* Regardless of options
, force one copy only if for PDF output
*/
742 IF output-to-pdf
THEN
747 /* _UIB-CODE-BLOCK-END
*/
752 &IF DEFINED(EXCLUDE-print-address) = 0 &THEN
754 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-address Procedure
755 PROCEDURE print-address
:
756 /*------------------------------------------------------------------------------
760 ------------------------------------------------------------------------------*/
761 DEF VAR order-date
AS CHAR NO-UNDO.
763 PUT CONTROL creditor-address-font.
765 PUT UNFORMATTED "To:".
RUN carriage-return.
766 PUT UNFORMATTED SPACE(14) STRING( creditor-address
[1], "X(50)" ).
RUN skip-line
(1).
767 PUT UNFORMATTED SPACE(14) STRING( creditor-address
[2], "X(50)" ).
RUN skip-line
(1).
768 PUT UNFORMATTED SPACE(14) STRING( creditor-address
[3], "X(50)" ).
RUN skip-line
(1).
769 PUT UNFORMATTED SPACE(14) STRING( creditor-address
[4], "X(50)" ).
RUN skip-line
(1).
770 PUT UNFORMATTED SPACE(14) STRING( creditor-address
[5], "X(50)" ).
RUN skip-line
(1).
771 PUT UNFORMATTED SPACE(14) STRING( creditor-address
[6], "X(50)" ).
RUN skip-line
(1).
773 IF AVAILABLE(Property
) THEN DO:
774 PUT UNFORMATTED "Delivery:".
RUN carriage-return.
776 PUT UNFORMATTED SPACE(14) STRING( property-address
[1], "X(50)" ).
RUN carriage-return.
778 PUT UNFORMATTED SPACE( 100 ) "Order No:".
779 PUT CONTROL line-printer.
RUN pcl-move-relative
( 0, 10 ).
780 PUT CONTROL num-font.
781 PUT Order.EntityType
STRING( Order.EntityCode
) + "/" + STRING( Order.OrderCode
).
782 PUT CONTROL creditor-address-font.
785 PUT UNFORMATTED SPACE(14) STRING( property-address
[2], "X(50)" ).
RUN skip-line
(1).
788 IF contact-name
<> ''
THEN DO:
789 PUT UNFORMATTED "Contact:".
RUN carriage-return.
790 PUT UNFORMATTED SPACE(14) STRING( contact-name
, "X(50)" ).
RUN carriage-return.
793 PUT UNFORMATTED SPACE( 100 ) "Date:".
794 PUT CONTROL line-printer.
RUN pcl-move-relative
( 0, 10 ).
795 PUT CONTROL creditor-address-font.
796 RUN date-to-word
( Order.OrderDate
, OUTPUT order-date
).
797 PUT order-date
FORMAT '
X(20)'.
800 IF contact-name
<> ''
THEN DO:
801 PUT UNFORMATTED SPACE(14) STRING( contact-phone
, "X(50)" ).
RUN skip-line
(1).
806 /* _UIB-CODE-BLOCK-END
*/
811 &IF DEFINED(EXCLUDE-print-copy-sign) = 0 &THEN
813 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-copy-sign Procedure
814 PROCEDURE print-copy-sign
:
815 /*------------------------------------------------------------------------------
817 ------------------------------------------------------------------------------*/
818 DEF VAR copy-codes
AS CHAR NO-UNDO.
821 RUN hpgl-copywatermark.
822 RUN hpgl-get-codes
( yes
, no
, OUTPUT copy-codes
).
823 PUT CONTROL copy-codes.
827 /* _UIB-CODE-BLOCK-END
*/
832 &IF DEFINED(EXCLUDE-print-header) = 0 &THEN
834 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-header Procedure
835 PROCEDURE print-header
:
836 /*------------------------------------------------------------------------------
838 ------------------------------------------------------------------------------*/
839 DEF VAR approver-text
AS CHAR NO-UNDO.
840 DEF VAR i
AS INT NO-UNDO.
842 RUN pcl-moveto
( 22, 11 ).
843 PUT CONTROL line-printer.
846 RUN pcl-move-relative
( 0, 32 ).
847 PUT CONTROL title-font.
848 PUT UNFORMATTED "PURCHASE ORDER".
RUN carriage-return.
849 PUT CONTROL creditor-address-font.
850 /* PUT UNFORMATTED SPACE(138) STRING( "Page " + STRING( page-no
) ).
*/
851 PUT CONTROL line-printer.
RUN skip-line
(1).
852 PUT CONTROL title-font.
853 PUT UNFORMATTED FILL( "__", 60 ).
858 PUT UNFORMATTED "RE: ".
RUN carriage-return.
859 IF call-description
<> ''
THEN DO:
860 PUT UNFORMATTED SPACE(20) ENTRY( 1, call-description
, "~n").
862 PUT UNFORMATTED "LOCATION: ".
RUN carriage-return.
863 PUT UNFORMATTED SPACE(20) entity-name .
866 PUT UNFORMATTED SPACE(15) entity-name.
869 IF NOT(Order.OrderAmount
> 0) AND Order.ApprovedAmount
> 0 THEN DO:
870 approver-text
= "us".
871 FIND Usr
WHERE Usr.UserName
= Order.FirstApprover
NO-LOCK NO-ERROR.
872 IF AVAILABLE(Usr
) THEN DO:
873 FIND Person
OF Usr
NO-LOCK NO-ERROR.
874 IF AVAILABLE(Person
) THEN approver-text
= Person.FirstName
+ " " + Person.LastName.
876 approver-text
= "Please contact " + approver-text
+ " for further approval if the required work will "
877 + "exceed " + TRIM( STRING( Order.ApprovedAmount
, "$>>>,>>>,>>9.99" ) )
880 RUN word-wrap
( approver-text
, 80, OUTPUT approver-text
).
882 PUT CONTROL prompt-font.
883 DO i
= 1 TO NUM-ENTRIES( approver-text
, "~n" ):
885 PUT UNFORMATTED ENTRY( i
, approver-text
, "~n" ).
890 PUT CONTROL line-printer.
895 /* _UIB-CODE-BLOCK-END
*/
900 &IF DEFINED(EXCLUDE-print-title) = 0 &THEN
902 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-title Procedure
903 PROCEDURE print-title
:
904 /*------------------------------------------------------------------------------
908 ------------------------------------------------------------------------------*/
910 PUT CONTROL line-printer.
913 PUT CONTROL logo-codes.
914 RUN pcl-moveto
( 8, 11 ).
RUN carriage-return.
916 PUT CONTROL line-printer.
921 /* _UIB-CODE-BLOCK-END
*/
926 &IF DEFINED(EXCLUDE-purchase-orders) = 0 &THEN
928 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE purchase-orders Procedure
929 PROCEDURE purchase-orders
:
930 /*------------------------------------------------------------------------------
932 ------------------------------------------------------------------------------*/
933 DEF VAR i
AS INT NO-UNDO.
935 RUN get-control-strings.
937 RUN date-to-word
( TODAY, OUTPUT date-in-words
).
941 FIND Project
WHERE Project.ProjectCode
= entity-code
NO-LOCK NO-ERROR.
942 IF NOT AVAILABLE Project
THEN RETURN.
945 FIND Property
WHERE Property.PropertyCode
= entity-code
NO-LOCK NO-ERROR.
946 IF NOT AVAILABLE Property
THEN DO:
947 MESSAGE "Could not find the property" VIEW-AS ALERT-BOX ERROR.
952 FIND Company
WHERE Company.CompanyCode
= entity-code
NO-LOCK NO-ERROR.
953 IF NOT AVAILABLE Company
THEN RETURN.
956 MESSAGE "No creditor to create order for." VIEW-AS ALERT-BOX ERROR.
960 IF order-list
<> ?
THEN
961 DO i
= 1 TO NUM-ENTRIES( order-list
):
963 /* If outputting to PDF the do individual files for each order
*/
964 IF output-to-pdf
THEN DO:
965 RUN txtrep-pdf-filename
( 'Order-'
+ ENTRY( i
, order-list
) ).
966 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
968 /* Inject the email control sequence if this is to be emailed
*/
969 IF email-address
<> "" THEN
970 RUN txtrep-do-email
( email-address
, 'Purchase Order'
, 'templates
/email
/orderfrm.txt'
).
973 FOR EACH Order
WHERE Order.EntityType
= entity-type
974 AND Order.EntityCode
= entity-code
975 AND Order.OrderCode
= INT( ENTRY( i
, order-list
) ) NO-LOCK:
978 /* If PDF mode then output will be opened again for the next file
*/
979 IF output-to-pdf
THEN
986 /* _UIB-CODE-BLOCK-END
*/
991 &IF DEFINED(EXCLUDE-reset-page) = 0 &THEN
993 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-page Procedure
994 PROCEDURE reset-page
:
995 /*------------------------------------------------------------------------------
999 ------------------------------------------------------------------------------*/
1001 PUT CONTROL reset-page.
1007 /* _UIB-CODE-BLOCK-END
*/
1012 &IF DEFINED(EXCLUDE-skip-line) = 0 &THEN
1014 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-line Procedure
1015 PROCEDURE skip-line
:
1016 /*------------------------------------------------------------------------------
1020 ------------------------------------------------------------------------------*/
1022 DEF INPUT PARAMETER n
AS DEC NO-UNDO.
1024 DEF VAR int-part
AS INT NO-UNDO.
1025 DEF VAR dec-part
AS DEC NO-UNDO.
1027 int-part
= TRUNCATE( n
, 0 ).
1028 IF int-part
< 0 THEN RETURN.
1029 dec-part
= n
- int-part.
1030 IF int-part
= 0 AND dec-part
= 0 THEN RETURN.
1032 /* Need to have this like the following
- do not touch
*/
1033 IF int-part
<> 0 THEN PUT CONTROL FILL( CHR(10), int-part
).
1034 IF dec-part
<> 0 THEN PUT CONTROL half-line.
1038 RUN carriage-return.
1042 /* _UIB-CODE-BLOCK-END
*/
1047 &IF DEFINED(EXCLUDE-skip-to-line) = 0 &THEN
1049 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-to-line Procedure
1050 PROCEDURE skip-to-line
:
1051 /*------------------------------------------------------------------------------
1055 ------------------------------------------------------------------------------*/
1057 DEF INPUT PARAMETER line-no
AS DEC NO-UNDO.
1059 DEF VAR int-part
AS INT NO-UNDO.
1060 DEF VAR dec-part
AS DEC NO-UNDO.
1062 int-part
= TRUNCATE( line-no
- ln
, 0 ).
1063 IF int-part
< 0 THEN RETURN.
1064 dec-part
= ( line-no
- ln
) - int-part.
1065 IF int-part
= 0 AND dec-part
= 0 THEN RETURN.
1067 IF int-part
<> 0 THEN PUT CONTROL FILL( CHR(10), int-part
).
1068 IF dec-part
<> 0 THEN PUT CONTROL half-line.
1072 RUN carriage-return.
1076 /* _UIB-CODE-BLOCK-END
*/