#
################################################################
# Facts7-5.rul rule file for standard Facts Accounting Software#
# Based upon Facts 7.2 demo data - 66 line non-preprinted docs #
# Requires, at least, UnForm version 5.0                       #
################################################################
# This rule file is provided "AS IS", without warranty. #
# Under no circumstances will the publisher be liable   #
# for consequential damages resulting from the use or   #
# inability to use the contents.                        #
#########################################################
#
# This rule file has been tested in version 6 with the GUI design tool
# and tests OK. 03/15/2004 - bcj
#
# NOTE: SDSI has attempted to create rule sets that are generic enough that they cover
#   as many options as possible.
#   If you find situations that the rule set is not handling properly, do not
#   hesitate to contact us and provide us with a sample text file showing the problem.
#   We will be happy to provide the "correction" in a timely manner.
#   The above assumes that no modifications have been made to the application.
#

# Generic comments ######################################
#
# choose correct FILL_CMD constant below for PVX or BBx
#
# Make changes to all constants as needed.
#

# Completed forms:
# ap - aging: detail, summary
# ap - checks, vouchers, cash requirements
# ar - aged trial balance: detail, summary, transactions
# ar - statement, dunning letter , invoice
# gl - balance sheet: 850,852,854,856,880
# gl - profit/loss: 820,822,824,826,828,830,832,834,836,838,840,842,844,848
# gl - trial balance, chart of accounts
# ic - transfer ticket
# jc - estimate, invoice
# mc - production ticket
# po - order, fill report
# pr - checks: long stub, short stub
# so - pick ticket, counter invoice, quote, bill of lading
# so - invoice: long form, short form, gross margin
# so - rga: short form, long form
# sr - invoice, work ticket
# generic reports (row 1 contains either PAGE or Page)

#
# Modification history
#
# Last modified 10/18/2004
#
# 02/20/2003 -- bcj
#   Added enhancements to P/O to handle confirm & acknowledgement
# 05/01/2003 -- bcj
#   Removed merge rule file constants because if you change the name of
#   the main rule file, you might forget to change this name.

# Note regarding ProvideX 4.xx, or ProvideX 5.xx with a 4.xx activation:
# The 32K string size limit of these releases of ProvideX will likely
# require that the GSON constant be set to "#gs on".  Also, low-bandwidth
# printer connections (i.e. serial) would benefit from commenting out
# gs on as well.

# Global constants #######################################

# Adjust the following constants to correct files and info
# if you use the subst file then replace each constant
# with subst info in rule sets below
const COMP_NAME="Company Name: Edit rule file"
const COMP_ADDR1="Address 1"
const COMP_ADDR2="Address 2"
const COMP_ADDR3="Address 3"
const COMP_PHONES="###-###-####  Fax: ###-###-####"
const COMP_EMAIL="E-Mail: xxxx@xxxxxxxxxxxxxxx.com"
const COMP_WEBSITE="Website: www.xxxxxxxxxxxxxxx.com"

# A/P check constants
const AP_BANK_NAME="One Major Bank"
const AP_BANK_ADDR1="1 Major Blvd"
const AP_BANK_ADDR2="Major City CA 90123"
const AP_ROUTING="12-345/6789"
const AP_MICR_ACCOUNTNO=":123456789:9999-1234<34>"
const AP_MICR="micr"                # remove # to turn on
const AP_NO_STUBS=2             # 1=vendor stub only
							# 2=vendor stub and payor stub

# P/R check constants
const PR_BANK_NAME="One Major Bank"
const PR_BANK_ADDR1="1 Major Blvd"
const PR_BANK_ADDR2="Major City CA 90123"
const PR_ROUTING="12-345/6789"
const PR_MICR_ACCOUNTNO=":123456789:9999-1234<34>"
const PR_MICR="micr"        # remove # to turn on
const PR_NO_STUBS=2     # does not apply to long stub version
					# 1=employee stub only
					# 2=employee stub and employer stub

# check signature on AP/PR checks,
const SIGNATURE_IMAGE="#image"      # remove # to turn on
const SIGNATURE=""              # insert signature file name

# Logos
const LOGO_IMAGE="image"            # remove # to turn on
const COMP_LOGO="sdsilogo.pcl"      # change to your logo file name

# watermarks
const WATERMARK_SHADE=10            # adjust to desired darkness
const WATERMARK="text"              # remove # to turn on

# PCL graphical shading uses a lot of memory
# PVX should be version 5 due to long string sizes
# DO NOT use if in slow printing environment like serial connections
# An example of sizing using sdsi's sample1.txt
# 300 dpi no gs 39KB
# 300 dpi w/ gs 86KB
# 600 dpi no gs 40KB
# 600 dpi w/ gs 216KB
# change #gs on to  gs on to turn on  graphical shading
# change  gs on to #gs on to turn off graphical shading
const GSON="gs on"

# What justification for ITEM column header
const IJUST="right"

# date mask for detects - 10/17/01
const DATEMASK="[0-1][0-9]/[0-3][0-9]/[0-9][0-9]"   # US dt
#const DATEMASK="[0-3][0-9]/[0-1][0-9]/[0-9][0-9]"  # Can dt

# BBx uses fill command, PVx uses dim command
#const FILL_CMD=fill                     # BBx
const FILL_CMD=dim                     # PVx

# main heading constants
const HFONT=  univers,11
const HCFONT= HFONT,center
const HRFONT= HFONT,right
const HSHADE= 30
# bold
const HBFONT= HFONT,bold
const HBCFONT=HBFONT,center
const HBRFONT=HBFONT,right

# internal heading font constants (ribbons, detail headers)
const IFONT=  univers,8,italic,fit
const ICFONT= IFONT,center
const IRFONT= IFONT,right
const ISHADE= 20
# bold
const IBFONT= IFONT,bold
const IBCFONT=IBFONT,center
const IBRFONT=IBFONT,right

# detail data font constants
const DFONT=  cgtimes,9
const DCFONT= DFONT,center
const DRFONT= DFONT,right
const DSHADE= 10
# bold
const DBFONT= DFONT,bold
const DBCFONT=DBFONT,center
const DBRFONT=DBFONT,right

# default major section box size
const MBOXSIZE=5

#***************************************************************
#           Merge rule sets for the facts7-5 rule file         *
#***************************************************************

[Mrg Report Header]
cerase 1,1,MAXCOLS,3
cbox LEFTCOL,.5,RIGHTCOL,3.25,MBOXSIZE,HSHADE
text 2,1.5,{rptdate$},HBFONT
text 1,1.5,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.5,{pageno$},HBRFONT,cols=MAXRCOLS
text 2,2.75,{user$},HBFONT
text 1,2.75,{doc_title$},HBCFONT,12,cols=MAXCOLS
text 1,2.75,{time$},HBRFONT,cols=MAXRCOLS

[Mrg Form Header]
LOGO_IMAGE 1,1,12,6,"COMP_LOGO"
text 1,{tpos},{doc_title$},HBRFONT,16,cols=MAXRCOLS
text 1,3.2,{reprint$},HRFONT,12,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS

[Mrg get company info]
# get comp info from page or constants?
compname$=trim(get(xcol,xrow,xcols))
if compname$="" then  compname$="COMP_NAME";  addr1$="COMP_ADDR1";  addr2$="COMP_ADDR2";  addr3$="COMP_ADDR3";  phone$="Phone: COMP_PHONES"  else  addr1$=trim(get(xcol,xrow+1,xcols));  addr2$=trim(get(xcol,xrow+2,xcols));  addr3$=trim(get(xcol,xrow+3,xcols));  phone$=trim(get(xcol,xrow+4,xcols));  if phone$="" then if addr3$="" or  addr3$(1,1)>="A" then  phone$="Phone: COMP_PHONES"  else  phone$="Phone: "+addr3$,addr3$=""  else    phone$="Phone: "+phone$
if addr3$="" then addr3$=phone$,phone$=""

[Mrg get watermark text]
	wmlines=1,wdoc_title$="",xdoc_title$=trim(doc_title$)
watermark_loop:
	x=pos(" "=xdoc_title$)
	if x=0 then if wdoc_title$="" then wdoc_title$=xdoc_title$ else  wdoc_title$=wdoc_title$+$0a$+trim(xdoc_title$) fi;  goto end_watermark_loop
	if wdoc_title$="" then wdoc_title$=trim(xdoc_title$(1,x)) else  wdoc_title$=wdoc_title$+$0a$+trim(xdoc_title$(1,x))
	xdoc_title$=trim(xdoc_title$(x+1))
	wmlines=wmlines+1
	goto watermark_loop
end_watermark_loop:

[Mrg get desc pos]
desc_pos=pos("DESCRIPTION"=text$[xrow])
if desc_pos=0 then desc_pos=pos("Description"=text$[xrow])

[Mrg find detail bottom]
# search for bottom of vertical lines in detail area
# prepayment area should not have any vertical lines
# detail lines will have many !, prepayment only 2 !
detail_bottom=yrow
equal$=FILL_CMD(xcols,"=")
for i=xrow to yrow-1
	if pos(equal$=text$[i])=2 then  detail_bottom=i;break
	x=pos("!"=text$[i],1,0)                 # get # of !
	if x=2 then detail_bottom=i-1; break
next i

[Mrg find memos]
# find memo lines and mark them for enhancing later
if xrow>=yrow-1 then goto end_find_memos
serial_on=0
for i=xrow to yrow-1
	# is it a blank line?
	if trim(get(desc_pos,i,20))="" then continue
	# if item # exists; must be item line
	if trim(get(ipos,i,desc_pos-2-ipos))<>"" and  trim(get(ipos,i,desc_pos-2-ipos))<>"!" then  serial_on=0;continue
	# is it a serial # line
	if get(desc_pos,i,5)="Ser# " or  get(desc_pos,i,5)="Lot# " then  x$=set(desc_pos-3,i,2,"sL");  serial_on=1; continue
	if get(desc_pos,i,5)="     " and serial_on then  x$=set(desc_pos-3,i,2,"sL");  continue
	# must be memo line or 2nd desc line
	x$=set(desc_pos-3,i,2,"mL"); serial_on=0
next i
end_find_memos:

[Mrg find prepayment]
if xrow>=yrow-1 then goto end_find_prepayment
for i=xrow to yrow
	if pos("-----"=text$[i]) or pos("====="=text$[i]) then  text$[i]="";  exec("cbox 15,"+str(i)+",42,"+str(i));continue
	if get(15,i,1)<>"" then x$=set(13,i,2,"pL")
next i
end_find_prepayment:

[Mrg gl report prepage]
prepage {
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,20))

	# find line
	lineno=0
	for i=3 to MAXROWS
		if mid(text$[i],1,3)="===" then lineno=i;exitto exit_loop
	next i
exit_loop:
}

[Mrg gl report hdr]
# header
cfont 1,2,MAXCOLS,{lineno-dhdlns},HBCFONT,12,black
cbox LEFTCOL,.5,RIGHTCOL,{LINENO-dhdlns-.6},1,HSHADE
cerase 1,1,MAXCOLS,1
text 2,1.25,{trim(get(1,1,15))},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS


[Mrg - END]

#***************************************************************
#                 Most frequently used rule sets               *
#***************************************************************

[S/O Invoice/RGA - Long form]
dsn_sample "/u0/unform_test/ssi/txt/so_inv_long.txt"
# Invoice Control   1-66, 2-N, 3-L, 4-1/2/B
# updated to version 5 enhancements
detect 0,2,"~(INVOICE)|(CREDIT MEMO)|(RETURN GOODS)"
detect 0,16,"SALESPERSON"

# set up document constants
const MAXCOLS=100                       # max cols to output
const MAXRCOLS=99                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=100                  # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "S/O Invoice"                 # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
}

