home *** CD-ROM | disk | FTP | other *** search
- * Program............: E:orders.FRG
- * Date...............: 3-10-92
- * Versions...........: dBASE IV, Report 1.5
- *
- * Notes:
- * ------
- * Prior to running this procedure with the DO command
- * it is necessary use LOCATE because the CONTINUE
- * statement is in the main loop.
- *
- *-- Parameters
- PARAMETERS gl_noeject, gl_plain, gl_summary, gc_heading, gc_extra
- ** The first three parameters are of type Logical.
- ** The fourth parameter is a string. The fifth is extra.
- PRIVATE _peject, _wrap
-
- *-- Test for no records found
- IF EOF() .OR. .NOT. FOUND()
- RETURN
- ENDIF
-
- *-- turn word wrap mode off
- _wrap=.F.
-
- IF _plength < (_pspacing * 4 + 1) + (_pspacing * 3 + 1) + 2
- SET DEVICE TO SCREEN
- DEFINE WINDOW gw_report FROM 7,17 TO 11,62 DOUBLE
- ACTIVATE WINDOW gw_report
- @ 0,1 SAY "Increase the page length for this report."
- @ 2,1 SAY "Press any key ..."
- x=INKEY(0)
- DEACTIVATE WINDOW gw_report
- RELEASE WINDOW gw_report
- RETURN
- ENDIF
-
- _plineno=0 && set lines to zero
- *-- NOEJECT parameter
- IF gl_noeject
- IF _peject="BEFORE"
- _peject="NONE"
- ENDIF
- IF _peject="BOTH"
- _peject="AFTER"
- ENDIF
- ENDIF
-
- *-- Set-up environment
- ON ESCAPE DO Prnabort
- IF SET("TALK")="ON"
- SET TALK OFF
- gc_talk="ON"
- ELSE
- gc_talk="OFF"
- ENDIF
- gc_space=SET("SPACE")
- SET SPACE OFF
- gc_time=TIME() && system time for predefined field
- gd_date=DATE() && system date " " " "
- gl_fandl=.F. && first and last page flag
- gl_intros=.F. && flag for group intros on each page
- gl_prntflg=.T. && Continue printing flag
- gl_widow=.T. && flag for checking widow bands
- gn_length=LEN(gc_heading) && store length of the HEADING
- gn_level=2 && current band being processed
- gn_page=_pageno && grab current page number
- gn_pspace=_pspacing && get current print spacing
-
- *-- Initialize group footer field variables
- r_foot1=.F.
-
-
- *-- Set up procedure for page break
- gn_atline=_plength - (_pspacing * 3 + 1)
- ON PAGE AT LINE gn_atline EJECT PAGE
-
- *-- Print Report
-
- PRINTJOB
-
- *-- Initialize group break vars.
- r_mvar4=CUST_ID
-
- *-- Initialize summary variables.
- r_msum1=0
- r_msum2=0
-
- IF gl_plain
- ON PAGE AT LINE gn_atline DO Pgplain
- ELSE
- ON PAGE AT LINE gn_atline DO Pgfoot
- ENDIF
-
- DO Pghead
-
- gl_fandl=.T. && first physical page started
-
- DO Rintro
-
- DO Grphead
- gl_intros=.F.
-
- *-- File Loop
- DO WHILE FOUND() .AND. .NOT. EOF() .AND. gl_prntflg
- DO CASE
- CASE CUST_ID <> r_mvar4
- gn_level=4
- OTHERWISE
- gn_level=0
- ENDCASE
- *-- test whether an expression didn't match
- IF gn_level <> 0
- DO Grpfoot WITH 100-gn_level
- DO Grpinit
- ENDIF
- *-- Repeat group intros
- IF gn_level <> 0
- DO Grphead
- ENDIF
- gl_intros=.F.
- gn_level=0
- *-- Detail lines
- IF gl_summary
- DO Upd_Vars
- ELSE
- DO __Detail
- ENDIF
- gl_widow=.T. && enable widow checking
- CONTINUE
- ENDDO
-
- IF gl_prntflg
- gn_level=3
- DO Grpfoot WITH 97
- DO Rsumm
- IF _plineno <= gn_atline
- EJECT PAGE
- ENDIF
- ELSE
- gn_level=3
- DO Rsumm
- DO Reset
- RETURN
- ENDIF
-
- ON PAGE
-
- ENDPRINTJOB
-
- DO Reset
- RETURN
- * EOP: E:orders.FRG
-
- *-- Determine height of group bands and detail band for widow checking
- FUNCTION Gheight
- PARAMETER Group_Band
- retval=0 && return value
- IF Group_Band <= 4
- retval = retval + 2 * gn_pspace
- ENDIF
- *-- add height of detail band
- retval = retval + 5 * gn_pspace
- RETURN retval
- * EOP: Gheight
-
- *-- Update summary fields and/or calculated fields.
- PROCEDURE Upd_Vars
- r_foot1=Cust_id
- *-- Count
- r_msum1=r_msum1+1
- *-- Count
- r_msum2=r_msum2+1
- RETURN
- * EOP: Upd_Vars
-
- *-- Set flag to get out of DO WHILE loop when escape is pressed.
- PROCEDURE Prnabort
- gl_prntflg=.F.
- RETURN
- * EOP: Prnabort
-
- *-- Reset group break variables. Reinit summary
- *-- fields with reset set to a particular group band.
- PROCEDURE Grpinit
- IF gn_level <= 4
- r_msum1=0
- ENDIF
- IF gn_level <= 4
- r_mvar4=CUST_ID
- ENDIF
- RETURN
- * EOP: Grpinit
-
- *-- Process Group Intro bands during group breaks
- PROCEDURE Grphead
- IF EOF()
- RETURN
- ENDIF
- PRIVATE _pspacing
- _pspacing=gn_pspace
- IF gn_level = 0
- gn_level=50
- ENDIF
- IF gn_level = 4
- IF 2 * gn_pspace < gn_atline
- IF (gl_widow .AND. _plineno+Gheight(4) > gn_atline + 1) ;
- .OR. (gl_widow .AND. _plineno+2 * gn_pspace > gn_atline)
- EJECT PAGE
- ENDIF
- ENDIF
- ENDIF
- IF gn_level <= 4 .OR. gl_intros
- DO Head4
- ENDIF
- gn_level=0
- RETURN
- * EOP: Grphead.PRG
-
- *-- Process Group Summary bands during group breaks
- PROCEDURE Grpfoot
- PARAMETER ln_level
- IF ln_level >= 96
- DO Foot96
- ENDIF
- RETURN
- * EOP: Grpfoot.PRG
-
- PROCEDURE Pghead
- PRIVATE ll_heading, ln_width
- ll_heading = .T.
- ln_width = _rmargin - _lmargin
- ?
- *-- Print HEADING parameter - if it doesn't fit on line one
- *-- Value added to gn_length is the last column on line one times two
- IF .NOT. gl_plain .AND. gn_length + 160 > ln_width
- ?? gc_heading FUNCTION "I;V"+LTRIM(STR(ln_width))
- ?
- ll_heading = .F.
- ENDIF
-
- ?? IIF(gl_plain,'',gd_date) AT 0,;
- IIF(gl_plain,'' , "PAGE " ) AT 71,;
- IIF(gl_plain,'',_pageno) PICTURE "999"
-
- *-- Print HEADING parameter - if it fits on line one
- IF .NOT. gl_plain .AND. gn_length > 0 .AND. ll_heading
- ?? " "
- ?? gc_heading FUNCTION "I;V"+LTRIM(STR(ln_width-(_pcolno*2)))
- ENDIF
- ?
- ?
- ?
- RETURN
- * EOP: Pghead
-
- PROCEDURE Rintro
- ?
- DEFINE BOX FROM 27 TO 56 HEIGHT 4 DOUBLE
- ?
- ?? "A-T FURNITURE INDUSTRIES" AT 30
- ?
- ?? "ORDERS REPORT" AT 35
- ?
- ?
- RETURN
- * EOP: Rintro
-
- PROCEDURE Head4
- ?? ;
- "══════════════════════════════════════════════════════════════════════";
- + "═════════";
- AT 0
- ?
- ?? "CUSTOMER I.D.: " STYLE "BU" AT 0,;
- Cust_id FUNCTION "T" STYLE "BU"
- ?
- RETURN
-
- PROCEDURE __Detail
- IF 5 * gn_pspace < gn_atline - (_pspacing * 4 + 1)
- IF gl_widow .AND. _plineno+5 * gn_pspace > gn_atline + 1
- EJECT PAGE
- gl_intros=.F.
- ENDIF
- ENDIF
- DO Upd_Vars
- ?? "ORDER DATE: " AT 0,;
- Date_trans ,;
- "PART NUMBER: " AT 40,;
- Part_id FUNCTION "T" ,;
- "QUANTITY: " AT 66,;
- Part_qty PICTURE "999"
- ?
- ?? "P.O. NUMBER: " AT 0,;
- Po_number FUNCTION "T"
- ?
- ?? "SOLD BY EMPLOYEE: " AT 0,;
- Emp_id FUNCTION "T" ,;
- "INVOICED: " AT 66,;
- Invoiced PICTURE "Y" AT 78
- ?
- ?? "NOTES: " AT 0,;
- Notes FUNCTION "V64" AT 13
- ?
- ?? ;
- "──────────────────────────────────────────────────────────────────────";
- + "─────────";
- AT 0
- ?
- RETURN
- * EOP: __Detail
-
- PROCEDURE Foot96
- ?? "NUMBER OF ORDERS FOR CUSTOMER " AT 0,;
- r_foot1 FUNCTION "T" ,;
- ": " ,;
- r_msum1 PICTURE "999"
- ?
- ?? ;
- "══════════════════════════════════════════════════════════════════════";
- + "═════════";
- AT 0
- ?
- ?
- RETURN
-
- PROCEDURE Rsumm
- ?? "TOTAL NUMBER OF ORDERS: " AT 0,;
- r_msum2 PICTURE "9,999"
- ?
- ?? ;
- "══════════════════════════════════════════════════════════════════════";
- + "═════════";
- AT 0
- gl_fandl=.F. && last page finished
- ?
- RETURN
- * EOP: Rsumm
-
- PROCEDURE Pgfoot
- PRIVATE _box, _pspacing
- gl_widow=.F. && disable widow checking
- _pspacing=1
- ?
- IF .NOT. gl_plain
- _pspacing=gn_pspace
- ?
- ?? "PREPARED BY SALES DEPARTMENT" AT 28
- ?
- ENDIF
- EJECT PAGE
- gl_intros=.T.
- *-- is the page number greater than the ending page
- IF _pageno > _pepage
- GOTO BOTTOM
- SKIP
- gn_level=0
- ENDIF
- IF .NOT. gl_plain .AND. gl_fandl
- _pspacing=gn_pspace
- DO Pghead
- IF gl_intros .AND. gn_level = 0
- DO GrpHead
- gl_newpage = .F.
- gl_intros = .F.
- ENDIF
- ENDIF
- RETURN
- * EOP: Pgfoot
-
- *-- Process page break when PLAIN option is used.
- PROCEDURE Pgplain
- PRIVATE _box
- EJECT PAGE
- RETURN
- * EOP: Pgplain
-
- *-- Reset dBASE environment prior to calling report
- PROCEDURE Reset
- SET SPACE &gc_space.
- SET TALK &gc_talk.
- ON ESCAPE
- ON PAGE
- RETURN
- * EOP: Reset
-
-