From 8f3a02064d273463894d8fc3c1a55287a7549eb8 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 25 Mar 2009 17:27:08 +1300 Subject: [PATCH] An order form for TGG. --- process/report/ordertgg.p | 1080 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1080 insertions(+) create mode 100644 process/report/ordertgg.p diff --git a/process/report/ordertgg.p b/process/report/ordertgg.p new file mode 100644 index 0000000..2e93bb1 --- /dev/null +++ b/process/report/ordertgg.p @@ -0,0 +1,1080 @@ +&ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 +&ANALYZE-RESUME +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure +/*-------------------------------------------------------------------------- + ------------------------------------------------------------------------*/ + +&SCOPED-DEFINE trn-per-page 58 +DEF INPUT PARAMETER report-options AS CHAR NO-UNDO. + +DEF VAR entity-type AS CHAR NO-UNDO INITIAL "J". +DEF VAR entity-code AS INT NO-UNDO. +DEF VAR order-list AS CHAR NO-UNDO. +DEF VAR no-of-copies AS INT NO-UNDO INITIAL 0. +DEF VAR supplier-copy AS LOGI NO-UNDO INITIAL No. +DEF VAR output-to-pdf AS LOGI NO-UNDO INITIAL NO. +DEF VAR email-address AS CHAR NO-UNDO. +DEF VAR notes-out-codes AS CHAR NO-UNDO. +RUN parse-parameters. + +/* Report counters */ +DEF VAR ln AS DEC INIT 0.00 NO-UNDO. + +/* Line definitions */ + +DEF VAR date-in-words AS CHAR NO-UNDO. +DEF VAR creditor-address AS CHAR NO-UNDO EXTENT 7. +DEF VAR property-address AS CHAR NO-UNDO EXTENT 3. +DEF VAR creditor-phones AS CHAR NO-UNDO EXTENT 2. +DEF VAR trn-line AS CHAR NO-UNDO. +DEF VAR trn-no AS INT NO-UNDO. +DEF VAR regarding AS CHAR NO-UNDO. +DEF VAR client-code AS CHAR NO-UNDO. +DEF VAR entity-name AS CHAR NO-UNDO. +DEF VAR account-name AS CHAR NO-UNDO. +DEF VAR contact-name AS CHAR NO-UNDO. +DEF VAR contact-phone AS CHAR NO-UNDO. + +DEF VAR reset-page AS CHAR NO-UNDO. +DEF VAR half-line AS CHAR NO-UNDO. half-line = CHR(27) + "=". +DEF VAR time-font AS CHAR NO-UNDO. +DEF VAR title-font AS CHAR NO-UNDO. +DEF VAR num-font AS CHAR NO-UNDO. +DEF VAR prompt-font AS CHAR NO-UNDO. +DEF VAR re-font AS CHAR NO-UNDO. +DEF VAR creditor-address-font AS CHAR NO-UNDO. +DEF VAR body-font AS CHAR NO-UNDO. +DEF VAR line-printer AS CHAR NO-UNDO. +DEF VAR order-body-font AS CHAR NO-UNDO. +DEF VAR stamp-font AS CHAR NO-UNDO. + +DEF VAR page-no AS INT NO-UNDO. + +DEF VAR logo-codes AS CHAR NO-UNDO. +DEF VAR copy-no AS INT NO-UNDO. + +DEF VAR time-stamp AS CHAR NO-UNDO. +DEF VAR user-name AS CHAR NO-UNDO. +{inc/username.i "user-name"} + + +time-stamp = + STRING( TODAY, "99/99/9999" ) + " " + STRING( TIME, "HH:MM:SS" ) + + " for " + user-name. + +{inc/ofc-set.i "Order-notes-routine" "order-notes-routine"} +IF NOT AVAILABLE(OfficeSetting) THEN + order-notes-routine = "". + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + + +&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK + +/* ******************** Preprocessor Definitions ******************** */ + +&Scoped-define PROCEDURE-TYPE Procedure +&Scoped-define DB-AWARE no + + + +/* _UIB-PREPROCESSOR-BLOCK-END */ +&ANALYZE-RESUME + + + +/* *********************** Procedure Settings ************************ */ + +&ANALYZE-SUSPEND _PROCEDURE-SETTINGS +/* Settings for THIS-PROCEDURE + Type: Procedure + Allow: + Frames: 0 + Add Fields to: Neither + Other Settings: CODE-ONLY COMPILE + */ +&ANALYZE-RESUME _END-PROCEDURE-SETTINGS + +/* ************************* Create Window ************************** */ + +&ANALYZE-SUSPEND _CREATE-WINDOW +/* DESIGN Window definition (used by the UIB) + CREATE WINDOW Procedure ASSIGN + HEIGHT = .05 + WIDTH = 30.86. +/* END WINDOW DEFINITION */ + */ +&ANALYZE-RESUME + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure +/* ************************* Included-Libraries *********************** */ + +{inc/method/m-txtrep.i} +{inc/method/m-hpgl.i} +{inc/persndtl.i} +{inc/entity.i} +{inc/convert.i} + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + + + + + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure + + +/* *************************** Main Block *************************** */ + +DEF VAR preview AS LOGI INIT No NO-UNDO. + +IF output-to-pdf THEN DO: + RUN txtrep-output-mode( "pdf" ). + RUN hpgl-output-mode( "pdf" ). +END. + +RUN get-control-strings. + +/* +If printing then send all orders to one file, otherwise for PDF output +see the procedure in this file called purchase-orders(). +*/ +IF NOT output-to-pdf THEN + OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0. + +RUN purchase-orders. + +IF NOT output-to-pdf THEN DO: + OUTPUT CLOSE. + RUN view-output-file ( preview ). +END. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + + +/* ********************** Internal Procedures *********************** */ + +&IF DEFINED(EXCLUDE-carriage-return) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE carriage-return Procedure +PROCEDURE carriage-return : +/*------------------------------------------------------------------------------ + Purpose: + Parameters: + Notes: +------------------------------------------------------------------------------*/ + + PUT CONTROL CHR(13). + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-each-order) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-order Procedure +PROCEDURE each-order : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ + RUN get-order-details. + RUN get-creditor-details. + DO copy-no = 1 TO no-of-copies: + + page-no = 1. + + RUN page-header. + RUN order-body. + RUN page-footer. + RUN page-feed. + + END. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-get-account-figures) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-account-figures Procedure +PROCEDURE get-account-figures : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ +DEF OUTPUT PARAMETER YTD-Budget AS DEC NO-UNDO INITIAL 0.0 . +DEF OUTPUT PARAMETER FY-Budget AS DEC NO-UNDO INITIAL 0.0 . +DEF OUTPUT PARAMETER Total-Committed AS DEC NO-UNDO INITIAL 0.0 . +DEF OUTPUT PARAMETER Wait-Appvl AS DEC NO-UNDO INITIAL 0.0 . +DEF OUTPUT PARAMETER OS-Orders AS DEC NO-UNDO INITIAL 0.0 . +DEF OUTPUT PARAMETER YTD-Spent AS DEC NO-UNDO INITIAL 0.0 . + +DEF VAR m1 AS INT NO-UNDO. +DEF VAR m2 AS INT NO-UNDO. +DEF VAR m3 AS INT NO-UNDO. + +DEF VAR et AS CHAR NO-UNDO. +DEF VAR ec AS INT NO-UNDO. +DEF VAR ac AS DEC NO-UNDO. + +/* DEF BUFFER tmp_Project FOR Project. */ + + FIND Month WHERE Month.StartDate <= TODAY AND Month.EndDate >= TODAY NO-LOCK. + m2 = Month.MonthCode. + FIND FinancialYear OF Month NO-LOCK. + IF Order.EntityType = 'J' THEN DO: + FIND FIRST Month NO-LOCK. m1 = Month.MonthCode. + END. + ELSE DO: + FIND FIRST Month OF FinancialYear NO-LOCK. m1 = Month.MonthCode. + END. + FIND LAST Month OF FinancialYear NO-LOCK. m3 = Month.MonthCode. + + ac = Order.AccountCode. + et = Order.EntityType. + ec = Order.EntityCode. + + FOR EACH AccountBalance WHERE AccountBalance.EntityType = et + AND AccountBalance.EntityCode = ec + AND AccountBalance.AccountCode = ac + AND AccountBalance.MonthCode >= m1 + AND AccountBalance.MonthCode <= m3 NO-LOCK: + FY-Budget = FY-Budget + AccountBalance.Budget. + IF AccountBalance.MonthCode <= m2 THEN DO: + YTD-Budget = YTD-Budget + AccountBalance.Budget. + YTD-Spent = YTD-Spent + AccountBalance.Balance. + END. + END. + + DEF BUFFER tmp_Order FOR Order. + FOR EACH tmp_Order WHERE tmp_Order.EntityType = et + AND tmp_Order.EntityCode = ec + AND tmp_Order.AccountCode = ac + AND ROWID(tmp_Order) <> ROWID(Order) NO-LOCK: + OS-Orders = OS-Orders + tmp_Order.ApprovedAmount . + FOR EACH Voucher WHERE Voucher.EntityType = et + AND Voucher.EntityCode = ec + AND Voucher.OrderCode = tmp_Order.OrderCode NO-LOCK: + IF Voucher.VoucherStatus = "U" THEN DO: + Wait-Appvl = Wait-Appvl + Voucher.GoodsValue. + END. + IF Voucher.VoucherStatus <> "C" THEN DO: + OS-Orders = OS-Orders - Voucher.GoodsValue. + END. + END. + END. + + + OS-Orders = OS-Orders + Order.ApprovedAmount . + FOR EACH Voucher WHERE Voucher.EntityType = et + AND Voucher.EntityCode = ec + AND Voucher.OrderCode = Order.OrderCode NO-LOCK: + IF Voucher.VoucherStatus = "U" THEN + Wait-Appvl = Wait-Appvl + Voucher.GoodsValue. + ELSE IF Voucher.VoucherStatus <> "C" THEN DO: + OS-Orders = OS-Orders - Voucher.GoodsValue. + END. + END. + + Total-Committed = YTD-Spent + OS-Orders + Wait-Appvl. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-get-control-strings) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-control-strings Procedure +PROCEDURE get-control-strings : +/*------------------------------------------------------------------------------ + Purpose: Get all control strings for this report + Parameters: + Notes: +------------------------------------------------------------------------------*/ +DEF VAR rows AS DEC NO-UNDO. +DEF VAR cols AS DEC NO-UNDO. + + RUN make-control-string( "PCL", "reset,simplex,portrait,a4,tm,0,lm,6", + OUTPUT reset-page, OUTPUT rows, OUTPUT cols ). + + RUN make-control-string( "PCL", "Helvetica,Point,20,Bold,Proportional,lpi,3.6", + OUTPUT title-font, OUTPUT rows, OUTPUT cols ). + + RUN make-control-string( "PCL", "Times,Point,6,Normal,Proportional,lpi,12", + OUTPUT time-font, OUTPUT rows, OUTPUT cols ). + + RUN make-control-string( "PCL", "Helvetica,Point,12,Proportional,Bold,lpi,6", + OUTPUT prompt-font, OUTPUT rows, OUTPUT cols ). + + RUN make-control-string( "PCL", "Times,Point,16,Bold,Proportional,lpi,4.5", + OUTPUT num-font, OUTPUT rows, OUTPUT cols ). + + RUN make-control-string( "PCL", "Helvetica,Point,14,Proportional,Bold,lpi,5", + OUTPUT re-font, OUTPUT rows, OUTPUT cols ). + + RUN make-control-string( "PCL", "Helvetica,Point,10,Proportional,Normal,lpi,7", + OUTPUT creditor-address-font, OUTPUT rows, OUTPUT cols ). + + RUN make-control-string( "PCL", "Courier,fixed,Point,10,normal,lpi,7", + OUTPUT order-body-font, OUTPUT rows, OUTPUT cols ). + + RUN make-control-string( "PCL", "Courier,fixed,cpi,14,lpi,6,normal", + OUTPUT line-printer, OUTPUT rows, OUTPUT cols ). + + RUN make-control-string( "PCL", "Times,Point,4,Proportional,Normal,lpi,17", + OUTPUT stamp-font, OUTPUT rows, OUTPUT cols ). + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-get-creditor-details) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-creditor-details Procedure +PROCEDURE get-creditor-details : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ + + DEF VAR i AS INT NO-UNDO. + DEF VAR addr AS CHAR NO-UNDO. + + FIND Creditor WHERE Creditor.CreditorCode = Order.CreditorCode NO-LOCK NO-ERROR. + + RUN process/getaddr.p( "C", Creditor.CreditorCode, "PYMT,MAIN", OUTPUT addr ). + DO i = 1 TO 7: creditor-address[i] = "". END. + DO i = 1 TO NUM-ENTRIES( addr, CHR(10) ): + creditor-address[i] = ENTRY( i, addr, CHR(10) ). + END. + + creditor-phones[1] = "". + FIND FIRST PhoneDetail WHERE PhoneDetail.PersonCode = Creditor.PaymentContact + AND PhoneType = 'BUS' NO-LOCK NO-ERROR. + IF AVAILABLE(PhoneDetail) THEN DO: + RUN combine-phone( PhoneDetail.cCountryCode, PhoneDetail.cSTDCode, PhoneDetail.Number, + OUTPUT creditor-phones[1] ). + creditor-phones[1] = "Bus: " + creditor-phones[1]. + END. + + FIND FIRST PhoneDetail WHERE PhoneDetail.PersonCode = Creditor.PaymentContact + AND PhoneType = 'FAX' NO-LOCK NO-ERROR. + creditor-phones[2] = "". + IF AVAILABLE(PhoneDetail) THEN DO: + RUN combine-phone( PhoneDetail.cCountryCode, PhoneDetail.cSTDCode, PhoneDetail.Number, + OUTPUT creditor-phones[2] ). + creditor-phones[2] = "Fax: " + creditor-phones[2]. + END. + + creditor-address[i] = creditor-phones[1]. + creditor-address[i + 1] = creditor-phones[2]. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-get-order-details) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-order-details Procedure +PROCEDURE get-order-details : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ + IF NOT AVAILABLE Order THEN RETURN. + + entity-name = get-entity-name( entity-type, entity-code). + client-code = get-entity-client( entity-type, entity-code). + account-name = get-entity-account( entity-type, entity-code, Order.AccountCode ). + + IF entity-type = 'P' THEN DO: + FIND FIRST Property WHERE Property.PropertyCode = entity-code NO-LOCK. + property-address[1] = ENTRY( 1, Property.StreetAddress ). + property-address[2] = TRIM(SUBSTRING( Property.StreetAddress, LENGTH(property-address[1]) + 2) ). + + contact-name = ''. + contact-phone = ''. + FIND FIRST TenantCall OF Property WHERE TenantCall.OrderNo = Order.OrderCode NO-LOCK. + IF AVAILABLE(TenantCall) THEN DO: + contact-name = TenantCall.ContactName. + contact-phone = TenantCall.ContactPhone. + END. + END. + ELSE DO: + property-address[1] = ''. + property-address[2] = ''. + + contact-name = ''. + contact-phone = ''. + END. + + RUN hpgl-initialize. + RUN client-logo( entity-type, entity-code, client-code ). + RUN client-address( entity-type, entity-code, client-code ). + + RUN hpgl-moveto(0,260). + RUN hpgl-get-codes( yes, yes, OUTPUT logo-codes ). + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-next-line) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE next-line Procedure +PROCEDURE next-line : +/*------------------------------------------------------------------------------ + Purpose: + Parameters: + Notes: +------------------------------------------------------------------------------*/ + + trn-no = trn-no + 1. + + IF trn-no > {&trn-per-page} THEN + DO: + RUN page-footer. + RUN page-feed. + RUN page-header. + END. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-order-body) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE order-body Procedure +PROCEDURE order-body : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ + +&SCOP wrap-width 70 + + DEf VAR i AS INT NO-UNDO. + DEF VAR order-text AS CHAR NO-UNDO. + + RUN pcl-moveto( 27, 11 ). RUN carriage-return. + PUT CONTROL creditor-address-font. + PUT UNFORMATTED "Description". + RUN skip-line(1). + + PUT CONTROL order-body-font. + + RUN word-wrap( Order.Description, {&wrap-width}, OUTPUT order-text ). + + DO i = 1 TO NUM-ENTRIES( order-text, "~n" ): + RUN next-line. + PUT UNFORMATTED ENTRY( i, order-text, "~n" ). + RUN skip-line(1). + END. + + IF Order.OrderAmount > 0 THEN DO: + DEF VAR amount-out AS CHAR NO-UNDO. + RUN pcl-moveto( 61, 11 ). RUN carriage-return. + PUT CONTROL num-font. + PUT UNFORMATTED SPACE(59) "AMOUNT: ". RUN carriage-return. + amount-out = TRIM(STRING( Order.OrderAmount, "$>>>,>>>,>>9.99" )). + PUT UNFORMATTED SPACE(77) SPACE( 2 * (14 - LENGTH(amount-out))) amount-out. + /* + IF Order.TaxAmount <> ? AND Order.TaxAmount <> 0 THEN DO: + PUT UNFORMATTED " plus GST of " TRIM( STRING( Order.TaxAmount, "$>>>,>>>,>>9.99" ) ). + END. + */ + RUN skip-line(1.3). + END. + +/* + DEF VAR box-codes AS CHAR NO-UNDO. + RUN hpgl-clear. + RUN hpgl-moveto(23,107). + RUN hpgl-pen-down. + RUN hpgl-set-line-type( 2, 1, 1 ). + RUN hpgl-set-line-width( 0.25 ). + RUN hpgl-box-relative(167,63). + RUN hpgl-pen-up. + RUN hpgl-moveto(127,89). + RUN hpgl-pen-down. + RUN hpgl-set-line-width( 1 ). + RUN hpgl-box-relative(63,11). + RUN hpgl-pen-up. + RUN hpgl-moveto(0,260). + RUN hpgl-get-codes( yes, NO, OUTPUT box-codes ). + + PUT CONTROL box-codes. +*/ + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-page-feed) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-feed Procedure +PROCEDURE page-feed : +/*------------------------------------------------------------------------------ + Purpose: + Parameters: + Notes: +------------------------------------------------------------------------------*/ + + PUT CONTROL CHR(12). + page-no = page-no + 1. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-page-footer) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-footer Procedure +PROCEDURE page-footer : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ + + IF copy-no = 1 AND supplier-copy THEN + RUN page-footer-creditor. + ELSE + RUN page-footer-copy. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-page-footer-copy) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-footer-copy Procedure +PROCEDURE page-footer-copy : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ +DEF VAR YTD-Budget AS DEC NO-UNDO . +DEF VAR FY-Budget AS DEC NO-UNDO . +DEF VAR Total-Committed AS DEC NO-UNDO . +DEF VAR Wait-Appvl AS DEC NO-UNDO . +DEF VAR OS-Orders AS DEC NO-UNDO . +DEF VAR YTD-Spent AS DEC NO-UNDO . + + RUN get-account-figures( OUTPUT YTD-Budget, OUTPUT FY-Budget, OUTPUT Total-Committed, + OUTPUT Wait-Appvl, OUTPUT OS-Orders, OUTPUT YTD-Spent ). + PUT CONTROL line-printer. + RUN pcl-moveto( 56, 10 ). RUN carriage-return. + PUT UNFORMATTED "Account coding: " + STRING(Order.AccountCode, "9999.99") + SPACE(3) account-name. + RUN carriage-return. + + PUT CONTROL title-font. PUT UNFORMATTED FILL( "__", 60 ). PUT CONTROL line-printer. + RUN skip-line(1.2). + + PUT UNFORMATTED "Total Paid Year to date: " + STRING(YTD-Spent, "->>>,>>>,>>9.99") + SPACE(20) "Full Year Budget: " + STRING(FY-Budget,"->>>,>>>,>>9.99"). + RUN skip-line(1.2). + + PUT UNFORMATTED "Vouchers awaiting approval: " + STRING(Wait-Appvl, "->>>,>>>,>>9.99") + SPACE(20) "YTD Budget: " + STRING(YTD-Budget,"->>>,>>>,>>9.99"). + RUN skip-line(1.2). + + PUT UNFORMATTED "Orders not yet invoiced: " + STRING(OS-Orders, "->>>,>>>,>>9.99") + SPACE(20) "Total Committed: " + STRING(Total-Committed,"->>>,>>>,>>9.99"). + RUN carriage-return. + PUT CONTROL title-font. PUT UNFORMATTED FILL( "__", 60 ). PUT CONTROL line-printer. + RUN skip-line(2). + + PUT CONTROL prompt-font. + PUT UNFORMATTED "__________ : Ordered from supplier". + RUN carriage-return. + PUT UNFORMATTED SPACE(55) "__________ ____/_____/_____ : Order requested". + RUN skip-line(2). + + PUT UNFORMATTED "__________ : Copy to accounts". + RUN carriage-return. + PUT UNFORMATTED SPACE(55) "__________ ____/_____/_____ : Order approved". + RUN skip-line(2). + + PUT UNFORMATTED "__________ : Filing Code". + RUN skip-line(0.7). + PUT CONTROL stamp-font. + PUT UNFORMATTED time-stamp. + +/* PUT CONTROL line-printer. + RUN pcl-moveto( 103, 10 ). */ + RUN print-copy-sign. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-page-footer-creditor) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-footer-creditor Procedure +PROCEDURE page-footer-creditor : +/*------------------------------------------------------------------------------ + Purpose: + Parameters: + Notes: +------------------------------------------------------------------------------*/ + + IF order-notes-routine <> "" THEN DO: + RUN hpgl-initialize. + IF output-to-pdf THEN + RUN VALUE(order-notes-routine) ( "pdf" ). + ELSE + RUN VALUE(order-notes-routine) ( "hpgl" ). + RUN hpgl-append( RETURN-VALUE ). + RUN hpgl-get-codes( YES, YES, OUTPUT notes-out-codes ). + PUT CONTROL notes-out-codes. + + PUT CONTROL line-printer. + RUN pcl-moveto( 65, 11 ). RUN carriage-return. + RUN skip-line(1). + END. + ELSE DO: + PUT CONTROL line-printer. + RUN pcl-moveto( 63, 11 ). RUN carriage-return. + + PUT CONTROL prompt-font. + PUT UNFORMATTED "Please note: Any works exceeding $550.00 (including GST) in value requires written". + RUN skip-line(1). + PUT UNFORMATTED "approval by an authorized representative of the George Group prior to acceptance of". + RUN skip-line(1). + PUT UNFORMATTED "quotation & commencement of works.". + RUN skip-line(1). + END. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-page-header) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-header Procedure +PROCEDURE page-header : +/*------------------------------------------------------------------------------ + Purpose: + Parameters: + Notes: +------------------------------------------------------------------------------*/ + + RUN reset-page. + RUN print-title. + RUN print-address. + RUN print-header. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure +PROCEDURE parse-parameters : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ +DEF VAR token AS CHAR NO-UNDO. +DEF VAR i AS INT NO-UNDO. + +{inc/showopts.i "report-options"} + + DO i = 1 TO NUM-ENTRIES( report-options, "~n" ): + token = ENTRY( i, report-options, "~n" ). + + CASE ENTRY( 1, token ): + WHEN "SupplierCopy" THEN supplier-copy = Yes. + WHEN "InternalCopies" THEN no-of-copies = INT( ENTRY(2,token) ). + WHEN "OutputPDF" THEN output-to-pdf = YES. + WHEN "EmailAddress" THEN email-address = ENTRY( 2, token ). + WHEN "Entity" THEN ASSIGN + entity-type = ENTRY(2,token) + entity-code = INT( ENTRY(3,token) ) . + WHEN "Orders" THEN + order-list = SUBSTRING(token, INDEX(token,",") + 1). + END CASE. + END. + + IF supplier-copy THEN no-of-copies = no-of-copies + 1. + + /* Regardless of options, force one copy only if for PDF output */ + IF output-to-pdf THEN + no-of-copies = 1. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-print-address) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-address Procedure +PROCEDURE print-address : +/*------------------------------------------------------------------------------ + Purpose: + Parameters: + Notes: +------------------------------------------------------------------------------*/ +DEF VAR order-date AS CHAR NO-UNDO. + + PUT CONTROL creditor-address-font. + + PUT UNFORMATTED "To:". RUN carriage-return. + PUT UNFORMATTED SPACE(14) STRING( creditor-address[1], "X(50)" ). RUN skip-line(1). + PUT UNFORMATTED SPACE(14) STRING( creditor-address[2], "X(50)" ). RUN skip-line(1). + PUT UNFORMATTED SPACE(14) STRING( creditor-address[3], "X(50)" ). RUN skip-line(1). + PUT UNFORMATTED SPACE(14) STRING( creditor-address[4], "X(50)" ). RUN skip-line(1). + PUT UNFORMATTED SPACE(14) STRING( creditor-address[5], "X(50)" ). RUN skip-line(1). + PUT UNFORMATTED SPACE(14) STRING( creditor-address[6], "X(50)" ). RUN skip-line(1). + + IF AVAILABLE(Property) THEN DO: + PUT UNFORMATTED "Delivery:". RUN carriage-return. + END. + PUT UNFORMATTED SPACE(14) STRING( property-address[1], "X(50)" ). RUN carriage-return. + + PUT UNFORMATTED SPACE( 100 ) "Order No:". + PUT CONTROL line-printer. RUN pcl-move-relative( 0, 10 ). + PUT CONTROL num-font. + PUT Order.EntityType STRING( Order.EntityCode ) + "/" + STRING( Order.OrderCode ). + PUT CONTROL creditor-address-font. + RUN skip-line(1). + + PUT UNFORMATTED SPACE(14) STRING( property-address[2], "X(50)" ). RUN skip-line(1). + RUN skip-line(1). + + IF contact-name <> '' THEN DO: + PUT UNFORMATTED "Contact:". RUN carriage-return. + PUT UNFORMATTED SPACE(14) STRING( contact-name, "X(50)" ). RUN carriage-return. + END. + + PUT UNFORMATTED SPACE( 100 ) "Date:". + PUT CONTROL line-printer. RUN pcl-move-relative( 0, 10 ). + PUT CONTROL creditor-address-font. + RUN date-to-word( Order.OrderDate, OUTPUT order-date ). + PUT order-date FORMAT 'X(20)'. + RUN skip-line(1). + + IF contact-name <> '' THEN DO: + PUT UNFORMATTED SPACE(14) STRING( contact-phone, "X(50)" ). RUN skip-line(1). + END. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-print-copy-sign) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-copy-sign Procedure +PROCEDURE print-copy-sign : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ +DEF VAR copy-codes AS CHAR NO-UNDO. + + RUN hpgl-initialize. + RUN hpgl-copywatermark. + RUN hpgl-get-codes( yes, no, OUTPUT copy-codes ). + PUT CONTROL copy-codes. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-print-header) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-header Procedure +PROCEDURE print-header : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ +DEF VAR approver-text AS CHAR NO-UNDO. +DEF VAR i AS INT NO-UNDO. + + RUN pcl-moveto( 22, 11 ). + PUT CONTROL line-printer. + RUN skip-line(1). + + RUN pcl-move-relative( 0, 32 ). + PUT CONTROL title-font. + PUT UNFORMATTED "PURCHASE ORDER". RUN carriage-return. + PUT CONTROL creditor-address-font. + /* PUT UNFORMATTED SPACE(138) STRING( "Page " + STRING( page-no ) ). */ + PUT CONTROL line-printer. RUN skip-line(1). + PUT CONTROL title-font. + PUT UNFORMATTED FILL( "__", 60 ). + RUN skip-line(1). + + /* Regarding bit */ + PUT CONTROL re-font. + PUT UNFORMATTED "RE: ". RUN carriage-return. + IF Order.EntityType = 'P' THEN DO: + PUT UNFORMATTED SPACE(20) ENTRY( 1, Order.Description, "~n"). + FIND FIRST Property WHERE Property.PropertyCode = Order.EntityCode NO-LOCK NO-ERROR. + IF AVAILABLE(Property) THEN DO: + RUN skip-line(1). + PUT UNFORMATTED "LOCATION: ". RUN carriage-return. + PUT UNFORMATTED SPACE(20) entity-name . + END. + END. + ELSE DO: + PUT UNFORMATTED SPACE(15) entity-name. + END. + RUN skip-line(1.3). + IF NOT(Order.OrderAmount > 0) AND Order.ApprovedAmount > 0 THEN DO: + approver-text = "us". + FIND Usr WHERE Usr.UserName = Order.FirstApprover NO-LOCK NO-ERROR. + IF AVAILABLE(Usr) THEN DO: + FIND Person OF Usr NO-LOCK NO-ERROR. + IF AVAILABLE(Person) THEN approver-text = Person.FirstName + " " + Person.LastName. + END. + approver-text = "Please contact " + approver-text + " for further approval if the required work will " + + "exceed " + TRIM( STRING( Order.ApprovedAmount, "$>>>,>>>,>>9.99" ) ) + + " in total.". + + RUN word-wrap( approver-text, 80, OUTPUT approver-text ). + + PUT CONTROL prompt-font. + DO i = 1 TO NUM-ENTRIES( approver-text, "~n" ): + RUN next-line. + PUT UNFORMATTED ENTRY( i, approver-text, "~n" ). + RUN skip-line(1). + END. + END. + + PUT CONTROL line-printer. + RUN skip-line(1). + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-print-title) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-title Procedure +PROCEDURE print-title : +/*------------------------------------------------------------------------------ + Purpose: + Parameters: + Notes: +------------------------------------------------------------------------------*/ + + PUT CONTROL line-printer. + RUN skip-line(2). + + PUT CONTROL logo-codes. + RUN pcl-moveto( 8, 11 ). RUN carriage-return. + + PUT CONTROL line-printer. + + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-purchase-orders) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE purchase-orders Procedure +PROCEDURE purchase-orders : +/*------------------------------------------------------------------------------ + Purpose: +------------------------------------------------------------------------------*/ +DEF VAR i AS INT NO-UNDO. + + RUN get-control-strings. + + RUN date-to-word( TODAY, OUTPUT date-in-words ). + + CASE entity-type: + WHEN "J" THEN DO: + FIND Project WHERE Project.ProjectCode = entity-code NO-LOCK NO-ERROR. + IF NOT AVAILABLE Project THEN RETURN. + END. + WHEN "P" THEN DO: + FIND Property WHERE Property.PropertyCode = entity-code NO-LOCK NO-ERROR. + IF NOT AVAILABLE Property THEN DO: + MESSAGE "Could not find the property" VIEW-AS ALERT-BOX ERROR. + RETURN. + END. + END. + WHEN "L" THEN DO: + FIND Company WHERE Company.CompanyCode = entity-code NO-LOCK NO-ERROR. + IF NOT AVAILABLE Company THEN RETURN. + END. + OTHERWISE DO: + MESSAGE "No creditor to create order for." VIEW-AS ALERT-BOX ERROR. + END. + END CASE. + + IF order-list <> ? THEN + DO i = 1 TO NUM-ENTRIES( order-list ): + + /* If outputting to PDF the do individual files for each order */ + IF output-to-pdf THEN DO: + RUN txtrep-pdf-filename( 'Order-' + ENTRY( i, order-list ) ). + OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0. + + /* Inject the email control sequence if this is to be emailed */ + IF email-address <> "" THEN + RUN txtrep-do-email( email-address, 'Purchase Order', 'templates/email/orderfrm.txt' ). + END. + + FOR EACH Order WHERE Order.EntityType = entity-type + AND Order.EntityCode = entity-code + AND Order.OrderCode = INT( ENTRY( i, order-list ) ) NO-LOCK: + RUN each-order. + + /* If PDF mode then output will be opened again for the next file */ + IF output-to-pdf THEN + OUTPUT CLOSE. + END. + END. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-reset-page) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-page Procedure +PROCEDURE reset-page : +/*------------------------------------------------------------------------------ + Purpose: + Parameters: + Notes: +------------------------------------------------------------------------------*/ + + PUT CONTROL reset-page. + trn-no = 0. + ln = 0. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-skip-line) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-line Procedure +PROCEDURE skip-line : +/*------------------------------------------------------------------------------ + Purpose: + Parameters: + Notes: +------------------------------------------------------------------------------*/ + + DEF INPUT PARAMETER n AS DEC NO-UNDO. + + DEF VAR int-part AS INT NO-UNDO. + DEF VAR dec-part AS DEC NO-UNDO. + + int-part = TRUNCATE( n, 0 ). + IF int-part < 0 THEN RETURN. + dec-part = n - int-part. + IF int-part = 0 AND dec-part = 0 THEN RETURN. + + /* Need to have this like the following - do not touch */ + IF int-part <> 0 THEN PUT CONTROL FILL( CHR(10), int-part ). + IF dec-part <> 0 THEN PUT CONTROL half-line. + + ln = ln + n. + + RUN carriage-return. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + +&IF DEFINED(EXCLUDE-skip-to-line) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-to-line Procedure +PROCEDURE skip-to-line : +/*------------------------------------------------------------------------------ + Purpose: + Parameters: + Notes: +------------------------------------------------------------------------------*/ + + DEF INPUT PARAMETER line-no AS DEC NO-UNDO. + + DEF VAR int-part AS INT NO-UNDO. + DEF VAR dec-part AS DEC NO-UNDO. + + int-part = TRUNCATE( line-no - ln, 0 ). + IF int-part < 0 THEN RETURN. + dec-part = ( line-no - ln ) - int-part. + IF int-part = 0 AND dec-part = 0 THEN RETURN. + + IF int-part <> 0 THEN PUT CONTROL FILL( CHR(10), int-part ). + IF dec-part <> 0 THEN PUT CONTROL half-line. + + ln = line-no. + + RUN carriage-return. + +END PROCEDURE. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + -- 2.11.4.GIT