prepage {
	# patch to handle RGA discrepancy
	x=pos("Ship-to:"=text$[10])
	if x>62 then for i=10 to 14;  text$[i](62)=text$[i](69,30);  next i
	reprint$=trim(get(92,2,7))
	doc_title$=trim(get(25,2,40))
	if doc_title$(1,6)="RETURN" then  doc_title$="RETURN GOODS ACKNOWLEDGEMENT"
	merge "Mrg get watermark text"
	if doc_title$(1,6)="RETURN" then  doc_title$="RETURN GOODS";  if reprint$="" then reprint$="ACKNOWLEDGEMENT" else  reprint$="ACKNOWLEDGEMENT "+reprint$

	xcol=27,xrow=3,xcols=46,tpos=2
	merge "Mrg get company info"

	xrow=20
	merge "Mrg get desc pos"

	xrow=22,yrow=60,xcols=MAXCOLS-2
	merge "Mrg find detail bottom"

	xrow=22,yrow=detail_bottom,ipos=2
	merge "Mrg find memos"

	xrow=detail_bottom+1,yrow=59
	merge "Mrg find prepayment"

	# sometimes invoice date is missing so copy in ship date
	if trim(get(91,7,8))="" then  x$=trim(get(18,18,8)); x1$=set(91,7,8,x$)
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# default line enhancement
const BROW=1
const EROW=60
cfont {desc_pos-2},BROW,2,EROW,DBFONT,IJUST,8       # item
cfont {desc_pos},BROW,43,EROW,DFONT,8           # desc
cfont 44,BROW,52,EROW,DBRFONT                   # ordered
cfont 54,BROW,62,EROW,DBRFONT                   # shipped
cfont 64,BROW,72,EROW,DBRFONT                   # backordered
cfont 74,BROW,75,EROW,DBCFONT                   # uom
cfont 77,BROW,85,EROW,DBRFONT                   # price
cfont 87,BROW,88,EROW,DBCFONT                   # uom
cfont 90,BROW,MAXRCOLS,EROW,DBRFONT             # extension

# header section
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "Mrg Form Header"
# handle copy title
cbox 80,3.75,RIGHTCOL,5.25,1,100
text 81,4.6,{copy_title$[copy]},HBCFONT,12,cols=19,shade 0

# right header
cbox 80,5.5,RIGHTCOL,10,1,ccols=90::ISHADE,crows=7 8.5
text 81,6.25,"Number",IFONT,cols=9
text 81,7.75,"Date",IFONT,cols=9
text 81,9.25,"Page",IFONT,cols=9
text 92,6.25,{trim(get(93,3,6))},DBFONT,cols=9
text 92,7.75,{trim(get(91,7,8))},DBFONT,cols=9
text 92,9.25,{trim(get(96,5,3))},DBFONT,cols=9

# bill to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,ccols=13::ISHADE 51 63::ISHADE
text 2,11,"Bill To:",ICFONT,cols=11
text 2,12,{trim(get(16,10,25))},DBCFONT,cols=11
text 14,11,{mcut(7,11,35,4,"","Y","Y")},DBFONT,cols=35

# ship to section
text 52,11,"Ship To:",ICFONT,cols=11
text 52,12,{trim(get(70,10,15))},DBCFONT,cols=11
text 64,11,{mcut(62,11,35,4,"","Y","Y")},DBFONT,cols=35

# ribbon section
cerase 17,15,17,19
cerase 26,15,26,19
cerase 41,15,41,19
cerase 57,15,57,19
cerase 66,15,66,19
cerase 73,15,73,19
cerase 76,15,76,19
cerase 84,15,84,19
cbox LEFTCOL,15,RIGHTCOL,19,MBOXSIZE,crows=17::ISHADE,  ccols=17 26 41 57 66 73 76 84
cfont 2,16,16,16,ICFONT,proper              # ref #
cfont 18,16,25,16,ICFONT,proper             # shipped dt
cfont 27,16,40,16,ICFONT,proper             # salesperson
cfont 42,16,56,16,ICFONT,proper             # terms
cfont 58,16,65,16,ICFONT,proper,fit         # tax code
cfont 67,16,72,16,ICFONT,proper             # doc #
cfont 74,16,75,16,ICFONT,proper             # whs
cfont 77,16,83,16,ICFONT,proper,fit         # frt
cfont 85,16,MAXRCOLS,16,ICFONT,proper,fit   # ship via

text 2,18,{cut(2,18,15,"")},DBCFONT,cols=15     # ref #
text 18,18,{cut(18,18,8,"")},DBCFONT,cols=8     # shipped dt
text 27,18,{cut(27,18,14,"")},DBCFONT,cols=14       # salesperson
text 42,18,{cut(42,18,15,"")},DBCFONT,cols=15       # terms
text 58,18,{cut(58,18,8,"")},DBCFONT,cols=8     # tax code
text 67,18,{cut(67,18,6,"")},DBCFONT,cols=6     # doc #
text 74,18,{cut(74,18,2,"")},DBCFONT,cols=2     # whs
text 77,18,{cut(77,18,7,"")},DBCFONT,cols=7     # frt
text 85,18,{cut(85,18,15,"")},DBCFONT,cols=15       # ship via

# detail
erase "!@desc_pos-1,20,desc_pos-1,60",0,0,1,1
erase "!@43,20,43,60",0,0,1,1
erase "!@53,20,53,60",0,0,1,1
erase "!@63,20,63,60",0,0,1,1
erase "!@73,20,73,60",0,0,1,1
erase "!@76,20,76,60",0,0,1,1
erase "!@86,20,86,60",0,0,1,1
erase "!@89,20,89,60"0,0,1,1
cbox LEFTCOL,19,RIGHTCOL,{detail_bottom},MBOXSIZE,  crows=21::DSHADE,ccols=43 53 63 73 76 86 89
cbox {desc_pos-1},19,{desc_pos-1},{detail_bottom}
cbox 43,19,43,{detail_bottom}
# detail headings
cfont {desc_pos-2},20,2,20,IFONT,proper,IJUST       # item code
cfont {desc_pos},20,43,20,IFONT,proper          # desc
cfont 44,20,52,20,IRFONT,proper             # ordered
cfont 54,20,62,20,IRFONT,proper             # shipped
cfont 64,20,72,20,IRFONT,proper             # backordered
cfont 74,20,75,20,ICFONT                    # uom
cfont 77,20,85,20,IRFONT,proper             # price
cfont 87,20,88,20,ICFONT                    # uom
cfont 90,20,MAXRCOLS,20,IRFONT,proper           # extension

# handle memo lines
font "mL@2,22,25,59",3,0,40,1,DFONT             # memo lines
erase "mL@2,22,40,59",0,0,2,1                   # spec chars
# enhance serial # lines
font "sL@2,22,25,59",3,0,4,1,DFONT              # serial lines
font "sL@2,22,25,59",8,0,40,1,DFONT             # serial lines
erase "sL@2,22,40,59",0,0,2,1                   # spec chars
# handle payment info
font "pL@2,22,40,59",2,0,15,1,DFONT             # pymt desc
font "pL@2,22,40,59",17,0,13,1,DBRFONT          # pymt amts
font "pL@2,22,40,59",30,0,35,1,DFONT            # pymt comment
erase "pL@2,22,40,59",0,0,2,1                   # spec chars

# handle ship from warehouse lines
font "*Whse:@2,22,7",0,0,6,1,IFONT
font "*Whse:@2,22,7",8,0,30,1,DFONT
font "*Ship Via:@43,22,52",0,0,10,1,IRFONT
font "*Ship Via:@43,22,52",12,0,15,1,DBFONT
font "*Freight:@70,22,78",0,0,9,1,IRFONT
font "*Freight:@70,22,78",11,0,8,1,DBRFONT

# watermark - large font with light shading
WATERMARK 1,{58-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cerase 32,62,100,62
cerase 32,64,100,64
cerase 32,61,32,63
cerase 44,61,44,63
cerase 56,61,56,63
cerase 68,61,68,63
cerase 78,61,78,63
cerase 87,61,87,63
cbox LEFTCOL,60,RIGHTCOL,MAXROWS,MBOXSIZE
cbox 31,60,RIGHTCOL,64,1,crows=62::HSHADE,ccols=44 56 68 78 87
cfont 32,61,43,61,IBRFONT,proper                # merchandise
cfont 45,61,55,61,IBRFONT,proper                # misc
cfont 57,61,67,61,IBRFONT,proper                # discount
cfont 69,61,77,61,IBRFONT,proper                # tax
cfont 79,61,86,61,IBRFONT,proper                # frt
cfont 88,61,MAXRCOLS,61,IBRFONT,9,proper            # tot due

cfont 32,63,43,63,DBRFONT                   # merchandise
cfont 45,63,55,63,DBRFONT                   # misc
cfont 57,63,67,63,DBRFONT                   # discount
cfont 69,63,77,63,DBRFONT                   # tax
cfont 79,63,86,63,DBRFONT                   # frt
cfont 88,63,MAXRCOLS,63,DBRFONT,10              # tot due

cfont 2,61,31,64,DFONT
cfont 2,65,MAXRCOLS,65,DFONT

[S/O Pick Ticket]
dsn_sample "/u0/unform_test/infor/txt/SOpickticket.txt"
#dsn_sample "/u0/unform_test/ssi/txt/so_pick.txt"
# Pick Control  1-66, 2-N, 3-1/2/B
# updated to version 5 enhancements
detect 0,2,"PICK TICKET"
detect 0,16,"SLSP"

# set up document constants
const MAXCOLS=85                        # max cols to output
const MAXRCOLS=84                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=85                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "S/O Pick Ticket"                 # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
}

prepage {
	reprint$=trim(get(77,2,7))
	doc_title$=trim(get(35,2,11))
	if doc_title$(1,6)="RETURN" then  doc_title$="RETURN GOODS"
	merge "Mrg get watermark text"

	xcol=19,xrow=3,xcols=46,tpos=2
	merge "Mrg get company info"

	xrow=20
	merge "Mrg get desc pos"

	xrow=22,yrow=62,ipos=2
	merge "Mrg find memos"
}

# erase vertical & horizontal lines
vline "!!",erase
hline "--",erase
hline "==",erase

# default line enhancements
const BROW=1
const EROW=62
cfont {desc_pos-2},BROW,2,EROW,DBFONT,IJUST     # item
cfont {desc_pos},BROW,42,EROW,DFONT             # desc
cfont 44,BROW,52,EROW,DBRFONT                   # ordered
cfont 54,BROW,59,EROW,DBRFONT                   # shipped
cfont 61,BROW,65,EROW,DBRFONT                   # backordered
cfont 67,BROW,68,EROW,DBCFONT                   # uom
cfont 70,BROW,77,EROW,DBRFONT                   # wt
cfont 79,BROW,MAXRCOLS,EROW,DBRFONT             # location

# header section
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "Mrg Form Header"
# handle copy title
cbox 68,3.75,RIGHTCOL,5.25,1,100
text 69,4.6,{copy_title$[copy]},HBCFONT,12,cols=16,shade 0

# right header
cbox 68,5.5,RIGHTCOL,10,1,ccols=77::ISHADE,crows=7 8.5
text 69,6.25,"Number",IFONT,cols=9
text 69,7.75,"Date",IFONT,cols=9
text 69,9.25,"Page",IFONT,cols=9
text 78,6.25,{trim(get(78,3,6))},DBFONT,cols=6
text 78,7.75,{trim(get(76,7,8))},DBFONT,cols=8
text 78,9.25,{trim(get(82,5,3))},DBFONT,cols=6

# ship to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,ccols=11::ISHADE 42 52::ISHADE
text 2,11,"Ship To:",ICFONT,cols=9
text 2,12,{trim(get(15,10,15))},DBCFONT,cols=9
text 12,11,{mcut(7,11,35,4,"","Y","Y")},DBFONT,cols=35

# bill to section
text 43,11,"Bill To:",ICFONT,cols=9
text 43,12,{trim(get(62,10,20))},DBCFONT,cols=9
cfont 53,11,MAXRCOLS,14,DBFONT              # bill to addr

# ribbon 1 section
cerase 17,15,17,19
cerase 26,15,26,19
cerase 36,15,36,19
cerase 41,15,41,19
cerase 57,15,57,19
cerase 61,15,61,19
cerase 69,15,69,19
cbox LEFTCOL,15,RIGHTCOL,19,MBOXSIZE,1,crows=17::ISHADE,  ccols=17 26 36 41 57 61 69
cfont 2,16,16,16,ICFONT,proper              # ref #
cfont 18,16,25,16,ICFONT,proper             # ordered
cfont 27,16,35,16,ICFONT,proper             # requested
cfont 37,16,40,16,ICFONT,proper             # salesperson
cfont 42,16,56,16,ICFONT,proper             # terms
cfont 58,16,60,16,ICFONT,proper             # whs
cfont 62,16,68,16,ICFONT,proper             # frt
cfont 70,16,MAXRCOLS,16,ICFONT,proper           # ship via

cfont 2,18,16,18,DBCFONT                    # ref #
cfont 18,18,25,18,DBCFONT                   # ordered
cfont 27,18,35,18,DBCFONT                   # requested
cfont 37,18,40,18,DBCFONT                   # salesperson
cfont 42,18,56,18,DBCFONT                   # terms
cfont 58,18,60,18,DBCFONT                   # whs
cfont 62,18,68,18,DBCFONT                   # frt
cfont 70,18,MAXRCOLS,18,DBCFONT             # ship via

# detail heading
erase "!@6,20,22,20",0,0,1,1
erase "!@43,19,43,62",0,0,1,1
erase "!@53,19,53,62",0,0,1,1
erase "!@60,19,60,62",0,0,1,1
erase "!@66,19,66,62",0,0,1,1
erase "!@69,19,69,62",0,0,1,1
erase "!@78,19,78,62",0,0,1,1
cbox LEFTCOL,19,RIGHTCOL,62,MBOXSIZE,crows=21::DSHADE,  ccols=43 53 60 66 69 78
cbox {desc_pos-1},19,{desc_pos-1},62

cfont 2,20,{desc_pos-2},20,IFONT,IJUST,proper       # item
cfont {desc_pos},20,43,20,IFONT,proper          # desc
cfont 44,20,52,20,IRFONT,proper             # committed
cfont 54,20,59,20,IRFONT,proper             # shipped
cfont 61,20,65,20,IRFONT,proper             # backordered
cfont 67,20,68,20,ICFONT                    # uom
cfont 70,20,77,20,IRFONT,proper             # wt
cfont 79,20,MAXRCOLS,20,IRFONT,proper           # location

# handle order initiated lines
font "Order @5,22,10,62",-3,0,35,1,DBFONT,left

# handle ordered by lines
font "Ordered By @2,22,25,62",0,0,40,1,DFONT

# handle memo lines
font "mL@2,22,25,62",3,0,30,1,DFONT             # memo lines
erase "mL@2,22,40,62",0,0,2,1                   # spec chars

# handle alternate location lines
font "Alt Loc: ",0,0,8,1,DFONT              # title
font "Alt Loc: ",9,0,50,1,DBFONT                # alt locs

# handle price lines
font "Price: ",0,0,6,1,DFONT                    # title
font "Price: ",7,0,9,1,DBRFONT              # price
font "Price: ",17,0,5,1,DBFONT              # uom

# handle disc lines
font "Disc: ",0,0,6,1,DFONT                 # title
font "Disc: ",7,0,9,1,DBRFONT                   # price
font "Disc: ",17,0,5,1,DBFONT                   # uom

# handle ext lines
font "Ext: ",0,0,4,1,DFONT                  # title
font "Ext: ",5,0,11,1,DBRFONT                   # ext price

# watermark - large font with light shading
WATERMARK 1,{59-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cbox LEFTCOL,62,RIGHTCOL,MAXROWS,MBOXSIZE
cbox "Total Weight",-2,-1,78,64,1,ccols=69::HSHADE
cfont 54,63,67,63,IBRFONT,10,proper             # wt
cfont 69,63,77,63,DBRFONT,10                    # wt
font "CONTINUED@75,63,83,63",0,0,10,1,IRFONT,proper

cfont 2,63,52,63,IFONT
font "EXTENSION TOT: ",0,0,14,1,IFONT,proper        # title
font "~\.[0-9][0-9]@1,63,50,63",-9,0,12,1,DBFONT,10 # ext total
font "~\.[0-9][0-9]@1,63,50,63",5,0,16,1,IFONT,proper
cfont 2,64,MAXRCOLS,64,IFONT

[S/O Invoice - Gross margin/Short Form/short RGA]
dsn_sample "/u0/unform_test/ssi/txt/so_inv_short.txt"
# Invoice Control   1-66, 2-N, 3-G/S, 4-1/2/B
# updated to version 5 enhancements
detect 0,2,"~(INVOICE)|(CREDIT MEMO)|(RETURN GOODS)"
detect 0,16,"~(SHIPPED)|(RETURNED)"
detect 0,16,"~(SLS)|(Sls)"

# set up document constants
const MAXCOLS=81                        # max cols to output
const MAXRCOLS=80                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=81                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const INTERNAL_COPY=3
const MAX_COPIES=3
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "S/O Invoice"                 # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
	if MAX_COPIES>=3 then  copy_title$[INTERNAL_COPY]="Internal Copy"
}

prepage {
	reprint$=trim(get(73,2,7))
	doc_title$=trim(get(20,2,40))
	if doc_title$(1,6)="RETURN" then  doc_title$="RETURN GOODS ACKNOWLEDGEMENT"
	merge "Mrg get watermark text"
	if doc_title$(1,6)="RETURN" then  doc_title$="RETURN GOODS";  if reprint$="" then reprint$="ACKNOWLEDGEMENT" else  reprint$="ACKNOWLEDGEMENT "+reprint$

	xcol=20,xrow=3,xcols=46,tpos=2
	merge "Mrg get company info"

	xrow=20
	merge "Mrg get desc pos"

	xrow=22,yrow=60,xcols=MAXCOLS-2
	merge "Mrg find detail bottom"

	xrow=22,yrow=detail_bottom,ipos=2
	merge "Mrg find memos"

	xrow=detail_bottom+1,yrow=59
	merge "Mrg find prepayment"
}

precopy {
	if copy=INTERNAL_COPY then cols$="100"
	if trim(get(86,3,3))<>"NO." and copy=INTERNAL_COPY then  skip=1
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# erase cost section if not copy 3
if copy CUSTOMER_COPY,FILE_COPY
	cerase 81,1,100,MAXROWS
end if

# default line enhancement
const BROW=22
const EROW=60
cfont 2,BROW,{desc_pos-2},EROW,DBFONT,IJUST,8       # item
cfont {desc_pos},BROW,42,EROW,DFONT,8           # desc
cfont 44,BROW,52,EROW,DBRFONT                   # shipped
cfont 54,BROW,55,EROW,DBCFONT                   # uom
cfont 57,BROW,65,EROW,DBRFONT                   # price
cfont 67,BROW,68,EROW,DBCFONT                   # uom
cfont 70,BROW,MAXRCOLS,EROW,DBRFONT             # extension
if copy INTERNAL_COPY
	cfont 82,BROW,92,EROW,DBRFONT               # cost
	cfont 94,BROW,99,EROW,DBRFONT               # gm
end if

# header section
cerase 1,1,100,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
if copy INTERNAL_COPY
	cbox 82,1,100,MAXROWS,MBOXSIZE
end if
merge "Mrg Form Header"
# handle copy title
cbox 64,3.75,RIGHTCOL,5.25,1,100
text 65,4.6,{copy_title$[copy]},HBCFONT,12,cols=16,shade 0

# right header
cbox 64,5.5,RIGHTCOL,10,1,crows=7 8.5, ccols=72::ISHADE
text 65,6.25,"Number",IFONT,cols=7
text 65,7.75,"Date",IFONT,cols=7
text 65,9.25,"Page",IFONT,cols=7
text 73,6.25,{trim(get(74,3,6))},DBFONT,cols=6
text 73,7.75,{trim(get(72,7,8))},DBFONT,cols=8
text 73,9.25,{trim(get(78,5,3))},DBFONT,cols=3
if copy INTERNAL_COPY
	cbox 82,1,100,8,crows=4 6,ccols=90::ISHADE
	text 83,3,"Number",IFONT,cols=7
	text 83,5,"Page",IFONT,cols=7
	text 83,7,"Date",IFONT,cols=7
	text 91,3,{trim(get(74,3,6))},DBFONT,cols=6
	text 91,5,{trim(get(72,7,8))},DBFONT,cols=8
	text 91,7,{trim(get(78,5,3))},DBFONT,cols=3
end if

# bill to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,1,ccols=10::ISHADE 41 50::ISHADE
text 2,11,"Bill To:",ICFONT,cols=8
text 2,12,{trim(get(16,10,25))},DBCFONT,cols=8
text 11,11,{mcut(8,11,30,4,"","Y","Y")},DBFONT,cols=30

# ship to section
text 42,11,"Ship To:",ICFONT,cols=8
text 42,12,{trim(get(58,10,15))},DBCFONT,cols=8
text 51,11,{mcut(50,11,30,4,"","Y","Y")},DBFONT,cols=30

# ribbon section
cerase 17,16,17,18
cerase 26,16,26,18
cerase 30,16,30,18
cerase 46,16,46,18
cerase 55,16,55,18
cerase 62,16,62,18
cerase 65,16,65,18
cbox LEFTCOL,15,RIGHTCOL,19,MBOXSIZE,1,crows=17::ISHADE,  ccols=17 26 30 46 55 62 65
cfont 2,16,16,16,ICFONT,proper              # ref #
cfont 18,16,25,16,ICFONT,proper             # shipped dt
cfont 27,16,29,16,ICFONT,proper             # slsp
cfont 31,16,45,16,ICFONT,proper             # terms
cfont 47,16,54,16,ICFONT,proper             # tax code
cfont 56,16,61,16,ICFONT,proper             # doc #
cfont 63,16,64,16,ICFONT,proper             # whs
cfont 66,16,MAXRCOLS,16,ICFONT,proper           # ship via

text 2,18,{cut(2,18,15,"")},DBCFONT,cols=15     # ref #
text 18,18,{cut(18,18,8,"")},DBCFONT,cols=8     # shipped dt
text 27,18,{cut(27,18,3,"")},DBCFONT,cols=3     # slsp
text 31,18,{cut(31,18,15,"")},DBCFONT,cols=15       # terms
text 47,18,{cut(47,18,8,"")},DBCFONT,cols=8     # tax code
text 56,18,{cut(56,18,6,"")},DBCFONT,cols=6     # doc #
text 63,18,{cut(63,18,2,"")},DBCFONT,cols=2     # whs
text 66,18,{cut(66,18,15,"")},DBCFONT,cols=15       # ship via

# detail
erase "!@desc_pos-1,20,desc_pos-1,60",0,0,1,1
erase "!@43,20,43,60",0,0,1,1
erase "!@53,20,53,60",0,0,1,1
erase "!@56,20,56,60",0,0,1,1
erase "!@66,20,66,60",0,0,1,1
erase "!@69,20,69,60",0,0,1,1
cbox LEFTCOL,19,RIGHTCOL,{detail_bottom},MBOXSIZE,  crows=21::DSHADE,ccols=43 53 56 66 69
cbox {desc_pos-1},19,{desc_pos-1},{detail_bottom}
cfont 2,20,{desc_pos-2},20,IFONT,proper,IJUST       # item code
cfont {desc_pos},20,42,20,IFONT,proper          # desc
cfont 44,20,52,20,IRFONT,proper             # shipped
cfont 54,20,55,20,ICFONT                    # uom
cfont 57,20,65,20,IRFONT,proper             # price
cfont 67,20,68,20,ICFONT                    # uom
cfont 70,20,MAXRCOLS,20,IRFONT,proper           # extension

if copy INTERNAL_COPY
	cerase 93,20,93,60
	cbox 82,19,100,60,MBOXSIZE,crows=21::DSHADE,ccols=93
	cfont 82,20,92,20,IRFONT,proper         # cost
	cfont 94,20,99,20,IRFONT,proper         # gm
end if

# handle memo lines
font "mL@2,22,25,59",3,0,40,1,DFONT,8           # memo lines
erase "mL@2,22,40,59",0,0,2,1                   # spec chars

# enhance serial # lines
font "sL@2,22,25,59",3,0,4,1,DFONT              # serial lines
font "sL@2,22,25,59",10,0,15,1,DFONT            # serial lines
erase "sL@2,22,40,59",0,0,2,1                   # spec chars

# handle payment info
font "pL@13,22,14,59",2,0,15,1,DFONT            # pymt desc
font "pL@13,22,14,59",17,0,13,1,DBRFONT         # pymt amts
font "pL@13,22,14,59",30,0,35,1,DFONT           # pymt comment
erase "pL@13,22,14,59",0,0,2,1              # spec chars

# watermark - large font with light shading
WATERMARK 1,{58-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cerase 25,62,100,62
cerase 25,64,100,64
cerase 25,61,25,63
cerase 37,61,37,63
cerase 49,61,49,63
cerase 59,61,59,63
cerase 68,61,68,63
cerase 93,61,93,63
cbox LEFTCOL,60,RIGHTCOL,MAXROWS,MBOXSIZE
cbox 25,60,RIGHTCOL,64,1,CROWS=62::HSHADE,ccols=37 49 59 68
cfont 25,61,36,61,IBRFONT,proper                # merchandise
cfont 38,61,48,61,IBRFONT,proper                # misc
cfont 50,61,58,61,IBRFONT,proper                # tax
cfont 60,61,67,61,IBRFONT,proper                # frt
cfont 69,61,MAXRCOLS,61,IBRFONT,10,proper           # tot due

cfont 26,63,36,63,DBRFONT                   # merchandise
cfont 38,63,48,63,DBRFONT                   # misc
cfont 50,63,58,63,DBRFONT                   # tax
cfont 60,63,67,63,DBRFONT                   # frt
cfont 69,63,MAXRCOLS,63,DBRFONT,10              # tot due
if copy INTERNAL_COPY
	cerase 83,61,92,61
	cbox 82,60,100,64,1,crows=62::HSHADE,ccols=93
	text 83,61,"Total Cost",IBRFONT,9,cols=10       # tot cost
	cfont 94,61,99,61,IBRFONT,proper            # gm
	cfont 83,63,92,63,DBRFONT,9             # tot cost
	cfont 94,63,99,63,DBRFONT               # gm
end if
cfont 2,61,24,64,DFONT
cfont 2,65,MAXRCOLS,65,DFONT

[S/R Invoice]
dsn_sample "/u0/unform_test/ssi/txt/sr_inv.txt"
# S/R Document Control  13-66, 14-N, 15-S/L, 16-1/2/B, 18-D/S/T
# updated to version 5 enhancements
detect 0,2,"~(INVOICE)|(CREDIT MEMO)"
detect 0,16,"CONTRACT"
detect 0,16,"EXPIRES"

# set up document constants
const MAXCOLS=81                        # max cols to output
const MAXRCOLS=80                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=81                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "S/R Invoice"                 # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
}

prepage {
	reprint$=trim(get(71,2,7))
	doc_title$=trim(get(20,2,40))
	merge "Mrg get watermark text"

	xcol=20,xrow=3,xcols=46,tpos=2
	merge "Mrg get company info"

	xrow=20
	merge "Mrg get desc pos"

	xrow=22,yrow=60,xcols=MAXCOLS-2
	merge "Mrg find detail bottom"

	xrow=22,yrow=detail_bottom,ipos=2
	merge "Mrg find memos"

	xrow=detail_bottom+1,yrow=59
	merge "Mrg find prepayment"
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# default line enhancement
const BROW=22
const EROW=60
cfont 2,BROW,{desc_pos-2},EROW,DBFONT,IJUST,8       # serial #
cfont {desc_pos},BROW,42,EROW,DFONT,8           # desc
cfont 44,BROW,52,EROW,DBRFONT
cfont 54,BROW,55,EROW,DCFONT
cfont 57,BROW,65,EROW,DBRFONT
cfont 67,BROW,68,EROW,DCFONT
cfont 70,BROW,MAXRCOLS,EROW,DBRFONT             # price

# header section
cerase 1,1,100,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "Mrg Form Header"
# handle copy title
cbox 64,3.75,RIGHTCOL,5.25,1,100
text 65,4.6,{copy_title$[copy]},HBCFONT,12,cols=16,shade 0

# right header
cbox 64,5.5,RIGHTCOL,10,1,crows=7 8.5, ccols=72::ISHADE
text 65,6.25,"Number",IFONT,cols=7
text 65,7.75,"Date",IFONT,cols=7
text 65,9.25,"Page",IFONT,cols=7
text 73,6.25,{trim(get(74,3,6))},DBFONT,cols=6
text 73,7.75,{trim(get(72,7,8))},DBFONT,cols=8
text 73,9.25,{trim(get(78,5,3))},DBFONT,cols=3

# bill to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,1,ccols=10::ISHADE 46 55::ISHADE
text 2,11,"Bill To:",ICFONT,cols=8
text 2,12,{trim(get(17,10,25))},DBCFONT,cols=8,fit
text 11,11,{mcut(8,11,30,4,"","Y","Y")},DBFONT,cols=30

# ship to section
text 47,11,"Ship To:",ICFONT,cols=8
text 47,12,{trim(get(58,10,20))},DBCFONT,cols=8,fit
text 56,11,{mcut(50,11,30,4,"","Y","Y")},DBFONT,cols=30

# ribbon section
cerase 17,16,17,18
cerase 26,16,26,18
cerase 30,16,30,18
cerase 46,16,46,18
cerase 55,16,55,18
cerase 62,16,62,18
cerase 65,16,65,18
cbox LEFTCOL,15,RIGHTCOL,19,MBOXSIZE,1,crows=17::ISHADE,ccols=17 26 30 46 55 62 65
cfont 2,16,16,16,ICFONT,proper              # ref #
cfont 18,16,25,16,ICFONT,proper             # inv dt
cfont 27,16,29,16,ICFONT,proper             # slsp
cfont 31,16,45,16,ICFONT,proper             # terms
cfont 47,16,54,16,ICFONT,proper             # tax code
cfont 56,16,61,16,ICFONT,proper             # contract
cfont 63,16,64,16,ICFONT,proper             # contract
cfont 66,16,MAXRCOLS,16,ICFONT,proper           # expires

text 2,18,{cut(2,18,15,"")},DBCFONT,cols=15     # ref #
text 18,18,{cut(18,18,8,"")},DBCFONT,cols=8     # inv dt
text 27,18,{cut(27,18,3,"")},DBCFONT,cols=3     # slsp
text 31,18,{cut(31,18,15,"")},DBCFONT,cols=15       # terms
text 47,18,{cut(47,18,7,"")},DBCFONT,cols=7     # tax code
text 56,18,{cut(56,18,6,"")},DBCFONT,cols=6       # contract
text 63,18,{cut(63,18,2,"")},DBCFONT,cols=2
text 66,18,{cut(66,18,15,"")},DBCFONT,cols=15       # expires

# detail
erase "!@desc_pos-1,20,desc_pos-1,60",0,0,1,1
erase "!@43,20,43,60",0,0,1,1
erase "!@53,20,53,60",0,0,1,1
erase "!@56,20,56,60",0,0,1,1
erase "!@66,20,66,60",0,0,1,1
erase "!@69,20,69,60",0,0,1,1
cbox LEFTCOL,19,RIGHTCOL,{detail_bottom},MBOXSIZE,crows=21::DSHADE,ccols=43 53 56 66 69
cbox {desc_pos-1},19,{desc_pos-1},{detail_bottom}
cfont 2,20,{desc_pos-2},20,IFONT,proper,IJUST       # serial #
cfont {desc_pos},20,42,20,IFONT,proper          # desc
cfont 44,20,52,20,IRFONT,proper
cfont 54,20,55,20,ICFONT
cfont 57,20,65,20,IRFONT,proper
cfont 67,20,68,20,ICFONT
cfont 70,20,MAXRCOLS,20,IRFONT,proper           # price

# handle memo lines
font "mL@2,22,25,59",3,0,40,1,DFONT,8           # memo lines
erase "mL@2,22,40,59",0,0,2,1                   # spec chars

# enhance serial # lines
font "sL@2,22,25,59",3,0,4,1,DFONT              # serial lines
font "sL@2,22,25,59",10,0,15,1,DFONT            # serial lines
erase "sL@2,22,40,59",0,0,2,1                   # spec chars

# handle payment info
font "pL@13,22,14,59",2,0,15,1,DFONT            # pymt desc
font "pL@13,22,14,59",17,0,13,1,DBRFONT         # pymt amts
font "pL@13,22,14,59",30,0,35,1,DFONT           # pymt comment
erase "pL@13,22,14,59",0,0,2,1              # spec chars

# watermark - large font with light shading
WATERMARK 1,{58-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cerase 25,62,MAXCOLS,62
cerase 25,64,MAXCOLS,64
cerase 25,61,25,63
cerase 37,61,37,63
cerase 49,61,49,63
cerase 59,61,59,63
cerase 68,61,68,63
cbox LEFTCOL,60,RIGHTCOL,MAXROWS,MBOXSIZE
cbox 25,60,RIGHTCOL,64,1,CROWS=62::HSHADE,ccols=37 49 59 68
cfont 26,61,36,61,IBRFONT,proper                # amt
cfont 38,61,48,61,IBRFONT,proper                # tax
cfont 50,61,58,61,IBRFONT,proper                # amt
cfont 60,61,67,61,IBRFONT,proper                # tax
cfont 69,61,MAXRCOLS,61,IBRFONT,10,proper           # tot due

cfont 26,63,36,63,DBRFONT                   # amt
cfont 38,63,48,63,DBRFONT                   # tax
cfont 50,63,58,63,DBRFONT                   # amt
cfont 60,63,67,63,DBRFONT                   # tax
cfont 69,63,MAXRCOLS,63,DBRFONT,10              # tot due

cfont 2,61,24,64,DFONT
cfont 2,65,MAXRCOLS,65,DFONT

[P/O Purchase Order]
#dsn_sample "/u0/unform_test/Infor/txt/POprint1page.txt"
dsn_sample "/u0/unform_test/Infor/txt/POprint2pagenotes30.txt"
#dsn_sample "/u0/unform_test/Infor/txt/POprint2pagenoteswide.txt"
#dsn_sample "C:/SDSI/uf60/test/infor/POprint1page.txt"
#dsn_sample "C:/SDSI/uf60/test/infor/POprint2pagenotes30.txt"
#dsn_sample "C:/SDSI/uf60/test/infor/POprint2pagenoteswide.txt"
#dsn_sample "/u0/unform_test/Infor/txt/old_txt/po_vendor.txt"
detect 0,2,"^PURCHASE ORDER"
detect 0,7,"~DATEMASK"

# set up document constants
const MAXCOLS=100
const MAXRCOLS=99
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=100                  # right vertical line
const MAXROWS=66                    # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const VENDOR_COPY=1
const FILE_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "P/O Purchase Order"              # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[VENDOR_COPY]="Vendor Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
}

prepage {
	reprint$=trim(get(91,2,7))
	doc_title$=trim(get(35,2,40))
	merge "Mrg get watermark text"

	xcol=35,xrow=3,xcols=40,tpos=2
	merge "Mrg get company info"

	xrow=20
	merge "Mrg get desc pos"

	icol1=2,icol2=desc_pos-2
	vcol1=2,vcol2=desc_pos-2
	# check for vendor item & item
	x=pos("!"=text$[20],1,0)
	# x=9 means both
	if x=9 then x=pos("!"=text$[20],1,2),icol1=x+1,vcol2=x-1

	xrow=22,yrow=60,ipos=2
	merge "Mrg find memos"

	cust_code$=""
	shipto_code$=trim(get(69,10,20))
	x=pos(" "=shipto_code$)
	if x then cust_code$=shipto_code$(x+1),  shipto_code$=shipto_code$(1,x-1)
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# default line enhancement
const BROW=22
const EROW=59
cfont {vcol1},BROW,{vcol2},EROW,DBFONT,IJUST,8      # vndr-item
cfont {icol1},BROW,{icol2},EROW,DBFONT,IJUST,8      # item
cfont {desc_pos},BROW,63,EROW,DFONT,8           # desc
cfont 64,BROW,72,EROW,DBRFONT                   # units
cfont 74,BROW,75,EROW,DBCFONT                   # uom
cfont 77,BROW,85,EROW,DBRFONT                   # cost
cfont 87,BROW,88,EROW,DBCFONT                   # uom
cfont 90,BROW,MAXRCOLS,EROW,DBRFONT             # extension

# header section
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "Mrg Form Header"

# handle Reprint
cfont 91,2,99,2,DBRFONT,11

# handle copy title
cbox 80,3.75,RIGHTCOL,5,1,100
text 80.5,4.5,{copy_title$[copy]},HBCFONT,12,cols=19,shade 0

# right header
cbox 80,5.25,RIGHTCOL,8.75,1,crows=6.25 7.5,ccols=90::ISHADE
text 81,5.75,"Number",IFONT,cols=9
text 81,7,"Date",IFONT,cols=9
text 81,8.25,"Page",IFONT,cols=9
text 91,5.75,{trim(get(92,3,6))},DBFONT,cols=6
text 91,7,{trim(get(91,7,8))},DBFONT,cols=8
text 91,8.25,{trim(get(97,5,3))},DBFONT,cols=3
text 81,9.25,{trim(cut(81,8,19,""))},DBRFONT,cols=19    # confirm
text 81,10.25,{trim(cut(81,9,19,""))},DBRFONT,cols=19    # acknowledgement

# vendor section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,1,ccols=12::ISHADE 51 62::ISHADE
text 2,11,"Vendor:",ICFONT,cols=10
text 2,12,{trim(get(19,10,25))},DBCFONT,cols=9,fit
text 13,11,{mcut(12,11,30,4,"","Y","Y")},DBFONT,cols=30

# ship to section
text 52,11,"Ship To:",ICFONT,cols=10
text 52,12,{shipto_code$},DBCFONT,cols=10,fit
text 52,13,{cust_code$},DBCFONT,cols=10,fit
text 63,11,{mcut(61,11,30,4,"","Y","Y")},DBFONT,cols=30

# ribbon section
cerase 7,16,7,18
cerase 23,16,23,18
cerase 39,16,39,18
cerase 55,16,55,18
cerase 63,16,63,18
cerase 79,16,79,18
cerase 88,16,88,18
cbox LEFTCOL,15,RIGHTCOL,19,MBOXSIZE,1,crows=17::ISHADE,ccols=7 23 39 55 63 79 88
cfont 2,16,6,16,ICFONT,proper                   # buyer
cfont 8,16,22,16,ICFONT,proper              # terms
cfont 24,16,38,16,ICFONT,proper             # ship via
cfont 40,16,54,16,ICFONT                    # fob
cfont 56,16,62,16,ICFONT,proper             # frt
cfont 64,16,78,16,ICFONT,proper             # ref #
cfont 80,16,87,16,ICFONT,proper             # expected dt
cfont 89,16,MAXRCOLS,16,ICFONT,proper           # customer

text 2,18,{cut(2,18,5,"")},DBCFONT,cols=5           # buyer
text 8,18,{cut(8,18,15,"")},DBCFONT,cols=15     # terms
text 24,18,{cut(24,18,15,"")},DBCFONT,cols=15       # ship via
text 40,18,{cut(40,18,15,"")},DBCFONT,cols=15       # fob
text 56,18,{cut(56,18,7,"")},DBCFONT,cols=7     # frt
text 64,18,{cut(64,18,15,"")},DBCFONT,cols=15       # ref #
text 80,18,{cut(80,18,8,"")},DBCFONT,cols=8     # expected dt
text 89,18,{cut(89,18,11,"")},DBCFONT,cols=11       # customer

# detail
erase "!@vcol2+1,20,vcol2+1,60",0,0,1,1
erase "!@desc_pos-1,20,desc_pos-1,60",0,0,1,1
erase "!@63,20,63,60",0,0,1,1
erase "!@73,20,73,60",0,0,1,1
erase "!@76,20,76,60",0,0,1,1
erase "!@86,20,86,60",0,0,1,1
erase "!@89,20,69,80",0,0,1,1
cbox LEFTCOL,19,RIGHTCOL,60,MBOXSIZE,  crows=21::DSHADE,ccols=63 73 76 86 89
cbox {vcol2+1},19,{desc_pos-1},60

# detail headers
cfont {vcol1},20,{vcol2},20,IFONT,IJUST,proper      # vndr-item
cfont {icol1},20,{icol2},20,IFONT,IJUST,proper      # item
cfont {desc_pos},20,63,20,IFONT,proper          # desc
cfont 64,20,72,20,IRFONT,proper             # units
cfont 74,20,75,20,ICFONT                    # uom
cfont 77,20,85,20,IRFONT,proper             # cost
cfont 87,20,88,20,ICFONT                    # uom
cfont 90,20,MAXRCOLS,20,IRFONT,proper           # extension

# handle line remarks
font "mL@1,22,63,59",3,0,40,1,DFONT,8           # memo lines
erase "mL@1,22,63,59",0,0,2,1                   # spec chars

# watermark - large font with light shading
WATERMARK 1,{59-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cerase 56,62,MAXCOLS,62
cerase 56,64,MAXCOLS,64
cerase 56,60,56,64
cerase 68,60,68,64
cerase 78,60,78,64
cerase 87,60,87,64
cbox LEFTCOL,60,RIGHTCOL,MAXROWS,MBOXSIZE
cbox 56,60,RIGHTCOL,64,1,CROWS=62::HSHADE,ccols=68 78 87
cfont 57,61,67,61,IBRFONT,proper                # amt
cfont 69,61,77,61,IBRFONT,proper                # tax
cfont 79,61,86,61,IBRFONT,proper                # frt
cfont 88,61,MAXRCOLS,61,IBRFONT,9,proper            # tot

cfont 57,63,67,63,DBRFONT                   # amt
cfont 69,63,77,63,DBRFONT                   # tax
cfont 79,63,86,63,DBRFONT                   # frt
cfont 88,63,MAXRCOLS,63,DBRFONT,9               # tot

cfont 1,61,55,65,IFONT                      # comments
cfont 57,65,MAXRCOLS,65,IFONT                   # resale license

[S/O Quote]
dsn_sample "/u0/unform_test/ssi/txt/so_quote.txt"
# Quote Control 1-66, 2-N, 3-1/2/B
# updated to version 5 enhancements
detect 0,2,"QUOTE"
detect 0,16,"EXPIRES"

# set up document constants
const MAXCOLS=80
const MAXRCOLS=79
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "S/O Quote"                       # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
}

prepage {
	reprint$=trim(get(72,2,7))
	doc_title$=trim(get(35,2,5))
	merge "Mrg get watermark text"

	xcol=20,xrow=3,xcols=46,tpos=2
	merge "Mrg get company info"

	xrow=22
	merge "Mrg get desc pos"

	xrow=22,yrow=60,ipos=2
	merge "Mrg find memos"
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# default line enhancement
const BROW=24
const EROW=60
cfont 2,BROW,{desc_pos-2},EROW,DBFONT,IJUST # item
cfont {desc_pos},BROW,42,EROW,DFONT             # desc
cfont 44,BROW,52,EROW,DBRFONT                   # ordered
cfont 54,BROW,55,EROW,DBCFONT                   # uom
cfont 57,BROW,65,EROW,DBRFONT                   # price
cfont 67,BROW,68,EROW,DBCFONT                   # uom
cfont 70,BROW,MAXRCOLS,EROW,DBRFONT             # extension

# header section
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "Mrg Form Header"
# handle copy title
cbox 60,3.75,RIGHTCOL,5.25,1,100
text 61,4.6,{copy_title$[copy]},HBCFONT,12,cols=19,shade 0

# right header
cbox 60,5.5,RIGHTCOL,10,1,ccols=70::ISHADE,crows=7 8.5
text 61,6.25,"Number",IFONT,cols=9
text 61,7.75,"Date",IFONT,cols=9
text 61,9.25,"Page",IFONT,cols=9
text 71,6.25,{trim(get(72,3,8))},DBFONT,cols=8
text 71,7.75,{trim(get(71,7,8))},DBFONT,cols=8
text 71,9.25,{trim(get(77,5,3))},DBFONT,cols=3

# ship to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,ccols=10::ISHADE 41 50::ISHADE
text 2,11,"Ship To:",ICFONT,cols=8
text 2,12,{trim(get(15,10,15))},DBCFONT,cols=8
text 11,11,{mcut(7,11,35,4,"","Y","Y")},DBFONT,cols=35

# bill to section
text 42,11,"Bill To:",ICFONT,cols=8
text 42,12,{trim(get(57,10,23))},DBCFONT,cols=8
text 51,11,{mcut(49,11,31,4,"","Y","Y")},DBFONT,cols=30

# ribbon 1 section
cerase 17,15,17,19
cerase 27,15,27,19
cerase 32,15,32,19
cerase 48,15,48,19
cerase 52,15,52,19
cerase 60,15,60,19
cbox LEFTCOL,15,RIGHTCOL,21,MBOXSIZE
cbox LEFTCOL,15,RIGHTCOL,19,1,crows=17::ISHADE,  ccols=17 27 32 48 52 60
cfont 2,16,16,16,ICFONT,proper              # ref #
cfont 18,16,26,16,ICFONT,proper             # expires
cfont 28,16,31,16,ICFONT,proper             # salesperson
cfont 33,16,47,16,ICFONT,proper             # terms
cfont 49,16,51,16,ICFONT,proper             # whs
cfont 53,16,59,16,ICFONT,proper             # frt
cfont 61,16,MAXRCOLS,16,ICFONT,proper           # ship via

cfont 2,18,16,18,DBCFONT                    # ref #
cfont 18,18,26,18,DBCFONT                   # expires
cfont 28,18,31,18,DBCFONT                   # salesperson
cfont 33,18,47,18,DBCFONT                   # terms
cfont 49,18,51,18,DBCFONT                   # whs
cfont 53,18,59,18,DBCFONT                   # frt
cfont 61,18,MAXRCOLS,18,DBCFONT             # ship via

# ribbon 2 section
cbox LEFTCOL,19,RIGHTCOL,21,1,ccols=12::ISHADE 17 27::ISHADE
cfont 2,20,11,20,IRFONT,proper
cfont 13,20,16,20,DBFONT                    # quoted by
cmove 18,20,27,20,17,20
cfont 17,20,26,20,IRFONT,proper             # quoted to
cfont 28,20,MAXRCOLS,20,DBFONT

# detail heading
cerase {desc_pos-1},21,{desc_pos-1},60
erase "!@43,22,43,60",0,0,1,1
cerase 53,21,53,60
cerase 56,21,56,60
cerase 66,21,66,60
cerase 69,21,69,60
cbox LEFTCOL,21,RIGHTCOL,60,MBOXSIZE,crows=23::DSHADE,  ccols=43 53 56 66 69
cbox {desc_pos-1},21,{desc_pos-1},60

cfont 2,22,{desc_pos-2},22,IFONT,IJUST,proper       # item
cfont {desc_pos},22,42,22,IFONT,proper          # desc
cfont 44,22,52,22,IRFONT,proper             # ordered
cfont 54,22,55,22,ICFONT                    # uom
cfont 57,22,65,22,IRFONT,proper             # price
cfont 67,22,68,22,ICFONT                    # uom
cfont 70,22,MAXRCOLS,22,IRFONT,proper           # extension

# handle memo lines
font "mL@2,24,25,62",3,0,40,1,DFONT             # memo lines
erase "mL@2,24,40,62",0,0,2,1                   # spec chars

# watermark - large font with light shading
WATERMARK 1,{58-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cerase 24,60,24,64
cerase 36,60,36,64
cerase 48,60,48,64
cerase 58,60,58,64
cerase 67,60,67,64
cbox LEFTCOL,60,RIGHTCOL,MAXROWS,MBOXSIZE
cbox 24,60,RIGHTCOL,64,1,crows=62::HSHADE,ccols=36 48 58 67

cfont 25,61,35,61,IBRFONT,proper                # merch
cfont 37,61,47,61,IBRFONT,proper                # misc
cfont 49,61,57,61,IBRFONT,proper                # tax
cfont 59,61,66,61,IBRFONT,proper                # frt
cfont 68,61,MAXRCOLS,61,IBRFONT,10,proper           # tot

cfont 25,63,35,63,DBRFONT                   # merchandise
cfont 37,63,47,63,DBRFONT                   # misc
cfont 49,63,57,63,DBRFONT                   # tax
cfont 59,63,66,63,DBRFONT                   # frt
cfont 68,63,MAXRCOLS,63,DBRFONT,10              # tot

cfont 2,65,60,65,DFONT

[A/R Statement]
dsn_sample "/u0/unform_test/ssi/txt/ar_stmt.txt"
# Statement Control 1-66, 2-N, 3-Y, 4-Y/N, 5-Y, 6-3
# handles both statement and statement with tearoff
# in both cases, a remittance copy is printed
# updated to version 5 enhancements
detect 0,2,"STATEMENT"
detect 0,16,"PYMT DTE"

# set up document constants
const MAXCOLS=80                        # max cols to output
const MAXRCOLS=79                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const REMITTANCE_COPY=2
const FILE_COPY=3
const RECAP_COPY=4
const MAX_COPIES=4
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "A/R Statement"                   # view in pdf properties

prejob {
	doc_title$="STATEMENT"
	merge "Mrg get watermark text"

	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[REMITTANCE_COPY]="Remittance Copy"
	if MAX_COPIES>=3 then  copy_title$[FILE_COPY]="Accounting Copy"
	if MAX_COPIES>=4 then  copy_title$[RECAP_COPY]="Recap Copy"
}

prepage {
	xcol=20,xrow=4,xcols=38,tpos=2
	merge "Mrg get company info"

	cust_code$=trim(get(5,10,25))
	msg_row=61
	# look for remark lines
	for i=18 to 61
		if mid(text$[i],1,3)="!==" or mid(text$[i],1,3)="!--" then  msg_row=i;exitto end_look
	next i
end_look:
}

precopy {
	if copy=RECAP_COPY and cust_code$<>"RECAP" then skip=1
	if copy<>RECAP_COPY and cust_code$="RECAP" then skip=1
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# erase tearoff section
cerase 76,1,98,MAXROWS

# default detail line
cfont 2,18,9,60,DBCFONT                         # dt
cfont 11,18,17,60,DCFONT                        # inv #
cfont 19,18,26,60,DCFONT                        # duedt
cfont 28,18,38,60,DBRFONT                       # amt
cfont 40,18,47,60,DCFONT                        # dt
cfont 49,18,59,60,DBRFONT                       # amt
cfont 61,18,62,60,DCFONT                        # type
cfont 64,18,74,60,DBRFONT                       # bal

# header section
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "Mrg Form Header"
# handle copy title
cbox 64,3.75,RIGHTCOL,5.25,1,100
text 65,4.6,{copy_title$[copy]},HBCFONT,12,cols=15,shade 0

# right header
cbox 64,7,RIGHTCOL,10,crows=8.5,ccols=72::ISHADE
text 65,7.75,"Date",IFONT,cols=7
text 65,9.25,"Page",IFONT,cols=7
text 73,7.75,{trim(get(65,7,8))},DBFONT,cols=7
text 73,9.25,{trim(get(71,5,3))},DBFONT,cols=7

# to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,ccols=11::ISHADE
text 2,11,"To:",IFONT,cols=9
text 2,12,{cust_code$},DBFONT,cols=9
cfont 12,11,51,14,DBFONT                    # to addr

# detail
erase "!@1,16,MAXCOLS,16",0,0,1,1
if copy CUSTOMER_COPY,REMITTANCE_COPY,FILE_COPY
	cbox LEFTCOL,15,MAXCOLS,{msg_row},MBOXSIZE,crows=17::DSHADE,  ccols=10 18 27 39 48 60 63 75

	cfont 2,16,9,16,ICFONT                      # dt
	cfont 11,16,17,16,ICFONT                    # inv #
	cfont 19,16,26,16,ICFONT                    # due dt
	cfont 28,16,38,16,IRFONT                    # amt
	cfont 40,16,47,16,ICFONT                    # pymt dt
	cfont 49,16,59,16,IRFONT                    # pymt amt
	cfont 61,16,62,16,ICFONT                    # type
	cfont 64,16,74,16,IBRFONT                   # bal
	text 76,15.5,"Mark for",ICFONT,cols=4
	text 76,16.5,"Payment",ICFONT,cols=4

	# handle ship-to header
	font "Ship-to@3,18,9,60",-1,0,8,1,DBCFONT
	font "Ship-to@3,18,9,60",9,0,40,1,DBFONT

	# handle ship-to totals
	erase "SHIP-TO TOTAL@50,18,62,60",13,-1,13,1
	box "SHIP-TO TOTAL@50,18,62,60",-2,-.75,27,1.5,1,DSHADE
	font "SHIP-TO TOTAL@50,18,62,60",-1,0,14,1,DBFONT
	font "SHIP-TO TOTAL@50,18,62,60",13,0,12,1,DBRFONT,10

end if
if copy RECAP_COPY
	cerase 1,15,MAXCOLS,60
	cbox LEFTCOL,15,RIGHTCOL,61
	text 1,60,"TOTAL DUE RECAP",HBCFONT,14,cols=MAXCOLS
end if

# watermark - large font with light shading
WATERMARK 1,{54-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# message area
if copy CUSTOMER_COPY,REMITTANCE_COPY,FILE_COPY
	cbox LEFTCOL,{msg_row},RIGHTCOL,61
	cfont 2,{msg_row},62,61,IFONT,black
end if

# footer
erase "!@1,62,MAXCOLS,62",0,0,1,1
erase "!@1,64,MAXCOLS,64",0,0,1,1
cbox "!=CONTINUED@66,64,74,64",-62,-3,75,65,  crows=63::HSHADE,ccols=14 26 38 50 62
cfont 3,62,13,62,IBRFONT
cfont 15,62,25,62,IBRFONT
cfont 27,62,37,62,IBRFONT
cfont 39,62,49,62,IBRFONT
cfont 51,62,61,62,IBRFONT
cfont 63,62,74,62,IBRFONT,12
cfont 3,64,13,64,DBRFONT
cfont 15,64,25,64,DBRFONT
cfont 27,64,37,64,DBRFONT
cfont 39,64,49,64,DBRFONT
cfont 51,64,61,64,DBRFONT
cfont 63,64,74,64,DBRFONT,12
erase "CONTINUED@66,64",0,-2,9,1
font "CONTINUED@66,64",0,0,9,1,IBFONT,12

[I/C transfer ticket]
dsn_sample "/u0/unform_test/ssi/txt/ic_transfer.txt"
# Static Control    4-66, 5-N, 6-1/2/B
# updated to version 5 enhancements
detect 0,2,"TRANSFER TICKET PRINT"

# set up document constants
const MAXCOLS=85
const MAXRCOLS=84
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=85                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const WAREHOUSE_COPY=1
const FILE_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "I/C Transfer Ticket"             # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[WAREHOUSE_COPY]="Warehouse Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
}

prepage {
	reprint$=trim(get(77,2,7))
	doc_title$=trim(get(33,2,15))
	merge "Mrg get watermark text"

	xcol=20,xrow=3,xcols=46,tpos=2
	merge "Mrg get company info"

	xrow=20
	merge "Mrg get desc pos"

	xrow=22,yrow=62,ipos=2
	merge "Mrg find memos"
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# default line enhancement
const BROW=22
const EROW=61
cfont 2,BROW,{desc_pos-2},EROW,DBFONT,IJUST         # item
cfont {desc_pos},BROW,42,EROW,DFONT             # desc
cfont 44,BROW,52,EROW,DBRFONT                   # ordered
cfont 54,BROW,59,EROW,DBRFONT                   # ship
cfont 61,BROW,65,EROW,DBRFONT                   # back
cfont 67,BROW,68,EROW,DBCFONT                   # uom
cfont 70,BROW,77,EROW,DBRFONT                   # wt
cfont 79,BROW,MAXRCOLS,EROW,DBRFONT             # loc

# header section
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "Mrg Form Header"
# handle copy title
cbox 64,3.75,RIGHTCOL,5.25,1,100
text 65,4.6,{copy_title$[copy]},HBCFONT,12,cols=20,shade 0

# right header
cbox 64,5.5,RIGHTCOL,10,1,ccols=72::ISHADE,crows=7 8.5
text 65,6.25,"Number",IFONT,cols=7
text 65,7.75,"Date",IFONT,cols=7
text 65,9.25,"Page",IFONT,cols=7
text 73,6.25,{trim(get(78,3,6))},DBFONT,cols=6
text 73,7.75,{trim(get(76,7,8))},DBFONT,cols=8
text 73,9.25,{trim(get(82,5,3))},DBFONT,cols=3

# to whse section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,ccols=6::ISHADE 48 53::ISHADE
text 2,11,"To",ICFONT,cols=4
text 2,12,"Whse:",ICFONT,cols=4
text 2,13,{trim(get(16,10,15))},DBCFONT,cols=4
text 7,11,{mcut(7,11,35,4,"","Y","Y")},DBFONT,cols=35

# ship to section
text 49,11,"From",ICFONT,cols=4
text 49,12,"Whse:",ICFONT,cols=4
text 49,13,{trim(get(65,10,15))},DBCFONT,cols=4
text 54,11,{mcut(54,11,31,4,"","Y","Y")},DBFONT,cols=31

# ribbon 1 section
cerase 17,16,17,18
cerase 26,16,26,18
cerase 36,16,36,18
cerase 69,16,69,18
cbox LEFTCOL,15,RIGHTCOL,19,MBOXSIZE,crows=17::ISHADE,  ccols=17 26 36 69
cfont 2,16,16,16,ICFONT,proper              # ref #
cfont 18,16,25,16,ICFONT,proper             # ordered dt
cfont 27,16,35,16,ICFONT,proper             # requested dt
cfont 70,16,MAXRCOLS,16,ICFONT,proper           # ship via

cfont 2,18,16,18,DBCFONT                    # ref #
cfont 18,18,25,18,DBCFONT                   # ordered dt
cfont 27,18,35,18,DBCFONT                   # requested dt
cfont 70,18,MAXRCOLS,18,DBCFONT             # ship via

# detail heading
cerase {desc_pos-1},20,{desc_pos-1},61
erase "!@43,20,43,61",0,0,1,1
erase "!@53,20,53,61",0,0,1,1
erase "!@60,20,60,61",0,0,1,1
erase "!@66,20,66,61",0,0,1,1
erase "!@69,20,69,61",0,0,1,1
erase "!@78,20,78,61",0,0,1,1
cbox LEFTCOL,19,RIGHTCOL,62,MBOXSIZE,crows=21::DSHADE,  ccols=46 53 60 66 69 78
cbox {desc_pos-1},19,{desc_pos-1},62

cfont 2,20,{desc_pos-2},20,IFONT,IJUST,proper       # item
cfont {desc_pos},20,42,20,IFONT,proper          # desc
cfont 44,20,52,20,IRFONT,proper             # ordered
cfont 54,20,59,20,IRFONT,proper             # ship
cfont 61,20,65,20,IRFONT,proper             # back
cfont 67,20,68,20,ICFONT                    # uom
cfont 70,20,77,20,IRFONT,proper             # wt
cfont 79,20,MAXRCOLS,20,IRFONT,proper           # loc

# handle memo lines
font "mL@2,22,25,61",3,0,40,1,DFONT             # memo lns
erase "mL@2,22,40,61",0,0,2,1                   # spc chars

# handle alternate location lines
font "Alt Loc: ",0,0,8,1,DFONT              # title
font "Alt Loc: ",9,0,60,1,DBFONT                # alt locs

# watermark - large font with light shading
WATERMARK 1,{60-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cbox LEFTCOL,62,RIGHTCOL,MAXROWS,MBOXSIZE
box "Total Weight",-2,-1,25,2,1,icols=16::HSHADE
font "TOTAL WEIGHT",0,0,14,1,IBRFONT,10,PROPER      # title
font "Total Weight",15,0,8,1,DBRFONT,10         # tot wt
font "CONTINUED",0,0,9,1,IBRFONT,proper

cfont 2,63,53,64,DFONT
cfont 2,65,MAXRCOLS,65,DFONT

[S/O Counter]
dsn_sample "/u0/unform_test/ssi/txt/so_counter.txt"
# Counter Control   1-66, 2-N, 3-S/I, 4-0, 5-1/2/B
# updated to version 5 enhancements
detect 0,2,"INVOICE"
detect 0,16,"CHECK/CARD#"

# set up document constants
const MAXCOLS=80
const MAXRCOLS=79
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "S/O Counter Invoice"             # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
}

prepage {
	reprint$=trim(get(71,2,8))
	doc_title$=trim(get(37,2,8))
	merge "Mrg get watermark text"

	xcol=20,xrow=3,xcols=46,tpos=2
	merge "Mrg get company info"

	xrow=20
	merge "Mrg get desc pos"

	xrow=22,yrow=60,xcols=MAXCOLS-2
	merge "Mrg find detail bottom"

	xrow=22,yrow=detail_bottom,ipos=2
	merge "Mrg find memos"

	xrow=detail_bottom+1,yrow=59
	merge "Mrg find prepayment"
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# default line enhancement
const BROW=22
const EROW=60
cfont 2,BROW,{desc_pos-2},EROW,DBFONT,IJUST         # item
cfont {desc_pos},BROW,42,EROW,DFONT             # desc
cfont 44,BROW,52,EROW,DBRFONT                   # quantity
cfont 54,BROW,55,EROW,DBRFONT                   # uom
cfont 57,BROW,65,EROW,DBRFONT                   # price
cfont 67,BROW,68,EROW,DBCFONT                   # uom
cfont 70,BROW,MAXRCOLS,EROW,DBRFONT             # extension

# header section
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "Mrg Form Header"
# handle copy title
cbox 64,3.75,RIGHTCOL,5.25,1,100
text 65,4.6,{copy_title$[copy]},HBCFONT,12,cols=15,shade 0

# right header
cerase 60,10,MAXCOLS,15
cbox 64,5.5,RIGHTCOL,10,1,ccols=72::ISHADE,crows=7 8.5
text 65,6.25,"Number",IFONT,cols=7
text 65,7.75,"Date",IFONT,cols=7
text 65,9.25,"Page",IFONT,cols=7
text 73,6.25,{trim(get(71,10,8))},DBFONT,cols=8
text 73,7.75,{trim(get(71,14,8))},DBFONT,cols=8
text 73,9.25,{trim(get(71,12,8))},DBFONT,cols=8

# sold to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,ccols=10::ISHADE
text 2,11,"Sold To:",IFONT,cols=8
text 2,12,{trim(get(14,10,25))},DBFONT,cols=8
cmove 6,11,41,14,11,11
cfont 11,11,41,14,DBFONT                    # sold to addr

# ribbon 1 section
cerase 69,16,75,16
cerase 6,15,6,19
cerase 22,15,22,19
cerase 43,15,43,19
cerase 49,15,49,19
cerase 52,15,52,19
cerase 68,15,68,19
cbox LEFTCOL,15,RIGHTCOL,19,MBOXSIZE,crows=17::ISHADE,  ccols=6 22 43 49 52 68
cfont 1,16,5,16,ICFONT,proper                   # salesperson
cfont 7,16,21,16,ICFONT,proper              # terms
cfont 23,16,42,16,ICFONT,proper             # check/card #
cfont 44,16,48,16,ICFONT,proper             # tax %
cfont 50,16,51,16,ICFONT,proper             # whs
cfont 53,16,67,16,ICFONT,proper             # ref #
text 69,16,"Receipt #",ICFONT,cols=11           # receipt #

cfont 1,18,5,18,DBCFONT                     # salesperson
cfont 7,18,21,18,DBCFONT                    # terms
cfont 23,18,42,18,DBCFONT                   # check/card #
cfont 44,18,48,18,DBCFONT                   # tax %
cfont 50,18,51,18,DBCFONT                   # whs
cfont 53,18,67,18,DBCFONT                   # ref #
cfont 69,18,MAXRCOLS,18,DBCFONT             # receipt #

# detail heading
cerase {desc_pos-1},20,{desc_pos-1},60
erase "!@43,20,43,60",0,0,1,1
erase "!@53,20,53,60",0,0,1,1
erase "!@56,20,56,60",0,0,1,1
erase "!@66,20,66,60",0,0,1,1
erase "!@69,20,69,60",0,0,1,1
cbox LEFTCOL,19,RIGHTCOL,{detail_bottom},MBOXSIZE,crows=21::DSHADE,  ccols=43 53 56 66 69
cbox {desc_pos-1},19,{desc_pos-1},{detail_bottom}

cfont 2,20,{desc_pos-2},20,IFONT,IJUST,proper       # item
cfont {desc_pos},20,42,20,IFONT,proper          # desc
cfont 44,20,52,20,IRFONT,proper             # quantity
cfont 54,20,55,20,ICFONT                    # uom
cfont 57,20,65,20,IRFONT,proper             # price
cfont 67,20,68,20,ICFONT                    # uom
cfont 70,20,MAXRCOLS,20,IRFONT,proper           # extension

# enhance memo lines
font "mL@2,22,25,59",3,0,40,1,DFONT             # memo lines
erase "mL@2,22,40,59",0,0,2,1                   # spec chars

# enhance serial # lines
font "sL@2,22,25,59",3,0,4,1,DFONT              # serial lines
font "sL@2,22,25,59",8,0,40,1,DFONT             # serial lines
erase "sL@2,22,40,59",0,0,2,1                   # spec chars

# handle payment info
font "pL@13,22,14,59",2,0,14,1,DFONT            # pymt desc
font "pL@13,22,14,59",17,0,12,1,DBRFONT         # pymt amts
font "pL@13,22,14,59",30,0,35,1,DFONT           # pymt comment
erase "pL@13,22,14,59",0,0,2,1              # spec chars

# watermark - large font with light shading
WATERMARK 1,{58-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cerase 23,60,23,64
cerase 36,60,36,63
cerase 46,60,46,63
cerase 57,60,57,63
cerase 68,60,68,63
cbox LEFTCOL,60,RIGHTCOL,MAXROWS,MBOXSIZE
cbox 23,60,RIGHTCOL,64,1,crows=62::HSHADE,  ccols=36 46 57 68
cfont 24,61,35,61,IBRFONT,proper                # merchandise
cfont 37,61,45,61,IBRFONT,proper                # tax
cfont 47,61,56,61,IBRFONT,proper                # tendered
cfont 58,61,67,61,IBRFONT,proper                # cash back
cfont 69,61,MAXRCOLS,61,IBRFONT,10,proper           # tot due

cfont 24,63,35,63,DBRFONT                   # merchandise
cfont 37,63,45,63,DBRFONT                   # tax
cfont 47,63,56,63,DBRFONT                   # tendered
cfont 58,63,67,63,DBRFONT                   # cash back
cfont 69,63,MAXRCOLS,63,DBRFONT,10              # tot due

cfont 2,61,23,64,DFONT
cfont 2,65,MAXRCOLS,65,DFONT

[A/P Check]
dsn_sample "/u0/unform_test/ssi/txt/ap_checks.txt"
# Print Control 1-01, 2-21, 3-55, 4-45, 5-55, 6-11, 7-68, 8-13
# updated to version 5 enhancements
detect 41,5,"~DATEMASK.."
detect 60,5,"~([0-9][0-9][0-9][0-9][0-9][0-9])|(XXXXXX)"       # Check #

# set up document constants
const MAXCOLS=83                        # max cols to output
const MAXRCOLS=82                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=83                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page 42                         # max input rows

const ONE_STUB_COPY=1
const TWO_STUB_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "A/P Check"                       # view in pdf properties

prepage {
	# the following moves will leave a space between
	# the top two stubs
	# move check to bottom
	for i=23 to 42
		text$[i+24]=text$[i]
		text$[i]=""                 # clear line
	next i

	# copy stub from top to middle
	for i=1 to 22
		text$[i+24]=text$[i]
	next i

	chkno$=trim(get(60,5,6))
	chk_amt_words$=trim(get(1,56,67))+" "+trim(get(1,57,67))

	# get comp info from constants?
	addr3$="COMP_ADDR3"
	save_addr3$=addr3$
	phone$="Phone: COMP_PHONES"
	if trim(phone$)="Phone:" then phone$=""
	if addr3$="" then addr3$=phone$,phone$=""
}

precopy {
	if copy=ONE_STUB_COPY and copy<>AP_NO_STUBS then skip=1
	if copy=ONE_STUB_COPY then  for i=1 to 21;  text$[i]="";  next i
	if copy=TWO_STUB_COPY and copy<>AP_NO_STUBS then skip=1
}

########## Payor Stub (top)
if copy TWO_STUB_COPY
	# top section
	cbox 40,1.5,RIGHTCOL,5.5,1,crows=2.5::ISHADE 3.5 4.5::ISHADE,ccols=53
	cbox 70,3.5,70,5.5
	text 2,2,"COMP_NAME",HBFONT
	text 2,2.9,"COMP_ADDR1",HFONT
	text 2,3.8,"COMP_ADDR2",HFONT
	text 2,4.7,{addr3$},HFONT
	text 2,5.6,{phone$},HFONT

	text 41,2,"Vendor #",ICFONT,cols=12
	text 54,2,"Vendor Name",ICFONT,cols=29
	cfont 40,3,52,3,DBCFONT                 # vendor #
	cfont 54,3,MAXCOLS,3,DBCFONT               # vendor name

	text 41,4,"Check Date",ICFONT,cols=12
	text 54,4,"Check #",ICFONT,cols=16
	text 71,4,"Page #",ICFONT,cols=12
	cfont 41,5,52,5,DBCFONT                 # check dt
	cfont 54,5,69,5,DBCFONT                 # check #
	cfont 71,5,MAXRCOLS,5,DBCFONT               # page #

	# detail
	cbox LEFTCOL,6.5,RIGHTCOL,20.5,1,crows=7.5::DSHADE,  ccols=11 22 34 46 58
	text 1,7,"Inv Date",ICFONT,cols=10
	text 12,7,"Invoice #",IRFONT,cols=10
	text 23,7,"Amount",IRFONT,cols=11
	text 35,7,"Discount",IRFONT,cols=11
	text 47,7,"Amount Paid",IRFONT,cols=11
	text 59,7,"Memo",IFONT,cols=20
	cfont 1,8,10,20,DBCFONT                 # inv dt
	cfont 12,8,21,20,DBRFONT                # inv #
	cfont 23,8,33,20,DBRFONT                # inv amt
	cfont 35,8,45,20,DBRFONT                # discount
	cfont 47,8,57,20,DBRFONT                # paid amt
	cfont 59,8,MAXCOLS,20,IFONT             # memo

	# footer
	cbox 11,20.5,58,21.5,1,ccols=22::100 34 46
	text 12,21,"Totals",IBFONT,shade 0
	cfont 23,21,33,21,DBRFONT               # inv amt
	cfont 35,21,45,21,DBRFONT               # discount
	cfont 47,21,57,21,DBRFONT               # paid amt

	text 1,21.5,"Payor's Copy",IBRFONT,cols=MAXRCOLS
	cbox LEFTCOL,23.5,RIGHTCOL,23.5
endif

########### Vendor Stub
# top section
cbox 40,25.5,RIGHTCOL,29.5,1,crows=26.5::ISHADE 27.5 28.5::ISHADE,ccols=53
cbox 70,27.5,70,29.5
text 2,26,"COMP_NAME",HBFONT
text 2,26.9,"COMP_ADDR1",HFONT
text 2,27.8,"COMP_ADDR2",HFONT
text 2,28.7,{ADDR3$},HFONT
text 2,29.6,{phone$},HFONT

text 41,26,"Vendor #",ICFONT,cols=12
text 54,26,"Vendor Name",ICFONT,cols=29
cfont 40,27,52,27,DBCFONT                   # vendor #
cfont 54,27,MAXCOLS,27,DBCFONT              # vendor name

text 41,28,"Check Date",ICFONT,cols=12
text 54,28,"Check #",ICFONT,cols=16
text 71,28,"Page #",ICFONT,cols=12
cfont 41,29,52,29,DBCFONT                   # check dt
cfont 54,29,69,29,DBCFONT                   # check #
cfont 71,29,MAXRCOLS,29,DBCFONT             # page #

# detail
cbox LEFTCOL,30.5,RIGHTCOL,44.5,1,crows=31.5::DSHADE,  ccols=11 22 34 46 58
text 1,31,"Inv Date",ICFONT,cols=10
text 12,31,"Invoice #",IRFONT,cols=10
text 23,31,"Amount",IRFONT,cols=11
text 35,31,"Discount",IRFONT,cols=11
text 47,31,"Amount Paid",IRFONT,cols=11
text 59,31,"Memo",IFONT,cols=20
cfont 1,32,10,44,DBCFONT                    # inv dt
cfont 12,32,21,44,DBRFONT                   # inv #
cfont 23,32,33,44,DBRFONT                   # inv amt
cfont 35,32,45,44,DBRFONT                   # discount
cfont 47,32,57,44,DBRFONT                   # paid amt
cfont 59,32,MAXCOLS,44,IFONT                    # memo

# footer
cbox 11,44.5,58,45.5,1,ccols=22::100 34 46
text 12,45,"Totals",IBFONT,shade 0,cols=6
cfont 23,45,33,45,DBRFONT                   # inv amt
cfont 35,45,45,45,DBRFONT                   # discount
cfont 47,45,57,45,DBRFONT                   # paid amt

text 1,45.5,"Vendor's Copy",IBRFONT,cols=MAXRCOLS
cbox LEFTCOL,46.5,RIGHTCOL,46.5

########### Check

cbox LEFTCOL,47,RIGHTCOL,64.5,MBOXSIZE
LOGO_IMAGE 1,47,10,5,"COMP_LOGO"
text 15,48.25,"COMP_NAME",HBFONT,14
text 15,49.35,"COMP_ADDR1",HFONT,12
text 15,50.35,"COMP_ADDR2",HFONT,12
text 15,51.35,"COMP_ADDR3",HFONT,12
text 49,48.25,"AP_BANK_NAME",DBFONT
text 49,49.05,"AP_BANK_ADDR1",DFONT
text 49,49.85,"AP_BANK_ADDR2",DFONT
text 70,49.35,"AP_ROUTING",DBFONT               # rtg #

cmove 44,52,63,52,49,52
cbox 48,50.5,81,52.5,1,crows=51.5::100,ccols=57 69
text 49,51,"Check #",ICFONT,shade 0,cols=8
cfont 49,52,56,52,DBCFONT                   # chk #
text 58,51,"Date",ICFONT,shade 0,cols=11
cfont 58,52,68,52,DBCFONT                   # chk dt
cmove 69,56,79,56,70,52                     # chk amt
text 70,51,"Amount",IRFONT,shade 0,cols=11
cfont 70,52,80,52,DBRFONT                   # chk amt

cerase 1,56,MAXCOLS,57
text 2,56,"Pay",IFONT,14
text 6.5,56,{chk_amt_words$},IBFONT,10,fit,cols=70

cmove 14,60,43,64,9,60
text 2,60,"Pay",IFONT
text 2,61,"to the",IFONT
text 2,62,"Order",IFONT
text 2,63,"of",IFONT
cfont 9,60,MAXRCOLS,63,DBFONT

text 50,59.50,"Check Void After 180 Days",ICFONT,cols=30
SIGNATURE_IMAGE 50,61,0,0,"SIGNATURE"
box 50,62.0,30,1,3
text 50,62.75,"Authorized Signature",ICFONT,cols=30
#AP_MICR 15,65.50,"AP_MICR_ACCOUNTNO",{chkno$}

[A/P Vouchers]
dsn_sample "/u0/unform_test/ssi/txt/ap_voucher.txt"
# updated to version 5 enhancements
detect 0,2,"CHECK VOUCHER"

# set up document constants
const MAXCOLS=80                        # max cols to output
const MAXRCOLS=79                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "A/P Voucher"                 # view in pdf properties

prepage {
	doc_title$=trim(get(1,2,MAXCOLS))
}

# default line enhancements
cfont 1,1,8,MAXROWS,DBCFONT                 # date
cfont 10,1,19,MAXROWS,DCFONT                    # inv #
cfont 21,1,30,MAXROWS,DBRFONT                   # amt
cfont 32,1,41,MAXROWS,DBRFONT                   # disc
cfont 43,1,52,MAXROWS,DBRFONT                   # paid amt
cfont 54,1,MAXRCOLS,MAXROWS,DFONT               # comments

# header
cerase 1,1,MAXCOLS,2
cbox LEFTCOL,.5,RIGHTCOL,2.75,MBOXSIZE,HSHADE
text 2,1.25,{trim(get(1,1,15))},HBFONT
text 1,1.25,{trim(get(16,1,50))},HBCFONT,14,cols=MAXCOLS
text 1,1.25,{trim(get(75,1,6))},HBRFONT,cols=MAXRCOLS
text 1,2.25,{doc_title$},HBCFONT,12,cols=MAXCOLS

# ribbon info
cfont 1,4,6,4,IRFONT,proper                 # check # title
cfont 8,4,13,4,DBFONT                       # check #
cfont 16,4,22,4,IFONT,proper                    # vendor
cfont 24,4,MAXRCOLS,4,DBFONT                    # name & code

# detail headings
cerase 1,7,MAXCOLS,7
cbox LEFTCOL,5.5,RIGHTCOL,6.5,1,DSHADE
cfont 1,6,8,6,ICFONT,proper                 # date
cfont 10,6,19,6,ICFONT,proper                   # inv #
cfont 21,6,30,6,IRFONT,proper                   # amt
cfont 32,6,41,6,IRFONT,proper                   # disc
cfont 43,6,52,6,IRFONT,proper                   # paid amt
cfont 54,6,MAXRCOLS,6,IFONT,proper              # comments

# footer
hline "---",erase
box "   ---------",2,0.5,32,1.01,1,HSHADE

[P/R Check - long stub]
dsn_sample "/u0/unform_test/ssi/txt/pr_checks_long.txt"
# Check Control 01-01, 02-42, 03-03, 04-16, 05-51, 06-64, 07-75,
#           08-01, 09-18, 10-25, 11-36, 12-48, 13-61, 14-72,
#           15-21, 16-90, 17-66, 18-66, 19-07, 20-66, 21-12
# updated to version 5 enhancements

detect  51,2,"~ [0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]"
detect  66,49,"~ DATEMASK.."

# set up document constants
const MAXCOLS=83                        # max cols to output
const MAXRCOLS=82                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=83                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page 63                         # max input rows

const MAX_COPIES=1
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "P/R Check"                       # view in pdf properties

prepage {
	chk_date$=trim(get(67,49,8))
	# if stub date is missing, place check date there
	if trim(get(65,2,8))="" then  x$=set(65,2,8,chk_date$)
}

# stub
# header
text 2,1,"COMP_NAME",HBFONT,14
text 35,1,"COMP_ADDR1",HBFONT,12
text 55,1,"COMP_ADDR2",HBFONT,12

# ribbon
move 1,1,84,41,1,2                              # dn 1 row
cbox LEFTCOL,1.5,RIGHTCOL,3.5,MBOXSIZE,crows=2.5::ISHADE,  ccols=16 50 64 74
text 2,2,"Dept",ICFONT,cols=13
text 17,2,"Employee name",ICFONT,cols=33
text 51,2,"Social Security #",ICFONT,cols=13
text 65,2,"Date",ICFONT,cols=9
text 75,2,"Check #",ICFONT,cols=8
cfont 2,3,14,3,DBCFONT                      # Department
cfont 17,3,49,3,DBCFONT                         # Empl name
cfont 51,3,63,3,DBCFONT                     # SSN
cfont 65,3,73,3,DBCFONT                     # dt
cfont 75,3,82,3,DBCFONT                     # check #

# detail
cbox LEFTCOL,3.5,RIGHTCOL,40.5,MBOXSIZE,crows=4.5::DSHADE,  ccols=19 26 37 48:3 62 73
text 2,4,"Description",IFONT
text 20,4,"Hours",IRFONT,cols=6
text 27,4,"Gross",IRFONT,cols=10
text 38,4,"YTD Gross",IRFONT,cols=10
text 49,4,"Deductions",IFONT
text 63,4,"Deduct",IRFONT,cols=10
text 74,4,"Gross ded",IRFONT,cols=9
cfont 2,5,18,40,IFONT                       # desc
cfont 20,5,25,40,DBRFONT                    # hours
cfont 27,5,36,40,DBRFONT                    # gross
cfont 38,5,47,40,DBRFONT                    # ytd gross
cfont 49,5,61,40,IFONT                      # deductions
cfont 63,5,72,40,DBRFONT                    # deduct
cfont 74,5,82,40,DBRFONT                    # gross ded

# footer
cbox LEFTCOL,40.5,48,42.5,MBOXSIZE,ccols=26::100 37
cbox 62,40.5,RIGHTCOL,42.5,MBOXSIZE,ccols=73
text 2,41,"Gross totals",IBFONT,shade 0
text 2,42,"Net totals",IBFONT,shade 0
cfont 27,41,35,42,DBRFONT                   # gross
cfont 37,41,47,42,DBRFONT                   # ytd gross
cfont 63,41,72,42,DBRFONT                   # deduct
cfont 74,41,82,42,DBRFONT                   # gross ded

# check
# header
cbox 1,46,83,64.5,MBOXSIZE               # check
LOGO_IMAGE 1,46.5,10,5,"COMP_LOGO"
text 15,48.25,"COMP_NAME",HBFONT,14
text 15,49.35,"COMP_ADDR1",HFONT,12
text 15,50.35,"COMP_ADDR2",HFONT,12
text 15,51.35,"COMP_ADDR3",HFONT,12
text 70,49.35,"PR_ROUTING",DFONT,cols=10            # rtg#
text 49,48.25,"PR_BANK_NAME",DBFONT,cols=30
text 49,49.05,"PR_BANK_ADDR1",DFONT,cols=30
text 49,49.85,"PR_BANK_ADDR2",DFONT,cols=30

# ribbon
cerase 1,47,84,51
cbox 48,50.5,81,52.5,1,crows=51.5::100,ccols=57 69
text 49,51,"Check #",ICFONT,shade 0,cols=8
text 58,51,"Date",ICFONT,shade 0,cols=11
text 70,51,"Amount",IRFONT,shade 0,cols=11
text 49,52,{trim(get(65,47,15))},DBCFONT,cols=8
text 58,52,{chk_date$},DBCFONT,cols=11
text 70,52,{trim(get(67,51,11))},DBRFONT,cols=11

# check amt in words
cerase 2,51,MAXCOLS,51                      # amt in words
text 2,56,"Pay",HFONT,14
text 7,56,{trim(get(8,51,58))},IBFONT

# pay to
cmove 13,55,47,58,9,60                      # payee and addr
text 2,60,"Pay\nto the\nOrder\nof",HFONT
cfont 9,60,MAXRCOLS,63,DBFONT                   # payee and addr

# Bottom
text 48,59.5,"Check Void After 180 Days",ICFONT,cols=30
SIGNATURE_IMAGE 50,61,0,0,"SIGNATURE"
box 47,62.0,30,1,3                      # signature line
text 47,62.75,"Authorized Signature",ICFONT,cols=30
PR_MICR 15,65.5,"PR_MICR_ACCOUNTNO",{trim(get(65,47,15))}

[P/R Check - short stub - 1/2]
#dsn_sample "/u0/unform_test/Infor/FE_PR.txt"
dsn_sample "/u0/unform_test/Infor/txt/PRcheckshort.txt"
# Check Control 01-01, 02-21, 03-03, 04-16, 05-51, 06-64, 07-75,
#           08-01, 09-18, 10-25, 11-36, 12-48, 13-61, 14-72,
#           15-21, 16-90, 17-66, 18-66, 19-07, 20-66, 21-12
# updated to version 5 enhancements

detect  51,2,"~ [0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]"
detect  66,28,"~ DATEMASK.."

# set up document constants
const MAXCOLS=83                        # max cols to output
const MAXRCOLS=82                       # MAXCOLS-1
const LEFTCOL=1                         # left vertical line
const RIGHTCOL=83                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page 42                         # max input rows

const ONE_STUB_COPY=1
const TWO_STUB_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "P/R Check"                       # view in pdf properties

prepage {
	chk_date$=trim(get(67,28,8))
	# if stub date is missing, place check date there
	if trim(get(65,2,8))="" then x$=set(65,2,8,chk_date$)

	# get chk amt in words
	chk_amt_in_words$=trim(get(8,30,58))
	x$=trim(get(8,31,58))
	if x$<>"" then chk_amt_in_words$=chk_amt_in_words$+" "+x$

	# the following moves will leave a space between the
	# top two stubs
	# move check to bottom
	for i=23 to 42
		text$[i+24]=text$[i]
		text$[i]=""                     # clear line
	next i

	# copy stub from top to middle
	for i=1 to 22
		text$[i+24]=text$[i]
	next i

}

precopy {
	if copy=ONE_STUB_COPY and copy<>PR_NO_STUBS then skip=1
	if copy=ONE_STUB_COPY then  for i=1 to 21;  text$[i]="";  next i
	if copy=TWO_STUB_COPY and copy<>PR_NO_STUBS then skip=1
}

#employer stub
if copy TWO_STUB_COPY
	# header
	text 2,2,"COMP_NAME",HBFONT,14
	text 35,2,"COMP_ADDR1",HBFONT,12
	text 55,2,"COMP_ADDR2",HBFONT,12

	# ribbon
	move 1,1,83,23,1,3                          # dn 2 lns
	cbox 1,2.5,RIGHTCOL,4.5,MBOXSIZE,crows=3.5::ISHADE,  ccols=16 50 64 74
	text 2,3,"Dept",ICFONT,cols=13
	text 17,3,"Employee name",ICFONT,cols=33
	text 51,3,"Social Security #",ICFONT,cols=13
	text 65,3,"Date",ICFONT,cols=9
	text 75,3,"Check #",ICFONT,cols=8

	cfont 2,4,14,4,DBCFONT                  # department
	cfont 17,4,49,4,DBCFONT                     # empl name
	cfont 51,4,63,4,DBCFONT                 # ssn
	cfont 65,4,73,4,DBCFONT                 # dt
	cfont 75,4,82,4,DBCFONT                 # check #

	# detail
	cbox 1,4.5,RIGHTCOL,20.5,MBOXSIZE,crows=5.5::DSHADE, ccols=18 26 36 48:3 62 73
	text 2,5,"Description",IFONT
	text 19,5,"Hours",IRFONT,cols=7
	text 27,5,"Gross",IRFONT,cols=9
	text 37,5,"YTD Gross",IRFONT,cols=11
	text 49,5,"Deductions",IFONT
	text 63,5,"Deduct",IRFONT,cols=10
	text 74,5,"Gross ded",IRFONT,cols=9

	cfont 2,5,17,20,IFONT                   # desc
	cfont 19,5,25,20,DBRFONT                # hours
	cfont 27,5,35,20,DBRFONT                # gross
	cfont 37,5,47,20,DBRFONT                # ytd gross
	cfont 49,5,61,20,IFONT                  # deductions
	cfont 63,5,72,20,DBRFONT                # deduct
	cfont 74,5,82,20,DBRFONT                # gross ded

	# footer
	cbox 1,20.5,48,22.5,MBOXSIZE,ccols=26::100 36
	cbox 62,20.5,RIGHTCOL,22.5,MBOXSIZE,ccols=73
	text 2,21,"Gross totals",IBFONT,shade 0
	text 2,22,"Net totals",IBFONT,shade 0
	cfont 27,21,35,22,DBRFONT               # gross
	cfont 37,21,47,22,DBRFONT               # ytd gross
	cfont 63,21,72,22,DBRFONT               # deduct
	cfont 74,21,82,22,DBRFONT               # gross ded
endif

# employee stub
# header
text 2,24,"COMP_NAME",HBFONT,14
text 35,24,"COMP_ADDR1",HBFONT,12
text 55,24,"COMP_ADDR2",HBFONT,12

# ribbon
cbox 1,24.5,RIGHTCOL,26.5,MBOXSIZE,crows=25.5::ISHADE,  ccols=16 50 64 74
text 2,25,"Dept",ICFONT,cols=13
text 17,25,"Employee name",ICFONT,cols=33
text 51,25,"Social Security #",ICFONT,cols=13
text 65,25,"Date",ICFONT,cols=9
text 75,25,"Check #",ICFONT,cols=8

cfont 2,26,14,26,DBCFONT                    # Department
cfont 17,26,49,26,DBCFONT                   # Employee name
cfont 51,26,63,26,DBCFONT                   # SS#
cfont 65,26,73,26,DBCFONT                   # dt
cfont 75,26,82,26,DBCFONT                   # check #

# detail
cbox 1,26.5,RIGHTCOL,42.5,MBOXSIZE,crows=27.5::DSHADE,  ccols=18 26 36 48:3 62 73
text 2,27,"Description",IFONT
text 19,27,"Hours",IRFONT,cols=7
text 27,27,"Gross",IRFONT,cols=9
text 37,27,"YTD Gross",IRFONT,cols=11
text 49,27,"Deductions",IFONT
text 63,27,"Deduct",IRFONT,cols=10
text 74,27,"Gross ded",IRFONT,cols=9

cfont 2,27,17,45,IFONT                      # desc
cfont 19,27,25,45,DBRFONT                   # hours
cfont 27,27,35,45,DBRFONT                   # gross
cfont 37,27,47,45,DBRFONT                   # ytd gross
cfont 49,27,61,45,IFONT                     # deductions
cfont 63,27,72,45,DBRFONT                   # deduct
cfont 74,27,82,45,DBRFONT                   # gross ded

# footer
cbox 1,42.5,48,44.5,MBOXSIZE,ccols=26::100 36
cbox 62,42.5,RIGHTCOL,44.5,MBOXSIZE,ccols=73
text 2,43,"Gross totals",IBFONT,shade 0
text 2,44,"Net totals",IBFONT,shade 0

cfont 27,27,35,45,DBRFONT                   # gross
cfont 37,27,47,45,DBRFONT                   # ytd gross
cfont 63,27,72,45,DBRFONT                   # deduct
cfont 74,27,82,45,DBRFONT                   # gross ded

# check
# header
cbox 1,46,83,64.5,MBOXSIZE                  # check
LOGO_IMAGE 1,47,10,5,"COMP_LOGO"
text 15,48.25,"COMP_NAME",HBFONT,14
text 15,49.35,"COMP_ADDR1",HFONT,12
text 15,50.35,"COMP_ADDR2",HFONT,12
text 15,51.35,"COMP_ADDR3",HFONT,12
text 70,49.35,"PR_ROUTING",DFONT                # rtg#
text 49,48.25,"PR_BANK_NAME",DBFONT
text 49,49.05,"PR_BANK_ADDR1",DFONT
text 49,49.85,"PR_BANK_ADDR2",DFONT

# ribbon
move 65,50,15,1,49,52                       # check #
move 67,52,15,1,58,52                       # dt up
move 67,54,15,1,70,52                       # numeric $ amt
cbox 48,50.5,81,52.5,1,crows=51.5::100,ccols=57 69
text 49,51,"Check #",ICFONT,shade 0,cols=8
text 58,51,"Date",ICFONT,shade 0,cols=11
text 70,51,"Amount",IRFONT,shade 0,cols=11

cfont 49,51,56,52,DBCFONT                   # check #
cfont 58,51,68,52,DBCFONT                   # dt
cfont 70,51,80,52,DBRFONT                   # amt
cerase 81,52,100,52

# check amt in words
cerase 2,54,100,57                          # amt in words
text 2,56,"Pay",HFONT,14
text 7,56,{trim(get(8,54,58))},IBFONT,cols=70

# pay to
cmove 13,58,47,61,9,60                      # payee and addr
text 2,60,"Pay",HFONT
text 2,61,"to the",HFONT
text 2,62,"Order",HFONT
text 2,63,"of",HFONT
cfont 9,60,MAXRCOLS,63,DBFONT                   # payee and addr

# Bottom
text 48,59.5,"Check Void After 180 Days",ICFONT,cols=30
SIGNATURE_IMAGE 50,61,0,0,"SIGNATURE"
box 47,62.0,30,1,3                      # signature line
text 47,62.75,"Authorized Signature",ICFONT,cols=30
PR_MICR 15,65.5,"PR_MICR_ACCOUNTNO",{trim(get(65,50,15))}

[A/R Dunning letter]
dsn_sample "/u0/unform_test/ssi/txt/ar_dunning.txt"
# Dunning Control   1-5, 2-N, 3-D, 4-S, 5-0, 6-0, 7-N, 8-0
# updated to version 5 enhancements
detect 0,3,"PAST DUE NOTICE"
detect 0,5,"PAGE"

# set up document constants
const MAXCOLS=80                        # max cols to output
const MAXRCOLS=79                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const MAX_COPIES=2
copies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "Dunning Letter"                  # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
	doc_title$="Past Due Notice"
	date$=""
}

prepage {
	xcol=20,xrow=5,xcols=40,tpos=2
	merge "Mrg get company info"

	# locate start of notice of past due items
	for i=1 to 66
		x=pos("NOTICE OF PAST DUE ITEMS"=text$[i])
		if x then nrow=i,ncol=x;break
	next i

	to$="",cust_code$="",cust_info$="",srow=0,lrow=0
	if nrow>14 then to$="To:";  cust_code$=trim(cut(10,14,20,""));  cust_info$=mcut(10,15,40,5,"","Y","Y");  date$=trim(cut(64,19,8,""));  srow=21,lrow=nrow-1
}

# default line
const BROW=1
const EROW=MAXROWS
cfont 19,BROW,24,EROW,DCFONT                    # inv #
cfont 31,BROW,38,EROW,DBCFONT                   # date
cfont 41,BROW,49,EROW,DCFONT                    # days past
cfont 51,BROW,62,EROW,DBRFONT                   # amount

# header section
cerase 1,1,MAXCOLS,8
merge "Mrg Form Header"
#text 1,2,"Past Due Notice",HBRFONT,16,cols=MAXCOLS
text 1,4.1,{trim(get(70,5,10))},HRFONT,cols=MAXRCOLS
text 1,6.1,{date$},HBRFONT,cols=MAXRCOLS

# customer name & addr
text 2,15,{to$},IRFONT,light,cols=6
text 10,14,{cust_code$},DBFONT
text 10,15,{cust_info$},DBFONT

# letter text
cfont 7,{srow},MAXRCOLS,{lrow},IFONT

# new headers
cfont 1,{nrow},MAXCOLS,{nrow},IBCFONT
font {ncol-13},{nrow+2},12,1,ICFONT
font {ncol+4},{nrow+2},4,1,ICFONT
font {ncol+12},{nrow+2},9,1,ICFONT
font {ncol+28},{nrow+2},6,1,IRFONT

# footer
cfont 26,56,36,57,IBRFONT
cfont 38,56,48,57,IBRFONT
cfont 26,59,36,59,HBRFONT
cfont 38,59,48,59,HBRFONT
text 1,65,{copy_title$[copy]},HBCFONT,12,cols=MAXCOLS

[J/C Estimate]
dsn_sample "/u0/unform_test/ssi/txt/jc_estnocost.txt"
# Handles with and without cost tearoff
# Static Control    9-66, 10-N, 11-Y/N
# updated to version 5 enhancements
detect 0,2,"ESTIMATE"
detect 0,7,"~DATEMASK"

# set up document constants
const MAXCOLS=80                        # max cols to output
const MAXRCOLS=79                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const INTERNAL_COPY=3
const MAX_COPIES=3
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "J/C Estimate"                    # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
	if MAX_COPIES>=3 then  copy_title$[INTERNAL_COPY]="Internal Copy"
}

prepage {
	#get header info for better placement
	doc_title$=trim(get(34,2,8))
	merge "Mrg get watermark text"

	reprint$=trim(get(72,2,7))
	xcol=20,xrow=3,xcols=40,tpos=2
	merge "Mrg get company info"
}

precopy {
	if copy=INTERNAL_COPY then cols$="100"
	if trim(get(83,3,8))<>"ESTIMATE" and  copy=INTERNAL_COPY then skip=1
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# erase cost section if not copy 3
if copy CUSTOMER_COPY,FILE_COPY
	cerase 81,1,100,MAXROWS
end if

# default line
const BROW=26
const EROW=63
cfont 2,BROW,5,EROW,DBCFONT                 # code
cfont 7,BROW,44,EROW,DFONT                  # desc
cfont 46,BROW,54,EROW,DBRFONT                   # units
cfont 56,BROW,57,EROW,DBCFONT                   # uom
cfont 59,BROW,67,EROW,DBRFONT                   # price
cfont 69,BROW,MAXRCOLS,EROW,DBRFONT             # extension
if copy INTERNAL_COPY
	cfont 82,BROW,92,EROW,DBRFONT               # cost
	cfont 94,BROW,99,EROW,DBRFONT               # gm
end if

# header section
cerase 1,1,100,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
if copy INTERNAL_COPY
	cbox 81,1,100,MAXROWS,MBOXSIZE
end if
merge "Mrg Form Header"
# handle copy title
cbox 64,3.75,RIGHTCOL,5.25,1,100
text 65,4.6,{copy_title$[copy]},HBCFONT,12,cols=15,shade 0
text 1,9.5,{"Job: "+trim(get(8,8,40))},HCFONT,12,cols=MAXRCOLS

# right header
cbox 64,5.5,RIGHTCOL,10,1,ccols=72::ISHADE,crows=7 8.5
text 65,6.25,"Number",IFONT,cols=7
text 65,7.75,"Date",IFONT,cols=7
text 65,9.25,"Page",IFONT,cols=7
text 73,6.25,{trim(get(70,3,8))},DBFONT,cols=7
text 73,7.75,{trim(get(70,7,8))},DBFONT,cols=7
text 73,9.25,{trim(get(77,5,3))},DBFONT,cols=7
if copy INTERNAL_COPY
	cbox 81,1,100,6,1,ccols=90::ISHADE,crows=4
	text 82,3,"Number",IFONT,cols=8
	text 82,5,"Customer",IFONT,cols=8
	text 92,3,{trim(get(70,3,8))},DBFONT,cols=7
	text 92,5,{trim(get(58,10,20))},DBFONT,cols=7
end if

# ship to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,ccols=10::ISHADE 41 50::ISHADE
text 2,11,"Ship To:",ICFONT,cols=8
cmove 7,11,41,14,11,11
text 2,12,{trim(get(15,10,15))},DBCFONT,cols=8
cfont 11,11,41,14,DBFONT                    # ship to addr

# bill to section
text 42,11,"Bill To:",ICFONT,cols=8
cmove 49,11,MAXRCOLS,14,51,11
text 42,12,{trim(get(58,10,20))},DBCFONT,cols=8
cfont 51,11,MAXRCOLS,14,DBFONT              # bill to addr

# ribbon 1 section
cerase 17,16,17,18
cerase 26,16,26,18
cerase 36,16,36,18
cerase 52,16,52,18
cerase 55,16,55,18
cerase 63,16,63,18
cbox LEFTCOL,15,RIGHTCOL,23,MBOXSIZE
cbox LEFTCOL,15,RIGHTCOL,19,1,crows=17::ISHADE,  ccols=17 26 36 52 55 63
cfont 2,16,16,16,ICFONT,proper              # ref no
cfont 18,16,25,16,ICFONT,proper             # expires
cfont 27,16,35,16,ICFONT,proper             # estimator
cfont 37,16,51,16,ICFONT,proper             # terms
cfont 53,16,54,16,ICFONT,proper             # whs
cfont 56,16,62,16,ICFONT,proper             # frt
cfont 64,16,MAXRCOLS,16,ICFONT,proper           # ship via

cfont 2,18,16,18,DBCFONT                    # ref #
cfont 18,18,25,18,DBCFONT                   # expires
cfont 27,18,35,18,DBCFONT                   # estimator
cfont 37,18,51,18,DBCFONT                   # terms
cfont 53,18,54,18,DBCFONT                   # whs
cfont 56,18,62,18,DBCFONT                   # frt
cfont 64,18,MAXRCOLS,18,DBCFONT             # ship via

# ribbon 2 section
cerase 33,20,33,22
cerase 42,20,42,22
cerase 51,20,51,22
cbox LEFTCOL,19,RIGHTCOL,23,1,crows=21::ISHADE,  ccols=33 42 51
cfont 2,20,32,20,ICFONT,proper              # billing
cfont 34,20,41,20,ICFONT,proper             # start
cfont 43,20,50,20,ICFONT,proper             # finish
cfont 52,20,MAXRCOLS,20,ICFONT,proper           # units

cfont 2,22,32,22,DBCFONT                    # billing
cfont 34,22,41,22,DBCFONT                   # start
cfont 43,22,50,22,DBCFONT                   # finish
cfont 52,22,MAXRCOLS,22,DBCFONT             # units

# detail
cerase 6,24,6,63
cerase 45,24,45,63
cerase 55,24,55,63
cerase 58,24,58,63
cerase 68,24,68,63
cerase 83,24,83,63
cerase 93,24,93,63
cbox LEFTCOL,23,RIGHTCOL,64,MBOXSIZE,crows=25::DSHADE,  ccols=6 45 55 58 68
cfont 2,24,5,24,ICFONT,proper                   # code
cfont 7,24,44,24,IFONT,proper                   # desc
cfont 46,24,54,24,IRFONT,proper             # units
cfont 56,24,57,24,ICFONT                    # uom
cfont 59,24,67,24,IRFONT,proper             # price
cfont 69,24,MAXRCOLS,24,IRFONT,proper           # extension

if copy INTERNAL_COPY
	cbox 81,23,100,64,MBOXSIZE,crows=25::DSHADE,ccols=93
	cfont 82,24,92,24,IRFONT,proper         # cost
	cfont 94,24,99,24,IRFONT,proper         # gm
end if

# watermark - large font with light shading
WATERMARK 1,{63-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cerase LEFTCOL,64,100,64
cerase 9,64,9,MAXROWS
cerase 30,64,30,MAXROWS
cerase 47,64,47,MAXROWS
cerase 61,64,61,MAXROWS
cerase 93,64,93,MAXROWS
cbox LEFTCOL,64,RIGHTCOL,MAXROWS,MBOXSIZE,  ccols=13 20::HSHADE 32 38::HSHADE 47 51::HSHADE 62 68::HSHADE
cfont 10,65,19,65,IBRFONT,proper                # subtot
cfont 31,65,37,65,IBRFONT,proper                # frt
cfont 48,65,50,65,IBRFONT,proper                # tax
cfont 62,65,67,65,IBRFONT,10,proper             # tot

cfont 21,65,29,65,DBFONT                    # subtot
cfont 39,65,46,65,DBFONT                    # frt
cfont 52,65,60,65,DBFONT                    # tax
cfont 69,65,MAXRCOLS,65,DBRFONT,10              # tot
if copy INTERNAL_COPY
	cbox 81,64,100,MAXROWS,MBOXSIZE,ccols=93
	cfont 82,65,92,65,DBRFONT,9             # tot cost
	cfont 94,63,99,65,DBRFONT               # gm
end if

[J/C Invoice]
dsn_sample "/u0/unform_test/ssi/txt/jc_invnocost.txt"
# Handles with and without cost tearoff
# Static Control    12-66, 13-N, 14-Y/N
# updated to version 5 enhancements
detect 0,2,"INVOICE"
detect 0,16,"JOB#"

# set up document constants
const MAXCOLS=80                        # max cols to output
const MAXRCOLS=79                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const INTERNAL_COPY=3
const MAX_COPIES=3
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "J/C Invoice"                 # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
	if MAX_COPIES>=3 then  copy_title$[INTERNAL_COPY]="Internal Copy"
}

prepage {
	doc_title$=trim(get(40,2,7))
	merge "Mrg get watermark text"

	reprint$=trim(get(70,2,7))
	xcol=20,xrow=3,xcols=40,tpos=2
	merge "Mrg get company info"
}

precopy {
	if copy=INTERNAL_COPY then cols$="100"
	if trim(get(83,3,7))<>"INVOICE" and  copy=INTERNAL_COPY then skip=1
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# erase cost section if not copy 3
if copy CUSTOMER_COPY,FILE_COPY
	cerase 81,1,100,MAXROWS
end if

# default line
const BROW=26
const EROW=60
cfont 2,BROW,67,EROW,DFONT                      # desc
cfont 69,BROW,MAXRCOLS,EROW,DBRFONT                 # amt
if copy INTERNAL_COPY
	cfont 82,26,92,63,DBRFONT                   # cost
	cfont 94,26,99,63,DBRFONT                   # gm
end if

# header section
cerase 1,1,100,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
if copy INTERNAL_COPY
	cbox 81,1,100,MAXROWS,MBOXSIZE
end if
merge "Mrg Form Header"
# handle copy title
cbox 64,3.75,RIGHTCOL,5.25,1,100
text 65,4.6,{copy_title$[copy]},HBCFONT,12,cols=15,shade 0

# right header
cbox 64,5.5,RIGHTCOL,10,1,crows=7 8.5,ccols=72::ISHADE
text 65,6.25,"Number",IFONT,cols=7
text 65,7.75,"Date",IFONT,cols=7
text 65,9.25,"Page",IFONT,cols=7
text 73,6.25,{trim(get(70,3,8))},DBFONT,cols=8
text 73,7.75,{trim(get(71,7,8))},DBFONT,cols=8
text 73,9.25,{trim(get(70,5,3))},DBFONT,cols=3
if copy INTERNAL_COPY
	cbox 81,1,100,8,1,crows=4 6,ccols=90::ISHADE
	text 82,3,"Invoice #",IFONT,cols=8
	text 82,5,"Job #",IFONT,cols=8
	text 82,7,"Customer",IFONT,cols=8
	text 92,3,{trim(get(70,3,8))},DBFONT,cols=8
	text 92,5,{trim(get(91,5,8))},DBFONT,cols=8
	text 92,7,{trim(get(16,10,25))},DBFONT,cols=25
end if

# bill to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,ccols=10::ISHADE 41 50::ISHADE
text 2,11,"Bill To:",ICFONT,cols=8
text 2,12,{trim(get(16,10,25))},DBCFONT,cols=8
cmove 7,11,41,14,11,11
cfont 11,11,40,14,DBFONT                    # bill to addr

# ship to section
text 42,11,"Ship To:",ICFONT,cols=8
text 42,12,{trim(get(57,10,15))},DBCFONT,cols=8
cmove 49,11,MAXRCOLS,14,51,11
cfont 51,11,MAXRCOLS,14,DBFONT              # ship to addr

# ribbon 1 section
cerase 10,15,10,19
cerase 41,15,41,19
cerase 52,15,52,19
cbox LEFTCOL,15,RIGHTCOL,23,MBOXSIZE
cbox LEFTCOL,15,RIGHTCOL,19,crows=17::ISHADE,  ccols=10 41 52
cfont 2,16,9,16,ICFONT,proper                   # job #
cfont 11,16,40,16,ICFONT,proper             # name
cfont 42,16,51,16,ICFONT,proper             # contract #
cfont 53,16,MAXRCOLS,16,ICFONT,proper           # manager

cfont 2,18,9,18,DBCFONT                     # job #
cfont 11,18,40,18,DBCFONT                   # name
cfont 42,18,51,18,DBCFONT                   # contract #
cfont 53,18,MAXRCOLS,18,DBCFONT             # manager

# ribbon 2 section
cerase 17,20,17,22
cerase 23,20,23,22
cerase 39,20,39,22
cerase 48,20,48,22
cerase 51,20,51,22
cbox LEFTCOL,19,RIGHTCOL,23,crows=21::ISHADE,  ccols=17 23 39 48 51
cfont 2,20,16,20,ICFONT,proper              # ref #
cfont 18,20,22,20,ICFONT,proper             # salesperson
cfont 24,20,38,20,ICFONT,proper             # terms
cfont 40,20,47,20,ICFONT,proper             # tax code
cfont 49,20,50,20,ICFONT,proper             # whs
cfont 52,20,MAXRCOLS,20,ICFONT,proper           # billing

cfont 2,22,16,22,DBCFONT                    # ref #
cfont 18,22,22,22,DBCFONT                   # salesperson
cfont 24,22,38,22,DBCFONT                   # terms
cfont 40,22,47,22,DBCFONT                   # tax code
cfont 49,22,50,22,DBCFONT                   # whs
cfont 52,22,MAXRCOLS,22,DBCFONT             # billing

# detail
cerase 68,24,68,60
cerase 83,24,83,60
cerase 93,24,93,60
cbox LEFTCOL,23,RIGHTCOL,60,MBOXSIZE,crows=25::DSHADE,ccols=68
cfont 2,24,67,24,IFONT,proper                   # desc
cfont 69,24,MAXRCOLS,24,IRFONT,proper           # amt

if copy INTERNAL_COPY
	cbox 81,23,100,60,MBOXSIZE,crows=25::DSHADE,ccols=93
	cfont 82,24,92,24,IRFONT,proper         # cost
	cfont 94,24,99,24,IRFONT,proper         # gm
end if

# watermark - large font with light shading
WATERMARK 1,{59-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cerase 36,62,100,62
cerase 36,64,100,64
cerase 36,61,36,64
cerase 48,61,48,63
cerase 57,61,57,63
cerase 67,61,67,63
cerase 93,61,93,63
cbox LEFTCOL,60,RIGHTCOL,MAXROWS,MBOXSIZE
cbox 36,60,RIGHTCOL,64,1,crows=62::HSHADE,ccols=48 57 67
cfont 37,61,47,61,IBRFONT,proper                # amt
cfont 50,61,56,61,IBRFONT,proper                # frt
cfont 58,61,66,61,IBRFONT,proper                # tax
cfont 68,61,MAXRCOLS,61,IBRFONT,10,proper           # tot due
cfont 37,63,47,63,DBRFONT                   # amt
cfont 50,63,56,63,DBRFONT                   # frt
cfont 58,63,66,63,DBRFONT                   # tax
cfont 68,63,MAXRCOLS,63,DBRFONT,10              # tot due

if copy INTERNAL_COPY
	cbox 81,60,100,MAXROWS,MBOXSIZE
	cbox 81,60,100,64,1,crows=62::HSHADE,ccols=93
	cfont 82,61,92,61,IBRFONT,9,proper          # tot cost
	cfont 94,61,99,61,IBRFONT,proper            # gm
	cfont 82,63,92,63,DBRFONT,9             # tot cost
	cfont 94,63,99,63,DBRFONT               # gm
end if
cfont 2,61,35,64,DFONT
cfont 2,65,MAXRCOLS,65,DFONT

[M/C Production Ticket]
dsn_sample "/u0/unform_test/ssi/txt/mc_prodticket.txt"
# updated to version 5 enhancements
detect 0,3,"PRODUCTION TICKET"

# set up document constants
const MAXCOLS=80                        # max cols to output
const MAXRCOLS=79                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const WHSE_COPY=1
const FILE_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "M/C Production Ticket"               # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[WHSE_COPY]="Warehouse Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
}

prepage {
	#get header info for better placement
	doc_title$=trim(get(20,3,40))
	merge "Mrg get watermark text"

	xrow=10
	merge "Mrg get desc pos"

	xrow=12,yrow=62,ipos=6
	merge "Mrg find memos"
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# default detail line
const BROW=12
const EROW=61
cfont 2,BROW,4,EROW,DCFONT                      # line #
cfont 6,BROW,{desc_pos-2},EROW,DBFONT,IJUST             # item
cfont {desc_pos},BROW,42,EROW,DFONT                 # desc
cfont 44,BROW,52,EROW,DBRFONT                       # units
cfont 54,BROW,55,EROW,DBCFONT                       # um
cfont 57,BROW,MAXRCOLS,EROW,DFONT                   # memo

# header section
cerase 1,1,MAXCOLS,5
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
text 1,2,{doc_title$},HBCFONT,16,cols=MAXRCOLS
text 1,4,{trim(get(20,2,40))},HBCFONT,14,cols=MAXRCOLS
cfont 2,6,MAXRCOLS,6,IBFONT
cfont 2,8,MAXRCOLS,8,IBFONT
# handle copy title
cbox 65,1.75,RIGHTCOL,3,1,100
text 66,2.5,{copy_title$[copy]},HBCFONT,12,cols=14,shade 0

# right header
cbox 65,3.5,RIGHTCOL,8,crows=5 6.5,ccols=73::ISHADE
text 66,4.25,"Number",IFONT,cols=7
text 66,5.75,"Date",IFONT,cols=7
text 66,7.25,"Whse",IFONT,cols=7
text 74,4.25,{trim(get(70,2,6))},DBFONT,cols=6
text 74,5.75,{trim(get(70,3,8))},DBFONT,cols=8
text 74,7.25,{trim(get(70,4,2))},DBFONT,cols=2

# detail heading
cbox LEFTCOL,9,RIGHTCOL,61,MBOXSIZE,crows=11::DSHADE,  ccols=5 43 53 56
cbox {desc_pos-1},9,{desc_pos-1},61
cfont 6,10,{desc_pos-2},10,IFONT,IJUST,proper           # item
cfont {desc_pos},10,42,10,IFONT,proper              # desc
cfont 44,10,52,10,IRFONT,proper                 # units
cfont 54,10,55,10,ICFONT                        # um
cfont 57,10,MAXRCOLS,10,IFONT,proper                # memo

# detail exceptions
font "mL@1,12,27,61",3,0,60,1,DFONT,black               # memo lines
erase "mL@1,12,27,61",0,0,2,1                       # spec chars

# watermark - large font with light shading
WATERMARK 1,{61-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cbox LEFTCOL,61,RIGHTCOL,MAXROWS,MBOXSIZE
cfont 1,64,MAXRCOLS,64,DRFONT,
font "DATE@1,63,MAXCOLS,MAXROWS",0,0,4,1,DRFONT,proper
font "INITIALS@1,63,MAXCOLS,MAXROWS",0,0,8,1,DRFONT,proper

[S/O Bill of Lading]
dsn_sample "/u0/unform_test/ssi/txt/BOL.TXT"
#dsn_sample "/u0/unform_test/ssi/txt/so_bol.txt"
# BOL Control   1-N, 2-Y/N, 3-Y/N
# updated to version 5 enhancements
detect 0,1,"STRAIGHT BILL OF LADING"

# set up document constants
const MAXCOLS=81                        # max cols to output
const MAXRCOLS=80                       # MAXCOLS-1
const LEFTCOL=1                         # left vertical line
const RIGHTCOL=81                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                            # max output columns
rows MAXROWS                            # max output rows
page MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
const MAX_COPIES=2
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "S/O Bill of Lading"              # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
}

prepage {
	#get header info for better placement
	doc_title$=trim(get(56,1,24))
	reprint$=trim(get(71,4,7))
	xcol=10,xrow=3,xcols=40,tpos=1.1
	merge "Mrg get company info"
}

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# header section
cerase 1,1,MAXCOLS,12
merge "Mrg Form Header"
text 1,2.1,{trim(get(56,2,24))},HBRFONT,12,cols=MAXRCOLS
# handle copy title
cbox 64,3.75,RIGHTCOL,5.25,1,100
text 65,4.6,{copy_title$[copy]},HBCFONT,12,cols=15,shade 0

# right header
cbox 64,5.5,RIGHTCOL,10,ccols=64 72::ISHADE, crows=7 8.5
text 65,6.25,"Number",IFONT,cols=7
text 65,7.75,"Date",IFONT,cols=7
text 65,9.25,"Page",IFONT,cols=7
text 73,6.25,{trim(get(74,6,6))},DBFONT,cols=6
text 73,7.75,{trim(get(72,8,8))},DBFONT,cols=8
text 73,9.25,{trim(get(63,10,3))},DBFONT,cols=3
text 75,9.25,"of   ___",IFONT,cols=7

# ship to section
cerase 1,13,1,17
cbox LEFTCOL,12,RIGHTCOL,18,MBOXSIZE,ccols=11::ISHADE
text 2,13,"Ship To:",ICFONT,cols=9
text 2,14,{trim(get(10,12,15))},DBCFONT,cols=9
cmove 10,13,50,17,12,13
cfont 12,13,41,17,DBFONT                    # ship to addr

# ribbon 1 section
cerase 8,18,8,20
cerase 31,18,31,20
cerase 34,18,34,20
cerase 38,18,38,20
cerase 44,18,44,20
cbox LEFTCOL,18,RIGHTCOL,20,MBOXSIZE,  ccols=8::ISHADE 31 34::ISHADE 38 44::ISHADE
cfont 1,19,7,19,IRFONT,proper                   # carrier
cfont 32,19,33,19,IRFONT,proper             # whs
cfont 39,19,43,19,IRFONT,proper             # notes

cfont 9,19,30,19,DBFONT                     # carrier
cfont 35,19,37,19,DBFONT                    # whs
cfont 45,19,MAXRCOLS,19,DFONT                   # notes

# detail
cerase 7,20,7,36
cerase 11,20,11,36
cerase 66,20,66,36
cerase 75,20,75,36
cbox LEFTCOL,20,RIGHTCOL,36,MBOXSIZE,crows=22::DSHADE,  ccols=7 11 66 75
cfont 1,21,6,21,IRFONT,proper                   # units
cfont 8,21,10,21,ICFONT,proper              # hm ??
cfont   12,21,65,21,IFONT,proper                # desc
cfont 67,21,74,21,IRFONT,proper             # wt
cfont 76,21,MAXRCOLS,21,ICFONT,proper           # class

cfont 1,23,6,36,DBRFONT                     # units
cfont 8,23,10,36,DBCFONT                    # hm ??
cfont 12,23,65,36,DFONT                     # desc
cfont 67,23,74,36,DBRFONT                   # wt
cfont 76,23,MAXRCOLS,36,DBCFONT             # class

# continued
cbox LEFTCOL,36,RIGHTCOL,38,MBOXSIZE,ISHADE
cfont LEFTCOL,37,MAXRCOLS,37,IBRFONT,proper

# emergency contact
cbox LEFTCOL,38,RIGHTCOL,40,MBOXSIZE,ccols=27::DSHADE
cerase 27,39,27,39
cfont LEFTCOL,39,26,39,IRFONT,proper            # emer contact
cfont 28,39,MAXRCOLS,39,DBFONT              # emer contact

# rules
cbox LEFTCOL,40,RIGHTCOL,53,MBOXSIZE,crows=45
cfont LEFTCOL,41,MAXRCOLS,44,DBCFONT
cfont LEFTCOL,46,MAXRCOLS,52,DBCFONT

# shipper
cerase 71,55,MAXCOLS,55
cbox LEFTCOL,53,RIGHTCOL,57,MBOXSIZE,ccols=8::ISHADE 45 64::ISHADE
cfont 1,54,7,54,IRFONT,proper                   # shipper
cfont 1,55,7,55,IRFONT,proper                   # signed
cfont 9,54,44,54,DBFONT
cfont 46,54,63,54,IRFONT,proper             # rcv company
cfont 46,55,63,55,IRFONT,proper             # signed
text 1,56,"Date",IRFONT,cols=63             # dt

text 10,56,"___________________________",DFONT      # signed shipper
text 66,55,"__________________",DFONT           # signed rcv
text 66,56,"__________________",DFONT           # dt

[S/R Work Ticket]
dsn_sample "/u0/unform_test/ssi/txt/sr_workticket.txt"
# updated to version 5 enhancements
detect 0,2,"WORK TICKET PRINT"

# set up document constants
const MAXCOLS=85                        # max cols to output
const MAXRCOLS=84                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=85                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const SERVICE_COPY=3
const MAX_COPIES=3
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "S/R Work Ticket"                 # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
	if MAX_COPIES>=3 then  copy_title$[SERVICE_COPY]="Service Copy"
}

prepage {
	#get header info for better placement
	doc_title$=trim(get(35,2,11))
	merge "Mrg get watermark text"

	xcol=20,xrow=3,xcols=40,tpos=2
	merge "Mrg get company info"
}


# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# header section
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "Mrg Form Header"
# handle copy title
cbox 64,3.75,RIGHTCOL,5.25,1,100
text 65,4.6,{copy_title$[copy]},HBCFONT,12,cols=20,shade 0

# right header
cbox 64,5.5,RIGHTCOL,10
cbox 64,5.5,72,10,1,ISHADE
cbox 64,7,RIGHTCOL,7
cbox 64,8.5,RIGHTCOL,8.5
text 65,6.25,"Number",IFONT,cols=7
text 65,7.75,"Date",IFONT,cols=7
text 65,9.25,"Page",IFONT,cols=7
text 73,6.25,{trim(get(78,3,7))},DBFONT,cols=7
text 73,7.75,{trim(get(76,7,8))},DBFONT,cols=8
text 73,9.25,{trim(get(82,5,3))},DBFONT,cols=3

# bill to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,ccols=10::ISHADE 41 50::ISHADE
text 2,11,"Bill To:",ICFONT,cols=8
text 2,12,{trim(get(17,10,23))},DBCFONT,cols=8
cmove 7,11,41,14,11,11
cfont 11,11,40,14,DBFONT                    # ship to addr

# location section
text 42,11,"Location:",ICFONT,cols=8
text 42,12,{trim(get(64,10,15))},DBCFONT,cols=8
cmove 49,11,MAXRCOLS,14,51,11
cfont 51,11,MAXRCOLS,14,DBFONT              # bill to addr

# ribbon 1 section
cerase 17,15,17,19
cerase 26,15,26,19
cerase 36,15,36,19
cerase 41,15,41,19
cerase 57,15,57,19
cerase 61,15,61,19
cerase 69,15,69,19
cbox LEFTCOL,15,RIGHTCOL,19,MBOXSIZE,crows=17::ISHADE,  ccols=17 26 36 41 57 61 69
cfont 2,16,16,16,ICFONT,proper              # ref #
cfont 18,16,25,16,ICFONT,proper             # order date
cfont 27,16,35,16,ICFONT,proper             # requested
cfont 37,16,40,16,ICFONT,proper             # slsp
cfont 42,16,56,16,ICFONT,proper             # terms
cfont 58,16,60,16,ICFONT,proper             # whs
cfont   62,16,68,16,ICFONT,proper               # freight
cfont 70,16,MAXRCOLS,16,ICFONT,proper           # ship via

cfont 2,18,16,18,DBCFONT                    # ref #
cfont 18,18,25,18,DBCFONT                   # order date
cfont 27,18,35,18,DBCFONT                   # requested
cfont 37,18,40,18,DBCFONT                   # slsp
cfont 42,18,56,18,DBCFONT                   # terms
cfont 58,18,60,18,DBCFONT                   # whs
cfont 62,18,68,18,DBCFONT                   # freight
cfont 70,18,MAXRCOLS,18,DBCFONT             # ship via

# detail
cbox LEFTCOL,19,RIGHTCOL,62,MBOXSIZE

# watermark - large font with light shading
WATERMARK 1,{60-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cbox LEFTCOL,62,RIGHTCOL,MAXROWS,MBOXSIZE
cfont 2,63,MAXRCOLS,65,DFONT

[A/R Invoice]
dsn_sample "/u0/unform_test/ssi/txt/ar_invcost.txt"
# handles both cost and no cost styles of A/R invoices
# Invoice Control   2-Y, 3-Y, 4-%, 9-N, 10-Y/N, 11-66
# updated to version 5 enhancements
detect 0,2,"INVOICE"
detect 0,16,"INVOICED"

# set up document constants
const MAXCOLS=80                        # max cols to output
const MAXRCOLS=79                       # MAXCOLS-1
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows
page MAXROWS                        # max input rows

const CUSTOMER_COPY=1
const FILE_COPY=2
const INTERNAL_COPY=3
const MAX_COPIES=3
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "A/R Invoice"                 # view in pdf properties

prejob {
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
	if MAX_COPIES>=2 then  copy_title$[FILE_COPY]="Accounting Copy"
	if MAX_COPIES>=3 then  copy_title$[INTERNAL_COPY]="Internal Copy"
}

prepage {
	#get header info for better placement
	doc_title$=trim(get(40,2,10))
	merge "Mrg get watermark text"

	reprint$=trim(get(71,2,7))
	xcol=20,xrow=3,xcols=40,tpos=2
	merge "Mrg get company info"

	xrow=20,ipos=2
	merge "Mrg get desc pos"
}

precopy {
	if copy=INTERNAL_COPY then cols$="100"
	if trim(get(84,3,3))<>"NO." and copy=INTERNAL_COPY then  skip=1
}

# erase columns !
vline "!!",erase

# erase rows - or =
hline "==",erase
hline "--",erase
hline "^^"

# erase cost section if not copy 3
if copy CUSTOMER_COPY,FILE_COPY
	cerase 81,1,100,MAXROWS
end if

# default line enhancement
const BROW=22
const EROW=60
cfont {desc_pos-2},BROW,2,EROW,DBFONT,IJUST         # item
cfont {desc_pos},BROW,67,EROW,DFONT                 # desc
cfont 69,BROW,MAXRCOLS,EROW,DBRFONT                 # price
if copy INTERNAL_COPY
	cfont 82,22,92,60,DBRFONT                   # cost
	cfont 94,22,99,60,DBRFONT                   # gm
end if

# header section
cerase 1,1,100,10
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
if copy INTERNAL_COPY
	cbox 81,1,100,MAXROWS,MBOXSIZE
end if
merge "Mrg Form Header"
# handle copy title
cbox 64,3.75,RIGHTCOL,5.25,1,100
text 65,4.6,{copy_title$[copy]},HBCFONT,12,cols=15,shade 0

# right header
cbox 64,5.5,RIGHTCOL,10,1,ccols=72::ISHADE,crows=7 8.5
if copy INTERNAL_COPY
	cbox 81,1,100,4,1,ccols=90::ISHADE
end if
text 65,6.25,"Number",IFONT,cols=7
text 65,7.75,"Date",IFONT,cols=7
text 65,9.25,"Page",IFONT,cols=7
if copy INTERNAL_COPY
	text 82,3,"Number",IFONT,cols=8
end if
text 73,6.25,{trim(get(72,3,6))},DBFONT,cols=6
text 73,7.75,{trim(get(71,7,8))},DBFONT,cols=8
text 73,9.25,{trim(get(77,5,3))},DBFONT,cols=3
if copy INTERNAL_COPY
	text 93.5,3,{trim(get(72,3,6))},DBFONT,cols=6
end if

# bill to section
cbox LEFTCOL,10,RIGHTCOL,15,MBOXSIZE,ccols=10::ISHADE 41 50::ISHADE
text 2,11,"Bill to:",ICFONT,cols=8
text 2,12,{trim(get(20,10,20))},DBCFONT,cols=8
cmove 12,11,41,14,11,11
cfont 11,11,40,14,DBFONT                    # bill to addr

# ship to section
text 42,11,"Ship to:",ICFONT,cols=8
text 42,12,{trim(get(57,10,15))},DBCFONT,cols=8
cmove 49,11,MAXRCOLS,14,51,11
cfont 51,11,MAXCOLS,14,DBFONT                   # ship to addr

# ribbon section
cerase 17,16,17,18
cerase 26,16,26,18
cerase 32,16,32,18
cerase 48,16,48,18
cerase 57,16,57,18
cerase 62,16,62,18
cbox LEFTCOL,15,RIGHTCOL,19,MBOXSIZE,CROWS=17::ISHADE,  ccols=17 26 32 48 57 62
cfont 2,16,16,16,ICFONT,proper              # ref #
cfont 18,16,25,16,ICFONT,proper             # inv dt
cfont 27,16,31,16,ICFONT,proper             # slsp
cfont 33,16,47,16,ICFONT,proper             # terms
cfont 49,16,56,16,ICFONT,proper             # tax code
cfont 58,16,61,16,ICFONT,proper             # branch

cfont 2,18,16,18,DBCFONT                    # ref #
cfont 18,18,25,18,DBCFONT                   # inv dt
cfont 27,18,31,18,DBCFONT                   # slsp
cfont 33,18,47,18,DBCFONT                   # terms
cfont 49,18,56,18,DBCFONT                   # tax code
cfont 58,18,61,18,DBCFONT                   # branch

# detail
erase "!@desc_pos-1,20,desc_pos-1,60",0,0,1,1
erase "!@68,20,68,60",0,0,1,1
if copy INTERNAL_COPY
	erase "!@93,20,93,60",0,0,1,1
end if
cbox LEFTCOL,19,RIGHTCOL,60,MBOXSIZE,crows=21::ISHADE,ccols=68
cbox {desc_pos-1},19,{desc_pos-1},60
if copy INTERNAL_COPY
	cbox 81,19,100,60,MBOXSIZE,crows=21::DSHADE,ccols=93
end if

cfont {desc_pos-2},20,2,20,IFONT,proper,IJUST       # item code
cfont {desc_pos},20,67,20,IFONT,proper          # desc
cfont 69,20,MAXRCOLS,20,IRFONT,proper           # price
if copy INTERNAL_COPY
	cfont 82,20,92,20,IRFONT,proper         # cost
	cfont 94,20,99,20,IRFONT,proper         # gm
end if

# watermark - large font with light shading
WATERMARK 1,{58-9*(wmlines-1)},{wdoc_title$},cgtimes,120,  shade=WATERMARK_SHADE,center,cols=MAXCOLS,  fit,spacing=1

# footer
cerase 36,61,36,64
cerase 48,61,48,63
cerase 58,61,58,63
cerase 67,61,67,63
cerase 93,61,93,63
cbox LEFTCOL,60,RIGHTCOL,MAXROWS,MBOXSIZE
cbox 36,60,RIGHTCOL,64,1,crows=62::HSHADE,ccols=48 58 67
if copy INTERNAL_COPY
	cbox 81,60,100,66,MBOXSIZE,crows=62::HSHADE 64,ccols=93
end if
cfont 37,61,47,61,IBRFONT,proper                # amt
cfont 49,61,57,61,IBRFONT,proper                # tax
cfont 59,61,66,61,IBRFONT,proper                # frt
cfont 68,61,MAXRCOLS,61,IBRFONT,9,proper            # tot due
if copy INTERNAL_COPY
	cfont 82,61,92,61,IBRFONT,9,proper          # tot cost
	cfont 94,61,99,61,IRFONT,proper         # gm
end if

cfont 37,63,47,63,DBRFONT                   # amt
cfont 49,63,57,63,DBRFONT                   # tax
cfont 59,63,66,63,DBRFONT                   # frt
cfont 68,63,MAXRCOLS,63,DBRFONT,10              # tot due
if copy INTERNAL_COPY
	cfont 82,63,92,63,DBRFONT,9             # tot cost
	cfont 94,63,99,63,DBRFONT               # gm
end if

cfont 2,61,35,64,DFONT
cfont 2,65,MAXRCOLS,65,DFONT

#***************************************************************
#              Less frequently used rule sets                  *
#***************************************************************

[A/P Aging Detail]
dsn_sample "/u0/unform_test/ssi/txt/ap_aging_det.txt"
detect 0,2,"AGED PAYABLES REPORT"
detect 0,0,"PAYMENT   DOCUMENT"

# set up document constants
const MAXCOLS=133                       # max cols to output
const MAXRCOLS=132                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=133                  # right vertical line
const MAXROWS=63                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "A/P Detail Aging"                # view in pdf properties

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,20))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	doc_title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")
}

# default detail line
cfont 1,1,10,MAXROWS,DRFONT                 # vendor code
cfont 12,1,32,MAXROWS,DBFONT                    # name
cfont 34,1,41,MAXROWS,DCFONT                    # pymt dt
cfont 43,1,52,MAXROWS,DRFONT                    # doc
cfont 54,1,56,MAXROWS,DCFONT                    # doc grp
cfont 58,1,65,AXROWS,DCFONT                 # ent dt
cfont 67,1,71,MAXROWS,DCFONT                    # due dt
cfont 74,1,84,MAXROWS,DRFONT                    # current
cfont 86,1,96,MAXROWS,DRFONT                    # 1-30
cfont 98,1,108,MAXROWS,DRFONT                   # 31-60
cfont 110,1,120,MAXROWS,DRFONT              # 61-90
cfont 122,1,132,MAXROWS,DRFONT              # over 90

# header
merge "Mrg Report Header"

# subheader
font "~^[A-Z]@1,3",0,0,50,1,IFONT               # rpt opts

# detail
hline "===",erase
erase "-----DATE@59,4,67,10",9,0,5,1
erase "-----DATE@59,4,67,10",0,0,5,1
erase "-----AGING@95,4,104,10",-21,0,58,1
box "VENDOR NAME@5,4,15,9",-4.5,-1.5,132.5,2,1,DSHADE
font "VENDOR@5,4,10,9",0,0,6,1,IRFONT,proper        # vendor
font "NAME@12,4,15,9",0,0,4,1,IFONT,proper      # name
font "PAYMENT@35,4,41,9",-1,-1,8,2,ICFONT,proper    # last pymt dt
font "DOCUMENT@45,4,52,9",0,0,8,1,IRFONT,proper     # document
font "GRP@54,4,56,9",0,-1,3,2,ICFONT,proper     # doc grp
font "ENTRY@60,4,64,9",-2,-1,14,1,ICFONT,proper     # dt
font "ENTRY@60,4,64,9",-2,0,8,1,ICFONT,proper       # entry
font "DUE@69,4,71,9",-2,0,5,1,ICFONT,proper     # due
font "CURRENT@77,4,83,9",0,0,8,1,IRFONT,proper      # current
font "CURRENT@77,4,83,9",11,0,9,1,IRFONT,proper     # 1-30
font "CURRENT@77,4,83,9",23,0,9,1,IRFONT,proper     # 31-60
font "CURRENT@77,4,83,9",35,0,9,1,IRFONT,proper     # 61-90
font "CURRENT@77,4,83,9",45,0,11,1,IRFONT,proper    # over 90

# vendor tots
erase "VENDOR TOTAL",0,-1,MAXCOLS,1
font "VENDOR TOTAL",-40,-1,12,1,DBFONT          # phone
font "VENDOR TOTAL",-25,-1,25,1,IFONT           # contact
box "VENDOR TOTAL",-1,-.75,86,1.25,1,DSHADE
box "VENDOR TOTAL",-45,.5,45,1
# purchases line
font "PURCH $@1,7",0,0,7,1,IFONT,proper
font "PURCH $@1,7",9,0,10,1,DBRFONT             # ytd amt
font "PURCH $@1,7",20,0,3,1,IFONT,black         # ytd
font "PURCH $@1,7",25,0,10,1,DBRFONT            # prev yr amt
font "PURCH $@1,7",36,0,3,1,IFONT,black         # pyr

font "VENDOR TOTAL",0,0,12,1,IBFONT,proper
bold "VENDOR TOTAL",0,0,85,A
font "VENDOR TOTAL",13,0,11,1,DBRFONT,10            # bal

# report tots
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-1,-.75,86,1.25,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT,proper
bold "REPORT TOTAL",0,0,86,1
font "REPORT TOTAL",13,0,11,1,DBRFONT,10            # bal

# footer
font "DOCUMENTS:",0,0,20,1,IBFONT
font "END OF REPORT",0,0,13,1,IBFONT

[A/P Aging Summary]
dsn_sample "/u0/unform_test/ssi/txt/ap_aging_sum.txt"
detect 0,2,"AGED PAYABLES REPORT"
detect 0,0,"PAYMENT     BALANCE"

# set up document constants
const MAXCOLS=115                       # max cols to output
const MAXRCOLS=114                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=115                  # right vertical line
const MAXROWS=64                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "A/P Summary Aging"               # view in pdf properties

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,20))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	doc_title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")

	# check if extra info printed and set flag to shade
	last_line=0
	for i=4 to MAXROWS
		# undo last flag if summary only
		if last_line>0 and i-last_line=1 and   mid(text$[i],36,1)="/" and  mid(text$[i],39,1)="/" then  text$[last_line](1,1)="";exitto end_loop
		# set flag if vendor line
		if mid(text$[i],36,1)="/" and  mid(text$[i],39,1)="/" then  text$[i](1,1)="*";last_line=i
	next i
end_loop:
}

# default detail line
cfont 1,1,10,MAXROWS,DRFONT                 # vendor
cfont 12,1,32,MAXROWS,DBFONT                    # name
cfont 34,1,41,MAXROWS,DCFONT                    # last pymt dt
cfont 43,1,54,MAXROWS,DBRFONT,10                # bal
cfont 56,1,66,MAXROWS,DRFONT                    # current
cfont 68,1,78,MAXROWS,DRFONT                    # 1-60
cfont 80,1,90,MAXROWS,DRFONT                    # 31-60
cfont 92,1,102,MAXROWS,DRFONT                   # 61-90
cfont 104,1,114,MAXROWS,DRFONT              # over 90

# header
merge "Mrg Report Header"

# subheader
font "~[A-Z]@1,4,2,10",0,0,50,1,IFONT           # rpt opts

# detail
erase "AGING@82,4,87,10",-27,0,60,1
erase "VENDOR@5,4,11,10",-4,1,MAXCOLS,1
box "VENDOR@5,4,11,10",-4.5,-1.5,114.5,2,1,DSHADE
font "VENDOR@5,4",0,0,6,1,IRFONT,proper         # vendor
font "NAME@12,4,15,10",0,0,4,1,IFONT,proper     # name
font "PAYMENT@35,4,42,10",-1,-1,8,2,ICFONT,proper   # lst pymt dt
font "BALANCE@47,4,54,10",0,0,8,1,IRFONT,proper     # bal
font "BALANCE@47,4,54,10",12,0,8,1,IRFONT,proper    # current
font "BALANCE@47,4,54,10",26,0,6,1,IRFONT,proper    # 1-30
font "BALANCE@47,4,54,10",37,0,7,1,IRFONT,proper    # 31-60
font "BALANCE@47,4,54,10",49,0,7,1,IRFONT,proper    # 61-90
font "BALANCE@47,4,54,10",60,0,8,1,IRFONT,proper    # over 90

# aging line
erase "*@1,1,2,MAXROWS",0,0,1,1
shade "*@1,1,2,MAXROWS",0,0,114.5,1,DSHADE

# phone line
const XMASK=[0-9][0-9][0-9]-[0-9][0-9][0-9]
font "~XMASK@8,7,15",0,0,12,1,DBFONT            # phone
font "~XMASK@8,7,15",18,0,40,1,IFONT            # contact

# purchases line
font "PURCH $@1,7",0,0,7,1,IFONT,proper
font "PURCH $@1,7",9,0,10,1,DBRFONT             # ytd amt
font "PURCH $@1,7",20,0,3,1,IFONT,black# ytd
font "PURCH $@1,7",25,0,10,1,DBRFONT            # prev yr amt
font "PURCH $@1,7",36,0,3,1,IFONT,black         # pyr

# footer
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-1,-1,86,2,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT,proper
bold "REPORT TOTAL",0,0,86,1
font "REPORT TOTAL",14,0,11,1,DBRFONT,10            # bal

# footer
font "VENDORS:",0,0,20,1,IBFONT,proper
font "END OF REPORT",0,0,13,1,IBFONT

[A/P Cash Requirements Summary]
dsn_sample "/u0/unform_test/ssi/txt/ap_cashreq_summary.txt"
detect 0,2,"Cash Requirements Report"
detect 0,4-9,"DATES"

# set up document constants
const MAXCOLS=132                       # max cols to output
const MAXRCOLS=131                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=132                  # right vertical line
const MAXROWS=64                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "A/P Cash Requirements"               # view in pdf properties

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,20))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	doc_title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")
}

# header
merge "Mrg Report Header"

# detail - do first to not mangle enhancements done below
cfont 1,4,10,MAXROWS,DRFONT                 # code
cfont 12,4,41,MAXROWS,DBFONT                    # name
cfont 43,4,53,MAXROWS,DBRFONT                   # balance
cfont 56,4,66,MAXROWS,DRFONT                    # 1st date
cfont 69,4,79,MAXROWS,DRFONT                    # 2nd date
cfont 82,4,92,MAXROWS,DRFONT                    # 3rd date
cfont 95,4,105,MAXROWS,DRFONT                   # 4th date
cfont 108,4,118,MAXROWS,DRFONT              # 5th date
cfont 121,4,131,MAXROWS,DRFONT              # 6th date

# subheader
font "~[A-Z]@1,4,1,6",0,0,50,1,IFONT            # rpt opts

# detail heading
const XMASK="VENDOR NAME@1,4,MAXCOLS,8"
font "XMASK",-4,0,10,1,IRFONT,proper            # code
font "XMASK",7,0,30,1,IFONT,proper              # name
font "XMASK",38,0,11,1,IRFONT,proper            # balance
font "XMASK",51,0,11,1,IRFONT,proper            # 1st date
font "XMASK",64,0,11,1,IRFONT,proper            # 2nd date
font "XMASK",77,0,11,1,IRFONT,proper            # 3rd date
font "XMASK",90,0,11,1,IRFONT,proper            # 4th date
font "XMASK",103,0,11,1,IRFONT,proper           # 5th date
font "XMASK",116,0,11,1,IRFONT,proper           # 6th date
erase "XMASK",0,-1,MAXCOLS,1
hline "=="

# footer
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-1,-1,104,2,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT,proper
bold "REPORT TOTAL",13,0,MAXCOLS,1              # totals

# footer
font "VENDORS:",0,0,20,1,IBFONT,proper
font "End of Report",0,0,13,1,IBFONT

[A/R Aged Trial Balance Detail]
dsn_sample "/u0/unform_test/ssi/txt/atb.txt"
detect 0,2,"AGED TRIAL BALANCE"
detect 0,0,"DATE     CURRENT"

# set up document constants
const MAXCOLS=134                       # max cols to output
const MAXRCOLS=133                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=134                  # right vertical line
const MAXROWS=64                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "A/R Detail Aging"                # view in pdf properties

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,20))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	doc_title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")

}

# default aging line
cfont 1,1,10,MAXROWS,DRFONT                 # customer
cfont 12,1,36,MAXROWS,DBFONT                    # name
cfont 38,1,45,MAXROWS,DCFONT                    # lst Pymt dt
cfont 47,1,52,MAXROWS,DRFONT                # doc #
cfont 54,1,57,MAXROWS,DCFONT                # type
cfont 59,1,66,MAXROWS,DCFONT                # entry dt
cfont 68,1,72,MAXROWS,DCFONT                # due dt
cfont 74,1,85,MAXROWS,DRFONT                # current
cfont 87,1,97,MAXROWS,DRFONT                # 1-60
cfont 99,1,109,MAXROWS,DRFONT               # 31-60
cfont 111,1,121,MAXROWS,DRFONT                  # 61-90
cfont 123,1,133,MAXROWS,DRFONT                  # over 90

# header
merge "Mrg Report Header"

# subheader
font "~^[A-Z]@1,4,1,6",0,0,MAXCOLS,1,IFONT      # rpt opts

# detail heading
erase "CUSTOMER NAME@3,5,15,10",-2,1,MAXCOLS,1
box   "CUSTOMER NAME@3,5,15,10",-2.5,-1.5,133.5,2,1,DSHADE
font  "CUSTOMER NAME@3,5,15,10",0,0,8,1,IRFONT,proper   # customer
font  "CUSTOMER NAME@3,5,15,10",9,0,4,1,IFONT,proper    # name
font  "PAYMENT@39,5,45,10",-1,-1,8,2,ICFONT,proper  # lst pymt dt
font  "DOC#@49,5,52,10",-2,0,6,1,IRFONT,proper      # doc #
font  "TYPE@54,5,57,10",0,0,4,1,ICFONT,proper       # type
font  "DATE    DATE@61,5,72,10",-2,-1,8,2,ICFONT,proper# entry dt
font  "DATE    DATE@61,5,72,10",7,-1,5,2,ICFONT,proper  # due   dt
font  "CURRENT@78,5,84,10",-3,0,11,1,IRFONT,proper  # current
font  "CURRENT@78,5,84,10",9,0,11,1,IRFONT,proper   # 1-30
font  "CURRENT@78,5,84,10",21,0,11,1,IRFONT,proper  # 31-60
font  "CURRENT@78,5,84,10",33,0,11,1,IRFONT,proper  # 61-90
font  "CURRENT@78,5,84,10",45,0,11,1,IRFONT,proper  # over 90

# returns pending
font "*Returns Pending Credit*@12,7",0,0,24,1,IFONT

# customer tots
erase "CUSTOMER TOTAL",0,-1,MAXCOLS,1
box "CUSTOMER TOTAL",-1,-.75,88,1.5,1,ISHADE
box "CUSTOMER TOTAL",-46.5,.75,47,1
font "CUSTOMER TOTAL",-40,-1,15,1,DBFONT            # phone
font "CUSTOMER TOTAL",-23,-1,24,1,IFONT         # contact
font "CUSTOMER TOTAL",-39,0,6,1,IFONT           # sales:
font "CUSTOMER TOTAL",-32,0,11,1,DBRFONT            # ytd amt
font "CUSTOMER TOTAL",-20,0,3,1,IFONT           # ytd
font "CUSTOMER TOTAL",-16,0,11,1,DBRFONT            # prev yr amt
font "CUSTOMER TOTAL",-4,0,3,1,IFONT            # pyr

font "CUSTOMER TOTAL",0,0,14,1,IBFONT,proper
bold "CUSTOMER TOTAL",0,0,88,1
font "CUSTOMER TOTAL",15,0,11,1,DBRFONT,10      # bal

# class sub header
font "Class@1,1,5,66",0,0,MAXCOLS,1,IBFONT
# class tots
erase "CLASS TOTAL",0,-1,MAXCOLS,1
box "CLASS TOTAL",-4,-.75,88,1.5,1,HSHADE
font "CLASS TOTAL",0,0,11,1,IBFONT,proper
bold "CLASS TOTAL",0,0,88,1
font "CLASS TOTAL",12,0,11,1,DBRFONT,10            # bal

# report tots
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-3,-.75,88,1.5,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT,proper
bold "REPORT TOTAL",0,0,88,1
font "REPORT TOTAL",13,0,11,1,DBRFONT,10            # bal

# footer
font "Customers:",0,-2,MAXCOLS,1,IBFONT
font "Customers:",0,0,20,1,IBFONT
font "End of Report",0,0,13,1,IBFONT

[A/R Aged Trial Balance Summary]
dsn_sample "/u0/unform_test/ssi/txt/atb_summary.txt"
detect 0,2,"AGED TRIAL BALANCE"
detect 0,0,"BALANCE     CURRENT"

# set up document constants
const MAXCOLS=128                       # max cols to output
const MAXRCOLS=127                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=128                  # right vertical line
const MAXROWS=64                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "A/R Summary Aging"               # view in pdf properties

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,20))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	doc_title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")
}

# detail line
cfont 1,1,10,MAXROWS,DRFONT                 # customer
cfont 12,1,36,MAXROWS,DBFONT                    # name
cfont 38,1,45,MAXROWS,DCFONT                    # lst pymt dt
cfont 47,1,54,MAXROWS,DCFONT                    # lst sale dt
cfont 56,1,68,MAXROWS,DBRFONT                   # bal
cfont 69,1,80,MAXROWS,DRFONT                    # current
cfont 82,1,92,MAXROWS,DRFONT                    # 1-60
cfont 94,1,104,MAXROWS,DRFONT                   # 31-60
cfont 106,1,116,MAXROWS,DRFONT              # 61-90
cfont 118,1,MAXRCOLS,MAXROWS,DRFONT             # over 90

# header
merge "Mrg Report Header"

# subheader
font "~^[A-Y]@1,4",0,0,MAXCOLS,1,IFONT          # rpt opts

# detail heading
erase "CUSTOMER NAME@3,4,15,10",-2,1,MAXCOLS,1
box "CUSTOMER NAME@3,4,15,10",-2.5,-1.5,127.5,2,1,DSHADE
font "CUSTOMER NAME@3,4,15,10",0,0,8,1,IRFONT,proper    # customer
font "CUSTOMER NAME@3,4,15,10",9,0,4,1,IFONT,proper # name
font "PAYMENT@39,4,45,10",-1,-1,8,2,ICFONT,proper   # lst pymt dt
font "SALE@49,4,52,10",-2,-1,8,2,ICFONT,proper      # lst sale dt
font "BALANCE@61,4,67,10",0,0,8,1,IRFONT,proper     # bal
font "BALANCE@61,4,67,10",10,0,10,1,IRFONT,proper   # current
font "BALANCE@61,4,67,10",22,0,10,1,IRFONT,proper   # 1-30
font "BALANCE@61,4,67,10",34,0,10,1,IRFONT,proper   # 31-60
font "BALANCE@61,4,67,10",46,0,10,1,IRFONT,proper   # 61-90
font "BALANCE@61,4,67,10",58,0,9,1,IRFONT,proper    # over 90

# returns pending
font "*Returns Pending Credit*@12,7",0,0,24,1,IFONT

# phone line
const XMASK=[0-9][0-9][0-9]
font "~XMASK@12,7,14",0,0,12,1,DBFONT           # phone #
font "~XMASK@12,7,14",18,0,40,1,IFONT           # contact

# sales line
font "Sales:@12,7",0,0,6,1,IFONT
font "Sales:@12,7",7,0,11,1,DBRFONT             # ytd amt
font "Sales:@12,7",19,0,3,1,IFONT               # ytd
font "Sales:@12,7",23,0,11,1,DBRFONT            # prev yr amt
font "Sales:@12,7",35,0,3,1,IFONT               # pyr

# class sub header
font "Class@1,1,5,66",0,0,MAXCOLS,1,IBFONT
# class tots
erase "CLASS TOTAL",0,-1,MAXCOLS,1
box "CLASS TOTAL",-2,-.75,85,1.5,1,HSHADE
font "CLASS TOTAL",0,0,11,1,IBFONT,proper
bold "CLASS TOTAL",0,0,88,1
font "CLASS TOTAL",12,0,11,1,DBRFONT,10            # bal

# footer
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-1,-1,85,2,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT,proper
bold "REPORT TOTAL",0,0,85,1
font "REPORT TOTAL",14,0,11,1,DBRFONT,10            # bal

# footer
font "Customers:",0,0,20,1,IBFONT
font "End of Report",0,0,13,1,IBFONT

[A/R Aged Trial Balance Transactions]
dsn_sample "/u0/unform_test/ssi/txt/atb_tran.txt"
detect 0,2,"AGED TRIAL BALANCE"
detect 0,0,"AMOUNT      CURRENT"

# set up document constants
const MAXCOLS=130                       # max cols to output
const MAXRCOLS=129                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=130                  # right vertical line
const MAXROWS=61                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "A/R Detail Aging"                # view in pdf properties

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,20))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	doc_title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")

}

# default detail line
cfont 1,1,6,MAXROWS,DRFONT                  # doc #
cfont 8,1,11,MAXROWS,DCFONT                 # type
cfont 13,1,20,MAXROWS,DCFONT                    # entry dt
cfont 22,1,29,MAXROWS,DCFONT                    # due dt
cfont 31,1,41,MAXROWS,DRFONT                    # orig amt
cfont 43,1,50,MAXROWS,DCFONT                    # trs dt
cfont 52,1,55,MAXROWS,DCFONT                    # trs type
cfont 57,1,68,MAXROWS,DRFONT                    # trs amt
cfont 70,1,81,MAXROWS,DRFONT                    # current
cfont 83,1,93,MAXROWS,DRFONT                    # 1-60
cfont 95,1,105,MAXROWS,DRFONT                   # 31-60
cfont 107,1,117,MAXROWS,DRFONT              # 61-90
cfont 119,1,MAXRCOLS,MAXROWS,DRFONT             # over 90

# header
merge "Mrg Report Header"

# subheader
font "~^[A-Z]@1,4,1,6",0,0,MAXCOLS,1,IFONT      # rpt opts

# detail heading
hline "===",erase
erase "DOC# TYPE@3,5,11,10",-2,1,MAXCOLS,1
erase "-------@1,4,70,10",0,0,7,1
box "DOC# TYPE@3,5,11,10",-2.5,-1.5,129.5,2,1,DSHADE
font "DOC#@3,5,6,10",-2,0,6,1,IRFONT    ,proper     # doc #
font "DOC# TYPE@3,5,11,10",5,0,4,1,ICFONT,proper        # type
font "DATE     DATE@15,5,27,10",-2,-1,8,2,ICFONT,proper# entry dt
font "DATE     DATE@15,5,27,10",8,-1,5,2,ICFONT,proper  # due   dt
font "AMOUNT   DATE@36,5,48,10",-5,-1,11,2,IRFONT,proper# orig amt
font "DATE   TYPE@45,5,55,10",-2,-1,25,1,ICFONT,proper  # trs hdr
font "DATE   TYPE@45,5,55,10",-2,0,8,1,ICFONT,proper    # trs dt
font "DATE   TYPE@45,5,55,10",7,0,4,1,ICFONT,proper # trs type
font "DATE   TYPE@45,5,55,10",12,0,12,1,IRFONT,proper   # trs amt
font "CURRENT@74,5,80,10",-3,0,11,1,IRFONT,proper   # current
font "CURRENT@74,5,80,10",10,0,10,1,IRFONT,proper   # 1-30
font "CURRENT@74,5,80,10",22,0,10,1,IRFONT,proper   # 31-60
font "CURRENT@74,5,80,10",34,0,10,1,IRFONT,proper   # 61-90
font "CURRENT@74,5,80,10",46,0,10,1,IRFONT,proper   # over 90

# Customer line
font "~^Customer:",0,0,9,1,DFONT
font "~^Customer:",10,0,10,1,DRFONT
font "~^Customer:",21,0,30,1,DBFONT
font "~^Customer:",53,0,25,1,DFONT
font "~^Customer:",0,1,MAXCOLS,1,DFONT

# customer tots
erase "CUSTOMER TOTAL",0,-1,MAXCOLS,1
box "CUSTOMER TOTAL",-1,-.75,76,1.25,1,ISHADE
box "CUSTOMER TOTAL",-54.5,.5,53.5,1
font "CUSTOMER TOTAL",0,0,14,1,IBFONT,proper
bold "CUSTOMER TOTAL",0,0,76,1

# class sub header
font "Class@1,1,5,66",0,0,MAXCOLS,1,IBFONT
# class tots
erase "CLASS TOTAL",0,-1,MAXCOLS,1
box "CLASS TOTAL",-4,-.75,76,1.5,1,HSHADE
font "CLASS TOTAL",0,0,11,1,IBFONT,proper
bold "CLASS TOTAL",0,0,88,1

# report tots
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-3,-.75,76,1.5,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT,proper
bold "REPORT TOTAL",0,0,76,1

# footer
font "Customers:",0,-2,MAXCOLS,1,IBFONT
font "Customers:",0,0,20,1,IBFONT
font "End of Report",0,0,13,1,IBFONT

[G/L Profit & Loss 820/828]
dsn_sample "/u0/unform_test/ssi/txt/glr828.txt"
detect 0,1,"~(GLR820)|(GLR828)"

# set up document constants
const MAXCOLS=133                       # max cols to output
const MAXRCOLS=132                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=133                  # right vertical line
const MAXROWS=58                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Profit & Loss"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=2
}

# default detail line
cfont 1,1,16,MAXROWS,DRFONT                 # period end
cfont 18,1,25,MAXROWS,DRFONT                    # %
cfont 27,1,41,MAXROWS,DRFONT                    # period end
cfont 43,1,50,MAXROWS,DRFONT                    # %
cfont 52,1,81,MAXROWS,DBFONT                    # desc
cfont 83,1,97,MAXROWS,DRFONT                    # ytd
cfont 99,1,107,MAXROWS,DRFONT                   # %
cfont 109,1,123,MAXROWS,DRFONT              # ytd
cfont 125,1,MAXRCOLS,MAXROWS,DRFONT             # %

merge "Mrg gl report hdr"

# detail heading
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-2.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 1,{lineno-2},16,{lineno-1},IRFONT,proper          # period end
cfont 18,{lineno-2},25,{lineno-1},IRFONT,proper         # %
cfont 27,{lineno-2},41,{lineno-1},IRFONT,proper         # period end
cfont 43,{lineno-2},50,{lineno-1},IRFONT,proper         # %
cfont 52,{lineno-2},81,{lineno-1},IBFONT,proper         # desc
cfont 83,{lineno-2},97,{lineno-1},IRFONT,proper         # ytd
cfont 99,{lineno-2},107,{lineno-1},IRFONT,proper        # %
cfont 109,{lineno-2},123,{lineno-1},IRFONT,proper       # ytd
cfont 125,{lineno-2},MAXRCOLS,{lineno-1},IRFONT,proper  # %

# detail
font "~^[A-Z0-9]@1,6",0,0,MAXCOLS,1,DBFONT      # acnt desc
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^ -----",0,0,MAXCOLS,1
bold "~^ -----",0,1,MAXCOLS,2
box "Total Revenues",-51,-.6,132,1.1,1,DSHADE
box "Total Cost of Sales",-51,-.6,132,1.1,1,DSHADE
box "Gross Profit",-51,-.6,132,1.1,1,ISHADE
box "Total General & Admin",-51,-.6,132,2.1,1,DSHADE
box "Net Profit or Loss",-51,-.6,132,1.1,1,HSHADE

[G/L Profit & Loss 822/824/826/834/836/842]
dsn_sample "/u0/unform_test/ssi/txt/glr822.txt"
detect 0,1,"~(GLR822)|(GLR824)|(GLR826)|(GLR834)|(GLR836)|(GLR842)"

# set up document constants
const MAXCOLS=106                       # max cols to output
const MAXRCOLS=105                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=106                  # right vertical line
const MAXROWS=58                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Profit & Loss"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=2
}

# default detail line
cfont 1,1,30,MAXROWS,DBFONT             # desc
cfont 32,1,46,MAXROWS,DRFONT                # period end
cfont 48,1,55,MAXROWS,DRFONT                # %
cfont 57,1,71,MAXROWS,DRFONT                # period end last yr
cfont 73,1,80,MAXROWS,DRFONT                # %
cfont 82,1,96,MAXROWS,DRFONT                # var amt
cfont 98,1,105,MAXROWS,DRFONT               # var pct

merge "Mrg gl report hdr"

# detail heading
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-2.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 1,{lineno-2},30,{lineno-1},IBFONT,proper      # desc
cfont 32,{lineno-2},46,{lineno-1},IRFONT,proper     # period end
cfont 48,{lineno-2},55,{lineno-1},IRFONT,proper     # %
cfont 57,{lineno-2},71,{lineno-1},IRFONT,proper     # period end last yr
cfont 73,{lineno-2},80,{lineno-1},IRFONT,proper     # %
cfont 82,{lineno-1},96,{lineno-1},IRFONT,proper     # var amt
cfont 98,{lineno-1},105,{lineno-1},IRFONT,proper    # var pct
cfont 82,{lineno-2},105,{lineno-2},ICFONT,proper    # var amt/pct

# detail
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^(Total)|(Gross Profit)|(Net Profit)",0,-1,MAXCOLS,1
bold "~^(Total)|(Gross Profit)|(Net Profit)",0,0,MAXCOLS,2
box "Total Revenues",-.5,-.6,105.5,1.1,1,DSHADE
box "Total Cost of Sales",-.5,-.6,105.5,1.1,1,DSHADE
box "Gross Profit",-.5,-.6,105.5,1.1,1,ISHADE
box "Total General & Admin",-.5,-.6,105.5,2.1,1,DSHADE
box "Net Profit or Loss",-.5,-.6,105.5,1.1,1,HSHADE

[G/L Profit & Loss 830]
dsn_sample "/u0/unform_test/ssi/txt/glr830.txt"
detect 0,1,"GLR830"

# set up document constants
const MAXCOLS=133                       # max cols to output
const MAXRCOLS=132                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=133                  # right vertical line
const MAXROWS=58                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Profit & Loss"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=2
}

# default detail line
cfont 1,1,13,MAXROWS,DRFONT                 # period end
cfont 15,1,27,MAXROWS,DRFONT                    # budget
cfont 29,1,41,MAXROWS,DRFONT                    # var amt
cfont 43,1,50,MAXROWS,DRFONT                    # var %
cfont 52,1,81,MAXROWS,DBFONT                    # desc
cfont 83,1,95,MAXROWS,DRFONT                    # ytd
cfont 97,1,109,MAXROWS,DRFONT                   # budget ytd
cfont 111,1,123,MAXROWS,DRFONT              # var amt
cfont 125,1,MAXRCOLS,MAXROWS,DRFONT             # var %

merge "Mrg gl report hdr"

# detail heading
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-2.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 1,{lineno-2},13,{lineno-1},IRFONT,proper          # period end
cfont 15,{lineno-2},27,{lineno-1},IRFONT,proper         # budget
cfont 29,{lineno-1},41,{lineno-1},IRFONT,proper         # var amt
cfont 43,{lineno-1},50,{lineno-1},IRFONT,proper         # var %
cfont 35,{lineno-2},50,{lineno-2},ICFONT,proper         # var amt/%
cfont 52,{lineno-2},81,{lineno-1},IBFONT,proper         # desc
cfont 83,{lineno-2},95,{lineno-1},IRFONT,proper         # ytd
cfont 97,{lineno-2},109,{lineno-1},IRFONT,proper        # budget ytd
cfont 111,{lineno-1},123,{lineno-1},IRFONT,proper       # var amt
cfont 125,{lineno-1},MAXRCOLS,{lineno-1},IRFONT,proper  # var %
cfont 117,{lineno-2},MAXRCOLS,{lineno-2},ICFONT,proper  # var amt/%

# detail
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^ -----",0,0,MAXCOLS,1
bold "~^ -----",0,1,MAXCOLS,2
box "Total Revenues",-51,-.6,132,1.1,1,DSHADE
box "Total Cost of Sales",-51,-.6,132,1.1,1,DSHADE
box "Gross Profit",-51,-.6,132,1.1,1,ISHADE
box "Total General & Admin",-51,-.6,132,2.1,1,DSHADE
box "Net Profit or Loss",-51,-.6,132,1.1,1,HSHADE

[G/L Profit & Loss 832]
dsn_sample "/u0/unform_test/ssi/txt/glr832.txt"
detect 0,1,"GLR832"

# set up document constants
const MAXCOLS=100                       # max cols to output
const MAXRCOLS=99                       # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=100                  # right vertical line
const MAXROWS=58                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Profit & Loss"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=2
}

# default detail line
cfont 1,1,16,MAXROWS,DRFONT                 # period end
cfont 18,1,33,MAXROWS,DRFONT                    # prev period end
cfont 36,1,65,MAXROWS,DBFONT                    # desc
cfont 67,1,83,MAXROWS,DRFONT                    # ytd
cfont 85,1,99,MAXROWS,DRFONT                    # prev ytd

merge "Mrg gl report hdr"

# detail heading
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-2.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 1,{lineno-2},16,{lineno-1},IRFONT,proper      # period end
cfont 18,{lineno-2},33,{lineno-1},IRFONT,proper     # prev period end
cfont 36,{lineno-2},65,{lineno-1},IBFONT,proper     # desc
cfont 67,{lineno-2},83,{lineno-1},IRFONT,proper     # ytd
cfont 85,{lineno-2},99,{lineno-1},IRFONT,proper     # prev ytd

# detail
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^ -----",0,0,MAXCOLS,1
bold "~^ -----",0,1,MAXCOLS,2
box "Total Revenues",-51,-.6,100,1.1,1,DSHADE
box "Total Cost of Sales",-51,-.6,100,1.1,1,DSHADE
box "Gross Profit",-51,-.6,100,1.1,1,ISHADE
box "Total General & Admin",-51,-.6,100,2.1,1,DSHADE
box "Net Profit or Loss",-51,-.6,100,1.1,1,HSHADE

[G/L Profit & Loss 838]
dsn_sample "/u0/unform_test/ssi/txt/glr838.txt"
detect 0,1,"GLR838"

# set up document constants
const MAXCOLS=87                        # max cols to output
const MAXRCOLS=86                       # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=87                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Profit & Loss"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=2
}

# default detail line
cfont 1,1,16,MAXROWS,DRFONT                 # period end
cfont 18,1,26,MAXROWS,DRFONT                    # %
cfont 29,1,58,MAXROWS,DBFONT                    # desc
cfont 60,1,76,MAXROWS,DRFONT                    # ytd
cfont 78,1,86,MAXROWS,DRFONT                    # %

merge "Mrg gl report hdr"

# detail heading
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-2.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 1,{lineno-2},16,{lineno-1},IRFONT,proper      # period end
cfont 18,{lineno-2},26,{lineno-1},IRFONT,proper     # %
cfont 60,{lineno-2},76,{lineno-1},IRFONT,proper     # ytd
cfont 78,{lineno-2},86,{lineno-1},IRFONT,proper     # %

# detail
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^ -----",0,0,MAXCOLS,1
bold "~^ -----",0,1,MAXCOLS,2
box "Total Revenues",-51,-.6,86,1.1,1,DSHADE
box "Total Cost of Sales",-51,-.6,86,1.1,1,DSHADE
box "Gross Profit",-51,-.6,86,1.1,1,ISHADE
box "Total General & Admin",-51,-.6,86,2.1,1,DSHADE
box "Net Profit or Loss",-51,-.6,86,1.1,1,HSHADE

[G/L Profit & Loss 840/848]
dsn_sample "/u0/unform_test/ssi/txt/glr840.txt"
detect 0,1,"~(GLR840)|(GLR848)"

# set up document constants
const MAXCOLS=132                       # max cols to output
const MAXRCOLS=131                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=132                  # right vertical line
const MAXROWS=59                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Profit & Loss"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=1
}

# default detail line
cfont 2,1,10,MAXROWS,DRFONT                 # 1st period
cfont 12,1,21,MAXROWS,DRFONT                    # 2nd period
cfont 23,1,32,MAXROWS,DRFONT                    # 3rd period
cfont 34,1,43,MAXROWS,DRFONT                    # 4th period
cfont 45,1,54,MAXROWS,DRFONT                    # 5th period
cfont 56,1,65,MAXROWS,DRFONT                    # 6th period
cfont 67,1,76,MAXROWS,DRFONT                    # 7th period
cfont 78,1,87,MAXROWS,DRFONT                    # 8th period
cfont 89,1,98,MAXROWS,DRFONT                    # 9th period
cfont 100,1,109,MAXROWS,DRFONT              # 10th period
cfont 111,1,120,MAXROWS,DRFONT              # 11th period
cfont 122,1,131,MAXROWS,DRFONT              # 12th period

merge "Mrg gl report hdr"

# detail heading
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-1.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 2,{lineno-1},10,{lineno-1},IRFONT,proper      # 1st period
cfont 12,{lineno-1},21,{lineno-1},IRFONT,proper     # 2nd period
cfont 23,{lineno-1},32,{lineno-1},IRFONT,proper     # 3rd period
cfont 34,{lineno-1},43,{lineno-1},IRFONT,proper     # 4th period
cfont 45,{lineno-1},54,{lineno-1},IRFONT,proper     # 5th period
cfont 56,{lineno-1},65,{lineno-1},IRFONT,proper     # 6th period
cfont 67,{lineno-1},76,{lineno-1},IRFONT,proper     # 7th period
cfont 78,{lineno-1},87,{lineno-1},IRFONT,proper     # 8th period
cfont 89,{lineno-1},98,{lineno-1},IRFONT,proper     # 9th period
cfont 100,{lineno-1},109,{lineno-1},IRFONT,proper   # 10th period
cfont 111,{lineno-1},120,{lineno-1},IRFONT,proper   # 11th period
cfont 122,{lineno-1},131,{lineno-1},IRFONT,proper   # 12th period

# detail
font "~^[A-Z0-9]@1,6",0,0,MAXCOLS,1,DBFONT      # acnt desc
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^ -----",0,0,MAXCOLS,1
bold "~^ -----",0,1,MAXCOLS,2
box "~^Total",-1.5,-.8,RIGHTCOL,2.4,1,DSHADE
box "~^Gross Profit",-1.5,-.8,RIGHTCOL,2.4,1,ISHADE
box "~^Net Profit",-1.5,-.8,RIGHTCOL,2.4,1,HSHADE

[G/L Profit & Loss 844]
dsn_sample "/u0/unform_test/ssi/txt/glr844.txt"
detect 0,1,"GLR844"

# set up document constants
const MAXCOLS=133                       # max cols to output
const MAXRCOLS=132                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=133                  # right vertical line
const MAXROWS=58                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Profit & Loss"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=1
}

# default detail line
cfont 1,1,17,MAXROWS,DBFONT                 # desc
cfont 19,1,28,MAXROWS,DRFONT                    # 1st period
cfont 30,1,36,MAXROWS,DRFONT                    # %
cfont 38,1,47,MAXROWS,DRFONT                    # 2nd period
cfont 49,1,56,MAXROWS,DRFONT                    # %
cfont 58,1,67,MAXROWS,DRFONT                    # 3rd period
cfont 69,1,75,MAXROWS,DRFONT                    # %
cfont 77,1,86,MAXROWS,DRFONT                    # 4th period
cfont 88,1,94,MAXROWS,DRFONT                    # %
cfont 96,1,105,MAXROWS,DRFONT                   # 5th period
cfont 107,1,113,MAXROWS,DRFONT              # %
cfont 115,1,124,MAXROWS,DRFONT              # 6th period
cfont 126,1,132,MAXROWS,DRFONT              # %

merge "Mrg gl report hdr"

# detail heading
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-1.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 1,{lineno-1},17,{lineno-1},IBFONT,proper          # desc
cfont 19,{lineno-1},28,{lineno-1},IRFONT,proper         # 1st period
cfont 30,{lineno-1},36,{lineno-1},IRFONT,proper         # %
cfont 38,{lineno-1},47,{lineno-1},IRFONT,proper         # 2nd period
cfont 49,{lineno-1},56,{lineno-1},IRFONT,proper         # %
cfont 58,{lineno-1},67,{lineno-1},IRFONT,proper         # 3rd period
cfont 69,{lineno-1},75,{lineno-1},IRFONT,proper         # %
cfont 77,{lineno-1},86,{lineno-1},IRFONT,proper         # 4th period
cfont 88,{lineno-1},94,{lineno-1},IRFONT,proper         # %
cfont 96,{lineno-1},105,{lineno-1},IRFONT,proper        # 5th period
cfont 107,{lineno-1},113,{lineno-1},IRFONT,proper       # %
cfont 115,{lineno-1},124,{lineno-1},IRFONT,proper       # 6th period
cfont 126,{lineno-1},132,{lineno-1},IRFONT,proper       # %

# detail
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^(Total)|(Gross Profit)|(Net Profit)",0,-1,MAXCOLS,1
bold "~^(Total)|(Gross Profit)|(Net Profit)",0,0,MAXCOLS,2
box "Total Revenues",-.5,-.6,132.5,1.1,1,DSHADE
box "Total Cost of Sal",-.5,-.6,132.5,1.1,1,DSHADE
box "Gross Profit",-.5,-.6,132.5,1.1,1,ISHADE
box "Total General & A",-.5,-.6,132.5,2.1,1,DSHADE
box "Net Profit or Los",-.5,-.6,132.5,1.1,1,HSHADE

[G/L Balance Sheet 850]
dsn_sample "/u0/unform_test/ssi/txt/glr850.txt"
detect 0,1,"GLR850"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const MAXROWS=66
const LEFTCOL=1
const RIGHTCOL=80
cols MAXCOLS
rows MAXROWS

prepage {
	dhdlns=0
}
merge "Mrg gl report prepage"

# default line enhancements
cfont 21,1,50,MAXROWS,DFONT             # desc
cfont 52,1,66,MAXROWS,DRFONT                # amt

merge "Mrg gl report hdr"

# detail
cerase 1,{lineno},MAXCOLS,{lineno}
font "~  ASSETS|  Assets",2,0,6,1,DBCFONT,11
font "~  CURRENT ASSETS|  Current Assets",2,0,15,1,DBCFONT
font "~  FIXED ASSETS|  Fixed Assets",2,0,13,1,DBCFONT
font "~  LIABILITIES|  Liabilities",2,0,20,1,DBCFONT,11
font "~  CURRENT LIABILITIES|  Current Liabilities",2,0,20,1,DBCFONT
font "~  LONG TERM LIABILITIES|  Long Term Liabilities",2,0,22,1,DBCFONT
font "~  EQUITY|  Equity",2,0,6,1,DBCFONT,10

# footer
erase "~Total|TOTAL",0,-1,MAXCOLS,1
bold "~Total|TOTAL",0,0,MAXCOLS,1               # tot lines
box "~Total|TOTAL",-1.5,-.5,48,1.01,1,DSHADE
box "~Total Assets|TOTAL ASSETS",-1.5,-.5,48,1.01,1,ISHADE
box "Total Liabilities & Equity",-1.5,-.5,48,1.01,1,ISHADE
box "TOTAL LIABILITIES & EQUITY",-1.5,-.5,48,1.01,1,ISHADE

[G/L Balance Sheet 852]
dsn_sample "/u0/unform_test/ssi/txt/glr852.txt"
detect 0,1,"GLR852"

# set up document constants
const MAXCOLS=80                        # max cols to output
const MAXRCOLS=79                       # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Balance Sheet"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=1
}

# default line enhancements
cfont 13,1,42,MAXROWS,DFONT                 # desc
cfont 44,1,58,MAXROWS,DRFONT                    # current amt
cfont 60,1,76,MAXROWS,DRFONT                    # prev amt

merge "Mrg gl report hdr"

# detail header
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-1.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 44,{lineno-1},58,{lineno-1},IRFONT
cfont 60,{lineno-1},76,{lineno-1},IRFONT

# detail
font "  ASSETS",2,0,6,1,DBCFONT,11
font "  CURRENT ASSETS:",2,0,15,1,DBCFONT
font "  FIXED ASSETS:",2,0,13,1,DBCFONT
font "  Liabilities",2,0,20,1,DBCFONT,11
font "  Current Liabilities:",2,0,20,1,DBCFONT
font "  Long Term Liabilities:",2,0,22,1,DBCFONT
font "  Equity",2,0,6,1,DBCFONT,10

# footer
erase "Total",0,-1,MAXCOLS,1
bold "Total",0,0,MAXCOLS,1                  # tot lines
box "Total",-1,-.5,65,1.01,1,DSHADE
box "Total Assets",-1,-.5,65,1.01,1,ISHADE
box "Total Liabilities & Equity",-1,-.5,65,1.01,1,ISHADE

[G/L Balance Sheet 854]
dsn_sample "/u0/unform_test/ssi/txt/glr854.txt"
detect 0,1,"GLR854"

# set up document constants
const MAXCOLS=132                       # max cols to output
const MAXRCOLS=131                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=132                  # right vertical line
const MAXROWS=58                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Balance Sheet"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=1
}

# default line enhancements
cfont 13,1,21,MAXROWS,DRFONT                    # 1st period
cfont 23,1,31,MAXROWS,DRFONT                    # 2nd period
cfont 33,1,41,MAXROWS,DRFONT                    # 3rd period
cfont 43,1,51,MAXROWS,DRFONT                    # 4th period
cfont 53,1,61,MAXROWS,DRFONT                    # 5th period
cfont 63,1,71,MAXROWS,DRFONT                    # 6th period
cfont 73,1,81,MAXROWS,DRFONT                    # 7th period
cfont 83,1,91,MAXROWS,DRFONT                    # 8th period
cfont 93,1,101,MAXROWS,DRFONT                   # 9th period
cfont 103,1,111,MAXROWS,DRFONT              # 10th period
cfont 113,1,121,MAXROWS,DRFONT              # 11th period
cfont 123,1,131,MAXROWS,DRFONT              # 12th period

merge "Mrg gl report hdr"

# detail heading
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-1.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 13,{lineno-1},21,{lineno-1},IRFONT,proper     # 1st period
cfont 23,{lineno-1},31,{lineno-1},IRFONT,proper     # 2nd period
cfont 33,{lineno-1},41,{lineno-1},IRFONT,proper     # 3rd period
cfont 43,{lineno-1},51,{lineno-1},IRFONT,proper     # 4th period
cfont 53,{lineno-1},61,{lineno-1},IRFONT,proper     # 5th period
cfont 63,{lineno-1},71,{lineno-1},IRFONT,proper     # 6th period
cfont 73,{lineno-1},81,{lineno-1},IRFONT,proper     # 7th period
cfont 83,{lineno-1},91,{lineno-1},IRFONT,proper     # 8th period
cfont 93,{lineno-1},101,{lineno-1},IRFONT,proper    # 9th period
cfont 103,{lineno-1},111,{lineno-1},IRFONT,proper   # 10th period
cfont 113,{lineno-1},121,{lineno-1},IRFONT,proper   # 11th period
cfont 123,{lineno-1},131,{lineno-1},IRFONT,proper   # 12th period

# detail
font "~^[A-Z0-9]@1,6",0,0,MAXCOLS,1,DBFONT      # acnt desc
font "  ASSETS",2,0,6,1,DBCFONT,11
font "  CURRENT ASSETS:",2,0,15,1,DBCFONT
font "  FIXED ASSETS:",2,0,13,1,DBCFONT
font "  Liabilities",2,0,20,1,DBCFONT,11
font "  Current Liabilities:",2,0,20,1,DBCFONT
font "  Long Term Liabilities:",2,0,22,1,DBCFONT
font "  Equity",2,0,6,1,DBCFONT,10

# footer
erase "~^Total",0,-1,MAXCOLS,1
bold "~^Total",0,0,MAXCOLS,2                    # tot lines
box "~^Total",-1.5,-.8,MAXCOLS,2.4,1,DSHADE
box "~^Total Assets",-1.5,-.8,132,2.4,1,ISHADE
box "~^Total Liabilities & Equity",-1.5,-.8,132,2.4,1,ISHADE

[G/L Balance Sheet 856]
dsn_sample "/u0/unform_test/ssi/txt/glr856.txt"
detect 0,1,"GLR856"

# set up document constants
const MAXCOLS=132                       # max cols to output
const MAXRCOLS=131                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=132                  # right vertical line
const MAXROWS=58                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Balance Sheet"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=1
}

# default line enhancements
cfont 1,1,30,MAXROWS,DFONT                  # desc
cfont 32,1,46,MAXROWS,DRFONT                    # 1nd period
cfont 48,1,63,MAXROWS,DRFONT                    # 2rd period
cfont 65,1,80,MAXROWS,DRFONT                    # 3th period
cfont 82,1,97,MAXROWS,DRFONT                    # 4th period
cfont 99,1,114,MAXROWS,DRFONT                   # 5th period
cfont 116,1,131,MAXROWS,DRFONT              # 6th period

merge "Mrg gl report hdr"

# detail heading
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-1.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 1,{lineno-1},30,{lineno-1},IFONT,proper           # desc
cfont 32,{lineno-1},46,{lineno-1},IRFONT,proper         # 1nd period
cfont 48,{lineno-1},63,{lineno-1},IRFONT,proper         # 2rd period
cfont 65,{lineno-1},80,{lineno-1},IRFONT,proper         # 3th period
cfont 82,{lineno-1},97,{lineno-1},IRFONT,proper         # 4th period
cfont 99,{lineno-1},114,{lineno-1},IRFONT,proper        # 5th period
cfont 116,{lineno-1},131,{lineno-1},IRFONT,proper       # 6th period

# detail
font "  ASSETS",2,0,6,1,DBCFONT,11
font "  CURRENT ASSETS:",2,0,15,1,DBCFONT
font "  FIXED ASSETS:",2,0,13,1,DBCFONT
font "  Liabilities",2,0,20,1,DBCFONT,11
font "  Current Liabilities:",2,0,20,1,DBCFONT
font "  Long Term Liabilities:",2,0,22,1,DBCFONT
font "  Equity",2,0,6,1,DBCFONT,10

# footer
erase "~^Total",0,-1,MAXCOLS,1
bold "~^Total",0,0,MAXCOLS,2                    # tot lines
box "~^Total",-1.5,-.7,MAXCOLS,1.2,1,DSHADE
box "~^Total Assets",-1.5,-.7,132,1.2,1,ISHADE
box "~^Total Liabilities & Equity",-1.5,-.7,132,1.2,1,ISHADE

[G/L Balance Sheet 880]
dsn_sample "/u0/unform_test/ssi/txt/glr880.txt"
detect 0,1,"GLR880"

# set up document constants
const MAXCOLS=80                        # max cols to output
const MAXRCOLS=79                       # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=80                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Balance Sheet"               # view in pdf properties

merge "Mrg gl report prepage"
prepage {
	dhdlns=1
}

# default line enhancements
cfont 1,1,4,MAXROWS,DCFONT                  # line #
cfont 6,1,6,MAXROWS,DCFONT                  # T
cfont 8,1,37,MAXROWS,DFONT                  # desc
cfont 39,1,52,MAXROWS,DFONT                 # g/l #
cfont 54,1,MAXRCOLS,MAXROWS,DFONT               # acnt desc

merge "Mrg gl report hdr"

# detail heading
cerase 1,{lineno},MAXCOLS,{lineno}
cbox LEFTCOL,{lineno-1.5},RIGHTCOL,{lineno-.5},1,DSHADE
cfont 1,{lineno-1},4,{lineno-1},ICFONT,proper       # line #
cfont 6,{lineno-1},6,{lineno-1},ICFONT,proper       # T
cfont 8,{lineno-1},37,{lineno-1},IFONT,proper       # desc
cfont 39,{lineno-1},52,{lineno-1},IFONT,proper      # g/l #
cfont 54,{lineno-1},MAXRCOLS,{lineno-1},IFONT,proper    # acnt desc

# detail
hline "---",erase
font "~^UNUSED",0,0,36,1,DFONT

# footer
font "~^TOTAL UNUSED",0,0,32,1,DFONT            # unused tot title
font "~^TOTAL UNUSED",39,0,3,1,DBFONT           # # unused

[G/L Chart of Accounts]
dsn_sample "/u0/unform_test/ssi/txt/gl_chartaccts.txt"
detect 0,2,"CHART OF ACCOUNTS"

# set up document constants
const MAXCOLS=81                        # max cols to output
const MAXRCOLS=80                       # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=81                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Chart of Accounts"               # view in pdf properties

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,20))
	compname$=trim(get(16,1,x-8-16))
	pageno=num(pageno$(13))

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	doc_title$=trim(get(16,2,x-16))

	# load sub-title
	subtitle$=""
	if pageno=1 then subtitle$=trim(get(1,4,MAXCOLS))

	# erase headers
	if pageno=1 then end_row=4 else end_row=2
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i

	# handle header box
	if pageno=1 then xrow$="3.75" else xrow$="2.75"
	x$="cbox LEFTCOL,.5,RIGHTCOL,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)
}

# default line enhancements
cfont 1,1,14,MAXROWS,DBFONT
cfont 16,1,45,MAXROWS,DFONT
cfont 47,1,68,MAXROWS,DBFONT
cfont 70,1,MAXRCOLS,MAXROWS,DBFONT

# header
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS

text 2,2.25,{user$},HBFONT
text 1,2.25,{doc_title$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{time$},HBRFONT,cols=MAXRCOLS

text 1,3.25,{subtitle$},HCFONT,12,cols=MAXRCOLS

# detail heading
cfont 1,5,8,6,IFONT,proper
cfont 16,5,26,6,IFONT,proper
cfont 47,4,53,6,IFONT,proper
cfont 70,4,78,6,IFONT,proper
hline "=="

# footer
font "ACCOUNTS:",0,0,20,1,IBFONT,proper
font "END OF REPORT",0,0,13,1,IBFONT,proper

[G/L Trial Balance]
dsn_sample "/u0/unform_test/ssi/txt/gl_trialbal.txt"
detect 0,2,"TRIAL BALANCE"
detect 0,0,"BEGINNING        ACTIVITY         ENDING"

# set up document constants
const MAXCOLS=81                        # max cols to output
const MAXRCOLS=80                       # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=81                       # right vertical line
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "G/L Trial Balance"               # view in pdf properties

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,20))
	compname$=trim(get(16,1,x-8-16))

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	doc_title$=trim(get(16,2,x-16))

	# load row 4 variables
	period_date$=trim(get(1,4,MAXCOLS))
}

# default line enhancements
cfont "G/L#   @1,5,7,11",0,2,14,MAXROWS,DBFONT      # g/l #
cfont "G/L#   @1,5,7,11",15,2,35,MAXROWS,DFONT      # desc
font "~\.[0-9][0-9]@1,8",-8,0,12,1,DBRFONT      # amts

# header
cerase 1,1,MAXCOLS,4
cbox LEFTCOL,.5,RIGHTCOL,3.75,3,HSHADE
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 2,2.25,{user$},HBFONT
text 1,2.25,{doc_title$},HBCFONT,12,cols=MAXCOLS
text 1,2.25,{time$},HBRFONT,cols=MAXRCOLS
text 1,3.25,{period_date$},HBCFONT,cols=MAXCOLS

# subheader
font "~G/L# [A-Z0-9]@1,6,7,6",0,0,MAXCOLS,1,IFONT   # opts

# detail heading
erase "G/L#   @1,5,7,11",0,1,MAXCOLS,1
box "G/L#   @1,5,7,11",-.5,-1,80.5,2,1,DSHADE
font "G/L#   @1,5,7,11",0,0,4,1,IFONT,proper        # g/l #
font "G/L#   @1,5,7,11",15,0,11,1,IFONT,proper      # desc
font "G/L#   @1,5,7,11",39,0,10,1,IRFONT,proper     # begin
font "G/L#   @1,5,7,11",56,0,9,1,IRFONT,proper      # act
font "G/L#   @1,5,7,11",73,0,7,1,IRFONT,proper      # ending

# footer
erase "TOTAL@61,5,66,MAXROWS",0,-1,MAXCOLS,1
box "TOTAL@61,5,65,MAXROWS",7,-1,12,1
box "TOTAL@62,5,66,MAXROWS",6,-1,12,1
font "TOTAL@61,5,65,MAXROWS",-50,0,56,1,IBCFONT,10,proper
font "TOTAL@62,5,66,MAXROWS",-50,0,55,1,IBCFONT,10,proper
font "TOTAL@61,5,65,MAXROWS",7,0,12,1,DBRFONT,10
font "TOTAL@62,5,66,MAXROWS",6,0,12,1,DBRFONT,10
font "TOTAL@61,5,65,MAXROWS",19,0,1,1,DBRFONT,10
font "TOTAL@62,5,66,MAXROWS",18,0,1,1,DBRFONT,10

# footer
font "ACCOUNTS:",0,0,20,1,IBFONT,proper
font "END OF REPORT",0,0,13,1,IBFONT,proper

[P/O Fill Report]
dsn_sample "/u0/unform_test/ssi/txt/po_fill.txt"
detect 0,2,"PURCHASE ORDER FILL REPORT"

# set up document constants
const MAXCOLS=133                       # max cols to output
const MAXRCOLS=132                  # MAXCOLS-1
const LEFTCOL=.5                        # left vertical line
const RIGHTCOL=133                  # right vertical line
const MAXROWS=62                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

landscape
dpi 600

# see global constant above
GSON                                # graphical shading

title "P/O Fill Report"                 # view in pdf properties

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,20))
	compname$=trim(get(16,1,x-8-16))
	pageno=num(pageno$(13))

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	doc_title$=trim(get(16,2,x-16))
}

# default enhancement line
cfont 1,1,20,MAXROWS,DBRFONT                    # item #
cfont 22,1,52,MAXROWS,DFONT                 # desc
cfont 54,1,61,MAXROWS,DBRFONT                   # rcvd
cfont 63,1,64,MAXROWS,DBCFONT                   # um
cfont 66,1,71,MAXROWS,DBRFONT                   # order #
cfont 73,1,75,MAXROWS,DBFONT                    # ln #
cfont 77,1,83,MAXROWS,DBCFONT                   # bin loc
cfont 85,1,92,MAXROWS,DBCFONT                   # req date
cfont 94,1,118,MAXROWS,DFONT                    # customer
cfont 120,1,129,MAXROWS,DBRFONT             # B/O + comm
cfont 131,1,132,MAXROWS,DBCFONT             # um

# header
merge "Mrg Report Header"

# subheader
cfont "~^[A-Z]@1,4,1,5",0,0,MAXRCOLS,1,IFONT

# detail heading
cfont 1,4,20,7,IRFONT,7,proper              # item #
cfont 22,4,52,7,IFONT,7,proper              # desc
cfont 54,4,61,7,IRFONT,7,proper             # rcvd
cfont 63,4,64,7,ICFONT,7,proper             # um
cfont 66,4,71,7,IRFONT,7,proper             # order #
cfont 73,4,75,7,IFONT,7,proper              # ln #
cfont 81,4,83,7,IFONT,7,proper              # bin loc
cfont 85,4,92,7,ICFONT,7,proper             # req date
cfont 94,4,118,7,IFONT,7,proper             # customer
cfont 119,4,129,7,IRFONT,7,black,proper         # B/O + comm
cfont 131,4,132,7,ICFONT,7,proper               # um
hline "=="

# PO# line
font "PO#:@1,7,MAXCOLS,MAXROWS",0,0,4,1,DFONT       # po title
font "PO#:@1,7,MAXCOLS,MAXROWS",5,0,7,1,DBFONT      # po #
font "Vendor:@1,7,MAXCOLS,MAXROWS",0,0,7,1,DRFONT   # vndr title
font "Vendor:@1,7,MAXCOLS,MAXROWS",8,0,42,1,DBFONT  # vndr
font "Whse:@1,7,MAXCOLS<MAXROWS",0,0,5,1,DFONT      # whse title
font "Whse:@1,7,MAXCOLS,MAXROWS",6,0,10,1,DBFONT    # whse

# alt loc line
font "Alt Loc: ",0,0,8,1,DFONT
font "Alt Loc: ",9,0,50,1,DBFONT

# footer
font "ITEMS:",0,-2,MAXCOLS,1,IBFONT
font "ITEMS:",0,0,20,1,IBFONT,proper
font "End of Report",0,0,13,1,IBFONT

[Generic]
dsn_sample "/u0/unform_test/ssi/txt/gl_chartaccts.txt"
# This rule set will set columns & rows and
# enhance the hdg for all other reports
# requires UnForm 4.1.05 or higher
detect 0,1,"~(PAGE)|(Page)"

# set up document constants
const MAXCOLS=150                       # max cols to output
const MAXROWS=66                        # max rows to output

cols MAXCOLS                        # max output columns
rows MAXROWS                        # max output rows

const MAX_COPIES=1
pcopies MAX_COPIES

portrait
dpi 600

# see global constant above
GSON                                # graphical shading

title "Generic Report"                  # view in pdf properties

prepage {
	maxlen=80                       # min columns is 80
	for i=1 to MAXROWS
		if len(cvs(text$[i],2))>maxlen then  maxlen=len(cvs(text$[i],2))
	next i
	cols$=str(maxlen+1)
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	if x=0 then x=pos("Page"=text$[1])
	pageno$=trim(get(x-7,1,20))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,200,"")
	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	if x=0 then x=pos("Time"=text$[2])
	if x>0 then time$=trim(get(x,2,15))
	doc_title$=trim(get(16,2,x-16))
	x$=set(1,2,200,"")

	# Now draw box around header
	exec("cbox 1,.5,"+cols$+",2.75,MBOXSIZE,HSHADE")
	# now place line 1 headers that need justification
	x$="text 1,1.25,"+$22$+compname$+$22$+",HBCFONT,14,cols="+str(maxlen)
	exec(x$)
	x$="text 1,1.25,"+$22$+pageno$+$22$+",HBRFONT,cols="+str(maxlen)
	exec(x$)
	# now place line 2 headers that need justification
	x$="text 1,2.25,"+$22$+doc_title$+$22$+",HBCFONT,12,cols="+str(maxlen)
	exec(x$)
	x$="text 1,2.25,"+$22$+time$+$22$+",HBRFONT,cols="+str(maxlen)
	exec(x$)
}

text 2,1.25,{rptdate$},HBFONT
text 2,2.25,{user$},HBFONT
font "~(End of Report)|(END OF REPORT)",0,0,13,1,IBFONT

#***************************************************************
#              Inactive or testing rule sets                   *
#***************************************************************