# Copyright 2010 by Synergetic Data Systems Inc.  All rights reserved.
# Permission granted to users of OSAS to use this file with a
# trial or licensed UnForm 8.0 installation.
##################################################################
# osas7-8.rul rule file for standard OSAS7.0 Accounting Software #
# Based upon OSAS 7.5 demo data                                  #
# Requires, at least, UnForm version 8.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.                        #
#########################################################
#
# 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 ######################################
#
# Make changes to all constants as needed.
#
# Completed & Checked Forms:
# ap - aged detail, aged summary
# ap - checks:    laser, blank, preprinted
# ar - aged detail, aged summary
# ar - statement: laser, plain paper, 8.5 x 11, std
# dd - Dir Dep:   laser, blank, preprinted
# generic reports (row 1 contains either PAGE or Page)
# gl - balance sheet: budget, prev yr
# gl - income statement: budget, prev yr
# gl - trial balance: actual, budget, prev yr
# po - order:     laser, plain, 8.5 x 11, std
# pr - checks:    laser, blank, preprinted
# so - invoice:   laser, plain paper, 8.5 x 11, std
# so - pick list: laser, 8.5 x 11, plain paper, std
# so - pack list: laser, 8.5 x 11, plain paper
#
# Modification history
#
# Last modified 08/27/2010 -- MJE
#
# 01/19/2009 - BCJ
#		added recd/bkord handling to P/O laser
# 02/25/2009 - BCJ
#		added 3 direct deposit rule sets
# 07/28/2010 - MJE
#		completed and published UnForm 8.0 additions
#		see the 8.0 README rule-set
# 08/27/2010 - MJE
#     Added entity ID field to archive document properties
# Global constants #######################################
# 8.0 archiving and deliver-related contants
merge "8.0 zMrg Configurator"
# 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
global COMP_NAME="Company Name: Edit rule file"
global COMP_ADDR1="Address 1"
global COMP_ADDR2="Address 2"
global COMP_ADDR3="Address 3"
global COMP_PHONES="###-###-####  Fax: ###-###-####"
global COMP_EMAIL="E-Mail: xxxx@xxxxxxxxxxxxxxx.com"
global COMP_WEBSITE="Website: www.xxxxxxxxxxxxxxx.com"
# A/P check constants
global AP_BANK_NAME="One Major Bank"
global AP_BANK_ADDR1="1 Major Blvd"
global AP_BANK_ADDR2="Major City CA 90123"
global AP_ROUTING="12-345/6789"
global AP_MICR_ACCOUNTNO=":123456789:9999-1234<34>"
global AP_MICR="micr"							# remove # to turn on
global AP_NO_STUBS=2								# 1=vendor stub only
														# 2=vendor stub and payor stub
# P/R check constants
global PR_BANK_NAME="One Major Bank"
global PR_BANK_ADDR1="1 Major Blvd"
global PR_BANK_ADDR2="Major City CA 90123"
global PR_ROUTING="12-345/6789"
global PR_MICR_ACCOUNTNO=":123456789:9999-1234<34>"
global PR_MICR="micr"        				    	# remove # to turn on
global 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,
global SIGNATURE_IMAGE="#image"
global SIGNATURE=""              		           	# insert signature file name
# Logos
global LOGO_IMAGE="image"
global COMP_LOGO="sdsilogo.pcl"          		    	# change to your logo file name
# watermarks
global WATERMARK_SHADE=10            	 	   	# adjust to desired darkness
global WATERMARK="text"
# change #gs on to  gs on to turn on  graphical shading
# change  gs on to #gs on to turn off graphical shading
global GSON="gs on"
# date mask for detects - 10/17/2001
global DATEMASK="[0-1][0-9]/[0-3][0-9]/[0-9][0-9]"   	   # US dt
#global DATEMASK="[0-3][0-9]/[0-1][0-9]/[0-9][0-9]"  	   # Can dt
# main heading constants
global HFONT=  univers,11,fit
global HLFONT= HFONT,left
global HCFONT= HFONT,center
global HRFONT= HFONT,right
global HSHADE= 30
# bold
global HBFONT= HFONT,bold
global HBLFONT=HBFONT,left
global HBCFONT=HBFONT,center
global HBRFONT=HBFONT,right
# internal heading font constants (ribbons, detail headers)
global IFONT=  univers,10,italic,fit
global ILFONT= IFONT,left
global ICFONT= IFONT,center
global IRFONT= IFONT,right
global ISHADE= 20
# bold
global IBFONT= IFONT,bold
global IBLFONT=IBFONT,left
global IBCFONT=IBFONT,center
global IBRFONT=IBFONT,right
# detail data font constants
global DFONT=  cgtimes,9
global DLFONT= DFONT,left
global DCFONT= DFONT,center
global DRFONT= DFONT,right
global DSHADE= 10
# bold
global DBFONT= DFONT,bold
global DBLFONT=DBFONT,left
global DBCFONT=DBFONT,center
global DBRFONT=DBFONT,right
# default major section box size
global MBOXSIZE=5
[AP_AgedDetail]
dsn_sample "/u0/unform_test/_oem/osas/txt7/ap_aging_det.txt"
detect 0,2,"Accounts Payable Detail Aged Trial Balance"
# set up document constants
local MAXCOLS=133                      			    # max cols to output
local MAXRCOLS=132                  			    # MAXCOLS-1
local LEFTCOL=1                     			    # left vertical line
local RIGHTCOL=MAXCOLS                			    # right vertical line
local MAXROWS=60                      			    # max rows to output
cols MAXCOLS                     				    # max output columns
rows MAXROWS                      				    # max output rows
local MAX_COPIES=1
pcopies MAX_COPIES
landscape
dpi 600
# see global constant above
##GSON                                			   # graphical shading
title "Vendor Aged Detail"              			   # view in pdf properties
prejob {
	brow=6     									   # used by rpt hdr
}
prepage {
	merge "zMrg load rpt header"
}
cmove LEFTCOL,1,MAXCOLS,MAXROWS,2,1
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,10,EROW,DFONT                			# inv #
cfont 12,BROW,14,EROW,DCFONT                			# st
cfont 16,BROW,25,EROW,DCFONT              			# date
cfont 27,BROW,42,EROW,DBRFONT                 		  	# amount
cfont 44,BROW,57,EROW,DRFONT                		   	# current
cfont 59,BROW,72,EROW,DRFONT                 		   	# 31-60
cfont 75,BROW,87,EROW,DRFONT                		   	# 61-90
cfont 90,BROW,102,EROW,DRFONT                 		  	# 91-120
cfont 105,BROW,117,EROW,DRFONT            		   	# over 120
cfont 120,BROW,MAXRCOLS,EROW,DRFONT          		   	# future
# header
merge "zMrg Report Header 2"
# detail
cmove LEFTCOL,7,MAXCOLS,7,LEFTCOL,8
cbox LEFTCOL,7.25,RIGHTCOL,8.5,MBOXSIZE,10
local BROW=8
local EROW=8
cfont 2,BROW,10,EROW,IFONT               			   # inv #
cfont 12,BROW,14,EROW,ICFONT             		          # st
cfont 16,BROW,25,EROW,ICFONT              	          # date
cfont 30,BROW,42,EROW,IRFONT                		   # amount
cfont 45,BROW,57,EROW,IRFONT                		   # current
cfont 60,BROW,72,EROW,IRFONT                 		   # 31-60
cfont 75,BROW,87,EROW,IRFONT                  		   # 61-90
cfont 90,BROW,102,EROW,IRFONT                		   # 91-120
cfont 105,BROW,117,EROW,IRFONT           			   # over 120
cfont 120,BROW,MAXRCOLS,EROW,IRFONT         		   # future
# vendor heading
font "~[A-Za-z0-9]@2,9,2,MAXROWS",0,0,37,1,DBFONT
font "~[A-Za-z0-9]@2,9,2,MAXROWS",39,0,14,1,DBFONT
font "~[A-Za-z0-9]@2,9,2,MAXROWS",60,0,67,1,DFONT
# vendor total line
erase "~VENDOR .* TOTAL@2,9,21,MAXROWS",0,-1,MAXCOLS,1
box "~VENDOR .* TOTAL@2,9,21,MAXROWS",28,-1,102,1,5
font "~VENDOR .* TOTAL@2,9,21,MAXROWS",0,0,20,1,DBFONT
# invoice total
font " TOTAL @11,9,17,MAXROWS",0,0,7,1,DFONT
# Grand totals line
erase "GRAND TOTAL",0,-1,MAXCOLS,1
box "GRAND TOTAL",-2,-1,{MAXCOLS-1},2,1,10
font "GRAND TOTAL",-1,0,20,1,IBLFONT
font "End of Report",0,0,14,1,DFONT
# ----------------------------------------------------------------------
	
	# 8.0 Archiving BEGIN
	const ARCRULE="ap aging"
	prepage {
	noarchive=1
	earc$="EARC_APAGING",doing_recat=0
	earca_formtype$="detail"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	# 8.0 Archiving END
	
# ----------------------------------------------------------------------
# Page X of Y feature
	# change XOFYS_COPIES to "0" to turn off
	local XOFYS_COPIES="ALL"			# or copy #'s to display
	local XOFYS_FONT 	="univers,10,bold,left"	# use global or ???
	local XOFYS_DCOL	=10
	local XOFYS_DROW	=MAXROWS+.5		# row to display title
	merge "zMrgSinglePageXofY"
# --- 8.0 ARCHIVING ----------------------------------------------------
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
# --- 8.0 DELIVER ------------------------------------------------------
# --- PAGE X of Y FEATURE -----------------------------------------------
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
[AP_AgedSummary]
dsn_sample "/u0/unform_test/_oem/osas/txt7/ap_aging_sum.txt"
detect 0,2,"Accounts Payable Summary Aged Trial Balance"
# set up document constants
local MAXCOLS=133                      			   # max cols to output
local MAXRCOLS=132                 			   # MAXCOLS-1
local LEFTCOL=1            					          # left vertical line
local RIGHTCOL=MAXCOLS          			          # right vertical line
local MAXROWS=60                   			   # max rows to output
cols MAXCOLS                    				   # max output columns
rows MAXROWS                    				   # max output rows
local MAX_COPIES=1
pcopies MAX_COPIES
landscape
dpi 600
# see global constant above
##GSON                              			          # graphical shading
title "Vendor Aged Summary"           			   # view in pdf properties
prejob {
	brow=6    										   # used by rpt hdr
}
prepage {
	merge "zMrg load rpt header"
}
cmove LEFTCOL,1,MAXCOLS,MAXROWS,2,1
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,7,EROW,DFONT               		          # vendor
cfont 9,BROW,28,EROW,DCFONT             		          # name
cfont 30,BROW,42,EROW,DBRFONT                		   # amount
cfont 45,BROW,57,EROW,DRFONT                		   # current
cfont 60,BROW,72,EROW,DRFONT                 		   # 31-60
cfont 75,BROW,87,EROW,DRFONT                		   # 61-90
cfont 90,BROW,102,EROW,DRFONT                		   # 91-120
cfont 105,BROW,117,EROW,DRFONT            		   # over 120
cfont 120,BROW,MAXRCOLS,EROW,DRFONT          		   # future
# header
merge "zMrg Report Header 2"
# detail
cmove LEFTCOL,7,MAXCOLS,7,LEFTCOL,8
cbox LEFTCOL,7.25,RIGHTCOL,8.5,MBOXSIZE,10
local BROW=8
local EROW=8
cfont 2,BROW,8,EROW,IFONT                 		   # vendor
cfont 10,BROW,28,EROW,ICFONT               		   # name
cfont 30,BROW,42,EROW,IRFONT                   		   # amount
cfont 45,BROW,57,EROW,IRFONT                  		   # current
cfont 60,BROW,72,EROW,IRFONT                    	   # 31-60
cfont 75,BROW,87,EROW,IRFONT                  		   # 61-90
cfont 90,BROW,102,EROW,IRFONT                  		   # 91-120
cfont 105,BROW,117,EROW,IRFONT             		   # over 120
cfont 120,BROW,MAXRCOLS,EROW,IRFONT          		   # future
# vendor heading
font "~[A-Za-z0-9]@2,9,2,MAXROWS",0,0,37,1,DBFONT
font "~[A-Za-z0-9]@2,9,2,MAXROWS",39,0,14,1,DBFONT
font "~[A-Za-z0-9]@2,9,2,MAXROWS",60,0,67,1,DFONT
# vendor total line
font "~VENDOR .* TOTAL@3,9,21,MAXROWS",0,0,20,1,DFONT
# Grand totals line
erase "GRAND TOTAL",0,-1,MAXCOLS,1
box "GRAND TOTAL",-2,-1,MAXRCOLS,2,1,10
font "GRAND TOTAL",-1,0,20,1,IBLFONT
font "End of Report",0,0,14,1,DFONT
# ----------------------------------------------------------------------
	
	# 8.0 Archiving BEGIN
	const ARCRULE="ap aging"
	prepage {
	noarchive=1
	earc$="EARC_APAGING",doing_recat=0
	earca_formtype$="summary"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	# 8.0 Archiving END
	
# ----------------------------------------------------------------------
# Page X of Y feature
	# change XOFYS_COPIES to "0" to turn off
	local XOFYS_COPIES="ALL"			# or copy #'s to display
	local XOFYS_FONT 	="univers,10,bold,left"	# use global or ???
	local XOFYS_DCOL	=10
	local XOFYS_DROW	=MAXROWS+.5		# row to display title
	merge "zMrgSinglePageXofY"
# --- 8.0 ARCHIVING ----------------------------------------------------
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
# --- 8.0 DELIVER ------------------------------------------------------
# --- PAGE X of Y FEATURE -----------------------------------------------
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
[AP_CheckLaser]
# Assumes company name heading printed on stub
dsn_sample "/u0/unform_test/_oem/osas/txt7/ap_chk_laser.txt"
detect 43,8,"~[0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
detect 51,8,"~DATEMASK.."
detect 0,21,"Vendor No."
# set up document constants
local MAXCOLS=82
local MAXRCOLS=81
local MAXROWS=62
local LEFTCOL=1                     				# left vertical line
local RIGHTCOL=MAXCOLS                       			# right vertical line
cols MAXCOLS
rows MAXROWS
local MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
##GSON                                				# graphical shading
title "Vendor Check - laser"              			# view in pdf properties
# make space on left
cmove 1,1,MAXCOLS,MAXROWS,2,1
# Check
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
cbox LEFTCOL,1,RIGHTCOL,17.75,MBOXSIZE
text 15,2.25,"COMP_NAME",HBFONT,14
text 15,3.35,"COMP_ADDR1",HFONT,12
text 15,4.35,"COMP_ADDR2",HFONT,12
text 15,5.35,"COMP_ADDR3",HFONT,12
text 49,2.25,"AP_BANK_NAME",DBFONT
text 49,3.05,"AP_BANK_ADDR1",DFONT
text 49,3.85,"AP_BANK_ADDR2",DFONT
text 70,3.35,"AP_ROUTING",DBFONT                		# rtg #
cmove 44,8,MAXCOLS,8,44,7
cbox 43,5.5,RIGHTCOL,7.5,1,crows=6.5::100,ccols=51 62
text 44,6,"Check #",ICFONT,10,cols=7,shade=0
cfont 44,7,50,7,DBCFONT,11
text 52,6,"Date",ICFONT,10,cols=10,shade=0
cfont 52,7,61,7,DBCFONT,11
text 63,6,"Amount",IRFONT,10,cols=18,shade=0
cfont 63,7,81,7,DBRFONT,11
text 2,10,"Pay",IFONT,14
text 7,10,{trim(cut(5,9,80,""))},DBFONT,italic,11,fit
text 2,13,"Pay",IFONT
text 2,14,"to the",IFONT
text 2,15,"Order",IFONT
text 2,16,"of",IFONT
cmove 7,11,47,14,7,13
cfont 8,13,51,16,DBFONT,11
SIGNATURE_IMAGE 50,15,0,0,"SIGNATURE"
box 50,16.25,30,1,3
text 50,14.5,"Check Void After 180 Days",ICFONT,cols=30
text 50,17,"Authorized Signature",ICFONT,cols=30
AP_MICR 15,18.5,"AP_MICR_ACCOUNTNO",{trim(get(43,7,7))}
# Top stub - vendor's
cerase 1,20,MAXCOLS,20
cbox LEFTCOL,20.25,RIGHTCOL,20.25
text 2,21,"COMP_NAME",HBFONT
cbox 25,20.5,76,23,1,crows=21.35::DSHADE,ccols=36 68
cfont 26,21,35,21,ICFONT
cfont 37,21,67,21,ICFONT
cfont 69,21,75,21,ICFONT
cfont 26,22,35,22,DBCFONT
cfont 37,22,67,22,DBCFONT
cfont 69,22,75,22,DBCFONT
cbox LEFTCOL,23,RIGHTCOL,36.5,MBOXSIZE,crows=24.5::DSHADE,  ccols=13 25 37 51 66
cfont 2,24,12,24,ICFONT
cfont 14,24,24,24,ICFONT
cfont 26,24,36,24,ICFONT
cfont 38,24,50,24,IRFONT
cfont 52,24,65,24,IRFONT
cfont 67,24,MAXRCOLS,24,IRFONT
cfont 2,25,12,36,DBCFONT
cfont 14,25,24,36,DBCFONT
cfont 26,25,36,36,DBCFONT
cfont 38,25,50,36,DBRFONT
cfont 52,25,65,36,DBRFONT
cfont 67,25,MAXRCOLS,36,DBRFONT
cbox LEFTCOL,36.5,RIGHTCOL,39,MBOXSIZE,crows=37.5::100,  ccols=13 37 51 66
cfont 2,37,12,37,ICFONT,shade=0
cfont 14,37,36,37,ICFONT,shade=0
cfont 38,37,50,37,IRFONT,shade=0
cfont 52,37,65,37,IRFONT,shade=0
cfont 67,37,MAXRCOLS,37,IRFONT,shade=0
cfont 2,38,12,38,DBCFONT
cfont 14,38,36,38,DBCFONT
cfont 38,38,50,38,DBRFONT
cfont 52,38,65,38,DBRFONT
cfont 67,38,MAXRCOLS,38,DBRFONT
text 1,40,"Vendor's Copy",DBRFONT,cols=MAXRCOLS
# bottom stub - Payor's
cerase 1,41,MAXCOLS,41
cbox LEFTCOL,41,MAXCOLS,41
text 2,42,"COMP_NAME",HBFONT
cbox 25,41.5,76,44,1,crows=42.5::DSHADE,ccols=36 68
cfont 26,42,35,42,ICFONT
cfont 37,42,67,42,ICFONT
cfont 69,42,75,42,ICFONT
cfont 26,43,35,43,DBCFONT
cfont 37,43,67,43,DBCFONT
cfont 69,43,75,43,DBCFONT
cbox LEFTCOL,44,MAXCOLS,57.5,MBOXSIZE,crows=45.5::DSHADE,ccols=13 25 37 51 66
cfont 2,45,12,45,ICFONT
cfont 14,45,24,45,ICFONT
cfont 26,45,36,45,ICFONT
cfont 38,45,50,45,IRFONT
cfont 52,45,65,45,IRFONT
cfont 67,45,MAXRCOLS,45,IRFONT
cfont 2,46,12,57,DBCFONT
cfont 14,46,24,57,DBCFONT
cfont 26,46,36,57,DBCFONT
cfont 38,46,50,57,DBRFONT
cfont 52,46,65,57,DBRFONT
cfont 67,46,MAXRCOLS,57,DBRFONT
cbox LEFTCOL,57.5,MAXCOLS,60,MBOXSIZE,crows=58.5::100,ccols=13 37 51 66
cfont 2,58,12,58,ICFONT,shade=0
cfont 14,58,36,58,ICFONT,shade=0
cfont 38,58,50,58,IRFONT,shade=0
cfont 52,58,65,58,IRFONT,shade=0
cfont 67,58,MAXRCOLS,58,IRFONT,shade=0
cfont 2,59,12,59,DBCFONT
cfont 14,59,36,59,DBCFONT
cfont 38,59,50,59,DBRFONT
cfont 52,59,65,59,DBRFONT
cfont 67,59,MAXRCOLS,59,DBRFONT
text 1,61,"Payor's Copy",DBRFONT,cols=MAXRCOLS
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="apcheck"
	prepage {
	noarchive=1
	earc$="EARC_APCHECK",doing_recat=0
	earca_formtype$="laser"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# Page X of Y feature
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=43			# adjust as needed
	local XOFYM_ROW  	=8				# adjust as needed
	local XOFYM_NCOLS	=7			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
[AP_CheckBlank]
# Assumes company name heading printed on stub
dsn_sample "/u0/unform_test/_oem/osas/txt7/ap_check_blank.txt"
detect 54,8,"~[0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
detect 43,8,"~DATEMASK.."
detect 0,22,"Vendor No."
# set up document constants
local MAXCOLS=82
local MAXRCOLS=81
local MAXROWS=62
local LEFTCOL=1                     			      # left vertical line
local RIGHTCOL=MAXCOLS                      		      # right vertical line
cols MAXCOLS
rows MAXROWS
page 42
local MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
##GSON                                			     # graphical shading
title "Vendor Check - Blank"           			     # view in pdf properties
prepage {
	brow=22,erow=40
	begin_copy_loop:
		text$[brow+21]=text$[brow]
		brow=brow+1
		if brow=erow then :
			goto end_copy_loop
		else
			goto begin_copy_loop
		endif
	end_copy_loop:
}
# make space on left
cmove 1,1,MAXCOLS,MAXROWS,2,1
# Check
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
cbox LEFTCOL,1,RIGHTCOL,17.75,MBOXSIZE
text 15,2.25,"COMP_NAME",HBFONT,14
text 15,3.35,"COMP_ADDR1",HFONT,12
text 15,4.35,"COMP_ADDR2",HFONT,12
text 15,5.35,"COMP_ADDR3",HFONT,12
text 49,2.25,"AP_BANK_NAME",DBFONT
text 49,3.05,"AP_BANK_ADDR1",DFONT
text 49,3.85,"AP_BANK_ADDR2",DFONT
text 70,3.35,"AP_ROUTING",DBFONT              		      # rtg #
cmove 44,8,MAXCOLS,8,44,7
cbox 43,5.5,RIGHTCOL,7.5,1,crows=6.5::100,ccols=54 62
text 44,6,"Date",ICFONT,10,cols=10,shade=0
cfont 44,7,53,7,DBCFONT,11
text 55,6,"Check #",ICFONT,10,cols=7,shade=0
cfont 55,7,61,7,DBCFONT,11
text 63,6,"Amount",IRFONT,10,cols=18,shade=0
cfont 63,7,81,7,DBRFONT,11
text 2,10,"Pay",IFONT,14
text 7,10,{trim(cut(2,9,80,""))},DBFONT,italic,11,fit
text 2,13,"Pay",IFONT
text 2,14,"to the",IFONT
text 2,15,"Order",IFONT
text 2,16,"of",IFONT
cmove 7,12,47,15,7,13
cfont 8,13,51,16,DBFONT,11
SIGNATURE_IMAGE 50,15,0,0,"SIGNATURE"
box 50,16.25,30,1,3
text 50,14.5,"Check Void After 180 Days",ICFONT,cols=30
text 50,17,"Authorized Signature",ICFONT,cols=30
AP_MICR 15,18.5,"AP_MICR_ACCOUNTNO",{trim(get(43,7,7))}
#move stubs up one line
cmove LEFTCOL,22,MAXCOLS,MAXROWS,LEFTCOL,21
# Top stub - vendor's
cerase 1,20,MAXCOLS,20
cbox LEFTCOL,20.25,RIGHTCOL,20.25
text 2,21,"COMP_NAME",HBFONT
cbox 25,20.5,76,23,1,crows=21.35::DSHADE,ccols=36 68
cfont 26,21,35,21,ICFONT
cfont 37,21,67,21,ICFONT
cfont 69,21,75,21,ICFONT
cfont 26,22,35,22,DBCFONT
cfont 37,22,67,22,DBCFONT
cfont 69,22,75,22,DBCFONT
cbox LEFTCOL,23,RIGHTCOL,36.5,MBOXSIZE,crows=24.5::DSHADE,  ccols=13 25 37 51 66
cfont 2,24,12,24,ICFONT
cfont 14,24,24,24,ICFONT
cfont 26,24,36,24,ICFONT
cfont 38,24,50,24,IRFONT
cfont 52,24,65,24,IRFONT
cfont 67,24,MAXRCOLS,24,IRFONT
cfont 2,25,12,36,DBCFONT
cfont 14,25,24,36,DBCFONT
cfont 26,25,36,36,DBCFONT
cfont 38,25,50,36,DBRFONT
cfont 52,25,65,36,DBRFONT
cfont 67,25,MAXRCOLS,36,DBRFONT
cbox LEFTCOL,36.5,RIGHTCOL,39,MBOXSIZE,crows=37.5::100,  ccols=13 37 51 66
cfont 2,37,12,37,ICFONT,shade=0
cfont 14,37,36,37,ICFONT,shade=0
cfont 38,37,50,37,IRFONT,shade=0
cfont 52,37,65,37,IRFONT,shade=0
cfont 67,37,MAXRCOLS,37,IRFONT,shade=0
cfont 2,38,12,38,DBCFONT
cfont 14,38,36,38,DBCFONT
cfont 38,38,50,38,DBRFONT
cfont 52,38,65,38,DBRFONT
cfont 67,38,MAXRCOLS,38,DBRFONT
text 1,40,"Vendor's Copy",DBRFONT,cols=MAXRCOLS
# bottom stub - Payor's
cerase 1,41,MAXCOLS,41
cbox LEFTCOL,41,MAXCOLS,41
text 2,42,"COMP_NAME",HBFONT
cbox 25,41.5,76,44,1,crows=42.5::DSHADE,ccols=36 68
cfont 26,42,35,42,ICFONT
cfont 37,42,67,42,ICFONT
cfont 69,42,75,42,ICFONT
cfont 26,43,35,43,DBCFONT
cfont 37,43,67,43,DBCFONT
cfont 69,43,75,43,DBCFONT
cbox LEFTCOL,44,MAXCOLS,57.5,MBOXSIZE,crows=45.5::DSHADE,ccols=13 25 37 51 66
cfont 2,45,12,45,ICFONT
cfont 14,45,24,45,ICFONT
cfont 26,45,36,45,ICFONT
cfont 38,45,50,45,IRFONT
cfont 52,45,65,45,IRFONT
cfont 67,45,MAXRCOLS,45,IRFONT
cfont 2,46,12,57,DBCFONT
cfont 14,46,24,57,DBCFONT
cfont 26,46,36,57,DBCFONT
cfont 38,46,50,57,DBRFONT
cfont 52,46,65,57,DBRFONT
cfont 67,46,MAXRCOLS,57,DBRFONT
cbox LEFTCOL,57.5,MAXCOLS,60,MBOXSIZE,crows=58.5::100,ccols=13 37 51 66
cfont 2,58,12,58,ICFONT,shade=0
cfont 14,58,36,58,ICFONT,shade=0
cfont 38,58,50,58,IRFONT,shade=0
cfont 52,58,65,58,IRFONT,shade=0
cfont 67,58,MAXRCOLS,58,IRFONT,shade=0
cfont 2,59,12,59,DBCFONT
cfont 14,59,36,59,DBCFONT
cfont 38,59,50,59,DBRFONT
cfont 52,59,65,59,DBRFONT
cfont 67,59,MAXRCOLS,59,DBRFONT
text 1,61,"Payor's Copy",DBRFONT,cols=MAXRCOLS
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="apcheck"
	prepage {
	noarchive=1
	earc$="EARC_APCHECK",doing_recat=0
	earca_formtype$="blank"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=54			# adjust as needed
	local XOFYM_ROW  	=8				# adjust as needed
	local XOFYM_NCOLS	=7			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
[AP_CheckPreprinted]
# Assumes company name heading printed on stub
dsn_sample "/u0/unform_test/_oem/osas/txt7/ap_chk_pre.txt"
detect 54,8,"~[0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
detect 43,8,"~DATEMASK.."
detect 33,23,"~ [A-Za-z0-9]+ "
# set up document constants
local MAXCOLS=82
local MAXRCOLS=81
local MAXROWS=62
local LEFTCOL=1                     			    # left vertical line
local RIGHTCOL=MAXCOLS                      		    # right vertical line
cols MAXCOLS
rows MAXROWS
page 42
local MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
##GSON                                			    # graphical shading
title "Vendor Check - Preprinted"            		    # view in pdf properties
prepage {
	brow=22,erow=40
	begin_copy_loop:
		text$[brow+21]=text$[brow]
		brow=brow+1
		if brow=erow then :
			goto end_copy_loop
		else
			goto begin_copy_loop
		endif
	end_copy_loop:
}
# make space on left
cmove 1,1,MAXCOLS,MAXROWS,2,1
# Check
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
cbox LEFTCOL,1,RIGHTCOL,17.75,MBOXSIZE
text 15,2.25,"COMP_NAME",HBFONT,14
text 15,3.35,"COMP_ADDR1",HFONT,12
text 15,4.35,"COMP_ADDR2",HFONT,12
text 15,5.35,"COMP_ADDR3",HFONT,12
text 49,2.25,"AP_BANK_NAME",DBFONT
text 49,3.05,"AP_BANK_ADDR1",DFONT
text 49,3.85,"AP_BANK_ADDR2",DFONT
text 70,3.35,"AP_ROUTING",DBFONT               			# rtg #
cmove 44,8,MAXCOLS,8,44,7
cbox 43,5.5,RIGHTCOL,7.5,1,crows=6.5::100,ccols=54 62
text 44,6,"Date",ICFONT,10,cols=10,shade=0
cfont 44,7,53,7,DBCFONT,11
text 55,6,"Check #",ICFONT,10,cols=7,shade=0
cfont 55,7,61,7,DBCFONT,11
text 63,6,"Amount",IRFONT,10,cols=18,shade=0
cfont 63,7,81,7,DBRFONT,11
text 2,10,"Pay",IFONT,14
text 7,10,{trim(cut(2,9,80,""))},DBFONT,italic,11,fit
text 2,13,"Pay",IFONT
text 2,14,"to the",IFONT
text 2,15,"Order",IFONT
text 2,16,"of",IFONT
cmove 7,12,47,15,7,13
cfont 8,13,51,16,DBFONT,11
SIGNATURE_IMAGE 50,15,0,0,"SIGNATURE"
box 50,16.25,30,1,3
text 50,14.5,"Check Void After 180 Days",ICFONT,cols=30
text 50,17,"Authorized Signature",ICFONT,cols=30
AP_MICR 15,18.5,"AP_MICR_ACCOUNTNO",{trim(get(43,7,7))}
#move stubs up one line
cmove LEFTCOL,22,MAXCOLS,MAXROWS,1,21
# Top stub - vendor's
cerase 1,20,MAXCOLS,20
cbox LEFTCOL,20.25,RIGHTCOL,20.25
text 2,21,"COMP_NAME",HBFONT
cbox 34,20.5,76,23,1,crows=21.35::DSHADE,ccols=44
text 34,21,"Vendor No.",ICFONT,cols=10
text 45,21,"Vendor Name",ICFONT,cols=32
cfont 34,22,43,22,DBCFONT
cfont 45,22,76,22,DBCFONT
cbox LEFTCOL,23,RIGHTCOL,36.5,MBOXSIZE,crows=24.5::DSHADE,  ccols=12 24 40 58
text 2,24,"Trans. Date",ICFONT,cols=10
text 13,24,"Reference",ICFONT,cols=11
text 25,24,"Gross Amount",IRFONT,cols=15
text 41,24,"Deduction",IRFONT,cols=17
text 59,24,"Net Amount",IRFONT,cols=23
cfont 2,25,11,36,DBCFONT
cfont 13,25,23,36,DBCFONT
cfont 25,25,39,36,DBRFONT
cfont 41,25,57,36,DBRFONT
cfont 59,25,MAXRCOLS,36,DBRFONT
cbox LEFTCOL,36.5,RIGHTCOL,39,MBOXSIZE,crows=37.5::100,  ccols=12 24 40 58
text 2,37,"Check Date",ICFONT,cols=10,shade=0
text 13,37,"Check No.",ICFONT,cols=11,shade=0
text 25,37,"Total Gross",IRFONT,cols=15,shade=0
text 41,37,"Total Ded.",IRFONT,cols=17,shade=0
text 59,37,"Check Amount",IRFONT,cols=23,shade=0
cfont 2,38,11,38,DBCFONT
cfont 13,38,23,38,DBCFONT
cfont 25,38,39,38,DBRFONT
cfont 41,38,57,38,DBRFONT
cfont 59,38,MAXRCOLS,38,DBRFONT
text 1,40,"Vendor's Copy",DBRFONT,cols=MAXRCOLS
# bottom stub - Payor's
cerase 1,41,MAXCOLS,41
cbox LEFTCOL,41,MAXCOLS,41
text 2,42,"COMP_NAME",HBFONT
cbox 34,41.5,76,44,1,crows=42.5::DSHADE,ccols=44
text 34,42,"Vendor No.",ICFONT,cols=10
text 45,42,"Vendor Name",ICFONT,cols=32
cfont 34,43,43,43,DBCFONT
cfont 45,43,76,43,DBCFONT
cbox LEFTCOL,44,RIGHTCOL,57.5,MBOXSIZE,crows=45.5::DSHADE,ccols=12 24 40 58
text 2,45,"Trans. Date",ICFONT,cols=10
text 13,45,"Reference",ICFONT,cols=11
text 25,45,"Gross Amount",IRFONT,cols=15
text 41,45,"Deduction",IRFONT,cols=17
text 59,45,"Net Amount",IRFONT,cols=23
cfont 2,46,11,57,DBCFONT
cfont 13,46,23,57,DBCFONT
cfont 25,46,39,57,DBRFONT
cfont 41,46,57,57,DBRFONT
cfont 59,46,MAXRCOLS,57,DBRFONT
cbox LEFTCOL,57.5,RIGHTCOL,60,MBOXSIZE,crows=58.5::100,ccols=12 24 40 58
text 2,58,"Check Date",ICFONT,cols=10,shade=0
text 13,58,"Check No.",ICFONT,cols=11,shade=0
text 25,58,"Total Gross",IRFONT,cols=15,shade=0
text 41,58,"Total Ded.",IRFONT,cols=17,shade=0
text 59,58,"Check Amount",IRFONT,cols=23,shade=0
cfont 2,59,11,59,DBCFONT
cfont 13,59,23,59,DBCFONT
cfont 25,59,39,59,DBRFONT
cfont 41,59,57,59,DBRFONT
cfont 59,59,MAXRCOLS,59,DBRFONT
text 1,61,"Payor's Copy",DBRFONT,cols=MAXRCOLS
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="apcheck"
	prepage {
	noarchive=1
	earc$="EARC_APCHECK",doing_recat=0
	earca_formtype$="preprinted"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=54			# adjust as needed
	local XOFYM_ROW  	=8				# adjust as needed
	local XOFYM_NCOLS	=7			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
[AR_AgedDetail]
dsn_sample "/u0/unform_test/_oem/osas/txt7/ar_aging_det.txt"
detect 0,2,"Detail Accounts Receivable Aged Trial Balance"
# set up document constants
local MAXCOLS=133                      			     # max cols to output
local MAXRCOLS=132               	   			     # MAXCOLS-1
local LEFTCOL=1                   				     # left vertical line
local RIGHTCOL=MAXCOLS                			     # right vertical line
local MAXROWS=60                     			     # max rows to output
cols MAXCOLS                      				     # max output columns
rows MAXROWS                     				     # max output rows
local MAX_COPIES=1
pcopies MAX_COPIES
landscape
dpi 600
# see global constant above
##GSON                               			     # graphical shading
title "Customer Aged Detail"             			     # view in pdf properties
prejob {
	brow=3      									     # used by rpt hdr
}
prepage {
	merge "zMrg load rpt header"
}
cmove LEFTCOL,1,MAXCOLS,MAXROWS,2,1
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,9,EROW,DFONT                 		     # inv #
cfont 11,BROW,11,EROW,DCFONT                  		     # st
cfont 13,BROW,13,EROW,DCFONT                		     # tp
cfont 15,BROW,23,EROW,DCFONT                		     # date
cfont 25,BROW,36,EROW,DBRFONT               		     # amount
cfont 39,BROW,52,EROW,DRFONT                 		     # current
cfont 55,BROW,68,EROW,DRFONT                		     # 31-60
cfont 71,BROW,84,EROW,DRFONT              		     # 61-90
cfont 87,BROW,100,EROW,DRFONT                		     # 91-120
cfont 103,BROW,116,EROW,DRFONT           			     # over 120
cfont 119,BROW,MAXRCOLS,EROW,DRFONT         		     # unapplied
# header
merge "zMrg Report Header"
# detail
cerase 1,7,MAXCOLS,7
cbox LEFTCOL,4.25,RIGHTCOL,6.5,MBOXSIZE,10
local BROW=5
local EROW=6
cfont 2,BROW,9,EROW,IFONT                 		     # inv #
cfont 11,BROW,11,EROW,ICFONT                		     # st
cfont 13,BROW,13,EROW,ICFONT                		     # tp
cfont 15,BROW,23,EROW,ICFONT                 		     # date
cfont 25,BROW,36,EROW,IRFONT                 		     # amount
cfont 39,BROW,52,EROW,IRFONT                 		     # current
cfont 55,BROW,68,EROW,IRFONT                 		     # 31-60
cfont 71,BROW,84,EROW,IRFONT                   		     # 61-90
cfont 87,BROW,100,EROW,IRFONT                		     # 91-120
cfont 103,BROW,116,EROW,IRFONT           			     # over 120
cfont 119,BROW,MAXRCOLS,EROW,IRFONT         		     # unapplied
# customer heading
font "~(...)...-@40,8,48,MAXROWS",-40,0,37,1,DBFONT
font "~(...)...-@40,8,48,MAXROWS",-2,0,48,1,DBCFONT
font "~(...)...-@40,8,48,MAXROWS",50,0,40,1,DRFONT
# customer total line
erase "~Cust .* TOTAL@1,9,20,MAXROWS",0,-1,MAXCOLS,1
box "~Cust .* TOTAL@1,9,20,MAXROWS",21,-1,110,1,5
font "~Cust .* TOTAL@1,9,20,MAXROWS",0,0,20,1,DBFONT
# Grand totals line
erase "GRAND TOTAL",0,-1,MAXCOLS,1
box "GRAND TOTAL",-1,-1,MAXRCOLS,2,1,10
font "GRAND TOTAL",0,0,20,1,IBFONT
#font "GRAND TOTAL",15,0,MAXCOLS,1,DBFONT
font "End of Report",0,0,14,1,DFONT
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="ar aging"
	prepage {
	noarchive=1
	earc$="EARC_ARAGING",doing_recat=0
	earca_formtype$="detail"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYS_COPIES to "0" to turn off
	local XOFYS_COPIES="ALL"			# or copy #'s to display
	local XOFYS_FONT 	="univers,10,bold,left"	# use global or ???
	local XOFYS_DCOL	=10
	local XOFYS_DROW	=MAXROWS+.5		# row to display title
	merge "zMrgSinglePageXofY"
[AR_AgedSummary]
detect 0,2,"Summary Accounts Receivable Aged Trial Balance"
# set up document constants
local MAXCOLS=133                    			    # max cols to output
local MAXRCOLS=132                 			    # MAXCOLS-1
local LEFTCOL=1                   				    # left vertical line
local RIGHTCOL=MAXCOLS               			    # right vertical line
local MAXROWS=60                        			    # max rows to output
cols MAXCOLS                       			    # max output columns
rows MAXROWS                    				    # max output rows
local MAX_COPIES=1
pcopies MAX_COPIES
landscape
dpi 600
# see global constant above
##GSON                              				    # graphical shading
title "Customer Aged Summary"           			    # view in pdf properties
prejob {
	brow=3    										    # used by rpt hdr
}
prepage {
	merge "zMrg load rpt header"
}
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,2,1
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,9,EROW,DFONT               			    # cust id
cfont 11,BROW,23,EROW,DBCFONT          		           # phone
cfont 25,BROW,28,EROW,DCFONT           		           # sls rep
cfont 30,BROW,33,EROW,DCFONT             		           # dist
cfont 35,BROW,48,EROW,DBRFONT                		    # amount
cfont 51,BROW,62,EROW,DRFONT                		    # current
cfont 65,BROW,76,EROW,DRFONT                    	    # 31-60
cfont 79,BROW,90,EROW,DRFONT                    	    # 61-90
cfont 93,BROW,104,EROW,DRFONT                  		    # 91-120
cfont 107,BROW,118,EROW,DRFONT              		    # over 120
cfont 121,BROW,MAXRCOLS,EROW,DRFONT            		    # unapplied
# header
merge "zMrg Report Header"
# detail
cerase 1,7,MAXCOLS,7
cbox LEFTCOL,4.25,RIGHTCOL,6.5,1,10
local BROW=5
local EROW=6
cfont 2,BROW,9,EROW,IFONT                     		    # cust id
cfont 11,BROW,23,EROW,ICFONT                 		    # phone
cfont 25,BROW,28,EROW,ICFONT               		    # sls rep
cfont 30,BROW,33,EROW,ICFONT                		    # dist
cfont 35,BROW,48,EROW,IRFONT                 		    # amount
cfont 51,BROW,62,EROW,IRFONT                 		    # current
cfont 65,BROW,76,EROW,IRFONT               		    # 31-60
cfont 79,BROW,90,EROW,IRFONT                 		    # 61-90
cfont 93,BROW,104,EROW,IRFONT               		    # 91-120
cfont 107,BROW,118,EROW,IRFONT              		    # over 120
cfont 121,BROW,MAXRCOLS,EROW,IRFONT         		    # unapplied
# customer heading
font "~[(][0-9 ][0-9 ][0-9 ][)][0-9 ][0-9 ][0-9 ]-@11,8,19,MAXROWS",-9,1,37,2,DBFONT
# Grand totals line
erase "GRAND TOTAL",0,-1,MAXCOLS,1
box "GRAND TOTAL",-1,-1,MAXRCOLS,2,1,10
font "GRAND TOTAL",0,0,20,1,IBFONT
#font "GRAND TOTAL",15,0,MAXCOLS,1,DBFONT
font "End of Report",0,0,14,1,DFONT
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="ar aging"
	prepage {
	noarchive=1
	earc$="EARC_ARAGING",doing_recat=0
	earca_formtype$="summary"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYS_COPIES to "0" to turn off
	local XOFYS_COPIES="ALL"			# or copy #'s to display
	local XOFYS_FONT 	="univers,10,bold,left"	# use global or ???
	local XOFYS_DCOL	=10
	local XOFYS_DROW	=MAXROWS+.5		# row to display title
	merge "zMrgSinglePageXofY"
[AR_StatementLaser]
dsn_sample "/u0/unform_test/_oem/osas/txt7/ar_laser_stmt-scanattch.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/ar_laser_stmt.txt"
detect 61,6,"~ DATEMASK"
detect 77,13,"~\.[0-9][0-9]"
# set up document constants
local MAXCOLS=81                      				 # max cols to output
local MAXRCOLS=80                      				 # MAXCOLS-1
local LEFTCOL=1                        				 # left vertical line
local RIGHTCOL=MAXCOLS              			        # right vertical line
local MAXROWS=66                  				        # max rows to output
cols MAXCOLS                         				 # max output columns
rows MAXROWS                         				 # max output rows
local CUSTOMER_COPY=1
local REMITTANCE_COPY=2
local FILE_COPY=3
local MAX_COPIES=3
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
##GSON                                    				 # graphical shading
title "Statement - laser"                   			 # view in pdf properties
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,2,1
# default detail line
local BROW=21
local EROW=52
cfont 2,BROW,11,EROW,DBCFONT                   			 # date
cfont 13,BROW,24,EROW,DFONT                 			 # inv #
cfont 26,BROW,28,EROW,DCFONT                    		 # type
cfont 30,BROW,41,EROW,DFONT                 		        # check #
cfont 43,BROW,54,EROW,DBRFONT            			        # charges
cfont 56,BROW,67,EROW,DBRFONT            			        # credits
cfont 69,BROW,MAXRCOLS,EROW,DBRFONT       		        # balance
# header section
cerase 1,1,MAXCOLS,7
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE
merge "zMrg Form Header"
# Invoice block
cbox 60,4,RIGHTCOL,9,1,crows=5.5 7.25,ccols=70::ISHADE
text 61,5,"Date",IFONT
text 61,6.75,"Account",IFONT
text 61,8.5,"Page",IFONT
# mje 052810 chg cut to get and add erase instead re arc subjob
text 71,5,{trim(get(62,6,10))},DBFONT,10
text 71,6.75,{trim(get(62,7,10))},DBFONT,10
text 71,8.5,{trim(get(62,5,10))},DBFONT,10
erase 62,5,10,3
# address & balance info
cfont 1,10,49,18,DBFONT
text 51,13,"Amount Due",IBFONT,10
cfont 70,13,MAXRCOLS,13,DBRFONT,10
text 51,15,"Terms",IBFONT,10
cfont 66,15,MAXRCOLS,15,DBRFONT,10
# detail section
cbox LEFTCOL,19,RIGHTCOL,53,MBOXSIZE,crows=20.5::DSHADE,  ccols=12 25 29 42 55 68
text 2,20,"Invoice Date",ICFONT,cols=10
text 13,20,"Invoice No",IFONT
text 26,20,"Type",ICFONT,cols=3
text 30,20,"Check No",IFONT
text 43,20,"Charges",IRFONT,cols=12
text 56,20,"Credits",IRFONT,cols=12
text 68,20,"Balance",IRFONT,cols=13
# handle special PO # line
font "PO Number ",-2,0,10,1,ICFONT
font "PO Number ",9,0,50,1,ILFONT
# Messages
cbox LEFTCOL,53,RIGHTCOL,58,MBOXSIZE
cfont 2,54,MAXCOLS,57,IFONT
# watermark - large font with light shading
WATERMARK 1,52.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# footer
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
cbox LEFTCOL,58,RIGHTCOL,61,MBOXSIZE,crows=59.5 61::HSHADE,  ccols=14 27 40 53 66
text 1,60.5,"Current",IRFONT,cols=13
text 15,60.5,"31-60 Days",IRFONT,cols=12
text 28,60.5,"61-90 Days",IRFONT,cols=12
text 41,60.5,"Over 90 Days",IRFONT,cols=12
text 54,60.5,"Finance Charge",IRFONT,cols=12
text 67,60.5,"Amount Due",IBRFONT,cols=13
cfont 1,59,13,60,DBRFONT
cfont 15,59,26,60,DBRFONT
cfont 28,59,39,60,DBRFONT
cfont 41,59,52,60,DBRFONT,black
cfont 54,59,65,60,DBRFONT,black
cfont 67,59,MAXRCOLS,60,DBRFONT,10
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	# 8.0 Archiving BEGIN
	const ARCRULE="statement"
	prepage {
	noarchive=1
	earc$="EARC_STATEMENT",doing_recat=0
	earca_formtype$="laser"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	# PDF hyperlink
	merge "8.0 zMrg PDFLinks v2"
	prepage {
		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]  ",11,21,22,53,2,0,"","","DFONT","EARC_STMLINKLIB","EARC_STMLINKDOCTY"))
	}
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=66			# adjust as needed
	local XOFYM_ROW  	=7				# adjust as needed
	local XOFYM_NCOLS	=6			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_STATEMENT"
	if lower(edel$)="y":
		eDocid$=get(66,7,6,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Statement"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(66,7,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
# --- ATTACH SCANNED IMAGES ---------------------------------------------
prepage {
do_attch$="STM_ATTCH_SCAN"
if lower(do_attch$)="y" then:
	if not(uf.arcjob) then:
		begrow=20,endrow=54
		tktcount=0,tktno$=""
		amask$=" [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]     [A-Z][A-Z] "
		for row=begrow to endrow
			pp=msk(text$[row],amask$,err=*next)
			if not(pp) continue
			tktno$+=trim(mid(text$[row],pp+1,8))+","
			tktcount+=1
		next row
		continued=(xofym_pageno<>xofym_maxpgs)
		# above, other erp was pos("Continued On Next Page"=text$[50])
		# dotypes$ has valid 1st char prefixes to filter sub-id's, if applicable
		dotypes$="Scan"
		tktlib$="Osas80_Sales"
		tktdocty$="Invoice"
		if tktcount then:
			for ii=1 to tktcount
				tktdocid$=parse(tktno$,ii,",")
					have_arc1=docidexists(tktlib$,tktdocty$,tktdocid$)
					if have_arc1 then:
						subidlist$=getsubids(tktlib$,tktdocty$,tktdocid$)
						subid_count=count(subidlist$,";")
						for x=1 to subid_count
							tktsubid$=parse(subidlist$,x,";")
							if tktsubid$<>"" then:
								if dotypes$="" or pos(left(tktsubid$,4)=dotypes$)=1 then:
									filename$=""
									getarc(tktlib$,tktdocty$,tktdocid$,tktsubid$,filename$,tkterrmsg$)
									imglist$+=filename$+";"
								endif
							endif
						next x
					endif
			next ii
			if not(continued) then images$=imglist$,imglist$=""
		end if
	endif
endif
}
if copy 1
	images {images$},across 2, down 2
end if
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	doc_title$="STATEMENT"
	merge "zMrg get watermark text"
	logocols=12,logorows=6
	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]="File Copy"
}
prepage {
	xcol=0,xrow=0
	merge "zMrg get company info"
}
[AR_Statement8.5x11]
dsn_sample "/u0/unform_test/_oem/osas/txt7-demo/ar_85x11_stmt-scanattch.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/ar_85x11_stmt-cm.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/ar_85x11_stmt.txt"
detect 49,7,"~ DATEMASK"
detect 77,13,"~\.[0-9][0-9]"
# set up document constants
local MAXCOLS=80                       		    		# max cols to output
local MAXRCOLS=79                      		    		# MAXCOLS-1
local LEFTCOL=1                       		    		# left vertical line
local RIGHTCOL=MAXCOLS                 	     	    		# right vertical line
local MAXROWS=66                       		    		# max rows to output
cols MAXCOLS                      			    		# max output columns
rows MAXROWS                        		    		# max output rows
local CUSTOMER_COPY=1
local REMITTANCE_COPY=2
local FILE_COPY=3
local MAX_COPIES=3
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
##GSON                                		   		# graphical shading
title "Statement - 8.5x11"               		  		# view in pdf properties
# default detail line
local BROW=21
local EROW=52
cfont 2,BROW,11,EROW,DBCFONT                    		# date
cfont 13,BROW,22,EROW,DFONT                     		# inv #
cfont 24,BROW,26,EROW,DCFONT                    		# type
cfont 28,BROW,39,EROW,DFONT                     		# check #
cfont 41,BROW,50,EROW,DBRFONT                   		# charges
cfont 52,BROW,63,EROW,DBRFONT                   		# credits
cfont 65,BROW,MAXRCOLS,EROW,DBRFONT             		# balance
# header section
cerase 1,1,MAXCOLS,7
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# Invoice block
cbox 60,4,RIGHTCOL,9,1,crows=5.5 7.25,ccols=70::ISHADE
text 61,5,"Date",IFONT
text 61,6.75,"Account",IFONT
text 61,8.5,"Page",IFONT
text 71,5,{date$},DBFONT,10
text 71,6.75,{cust_code$},DBFONT,10
text 71,8.5,{pageno$},DBFONT,10
	
# address & balance info
cbox LEFTCOL,9,RIGHTCOL,19,MBOXSIZE
cfont 1,10,49,18,DBFONT
text 51,13,"Amount Due",IBFONT,10
cfont 70,13,MAXRCOLS,13,DBRFONT,10
text 51,15,"Terms",IBFONT,10
cfont 66,15,MAXRCOLS,15,DBRFONT,10
# zip bar
#barcode 2,16,{shipzip$},900,12.0,2
# detail section
cbox LEFTCOL,19,RIGHTCOL,51,MBOXSIZE,crows=20.5::DSHADE,  ccols=12 23 27 40 51 64
text 2,20,"Invoice Date",ICFONT,cols=10
text 13,20,"Invoice No",IFONT
text 24,20,"Type",ICFONT,cols=3
text 28,20,"Check No",IRFONT, cols=12
text 39,20,"Charges",IRFONT,cols=12
text 52,20,"Credits",IRFONT,cols=12
text 67,20,"Balance",IRFONT,cols=13
# Messages
cbox LEFTCOL,51,MAXCOLS,58,MBOXSIZE
cfont 2,52,MAXCOLS,57,IFONT
# watermark - large font with light shading
WATERMARK 1,50.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# footer
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
cbox LEFTCOL,58,RIGHTCOL,61,MBOXSIZE,crows=59.5::HSHADE 61,  ccols=14 27 40 53 66
text 1,59,"Current",IRFONT,cols=13
text 15,59,"31-60 Days",IRFONT,cols=12
text 28,59,"61-90 Days",IRFONT,cols=12
text 41,59,"Over 90 Days",IRFONT,cols=12
text 54,59,"Finance Charge", IRFONT,cols=12
text 67,59,"Amount Due", IBRFONT,cols=12
cfont 1,60,13,60,DBRFONT
cfont 15,60,26,60,DBRFONT
cfont 28,60,39,60,DBRFONT
cfont 41,60,52,60,DBRFONT,black
cfont 54,60,65,60,DBRFONT,black
cfont 67,60,MAXRCOLS,60,DBRFONT,10
# ----------------------------------------------------------------------
	prepage {
		# EXTRA LINEFEED AT TOP OF PAGE 2 AND GREATER
		if mask(text$[8]," DATEMASK")=49:
			for i=2 to 66
				text$[i-1]=text$[i],text$[i]=""
			next i
		endif
	}
	
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="statement"
	prepage {
	noarchive=1
	earc$="EARC_STATEMENT",doing_recat=0
	earca_formtype$="8.5x11"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	merge "8.0 zMrg PDFLinks v2"
	prepage {
		exec(fnCreateAnnotations$("~[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]  I//0,8",14,21,24,50,-1,0,"","","DFONT","EARC_STMLINKLIB","Invoice"))
		exec(fnCreateAnnotations$("~[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]  C//0,8",14,21,24,50,-1,0,"","","DFONT","EARC_STMLINKLIB","Credit Memo"))
	}
	
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_STATEMENT"
	if lower(edel$)="y":
		eDocid$=get(62,7,6,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Statement"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(62,7,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-r AR_Statement8.5x11 -ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-r AR_Statement8.5x11 -ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	local XOFYM_COL  	=62			# adjust as needed
	local XOFYM_ROW  	=7				# adjust as needed
	local XOFYM_NCOLS	=6			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- ATTACH SCANNED IMAGES ---------------------------------------------
prepage {
do_attch$="STM_ATTCH_SCAN"
if lower(do_attch$)="y" then:
	if not(uf.arcjob) then:
		begrow=20,endrow=51
		tktcount=0,tktno$=""
		amask$=" [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]  [A-Z][A-Z] "
		for row=begrow to endrow
			pp=msk(text$[row],amask$,err=*next)
			if not(pp) continue
			tktno$+=trim(mid(text$[row],pp+1,8))+","
			tktcount+=1
		next row
		continued=(xofym_pageno<>xofym_maxpgs)
		# above, other erp was pos("Continued On Next Page"=text$[50])
		# dotypes$ has valid 1st char prefixes to filter sub-id's, if applicable
		dotypes$="Scan"
		tktlib$="Osas80_Sales"
		tktdocty$="Invoice"
		if tktcount then:
			for ii=1 to tktcount
				tktdocid$=parse(tktno$,ii,",")
					have_arc1=docidexists(tktlib$,tktdocty$,tktdocid$)
					if have_arc1 then:
						subidlist$=getsubids(tktlib$,tktdocty$,tktdocid$)
						subid_count=count(subidlist$,";")
						for x=1 to subid_count
							tktsubid$=parse(subidlist$,x,";")
							if tktsubid$<>"" then:
								if dotypes$="" or pos(left(tktsubid$,4)=dotypes$)=1 then:
									filename$=""
									getarc(tktlib$,tktdocty$,tktdocid$,tktsubid$,filename$,tkterrmsg$)
									imglist$+=filename$+";"
								endif
							endif
						next x
					endif
			next ii
			if not(continued) then images$=imglist$,imglist$=""
		end if
	endif
endif
}
if copy 1
	images {images$},across 2, down 2
end if
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	doc_title$="STATEMENT"
	logocols=14,logorows=6
	merge "zMrg get watermark text"
	# set up copy titles
	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]="File Copy"
}
prepage {
	date$=trim(get(50,7,10))
	cust_code$=trim(get(61,7,7))
	pageno$=trim(get(69,7,4))
	xcol=0,xrow=0
	merge "zMrg get company info"
	
	# add zip barcode
	xrow=14;xcols=40
	#merge "zmrg get zip"
}
[AR_StatementPlain]
dsn_sample "/u0/unform_test/_oem/osas/txt7-demo/ar_plainpaper_stmt-scanattch.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/ar_plainpaper_stmt.txt"
detect 0,1,"S T A T E M E N T"
# set up document constants
local MAXCOLS=80                     	   			# max cols to output
local MAXRCOLS=79                   	   			# MAXCOLS-1
local LEFTCOL=1                       	   			# left vertical line
local RIGHTCOL=MAXCOLS                      			# right vertical line
local MAXROWS=66                       	   			# max rows to output
cols MAXCOLS                          	   			# max output columns
rows MAXROWS                            	   			# max output rows
local CUSTOMER_COPY=1
local REMITTANCE_COPY=2
local FILE_COPY=3
local MAX_COPIES=3
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
##GSON                                	  			# graphical shading
title "Statement - plain"                  			# view in pdf properties
# make space on left & top
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,2,2
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,11,EROW,DBCFONT                    		# date
cfont 13,BROW,20,EROW,DFONT                     		# inv #
cfont 22,BROW,26,EROW,DCFONT                    		# type
cfont 28,BROW,34,EROW,DFONT                     		# check #
cfont 36,BROW,46,EROW,DBRFONT                   		# charges
cfont 48,BROW,58,EROW,DBRFONT                   		# credits
cfont 60,BROW,MAXRCOLS,EROW,DBRFONT             		# balance
# detail section
cerase LEFTCOL,16,RIGHTCOL,16
cerase LEFTCOL,18,RIGHTCOL,18
cbox LEFTCOL,16,RIGHTCOL,49,MBOXSIZE,crows=18::DSHADE,  ccols=12 21 27 35 47 59
local BROW=17
local EROW=17
cfont 2,BROW,11,EROW,ICFONT                     		# date
cfont 13,BROW,20,EROW,IFONT                			# inv #
cfont 22,BROW,26,EROW,ICFONT                    		# type
cfont 28,BROW,34,EROW,IFONT               			# check #
cfont 36,BROW,46,EROW,IRFONT                    		# charges
cfont 48,BROW,58,EROW,IRFONT                    		# credits
cfont 60,BROW,MAXRCOLS,EROW,IRFONT              		# balance
# header section
cerase 1,1,MAXCOLS,9
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# Invoice block
cbox 60,4,RIGHTCOL,9,1,crows=5.5 7.25,ccols=70::ISHADE
text 61,5,"Date",IFONT
text 61,6.75,"Account #",IFONT
text 61,8.5,"Page #",IFONT
text 71,5,{trim(cut(60,9,10,""))},DBFONT,10
text 71,6.75,{trim(cut(47,9,10,""))},DBFONT,10
text 71,8.5,{trim(cut(61,3,10,""))},DBFONT,10
# address & balance info
cbox LEFTCOL,9,RIGHTCOL,16,MBOXSIZE
cfont 1,10,49,15,DBFONT
cfont 48,13,52,13,IBFONT,10
cfont 48,14,79,14,DBFONT,10
# zip bar
#barcode 3,15,{shipzip$},900,12.0,2
# Messages
cbox LEFTCOL,49,RIGHTCOL,53,MBOXSIZE
cfont 1,50,MAXCOLS,52,IFONT
# watermark - large font with light shading
WATERMARK 1,48.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# footer
cerase 1,53,MAXCOLS,53
cerase 1,55,MAXCOLS,55
cerase 1,57,MAXCOLS,57
cbox LEFTCOL,53,MAXCOLS,57,MBOXSIZE,crows=55::HSHADE,ccols=11 22 32 42 52 61
cfont 2,54,10,54,IRFONT
cfont 12,54,21,54,IRFONT
cfont 23,54,31,54,IRFONT
cfont 33,54,41,54,IRFONT
cfont 43,54,51,54,IRFONT
cfont 53,54,60,54,IRFONT
cfont 62,54,MAXRCOLS,54,IBRFONT
cfont 2,56,10,56,DBRFONT,10
cfont 12,56,21,56,DBRFONT,10
cfont 23,56,31,56,DBRFONT,10
cfont 33,56,41,56,DBRFONT,10,black
cfont 43,56,51,56,DBRFONT,10,black
cfont 53,56,60,56,DBRFONT,10,black
cfont 62,56,MAXRCOLS,56,DBRFONT,11,black
cfont LEFTCOL,58,RIGHTCOL,63,IFONT
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="statement"
	prepage {
	noarchive=1
	earc$="EARC_STATEMENT",doing_recat=0
	earca_formtype$="plain"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	merge "8.0 zMrg PDFLinks v2"
	precopy {
		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]  ",11,18,21,48,2,1,"","","DFONT","EARC_STMLINKLIB","EARC_STMLINKDOCTY"))
	}
	
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_STATEMENT"
	if lower(edel$)="y":
		eDocid$=get(47,9,6,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="STATEMENT"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(47,9,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=47			# adjust as needed
	local XOFYM_ROW  	=9				# adjust as needed
	local XOFYM_NCOLS	=6			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- ATTACH SCANNED IMAGES ---------------------------------------------
prepage {
do_attch$="STM_ATTCH_SCAN"
if lower(do_attch$)="y" then:
	if not(uf.arcjob) then:
		begrow=17,endrow=48
		tktcount=0,tktno$=""
		amask$=" [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]  [A-Z][A-Z] "
		for row=begrow to endrow
			pp=msk(text$[row],amask$,err=*next)
			if not(pp) continue
			tktno$+=trim(mid(text$[row],pp+1,8))+","
			tktcount+=1
		next row
		continued=(xofym_pageno<>xofym_maxpgs)
		# above, other erp was pos("Continued On Next Page"=text$[50])
		# dotypes$ has valid 1st char prefixes to filter sub-id's, if applicable
		dotypes$="Scan"
		tktlib$="Osas80_Sales"
		tktdocty$="Invoice"
		if tktcount then:
			for ii=1 to tktcount
				tktdocid$=parse(tktno$,ii,",")
					have_arc1=docidexists(tktlib$,tktdocty$,tktdocid$)
					if have_arc1 then:
						subidlist$=getsubids(tktlib$,tktdocty$,tktdocid$)
						subid_count=count(subidlist$,";")
						for x=1 to subid_count
							tktsubid$=parse(subidlist$,x,";")
							if tktsubid$<>"" then:
								if dotypes$="" or pos(left(tktsubid$,4)=dotypes$)=1 then:
									filename$=""
									getarc(tktlib$,tktdocty$,tktdocid$,tktsubid$,filename$,tkterrmsg$)
									imglist$+=filename$+";"
								endif
							endif
						next x
					endif
			next ii
			if not(continued) then images$=imglist$,imglist$=""
		end if
	endif
endif
}
if copy 1
	images {images$},across 2, down 2
end if
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	doc_title$="STATEMENT"
	merge "zMrg get watermark text"
	logocols=12,logorows=6
	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]="File Copy"
}
prepage {
	xcol=2,xrow=3
	merge "zMrg get company info"
	
	# add zip barcode
	xrow=17;xcols=40
	#merge "zmrg get zip"
}
[AR_StatementStd]
# This format has "tearoff stub", replaced by remittance copy
dsn_sample "/u0/unform_test/_oem/osas/txt7-demo/ar_standard_stmt-scanattch.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/Statement_ACE001-20051231.1.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/ar_standard_stmt.txt"
detect 60,6,"~DATEMASK"
detect 88,6,"~DATEMASK"
# set up document constants
local MAXCOLS=80                         		  		# max cols to output
local MAXRCOLS=79                      		  		# MAXCOLS-1
local LEFTCOL=1                         		  		# left vertical line
local RIGHTCOL=MAXCOLS                    	  		# right vertical line
local MAXROWS=66                    		  		# max rows to output
cols MAXCOLS                          		  		# max output columns
rows MAXROWS                           		 		# max output rows
page 66
local CUSTOMER_COPY=1
local REMITTANCE_COPY=2
local FILE_COPY=3
local MAX_COPIES=3
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
##GSON                              			  		# graphical shading
title "Statement - std"             		  		# view in pdf properties
# make space on left & top
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,1,2
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,10,EROW,DBCFONT                  	     		# date
cfont 12,BROW,20,EROW,DFONT                   	     		# inv #
cfont 22,BROW,24,EROW,DCFONT                  	     		# type
cfont 26,BROW,34,EROW,DFONT                    	     		# check #
cfont 36,BROW,47,EROW,DBRFONT                	     		# charges
cfont 49,BROW,58,EROW,DBRFONT               	     		# credits
cfont 60,BROW,79,EROW,DBRFONT                	     		# balance
# detail section
#cerase LEFTCOL,16,RIGHTCOL,16
#cerase LEFTCOL,18,RIGHTCOL,18
cbox LEFTCOL,20,RIGHTCOL,51,MBOXSIZE,crows=21.5::DSHADE,  ccols=11 21 25 35 48 59
local BROW=21
local EROW=21
text 1,21,"Invoice Date",ICFONT,cols=10
text 12,21,"Invoice No",IFONT
text 22,21,"Type",ICFONT,cols=3
text 26,21,"Check No",IFONT
text 36,21,"Charges",IRFONT,cols=12
text 49,21,"Credits",IRFONT,cols=10
text 60,21,"Balance",IRFONT,cols=20
# header section
cerase 1,1,MAXCOLS,12
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# Invoice block
cbox 60,4,RIGHTCOL,9,1,crows=5.5 7.25,ccols=70::ISHADE
text 61,5,"Date",IFONT
text 61,6.75,"Account #",IFONT
text 61,8.5,"Page #",IFONT
text 71,5,{date$},DBFONT,10
text 71,6.75,{cust_code$},DBFONT,10
text 71,8.5,{pageno$},DBFONT,10
# address & balance info
cerase 75,11,97,51
cbox LEFTCOL,9,RIGHTCOL,20,MBOXSIZE
cfont 1,10,49,19,DBFONT
text 65,15,"Terms",IBFONT
cfont 47,15,79,15,DBRFONT
# Messages
cbox LEFTCOL,51,MAXCOLS,57,MBOXSIZE
cfont 1,52,MAXCOLS,56,IFONT
# watermark - large font with light shading
WATERMARK 1,50.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# aging table
cerase 75,58,97,58
cerase 1,60,97,MAXROWS
cbox LEFTCOL,57,MAXCOLS,60,MBOXSIZE,crows=58.5::HSHADE,ccols=10 21 31 41 52 62
text 1,58,"Unpaid F/C",IRFONT,cols=9
text 11,58,"Current",IRFONT,cols=10
text 22,58,"31-60 Days",IRFONT,cols=9
text 32,58,"61-90 Days",IRFONT,cols=9
text 42,58,"Over 90 Days",IRFONT,cols=10
text 52,58,"New F/C",IRFONT,cols=10
text 63,58,"Amount Due",IBRFONT,cols=16
cfont 1,59,9,59,DBRFONT
cfont 11,59,20,59,DBRFONT,black
cfont 22,59,30,59,DBRFONT
cfont 32,59,40,59,DBRFONT,black
cfont 42,59,50,59,DBRFONT
cfont 52,59,61,59,DBRFONT,black
cfont 63,59,79,59,DBRFONT
text 2,63,{payby_date$},HFONT
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="statement"
	prepage {
	noarchive=1
	earc$="EARC_STATEMENT",doing_recat=0
	earca_formtype$="std"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	merge "8.0 zMrg PDFLinks v2"
	precopy {
		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]  ",11,21,21,51,1,1,"","","DFONT","EARC_STMLINKLIB","EARC_STMLINKDOCTY"))
	}
	
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_STATEMENT"
	if lower(edel$)="y":
		eDocid$=get(47,6,6,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Statement"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(47,6,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
# --- PAGE X of Y FEATURE -----------------------------------------------
	# Page X of Y feature
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=47			# adjust as needed
	local XOFYM_ROW  	=6				# adjust as needed
	local XOFYM_NCOLS	=6			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- ATTACH SCANNED IMAGES ---------------------------------------------
prepage {
do_attch$="STM_ATTCH_SCAN"
if lower(do_attch$)="y" then:
	if not(uf.arcjob) then:
		begrow=15,endrow=46
		tktcount=0,tktno$=""
		amask$=" [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]  [A-Z][A-Z] "
		for row=begrow to endrow
			pp=msk(text$[row],amask$,err=*next)
			if not(pp) continue
			tktno$+=trim(mid(text$[row],pp+1,8))+","
			tktcount+=1
		next row
		continued=(xofym_pageno<>xofym_maxpgs)
		# above, other erp was pos("Continued On Next Page"=text$[50])
		# dotypes$ has valid 1st char prefixes to filter sub-id's, if applicable
		dotypes$="Scan"
		tktlib$="Osas80_Sales"
		tktdocty$="Invoice"
		if tktcount then:
			for ii=1 to tktcount
				tktdocid$=parse(tktno$,ii,",")
					have_arc1=docidexists(tktlib$,tktdocty$,tktdocid$)
					if have_arc1 then:
						subidlist$=getsubids(tktlib$,tktdocty$,tktdocid$)
						subid_count=count(subidlist$,";")
						for x=1 to subid_count
							tktsubid$=parse(subidlist$,x,";")
							if tktsubid$<>"" then:
								if dotypes$="" or pos(left(tktsubid$,4)=dotypes$)=1 then:
									filename$=""
									getarc(tktlib$,tktdocty$,tktdocid$,tktsubid$,filename$,tkterrmsg$)
									imglist$+=filename$+";"
								endif
							endif
						next x
					endif
			next ii
			if not(continued) then images$=imglist$,imglist$=""
		end if
	endif
endif
}
if copy 1
	images {images$},across 2, down 2
end if
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	doc_title$="STATEMENT"
	merge "zMrg get watermark text"
	logocols=12,logorows=6
	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]="File Copy"
}
prepage {
	xcol=2,xrow=3
	merge "zMrg get company info"
	date$=trim(get(60,6,10))
	cust_code$=trim(get(47,6,7))
	pageno$=trim(get(60,1,7))
	x$=set(1,16,97,"")
	if trim(get(60,55,20))<>"" then :
		payby_date$="To avoid additional finance charges, pay by "+trim(get(60,55,20))
	endif
	for i=MAXROWS to 6 step -1
		text$[i]=text$[i-5]
		text$[i-5]=""
	next i
	remit$="Remittance Copy - Please return with payment"
}
[DD_DirDepLaser]
dsn_sample "/u0/unform_test/_oem/osas/txt7/dd_VoucherLaser.txt"
detect 0,1,"D I R E C T   D E P O S I T   V O U C H E R"
detect 0,8,"~ DATEMASK"
detect 0,22,"~ [0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]/[0-9][0-9]/[0-9][0-9] "
# set up document constants
const MAXCOLS=81
const MAXRCOLS=80
const MAXROWS=66
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=81                   # right vertical line
cols MAXCOLS
rows MAXROWS
const MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                                # graphical shading
title "DD Direct Deposit - Laser"              # view in pdf properties
	# make space on left
	cmove 1,1,MAXCOLS,MAXROWS,2,1
	# first adjust format to standard
	cmove 1,20,MAXCOLS,60,1,22
	cerase 1,1,35,6
	# Check
	LOGO_IMAGE 1,1,10,4,"COMP_LOGO"
	cbox LEFTCOL,1,RIGHTCOL,17.75,MBOXSIZE
	text 15,2.25,{compname$},HBFONT,14
	text 15,3.35,"COMP_ADDR1",HFONT,12
	text 15,4.35,"COMP_ADDR2",HFONT,12
	text 15,5.35,"COMP_ADDR3",HFONT,12
	text 49,2.25,"PR_BANK_NAME",DBFONT
	text 49,3.05,"PR_BANK_ADDR1",DFONT
	text 49,3.85,"PR_BANK_ADDR2",DFONT
	text 70,3.35,"PR_ROUTING",DBFONT                # rtg #
	text 2,7,"Pay",IFONT,14
	text 7,7,{trim(cut(4,7,80,""))},DBFONT,italic,11,fit
	cfont 1,8,MAXCOLS,8,DCFONT,11
	cfont 2,9,9,11,DFONT,10
	cfont 11,9,27,11,DRFONT,10
	cfont 29,9,38,11,DBRFONT,10
	cfont 42,9,49,11,DFONT,10
	cfont 51,9,67,11,DRFONT,10
	cfont 69,9,78,11,DBRFONT,10
	shade "~\.[0-9][0-9]@36,9,38,11",-34,0,26,1,DSHADE
	shade "~\.[0-9][0-9]@76,9,78,11",-34,0,26,1,DSHADE
	cfont 59,12,66,12,DRFONT,10
	cfont 68,12,78,12,DBRFONT,10
	text 2,14,"Pay",IFONT
	text 2,15,"to the",IFONT
	text 2,16,"Order",IFONT
	text 2,17,"of",IFONT
	cmove 6,12,47,14,6,14
	cfont 7,13,51,17,DBFONT,11
	# direct deposit on line 1
	cerase 1,1,MAXCOLS,1
	text 51,16,"DIRECT DEPOSIT ADVICE SLIP",HBCFONT,12,cols=30
	text 51,17,"NON-NEGOTIABLE",HBCFONT,cols=30
	# top stub - employee's
	cerase 1,22,30,22
	cbox LEFTCOL,21,MAXCOLS,21
	text 15,22,{compname$},HBFONT,12
	cbox LEFTCOL,22.5,MAXCOLS,24.5,MBOXSIZE,crows=23.5::DSHADE,  ccols=15 33 45 54 64
	cfont 2,23,14,23,ICFONT,8,proper
	cfont 16,23,32,23,ICFONT,8,proper
	cfont 34,23,44,23,ICFONT,8,proper
	cfont 46,23,53,23,ICFONT,8,proper
	cfont 55,23,63,23,ICFONT,8,proper
	cfont 65,23,MAXRCOLS,23,ICFONT,8,proper
	cfont 2,24,14,24,DBCFONT
	cfont 16,24,32,24,DBCFONT
	cfont 34,24,44,24,DBCFONT
	cfont 46,24,53,24,DBCFONT
	cfont 55,24,63,24,DBCFONT
	cfont 65,24,MAXRCOLS,24,DBCFONT
	cbox LEFTCOL,24.5,MAXCOLS,38.5,MBOXSIZE,crows=25.5::DSHADE,  ccols=14 23 34 47 60 70
	cfont 2,25,13,25,IFONT,8,proper
	text 14,25,{proper(cut(14,23,10,""))},IRFONT,8,proper,cols=9
	cfont 24,25,33,25,IRFONT,8,proper
	cfont 35,25,46,25,IRFONT,8,proper
	cfont 48,25,59,25,ILFONT,8,proper
	cfont 61,25,69,25,IRFONT,8,proper
	cfont 71,25,MAXRCOLS,25,IRFONT,8,proper
	cfont 2,26,13,35,DFONT
	cfont 14,26,22,35,DBRFONT,black
	cfont 24,26,33,35,DBRFONT
	cfont 35,26,46,35,DBRFONT
	cfont 48,26,59,38,DFONT
	cfont 61,26,69,38,DBRFONT
	cfont 71,26,MAXRCOLS,38,DBRFONT
	text 2,36,{mcut(1,34,15,2,"","Y","Y")},IBFONT
	text 14,36,{mcut(17,34,9,2,"","Y","Y")},DBRFONT,cols=9
	cbox LEFTCOL,38.5,MAXCOLS,40.5,MBOXSIZE,crows=39.5::100,  ccols=13 25 37 48 60 71
	cfont 2,39,12,39,IFONT,8,shade=0
	cfont 14,39,24,39,IRFONT,8,shade=0
	cfont 26,39,36,39,IRFONT,8,shade=0
	cfont 38,39,47,39,IRFONT,8,shade=0
	cfont 49,39,59,39,IRFONT,8,shade=0
	cerase 61,39,MAXCOLS,39
	text 61,39,"YTD Ded",IRFONT,8,shade=0,cols=10
	text 72,39,"YTD Net Pay",IRFONT,8,shade=0,cols=9
	cfont 2,40,12,40,DBFONT
	cfont 14,40,24,40,DBRFONT
	cfont 26,40,36,40,DBRFONT
	cfont 38,40,47,40,DBRFONT
	cfont 49,40,59,40,DBRFONT
	cfont 61,40,70,40,DBRFONT
	cfont 72,40,MAXRCOLS,40,DBRFONT
	# Bottom stub - employer's
	cerase 1,43,30,43
	cbox LEFTCOL,42,MAXCOLS,42
	text 15,43,"COMP_NAME",HBFONT,12
	cbox LEFTCOL,43.5,MAXCOLS,45.5,MBOXSIZE,crows=44.5::DSHADE,  ccols=15 33 45 54 64
	cfont 2,44,14,44,ICFONT,8,proper
	cfont 16,44,32,44,ICFONT,8,proper
	cfont 34,44,44,44,ICFONT,8,proper
	cfont 46,44,53,44,ICFONT,8,proper
	cfont 55,44,63,44,ICFONT,8,proper
	cfont 65,44,MAXRCOLS,44,ICFONT,8,proper
	cfont 2,45,14,45,DBCFONT
	cfont 16,45,32,45,DBCFONT
	cfont 34,45,44,45,DBCFONT
	cfont 46,45,53,45,DBCFONT
	cfont 55,45,63,45,DBCFONT
	cfont 65,45,MAXRCOLS,45,DBCFONT
	cbox LEFTCOL,45.5,MAXCOLS,59.5,MBOXSIZE,crows=46.5::DSHADE,  ccols=14 23 34 47 60 70
	cfont 2,46,13,46,IFONT,8,proper
	text 14,46,{proper(cut(14,44,10,""))},IRFONT,8,proper,cols=9
	cfont 24,46,33,46,IRFONT,8,proper
	cfont 35,46,46,46,IRFONT,8,proper
	cfont 48,46,59,46,ILFONT,8,proper
	cfont 61,46,69,46,IRFONT,8,proper
	cfont 71,46,MAXRCOLS,46,IRFONT,8,proper
	cfont 2,47,13,56,DFONT
	cfont 14,47,22,56,DBRFONT,black
	cfont 24,47,33,56,DBRFONT
	cfont 35,47,46,56,DBRFONT
	cfont 48,47,59,59,DFONT
	cfont 61,47,69,59,DBRFONT
	cfont 71,47,MAXRCOLS,59,DBRFONT
	text 2,57,{mcut(1,55,15,2,"","Y","Y")},IBFONT
	text 14,57,{mcut(17,55,9,2,"","Y","Y")},DBRFONT,cols=9
	cbox LEFTCOL,59.5,MAXCOLS,61.5,MBOXSIZE,crows=60.5::100,  ccols=13 25 37 48 60 71
	cfont 2,60,12,60,IFONT,8,shade=0
	cfont 14,60,24,60,IRFONT,8,shade=0
	cfont 26,60,36,60,IRFONT,8,shade=0
	cfont 38,60,47,60,IRFONT,8,shade=0
	cfont 49,60,59,60,IRFONT,8,shade=0
	cerase 61,60,MAXCOLS,60
	text 61,60,"YTD Ded",IRFONT,shade=0,cols=10
	text 72,60,"YTD Net Pay",IRFONT,shade=0,cols=9
	cfont 2,61,12,61,DBFONT
	cfont 14,61,24,61,DBRFONT
	cfont 26,61,36,61,DBRFONT
	cfont 38,61,47,61,DBRFONT
	cfont 49,61,59,61,DBRFONT
	cfont 61,61,70,61,DBRFONT
	cfont 72,61,MAXRCOLS,61,DBRFONT
# --- 8.0 ARCHIVING ----------------------------------------------------
	# mje 060210 temporary patch for archiving until summary page issue with DD's fully dispositioned
	prepage {
	if pos("TOTAL GROSS"=text$[1]) then skip=1,sumpage=1
	}
	
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="ddvouch"
	prepage {
	noarchive=1
	earc$="EARC_DDVOUCH",doing_recat=0
	earca_formtype$="laser"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(1,22,6,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="D/D Voucher"
		# Method 6: Address entity ID for lookup
		eAddrEnt$="emp-"+get(1,22,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	compname$=cut(10,20,15,"")
	logocols=10,logorows=5
}
[DD_DirDepBlank]
dsn_sample "/u0/unform_test/_oem/osas/txt7/dd_VoucherBlank.txt"
detect 0,1,"D I R E C T   D E P O S I T   V O U C H E R"
detect 0,7,"! * VOID * "
detect 0,8,"~ DATEMASK"
detect 0,25,"~ [0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]/[0-9][0-9]/[0-9][0-9] "
# set up document constants
const MAXCOLS=81
const MAXRCOLS=80
const MAXROWS=66
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=81                   # right vertical line
cols MAXCOLS
rows MAXROWS
page 42
portrait
dpi 600
# see global constant above
#GSON                                # graphical shading
title "DD Direct Deposit - Blank"              # view in pdf properties
	# make space on left
	cmove 1,1,MAXCOLS,MAXROWS,2,1
	# clear header
	cerase 1,1,MAXCOLS,7
	# Check
	LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
	cbox LEFTCOL,1,RIGHTCOL,17.75,MBOXSIZE
	text 15,2.25,{compname$},HBFONT,14
	text 15,3.35,"COMP_ADDR1",HFONT,12
	text 15,4.35,"COMP_ADDR2",HFONT,12
	text 15,5.35,"COMP_ADDR3",HFONT,12
	text 49,2.25,"PR_BANK_NAME",DBFONT
	text 49,3.05,"PR_BANK_ADDR1",DFONT
	text 49,3.85,"PR_BANK_ADDR2",DFONT
	text 70,3.35,"PR_ROUTING",DBFONT                # rtg #
	cfont 21,8,57,8,DFONT,11
	cfont 61,8,69,8,DFONT,11
	
	cfont 1,8,MAXCOLS,8,DCFONT,11
	cfont 2,10,9,12,DFONT,10
	cfont 11,10,27,12,DRFONT,10
	cfont 29,10,38,12,DBRFONT,10
	cfont 42,10,49,12,DFONT,10
	cfont 51,10,67,12,DRFONT,10
	cfont 69,10,78,12,DBRFONT,10
	shade "~\.[0-9][0-9]@36,10,38,12",-34,0,26,1,DSHADE
	shade "~\.[0-9][0-9]@76,10,78,12",-34,0,26,1,DSHADE
		
	text 2,14,"Pay",IFONT
	text 2,15,"to the",IFONT
	text 2,16,"Order",IFONT
	text 2,17,"of",IFONT
	cmove 6,14,47,17,6,14
	cfont 7,13,51,16,DBFONT,11
	text 51,16,"DIRECT DEPOSIT ADVICE SLIP",HBCFONT,12,cols=30
	text 51,17,"NON-NEGOTIABLE",HBCFONT,cols=30
	cfont 58,14,66,14,DFONT
	cfont 68,14,77,14,DBRFONT
	# top stub - employee's
	cerase 1,22,30,22
	cbox LEFTCOL,21,MAXCOLS,21
	text 15,22,{compname$},HBFONT,12
	cbox LEFTCOL,22.5,MAXCOLS,24.5,MBOXSIZE,crows=23.5::DSHADE,  ccols=15 33 45 54 64
	cfont 2,23,14,23,ICFONT,8,proper
	cfont 16,23,32,23,ICFONT,8,proper
	cfont 34,23,44,23,ICFONT,8,proper
	cfont 46,23,53,23,ICFONT,8,proper
	cfont 55,23,63,23,ICFONT,8,proper
	cfont 65,23,MAXRCOLS,23,ICFONT,8,proper
	cfont 2,24,14,24,DBCFONT
	cfont 16,24,32,24,DBCFONT
	cfont 34,24,44,24,DBCFONT
	cfont 46,24,53,24,DBCFONT
	cfont 55,24,63,24,DBCFONT
	cfont 65,24,MAXRCOLS,24,DBCFONT
	cmove LEFTCOL,24,MAXCOLS,25,LEFTCOL,23
	cmove LEFTCOL,27,MAXCOLS,42,LEFTCOL,25
	
	cbox LEFTCOL,24.5,MAXCOLS,38.5,MBOXSIZE,crows=25.5::DSHADE,  ccols=14 24 34 47 60 70
	cfont 2,25,13,25,IFONT,8,proper
	cfont 14,25,23,25,IRFONT,8,black,proper
	cfont 24,25,33,25,IRFONT,8,proper
	cfont 35,25,46,25,IRFONT,8,proper
	cfont 48,25,59,25,IFONT,8,proper
	cfont 61,25,69,25,IRFONT,8,proper
	cfont 71,25,MAXRCOLS,25,IRFONT,8,proper
	cfont 2,26,14,35,DFONT
	cfont 14,26,23,35,DBRFONT,black
	cfont 24,26,33,35,DBRFONT
	cfont 35,26,46,35,DBRFONT
	cfont 48,26,59,36,DFONT
	cfont 61,26,69,36,DBRFONT
	cfont 71,26,MAXRCOLS,36,DBRFONT
	
	#Vac and sick remaining
	cfont 2,36,15,38,IFONT
	cfont 16,36,23,38,DBRFONT
	
	text 2,36,{vacsickrem$},IBFONT
	text 15,36,{vacsickamt$},DBRFONT,cols=9
	cbox LEFTCOL,38.5,MAXCOLS,40.5,MBOXSIZE,crows=39.5::100,  ccols=13 25 37 48 60 71
	cfont 2,39,12,39,IFONT,8,shade=0
	cfont 14,39,24,39,IRFONT,8,shade=0
	cfont 26,39,36,39,IRFONT,8,shade=0
	cfont 38,39,47,39,IRFONT,8,shade=0
	cfont 49,39,59,39,IRFONT,8,shade=0
	cerase 61,39,MAXCOLS,39
	text 61,39,"YTD Ded",IRFONT,8,shade=0,cols=10
	text 72,39,"YTD Net Pay",IRFONT,8,shade=0,cols=9
	cfont 2,40,12,40,DBFONT
	cfont 14,40,24,40,DBRFONT
	cfont 26,40,36,40,DBRFONT
	cfont 38,40,47,40,DBRFONT
	cfont 49,40,59,40,DBRFONT
	cfont 61,40,70,40,DBRFONT
	cfont 72,40,MAXRCOLS,40,DBRFONT
	# Bottom stub - employer's
	cbox LEFTCOL,42,MAXCOLS,42
	text 15,43,{compname$},HBFONT,12
	cbox LEFTCOL,43.5,MAXCOLS,45.5,MBOXSIZE,crows=44.5::DSHADE,  ccols=15 33 45 54 64
	cfont 2,44,14,44,ICFONT,8,proper
	cfont 16,44,32,44,ICFONT,8,proper
	cfont 34,44,44,44,ICFONT,8,proper
	cfont 46,44,53,44,ICFONT,8,proper
	cfont 55,44,63,44,ICFONT,8,proper
	cfont 65,44,MAXRCOLS,44,ICFONT,8,proper
	cfont 2,45,14,45,DBCFONT
	cfont 16,45,32,45,DBCFONT
	cfont 34,45,44,45,DBCFONT
	cfont 46,45,53,45,DBCFONT
	cfont 55,45,63,45,DBCFONT
	cfont 65,45,MAXRCOLS,45,DBCFONT
	cmove LEFTCOL,47,MAXCOLS,62,LEFTCOL,46
	cbox LEFTCOL,45.5,MAXCOLS,59.5,MBOXSIZE,crows=46.5::DSHADE,  ccols=14 24 34 47 60 70
	cfont 2,46,13,46,IFONT,8,proper
	cfont 14,46,23,46,IRFONT,8,black,proper
	cfont 24,46,33,46,IRFONT,8,proper
	cfont 35,46,46,46,IRFONT,8,proper
	cfont 48,46,59,46,IFONT,8,proper
	cfont 61,46,69,46,IRFONT,8,proper
	cfont 71,46,MAXRCOLS,46,IRFONT,8,proper
	cfont 2,47,13,56,DFONT
	cfont 14,47,23,56,DBRFONT,black
	cfont 24,47,33,56,DBRFONT
	cfont 35,47,46,56,DBRFONT
	cfont 48,47,59,59,DFONT
	cfont 61,47,69,59,DBRFONT
	cfont 71,47,MAXRCOLS,59,DBRFONT
	text 2,57,{vacsickrem$},IBFONT
	text 15,57,{vacsickamt$},DBRFONT,cols=9
	cbox LEFTCOL,59.5,MAXCOLS,61.5,MBOXSIZE,crows=60.5::100,  ccols=13 25 37 48 60 71
	cfont 2,60,12,60,IFONT,8,shade=0
	cfont 14,60,24,60,IRFONT,8,shade=0
	cfont 26,60,36,60,IRFONT,8,shade=0
	cfont 38,60,47,60,IRFONT,8,shade=0
	cfont 49,60,59,60,IRFONT,8,shade=0
	cerase 61,60,MAXCOLS,60
	text 61,60,"YTD Ded",IRFONT,shade=0,cols=10
	text 72,60,"YTD Net Pay",IRFONT,shade=0,cols=9
	cfont 2,61,12,61,DBFONT
	cfont 14,61,24,61,DBRFONT
	cfont 26,61,36,61,DBRFONT
	cfont 38,61,47,61,DBRFONT
	cfont 49,61,59,61,DBRFONT
	cfont 61,61,70,61,DBRFONT
	cfont 72,61,MAXRCOLS,61,DBRFONT
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="ddvouch"
	prepage {
	noarchive=1
	earc$="EARC_DDVOUCH",doing_recat=0
	earca_formtype$="blank"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(1,25,6,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="D/D Voucher"
		# Method 6: Address entity ID for lookup
		eAddrEnt$="emp-"+get(1,25,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=10,logorows=5
}
prepage {
	compname$=cut(10,23,15,"")
	vacsickrem$=mcut(1,38,14,2,"","Y","Y")
	vacsickamt$=mcut(17,38,9,2,"","Y","Y")
	brow=24,erow=43
	begin_copy_loop:
		text$[brow+20]=text$[brow]
		brow=brow+1
		if brow=erow then goto end_copy_loop else goto begin_copy_loop
	end_copy_loop:
}
[DD_DirDepPreprinted]
dsn_sample "/u0/unform_test/_oem/osas/txt7/dd_VoucherPreprinted.txt"
detect 0,1,"D I R E C T   D E P O S I T   V O U C H E R"
detect 0,8,"~ DATEMASK"
detect 0,25,"~ [0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]/[0-9][0-9]/[0-9][0-9] "
# set up document constants
const MAXCOLS=81
const MAXRCOLS=80
const MAXROWS=66
const LEFTCOL=1                     # left vertical line
const RIGHTCOL=81                   # right vertical line
cols MAXCOLS
rows MAXROWS
page 42
const MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                                # graphical shading
title "DD Direct Deposit - Preprinted"              # view in pdf properties
	# make space on left
	cmove 1,1,MAXCOLS,MAXROWS,2,1
	# clear header
	cerase 1,1,MAXCOLS,7
	# check
	LOGO_IMAGE 1,1,10,4,"COMP_LOGO"
	cbox LEFTCOL,1,RIGHTCOL,17.75,MBOXSIZE
	text 15,2.25,{compname$},HBFONT,14
	text 15,3.35,"COMP_ADDR1",HFONT,12
	text 15,4.35,"COMP_ADDR2",HFONT,12
	text 15,5.35,"COMP_ADDR3",HFONT,12
	text 49,2.25,"PR_BANK_NAME",DBFONT
	text 49,3.05,"PR_BANK_ADDR1",DFONT
	text 49,3.85,"PR_BANK_ADDR2",DFONT
	text 70,3.35,"PR_ROUTING",DBFONT                # rtg #
	cfont 22,8,57,8,DLFONT,11
	cfont 57,8,69,8,DFONT,11
	
	cfont 1,8,MAXCOLS,8,DCFONT,11
	cfont 2,10,9,12,DFONT,10
	cfont 11,10,27,12,DRFONT,10
	cfont 29,10,38,12,DBRFONT,10
	cfont 42,10,49,12,DFONT,10
	cfont 51,10,67,12,DRFONT,10
	cfont 69,10,78,12,DBRFONT,10
	shade "~\.[0-9][0-9]@36,10,38,12",-34,0,26,1,DSHADE
	shade "~\.[0-9][0-9]@76,10,78,12",-34,0,26,1,DSHADE
		
	text 2,14,"Pay",IFONT
	text 2,15,"to the",IFONT
	text 2,16,"Order",IFONT
	text 2,17,"of",IFONT
	cfont 7,13,51,16,DBFONT,11
	text 51,16,"DIRECT DEPOSIT ADVICE SLIP",HBCFONT,12,cols=30
	text 51,17,"NON-NEGOTIABLE",HBCFONT,cols=30
	cfont 58,14,66,14,DFONT
	cfont 68,14,77,14,DBRFONT
	# top stub - employee's
	cbox LEFTCOL,21,MAXCOLS,21
	text 15,22,{compname$},HBFONT,12
	cbox LEFTCOL,22.5,MAXCOLS,24.5,MBOXSIZE,crows=23.5::DSHADE,  ccols=15 33 45 54 64
	cfont 2,23,14,23,ICFONT,9,proper
	cfont 16,23,32,23,ICFONT,9,proper
	cfont 34,23,44,23,ICFONT,9,proper
	cfont 46,23,53,23,ICFONT,9,proper
	cfont 55,23,63,23,ICFONT,9,proper
	cfont 65,23,MAXRCOLS,23,9,ICFONT,proper
	cfont 2,24,14,24,DBCFONT
	cfont 16,24,32,24,DBCFONT
	cfont 34,24,44,24,DBCFONT
	cfont 46,24,53,24,DBCFONT
	cfont 55,24,63,24,DBCFONT
	cfont 65,24,MAXRCOLS,24,DBCFONT
	cmove LEFTCOL,24,MAXCOLS,25,LEFTCOL,23
	cmove LEFTCOL,27,MAXCOLS,42,LEFTCOL,25
	
	cbox LEFTCOL,24.5,MAXCOLS,38.5,MBOXSIZE,crows=25.5::DSHADE,  ccols=14 24 34 47 60 70
	cfont 2,25,13,25,IFONT,9,proper
	cfont 14,25,23,25,IRFONT,9,black,proper
	cfont 24,25,33,25,IRFONT,9,proper
	cfont 35,25,46,25,IRFONT,9,proper
	cfont 48,25,59,25,IFONT,9,proper
	cfont 61,25,69,25,IRFONT,9,proper
	cfont 71,25,MAXRCOLS,25,IRFONT,9,proper
	cfont 2,26,14,35,DFONT
	cfont 14,26,23,35,DBRFONT,black
	cfont 24,26,33,35,DBRFONT
	cfont 35,26,46,35,DBRFONT
	cfont 48,26,59,36,DFONT
	cfont 61,26,69,36,DBRFONT
	cfont 71,26,MAXRCOLS,36,DBRFONT
	text 2,36,{vacsickrem$},IBFONT,9
	text 15,36,{vacsickamt$},DBRFONT,cols=9
	cbox LEFTCOL,38.5,MAXCOLS,40.5,MBOXSIZE,crows=39.5::100,  ccols=13 25 37 48 60 71
	cfont 2,39,12,39,IFONT,9,shade=0
	cfont 14,39,24,39,IRFONT,9,shade=0
	cfont 26,39,36,39,IRFONT,9,shade=0
	cfont 38,39,47,39,IRFONT,9,shade=0
	cfont 49,39,59,39,IRFONT,9,shade=0
	cerase 61,39,MAXCOLS,39
	text 61,39,"YTD Ded",IRFONT,9,shade=0,cols=10
	text 72,39,"YTD Net Pay",IRFONT,9,shade=0,cols=9
	cfont 2,40,12,40,DBFONT
	cfont 14,40,24,40,DBRFONT
	cfont 26,40,36,40,DBRFONT
	cfont 38,40,47,40,DBRFONT
	cfont 49,40,59,40,DBRFONT
	cfont 61,40,70,40,DBRFONT
	cfont 72,40,MAXRCOLS,40,DBRFONT
	# Bottom stub - employer's
	cbox LEFTCOL,42,MAXCOLS,42
	text 15,43,{compname$},HBFONT,12
	cbox LEFTCOL,43.5,MAXCOLS,45.5,MBOXSIZE,crows=44.5::DSHADE,  ccols=15 33 45 54 64
	cfont 2,44,14,44,ICFONT,9,proper
	cfont 16,44,32,44,ICFONT,9,proper
	cfont 34,44,44,44,ICFONT,9,proper
	cfont 46,44,53,44,ICFONT,9,proper
	cfont 55,44,63,44,ICFONT,9,proper
	cfont 65,44,MAXRCOLS,44,ICFONT,9,proper
	cfont 2,45,14,45,DBCFONT
	cfont 16,45,32,45,DBCFONT
	cfont 34,45,44,45,DBCFONT
	cfont 46,45,53,45,DBCFONT
	cfont 55,45,63,45,DBCFONT
	cfont 65,45,MAXRCOLS,45,DBCFONT
	cmove LEFTCOL,47,MAXCOLS,62,LEFTCOL,46
	cbox LEFTCOL,45.5,MAXCOLS,59.5,MBOXSIZE,crows=46.5::DSHADE,  ccols=14 24 34 47 60 70
	cfont 2,46,13,46,IFONT,9,proper
	cfont 14,46,23,46,IRFONT,9,black,proper
	cfont 24,46,33,46,IRFONT,9,proper
	cfont 35,46,46,46,IRFONT,9,proper
	cfont 48,46,59,46,IFONT,9,proper
	cfont 61,46,69,46,IRFONT,9,proper
	cfont 71,46,MAXRCOLS,46,IRFONT,9,proper
	cfont 2,47,13,56,DFONT
	cfont 14,47,23,56,DBRFONT,black
	cfont 24,47,33,56,DBRFONT
	cfont 35,47,46,56,DBRFONT
	cfont 48,47,59,59,DFONT
	cfont 61,47,69,59,DBRFONT
	cfont 71,47,MAXRCOLS,59,DBRFONT
	text 2,57,{vacsickrem$},IBFONT,9
	text 15,57,{vacsickamt$},DBRFONT,cols=9
	cbox LEFTCOL,59.5,MAXCOLS,61.5,MBOXSIZE,crows=60.5::100,  ccols=13 25 37 48 60 71
	cfont 2,60,12,60,IFONT,shade=0
	cfont 14,60,24,60,IRFONT,shade=0
	cfont 26,60,36,60,IRFONT,shade=0
	cfont 38,60,47,60,IRFONT,shade=0
	cfont 49,60,59,60,IRFONT,shade=0
	cerase 61,60,MAXCOLS,60
	text 61,60,"YTD Ded",IRFONT,shade=0,cols=10
	text 72,60,"YTD Net Pay",IRFONT,shade=0,cols=9
	cfont 2,61,12,61,DBFONT
	cfont 14,61,24,61,DBRFONT
	cfont 26,61,36,61,DBRFONT
	cfont 38,61,47,61,DBRFONT
	cfont 49,61,59,61,DBRFONT
	cfont 61,61,70,61,DBRFONT
	cfont 72,61,MAXRCOLS,61,DBRFONT
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="ddvouch"
	prepage {
	noarchive=1
	earc$="EARC_DDVOUCH",doing_recat=0
	earca_formtype$="preprinted"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(1,25,6,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="D/D Voucher"
		# Method 6: Address entity ID for lookup
		eAddrEnt$="emp-"+get(1,25,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=10,logorows=5
}
prepage {
	compname$=cut(10,23,15,"")
	vacsickrem$=mcut(1,38,14,2,"","Y","Y")
	vacsickamt$=mcut(17,38,9,2,"","Y","Y")
	brow=24,erow=43
	begin_copy_loop:
		text$[brow+20]=text$[brow]
		brow=brow+1
		if brow=erow then goto end_copy_loop else goto begin_copy_loop
	end_copy_loop:
}
[GL_BalanceSheet]
dsn_sample "/u0/unform_test/_oem/osas/txt7/gl_bs_budget.txt"
detect 0,3,"~BALANCE SHEET WITH .* COMPARISON"
detect 0,3,"~(BUDGET)|(LAST YEAR)"
# set up document constants
local MAXCOLS=80                        			   # max cols to output
local MAXRCOLS=79                     			   # MAXCOLS-1
local LEFTCOL=1                      			   # left vertical line
local RIGHTCOL=MAXCOLS                 		          # right vertical line
local MAXROWS=66                    			   # max rows to output
cols MAXCOLS                       			   # max output columns
rows MAXROWS                       			   # max output rows
local MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                               			   # graphical shading
title "Balance Sheet"              			   # view in pdf properties
cmove LEFTCOL,1,MAXCOLS,MAXROWS,2,1
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,16,EROW,DBCFONT           			   # acnt no
cfont 18,BROW,46,EROW,DFONT            			   # desc
cfont 48,BROW,60,EROW,DBRFONT             		   # curr yr
cfont 61,BROW,59,EROW,DBFONT,black        		   # )
cfont 64,BROW,76,EROW,DBRFONT            			   # prev yr/budget
cfont 77,BROW,77,EROW,DBFONT,black       			   # )
# header
cerase LEFTCOL,1,MAXCOLS,4
cbox LEFTCOL,.1,RIGHTCOL,4,MBOXSIZE,HSHADE
text 2,1.5,{trim(cut(1,1,10,""))},HFONT
text 1,1.5,{trim(cut(18,1,50,""))},HBCFONT,14,cols=MAXCOLS
text 1,1.5,{trim(cut(70,1,10,""))},HRFONT,cols=MAXRCOLS
text 2,2.5,{trim(cut(1,2,10,""))},HFONT
text 1,2.75,{trim(cut(1,3,MAXCOLS,""))},HBCFONT,12,cols=MAXCOLS
text 1,3.75,{trim(cut(1,4,MAXCOLS,""))},HCFONT,cols=MAXCOLS
# detail header line
cerase 1,10,MAXCOLS,10
cbox LEFTCOL,6,MAXCOLS,8.5,1,DSHADE
local BROW=7
local EROW=8
cfont 2,BROW,16,EROW,ICFONT,proper      			   # acnt no
cfont 18,BROW,46,EROW,IFONT,proper      			   # desc
cfont 48,BROW,60,EROW,IRFONT,black,proper			   # curr yr
cfont 64,BROW,76,EROW,IRFONT,proper     		          # prev yr/budget
# special detail lines
font "~  [A-Z]@23,11,25,MAXROWS",2,0,50,1,DBFONT,11
font "~  [A-Z]@14,11,16,MAXROWS",2,0,50,1,IBFONT,10
font "~  TOTAL@18,11,24,MAXROWS",2,0,27,1,IBFONT,10
box  "~  TOTAL@18,11,24,MAXROWS",1,-.85,58,1.4,1,DSHADE
erase "~  TOTAL@18,11,24,MAXROWS",0,-1,MAXCOLS,1
erase "~  TOTAL@18,11,24,MAXROWS",0,1,MAXCOLS,1
# unaudited
font "UNAUDITED",0,0,9,1,HFONT
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="financials"
	prepage {
	noarchive=1
	earc$="EARC_BALSHEET",doing_recat=0
	earca_formtype$="balance sheet"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYS_COPIES to "0" to turn off
	local XOFYS_COPIES="ALL"			# or copy #'s to display
	local XOFYS_FONT 	="univers,10,bold,left"	# use global or ???
	local XOFYS_DCOL	=10
	local XOFYS_DROW	=MAXROWS+.5		# row to display title
	merge "zMrgSinglePageXofY"
[GL_IncStmtwBudgComp]
dsn_sample "/u0/unform_test/_oem/osas/txt7/GLINCB.TXT"
dsn_sample "/u0/unform_test/_oem/osas/txt7/gl_inc_budget.txt"
detect 0,3,"~INCOME STATEMENT WITH BUDGET COMPARISON"
# set up document constants
local MAXCOLS=130                     			    # max cols to output
local MAXRCOLS=129                			           # MAXCOLS-1
local LEFTCOL=1                    			    # left vertical line
local RIGHTCOL=MAXCOLS                			    # right vertical line
local MAXROWS=60                     			    # max rows to output
cols MAXCOLS                    			           # max output columns
rows MAXROWS                      				    # max output rows
local MAX_COPIES=1
pcopies MAX_COPIES
landscape
dpi 600
# see global constant above
#GSON                                			 	# graphical shading
title "Income Statement with Budget Comp" 		 	# view in pdf properties
cmove LEFTCOL,1,MAXCOLS,MAXROWS,2,1
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,7,EROW,DBCFONT          		   	 	# acnt no
cfont 9,BROW,40,EROW,DFONT             			 	# desc
# current period
cfont 41,BROW,52,EROW,DBRFONT,black        			# this yr
cfont 53,BROW,53,EROW,DBFONT             			 	# -
cfont 55,BROW,60,EROW,DRFONT             			 	# %
cfont 61,BROW,61,EROW,DFONT,black         		 	# -
cfont 63,BROW,75,EROW,DBRFONT               		 	# budget
cfont 76,BROW,76,EROW,DBFONT,black         		 	# -
cfont 78,BROW,83,EROW,DRFONT              		 	# %
cfont 84,BROW,84,EROW,DFONT,black          		 	# -
#year to date
cfont 86,BROW,98,EROW,DBRFONT               		 	# this yr
cfont 99,BROW,99,EROW,DBFONT,black         		 	# -
cfont 101,BROW,106,EROW,DRFONT        			 	# %
cfont 107,BROW,107,EROW,DFONT,black       		 	# -
cfont 109,BROW,121,EROW,DBRFONT        		        	# budget
cfont 122,BROW,122,EROW,DBFONT,black      		 	# -
cfont 124,BROW,129,EROW,DRFONT         			 	# %
cfont 130,BROW,130,EROW,DFONT,black       		 	# -
# header
cerase LEFTCOL,1,MAXCOLS,4
cbox LEFTCOL,.1,RIGHTCOL,4,MBOXSIZE,HSHADE
text 2,1.5,{trim(cut(1,1,10,""))},HFONT
text 1,1.5,{trim(cut(18,1,92,""))},HBCFONT,14,cols=MAXCOLS
text 1,1.5,{trim(cut(121,1,10,""))},HRFONT,cols=MAXRCOLS
text 2,2.5,{trim(cut(1,2,10,""))},HFONT
text 1,2.75,{trim(cut(1,3,MAXCOLS,""))},HBCFONT,12,cols=MAXCOLS
text 1,3.75,{trim(cut(1,4,MAXCOLS,""))},HCFONT,cols=MAXCOLS
# detail header line
cerase 1,10,MAXCOLS,10
cbox LEFTCOL,6,MAXCOLS,8.5,1,DSHADE
local BROW=7
local EROW=8
cfont 2,BROW,7,EROW,ICFONT,proper        			 	# acnt no
cfont 9,BROW,40,EROW,IFONT,proper        			 	# desc
cfont 41,7,83,7,ICFONT,black        				# current period
local BROW=8
local EROW=8
cbox 42,7.375,83.5,7.375
cfont 41,BROW,52,EROW,IRFONT,black,proper      		 	# this yr
cfont 55,BROW,60,EROW,IRFONT              		 	# %
cfont 63,BROW,75,EROW,IRFONT,proper            		 	# budget
cfont 78,BROW,83,EROW,IRFONT              		 	# %
# year to date
cbox 88,7.375,129.5,7.375
cfont 86,7,129,7,ICFONT,black
cfont 86,BROW,98,EROW,IRFONT,proper            		 	# this yr
cfont 101,BROW,106,EROW,IRFONT         			 	# %
cfont 109,BROW,121,EROW,IRFONT,proper    			 	# budget
cfont 124,BROW,129,EROW,IRFONT        			 	# %
# special detail lines
font "~  [A-Z]@7,11,9,MAXROWS",2,0,50,1,DBFONT,11
font "~  [A-Z]@8,11,10,MAXROWS",2,0,50,1,DBFONT,10
font "~  TOTAL@10,11,16,MAXROWS",2,0,27,1,IBFONT,10
box  "~  TOTAL@10,11,16,MAXROWS",1,-.85,119,1.4,1,DSHADE
erase "~  TOTAL@10,11,16,MAXROWS",0,-1,MAXCOLS,1
erase "~  TOTAL@10,11,16,MAXROWS",0,1,MAXCOLS,1
font "~  TOTAL@11,11,17,MAXROWS",2,0,27,1,IBFONT,10
box  "~  TOTAL@11,11,17,MAXROWS",1,-.85,118,1.4,1,DSHADE
erase "~  TOTAL@11,11,17,MAXROWS",0,-1,MAXCOLS,1
erase "~  TOTAL@11,11,17,MAXROWS",0,1,MAXCOLS,1
font "~  GROSS@11,11,17,MAXROWS",2,0,27,1,IBFONT,10
box  "~  GROSS@11,11,17,MAXROWS",1,-.85,118,1.4,1,HSHADE
font "~  PROFI@11,11,17,MAXROWS",2,0,27,1,IBFONT,10
box  "~  PROFI@11,11,17,MAXROWS",1,-.85,118,1.4,1,HSHADE
font "~  NET@11,11,15,MAXROWS",2,0,27,1,IBFONT,10
box  "~  NET@11,11,15,MAXROWS",1,-.85,118,1.4,1,HSHADE
# unaudited
font "UNAUDITED",0,0,9,1,HFONT
	
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="financials"
	prepage {
	noarchive=1
	earc$="EARC_INCSTMT",doing_recat=0
	earca_formtype$="income statement"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYS_COPIES to "0" to turn off
	local XOFYS_COPIES="ALL"			# or copy #'s to display
	local XOFYS_FONT 	="univers,10,bold,left"	# use global or ???
	local XOFYS_DCOL	=10
	local XOFYS_DROW	=MAXROWS+.5		# row to display title
	merge "zMrgSinglePageXofY"
[GL_IncStmtwLstYrComp]
dsn_sample "/u0/unform_test/_oem/osas/txt7/gl_inc_prev.txt"
detect 0,3,"~INCOME STATEMENT WITH LAST YEAR COMPARISON"
# set up document constants
local MAXCOLS=128                      				# max cols to output
local MAXRCOLS=127                     				# MAXCOLS-1
local LEFTCOL=1                        				# left vertical line
local RIGHTCOL=MAXCOLS                    			# right vertical line
local MAXROWS=60                       				# max rows to output
cols MAXCOLS                          				# max output columns
rows MAXROWS                          				# max output rows
local MAX_COPIES=1
pcopies MAX_COPIES
landscape
dpi 600
# see global constant above
#GSON                               				# graphical shading
title "Income Statement with Last Year Comp"			# view in pdf properties
cmove LEFTCOL,1,MAXCOLS,MAXROWS,2,1
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,7,EROW,DBCFONT  						# acnt no
cfont 9,BROW,37,EROW,DFONT    			   		       # desc
# current period
cfont 38,BROW,49,EROW,DBRFONT,black			  	# this yr
cfont 50,BROW,50,EROW,DBFONT              		  	# -
cfont 52,BROW,57,EROW,DRFONT              		  	# %
cfont 58,BROW,58,EROW,DFONT,black         		  	# -
cfont 60,BROW,71,EROW,DBRFONT      			  	# prev yr
cfont 72,BROW,72,EROW,DBFONT,black        		  	# -
cfont 74,BROW,81,EROW,DRFONT              		  	# %
cfont 82,BROW,82,EROW,DFONT,black         		  	# -
# year to date
cfont 84,BROW,95,EROW,DBRFONT 			  			# this yr
cfont 96,BROW,96,EROW,DBFONT,black       			  	# -
cfont 98,BROW,103,EROW,DRFONT             		  	# %
cfont 104,BROW,104,EROW,DFONT,black       		  	# -
cfont 106,BROW,117,EROW,DBRFONT				  	# prev yr
cfont 118,BROW,118,EROW,DBFONT,black      		  	# -
cfont 120,BROW,127,EROW,DRFONT         			  	# %
cfont 128,BROW,128,EROW,DFONT,black       		  	# -
# header
cerase LEFTCOL,1,MAXCOLS,4
cbox LEFTCOL,.1,RIGHTCOL,4,MBOXSIZE,HSHADE
text 2,1.5,{trim(cut(1,1,10,""))},HFONT
text 1,1.5,{trim(cut(18,1,92,""))},HBCFONT,14,cols=MAXCOLS
text 1,1.5,{trim(cut(121,1,10,""))},HRFONT,cols=MAXRCOLxt 2,2.5,{trim(cut(1,2,10,""))},HFONT
text 1,2.75,{trim(cut(1,3,MAXCOLS,""))},HBCFONT,12,cols=MAXCOLS
text 1,3.75,{trim(cut(1,4,MAXCOLS,""))},HCFONT,cols=MAXCOLS
# detail header line
cerase 1,10,MAXCOLS,10
cbox LEFTCOL,6,MAXCOLS,9,1,DSHADE
local BROW=7
local EROW=8
cfont 2,BROW,6,EROW,ICFONT,black,proper   		   # acnt no
cfont 7,BROW,37,EROW,IFONT,proper   			   # desc
# current period
local BROW=8
local EROW=8
cbox 39,7.375,81,7.375
cfont 38,7,81,7,ICFONT,black
cfont 38,BROW,49,EROW,IRFONT,black,proper      		   # this yr
cfont 52,BROW,57,EROW,IRFONT              		   # %
cerase 65,8,74,8
text 72,BROW,"Last Year",IRFONT				   # prev yr
cfont 74,BROW,81,EROW,IRFONT             			   # %
# year to date
cbox 85,7.375,127,7.375
cfont 84,7,127,7,ICFONT,black
cfont 84,BROW,95,EROW,IRFONT,proper         		   # this yr
cfont 98,BROW,103,EROW,IRFONT             		   # %
cerase 111,8,120,8
text 118,BROW,"Last Year",IRFONT				   # prev yr
cfont 120,BROW,127,EROW,IRFONT        			   # %
# special detail lines
font "~  [A-Z]@5,11,7,MAXROWS",2,0,50,1,DBFONT,11
font "~  [A-Z]@6,11,8,MAXROWS",2,0,50,1,DBFONT,10
font "~  TOTAL@8,11,14,MAXROWS",2,0,27,1,IBFONT,10
box  "~  TOTAL@8,11,14,MAXROWS",1,-.85,119,1.4,1,DSHADE
erase "~  TOTAL@8,11,14,MAXROWS",0,-1,MAXCOLS,1
erase "~  TOTAL@8,11,14,MAXROWS",0,1,MAXCOLS,1
font "~  TOTAL@9,11,15,MAXROWS",2,0,27,1,IBFONT,10
box  "~  TOTAL@9,11,15,MAXROWS",1,-.85,118,1.4,1,DSHADE
erase "~  TOTAL@9,11,15,MAXROWS",0,-1,MAXCOLS,1
erase "~  TOTAL@9,11,15,MAXROWS",0,1,MAXCOLS,1
font "~  GROSS@9,11,15,MAXROWS",2,0,27,IBFONT,10
box  "~  GROSS@9,11,15,MAXROWS",1,-.85,118,1.4,1,HSHADE
font "~  PROFI@9,11,15,MAXROWS",2,0,27,1,IBFONT,10
box  "~  PROFI@9,11,15,MAXROWS",1,-.85,118,1.4,1,HSHADE
font "~  NET@9,11,15,MAXROWS",2,0,27,1,IBFONT,10
box  "~  NET@9,11,15,MAXROWS",1,-.85,118,1.4,1,HSHADE
font "~FEDERAL INCOME TAX EXPENSE@6,11,33,MAXROWS",0,0,26,1,DBFONT,black
font "~STATE INCOME TAX EXPENSE@6,11,33,MAXROWS",0,0,26,1,DBFONT,black
# unaudited
font "UNAUDITED",0,0,9,1,HFONT
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="financials"
	prepage {
	noarchive=1
	earc$="EARC_INCSTMT",doing_recat=0
	earca_formtype$="income statement"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYS_COPIES to "0" to turn off
	local XOFYS_COPIES="ALL"			# or copy #'s to display
	local XOFYS_FONT 	="univers,10,bold,left"	# use global or ???
	local XOFYS_DCOL	=10
	local XOFYS_DROW	=MAXROWS+.5		# row to display title
	merge "zMrgSinglePageXofY"
[GL_TrialBalance]
dsn_sample "/u0/unform_test/_oem/osas/txt7/gl_tb_prev.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/gl_tb_budget.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/gl_tb_actual.txt"
detect 0,3,"TRIAL BALANCE"
detect 1,8,"GL"
# set up document constants
local MAXCOLS=131                      		     		# max cols to output
local MAXRCOLS=130                    		     		# MAXCOLS-1
local LEFTCOL=1                       		     		# left vertical line
local RIGHTCOL=MAXCOLS                		     		# right vertical line
local MAXROWS=66                       		     		# max rows to output
cols MAXCOLS                      			     		# max output columns
rows MAXROWS                       		     		# max output rows
local MAX_COPIES=1
pcopies MAX_COPIES
landscape
dpi 600
# see global constant above
#GSON                              			    		# graphical shading
title "Trial Balance"           			    		# view in pdf properties
cmove LEFTCOL,1,MAXCOLS,MAXROWS,2,1
# default detail line
local BROW=1
local EROW=MAXCOLS
cfont 2,BROW,14,EROW,DBFONT           		    		# acnt #
cfont 16,BROW,51,EROW,DBFONT              	    		# desc
cfont 55,BROW,67,EROW,DBRFONT           		    		# debit
cfont 75,BROW,87,EROW,DBRFONT           		    		# credit
cfont 98,BROW,110,EROW,DBRFONT        		    		# debit
cfont 118,BROW,130,EROW,DBRFONT       		    		# credit
# header
cerase LEFTCOL,1,MAXCOLS,4
cbox LEFTCOL,.1,RIGHTCOL,4.5,MBOXSIZE,HSHADE
text 2,3,{trim(get(1,1,10))},HFONT
text 1,1.65,{trim(get(11,1,110))},HBCFONT,14,cols=MAXCOLS
text 1,3,{trim(get(11,3,110))},HBCFONT,12,cols=MAXCOLS
text 1,1.65,{trim(get(122,1,10))},HRFONT,cols=MAXRCOLS
text 2,1.65,{trim(get(1,3,10))},HFONT
text 1,3,{trim(get(1,2,10))},HRFONT,cols=MAXRCOLS
text 1,4.15,{trim(get(11,4,110))},HCFONT,cols=MAXCOLS
text 2,4.15,{trim(get(1,4,10))},HFONT
# detail header line
cerase 1,9,MAXCOLS,9
cbox LEFTCOL,5,MAXCOLS,9,1,DSHADE
local BROW=8
local EROW=8
cfont 55,6,96,7,ICFONT,10
cfont 98,6,136,7,ICFONT,10
cfont 2,BROW,14,EROW,IFONT           		   		# acnt #
cfont 16,BROW,51,EROW,IFONT           		   		# desc
cfont 55,BROW,67,EROW,IRFONT              	   		# debit
cfont 75,BROW,87,EROW,IRFONT           		   		# credit
cfont 98,BROW,110,EROW,IRFONT             	   		# debit
cfont 118,BROW,130,EROW,IRFONT        		   		# credit
cmove 2,BROW,130,EROW,2,8.25
# totals
erase "  BALANCE@14,10,22,MAXROWS",0,-1,MAXCOLS,1
erase "  BALANCE@14,10,22,MAXROWS",0,1,MAXCOLS,1
box "  BALANCE@14,10,22,MAXROWS",1,-1,116,2,MBOXSIZE,HSHADE
font "  BALANCE@14,10,22,MAXROWS",2,0,15,1,IBFONT
font "End of Report",0,0,13,1,HFONT
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="financials"
	prepage {
	noarchive=1
	earc$="EARC_TRIALBAL",doing_recat=0
	earca_formtype$="trial balance"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYS_COPIES to "0" to turn off
	local XOFYS_COPIES="ALL"			# or copy #'s to display
	local XOFYS_FONT 	="univers,10,bold,left"	# use global or ???
	local XOFYS_DCOL	=10
	local XOFYS_DROW	=MAXROWS+.5		# row to display title
	merge "zMrgSinglePageXofY"
[PO_PurchOrderLaser]
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/formlaser/po_laser.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/po_laser.txt"
detect 53,4,"~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]   DATEMASK"
detect 75,7,"~[0-9]"                    				  # page #
detect 5,10,"~ [0-z]"                   				  # cust name
# set up document constants
local MAXCOLS=81                       				  # max cols to output
local MAXRCOLS=80                    			         # MAXCOLS-1
local LEFTCOL=1                    				  # left vertical line
local RIGHTCOL=MAXCOLS                     			  # right vertical line
local MAXROWS=66                       				  # max rows to output
cols MAXCOLS                      					  # max output columns
rows MAXROWS                    				         # max output rows
local VENDOR_COPY=1
local FILE_COPY=2
local MAX_COPIES=2
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                                			         # graphical shading
title "Purchase Order - laser"           				  # view in pdf properties
# shift down 1 for more room at top
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,1,2
# default detail line
local BROW=25
local EROW=50
cfont 2,BROW,5,EROW,DCFONT              				   # line #
cfont 7,BROW,26,EROW,DBFONT             				   # item #
cfont 28,BROW,33,EROW,DCFONT               			   # uom
cfont 35,BROW,46,EROW,DBRFONT               			   # price
cfont 49,BROW,61,EROW,DBRFONT                  			   # qty ord
cfont 64,BROW,MAXRCOLS,EROW,DBRFONT           			   # ext
# header section
cerase 1,1,MAXCOLS,9
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "zMrg Form Header"
# Invoice block
cbox 60,4.5,RIGHTCOL,9.5,1,ccols=72::ISHADE,crows=5.5 6.5 7.5 8.5
text 61,5,"PO Number",IFONT
text 61,6,"PO Date",IFONT
text 61,7,"Req'd Ship Date",IFONT
text 61,8,"Location",IFONT
text 61,9,"Page",IFONT
text 73,5,{trim(get(54,4,8))},DBFONT
text 73,6,{trim(get(65,4,10))},DBFONT
text 73,7,{trim(get(54,7,10))},DBFONT
text 73,8,{trim(get(66,7,6))},DBFONT
text 73,9,{trim(get(75,7,3))},DBFONT
# vendor address
cmove 5,16,MAXRCOLS,19,6,16
cmove 42,16,MAXRCOLS,19,45,16
cbox LEFTCOL,10,RIGHTCOL,20,MBOXSIZE,ccols=5::ISHADE 40 44::ISHADE
text 2,11,"V\ne\nn\nd\no\nr",ICFONT,cols=3,fit
cfont 6,11,39,19,DBLFONT                 				   # vend addr
text 40,11,"S\nh\ni\np\n\nT\no",ICFONT,cols=5,fit
cfont 45,11,MAXRCOLS,19,DBFONT         				   # ship to addr
# ribbon info
cbox LEFTCOL,20,RIGHTCOL,23,MBOXSIZE,crows=21.5::ISHADE,  ccols=21 40 59
text 1,21,"Ordered By",ICFONT,cols=20
text 22,21,"Ship Via",ICFONT,cols=18
text 41,21,"F.O.B.",ICFONT,cols=18
text 60,21,"Terms Description",ICFONT,cols=19
cfont 1,22,20,22,DBCFONT
cfont 22,22,39,22,DBCFONT
cfont 41,22,58,22,DBCFONT
cfont 60,22,79,22,DBCFONT
# line detail
cbox LEFTCOL,23,RIGHTCOL,51,MBOXSIZE,crows=24.5::DSHADE,ccols=6 34 47 62
text 2,24,"Entry #",ICFONT,cols=4
text 7,24,"Item ID",IFONT
text 28,24,"U/M",ICFONT,cols=6
text 35,24,"Unit Price",IRFONT,cols=12
text 49,24,"Ordered Quantity",IRFONT,cols=13
text 64,24,"Extension",IRFONT,cols=16
# description
font " @2,24,2,50",5,0,54,1,DFONT            			   # description
#shade lines
shade "~[0-9][0-9][0-9]@2,25,4,50",-.5,0,80,1,DSHADE		   # shade lines
# req date
font "Req Date",0,0,19,1,DBRFONT          			   # req date
# recd
font "Recd",0,0,6,1,DFONT,BLACK
font "Recd",7,0,13,1,DBRFONT
# bk ord
font "Bk Ord",0,0,6,1,DFONT,BLACK
font "Bk Ord",7,0,13,1,DBRFONT
# watermark - large font with light shading
WATERMARK 1,50.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# message area
cbox LEFTCOL,51,RIGHTCOL,53,MBOXSIZE
cfont 1,52,48,52,IFONT
cfont 50,52,60,52,DBRFONT
cfont 63,52,MAXRCOLS,52,DBRFONT
# sub totals
cbox LEFTCOL,53,RIGHTCOL,56,MBOXSIZE,crows=54.5::HSHADE,ccols=15 30 45 60
text 1,54,"Tax",HRFONT,cols=13
text 16,54,"Freight",HRFONT,cols=13
text 31,54,"Miscellaneous",HRFONT,cols=13
text 46,54,"Prepaid",HRFONT,cols=13
text 61,54,"Grand Total",HBRFONT,cols=19
cfont 1,55,13,55,DBRFONT
cfont 16,55,28,55,DBRFONT
cfont 31,55,43,55,DBRFONT,black
cfont 46,55,58,55,DBRFONT,black
cfont 61,55,MAXRCOLS,55,DBRFONT,fit
# approval line
cbox 55,60,RIGHTCOL,60
text 55.5,60.75,"Received by",HFONT
cbox 55,64,MAXCOLS,64
text 55.5,64.75,"Authorized Signature",HFONT
text 1,{MAXROWS+.5},{copy_title$[copy]},IBCFONT,cols=MAXCOLS
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="purchase order"
	prepage {
	noarchive=1
	earc$="EARC_PURCHORDER",doing_recat=0
	earca_formtype$="laser"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(54,4,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_PURCHORDER"	# Y/N Switch from global section
		bcod_Copies$="2"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docTy$="PORD"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docTy$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=54			# adjust as needed
	local XOFYM_ROW  	=4				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(54,4,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="P.O."
		# Method 6: Address entity ID for lookup
		eAddrEnt$="ven-"+lower(get(6,10,30,"y"))
		# no vendor ID, just name!
		pp=pos(" "=eAddrEnt$); if pp eAddrEnt$=pad(eAddrEnt$,pp-1)
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=12,logorows=7
	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]="File Copy"
	doc_title$="PURCHASE ORDER"
	merge "zMrg get watermark text"
}
prepage {
	xcol=0,xrow=0
	merge "zMrg get company info"
}
[PO_PurchOrder8.5x11]
dsn_sample "/u0/unform_test/_oem/osas/txt7/po_8.5x11.txt"
detect 53,3,"~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]   DATEMASK"
detect 75,6,"~[0-9]"                    		   		# page #
detect 5,9,"~ [0-z]"                    		   		# cust name
# set up document constants
local MAXCOLS=81                        		   		# max cols to output
local MAXRCOLS=80                     		   		# MAXCOLS-1
local LEFTCOL=1                   			   		# left vertical line
local RIGHTCOL=MAXCOLS                    	   		# right vertical line
local MAXROWS=66                     		   		# max rows to output
cols MAXCOLS                        		   		# max output columns
rows MAXROWS                     			   		# max output rows
local VENDOR_COPY=1
local FILE_COPY=2
local MAX_COPIES=2
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
# #GSON                            		        		# graphical shading
title "Purchase Order - 8.5 x 11"                 		# view in pdf properties
# shift down 1 for more room at top
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,1,3
# header section
cerase 1,1,MAXCOLS,9
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "zMrg Form Header"
# Invoice block
cbox 60,4.5,RIGHTCOL,9.5,1,ccols=72::ISHADE,crows=5.5 6.5 7.5 8.5
text 61,5,"PO Number",IFONT
text 61,6,"PO Date",IFONT
text 61,7,"Req'd Ship Date",IFONT
text 61,8,"Location",IFONT
text 61,9,"Page",IFONT
text 73,5,{trim(get(54,3,8))},DBFONT
text 73,6,{trim(get(65,3,10))},DBFONT
text 73,7,{trim(get(54,6,10))},DBFONT
text 73,8,{trim(get(66,6,6))},DBFONT
text 73,9,{trim(get(75,6,3))},DBFONT
# vendor address
cmove 5,16,MAXRCOLS,19,6,16
cmove 42,16,MAXRCOLS,19,45,16
cbox LEFTCOL,10,RIGHTCOL,20,MBOXSIZE,ccols=8::ISHADE 40 47::ISHADE
text 1,11,"Vendor",ICFONT,cols=8,fit
cmove 6,11,39,19,9,11
cfont 9,11,42,19,DBLFONT             		     		# vend addr
text 40,11,"Ship To",ICFONT,cols=8,fit
cmove 45,11,MAXRCOLS,19,48,11
cfont 48,11,MAXRCOLS,19,DBFONT         		     		# ship to addr
# zip bar
#barcode 48,16,{shipzip$},900,12.0,2
# ribbon info
cbox LEFTCOL,20,RIGHTCOL,23,MBOXSIZE,crows=21.5::ISHADE,  ccols=21 40 59
text 1,21,"Ordered By",ICFONT,cols=20
text 22,21,"Ship Via",ICFONT,cols=18
text 41,21,"F.O.B.",ICFONT,cols=18
text 60,21,"Terms Description",ICFONT,cols=19
cfont 1,22,20,22,DBCFONT
cfont 22,22,39,22,DBCFONT
cfont 41,22,58,22,DBCFONT
cfont 60,22,79,22,DBCFONT
# line detail
cbox LEFTCOL,23,RIGHTCOL,51,MBOXSIZE,crows=24.5::DSHADE,ccols=6 28 33 47 62
text 2,24,"Entry #",ICFONT,cols=4
text 7,24,"Item ID",IFONT
text 28,24,"U/M",ICFONT,cols=6
text 35,24,"Unit Price",IRFONT,cols=12
text 49,24,"Ordered Quantity",IRFONT,cols=13
text 64,24,"Extension",IRFONT,cols=16
# default detail line
local BROW=25
local EROW=50
cfont 2,BROW,5,EROW,DCFONT            		     		# line #
cfont 7,BROW,26,EROW,DBFONT              		     		# item #
cfont 28,BROW,33,EROW,DCFONT                        		# uom
cfont 35,BROW,46,EROW,DBRFONT                 	     		# price
cfont 49,BROW,61,EROW,DBRFONT                 	     		# qty ord
cfont 64,BROW,MAXRCOLS,EROW,DBRFONT        	     		# ext
# move for shading
cmove 1,23,80,48,1,24
# shade item lines
shade "~[0-9][0-9][0-9]@2,23,4,50",-.5,0,80,1,DSHADE
# description
font " @2,23,2,50",5,0,54,1,DFONT             	    		# description
# req date
font "Req Date",0,0,19,1,DBRFONT          	    		# req date
# watermark - large font with light shading
WATERMARK 1,50.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# message area
cbox LEFTCOL,51,RIGHTCOL,53,MBOXSIZE
cfont 1,52,48,52,IFONT
text 60,52,{trim(cut(50,50,17,""))+":"},IRFONT,cols=14
cfont 68,52,MAXRCOLS,52,DBRFONT
# sub totals
cbox LEFTCOL,53,RIGHTCOL,56,MBOXSIZE,crows=54.5::HSHADE,ccols=15 30 45 60
text 1,54,"Tax",IRFONT,cols=13
text 16,54,"Freight",IRFONT,cols=13
text 31,54,"Miscellaneous",IRFONT,cols=13
text 46,54,"Prepaid",IRFONT,cols=13
text 61,54,"Grand Total",IBRFONT,cols=19
cfont 1,55,13,55,DBRFONT
cfont 16,55,28,55,DBRFONT
cfont 31,55,43,55,DBRFONT,black
cfont 46,55,58,55,DBRFONT,black
cfont 61,55,MAXRCOLS,55,DBRFONT,fit
# approval line
cbox 55,60,RIGHTCOL,60
text 55.5,60.75,"Received by",HFONT
cbox 55,64,MAXCOLS,64
text 55.5,64.75,"Authorized Signature",HFONT
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="purchase order"
	prepage {
	noarchive=1
	earc$="EARC_PURCHORDER",doing_recat=0
	earca_formtype$="8.5x11"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(54,3,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_PURCHORDER"	# Y/N Switch from global section
		bcod_Copies$="2"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docTy$="PORD"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docTy$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
# barcodes were was 16.0,5
	}
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=54			# adjust as needed
	local XOFYM_ROW  	=3				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(54,3,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="P.O."
		# Method 6: Address entity ID for lookup
		eAddrEnt$="ven-"+lower(get(6,9,30,"y"))
		# no vendor ID, just name!
		pp=pos(" "=eAddrEnt$); if pp eAddrEnt$=pad(eAddrEnt$,pp-1)
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=12,logorows=7
	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]="File Copy"
	doc_title$="PURCHASE ORDER"
	merge "zMrg get watermark text"
}
prepage {
	xcol=0,xrow=0
	merge "zMrg get company info"
	
	# add zip barcode
	xrow=12;xcols=40
	#merge "zmrg get zip"
}
[PO_PurchOrderPlain]
dsn_sample "/u0/unform_test/_oem/osas/txt7/po_laserplain.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/po_plain.txt"
detect 0,1,"Purchase Order"
# set up document constants
local MAXCOLS=113                      			# max cols to output
local MAXRCOLS=112                  			# MAXCOLS-1
local LEFTCOL=1                    			# left vertical line
local RIGHTCOL=MAXCOLS                			# right vertical line
local MAXROWS=66                 		       	# max rows to output
	
cols MAXCOLS                      				# max output columns
rows MAXROWS                     		       	# max output rows
page MAXROWS                    		       	# no form feeds
local VENDOR_COPY=1
local FILE_COPY=2
local MAX_COPIES=2
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                              					# graphical shading
title "Purchase Order - plain"             	       	# view in pdf properties
# shift over 1 for more room on left
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,2,1
# default detail line
cerase LEFTCOL,22,MAXCOLS,22
cerase LEFTCOL,24,MAXCOLS,24
cbox LEFTCOL,22,RIGHTCOL,{sub_line},MBOXSIZE,crows=24::DSHADE,  ccols=6 50 62 68 81 95
local BROW=23
local EROW=23
cfont 2,BROW,5,EROW,ICFONT              				# line #
cfont 7,BROW,49,EROW,ILFONT                     		# item #
cfont 51,BROW,61,EROW,IRFONT                    		# price
cfont 62,BROW,68,EROW,ICFONT                    		# units
cfont 69,BROW,80,EROW,IRFONT                    		# qty ord
cfont 82,BROW,94,EROW,IRFONT                    		# qty rcvd
cfont 96,BROW,MAXRCOLS,EROW,IRFONT              		# b/o
local BROW=25
local EROW=51
cfont 2,BROW,5,EROW,DLFONT                      		# line #
cfont 7,BROW,41,EROW,DBFONT                      		# item #
cfont 42,BROW,50,EROW,DBRFONT						# req date
cfont 51,BROW,61,EROW,DBRFONT                    		# price
cfont 62,BROW,67,EROW,DRFONT                    		# units
cfont 69,BROW,80,EROW,DBRFONT                    		# qty ord
cfont 82,BROW,94,EROW,DBRFONT                    		# qty rcvd
cfont 96,BROW,MAXRCOLS,EROW,DBRFONT              		# b/o
# header section
cerase 1,1,MAXCOLS,9
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# PO block
cbox 85,5.5,MAXCOLS,8.5,1,ccols=101::ISHADE,crows=6.5 7.5
text 86,6,"PO Number",IFONT
text 86,7,"Page",IFONT
text 86,8,"Req'd Ship Date",IFONT
text 102,6,{trim(get(69,4,10))},DBFONT
text 102,7,{trim(get(83,4,10))},DBFONT
text 102,8,{trim(get(69,7,14))},DBFONT
# ribbon info
cerase LEFTCOL,12,RIGHTCOL,12
cbox LEFTCOL,9,RIGHTCOL,12,MBOXSIZE,crows=10.5::ISHADE,  ccols=12 33 44 69
cfont 2,10,11,10,ICFONT
cfont 13,10,32,10,ICFONT
cfont 34,10,43,10,ICFONT
cfont 45,10,67,10,ICFONT
cfont 69,10,MAXCOLS,10,ICFONT
cfont 2,11,11,11,DBCFONT
cfont 13,11,32,11,DBCFONT
cfont 34,11,43,11,DBCFONT
cfont 45,11,67,11,DBCFONT
cfont 69,11,MAXRCOLS,11,DBCFONT
# vendor address
cmove 12,20,MAXRCOLS,21,13,20
cmove 49,20,MAXRCOLS,21,62,20
cbox LEFTCOL,12,MAXCOLS,22,MBOXSIZE,ccols=12::ISHADE 50 61::ISHADE
cerase 3,13,10,21,ICFONT
cfont 13,13,49,21,DBFONT                       			# vend addr
cerase 51,13,60,21,ICFONT
cfont 62,13,MAXRCOLS,21,DBFONT                 			# ship to addr
text 2,14, "Vendor",ICFONT, cols=10
text 51,14, "Ship \nto",ICFONT, cols =10
# zip bar
#barcode 62,18,{shipzip$},900,12.0,2
# watermark - large font with light shading
WATERMARK 1,51.25,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# sub totals
cerase LEFTCOL,55,RIGHTCOL,55
cbox "Subtotal@1,53",-6,-1,RIGHTCOL,55,MBOXSIZE,crows=53.5::HSHADE
box "Subtotal@1,53",9,-1,1,3
box "Tax@1,53",4,-1,1,3
box "Freight@1,53",8,-1,1,3
box "Misc.@1,53",6,-1,1,3
box "Prepaid@1,53",8,-1,1,3
#box "Total@1,53",6,-1,1,3
font "Subtotal@1,53",0,0,9,1,IRFONT
font "Tax@1,53",0,0,4,1,IRFONT
font "Freight@1,53",0,0,8,1,IRFONT
font "Misc.@1,53",0,0,6,1,IRFONT,black
font "Prepaid@1,53",0,0,8,1,IRFONT,black
font "Total@1,53",0,0,27,1,IRFONT,black
font "Subtotal@1,53",-4,1,13,1,DBRFONT
font "Tax@1,53",-10,1,14,1,DBRFONT
font "Freight@1,53",-6,1,14,1,DBRFONT
font "Misc.@1,53",-8,1,14,1,DBRFONT
font "Prepaid@1,53",-6,1,14,1,DBRFONT
font "Total@1,53",-9,1,36,1,DBRFONT
# message area
cbox LEFTCOL,55,MAXCOLS,MAXROWS,MBOXSIZE
cfont 2,56,10,56,IFONT
cfont 12,56,60,56,IFONT
cfont 2,57,60,65,IFONT
# shade lines
shade "~[0-9][0-9][0-9]@2,25,4,51",-.5,0,112,1,DSHADE
# description
font " @2,25,2,51",5,0,70,1,DLFONT
# approval line
cerase 61,56,RIGHTCOL,65
cbox 65,58,MAXRCOLS,58
text 65.5,58.75,"Received by",HCFONT,cols=45
cbox 65,62,MAXRCOLS,62
text 65.5,62.75,"Authorized Signature",HCFONT,cols=45
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="purchase order"
	prepage {
	noarchive=1
	earc$="EARC_PURCHORDER",doing_recat=0
	earca_formtype$="plain"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(69,4,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_PURCHORDER"	# Y/N Switch from global section
		bcod_Copies$="2"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_Docty$="PORD"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_Docty$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=69			# adjust as needed
	local XOFYM_ROW  	=4				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(69,4,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="P.O."
		# Method 6: Address entity ID for lookup
		eAddrEnt$="ven-"+lower(get(12,14,30,"y"))
		# no vendor ID, just name!
		pp=pos(" "=eAddrEnt$); if pp eAddrEnt$=pad(eAddrEnt$,pp-1)
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=14,logorows=6
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then :
		copy_title$[VENDOR_COPY]="Vendor Copy"
	endif
	if MAX_COPIES>=2 then :
		copy_title$[FILE_COPY]="File Copy"
	endif
	doc_title$="PURCHASE ORDER"
	merge "zMrg get watermark text"
}
prepage {
	xcol=6,xrow=1
	merge "zMrg get company info"
	# add zip barcode
	xrow=17;xcols=40
	#merge "zmrg get zip"
	# continued?
	cont$="",sub_line=52
	for i=52 to MAXROWS
		x=pos("(continued"=text$[i])
		if x then :
			cont$="Continued"
			sub_line=55
			x$=set(x,i,30,"")
			break
		endif
	next i
}
[PO_PurchOrderStd]
dsn_sample "/u0/unform_test/_oem/osas/txt7/po_std.txt"
detect 68,1,"~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
detect 85,1,"~[0-9]"                   		 		# page #
detect 68,4,"~ DATEMASK"                 		 		# cust name
# set up document constants
local MAXCOLS=109                    	        		# max cols to output
local MAXRCOLS=108                 	        		# MAXCOLS-1
local LEFTCOL=1                    		 		# left vertical line
local RIGHTCOL=MAXCOLS                 	        		# right vertical line
local MAXROWS=66                       		 		# max rows to output
cols MAXCOLS                      			 		# max output columns
rows MAXROWS                       		 		# max output rows
local VENDOR_COPY=1
local FILE_COPY=2
local MAX_COPIES=2
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                                				# graphical shading
title "Purchase Order - Standard"               		# view in pdf properties
# shift down 1 for more room at top
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,2,4
# default detail line
cerase LEFTCOL,22,MAXCOLS,22
cerase LEFTCOL,24,MAXCOLS,24
cbox LEFTCOL,22,RIGHTCOL,{sub_line},MBOXSIZE,crows=24::DSHADE,  ccols=5.5 50 61 68 81 95
local BROW=22
local EROW=50
cfont 2,BROW,4,EROW,DCFONT                 			# line #
cfont 6,BROW,49,EROW,DBFONT                 			# item #
cfont 51,BROW,60,EROW,DBRFONT                 			# price
cfont 62,BROW,67,EROW,DCFONT               		       # units
cfont 69,BROW,80,EROW,DBRFONT                 		       # qty ord
cfont 82,BROW,94,EROW,DBRFONT               		       # qty rcvd
cfont 96,BROW,MAXRCOLS,EROW,DBRFONT       		       # b/o
# line detail
text 2,23,"Line",ICFONT,cols=3
text 7,23,"Item/Description",IFONT
text 51,23,"Unit Price",IRFONT,cols=10
text 62,23,"Units",IRFONT,cols=5
text 69,23,"Ordered",IRFONT,cols=12
text 82,23,"Received",IRFONT,cols=13
text 96,23,"Backordered",IRFONT,cols=13
# header section
cerase 1,1,MAXCOLS,9
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# PO block
cbox 84,5.5,MAXCOLS,8.5,1,ccols=99::ISHADE,crows=6.5 7.5
text 85,6,"PO Number",IFONT
text 85,7,"Page",IFONT
text 85,8,"Req'd Ship Date",IFONT
text 100,6,{trim(get(69,1,8))},DBFONT
text 100,7,{trim(get(83,1,3))},DBFONT
text 100,8,{trim(get(69,4,10))},DBFONT
# ribbon info
cerase LEFTCOL,12,RIGHTCOL,12
cbox LEFTCOL,9,RIGHTCOL,12,MBOXSIZE,crows=10.5::ISHADE,  ccols=12 33 44 69
text 2,10,"Ord. Date",ICFONT,cols=9
text 13,10,"Ordered By",ICFONT,cols=19
text 34,10,"Terms",ICFONT,cols=9
text 45,10,"F.O.B.",ICFONT,cols=22
text 69,10,"Ship Via",ICFONT,cols=40
cfont 2,11,11,11,DBCFONT
cfont 13,11,32,11,DBCFONT
cfont 34,11,43,11,DBCFONT
cfont 45,11,67,11,DBCFONT
cfont 69,11,MAXRCOLS,11,DBCFONT
# vendor address
cmove 12,20,MAXRCOLS,21,13,20
cmove 49,20,MAXRCOLS,21,62,20
cmove 13,13,49,21,22,13
cbox LEFTCOL,12,MAXCOLS,22,MBOXSIZE,ccols=10::ISHADE 50 59::ISHADE
text 6,14,"Vendor",ICFONT
cmove 13,13,49,21,11.5,13
cfont 11.5,13,47,21,DBLFONT                    			# vend addr
text 55,14,"Ship To",ICFONT
cmove 62,13,MAXRCOLS,21,60.5,13
cfont 60.5,13,MAXRCOLS,21,DBFONT              			# ship to addr
# zip bar
#barcode 60.5,18,{shipzip$},900,12.0,2
# line detail
# description
font " @2,24,2,51",5,0,77,1,DFONT             			# description
# watermark - large font with light shading
WATERMARK 1,51.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# shade lines
shade "~[0-9][0-9][0-9]@2,24,4,51",-.5,0,108,1,DSHADE
# sub totals
cbox "Subtotal@1,53",-6,-.5,RIGHTCOL,55.5,MBOXSIZE,crows=54.5::HSHADE
box "Subtotal@1,53",9,-.5,1,2
box "Tax@1,53",4,-.5,1,2
box "Freight@1,53",8,-.5,1,2
box "Misc.@1,53",6,-.5,1,2
box "Prepaid@1,53",13,-.5,1,2
font "Subtotal@1,53",0,0,9,1,IRFONT
font "Tax@1,53",0,0,4,1,IRFONT
font "Freight@1,53",0,0,8,1,IRFONT
font "Misc.@1,53",0,0,6,1,IRFONT,black
font "Prepaid@1,53",0,0,13,1,IRFONT,black
font "Total@1,53",0,0,23,1,IRFONT,black
font "Subtotal@1,53",-4,1,13,1,DBRFONT
font "Tax@1,53",-10,1,14,1,DBRFONT
font "Freight@1,53",-6,1,14,1,DBRFONT
font "Misc.@1,53",-8,1,14,1,DBRFONT
font "Prepaid@1,53",-6,1,19,1,DBRFONT
font "Total@1,53",-3,1,26,1,DBRFONT
# message area
cbox LEFTCOL,55.5,MAXCOLS,MAXROWS,MBOXSIZE
cfont 2,56,10,56,IFONT
cfont 12,56,60,56,IFONT
cfont 2,57,60,65,IFONT
# approval line
cerase 61,56,RIGHTCOL,65
cbox 65,58,MAXRCOLS,58
text 65.5,58.75,"Received by",HCFONT,cols=45
cbox 65,62,MAXRCOLS,62
text 65.5,62.75,"Authorized Signature",HCFONT,cols=45
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="purchase order"
	prepage {
	noarchive=1
	earc$="EARC_PURCHORDER",doing_recat=0
	earca_formtype$="std"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(69,1,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_PURCHORDER"	# Y/N Switch from global section
		bcod_Copies$="2"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docty$="PORD"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docty$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=69			# adjust as needed
	local XOFYM_ROW  	=1				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(69,1,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="P.O."
		# Method 6: Address entity ID for lookup
		eAddrEnt$="ven-"+lower(get(12,11,30,"y"))
		# no vendor ID, just name!
		pp=pos(" "=eAddrEnt$); if pp eAddrEnt$=pad(eAddrEnt$,pp-1)
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# Control which copy prints rather than delivers, see pcopy$ variable
	# remark this to ALWAYS 'PRINT' ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=14,logorows=6
	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]="File Copy"
	doc_title$="PURCHASE ORDER"
	merge "zMrg get watermark text"
}
prepage {
	xcol=0,xrow=0
	merge "zMrg get company info"
	
	# add zip barcode
	xrow=14;xcols=40
	#merge "zmrg get zip"
	# continued?
	cont$="",sub_line=52
	for i=52 to MAXROWS
		x=pos("(continued"=text$[i])
		if x then :
			cont$="Continued"
			sub_line=55
			x$=set(x,i,30,"")
			break
		endif
	next i
}
[PR_CheckLaser]
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/chklaser/pr_laser_checks.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/pr_laser_checks.txt"
detect 0,8,"~ DATEMASK"
detect 0,22,"~ [0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]/[0-9][0-9]/[0-9][0-9] "
detect 0,1,"!D I R E C T   D E P O S I T   V O U C H E R"
# set up document constants
local MAXCOLS=81
local MAXRCOLS=80
local MAXROWS=66
local LEFTCOL=1                     			    # left vertical line
local RIGHTCOL=MAXCOLS                    		    # right vertical line
cols MAXCOLS
rows MAXROWS
# copy 2 is for summary
local MAX_COPIES=2
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                                			    # graphical shading
title "PR Check - laser"             			    # view in pdf properties
prejob {
	logocols=10,logorows=5
}
prepage {
	dtype$=get(1,1,MAXCOLS,"Y")
	if dtype$="" then :
		# check
		docdate$=get(53,8,8,"Y")
	else
		# summary
		docdate$=get(36,3,10,"Y")
	endif
}
precopy {
	# Summary?
	xtype$=trim(get(1,1,20))
	if copy=1 and xtype$<>"" then skip=1
	if copy=2 and xtype$="" then skip=1
	if copy=2 and not(skip) then :
		docdate$=get(36,3,10,"Y",1)
	endif
}
# make space on left
cmove 1,1,MAXCOLS,MAXROWS,2,1
if copy 1
	# first adjust format to standard
	cmove 1,20,MAXCOLS,60,1,22
	cerase 1,1,30,6
	# Check
	LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
	cbox LEFTCOL,1,RIGHTCOL,17.75,MBOXSIZE
	text 15,2.25,"COMP_NAME",HBFONT,14
	text 15,3.35,"COMP_ADDR1",HFONT,12
	text 15,4.35,"COMP_ADDR2",HFONT,12
	text 15,5.35,"COMP_ADDR3",HFONT,12
	text 49,2.25,"PR_BANK_NAME",DBFONT
	text 49,3.05,"PR_BANK_ADDR1",DFONT
	text 49,3.85,"PR_BANK_ADDR2",DFONT
	text 70,3.35,"PR_ROUTING",DBFONT             	      # rtg #
	cmove 53,8,MAXCOLS,8,53,7
	cbox 44,5.5,RIGHTCOL,7.5,1,crows=6.5::100,ccols=52 63
	text 45,6,"Check #",ICFONT,10,cols=7,shade=0
	text 45,7,{trim(get(64,22,7))},DBCFONT,11,cols=7
	text 53,6,"Date",ICFONT,10,cols=10,shade=0
	cfont 53,7,62,7,DBCFONT,11
	text 64,6,"Amount",IRFONT,10,cols=17,shade=0
	cfont 64,7,MAXRCOLS,7,DBRFONT,11
	text 2,10,"Pay",IFONT,14
	text 7,10,{trim(cut(5,9,80,""))},DBFONT,italic,11,fit
	text 2,13,"Pay",IFONT
	text 2,14,"to the",IFONT
	text 2,15,"Order",IFONT
	text 2,16,"of",IFONT
	cmove 6,11,47,14,6,13
	cfont 7,13,51,16,DBFONT,11
	SIGNATURE_IMAGE 50,15,0,0,"SIGNATURE"
	box 50,16.25,30,1,3
	text 50,14.5,"Check Void After 180 Days",ICFONT,cols=30
	text 50,17,"Authorized Signature",ICFONT,cols=30
	PR_MICR 15,18.5,"PR_MICR_ACCOUNTNO",{trim(get(64,22,7))}
	# top stub - employee's
	cerase 1,22,30,22
	cbox LEFTCOL,21,MAXCOLS,21
	text 15,22,"COMP_NAME",HBFONT,12
	cbox LEFTCOL,22.5,MAXCOLS,24.5,MBOXSIZE,crows=23.5::DSHADE,  ccols=15 33 45 54 64
	cfont 2,23,14,23,ICFONT,proper
	cfont 16,23,32,23,ICFONT,proper
	cfont 34,23,44,23,ICFONT,proper
	cfont 46,23,53,23,ICFONT,proper
	cfont 55,23,63,23,ICFONT,proper
	cfont 65,23,MAXRCOLS,23,ICFONT,proper
	cfont 2,24,14,24,DBCFONT
	cfont 16,24,32,24,DBCFONT
	cfont 34,24,44,24,DBCFONT
	cfont 46,24,53,24,DBCFONT
	cfont 55,24,63,24,DBCFONT
	cfont 65,24,MAXRCOLS,24,DBCFONT
	cbox LEFTCOL,24.5,MAXCOLS,38.5,MBOXSIZE,crows=25.5::DSHADE,  ccols=14 23 34 47 60 70
	cfont 2,25,13,25,IFONT,proper
	cfont 14,25,22,25,IRFONT,black,proper
	cfont 24,25,33,25,IRFONT,proper
	cfont 35,25,46,25,IRFONT,proper
	cfont 48,25,59,25,IFONT,proper
	cfont 61,25,69,25,IRFONT,proper
	cfont 71,25,MAXRCOLS,25,IRFONT,proper
	cfont 2,26,13,35,DFONT
	cfont 14,26,22,35,DBRFONT,black
	cfont 24,26,33,35,DBRFONT
	cfont 35,26,46,35,DBRFONT
	cfont 48,26,59,38,DFONT
	cfont 61,26,69,38,DBRFONT
	cfont 71,26,MAXRCOLS,38,DBRFONT
	text 2,36,{mcut(1,34,15,2,"","Y","Y")},IBFONT
	text 14,36,{mcut(17,34,9,2,"","Y","Y")},DBRFONT,cols=9
	cbox LEFTCOL,38.5,MAXCOLS,40.5,MBOXSIZE,crows=39.5::100,  ccols=13 25 37 48 60 71
	cfont 2,39,12,39,IFONT,shade=0
	cfont 14,39,24,39,IRFONT,shade=0
	cfont 26,39,36,39,IRFONT,shade=0
	cfont 38,39,47,39,IRFONT,shade=0
	cfont 49,39,59,39,IRFONT,shade=0
	cerase 61,39,MAXCOLS,39
	text 61,39,"YTD Ded",IRFONT,shade=0,cols=10
	text 72,39,"YTD Net Pay",IRFONT,shade=0,cols=9
	cfont 2,40,12,40,DBFONT
	cfont 14,40,24,40,DBRFONT
	cfont 26,40,36,40,DBRFONT
	cfont 38,40,47,40,DBRFONT
	cfont 49,40,59,40,DBRFONT
	cfont 61,40,70,40,DBRFONT
	cfont 72,40,MAXRCOLS,40,DBRFONT
	# Bottom stub - employer's
	cerase 1,43,30,43
	cbox LEFTCOL,42,MAXCOLS,42
	text 15,43,"COMP_NAME",HBFONT,12
	cbox LEFTCOL,43.5,MAXCOLS,45.5,MBOXSIZE,crows=44.5::DSHADE,  ccols=15 33 45 54 64
	cfont 2,44,14,44,ICFONT,proper
	cfont 16,44,32,44,ICFONT,proper
	cfont 34,44,44,44,ICFONT,proper
	cfont 46,44,53,44,ICFONT,proper
	cfont 55,44,63,44,ICFONT,proper
	cfont 65,44,MAXRCOLS,44,ICFONT,proper
	cfont 2,45,14,45,DBCFONT
	cfont 16,45,32,45,DBCFONT
	cfont 34,45,44,45,DBCFONT
	cfont 46,45,53,45,DBCFONT
	cfont 55,45,63,45,DBCFONT
	cfont 65,45,MAXRCOLS,45,DBCFONT
	cbox LEFTCOL,45.5,MAXCOLS,59.5,MBOXSIZE,crows=46.5::DSHADE,  ccols=14 23 34 47 60 70
	cfont 2,46,13,46,IFONT,proper
	cfont 14,46,22,46,IRFONT,black,proper
	cfont 24,46,33,46,IRFONT,proper
	cfont 35,46,46,46,IRFONT,proper
	cfont 48,46,59,46,IFONT,proper
	cfont 61,46,69,46,IRFONT,proper
	cfont 71,46,MAXRCOLS,46,IRFONT,proper
	cfont 2,47,13,56,DFONT
	cfont 14,47,22,56,DBRFONT,black
	cfont 24,47,33,56,DBRFONT
	cfont 35,47,46,56,DBRFONT
	cfont 48,47,59,59,DFONT
	cfont 61,47,69,59,DBRFONT
	cfont 71,47,MAXRCOLS,59,DBRFONT
	text 2,57,{mcut(1,55,15,2,"","Y","Y")},IBFONT
	text 14,57,{mcut(17,55,9,2,"","Y","Y")},DBRFONT,cols=9
	cbox LEFTCOL,59.5,MAXCOLS,61.5,MBOXSIZE,crows=60.5::100,  ccols=13 25 37 48 60 71
	cfont 2,60,12,60,IFONT,shade=0
	cfont 14,60,24,60,IRFONT,shade=0
	cfont 26,60,36,60,IRFONT,shade=0
	cfont 38,60,47,60,IRFONT,shade=0
	cfont 49,60,59,60,IRFONT,shade=0
	cerase 61,60,MAXCOLS,60
	text 61,60,"YTD Ded",IRFONT,shade=0,cols=10
	text 72,60,"YTD Net Pay",IRFONT,shade=0,cols=9
	cfont 2,61,12,61,DBFONT
	cfont 14,61,24,61,DBRFONT
	cfont 26,61,36,61,DBRFONT
	cfont 38,61,47,61,DBRFONT
	cfont 49,61,59,61,DBRFONT
	cfont 61,61,70,61,DBRFONT
	cfont 72,61,MAXRCOLS,61,DBRFONT
end if
# summary copy
if copy 2
	# title
	text 1,2,"Payroll Check Summary",HBCFONT,cols=MAXRCOLS,14
	# summary
	text 25,6,{mcut(14,1,21,7,"","Y","Y")},HBFONT
	text 58,6,{mcut(36,1,13,7,"","Y","Y")},DBRFONT,11
	# end of report
	text 2,15,{cut(1,10,13,"")},HBCFONT,cols=MAXRCOLS
end if
# ----------------------------------------------------------------------
prepage {
	# needed prior to archiving
	dtype$=get(1,1,MAXCOLS,"Y")
	if dtype$="" arcdtype$="check" else arcdtype$="summary"
}
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="prcheck"
	prepage {
	noarchive=1
	earc$="EARC_PRCHECK",doing_recat=0
	earca_formtype$="laser"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=10,logorows=5
}
prepage {
	if dtype$="" then :
		# check
		docdate$=get(53,8,8,"Y")
	else
		# summary
		docdate$=get(36,3,10,"Y")
	endif
}
precopy {
	# Summary?
	xtype$=trim(get(1,1,20))
	if copy=1 and xtype$<>"" then skip=1
	if copy=2 and xtype$="" then skip=1
	if copy=2 and not(skip) then :
		docdate$=get(36,3,10,"Y",1)
	endif
}
[PR_CheckBlank]
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/chkblank/pr_blank_checks.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/pr_blank_checks.txt"
detect 0,10,"~ DATEMASK"
detect 0,24,"~ [0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]/[0-9][0-9]/[0-9][0-9] "
detect 0,1,"!D I R E C T   D E P O S I T   V O U C H E R"
# set up document constants
local MAXCOLS=81
local MAXRCOLS=80
local MAXROWS=66
local LEFTCOL=1                     			      # left vertical line
local RIGHTCOL=MAXCOLS                       		      # right vertical line
cols MAXCOLS
rows MAXROWS
page 42
# copy 2 is for summary
local MAX_COPIES=2
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                               			     # graphical shading
title "PR Check - blank"           			     # view in pdf properties
# make space on left
cmove 1,1,MAXCOLS,MAXROWS,2,1
if copy 1
	# make room on left
	cmove 1,1,MAXCOLS,MAXROW,2,1
	# Check
	cerase 1,1,MAXCOLS,20
	LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
	cbox LEFTCOL,1,RIGHTCOL,17.75,MBOXSIZE
	text 15,2.25,"COMP_NAME",HBFONT,14
	text 15,3.35,"COMP_ADDR1",HFONT,12
	text 15,4.35,"COMP_ADDR2",HFONT,12
	text 15,5.35,"COMP_ADDR3",HFONT,12
	text 49,2.25,"PR_BANK_NAME",DBFONT
	text 49,3.05,"PR_BANK_ADDR1",DFONT
	text 49,3.85,"PR_BANK_ADDR2",DFONT
	text 70,3.35,"PR_ROUTING",DBFONT               		# rtg #
	cbox 44,5.5,RIGHTCOL,7.5,1,crows=6.5::100,ccols=52 63
	text 45,6,"Check #",ICFONT,10,cols=7,shade=0
	text 45,7,{checkno$},DBCFONT,11,cols=7
	text 53,6,"Date",ICFONT,10,cols=10,shade=0
	text 53,7,{docdate$},DBCFONT,11,cols=10
	text 64,6,"Amount",IRFONT,10,cols=17,shade=0
	text 64,7,{chkamt$},DBRFONT,11,cols=17
	text 2,10,"Pay",IFONT,14
	text 7,10,{chktextamt$},DBFONT,italic,11,fit
	text 2,13,"Pay",IFONT
	text 2,14,"to the",IFONT
	text 2,15,"Order",IFONT
	text 2,16,"of",IFONT
	text 7,13,{emp$},DBFONT,11
	SIGNATURE_IMAGE 50,15,0,0,"SIGNATURE"
	box 50,16.25,30,1,3
	text 50,14.5,"Check Void After 180 Days",ICFONT,cols=30
	text 50,17,"Authorized Signature",ICFONT,cols=30
	PR_MICR 15,18.5,"PR_MICR_ACCOUNTNO",{trim(get(64,22,7))}
	# top stub - employee's
	cerase 1,22,MAXCOLS,22
	cbox LEFTCOL,21,MAXCOLS,21
	text 15,22,"COMP_NAME",HBFONT,12
	cbox LEFTCOL,22.5,MAXCOLS,24.5,MBOXSIZE,crows=23.5::DSHADE,ccols=15 33 45 54 63
	local SROW=23
	cfont 2,SROW,14,SROW,ICFONT,proper
	cfont 16,SROW,32,SROW,ICFONT,proper
	cfont 34,SROW,43,SROW,ICFONT,proper
	cfont 45,SROW,53,SROW,ICFONT,proper
	cfont 55,SROW,62,SROW,ICFONT,proper
	cfont 64,SROW,MAXRCOLS,SROW,ICFONT,proper
	local SROW=24
	cfont 2,SROW,14,SROW,DBCFONT
	cfont 16,SROW,32,SROW,DBCFONT
	cfont 34,SROW,43,SROW,DBCFONT
	cfont 45,SROW,53,SROW,DBCFONT
	cfont 55,SROW,62,SROW,DBCFONT
	cfont 64,SROW,MAXRCOLS,SROW,DBCFONT
	cmove LEFTCOL,26,MAXCOLS,38,LEFTCOL,25
	cbox LEFTCOL,24.5,MAXCOLS,38.5,MBOXSIZE,crows=25.5::DSHADE,ccols=14 24 34 45 60 70
	local SROW=25
	cfont 2,SROW,13,SROW,IFONT,proper
	cfont 15,SROW,23,SROW,IRFONT,black,proper
	cfont 25,SROW,33,SROW,IRFONT,proper
	cfont 35,SROW,44,SROW,IRFONT,proper
	cfont 46,SROW,59,SROW,ILFONT,proper
	cfont 61,SROW,69,SROW,IRFONT,proper
	cfont 71,SROW,MAXRCOLS,SROW,IRFONT,proper
	local SROW=26
	local EROW=35
	cfont 2,SROW,13,EROW,DFONT
	cfont 15,SROW,23,EROW,DBRFONT,black
	cfont 25,SROW,33,EROW,DBRFONT
	cfont 35,SROW,44,EROW,DBRFONT
	local EROW=38
	cfont 46,SROW,59,EROW,DLFONT
	cfont 61,SROW,69,EROW,DBRFONT
	cfont 71,SROW,MAXRCOLS,EROW,DBRFONT
	text 2,36,{mget(1,36,13,2,"Y","Y")},IBFONT
	text 15,36,{mget(17,36,9,2,"Y","Y")},DBRFONT,cols=9
	cerase 1,36,14,37
	cerase 16,36,26,37
	cmove LEFTCOL,40,MAXCOLS,41,LEFTCOL,39
	cbox LEFTCOL,38.5,MAXCOLS,40.5,MBOXSIZE,crows=39.5::100,ccols=14 25 37 48 60 71
	local SROW=39
	cfont 2,SROW,13,SROW,IFONT,shade=0
	cfont 15,SROW,24,SROW,IRFONT,shade=0
	cfont 26,SROW,36,SROW,IRFONT,shade=0
	cfont 38,SROW,47,SROW,IRFONT,shade=0
	cfont 49,SROW,59,SROW,IRFONT,shade=0
	cerase 61,SROW,MAXCOLS,SROW
	text 61,SROW,"YTD Ded",IRFONT,shade=0,cols=10
	text 72,SROW,"YTD Net Pay",IRFONT,shade=0,cols=9
	local SROW=40
	cfont 2,SROW,13,SROW,DBFONT
	cfont 15,SROW,24,SROW,DBRFONT
	cfont 26,SROW,36,SROW,DBRFONT
	cfont 38,SROW,47,SROW,DBRFONT
	cfont 49,SROW,59,SROW,DBRFONT
	cfont 61,SROW,70,SROW,DBRFONT
	cfont 72,SROW,MAXRCOLS,SROW,DBRFONT
	# Bottom stub - employer's
	cerase 1,43,MAXCOLS,43
	cbox LEFTCOL,42,MAXCOLS,42
	text 15,43,"COMP_NAME",HBFONT,12
	cbox LEFTCOL,43.5,MAXCOLS,45.5,MBOXSIZE,crows=44.5::DSHADE,ccols=15 33 45 54 63
	local SROW=44
	cfont 2,SROW,14,SROW,ICFONT,proper
	cfont 16,SROW,32,SROW,ICFONT,proper
	cfont 34,SROW,43,SROW,ICFONT,proper
	cfont 45,SROW,53,SROW,ICFONT,proper
	cfont 55,SROW,62,SROW,ICFONT,proper
	cfont 64,SROW,MAXRCOLS,SROW,ICFONT,proper
	local SROW=45
	cfont 2,SROW,14,SROW,DBCFONT
	cfont 16,SROW,32,SROW,DBCFONT
	cfont 34,SROW,43,SROW,DBCFONT
	cfont 45,SROW,53,SROW,DBCFONT
	cfont 55,SROW,62,SROW,DBCFONT
	cfont 64,SROW,MAXRCOLS,SROW,DBCFONT
	cmove LEFTCOL,47,MAXCOLS,59,LEFTCOL,46
	cbox LEFTCOL,45.5,MAXCOLS,59.5,MBOXSIZE,crows=46.5::DSHADE,ccols=14 24 34 45 60 70
	local SROW=46
	cfont 2,SROW,13,SROW,IFONT,proper
	cfont 15,SROW,23,SROW,IRFONT,black,proper
	cfont 25,SROW,33,SROW,IRFONT,proper
	cfont 35,SROW,44,SROW,IRFONT,proper
	cfont 46,SROW,59,SROW,ILFONT,proper
	cfont 61,SROW,69,SROW,IRFONT,proper
	cfont 71,SROW,MAXRCOLS,SROW,IRFONT,proper
	local SROW=47
	local EROW=56
	cfont 2,SROW,13,EROW,DFONT
	cfont 15,SROW,23,EROW,DBRFONT,black
	cfont 25,SROW,33,EROW,DBRFONT
	cfont 35,SROW,44,EROW,DBRFONT
	local EROW=59
	cfont 46,SROW,59,EROW,DLFONT
	cfont 61,SROW,69,EROW,DBRFONT
	cfont 71,SROW,MAXRCOLS,EROW,DBRFONT
	text 2,57,{mget(1,57,13,2,"Y","Y")},IBFONT
	text 15,57,{mget(17,57,9,2,"Y","Y")},DBRFONT,cols=9
	cerase 1,57,14,58
	cerase 16,57,26,58
	cmove LEFTCOL,61,MAXCOLS,62,LEFTCOL,60
	cbox LEFTCOL,59.5,MAXCOLS,61.5,MBOXSIZE,crows=60.5::100,ccols=14 25 37 48 60 71
	local SROW=60
	cfont 2,SROW,13,SROW,IFONT,shade=0
	cfont 15,SROW,24,SROW,IRFONT,shade=0
	cfont 26,SROW,36,SROW,IRFONT,shade=0
	cfont 38,SROW,47,SROW,IRFONT,shade=0
	cfont 49,SROW,59,SROW,IRFONT,shade=0
	cerase 61,SROW,MAXCOLS,SROW
	text 61,SROW,"YTD Ded",IRFONT,shade=0,cols=10
	text 72,SROW,"YTD Net Pay",IRFONT,shade=0,cols=9
	local SROW=61
	cfont 2,SROW,13,SROW,DBFONT
	cfont 15,SROW,24,SROW,DBRFONT
	cfont 26,SROW,36,SROW,DBRFONT
	cfont 38,SROW,47,SROW,DBRFONT
	cfont 49,SROW,59,SROW,DBRFONT
	cfont 61,SROW,70,SROW,DBRFONT
	cfont 72,SROW,MAXRCOLS,SROW,DBRFONT
end if
# summary copy
if copy 2
	notext
	# title
	text 1,2,"Payroll Check Summary",HBCFONT,cols=MAXRCOLS,14
	# summary
	text 25,6,{mget(14,1,21,7,"Y","Y")},HBFONT
	text 58,6,{mget(36,1,13,7,"Y","Y")},DBRFONT,11
	# end of report
	text 2,15,{get(1,10,13,"Y")},HBCFONT,cols=MAXRCOLS
end if
# ----------------------------------------------------------------------
prepage {
	# needed prior to archiving
	dtype$=get(1,1,MAXCOLS,"Y")
	if dtype$="" arcdtype$="check" else arcdtype$="summary"
}
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="prcheck"
	prepage {
	noarchive=1
	earc$="EARC_PRCHECK",doing_recat=0
	earca_formtype$="blank"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=10,logorows=5
}
prepage {
	if dtype$="" then :
		# check
		checkno$=get(57,10,8,"Y")
		docid$=checkno$
		docdate$=get(46,10,8,"Y")
		chkamt$=get(65,10,15,"Y")
		chktextamt$=get(1,11,MAXCOLS,"Y")
		emp$=mget(6,14,40,4,"Y","Y")
	else
		# summary
		docid$=get(36,4,10,"Y")
		docdate$=get(36,3,10,"Y")
	endif
	for row=22 to 42
		text$[row+21]=text$[row]
	next row
}
precopy {
	# Summary?
	if copy=1 and dtype$<>"" then skip=1
	if copy=2 and dtype$="" then skip=1
	if copy=2 and not(skip) then :
		docdate$=get(36,3,8,"Y",1)
	endif
}
[PR_CheckPreprinted]
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/chkpreprinted/pr_preprinted_checks.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/pr_preprinted_checks.txt"
detect 0,27,"~ DATEMASK"
detect 0,2,"~ [0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]/[0-9][0-9]/[0-9][0-9] "
detect 0,1,"!D I R E C T   D E P O S I T   V O U C H E R"
# set up document constants
local MAXCOLS=81
local MAXRCOLS=80
local MAXROWS=66
local LEFTCOL=1                    	     	         # left vertical line
local RIGHTCOL=MAXCOLS                    	         # right vertical line
	
cols MAXCOLS
rows MAXROWS
page 42
# copy 2 is for summary
local MAX_COPIES=2
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                                			  # graphical shading
title "PR Check - preprinted"             		  # view in pdf properties
# make space on left
cmove 1,1,MAXCOLS,MAXROWS,2,2
if copy 1
	cerase 1,22,30,27
	# Check
	LOGO_IMAGE 1,22,10,5,"COMP_LOGO"
	cbox LEFTCOL,22,RIGHTCOL,38.75,MBOXSIZE
	text 15,23.25,"COMP_NAME",HBFONT,14
	text 15,24.35,"COMP_ADDR1",HFONT,12
	text 15,25.35,"COMP_ADDR2",HFONT,12
	text 15,26.35,"COMP_ADDR3",HFONT,12
	text 49,23.25,"PR_BANK_NAME",DBFONT
	text 49,24.05,"PR_BANK_ADDR1",DFONT
	text 49,24.85,"PR_BANK_ADDR2",DFONT
	text 70,24.35,"PR_ROUTING",DBFONT                # rtg #
	cbox 44,26.5,RIGHTCOL,28.5,1,crows=27.5::100,ccols=52 63
	text 45,27,"Check #",ICFONT,10,cols=7,shade=0
	text 45,28,{trim(get(63,2,7,""))},DBCFONT,11,cols=7
	text 53,27,"Date",ICFONT,10,cols=10,shade=0
	text 53,28,{trim(cut(58,27,8,""))},DBCFONT,11,cols=10
	text 64,27,"Amount",IRFONT,10,cols=17,shade=0
	cfont 64,28,MAXRCOLS,28,DBRFONT,11
	text 2,31,"Pay",IFONT,14
	text 7,31,{trim(cut(1,30,80,""))},DBFONT,italic,11,fit
	text 2,34,"Pay",IFONT
	text 2,35,"to the",IFONT
	text 2,36,"Order",IFONT
	text 2,37,"of",IFONT
	cmove 6,35,47,38,6,34
	cfont 7,34,51,37,DBFONT,11
	SIGNATURE_IMAGE 50,36,0,0,"SIGNATURE"
	box 50,37.25,30,1,3
	text 50,35.5,"Check Void After 180 Days",ICFONT,cols=30
	text 50,38,"Authorized Signature",ICFONT,cols=30
	PR_MICR 15,39.5,"PR_MICR_ACCOUNTNO",{trim(get(64,41,7))}
	# top stub - employee's
	cerase 1,2,30,2
	cbox LEFTCOL,21.5,MAXCOLS,21.5
	text 15,1,"COMP_NAME",HBFONT,12
	cbox LEFTCOL,1.5,MAXCOLS,3.5,MBOXSIZE,crows=2.5::DSHADE,  ccols=15 33 45 54 64
	text 2,2,"Emp No/Dept",ICFONT,cols=13
	text 16,2,"Employee Name",ICFONT,cols=17
	text 34,2,"SSN",ICFONT,cols=11
	text 46,2,"Per Beg",ICFONT,cols=8
	text 55,2,"Per End",ICFONT,cols=9
	text 65,2,"Ck No.",ICFONT,cols=16
	cfont 2,3,14,3,DBCFONT
	cfont 16,3,32,3,DBCFONT
	cfont 34,3,44,3,DBCFONT
	cfont 46,3,53,3,DBCFONT
	cfont 55,3,63,3,DBCFONT
	cfont 65,3,MAXRCOLS,3,DBCFONT
	cbox LEFTCOL,3.5,MAXCOLS,17.5,MBOXSIZE,crows=5.5::DSHADE,  ccols=14 24 34 47 60 70
	text 2,4.5,"Earnings",IFONT
	text 24,4.5,"Hrs/Units",IRFONT,black
	text 34,4.5,"Curr Amt",IRFONT
	text 47,4.5,"YTD",IRFONT
	text 48,4.5,"Deductions",IFONT
	text 70,4.5,"Curr Amt",IRFONT
	text 75,4.5,"YTD",IRFONT,cols=6
	cfont 2,6,13,15,DFONT
	cfont 14,6,23,15,DBRFONT,black
	cfont 24,6,33,15,DBRFONT
	cfont 35,6,46,15,DBRFONT
	cfont 48,6,59,18,DFONT
	cfont 61,6,69,18,DBRFONT
	cfont 71,6,MAXRCOLS,18,DBRFONT
	text 2,16,{mcut(1,16,13,2,"","Y","Y")},IBFONT
	text 15,16,{mcut(17,16,9,2,"","Y","Y")},DBRFONT,cols=9
	cbox LEFTCOL,18.5,MAXCOLS,20.5,MBOXSIZE,crows=19.5::100,  ccols=13 25 37 48 60 71
	text 2,19,"Pay Rate",IFONT,shade=0
	text 25,19,"Curr Earn",IRFONT,shade=0
	text 37,19,"Curr Ded",IRFONT,shade=0
	text 48,19,"Net Pay",IRFONT,shade=0
	text 60,19,"YTD Earn",IRFONT,shade=0
	text 61,19,"YTD Ded",IRFONT,shade=0,cols=10
	text 72,19,"YTD Net Pay",IRFONT,shade=0,cols=9
	cfont 2,20,12,20,DBFONT
	cfont 14,20,24,20,DBRFONT
	cfont 26,20,36,20,DBRFONT
	cfont 38,20,47,20,DBRFONT
	cfont 49,20,59,20,DBRFONT
	cfont 61,20,70,20,DBRFONT
	cfont 72,20,MAXRCOLS,20,DBRFONT
	# Bottom stub - employer's
	cerase 1,42,30,42
	cbox LEFTCOL,39.5,MAXCOLS,39.5
	text 15,41,"COMP_NAME",HBFONT,12
	cbox LEFTCOL,41.5,MAXCOLS,43.5,MBOXSIZE,crows=42.5::DSHADE,  ccols=15 33 45 54 64
	text 2,42,"Emp No/Dept",ICFONT,cols=13
	text 16,42,"Employee Name",ICFONT,cols=17
	text 34,42,"SSN",ICFONT,cols=11
	text 46,42,"Per Beg",ICFONT,cols=8
	text 55,42,"Per End",ICFONT,cols=9
	text 65,42,"Ck No.",ICFONT,cols=16
	cfont 2,43,14,43,DBCFONT
	cfont 16,43,32,43,DBCFONT
	cfont 34,43,44,43,DBCFONT
	cfont 46,43,53,43,DBCFONT
	cfont 55,43,63,43,DBCFONT
	cfont 65,43,MAXRCOLS,43,DBCFONT
	cbox LEFTCOL,43.5,MAXCOLS,57.5,MBOXSIZE,crows=45.5::DSHADE,  ccols=14 24 34 47 60 70
	text 2,44.5,"Earnings",IFONT
	text 24,44.5,"Hrs/Units",IRFONT,black
	text 34,44.5,"Curr Amt",IRFONT
	text 47,44.5,"YTD",IRFONT
	text 48,44.5,"Deductions",IFONT
	text 70,44.5,"Curr Amt",IRFONT
	text 75,44.5,"YTD",IRFONT,cols=6
	cfont 2,46,13,55,DFONT
	cfont 14,46,23,55,DBRFONT,black
	cfont 24,46,33,55,DBRFONT
	cfont 35,46,46,55,DBRFONT
	cfont 48,46,59,58,DFONT
	cfont 61,46,69,58,DBRFONT
	cfont 71,46,MAXRCOLS,58,DBRFONT
	text 2,56,{mcut(1,56,13,2,"","Y","Y")},IBFONT
	text 15,56,{mcut(17,56,9,2,"","Y","Y")},DBRFONT,cols=9
	cbox LEFTCOL,58.5,MAXCOLS,60.5,MBOXSIZE,crows=59.5::100,  ccols=13 25 37 48 60 71
	text 2,59,"Pay Rate",IFONT,shade=0
	text 25,59,"Curr Earn",IRFONT,shade=0
	text 37,59,"Curr Ded",IRFONT,shade=0
	text 48,59,"Net Pay",IRFONT,shade=0
	text 60,59,"YTD Earn",IRFONT,shade=0
	text 61,59,"YTD Ded",IRFONT,shade=0,cols=10
	text 72,59,"YTD Net Pay",IRFONT,shade=0,cols=9
	cfont 2,60,12,60,DBFONT
	cfont 14,60,24,60,DBRFONT
	cfont 26,60,36,60,DBRFONT
	cfont 38,60,47,60,DBRFONT
	cfont 49,60,59,60,DBRFONT
	cfont 61,60,70,60,DBRFONT
	cfont 72,60,MAXRCOLS,60,DBRFONT
end if
# summary copy
if copy 2
	cerase 1,1,MAXCOLS,MAXROWS
	# title
	text 1,2,"Payroll Check Summary",HBCFONT,cols=MAXRCOLS,14
	# summary
	text 25,6,{mget(14,1,21,8,"Y","Y")},HBFONT
	text 58,6,{mget(36,1,13,8,"Y","Y")},DBRFONT,11
	# end of report
	text 2,15,{get(1,11,13)},HBCFONT,cols=MAXRCOLS
	cerase LEFTCOL,1,RIGHTCOL,MAXROWS
end if
# ----------------------------------------------------------------------
prepage {
	# needed prior to archiving
	dtype$=get(1,1,MAXCOLS,"Y")
	if dtype$="" arcdtype$="summary" else arcdtype$="check"
}
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="prcheck"
	prepage {
	noarchive=1
	earc$="EARC_PRCHECK",doing_recat=0
	earca_formtype$="preprinted"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=10,logorows=5
}
prepage {
# mje 082307
	dtype$=get(1,1,MAXCOLS,"Y")
	# note, opposite of other 2 check formats
	if dtype$<>"" then :
		# check
		docdate$=get(58,27,8,"Y")
	else
		# summary
		docid$=get(36,5,10,"Y")
		docdate$=get(36,4,10,"Y")
	endif
	for row=1 to 21
		text$[row+40]=text$[row]
	next row
}
precopy {
	# Summary?
	if copy=1 and dtype$="" then skip=1
	if copy=2 and dtype$<>"" then skip=1
	if copy=2 and not(skip) then :
		docdate$=get(36,3,10,"Y",1)
	endif
}
[SO_Bol]
# bill of lading rule set
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/txt7/bolading.txt"
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/txt7/bol2pg.txt"
detect 64,1,"BILL"
detect 122,2,"~[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
# set up document constants
local MAXCOLS=132                   		 		# max cols to output
local MAXRCOLS=131                 			 		# MAXCOLS-1
local LEFTCOL=1                   			 		# left vertical line
local RIGHTCOL=MAXCOLS                	        		# right vertical line
local MAXROWS=66                  			 		# max rows to output
cols MAXCOLS                      			 		# max output columns
rows MAXROWS                      			 		# max output rows
local CUSTOMER_COPY=1
local FILE_COPY=2
local TOTALS_COPY=3
local MAX_COPIES=2
copies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                              			 		# graphical shading
	
title "Shipping Order - Bill of Lading"    				 		# view in pdf properties
# header section
cerase 1,1,MAXCOLS,17
text 13,4.5,{received$}, DFONT
cbox LEFTCOL,1.5,MAXCOLS,3.5,MBOXSIZE,ccols=18::ISHADE 46.5 64::ISHADE 80 87::ISHADE 100 118::ISHADE
cbox LEFTCOL,3.5,RIGHTCOL,10.5,MBOXSIZE
text 1,1,"Straight Bill of Lading",DBCFONT,12,cols=MAXCOLS
text 10,2.5,"Name of carrier",ICFONT,10
text 33,2.5,{carrier$},DBCFONT,10
text 48,2.5,"Carrier number",IFONT,10
text 66,2.5,{carno$},DBFONT,10
text 82,2.5,"Date",IFONT,10
text 89,2.5,{date$},DBFONT,10
text 101,2.5,"Shipper number",IFONT,10
text 119,2.5,{shipno$},DBFONT,10
# from & to
cbox LEFTCOL,10.5,MAXCOLS,16,MBOXSIZE,ccols=10::ISHADE 64 75::ISHADE
text 2,11.5,"From:\nShipper",ICFONT,10,cols=7.5
text 11.5,11.5,{from$},DBFONT,10
	
text 65,11.5,"To:\nConsignee",ICFONT,10,cols=10
cfont 47,11,MAXRCOLS,18,DBFONT,black            		# ship to addr
text 77,11.5,{to$},DBFONT,10
# ribbon 1
cbox LEFTCOL,16,MAXCOLS,19,MBOXSIZE,crows=17.5::ISHADE, ccols=40 100
text 3,16.75,"Delivering",ICFONT,ccols=37
text 1.5,18.25,{deliver$},DBCFONT,10,cols=37
text 53,16.75,"Route",ICFONT,cols=30
text 53,18.25,{route$},DBCFONT,10, cols=30
text 101,16.75,"Vehicle Number",ICFONT,cols=30
text 101,18.25,{vehicle$},DBCFONT,10,cols=30
cerase 12,22,12,50
cerase 17,22,17,50
#cerase 81,22,81,50
cerase 86,22,86,50
cerase 105,22,105,50
cerase 116,22,119,50
#detail section
cbox LEFTCOL,19,RIGHTCOL,50.5,MBOXSIZE,crows=21.5::DSHADE,ccols=11 16 68 77 95.5 108 117
cmove 1,18,MAXCOLS,46,1,22
text 1,19.75,"No. of\nUnits",IRFONT,cols=9
cmove 3,22,11,50,1,22
cfont 1,22,9.75,50,DBRFONT
text 13.75,19.75,"Hm",ICFONT
cfont 12,22,15,50,DCFONT
text 17.5,19.75,"Kind of Packaging, Description of Articles, \nSpecial Marks and Exceptions",ILFONT
cfont 17,22,69,50,DLFONT
text 69,19.75,"Erg #",ICFONT,cols=8
cmove 82,22,85,50,70,22
cfont 70,22,74,50,DCFONT
text 77,19.75,"Weight (subject \nto correction)",IRFONT,cols=18
cmove 87,22,102,50,70,22
cfont 76,22,94,50,DBRFONT
text 97,19.75,"Class\n or Rate",ICFONT,cols=10
cmove 107,22,112,50,97,22
cfont 97,22,107,50,DCFONT
text 110,19.75,"CK",ICFONT,cols=5
cfont 109,22,116,50,DCFONT
text 118.5,19.75,"Charges \n(Carrier Use)",IRFONT,cols=13
cfont 118,22,131,50,DBRFONT
# shade lines
shade "~[0-9][0-9]@6,22,8,50", 10,0,79,1,DFONT,20
# watermark - large font with light shading
WATERMARK 1,54.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# bottom sections
cerase 1,50,MAXCOLS,MAXROWS
cbox LEFTCOL,50.5,MAXCOLS,53,MBOXSIZE,ccols=23::ISHADE 39 58::ISHADE 83 104::ISHADE
cbox LEFTCOL,53,102,56,MBOXSIZE,ccols=13::ISHADE 65 77::ISHADE
cbox 102,53,MAXCOLS,57,MBOXSIZE, crows 55::ISHADE
cbox LEFTCOL,56,102,62,MBOXSIZE, ccols=33.5
cbox 102,57,MAXCOLS,60,MBOXSIZE, ccols=112::ISHADE
cbox 102,60,MAXCOLS,64,MBOXSIZE, crows=62::ISHADE
cbox LEFTCOL,62,102,64,MBOXSIZE
cbox LEFTCOL,64,MAXCOLS,66,MBOXSIZE,ccols=59 99
text 2.5,51.75,"Placards supplied?",IFONT
text 23,51.75,{placards$}, DBCFONT,10,cols=16
text 3,54.5,"Remit To",IFONT
text 14,53.5,{remit$},10, DBFONT
text 40,51.25,"Driver's\n signature",ICFONT,cols=21
text 84,51.25,"Emergency\n response phone",ICFONT,cols=20
text 109,51.75,{emerg$},10,DBFONT
text 105,54,"C.O.D. Fee",ICFONT, cols=25
text 116,56.5,{codfee$}, DBRFONT,10,cols=15
text 68,54,"C.O.D.\nAmount",IFONT
text 82,54.5,"$",DBFONT
text 81,54.5,{codamt$}, DBRFONT,10,cols=20
text 105,55.5, "___Prepaid",IFONT
text 118,55.5, "___Collect",IFONT
text 118,56.5, "$",DBFONT
text 107.5,58,"Total\nCharges",ICFONT
text 117,58.5,"$",DBFONT
text 115,58.5,{total$}, DBRFONT,10, cols=16
text 105,61,"Freight charges are:",IFONT
text 104,63,{freight$},DCFONT,10,cols=23
text 3.5,56.75,{mcut(1,52,35,4,"","y","")},DFONT
text 40,56.75,{mcut(38,52,67,4,"","y","")},DFONT
text 3,62.5,"This is to certify that the above materials are properly classified, described, packaged, marked, labeled, and in proper\ncondition for transportation, according to the applicable regulations of the Department of Transportation.",DFONT,8
text 3,61,"$",DBFONT
text 3,61,{perunit$},DBFONT,10
text 40,61,"Signature of Consignor:",IFONT
text 60,64.75,"Shipper, per",IFONT
text 100,64.75,"Agent, per",IFONT
# handle copy title
cbox 1.7,64.3,30,65.7,1,100
text 1,65,{copy_title$[copy]},HBCFONT,12,cols=30,shade 0
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="bill of lading"
	prepage {
	noarchive=1
	earc$="EARC_BILLOFLADING",doing_recat=0
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# Page X of Y feature
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=122			# adjust as needed
	local XOFYM_ROW  	=2				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(122,2,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_BILLOFLADING"			# Y/N Switch from global section
		bcod_Copies$="2"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docTy$="SOBOL"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_Docty$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
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 {
	carrier$=cut(16,2,25,"")
	carno$=cut(77,2,10,"")
	# mje 060710 chg cut to get re arc timing
	date$=cut(98,2,10,"")
	shipno$=cut(121,2,10,"")
	
	received$=mcut(1,3,132,6,"","y","")
	
	from$=mcut(10,9,30,5,"","y","")
	# mje 060710 chg cut to get re arc timing
	to$=mcut(83,9,30,5,"","y","")
	deliver$=cut(1,15,25,"")
	route$=	cut(49,15,25,"")
	vehicle$=cut(115,15,5,"")
	#detail$=mcut(2,18,132,28,"","y","")
	
	placards$=cut(20,48,5,"")
	remit$=mcut(10,49,25,3,"","y","")
	codamt$=cut(90,51,14,"")
	emerg$=cut(107,48,30,"")
	codfee$=cut(120,51,13,"")
	total$=cut(120,53,13,"")
	freight$=cut(112,56,13,"")
	perunit$=cut(3,57,25,"")
}
[SO_InvLaser]
# handles invoice, quote, credit memo
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/formlaser/so_invc_laser-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_invc_laser-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_invc_laser.txt"
detect 111,6,"~ DATEMASK"
detect 0,17,"~\.[0-9][0-9]"
# mje 062910
# NOTE the difference between sample text files, one has the OSAS
# multi-copy format, and the "-nocopy" sample has the OSAS multi-copy
# text removed. The one with OSAS multi-copy format will not print
# a barcode page, because the logic is designed to disable the UnForm
# multiple copies in this case.
# set up document constants
local MAXCOLS=132                       			       # max cols to output
local MAXRCOLS=131                 				# MAXCOLS-1
local LEFTCOL=1                     				# left vertical line
local RIGHTCOL=MAXCOLS                  				# right vertical line
local MAXROWS=66                        				# max rows to output
cols MAXCOLS                        				# max output columns
rows MAXROWS                        				# max output rows
local CUSTOMER_COPY=1
local FILE_COPY=2
local MAX_COPIES=2
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                                				# graphical shading
title "Invoice - laser"             				# view in pdf properties
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,39,EROW,DBFONT                     		   # item #
cfont 41,BROW,43,EROW,DCFONT                        		   # tx
cfont 45,BROW,49,EROW,DCFONT                       		   # uom
cfont 51,BROW,69,EROW,DBRFONT                       		   # qty ord
cfont 71,BROW,89,EROW,DBRFONT,black                 		   # qty ship
cfont 91,BROW,111,EROW,DBRFONT                  		   # price
cfont 113,BROW,MAXRCOLS,EROW,DBRFONT                		   # ext
cbox LEFTCOL,26,MAXCOLS,55,MBOXSIZE,crows=27.5::DSHADE,ccols=40 44 50 70 90 112
text 2,27,"Item Information",IFONT
text 41,27,"Tx",ICFONT,cols=3
text 45,27,"U/M",ICFONT,cols=5
text 51,27,"Ordered",IRFONT,cols=19
text 71,27,"Shipped",IRFONT,cols=19
text 91,27,"Unit Price",IRFONT,cols=21
text 113,27,"Extension",IRFONT,cols=19
# header section
cerase 1,1,MAXCOLS,9
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
merge "zMrg Form Header"
# Invoice block
cbox 111,4,MAXCOLS,10,1,ccols=120::ISHADE,crows=6 8
text 112,5,"Invoice",IFONT
text 112,7,"Date",IFONT
text 112,9,"Page",IFONT
text 121,5,{trim(cut(112,7,8,""))},DBFONT
text 121,7,{trim(cut(112,6,8,""))},DBFONT
text 121,9,{trim(cut(112,4,7,""))},DBFONT
# sold to
cerase 49,10,59,10
cbox LEFTCOL,10,MAXCOLS,20,MBOXSIZE,ccols=12::ISHADE 67 79::ISHADE
text 1,11,"Sold\nTo:",ICFONT,cols=11
cfont 10,11,66,18,DBFONT,black              			   # sold to addr
text 1,13,{trim(cut(10,10,6,""))},DBCFONT, cols=11
cmove 10,11,66,18,17,11
# ship to
text 68,11,"Ship\nTo:",ICFONT,cols=11
cfont 76,11,MAXRCOLS,18,DBFONT,black            		   # ship to addr
text 76,18,{shipto$},DBFONT
text 80.75,19,{totaldue$},DBFONT
cmove 76,11,MAXRCOLS,18,85,11
# ribbon 1
cbox LEFTCOL,20,MAXCOLS,23,MBOXSIZE,crows=21.5::ISHADE,  ccols=7 13 24 38 60 78 96 119
text 2,21,"Slsp1",ICFONT,cols=5
text 8,21,"Slsp2",ICFONT,cols=5
text 25,21,"Due Date",ICFONT,cols=13
text 39,21,"Disc Due Date",ICFONT,cols=21
text 61,21,"Order No",ICFONT,cols=17
text 79,21,"Order Date",ICFONT,cols=17
text 97,21,"Ship Date",ICFONT,cols=22
text 120,21,"Ship No",ICFONT,cols=12
cfont 2,22,6,22,DBCFONT                     			   # slsp 1
cfont 8,22,23,22,DBCFONT                    			   # slsp 2
cfont 25,22,37,22,DBCFONT                   			   # due date
cfont 39,22,59,22,DBCFONT                   			   # disc due date
cfont 61,22,77,22,DBCFONT,black            			   # order #
cfont 79,22,95,22,DBCFONT                   			   # order date
cfont 97,22,118,22,DBCFONT                 			   # ship date
cfont 120,22,MAXRCOLS,22,DBCFONT               			   # ship #
# ribbon 2
cbox LEFTCOL,23,MAXCOLS,26,MBOXSIZE,crows=24.5::ISHADE,ccols=32 78
text 2,24,"Terms Description",ICFONT,cols=30
text 33,24,"Customer PO No",ICFONT,cols=45
text 79,24,"Ship Via",ICFONT,cols=53
cfont 2,25,31,25,DBCFONT                    			   # terms
cfont 33,25,77,25,DBCFONT,black            			   # cust po
cfont 79,25,MAXRCOLS,25,DBCFONT,black           		   # ship via
# detail section
# lot line
font "Lot@4,28,6,54",0,0,3,1,IRFONT             		   # lot
font "Lot@4,28,6,54",4,0,30,1,DBFONT            		   # lot id
font "Lot@4,28,6,54",42,0,12,2,IRFONT           		   # lot ord/ship
font "Lot@4,28,6,54",59,0,12,2,DBRFONT,black        		   # lot qty
font "Lot@4,28,6,54",73,0,10,2,IFONT           			   # lot uom
# ser line
font "Ser@6,28,8,54",0,0,3,1,IRFONT             		   # ser
font "Ser@6,28,8,54",4,0,20,1,DBFONT          			   # ser id
# component lines
font "C@1,28,1,54",2,0,30,1,DBFONT             			   # item #
font "C@1,28,1,54",2,1,45,1,DFONT            			   # desc
font "C@1,28,1,54",44,0,5,1,DBCFONT         			   # uom
font "C@1,28,1,54",50,0,19,1,DBRFONT         			   # qty
# description
font "R@1,28,1,54",1,0,77,1,DFONT             			   # description
cerase 1,28,1,54
# watermark - large font with light shading
WATERMARK 1,54.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# message area
cbox LEFTCOL,55,MAXCOLS,58,MBOXSIZE
cfont 2,56,92,57,IFONT                  				   # mesg
cfont 94,57,110,57,DBRFONT             				   # subtotal:
cfont 114,57,MAXRCOLS,57,DBRFONT      				   # subtotal amt
# footer
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
# shade lines
shade "~\.[0-9][0-9]@128,28,130,54",-126.5,0,131,1,DSHADE
# totals
cerase LEFTCOL,60,RIGHTCOL,60
cfont 2,59,26,59,DBRFONT            				   # taxable
cfont 28,59,47,59,DBRFONT              				   # non-taxable
cfont 49,59,68,59,DBRFONT,black      				   # freight
cfont 70,59,89,59,DBRFONT             				   # sales tax
cfont 91,59,113,59,DBRFONT,black     			          # misc
cfont 115,59,MAXRCOLS,59,DBRFONT,10      				   # grand total
# ----------------------------------------------------------------------
prepage {
	# get invoice title
	doc_title$="INVOICE",reprint$=""
	# get title from body of invoice, if available.
	# Must handle credit memo text/quote.
	x$=trim(cut(18,10,26,""))
	x=pos("REPRINT"=x$)
	if x then reprint$="REPRINT"
	x=pos("C R E D I T"=X$)
	if x then doc_title$="CREDIT MEMO"
	x=pos("Q U O T E"=X$)
	if x then doc_title$="QUOTE"
}
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="invoice"
	prepage {
	noarchive=1
	earc$="EARC_INVOICE",doing_recat=0
	earca_formtype$="laser"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	#	# mje 062810 disabled due to different order doc types
	#	merge "8.0 zMrg PDFLinks v2"
	#	prepage {
	#		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ",61,22,70,22,0,"","","DBCFONT","EARC_ORDLINKLIB","EARC_ORDLINKDOCTY"))
	#	}
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(112,7,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_INVOICE"			# Y/N Switch from global section
		bcod_Copies$="2"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docty$="SOINV"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docty$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# Page X of Y feature
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=112			# adjust as needed
	local XOFYM_ROW  	=7				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(112,7,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Invoice"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(10,10,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# remark this to ALWAYS print ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=16,logorows=7
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then :
		copy_title$[CUSTOMER_COPY]="Customer Copy"
	endif
	if MAX_COPIES>=2 then :
		copy_title$[FILE_COPY]="File Copy"
	endif
}
prepage {
	if trim(get(1,1,80))<>"" then :
		pcopies=CUSTOMER_COPY
		copy_title$[CUSTOMER_COPY]=trim(get(1,1,80))
	endif
	merge "zMrg get watermark text"
	xcol=0,xrow=0
	merge "zMrg get company info"
	shipto$=trim(get(45,10,10))
	if shipto$<>"" then :
		shipto$="Your ship to code is "+shipto$
	endif
	totaldue$=""
	due$=trim(cut(110,17,12,""))
	if doc_title$="INVOICE" then :
		totaldue$="Your total due is "+due$
	endif
	# mark memo lines
	for i=28 to 54
		if mid(text$[i],4,3)="Lot" and mid(text$[i],46,7)="Ordered" then :
			i=i+1
			goto bottom_loop 					 			# lot line
		endif
		if mid(text$[i],6,3)="Ser" and mid(text$[i],107,1)="." then :
			goto bottom_loop          				 	# serial line
		endif
		if mid(text$[i],128,1)="."  then goto bottom_loop       	# detail line
		# component?
		if mid(text$[i],2,17)="End of Components" then compon=0
		if compon and len(trim(text$[i]))>2 and mid(text$[i],1,2)="  " then :
			text$[i](1,1)="C"
			i=i+1
			goto bottom_loop
		endif
		if mid(text$[i],2,11)="Component :" then compon=1
		# must be remark/desc
		if text$[i]<>"" then :
			text$[i](1,1)="R"
			bottom_loop:
		endif
		next i
	# continued?
	cont$="",sub_line=50
	for i=50 to MAXROWS
		x=pos("(continued"=text$[i])
		if x then :
			cont$="Continued on next page ..."
			sub_line=55; x$=set(x,i,30,"")
			break
		endif
	next i
	if cont$="" then :
		exec("cbox 1,58,RIGHTCOL,61,MBOXSIZE,crows=59.5 61::HSHADE,ccols=27 48 69 90 114")
	endif
	if cont$="" then exec("text 2,60.5,""Taxable"",HRFONT,cols=25,10")
	if cont$="" then exec("text 29,60.5,""Non-Taxable"",HRFONT,cols=19,10")
	if cont$="" then exec("text 50,60.5,""Freight"",HRFONT,cols=19,10")
	if cont$="" then exec("text 71,60.5,""Sales Tax"",HRFONT,cols=19,10")
	if cont$="" then exec("text 92,60.5,""Misc Charge"",HRFONT,cols=22,10")
	if cont$="" then exec("text 115,60.5,""Grand Total"",HBRFONT,cols=16,10")
	amount_paid$=trim(get(10,60,20))
	amt_paid$=trim(get(31,60,20))
	net_due$=trim(get(50,60,20))
	nt_due$=trim(get(70,60,20))
	if amount_paid$="" then goto no_amount_paid
	amount_paid$=amount_paid$(1,len(amount_paid$)-1)    	  # remove colon
	net_due$=net_due$(1,len(net_due$)-1)            		  # remove colon
	x$="cbox 90,61,MAXCOLS,64,1,ccols=114::DSHADE,crows=62.5"
	exec(x$)
	x$="text 91,62,"+$22$+amount_paid$+$22$+",IFONT,10"
	exec(x$)
	x$="text 118,62,"+$22$+amt_paid$+$22$+",DBRFONT,10,cols=14"
	exec(x$)
	x$="text 91,63.5,"+$22$+net_due$+$22$+",IBFONT,10"
	exec(x$)
	x$="text 118,63.5,"+$22$+nt_due$+$22$+",DBRFONT,10,cols=14"
	exec(x$)
no_amount_paid:
}
[SO_Inv8.5x11]
# handles invoice, quote, credit memo
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/form8.5x11/so_invc_8.5x11-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/form8.5x11/so_invc_8.5x11.txt"
detect 62,6,"~ DATEMASK "
detect 77,17,"~\.[0-9][0-9]"
# mje 062910
# NOTE the difference between sample text files, one has the OSAS
# multi-copy format, and the "-nocopy" sample has the OSAS multi-copy
# text removed. The one with OSAS multi-copy format will not print
# a barcode page, because the logic is designed to disable the UnForm
# multiple copies in this case.
# set up document constants
local MAXCOLS=80                   		 		# max cols to output
local MAXRCOLS=79                 			 		# MAXCOLS-1
local LEFTCOL=1                   			 		# left vertical line
local RIGHTCOL=MAXCOLS                	        		# right vertical line
local MAXROWS=66                  			 		# max rows to output
cols MAXCOLS                      			 		# max output columns
rows MAXROWS                      			 		# max output rows
local CUSTOMER_COPY=1
local FILE_COPY=2
local TOTALS_COPY=3
local MAX_COPIES=3
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                              			 		# graphical shading
	
title "Invoice - 8.5 x 11"    				 		# view in pdf properties
# customer or file copy
if copy CUSTOMER_COPY,FILE_COPY
	# default detail line
	local BROW=1
	local EROW=MAXROWS
	cmove 1,28,MAXCOLS,53,1,29
	cfont 2,BROW,21,EROW,DBFONT                         		# item #
	cfont 23,BROW,24,EROW,DCFONT                    		# tx
	cfont 26,BROW,30,EROW,DCFONT                       		# uom
	cfont 32,BROW,41,EROW,DBRFONT                       		# qty ord
	cfont 43,BROW,53,EROW,DBRFONT,black                 		# qty ship
	cfont 55,BROW,65,EROW,DBRFONT                       		# price
	cfont 67,BROW,MAXRCOLS,EROW,DBRFONT                 		# ext
	cbox LEFTCOL,26,RIGHTCOL,55,MBOXSIZE,crows=27.5::DSHADE,ccols=22 25 31 42 54 66
	text 2,27,"Item Information",IFONT
	text 23,27,"Tx",ICFONT,cols=2
	text 26,27,"U/M",ICFONT,cols=5
	text 32,27,"Ordered",IRFONT,cols=10
	text 43,27,"Shipped",IRFONT,cols=11
	text 55,27,"Unit Price",IRFONT,cols=11
	text 67,27,"Extension",IRFONT,cols=13
	# shade lines
	shade "~[0-9][0-9][0-9]@2,28,4,54", -.5,0,79,1,DSHADE
	# header section
	cerase 1,1,MAXCOLS,6
	cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=10:MBOXSIZE
	merge "zMrg Form Header"
	# Invoice block
	cbox 66,4,RIGHTCOL,10,1,ccols=72::ISHADE,crows=6 8
	text 67,5,"Invoice",IFONT
	text 67,7,"Date",IFONT
	text 67,9,"Page",IFONT
	text 73,5,{trim(cut(52,6,8,""))},DBFONT
	text 73,7,{trim(cut(63,6,8,""))},DBFONT
	text 73,9,{trim(cut(72,6,7,""))},DBFONT
	# sold to
	cbox LEFTCOL,10,MAXCOLS,20,MBOXSIZE,ccols=7::ISHADE 40 46::ISHADE
	text 3,11,"Sold\nTo",ICFONT,cols=3
	cmove 6,11,39,18,8,11
	cfont 8,11,39,18,DBFONT,black              			# sold to addr
	text 2,13,{trim(cut(6,10,6,""))},DBFONT
	# ship to
	text 42,11,"Ship\nTo",ICFONT,cols=3
	cmove 45,11,MAXRCOLS,18,47,11
	cfont 47,11,MAXRCOLS,18,DBFONT,black            		# ship to addr
	text 41,13,{shipto$},DBFONT
	text 47,19,{totaldue$},DBFONT
	# zip bar
	#barcode 47,16,{shipzip$},900,12.0,2
	# ribbon 1
	cbox LEFTCOL,20,MAXCOLS,23,MBOXSIZE,crows=21.5::ISHADE,ccols=7 13 25 37 46 58 70
	text 2,21,"Slsp1",ICFONT,cols=5
	text 8,21,"Slsp2",ICFONT,cols=5
	text 14,21,"Due Date",ICFONT,cols=11
	text 26,21,"Disc Due Date",ICFONT,cols=11
	text 38,21,"Order No",ICFONT,cols=8
	text 47,21,"Order Date",ICFONT,cols=11
	text 59,21,"Ship Date",ICFONT,cols=11
	text 71,21,"Ship No",ICFONT,cols=9
	cfont 2,22,6,22,DBCFONT                     			# slsp 1
	cfont 8,22,12,22,DBCFONT                    			# slsp 2
	cfont 14,22,24,22,DBCFONT                   			# due date
	cfont 26,22,36,22,DBCFONT                   			# disc due date
	cfont 38,22,45,22,DBCFONT,black             			# order #
	cfont 47,22,57,22,DBCFONT,black             			# order date
	cfont 59,22,69,22,DBCFONT                   			# ship date
	cfont 71,22,MAXRCOLS,22,DBCFONT            			# ship #
	# ribbon 2
	cbox LEFTCOL,23,MAXCOLS,26,MBOXSIZE,crows=24.5::ISHADE,ccols=18 45
	text 2,24,"Terms Description",ICFONT,cols=17
	text 19,24,"Customer PO No",ICFONT,cols=25
	text 46,24,"Ship Via",ICFONT,cols=34
	cfont 2,25,17,25,DBCFONT                    			# terms
	cfont 19,25,44,25,DBCFONT,black             			# cust po
	cfont 46,25,MAXRCOLS,25,DBCFONT,black           		# ship via
	# detail section
	# lot line
	font "Lot@4,28,6,54",0,0,3,1,IRFONT             		# lot
	font "Lot@4,28,6,54",4,0,20,1,DBFONT            		# lot id
	font "Lot@4,28,6,54",34,0,9,2,IRFONT           			# lot ord/ship
	font "Lot@4,28,6,54",43,0,13,2,DBRFONT,black        		# lot qty
	font "Lot@4,28,6,54",57,0,10,2,IFONT            		# lot uom
	# ser line
	font "Ser@6,28,8,54",0,0,3,1,IRFONT             		# ser
	font "Ser@6,28,8,54",4,0,20,1,DBFONT            		# ser id
	# component lines
	font "C@1,28,1,54",2,0,30,1,DBFONT              		# item #
	font "C@1,28,1,54",2,1,45,1,DFONT               		# desc
	font "C@1,28,1,54",44,0,5,1,DBCFONT             		# uom
	font "C@1,28,1,54",50,0,19,1,DBRFONT            		# qty
	# description
	font "R@1,28,1,54",1,0,77,1,DFONT               		# description
	cerase 1,28,1,54
	# watermark - large font with light shading
	WATERMARK 1,54.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
	# message area
	cbox LEFTCOL,55,MAXCOLS,58,MBOXSIZE
	cfont 2,56,55,57,ILFONT,black           				# mesg
	cfont 57,57,66,57,IBRFONT              				# subtotal:
	cfont 67,57,MAXRCOLS,57,DBRFONT        				# subtotal amt
	# footer
	text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
	text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
	# totals
	cfont 2,60,14,60,DBRFONT                				# taxable
	cfont 16,60,27,60,DBRFONT               				# non-taxable
	cfont 29,60,40,60,DBRFONT,black         				# freight
	cfont 42,60,53,60,DBRFONT               				# sales tax
	cfont 55,60,66,60,DBRFONT,black            			# misc
	cfont 68,60,MAXRCOLS,60,DBRFONT,10          			# grand total
end if
if copy TOTALS_COPY
	cfont 21,21,40,50,HFONT
	cfont 42,21,53,50,DFONT,right
	cfont 54,21,54,50,DFONT,black
	bold "Total",-5,0,25,1
end if
# ----------------------------------------------------------------------
prepage {
	# get invoice title
	doc_title$="INVOICE",reprint$=""
	# get title from body of invoice, if available.
	# Must handle credit memo text/quote.
	x$=trim(cut(13,10,26,""))
	x=pos("REPRINT"=x$)
	if x then reprint$="REPRINT"
	x=pos("C R E D I T"=X$)
	if x then doc_title$="CREDIT MEMO"
	x=pos("Q U O T E"=X$)
	if x then doc_title$="QUOTE"
}
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="invoice"
	prepage {
	noarchive=1
	earc$="EARC_INVOICE",doing_recat=0
	earca_formtype$="8.5x11"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
#	# mje 062810 disabled due to different order doc types
#		merge "8.0 zMrg PDFLinks v2"
#		prepage {
#			# inherit from arc logic: targDoctys$="Picking List,Packing List,Picking Slip"
#			exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ",37,22,46,22,0,"","","DBCFONT","EARC_ORDLINKLIB",targDoctys$))
#		}
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(52,6,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_INVOICE"			# Y/N Switch from global section
		bcod_Copies$="2"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docTy$="SOINV"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docTy$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
# --- PAGE X of Y FEATURE -----------------------------------------------
	# Page X of Y feature
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=52			# adjust as needed
	local XOFYM_ROW  	=6				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(52,6,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Invoice"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(6,10,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# remark this to ALWAYS print ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=14,logorows=6
	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]="File Copy"
}
prepage {
	if trim(get(1,1,80))<>"" then :
		pcopies=CUSTOMER_COPY
		copy_title$[CUSTOMER_COPY]=trim(get(1,1,80))
	endif
	# add zip barcode
	xrow=13;xcols=40
	#merge "zmrg get zip"
	xcol=0,xrow=0
	merge "zMrg get company info"
	shipto$=trim(cut(45,10,6,""))
	due$=trim(get(70,17,11)),x$=set(70,17,11,"")
	totaldue$=""
	# mje 060210 fixed next line, said title$=
	if doc_title$="INVOICE" then :
			totaldue$="The total due on this invoice is $"+totaldue$+"."
	endif
	# continued?
	cont$="",sub_line=50
	for i=50 to MAXROWS
		x=pos("(continued"=text$[i])
		if x then :
			cont$="Continued on next page ..."
			sub_line=55
			x$=set(x,i,30,"")
			break
		endif
	next i
	if cont$="" then :
		exec("cbox 1,58,RIGHTCOL,61,MBOXSIZE,crows=59.5::HSHADE 61,ccols=15 28 41 54 67")
	endif
	if cont$="" then exec("text 3,59,""Taxable"",HRFONT,cols=12,10")
	if cont$="" then exec("text 16,59,""Non-Taxable"",HRFONT,cols=12,10")
	if cont$="" then exec("text 29,59,""Freight"",HRFONT,cols=12,10")
	if cont$="" then exec("text 42,59,""Sales Tax"",HRFONT,cols=12,10")
	if cont$="" then exec("text 55,59,""Misc Charge"",HRFONT,cols=12,10")
	if cont$="" then exec("text 67,59,""Grand Total"",HBRFONT,cols=12,10")
	amount_paid$=trim(get(23,61,11))
	amt_paid$=trim(get(36,61,15))
	net_due$=trim(get(58,61,7))
	nt_due$=trim(get(67,61,14))
	if amount_paid$="" then goto no_amount_paid
	amount_paid$=amount_paid$(1,len(amount_paid$)-1)		# remove colon
	net_due$=net_due$(1,len(net_due$)-1)            		# remove colon
	x$="cbox 61,61,RIGHTCOL,64,1,ccols=70::DSHADE,crows=62.5"
	exec(x$)
	x$="text 62,62,"+$22$+amount_paid$+$22$+",IFONT,10"
	exec(x$)
	x$="text 71,62,"+$22$+amt_paid$+$22$+",DBRFONT,10,cols=9"
	exec(x$)
	x$="text 62,63.5,"+$22$+net_due$+$22$+",IBFONT,10"
	exec(x$)
	x$="text 71,63.5,"+$22$+nt_due$+$22$+",DBRFONT,10,cols=9"
	exec(x$)
no_amount_paid:
	# mark line types (D=detail, L=lot, R=remark/desc, S=serial
	for i=28 to 54
		if mid(text$[i],4,3)="Lot" and mid(text$[i],38,7)="Ordered" then :
			i=i+1
			goto bottom_loop
		endif
		if mid(text$[i],6,3)="Ser" and mid(text$[i],61,1)="." then goto bottom_loop
		if mid(text$[i],77,1)="." then goto bottom_loop
		# component?
		if mid(text$[i],2,17)="End of Components" then compon=0
		if compon and len(trim(text$[i]))>2 and  mid(text$[i],1,2)="  " then :
			text$[i](1,1)="C"
			i=i+1
			goto bottom_loop
		endif
		if mid(text$[i],2,11)="Component :" then compon=1
		# must be remark
		if text$[i]<>"" then text$[i](1,1)="R"
bottom_loop:
	next i
}
precopy {
	x$=trim(get(1,21,MAXCOLS))
	if copy=3 and x$<>"Run Totals:" then skip=1
	if copy<3 and x$="Run Totals:" then skip=1
	if copy=3 then doc_title$="Summary"
	merge "zMrg get watermark text"
}
[SO_InvPlain]
# handles invoice, quote, credit memo
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_invc_plain-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_invc_plain.txt"
detect 0,2,"~(I N V O I C E)|(C R E D I T)|(Q U O T E)"
# mje 062910
# NOTE the difference between sample text files, one has the OSAS
# multi-copy format, and the "-nocopy" sample has the OSAS multi-copy
# text removed. The one with OSAS multi-copy format will not print
# a barcode page, because the logic is designed to disable the UnForm
# multiple copies in this case.
# set up document constants
local MAXCOLS=120                     		  		# max cols to output
local MAXRCOLS=119                 		  		# MAXCOLS-1
local LEFTCOL=1                   			  		# left vertical line
local RIGHTCOL=MAXCOLS           		        		# right vertical line
local MAXROWS=66                		        		# max rows to output
cols MAXCOLS                   		        		# max output columns
rows MAXROWS                  			        		# max output rows
	
local CUSTOMER_COPY=1
local FILE_COPY=2
local MAX_COPIES=2
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                               		 		# graphical shading
title "Invoice - plain"         			 		# view in pdf properties
# more room at top
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,1,2
# default detail line
local BROW=19 # 1
local EROW=MAXROWS
cfont 2,BROW,45,EROW,DBLFONT                        		# item #
cfont 47,BROW,54,EROW,DFONT,black                  		# o/s
cfont 55,BROW,68,EROW,DBRFONT                       		# qty
cfont 70,BROW,76,EROW,DCFONT                       		# units
cfont 78,BROW,99,EROW,DBRFONT                       		# price
cfont 101,BROW,MAXRCOLS,EROW,DBRFONT                		# ext
cbox LEFTCOL,19.5,MAXCOLS,48,MBOXSIZE,CROWS=20.5::DSHADE,  ccols=46 54 69 77 100
local BROW=20
local EROW=20
cfont 2,BROW,45,EROW,ILFONT                 	    		# item #
cerase 47,BROW,68,EROW								# mislabeling
text 50.5,BROW,"O/S",ICFONT
text 66.5, BROW,"Qtys", ICFONT					# qtys
#cfont 47,BROW,68,EROW,ICFONT             		    	# qtys
cfont 70,BROW,76,EROW,ICFONT                 	    		# units
cfont 78,BROW,99,EROW,IRFONT                  	    		# price
cfont 101,BROW,MAXRCOLS,EROW,IRFONT                 		# ext
# header section
cerase 1,1,MAXCOLS,8
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# page block
text 1,7,{trim(get(111,6,10))},HFONT,right,cols=MAXRCOLS
# address region
cbox LEFTCOL,9,MAXCOLS,16,MBOXSIZE,ccols=10::ISHADE 61 70::ISHADE
cmove 11,10,18,10,2,10
cmove 20,9,60,15,11,9
cmove 71,10,78,10,62,10
cmove 81,9,MAXRCOLS,15,71.5,9
cerase 1,10,9,10  # mje 061510 ,ICFONT, cols=6
text 6,10,"Sold\nTo:",ICFONT
cfont 11,10,60,15,DBFONT
cerase 62,10,70,10 # mje 061510 ,ICFONT, cols=8
text 66,10,"Ship\nTo:",ICFONT
cfont 71,8,MAXRCOLS,15,DBFONT
text 1,12,{trim(get(20,7,10))},DBCFONT, cols=9
# subhead 1
cbox LEFTCOL,16,MAXCOLS,18.5,MBOXSIZE,crows=17.5::ISHADE,  ccols=30 38 48 64 85 106
cfont 2,17,29,17,ICFONT,black
cfont 31,17,37,17,ICFONT,black
cfont 39,17,48,17,ICFONT,black
cfont 50,17,63,17,ICFONT,black
cfont 65,17,84,17,ICFONT,black
cfont 86,17,105,17,ICFONT,black
cfont 107,17,MAXCOLS,17,ICFONT
cfont 2,18,29,18,DBCFONT,black
cfont 31,18,37,18,DBCFONT,black
cfont 39,18,48,18,DBCFONT,black
cfont 39,19,84,19,DBCFONT,black
cfont 50,18,63,18,DBCFONT,black
cfont 65,18,84,18,DBCFONT,black
cfont 86,18,105,18,DBCFONT,black
cfont 107,18,MAXCOLS,18,DBCFONT,black
# watermark - large font with light shading
WATERMARK 1,47.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# message area
cbox LEFTCOL,48,MAXCOLS,51.5,MBOXSIZE
cfont 2,49,91,51,IFONT,black
cfont 93,51,102,51,IFONT,black
# shade lines
shade "~[0-9][0-9][0-9]@11,22,13,46",-9.5,0,118.75,1,DSHADE
# item descs
font "~[0-9][0-9][0-9]@11,20,13,46",-9,1,44,1,DLFONT
# totals
cfont 1,52,24,52,IRFONT,black
cfont 26,52,39,52,IRFONT,black
cfont 41,52,54,52,IRFONT,black
cfont 56,52,69,52,IRFONT,black
cfont 71,52,84,52,IRFONT,black
cfont 86,52,MAXRCOLS,52,IRFONT,black
cfont 1,53,24,53,DBRFONT,black
cfont 26,53,39,53,DBRFONT,black
cfont 41,53,54,53,DBRFONT,black
cfont 56,53,69,53,DBRFONT,black
cfont 71,53,84,53,DBRFONT,black
cfont 86,53,MAXRCOLS,53,DBRFONT,black
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
cerase 80,55,MAXCOLS,58
# ----------------------------------------------------------------------
prepage {
	# get invoice title
	doc_title$="INVOICE",reprint$=""
	# get title from body of invoice, if available.
	# Must handle credit memo text/quote.
	x$=trim(cut(70,2,50,""))
	x=pos("REPRINT"=x$)
	if x then reprint$="REPRINT"
	x=pos("C R E D I T"=X$)
	if x then doc_title$="CREDIT MEMO"
	x=pos("Q U O T E"=X$)
	if x then doc_title$="QUOTE"
}
# --- 8.0 ARCHIVING ----------------------------------------------------
	const ARCRULE="invoice"
	prepage {
	noarchive=1
	earc$="EARC_INVOICE",doing_recat=0
	earca_formtype$="plain"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	#	# mje 062810 disabled due to different order doc types
	#	merge "8.0 zMrg PDFLinks v2"
	#	prepage {
	#		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ",39,17,48,17,0,"","","DBCFONT","EARC_ORDLINKLIB","EARC_ORDLINKDOCTY"))
	#	}
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(107,17,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_INVOICE"			# Y/N Switch from global section
		bcod_Copies$="2"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docty$="SOINV"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docty$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
	
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(107,17,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Invoice"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(21,7,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# remark this to ALWAYS print ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=107			# adjust as needed
	local XOFYM_ROW  	=17				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=14,logorows=6
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then :
		copy_title$[CUSTOMER_COPY]="Customer Copy"
	endif
	if MAX_COPIES>=2 then :
		copy_title$[FILE_COPY]="File Copy"
	endif
}
prepage {
	if trim(get(70,1,80))<>"" then :
		pcopies=CUSTOMER_COPY
		copy_title$[CUSTOMER_COPY]=trim(get(70,1,80))
	endif
	merge "z Mrg get watermark text"
	xcol=30,xrow=1
	merge "zMrg get company info"
	amount_paid$=trim(get(80,55,20))
	amt_paid$=trim(get(100,55,20))
	net_due$=trim(get(80,57,20))
	nt_due$=trim(get(100,57,20))
	if amount_paid$="" then goto no_amount_paid
	amount_paid$=amount_paid$(1,len(amount_paid$)-1)		# remove colon
	net_due$=net_due$(1,len(net_due$)-1)            		# remove colon
	x$="cbox 85,53,MAXCOLS,56,1,ccols=104::DSHADE,crows=54.5"
	exec(x$)
	x$="text 86,54,"+$22$+amount_paid$+$22$+",IFONT,11"
	exec(x$)
	x$="text 108,54,"+$22$+amt_paid$+$22$+",DBRFONT,11,cols=12"
	exec(x$)
	x$="text 86,55.5,"+$22$+net_due$+$22$+",IBFONT,11"
	exec(x$)
	x$="text 108,55.5,"+$22$+nt_due$+$22$+",DBRFONT,11,cols=12"
	exec(x$)
no_amount_paid:
	# continued?
	cont$="",sub_line=47
	for i=47 to MAXROWS
		x=pos("(continued"=text$[i])
		if x then :
			cont$="Continued on next page ..."
			sub_line=55
			x$=set(x,i,30,"")
			break
		endif
	next i
	if cont$="" then :
		exec("cbox LEFTCOL,51.5,MAXCOLS,53.5,MBOXSIZE,crows=52.5::ISHADE,  ccols=25 40 55 70 85")
	endif
	if cont$<>"" then :
		exec("erase 1,52,MAXCOLS,53")
	endif
}
[SO_InvStd]
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_invc_std-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_invc_std-test-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_invc_std-test.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_invc_std.txt"
detect 0,10,"~DATEMASK"
detect 80,1,"Page"
detect 98,1,"Page"
# mje 062910
# NOTE the difference between sample text files, one has the OSAS
# multi-copy format, and the "-nocopy" sample has the OSAS multi-copy
# text removed. The one with OSAS multi-copy format will not print
# a barcode page, because the logic is designed to disable the UnForm
# multiple copies in this case.
# set up document constants
local MAXCOLS=93                      		 	# max cols to output
local MAXRCOLS=92                 			 	# MAXCOLS-1
local LEFTCOL=1                  		        	# left vertical line
local RIGHTCOL=MAXCOLS                		 	# right vertical line
local MAXROWS=66                       		 	# max rows to output
cols MAXCOLS                    		        	# max output columns
rows MAXROWS                     			 	# max output rows
page 51
local CUSTOMER_COPY=1
local REMITTANCE_COPY=2
local FILE_COPY=3
local MAX_COPIES=3
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                               	       	# graphical shading
title "Invoice - std"           				# view in pdf properties
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,2,2
# default detail line
#cmove 2,20,93,43,2,21
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,36,EROW,DBFONT                    	    		# item #
cfont 38,BROW,45,EROW,DFONT,black                  		# o/s
cfont 46,BROW,59,EROW,DBRFONT                       		# qty
cfont 61,BROW,65,EROW,DCFONT                       		# units
cfont 67,BROW,80,EROW,DBRFONT                       		# price
cfont 82,BROW,92,EROW,DBRFONT                			# ext
cbox LEFTCOL,18.5,MAXCOLS,44,MBOXSIZE,CROWS=19.5::DSHADE,  ccols=37 44 60 66 81
text 2,19,"Item/Description",ILFONT
text 37,19,"O/S",ICFONT, cols=8
text 38,19,"Quantities",IRFONT,cols=22
text 61,19,"Units",ICFONT,cols=5
text 67,19,"Price",IRFONT,cols=14
text 82,19,"Amount",IRFONT,cols=11
# header section
cerase 1,1,MAXCOLS,8
cerase 93,1,110,MAXROWS
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# page block
text 1,8,{pageno$},HRFONT,cols=MAXRCOLS
# address region
cbox LEFTCOL,9,MAXCOLS,15,ccols=7::ISHADE 44 50::ISHADE
text 1,10,"Sold\nTo",ICFONT, cols=7
text 2,12,{custno$},DBFONT, cols=6
text 44,10,"Ship\nTo",ICFONT, cols=7
cfont 8,8,43,14,DBLFONT
cmove 52,8,MAXRCOLS,14,51,8
cfont 51,8,MAXRCOLS,14,DBFONT
# subhead 1
cbox LEFTCOL,15,MAXCOLS,17.5,MBOXSIZE,crows=16.5::ISHADE,ccols=12 19 34 45 67 83
cbox LEFTCOL,17.5,MAXCOLS,18.5,MBOXSIZE,ccols=19 67
text 1,16,"Date",ICFONT,cols=11
text 13,16,"Rep ID",ICFONT, cols=5.5
text 20,16,"Order No",ICFONT, cols=14
text 35,16,"Ord Date",ICFONT,cols=10
text 46,16,"Ship Via",ICFONT, cols=20
text 68,16,"Terms",ICFONT, cols=15
text 84,16,"Invoice No",ICFONT, cols=9
cfont 1,17,11,17,DBCFONT
cfont 13,17,18,17,DBCFONT
cfont 20,17,33,17,DBCFONT
cfont 20,18,66,18,DBCFONT
cfont 35,17,44,17,DBCFONT
cfont 46,17,66,17,DBCFONT
cfont 68,17,82,17,DBCFONT
cfont 84,17,92,17,DBCFONT
# watermark - large font with light shading
WATERMARK 1,43.25,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# shade lines
shade "~[0-9][0-9][0-9]@2,22,4,39",-.5,0,92,1,DSHADE
#item descs
font "~[0-9][0-9][0-9]@2,20,4,39",0,1,35,1,DLFONT
# message area
cbox LEFTCOL,44,MAXCOLS,47,MBOXSIZE
cfont 1,45,MAXCOLS,45,IFONT,black
cfont 1,46,66,46,IFONT,black
cfont 68,46,78,46,IFONT
cfont 79,46,91,46,IRFONT,black
# totals
cfont 1,49,13,49,DBRFONT
cfont 15,49,26,49,DBRFONT
cfont 28,49,39,49,DBRFONT
cfont 41,49,51,49,DBRFONT,black
cfont 53,49,63,49,DBRFONT
cfont 65,49,92,49,DBRFONT,black
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
# ----------------------------------------------------------------------
prepage {
	# get invoice title
	# mje 061610 fixed title logic compared w/previous
	doc_title$="INVOICE"
	title$=trim(get(50,2,40))
	if title$="" then doc_title$="INVOICE"
	x$=doc_title$
	x$=sub(x$,"<",""); x$=sub(x$,">",""); 	x$=sub(x$,"  ","~ "); x$=sub(x$," ",""); x$=sub(x$,"~"," ")
	if x$>"" then doc_title$=x$
}
# --- 8.0 ARCHIVING ----------------------------------------------------
	const ARCRULE="invoice"
	prepage {
	noarchive=1
	earc$="EARC_INVOICE",doing_recat=0
	earca_formtype$="std"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	# mje 060210 disabling re row down shift after prepage not handled
	##	#moving these below archiving section re globals
	#	merge "8.0 zMrg PDFLinks v2"
	#	prepage {
	#		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ",20,16,29,16,0,"","","DBCFONT","EARC_ORDLINKLIB","EARC_ORDLINKDOCTY"))
	#	}
	
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(84,10,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_INVOICE"			# Y/N Switch from global section
		bcod_Copies$="3"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docty$="SOINV"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docty$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(84,10,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Invoice"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(8,2,10,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# remark this to ALWAYS print ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=84			# adjust as needed
	local XOFYM_ROW  	=10				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=14,logorows=6
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then :
		copy_title$[CUSTOMER_COPY]="Customer Copy"
	endif
	if MAX_COPIES>=2 then :
		copy_title$[REMITTANCE_COPY]="Remittance Copy"
	endif
	if MAX_COPIES>=3 then :
		copy_title$[FILE_COPY]="File Copy"
	endif
}
prepage {
	if trim(get(50,1,27))<>"" then :
		pcopies=CUSTOMER_COPY
		copy_title$[CUSTOMER_COPY]=trim(get(50,1,27))
	endif
	# mje 061610 title logic was here, moved up
	pageno$=trim(get(80,1,10))
	custno$=trim(get(8,2,10))
	# x$
	merge "zMrg get watermark text"
	xcol=0,xrow=0
	merge "zMrg get company info"
	# now move down to allow space for logo, etc.
	for i=MAXROWS to 9 step -1
		text$[i]=text$[i-6]
		text$[i-6]=""
	next i
	remit$="Remittance Copy - Please return with payment"
	# continued?
	cont$="",sub_line=30
	for i=30 to MAXROWS
		x=pos("(continued"=text$[i])
		if x then :
			cont$="Continued on next page ..."
			sub_line=55
			x$=set(x,i,30,"")
			break
		endif
	next i
	if cont$="" then :
		exec("cbox LEFTCOL,47,MAXCOLS,50,1,crows=48.5::ISHADE, ccols=14 27 40 52 64")
	endif
	if cont$="" then exec("text 1,48,""Non-Taxable"",IRFONT,cols=13")
	if cont$="" then exec("text 15,48,""Taxable"",IRFONT,cols=12")
	if cont$="" then exec("text 28,48,""Sales Tax"",IRFONT,cols=12")
	if cont$="" then exec("text 41,48,""Freight"",IRFONT,cols=11")
	if cont$="" then exec("text 53,48,""Misc"",IRFONT,cols=11")
	if cont$="" then exec("text 65,48,""Invoice Total"",IBRFONT,cols=27")
}
[SO_PickPackListLaser]
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_pick_laser-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_pack_laser-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_pick_laser.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_pack_laser.txt"
detect 62,4,"~ DATEMASK "
detect 6,9,"~ [A-Z0-9a-z*]+"
detect 6,10,"~ [A-Z0-9a-z]+"
# set up document constants
local MAXCOLS=80                        				   # max cols to output
local MAXRCOLS=79                       				   # MAXCOLS-1
local LEFTCOL=1                   					   # left vertical line
local RIGHTCOL=MAXCOLS                      			   # right vertical line
local MAXROWS=66                        				   # max rows to output
cols MAXCOLS                        				   # max output columns
rows MAXROWS                       				   # max output rows
local WHSE_COPY=1
local MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                                				   # graphical shading
title "Pick/Pack List - laser"          				   # view in pdf properties
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,4,EROW,DCFONT                			 # line #
cfont 6,BROW,25,EROW,DBFONT                 			 # item #
cfont 27,BROW,31,EROW,DCFONT                   		 	 # uom
cfont 33,BROW,38,EROW,DCFONT                   		 	 # bin
cfont 40,BROW,52,EROW,DBRFONT                		        # qty ord
cfont 54,BROW,66,EROW,DBRFONT                 			 # qty ship
cfont 68,BROW,MAXRCOLS,EROW,DBRFONT            			 # qty b/o
# header section
cerase 1,1,MAXCOLS,9
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# right header
cbox 60,3,RIGHTCOL,7,1,ccols=70::ISHADE,crows=4 5 6 7
text 61,3.5,"Order #",IFONT,cols=9
text 61,4.5,"Order Date",IFONT,cols=9
text 61,5.5,"Batch #",IFONT,cols=9
text 61,6.5,"Page",IFONT,cols=9
text 71,3.5,{trim(cut(51,4,8,""))},DBFONT,cols=9
text 71,4.5,{trim(cut(63,4,8,""))},DBFONT,cols=9
text 71,5.5,{trim(cut(40,4,6,""))},DBFONT,cols=9
text 71,6.5,{trim(cut(74,4,2,""))},DBFONT,cols=9
cbox 60,7,MAXCOLS,9,1,crows=8::ISHADE
text 61,7.5,"Customer PO #",ICFONT,cols=19
text 61,8.5,{trim(cut(51,7,25,""))},DBFONT
# ship to section
cbox LEFTCOL,9,MAXCOLS,19,MBOXSIZE,ccols=7::ISHADE 41 47::ISHADE
text 2,10,"Ship",ICFONT,cols=5
text 2,11,"To:",ICFONT,cols=5
cfont 7,10,40,17,DBFONT,black
text 2,12,{shipto$},DBCFONT, cols=5
cmove 7,10,40,17,11,10
# sold to section
text 42,10,"Sold",ICFONT,cols=5
text 42,11,"To:",ICFONT,cols=5
cfont 47,10,MAXRCOLS,17,DBFONT
text 42,12,{soldto$},DBCFONT,cols=5
cmove 47,10,MAXRCOLS,17,51,10
# ribbon section
cbox LEFTCOL,19,RIGHTCOL,22,MBOXSIZE,crows=20.5::ISHADE,  ccols=7 13 21 44 58 69
text 2,20,"Slsp 1",ICFONT,cols=5
text 8,20,"Slsp 2",ICFONT,cols=5
text 14,20,"Location",ICFONT,cols=7
text 22,20,"Ship Via",ICFONT,cols=22
text 45,20,"Pack List #",ICFONT,cols=13
text 59,20,"Rqstd Ship Date",ICFONT,cols=10
text 70,20,"Actual Ship Date",ICFONT,cols=10
cfont 2,21,6,21,DBCFONT
cfont 8,21,12,21,DBCFONT,black
cfont 14,21,20,21,DBCFONT
cfont 22,21,43,21,DBCFONT
cfont 45,21,57,21,DBCFONT
cfont 59,21,68,21,DBCFONT
cfont 70,21,MAXRCOLS,21,DBCFONT
# detail
cbox LEFTCOL,22,RIGHTCOL,62,MBOXSIZE,  crows=23.5::DSHADE,ccols=5 32 39 53 67
text 2,23,"Line",ICFONT,cols=3
text 6,23,"Item ID",IFONT,cols=21
text 27,23,"U/M",ICFONT,cols=5
text 33,23,"Bin",ICFONT,cols=6
text 40,23,"Ordered",IRFONT,cols=13
text 54,23,"Shipped",IRFONT,cols=13
text 68,23,"Back Ordered",IRFONT,cols=12
#shade lines
shade "~[0-9][0-9][0-9]@2,24,4,57",-.5,0,79,1,DSHADE
# handle memo lines
font "   @2,24,4,61",4,0,40,1,DFONT,black                   # memo lines
# watermark - large font with light shading
WATERMARK 1,61.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# footer
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
cfont 2,63,MAXCOLS,65,IFONT             			     # memo lines
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="pickpack"
	prepage {
	noarchive=1
	earc$="EARC_PICKPACK",doing_recat=0
	earca_formtype$="pickpacklaser"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	#	merge "8.0 zMrg PDFLinks v2"
	#	prepage {
	#		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ",37,22,46,22,0,"","","DBCFONT","EARC_ORDLINKLIB","EARC_ORDLINKDOCTY"))
	#	}
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=51			# adjust as needed
	local XOFYM_ROW  	=4				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(51,4,8,"y")
		if doc_title$="PICKING SLIP" bcod_docTy$="PSL"
		if doc_title$="PACKING LIST" bcod_docTy$="PAL"
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_PICKPACK"			# Y/N Switch from global section
		bcod_Copies$="1"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				# see prepage above, bcod_docTy$="PL"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docTy$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_PICKPACK"
	if lower(edel$)="y":
		eDocid$=get(51,4,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Pick List"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(7,9,10,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# remark this to ALWAYS print ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=12,logorows=6
	# pick list qty fields are shifted right 1 character more than pack
	pick=0
	for i=24 to 61
		if trim(get(52,i,1))<>"" then pick=1;break
	next i
	if pick then doc_title$="PICKING SLIP"  else doc_title$="PACKING LIST"
	merge "zMrg get watermark text"
	# set up copy titles
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then :
		if pick then :
			copy_title$[WHSE_COPY]="Warehouse Copy"
		else
			copy_title$[WHSE_COPY]="Customer Copy"
		endif
	endif
	# determine if picking list or packing list
}
prepage {
	if trim(get(1,7,50))<>"" then :
		pcopies=WHSE_COPY
		copy_title$[WHSE_COPY]=trim(get(1,7,80))
	endif
	xcol=0,xrow=0
	merge "zMrg get company info"
	shipto$=""
	soldto$=""
	if trim(get(7,9,10))<>"" then :
		shipto$=trim(get(7,9,10))
	endif
	if trim(get(47,9,10))<>"" then :
		soldto$=trim(get(47,9,10))
	endif
	# continued?
	cont$="",sub_line=52
	for i=52 to MAXROWS
		x=pos("(continued"=text$[i])
		if x then :
			cont$="Continued on next page ..."
			sub_line=55
			x$=set(x,i,30,"")
			break
		endif
	next i
}
[SO_PickPackList8.5x11]
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_pick_8.5x11-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_pack_8.5x11-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_pick_8.5x11.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_pack_8.5x11.txt"
detect 0,4,"~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] "
detect 0,4,"~ DATEMASK "
detect 5,9,"~ [A-Z0-9a-z*]+"
detect 5,10,"~ [A-Z0-9a-z]+"
# set up document constants
local MAXCOLS=80                      		   	  	# max cols to output
local MAXRCOLS=79                      		 	  	# MAXCOLS-1
local LEFTCOL=1                         			  	# left vertical line
local RIGHTCOL=MAXCOLS                   			  	# right vertical line
local MAXROWS=66                      			  	# max rows to output
cols MAXCOLS                      				  	# max output columns
rows MAXROWS                       			  	# max output rows
local WHSE_COPY=1
local MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                              				  	# graphical shading
title "Pick/Pack List - 8.5 x 11"        			  	# view in pdf properties
cmove LEFTCOL,1,MAXCOLS,MAXROWS,2,1
# default detail line
local BROW=1
local EROW=MAXROWS
cfont 2,BROW,4,EROW,DCFONT                			  # line#
cfont 6,BROW,25,EROW,DBFONT                 			  # item #
cfont 27,BROW,31,EROW,DCFONT                   		         # uom
cfont 33,BROW,38,EROW,DCFONT                 			  # bin
cfont 40,BROW,52,EROW,DBRFONT                 			  # qty ord
cfont 54,BROW,66,EROW,DBRFONT                 			  # qty ship
cfont 68,BROW,MAXRCOLS,EROW,DBRFONT           			  # qty b/o
# header section
cerase 1,1,MAXCOLS,9
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# right header
cbox 60,3,RIGHTCOL,7,1,ccols=70::ISHADE,crows=4 5 6 7
text 61,3.5,"Order #",IFONT,cols=9
text 61,4.5,"Order Date",IFONT,cols=9
text 61,5.5,"Batch #",IFONT,cols=9
text 61,6.5,"Page",IFONT,cols=9
# mje 060310 chg cut to get re archive timing
text 71,3.5,{trim(get(51,4,8))},DBFONT,cols=9
text 71,4.5,{trim(get(63,4,8))},DBFONT,cols=9
text 71,5.5,{trim(get(40,4,6))},DBFONT,cols=9
text 71,6.5,{trim(cut(74,4,2,""))},DBFONT,cols=9
cbox 60,7,MAXCOLS,9,1,crows=8::ISHADE
text 61,7.5,"Customer PO #",ICFONT,cols=19
text 61,8.5,{trim(get(51,7,25))},DBFONT
# ship to section
cbox LEFTCOL,9,MAXCOLS,19,MBOXSIZE,ccols=6::ISHADE 41 46::ISHADE
text 2,10,"Ship",ICFONT,cols=4
text 2,11,"To",ICFONT,cols=4
cfont 7,10,40,17,DBFONT,black
text 1,12,{shipto$},DBCFONT,cols=6
# sold to section
text 42,10,"Sold",ICFONT,cols=4
text 42,11,"To",ICFONT,cols=4
cfont 47,10,MAXRCOLS,17,DBFONT
text 41,12,{soldto$},DBCFONT,cols=6
# zip bar
#barcode 41,16,{shipzip$},900,12.0,2
# ribbon section
cbox LEFTCOL,19,RIGHTCOL,22,MBOXSIZE,crows=20.5::ISHADE,  ccols=7 13 21 44 58 69
text 2,20,"Slsp 1",ICFONT,cols=5
text 8,20,"Slsp 2",ICFONT,cols=5
text 14,20,"Location",ICFONT,cols=7
text 22,20,"Ship Via",ICFONT,cols=22
text 45,20,"Pack List #",ICFONT,cols=13
text 59,20,"Rqstd Ship Date",ICFONT,cols=10
text 70,20,"Actual Ship Date",ICFONT,cols=10
cfont 2,21,6,21,DBCFONT
cfont 8,21,12,21,DBCFONT,black
cfont 14,21,20,21,DBCFONT
cfont 22,21,43,21,DBCFONT
cfont 45,21,57,21,DBCFONT
cfont 59,21,68,21,DBCFONT
cfont 70,21,MAXRCOLS,21,DBCFONT
# detail
cbox LEFTCOL,22,RIGHTCOL,62,MBOXSIZE,  crows=23.5::DSHADE,ccols=5 32 39 53 67
text 2,23,"Line",ICFONT,cols=3
text 6,23,"Item ID",IFONT,cols=21
text 27,23,"U/M",ICFONT,cols=5
text 33,23,"Bin",ICFONT,cols=6
text 40,23,"Ordered",IRFONT,cols=13
text 54,23,"Shipped",IRFONT,cols=13
text 68,23,"Back Ordered",IRFONT,cols=12
# handle memo lines
font "   @2,24,4,61",4,0,40,1,DFONT,black          		# memo lines
# move for shading
cmove 1,24,MAXCOLS,60,1,25
# shade lines
shade "~[0-9][0-9][0-9]@2,24,4,61",-.5,0,79,1,DSHADE
# watermark - large font with light shading
WATERMARK 1,61.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# footer
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
cfont 2,63,MAXCOLS,65,IFONT            				# memo lines
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="pickpack"
	prepage {
	noarchive=1
	earc$="EARC_PICKPACK",doing_recat=0
	earca_formtype$="pickpack8.5x11"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	#	merge "8.0 zMrg PDFLinks v2"
	#	prepage {
	#		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ",37,22,46,22,0,"","","DBCFONT","EARC_ORDLINKLIB","EARC_ORDLINKDOCTY"))
	#	}
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=51			# adjust as needed
	local XOFYM_ROW  	=4				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(51,4,8,"y")
		if doc_title$="PICKING SLIP" bcod_docTy$="PSL"
		if doc_title$="PACKING LIST" bcod_docTy$="PAL"
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_PICKPACK"			# Y/N Switch from global section
		bcod_Copies$="1"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				# see prepage, bcod_docTy$="PL"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docTy$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_PICKPACK"
	if lower(edel$)="y":
		eDocid$=get(51,4,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Pick List"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(6,9,10,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# remark this to ALWAYS print ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=12,logorows=6
	# pick list qty fields are shifted right 1 character more than pack
	pick=0
	for i=24 to 61
		if trim(get(51,i,1))<>"" then pick=1;break
	next i
	if pick then :
		doc_title$="PICKING SLIP"
	else
		doc_title$="PACKING LIST"
	endif
	merge "zMrg get watermark text"
	# set up copy titles
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then :
		if pick then :
			copy_title$[WHSE_COPY]="Warehouse Copy"
		else
			copy_title$[WHSE_COPY]="Customer Copy"
		endif
	endif
	# determine if picking list or packing list
}
prepage {
	if trim(get(1,7,80))<>"" then :
		pcopies=WHSE_COPY
		copy_title$[WHSE_COPY]=trim(get(1,7,80))
	endif
	xcol=0,xrow=0
	merge "zMrg get company info"
	shipto$=""
	soldto$=""
	if trim(get(6,9,10))<>"" then :
		shipto$=trim(get(6,9,10))
	endif
	if trim(get(46,9,10))<>"" then :
		soldto$=trim(get(46,9,10))
	endif
	# continued?
	cont$="",sub_line=52
	for i=52 to MAXROWS
		x=pos("(continued"=text$[i])
		if x then :
			cont$="Continued on next page ..."
			sub_line=55
			x$=set(x,i,30,"")
			break
		endif
	next i
	
	# add zip barcode
	xrow=13;xcols=40
	#merge "zmrg get zip"
}
[SO_PackListPlain]
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/formplain/so_pack_plain-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/formplain/so_pack_plain.txt"
detect 0,1,"P A C K I N G   L I S T"
# set up document constants
local MAXCOLS=125                      		 	# max cols to output
local MAXRCOLS=124                		        	# MAXCOLS-1
local LEFTCOL=1                 		        	# left vertical line
local RIGHTCOL=MAXCOLS             		 	# right vertical line
local MAXROWS=66                    	        	# max rows to output
cols MAXCOLS                     		        	# max output columns
rows MAXROWS                        		 	# max output rows
local CUSTOMER_COPY=1
local MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                               		 	# graphical shading
title "Pack List - plain"           		 	# view in pdf properties
cmove LEFTCOL,1,MAXCOLS,MAXROWS,1,4
cerase 127,1,131,MAXROWS  # mje 062910, why needed if maxcols is 125?
# default detail line
cbox LEFTCOL,21.5,RIGHTCOL,64,MBOXSIZE,crows=22.5::DSHADE,ccols=14 65 72 88 107
local BROW=1
local EROW=MAXROWS
cfont 7,BROW,13,EROW,DBLFONT                   			# line #
cfont 15,BROW,53,EROW,DFONT               			# item #/desc
cfont 55,BROW,64,EROW,DBCFONT                   		# bin
cfont 66,BROW,71,EROW,DCFONT	                   		# units
cfont 73,BROW,87,EROW,DBRFONT                   		# qty ord
cfont 89,BROW,106,EROW,DBRFONT             			# qty ship
cfont 108,BROW,MAXRCOLS,EROW,DBRFONT            		# qty b/o
local BROW=22
local EROW=22
cfont 7,BROW,13,EROW,ILFONT                    			# line #
cfont 15,BROW,53,EROW,IFONT                			# item #/desc
cfont 55,BROW,64,EROW,ICFONT                    		# bin
cfont 66,BROW,71,EROW,ICFONT                    		# units
cfont 73,BROW,87,EROW,IRFONT                    		# qty ord
cfont 89,BROW,106,EROW,IRFONT                   		# qty ship
cfont 108,BROW,MAXRCOLS,EROW,IRFONT             		# qty b/o
# header section
cerase 1,1,MAXCOLS,7
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9.5:MBOXSIZE
merge "zMrg Form Header"
# right header
cbox 100,5.5,RIGHTCOL,7.5,1,ccols=115::ISHADE,crows=6.5
text 101,6,"Batch No.",IFONT
text 116,6,{trim(cut(83,4,6,""))},DBFONT
text 101,7,"Picking Slip #",IFONT
text 116,7,{trim(cut(107,5,15,""))},DBFONT
# ribbon section
cbox LEFTCOL,9.5,RIGHTCOL,12.5,MBOXSIZE,crows=10.5::ISHADE,  ccols= 22 34 44 55 72 115
cbox 92,9.5,115,11.5
cfont 8,10,20,10,ILFONT
cfont 22,10,33,10,ICFONT
cfont 35,10,43,10,ICFONT
cfont 45,10,54,10,ICFONT
cfont 56,10,71,10,ICFONT
cfont 73,10,90,10,ICFONT
cfont 92,10,113,10,ICFONT
cfont 115,10,MAXCOLS,10,ICFONT
cfont 8,11,20,11,DBLFONT,black
cfont 22,11,33,11,DBCFONT,black
cfont 35,11,43,11,DBCFONT,black
cfont 45,11,54,11,DBCFONT,black
cfont 56,11,71,11,DBCFONT,black
cfont 73,11,90,11,DBCFONT,black
cfont 73,12,113,12,DBFONT,black
cfont 92,11,113,11,DBCFONT,black
cfont 115,11,MAXCOLS,11,DBCFONT,black
#remove ship to and sold to
cerase 16,15,24,15
cerase 57,15,65,15
# ship to section
cbox LEFTCOL,12.5,MAXCOLS,21.5,MBOXSIZE,ccols=10::ISHADE 57 66::ISHADE
text 2,13,"Ship\nTo:",ICFONT,cols=8
text 11,13,{mcut(26,12,30,4,"","Y","Y")},DBFONT
text 3,15,{shipto$},DBFONT
#shade lines
shade "~[0-9][0-9][0-9]@11,23,13,60",-9.5,0,124,1,DSHADE
#item descriptions
font "~[0-9][0-9][0-9]@11,23,13,60",4,0,10,1,DBLFONT
# sold to section
text 58,13,"Sold\nTo:",ICFONT,cols=8
text 67,13,{mcut(67,12,30,4,"","Y","Y")},DBFONT
text 58.5,15,{soldto$},DBFONT
# watermark - large font with light shading
WATERMARK 1,63.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# footer
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
cfont 2,63,MAXCOLS,65,IFONT             # memo lines
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="pickpack"
	prepage {
	noarchive=1
	earc$="EARC_PICKPACK",doing_recat=0
	earca_formtype$="packplain"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	#	merge "8.0 zMrg PDFLinks v2"
	#	prepage {
	#		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ",37,22,46,22,0,"","","DBCFONT","EARC_ORDLINKLIB","EARC_ORDLINKDOCTY"))
	#	}
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(11,8,8,"y")
		# targDoctys$="Picking List,Packing List,Picking Slip"
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_PICKPACK"			# Y/N Switch from global section
		bcod_Copies$="1"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docTy$="PAL"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docTy$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_PICKPACK"
	if lower(edel$)="y":
		eDocid$=get(11,8,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Pack List"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(67,11,10,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# remark this to ALWAYS print ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=11			# adjust as needed
	local XOFYM_ROW  	=8				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=14,logorows=6
	doc_title$="PACKING LIST"
	merge "zMrg get watermark text"
	# set up copy titles
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then  copy_title$[CUSTOMER_COPY]="Customer Copy"
}
prepage {
	if trim(get(80,2,80))<>"" then :
		pcopies=CUSTOMER_COPY
		copy_title$[CUSTOMER_COPY]=trim(get(80,2,80))
	endif
	xcol=31,xrow=2
	merge "zMrg get company info"
	shipto$=""
	soldto$=""
	if trim(get(26,11,10))<>"" then :
		shipto$=trim(cut(26,11,10,""))
	endif
	if trim(get(67,11,10))<>"" then :
		soldto$=trim(cut(67,11,10,""))
	endif
	# continued?
		nextpageno$=""
	cont$=""
	nextpageno$=get(119,8,1,1,pagenum+1)
	if nextpageno$<>"1" then :
		cont$="Continued on Next Page..."
		if nextpageno$=""	 then :
			cont$=""
		endif
	endif
}
[SO_PickSlipPlain]
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/formplain/so_pick_plain.txt"
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/osas-txt/formplain/so_pick_plain-nocopy.txt"
detect 0,1,"P I C K I N G   S L I P"
# set up document constants
local MAXCOLS=125                      		 	# max cols to output
local MAXRCOLS=124                 		 	# MAXCOLS-1
local LEFTCOL=1                   			 	# left vertical line
local RIGHTCOL=MAXCOLS            		        	# right vertical line
local MAXROWS=66                    		 	# max rows to output
cols MAXCOLS                      			 	# max output columns
rows MAXROWS                     		        	# max output rows
local WHSE_COPY=1
local MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                               		  	# graphical shading
title "Pick Slip - plain"         		         	# view in pdf properties
cmove LEFTCOL,1,MAXCOLS,MAXROWS,1,3
# default detail line
cbox LEFTCOL,21,RIGHTCOL,64,MBOXSIZE,crows=23::DSHADE,ccols=14 54 65 72 88 107
local BROW=21
local EROW=59
cfont 2,BROW,13,EROW,DCFONT                 	  		# line #
cfont 15,BROW,53,EROW,DFONT               	  		# item #/desc
cfont 55,BROW,64,EROW,DCFONT                     		# bin
cfont 66,BROW,71,EROW,DCFONT                     		# units
cfont 73,BROW,87,EROW,DBRFONT                     		# qty ord
cfont 89,BROW,106,EROW,DBRFONT            	  		# qty ship
cfont 108,BROW,MAXRCOLS,EROW,DBRFONT              		# qty b/o
local BROW=22
local EROW=22
cfont 2,BROW,13,EROW,ICFONT                      		# line #
cfont 15,BROW,53,EROW,IFONT                 	  		# item #/desc
cfont 55,BROW,64,EROW,ICFONT                      		# bin
cfont 66,BROW,71,EROW,ICFONT                      		# units
cfont 73,BROW,87,EROW,IRFONT                      		# qty ord
cfont 89,BROW,106,EROW,IRFONT                     		# qty ship
cfont 108,BROW,MAXRCOLS,EROW,IRFONT               		# qty b/o
# header section
cerase 1,1,MAXCOLS,8
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# right header
cbox 100,5.5,RIGHTCOL,7.5,1,ccols=115::ISHADE,crows=6.5
text 101,6,"Batch No.",IFONT
text 116,6,{trim(cut(83,5,6,""))},DBFONT
text 101,7,"Picking Slip #",IFONT
text 116,7,{trim(cut(107,6,15,""))},DBFONT
# ribbon section
cbox LEFTCOL,9,RIGHTCOL,12.5,MBOXSIZE,crows=10.5::ISHADE,  ccols= 19 34 44 55 72 115
cbox 91,9,115,11.5
cfont 2,10,18,10,ICFONT
cfont 20,10,33,10,ICFONT
cfont 35,10,43,10,ICFONT
cfont 45,10,54,10,ICFONT
cfont 56,10,71,10,ICFONT
cfont 73,10,90,10,ICFONT
cfont 92,10,113,10,ICFONT
cfont 115,10,MAXCOLS,10,ICFONT
cfont 2,11,18,11,DBCFONT,black
cfont 20,11,33,11,DBCFONT,black
cfont 35,11,43,11,DBCFONT,black
cfont 45,11,54,11,DBCFONT,black
cfont 56,11,71,11,DBCFONT,black
cfont 73,11,90,11,DBCFONT,black
cfont 73,12,113,12,DBFONT,black
cfont 92,11,113,11,DBCFONT,black
cfont 115,11,MAXCOLS,11,DBCFONT,black
# ship to section
cbox LEFTCOL,12.5,MAXCOLS,21,MBOXSIZE,ccols=10::ISHADE 57 66::ISHADE
text 2,14,{trim(cut(17,13,8,""))},ICFONT,cols=8
text 11,14,{mcut(26,13,30,5,"","Y","Y")},DBFONT
text 2,15,{shipto$},DBFONT
# sold to section
text 58,14,{trim(cut(58,13,8,""))},ICFONT,cols=8
text 67,14,{mcut(67,13,30,5,"","Y","Y")},DBFONT
text 58,15,{soldto$},DBFONT
# zip bar
#barcode 41,16,{shipzip$},900,12.0,2
# shade lines
shade "~[0-9][0-9][0-9]@11,24,13,59",-9.5,0,124,1,DSHADE
# bold item numbers
font "~[0-9][0-9][0-9]@11,24,13,59",3,0,35,1,DBFONT
# watermark - large font with light shading
WATERMARK 1,63.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# footer
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
cfont 2,63,MAXCOLS,65,IFONT            		 # memo lines
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="pickpack"
	prepage {
	noarchive=1
	earc$="EARC_PICKPACK",doing_recat=0
	earca_formtype$="pickplain"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	#	merge "8.0 zMrg PDFLinks v2"
	#	prepage {
	#		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ",37,22,46,22,0,"","","DBCFONT","EARC_ORDLINKLIB","EARC_ORDLINKDOCTY"))
	#	}
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=11			# adjust as needed
	local XOFYM_ROW  	=9				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(11,9,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_PICKPACK"			# Y/N Switch from global section
		bcod_Copies$="1"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docTy$="PSL"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docTy$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_PICKPACK"
	if lower(edel$)="y":
		eDocid$=get(11,9,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Pick List"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(67,12,10,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# remark this to ALWAYS print ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=14,logorows=6
	doc_title$="PICKING SLIP"
	merge "zMrg get watermark text"
	# set up copy titles
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then :
		copy_title$[WHSE_COPY]="Warehouse Copy"
	endif
}
prepage {
	if trim(get(70,2,60))<>"" then :
		pcopies=WHSE_COPY
		copy_title$[WHSE_COPY]=trim(get(70,2,60))
	endif
	xcol=31,xrow=2
	merge "zMrg get company info"
	shipto$=""
	soldto$=""
	if trim(get(26,12,10))<>"" then :
		shipto$=trim(cut(26,12,10,""))
	endif
	if trim(get(67,12,10))<>"" then :
		soldto$=trim(cut(67,12,10,""))
	endif
	# continued?
	cont$="",sub_line=52
	for i=52 to MAXROWS
		x=pos("(continued"=text$[i])
		if x then :
			cont$="Continued on next page ..."
			sub_line=55
			x$=set(x,i,30,"")
			break
		endif
	next i
	
	# add zip barcode
	xrow=13;xcols=40
	#merge "zmrg get zip"
}
[SO_PickListStd]
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_pick_std-nocopy.txt"
dsn_sample "/u0/unform_test/_oem/osas/txt7/so_pick_std.txt"
detect 0,1,"Batch"
detect 0,5,"~[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] "
detect 0,5,"~ DATEMASK "
detect 56,9,"~ [A-Z0-9a-z*]+"
detect 56,10,"~ [A-Z0-9a-z]+"
# set up document constants
local MAXCOLS=107                        			    # max cols to output
local MAXRCOLS=106                       			    # MAXCOLS-1
local LEFTCOL=1                          			    # left vertical line
local RIGHTCOL=MAXCOLS                   			    # right vertical line
local MAXROWS=66                      			    # max rows to output
cols MAXCOLS                     				    # max output columns
rows MAXROWS                  				           # max output rows
page 66
local WHSE_COPY=1
local MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                                 			    # graphical shading
title "Pick List - std"          				    # view in pdf properties
cmove LEFTCOL,1,RIGHTCOL,MAXROWS,2,2
# header section
cerase 1,1,MAXCOLS,7
cbox LEFTCOL,1,RIGHTCOL,MAXROWS,MBOXSIZE,crows=9:MBOXSIZE
merge "zMrg Form Header"
# right header
cbox 80,6.5,MAXCOLS,9,1,crows=7.5::ISHADE,ccols=95
text 81,7,"Picking Slip #",ICFONT, cols=14
text 96,7,"Batch #",ICFONT, cols=11
text 81,8,{pslipno$},DBCFONT, cols=14
text 96,8,{batchno$},DBCFONT, cols=11
# subhead
cbox LEFTCOL,9,MAXCOLS,10.5,1,ISHADE,ccols=10 20 31 42 57 69 101
cbox LEFTCOL,10.5,57,11.5,ccols=10 20 31 42
cbox 69,10.5,MAXCOLS,11.5,ccols=101 57
cbox 57,9,57,12.5
cbox 101,9,101,12.5
cbox 57,12.5,101,12.5
text 1,10,"Order #",ICFONT, cols=10
text 11,10,"Order Date",ICFONT,cols=9
text 21,10,"Loc Id",ICFONT, cols=10
text 32,10,"Ship Date",ICFONT,cols=10
text 43,10,"Req'd Ship Date",ICFONT,cols=15
text 58,10,"Cust. P/O #",ICFONT,cols=11
text 70,10,"Ship Via",ICFONT, cols=31
text 102,10,"Page #",ICFONT, cols=5
cmove 1,9,MAXCOLS,10,1,11
cfont 2,11,9,11,DBCFONT
cfont 11,11,19,11,DBCFONT
cfont 21,11,30,11,DBCFONT
cfont 32,11,41,11,DBCFONT
cfont 43,11,56,11,DBCFONT
cfont 58,11,68,11,DBCFONT
cfont 70,11,100,11,DBCFONT
cfont 102,11,MAXCOLS,11,DBCFONT
cfont 58,12,100,12,DBCFONT
# address region
cbox LEFTCOL,13,MAXCOLS,19,ccols=8::ISHADE 49 57::ISHADE
text 1,14,"Ship \nTo:",ICFONT, cols=7
text 50,14,"Sold \nTo:",ICFONT, cols=7
cfont 9,14,49,19,DBFONT
cfont 57,14,MAXCOLS,19,DBFONT
text 50,16,{custno$},DBFONT, cols=7.5
cmove 16,14,49,19,9,14
cmove 57,14,MAXCOLS,19,59,14
# items
cbox LEFTCOL,19,MAXCOLS,63,1,,crows=21::DSHADE, ccols=5 51 57 73 88
text 2,20,"Line",IFONT
text 6,20,"Item/Description",IFONT
text 52,20,"Units",ICFONT, cols=5
text 58,20,"Qty Ordered",IRFONT,cols=15
text 74,20,"Qty Shipped",IRFONT,cols=14
text 89,20,"Qty Backordered",IRFONT,cols=18
cfont 2,21,4,62,DFONT
cfont 6,21,50,62,DFONT
cfont 52,21,56,62,DCFONT
cfont 58,21,72,62,DBRFONT
cfont 74,21,87,62,DBRFONT
cfont 89,21,105,62,DRFONT
cerase 43,21,47,54
#shade lines
shade "~[0-9][0-9][0-9]@2,22,4,58",-.5,0,106,1,DSHADE
#bold item numbers
font "~[0-9][0-9][0-9]@2,22,4,58",4.5,0,40,0,DBLFONT,9
# watermark - large font with light shading
WATERMARK 1,62.5,{doc_title$},cgtimes,120,shade=WATERMARK_SHADE,center,cols=MAXCOLS,fit,spacing=.75
# memo lines
font "    @1,21,4,55",5,0,90,1,DLFONT
# footer
text 1,{MAXROWS+.5},{copy_title$[copy]},DBCFONT,cols=MAXCOLS
text 1,{MAXROWS+.5},{cont$},DBRFONT,cols=MAXRCOLS
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="pickpack"
	prepage {
	noarchive=1
	earc$="EARC_PICKPACK",doing_recat=0
	earca_formtype$="pickstd"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	#	merge "8.0 zMrg PDFLinks v2"
	#	prepage {
	#		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ",37,22,46,22,0,"","","DBCFONT","EARC_ORDLINKLIB","EARC_ORDLINKDOCTY"))
	#	}
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=1			# adjust as needed
	local XOFYM_ROW  	=5				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(1,5,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_PICKPACK"			# Y/N Switch from global section
		bcod_Copies$="1"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docTy$="PL"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docTy$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_PICKPACK"
	if lower(edel$)="y":
		eDocid$=get(1,5,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Pick List"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(57,9,10,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# remark this to ALWAYS print ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
prejob {
	logocols=12,logorows=6
	# set up copy titles
	dim copy_title$[MAX_COPIES]
	if MAX_COPIES>=1 then :
		if pick then :
			copy_title$[WHSE_COPY]="Warehouse Copy"
		else
			copy_title$[WHSE_COPY]="Customer Copy"
		endif
	endif
	# mje 062810 moved from prepage
	doc_title$="PICKING LIST"
}
prepage {
	if trim(get(1,2,70))<>"" then :
		pcopies=WHSE_COPY
		copy_title$[WHSE_COPY]=trim(get(1,2,70))
	endif
	xcol=0,xrow=0
	merge "zMrg get company info"
	batchno$=trim(get(83,1,6))
	pslipno$=trim(get(100,2,6))
	custno$=trim(cut(57,9,10,""))
	for i=MAXROWS to 5 step -1
		text$[i]=text$[i-3]
		text$[i-3]=""
	next i
	# continued?
	cont$="",sub_line=52
	for i=52 to MAXROWS
		x=pos("(continued"=text$[i])
		if x then :
			cont$="Continued on next page ..."
			sub_line=55
			x$=set(x,i,30,"")
			break
		endif
	next i
}
[Generic]
# This rule set will set columns & rows and
# enhance the hdg for all other reports
# requires UnForm 5
detect 0,1,"~(PAGE)|(Page)"
# set up document constants
local MAXCOLS=250                     		   	    	# max cols to output
local MAXROWS=66                       		  	    	# max rows to output
cols MAXCOLS                     		 		    	# max output columns
rows MAXROWS                       			    	# max output rows
local MAX_COPIES=1
pcopies MAX_COPIES
portrait
dpi 600
# see global constant above
#GSON                               			   	# graphical shading
title "Generic"                		     		   	# 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))
		endif
	next i
	cols$=str(maxlen+1)
	# load row 1 variables
	rptdate$=trim(get(1,1,10))
	x=pos("PAGE"=text$[1])
	if x=0 then x=pos("Page"=text$[1])
	pageno$=trim(get(x,1,11))
	compname$=trim(get(21,1,x-1-20))
	x$=set(1,1,200,"")
	# load row 2 variables
	time$=trim(get(1,2,10))
	x=pos("AM"=time$)
	if x=0 then x=pos("PM"=time$)
	if x=0 then :
		left2$=trim(get(1,2,20))
		time$=""
	endif
	title$=trim(get(21,2,100))
	x$=set(1,2,200,"")
	# load row 3 variables
	if time$="" then time$=trim(get(1,3,10))
	subtitle$=trim(get(21,3,100))
	x$=set(1,3,200,"")
	# Now draw box around header
	exec("cbox 1,.5,"+cols$+",3.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$+title$+$22$+  ",HBCFONT,12,cols="+str(maxlen)
	exec(x$)
	# now place line 3 headers that need justification
	x$="text 1,3.25,"+$22$+subtitle$+$22$+  ",HBCFONT,cols="+str(maxlen)
	exec(x$)
}
text 2,1.25,{rptdate$},HBFONT
text 2,2.25,{time$},HBFONT
text 2,3.25,{left2$},HBFONT
font "~(End of Report)|(END OF REPORT)",0,0,13,1,HBFONT
[-------]
[8.0 README]
dsn_sample "/u0/unform_test/_oem/osas/osas7/uf8/readme-osas-uf8.txt"
# To view this readme section inside the design tool without
# color and syntax error red-mark lines, TURN OFF syntax
# highlighting by pressing the color palette on the ribbon
# menu above!!
UnForm 8.0 Rule-file and supporting demo files for Osas 7.5
Including these integrated features:
(as of 07/14/2010)
	- Archiving preconfigured with standard properties
	- Scanning barcodes on forms
	- Statement with attached scanned proof of delivery copies
		out of archive
	- PDF hyperlinks to invoices in archived statement
	- Electronic form delivery by email or fax
	- Page X of Y counters on forms and reports
------
	1
------
	"osas7-8.zip" File
	Extract or place the contents into the main unform server folder.
	Contents:
	
	- osas7-8.rul file
	- build80demo.sh for Linux/Unix
	- build80demo.vbs for Windows
	- osas-txt/ folder containing sample text files
	- osas-scan/ folder containing sample scans and the OSAS_DOCS image
		manager job definition.
------
	2
------
	New "utility" rulesets in the osas7-8.rul file which support the new
	features:
	[8.0 zMrg Configurator]
	[8.0 zMrg ArcProps]
	[8.0 zMrg PDFLinks v2]
	[8.0 EDM6 BOOK]
	[8.0 ED TAG PARSER]
	[8.0 ED Selective Copy Printing]
	[zMrgMultiPageXofY]
	[zMrgSinglePageXofY]
------
	3
------
	TURNING FEATURES OFF AND ON:
	Top global section of the rule file has:
		merge "8.0 zMrg Configurator"
	to include the global constants that turn the new features ON/OFF by
	feature and ruleset.
	See the constants in "8.0 zMrg Configurator" for which forms are
	archive-enabled, deliver-enabled, or scanning barcode-enabled, and to
	turn them on/off. BY DEFAULT THEY ARE TURNED OFF WHEN DISTRIBUTED.
------
	4
------
	For each Osas "enhancement" rule-set:
	Original code blocks were moved to the bottom of the rule-set so that
	timing of text movement would be performed AFTER get() functions needed
	for archiving and deliver properties.
	Where applicable, the following code sections were inserted with processing
	code at the BOTTOM of existing rule-sets, but BEFORE the original code
	block section.
	# --- 8.0 ARCHIVING ------------------
	# --- PDF HYPERLINK FOR ARCHIVING ----
	# --- 8.0 DELIVER --------------------
	# --- PAGE X of Y FEATURE ------------
	# --- ATTACH SCANNED IMAGES ----------
	# --- SCANNING BARCODE ---------------
	Here's a cross-reference between the new rule-set sections and the new utility
	rule-sets that are merged:
	# --- 8.0 ARCHIVING ------------------
			merge "8.0 zMrg Arcprops"
	# --- PDF HYPERLINK FOR ARCHIVING ----
			merge "8.0 zMrg PDFLinks v2
	# --- 8.0 DELIVER --------------------
			merge "8.0 EDM6 BOOK"
			(which in turn does: merge "8.0 ED TAG PARSER")
			merge "8.0 Selective Copy Printing"
	# --- PAGE X of Y FEATURE ------------
				Forms: merge "zMrgMultiPageXofY"
			Reports: merge "zMrgSinglePageXofY"
	# --- ATTACH SCANNED IMAGES ----------
			(No merges)
			(Statement forms only)
	# --- SCANNING BARCODE ---------------
			(No merges)
------
	5
------
	ARCHIVING notes:
	Archiving properties for each form and report are maintained centrally in
	the "8.0 zMrg ArcProps" rule-set. This model is used to facilitate mass
	re-indexing processes. By centralizing archive properties by form or report
	type in a single rule-set, a mass re-indexing rule-set will be able to
	access property assignments for multiple doc types in the same place that
	the new property assignments are coded for print jobs.
	For OSAS, because of multiple form-type selections, a mass re-indexing job
	would need to account for the proper form type when using this model.
	Contact SDSI for consultation or assistance if you encounter the need to
	re-index your archive libraries.
	"8.0 zMrgArcProps" rule-set Maintenance:
	
	To change the library names created on your system:
	Change the following local constant to zero:
	local EARC_LIBCOABRSUB=1
	And/or change or make null ("") this library company abgreviation prefix:
	local EARC_COABREVSUJ="Osas80"
	
	See the individual form "case" statements for each ruleset to modify the
	earca_library$ variable to change the library name from "Sales",
	"Accounting", etc.
------
	6
------
	DELIVER notes:
	8.0 uses the new DELIVER command.
	Addresses are retrieved from an address book named "osas" using an address
	entity ID somewhere on the form, e.g. customer number, vendor number, etc.
	If the address retrieved contains an @-sign an EMAIL will be submitted.
	If the address retrieved does NOT contain @-sign, a FAX will be initiated.
	You can customize tags for each form individually within each rule-set,
	in the routine underneath the merge for the address book.
	You must configure/maintain the deliver.ini file for email tag and fax
	settings.
	You must configure/maintain the prog/mailcall.ini file for email smtp
	server settings.
	More information is available on *.ini configuration in unform80.pdf.
	The "osas" address book can be defined in the UnForm browser interface.
	You can import addresses from an appropriately mapped CSV file to populate
	the address book.
	See the "8.0 EDM6 BOOK" merged rule-set to see a hierarchy for looking up
	address info that demonstrates how to look up addresses with or without
	document types, suffixes or prefixes. The routines here are for
	demonstration purposes -- you can modify the address lookup logic to suit
	your needs, and/or contact SDSI for assistance.
	If you want to use a method other than the address book method, contact
	SDSI about tailoring one of the pre-developed merge rule-sets for other
	methods that are contained in the samples/eDeliver8.0.rul file. Contact
	SDSI for possible updates to these templates.
------
	7
------
	SCANNING BARCODE notes:
	See the "BCOD_" series of contants in "8.0 zMrg Configurator" to turn
	scanning barcodes ON or OFF by form.
	This line in the scanning barcode section opens up 7 rows at the bottom
	of the form for placement of barcodes, and causes the rest of the
	form to resize with a maintenance of its aspect ratio:
	
		rows$=str(MAXROWS+7)
	This line allows you to specify which copy of a form gets a barcode:
	
		bcod_Copies$="2"	# which copy(s) get barcode
	To include the barcode on multiple copies, add the copy numbers to
	the string, e.g. bcod_Copies$="123". Note that this syntax maxes out at
	9 copies, so the pos() function would need to be modified if copy
	numbers above 9 need to be referenced.
	The bcod_docty$ variable places an abbreviated doctype code on the form
	that is mapped to the full archive document type in the image manager
	job definition that automates property index assignment on scanned
	documents. IF YOU CHANGE A DOCUMENT TYPE IN THE ARCHIVING RULE-SET,
	YOU MUST CHANGE THE CORRESPONDING ENTRY IN THE SCANNING JOB DEFINITION,
	IF THAT DOCUMENT WILL BE SCANNED AND UPLOADED.
------
	8
------
	SCANNING JOB DEFINITION notes:
	
	A scanning job defintion is provided called "OSAS_DOCS.ufz" in the
	"osas-scan" folder. Copy this file to the scanning/JobDefs folder
	of the image manager workstation. It has been designed to detect and
	process all the barcoded osas forms using a single job, including
	header/attachment jobs where attachment pages receive the same
	indexes as the header page. Demo scanned images are provided
	for importing, both regular scans with no attachment pages, as well
	as ones with attachment pages.
	
------
	9
------
	DEMO BUILD SCRIPT notes:
	**CAUTION** THESE SCRIPTS ARE DESTRUCTIVE TO PREVIOUSLY ARCHIVED
	DOCUMENTS. PLEASE READ THIS CAREFULLY BEFORE USING THEM.
	
	- build80demo.sh for Linux/Unix
	- build80demo.vbs for Windows
	Execute the appropriate script from the server folder where the zip file
	was extracted. It builds demo archives from the text samples contained
	in the "osas-txt" subfolders. Note that the scripts have some settings
	at the top of each file for specifying what form types you want to build
	for forms and checks.
	
	WHEN LAUNCHED, THE SCRIPTS START BY REMOVING THE SAMPLE LIBRARIES, SO
	DO NOT RUN THESE SCRIPTS ON A LIVE SYSTEM THAT USES THE SAME LIBRARY
	NAMES AS THE DEMO!!
	
	See the Archive notes for how to change the library names for the live
	system.
	
	Or modify the library name prefix at the top of the scripts to
	reference a non-live set of libraries.
	The build scripts will also create PDF's of the documents in the
	respective text file folders. If deliver feature is enabled and
	address book entries exist for document recipient entities then
	emails or faxes will be attempted, assuming proper configuration
	of deliver.ini and mailcall.ini.
------
	10
------
	
	ATTACH SCANNED IMAGE notes:
	
	The AR statement rule-sets contain a routine to retrieve scanned
	copies of invoices from the archive and attach them to the statement.
	
	There is a global to turn this feature ON or OFF in the constants
	merged rule-sets.
	
	By default, for each invoice listed on a statement, the routine looks
	for document images based on the following variables:
			
	dotypes$="Scan"
	- the image sub-id begins with the word "Scan"
	- change this in the ruleset if you change the sub-id in the scanning job definition
	tktlib$="Osas80_Sales"
	- change this in the ruleset to match your ssytem
	tktdocty$="Invoice"
	- change this in the ruleset if you change the doc type for archived invoices
	Imagemagick and/or Ghostscript must be available for this feature to work.
	By default images are tiled 2 across, 2 down in portrait orientation, as
	seen in the below command:
	
		images {images$},across 2, down 2
	Remove the across and down arguments to attach full page images.
[8.0 zMrg Configurator]
# Attach scanned invoice proof of delv to statement copy 1
global STM_ATTCH_SCAN=N
# Archiving ON=Y OFF=N for rule-sets
global EARC_INVOICE=N
global EARC_PICKPACK=N
global EARC_BILLOFLADING=N
global EARC_STATEMENT=N
global EARC_PURCHORDER=N
global EARC_APCHECK=N
global EARC_PRCHECK=N
global EARC_DDVOUCH=N
global EARC_TRIALBAL=N
global EARC_BALSHEET=N
global EARC_INCSTMT=N
global EARC_APAGING=N
global EARC_ARAGING=N
# Barcode for Scanning Copy: ON=Y OFF=N for rule-sets
global BCOD_INVOICE=N
global BCOD_PICKPACK=N
global BCOD_BILLOFLADING=N
global BCOD_PURCHORDER=N
global EDEL_METHOD="8.0 EDM6 BOOK"
# Delivery(Email/Fax/Selective Copy Print)
# ON=Y OFF=N for rule-sets
global EDEL_INVOICE=N
global EDEL_PICKPACK=N
global EDEL_STATEMENT=N
global EDEL_PURCHORDER=N
global EDEL_DDVOUCH=N
# Note, below rule-sets do not have deliver logic embedded
# global EDEL_BILLOFLADING=N
# global EDEL_PRCHECK=N
# global EDEL_APCHECK=N
# global EDEL_TRIALBAL=N
# global EDEL_BALSHEET=N
# global EDEL_INCSTMT=N
# global EDEL_APAGING=N
# global EDEL_ARAGING=N
# Barcode symbology selection
# 400=Code 3 of 9, supported by virtually all devices.
#     Note it only supports digits, upper-case letters
#     spaces, and these characters: - . $ / + %.
# 605=Code 128 Series B, which offers support for
#     a wide range of printable characters.  Most barcode
#     reading devices, including UnForm Image Manager
#     software, support this symbology.
# We default to 605 due to its flexible character support.
const BCSYMB=605
[8.0 zMrg ArcProps]
# version 8.0
# placing archiving-related property assignments together in a
# merged rule-set like this is designed to make the RE-GENERATION
# of properties
# establish text-based docdate format for date conversion
# into segments adjust this format to fit your document
local EARCA_DATEFMT="MM/DD/YYYY"
# Turn flag off (=0) to bypass prefixing the Co Abbrev to the library names
local EARC_LIBCOABRSUB=1
local EARC_COABREVSUJ="Osas80"
prejob {
	day_format "EARCA_DATEFMT"
	earca_momask$="%Mz(%Ms)"
	earca_dtsep$="-"
	# v 7.x category compatibility
	#	earca_71$="N"  # "EARCA_71"
	#	if lower(earca_71$)="y":
	#		earca_momask$="%Ms"
	#		earca_dtsep$=" "
	#	endif
	# defs for date categories
	def fnearca_yyyy$(q$)=dte(q$:"%Ys")
	def fnearca_mmm$(q$)=earca_dtsep$+dte(q$:earca_momask$)
	def fnearca_dd$(q$)=earca_dtsep$+dte(q$:"%Dz")
	def fnearca_yyyymmmdd$(q$)=fnearca_yyyy$(q$)+"|"+fnearca_yyyy$(q$)+fnearca_mmm$(q$)+"|"+fnearca_yyyy$(q$)+fnearca_mmm$(q$)+fnearca_dd$(q$)
	def fnearca_yyyymmm$(q$)=fnearca_yyyy$(q$)+"|"+fnearca_yyyy$(q$)+fnearca_mmm$(q$)
	# mje 060210
	def fnUpdateLink(local doclib$,local doctype$,local docid$,local link$)
	local props$
	arcrval=0
	if docidexists(doclib$,doctype$,docid$) then:
		arcrval=1
		getdocidprop(doclib$,doctype$,docid$,props$)
		props.links$=sub(props.links$,link$,"")
		props.links$=sub(props.links$,";;",";")
		if props.links$>"" then props.links$+=";"
		props.links$+=link$
		putdocidprop(doclib$,doctype$,docid$,props$)
	end if
	return arcrval
	end def
	# mje 052810, handle "MAR 15 2010" style date
	def fnumo$(umo$)
		dd1$="janfebmaraprmayjunjulaugsepoctnovdec"
		dd2$="01 02 03 04 05 06 07 08 09 10 11 12 "
		umo$=lower(umo$),newmo$=""
		xx=pos(umo$=dd1$)
		if xx newmo$=dd2$(xx,2)
		return newmo$
	fnend
}
# AR statement pdf hot link library and docty
global EARC_STMLINKLIB="Osas80_Sales"
global EARC_STMLINKDOCTY="Invoice"
# Invoice pdf hot link library and docty
global EARC_ORDLINKLIB="Osas80_Sales"
global EARC_ORDLINKDOCTY="Order"
postjob {
# bypass during postjob; code is for gosub purposes
goto skipcode1
process_arcprops:
# note recat needs all variables, but currently will only update the categories
if not(doing_recat):
	arcrule$="ARCRULE"
endif
if not(uf.arcjob):
	switch arcrule$
		case "purchase order"
			day_format "MM/DD/YYYY"
			earca_library$="Purchasing"
			earca_libcoabrsub=EARC_LIBCOABRSUB
			if earca_libcoabrsub:
				earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
			endif
			earca_doctype$="Purchase Order"
			#
			if earca_formtype$="8.5x11":
				earca_docid$=get(54,3,8,"y")
				earca_docdate$=get(65,3,10,"y")
				earca_vendname$=get(6,9,30,"y")
			endif
			if earca_formtype$="laser":
				earca_docid$=get(54,4,8,"y")
				earca_docdate$=get(65,4,10,"y")
				earca_vendname$=get(6,10,30,"y")
			endif
			if earca_formtype$="plain":
				earca_docid$=get(69,4,8,"y")
				earca_docdate$=get(1,11,10,"y")
				earca_vendname$=get(12,14,30,"y")
			endif
			if earca_formtype$="std":
				earca_docid$=get(69,1,8,"y")
				earca_docdate$=get(1,8,10,"y")
				earca_vendname$=get(12,11,30,"y")
			endif
			#
			earca_subid$=""
			earca_title$=earca_vendname$
			earca_yyyy$=dte(earca_docdate$:"%Ys")
			earca_mmm$=dte(earca_docdate$:earca_momask$)
			earca_dd$=dte(earca_docdate$:"%Dz")
			earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
			earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
			earca_cats$+="Vendor|Name|"+earca_vendname$+"|"+earca_yyyymmm$+";"
			# see add'l date categories at bottom of rule-set
			earca_xty$="Forms"
			earca_links$=""
			earca_args$="-ce 1"
			earca_mm$=dte(earca_docdate$:"%Mz")
			earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
			earca_subtitle$=""
			earca_subdtm$=""
			earca_notes$=""
			earca_keywords$="*;"
			# form missing vendor ID!
			# earca_entid$=earca_vendid$
		break
		
		case "pickpack"
			day_format "MM/DD/YY"
			earca_library$="Sales"
			earca_libcoabrsub=EARC_LIBCOABRSUB
			if earca_libcoabrsub:
				earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
			endif
			earca_doctype$=proper(doc_title$) # "Order"
			#
			if earca_formtype$="packplain":
				earca_docid$=get(11,8,8,"y")
				earca_docdate$=get(23,8,8,"y")
				earca_custid$=get(67,11,6,"y")
				earca_custname$=get(67,12,30,"y")
				earca_oid$=get(11,8,8,"y")
				earca_custpo$="PO "+get(74,8,15,"Y")
			endif
			if earca_formtype$="pickplain":
				earca_docid$=get(11,9,8,"y")
				earca_docdate$=get(23,9,8,"y")
				earca_custid$=get(67,12,6,"y")
				earca_custname$=get(67,13,30,"y")
				earca_oid$=get(11,9,8,"y")
				earca_custpo$="PO "+get(74,9,15,"Y")
				earca_batchno$="Batch# "+trim(get(83,5,6))
				earca_pslipno$="Pickslip# "+trim(get(110,6,6))
			endif
			if earca_formtype$="pickstd":
				earca_docid$=get(1,5,8,"y")
				earca_docdate$=get(10,5,8,"y")
				earca_custid$=get(57,9,6,"y")
				earca_custname$=get(57,10,30,"y")
				earca_oid$=get(1,5,8,"y")
				earca_custpo$="PO "+get(58,5,11,"Y")
				earca_batchno$="Batch# "+trim(get(83,1,6))
				earca_pslipno$="Pickslip# "+trim(get(100,5,6))
			endif
			if earca_formtype$="pickpack8.5x11":
				earca_docid$=get(51,4,8)
				earca_docdate$=get(63,4,8)
				earca_custid$=get(6,9,6,"y")
				earca_custname$=get(46,10,30,"y")
				earca_oid$=get(51,8,8,"y")
				earca_slsp1$="Slsp "+get(2,21,5,"y")
				earca_slsp2$="Slsp "+get(8,21,5,"y")
				earca_custpo$="PO "+get(51,7,25,"Y")
				earca_batchno$="Batch# "+trim(get(40,4,6))
				earca_pslipno$="Packslip# "+trim(get(45,21,13))
			endif
			if earca_formtype$="pickpacklaser":
				earca_docid$=get(51,4,8)
				earca_docdate$=get(63,4,8)
				earca_custid$=get(7,9,6,"y")
				earca_custname$=get(47,10,30,"y")
				earca_oid$=get(51,4,8,"y")
				earca_slsp1$="Slsp "+get(3,21,5,"y")
				earca_slsp2$="Slsp "+get(9,21,5,"y")
				earca_custpo$="PO "+get(52,7,25,"Y")
				earca_batchno$="Batch# "+trim(get(40,4,6))
				earca_pslipno$="Packslip# "+trim(get(45,21,13))
			endif
			earca_orderid$="Order "+earca_oid$
			if earca_docdate$="" then earca_docdate$=dte(0:"%Mz/%Dz/%Yz")
			if trim(earca_orderid$)="Order" then earca_orderid$="Order (none)"
			if trim(earca_slsp1$)="Slsp" then earca_slsp1$=""
			if trim(earca_slsp2$)="Slsp" then earca_slsp2$=""
			if trim(earca_custpo$)="PO" then earca_custpo$="PO (none)"
			if trim(earca_batchno$)="Batch#" then earca_batchno$=""
			if trim(earca_pslipno$)="Pickslip#" then earca_pslipno$=""
			if trim(earca_pslipno$)="Packslip#" then earca_pslipno$=""
			#
			earca_title$=earca_custid$+": "+earca_custname$+" "+earca_custpo$
			if earca_slsp1$<>"":
				earca_title$+=" "+earca_slsp1$
			endif
			if earca_slsp2$<>"":
				earca_title$+=" "+earca_slsp2$
			endif
			earca_subid$="@unform"
			earca_subtitle$=doc_title$
			if earca_batchno$<>"":
				earca_title$+=" "+earca_batchno$
			endif
			if earca_pslipno$<>"":
				earca_title$+=" "+earca_pslipno$
			endif
			earca_yyyy$=dte(earca_docdate$:"%Ys")
			earca_mmm$=dte(earca_docdate$:earca_momask$)
			earca_dd$=dte(earca_docdate$:"%Dz")
			earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
			earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
			earca_cats$="Customer|Id|"+earca_custid$+" "+earca_custname$+"|"+earca_yyyymmm$+";"
			earca_cats$+="Customer|Name|"+earca_custname$+"|"+earca_yyyymmm$+";"
			earca_cats$+="OrderId|Customer Id|"+earca_custid$+" "+earca_custname$+"|"+earca_orderid$+";"
			earca_cats$+="OrderId|Customer Name|"+earca_custname$+"|"+earca_orderid$+";"
			if earca_slsp1$<>"":
				earca_cats$+="Salesperson|"+earca_slsp1$+"|Customer Id|"+earca_custid$+" "+earca_custname$+"|"+earca_yyyy$+";"
				earca_cats$+="Salesperson|"+earca_slsp1$+"|Customer Name|"+earca_custname$+"|"+earca_yyyy$+";"
			endif
			if earca_slsp2$<>"":
				earca_cats$+="Salesperson|"+earca_slsp2$+"|Customer Id|"+earca_custid$+" "+earca_custname$+"|"+earca_yyyy$+";"
				earca_cats$+="Salesperson|"+earca_slsp2$+"|Customer Name|"+earca_custname$+"|"+earca_yyyy$+";"
			endif
			earca_cats$+="CustPo|Id|"+earca_custid$+":"+earca_custname$+"|"+earca_custpo$+";"
			earca_cats$+="CustPo|Name|"+earca_custname$+"|"+earca_custpo$+";"
			if earca_batchno$<>"":
				earca_cats$+="Batch|"+earca_batchno$+";"
			endif
			# see add'l date categories at bottom of rule-set
			earca_xty$="Forms"
			earca_args$="-ce 1"
			earca_mm$=dte(earca_docdate$:"%Mz")
			earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
			earca_subdtm$=""
			earca_notes$=""
			earca_keywords$="*;"
			earca_links$=""
			earca_entid$=earca_custid$
		break
		
		case "invoice"
			day_format "MM/DD/YY"
			earca_library$="Sales"
			earca_libcoabrsub=EARC_LIBCOABRSUB
			if earca_libcoabrsub:
				earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
			endif
			earca_doctype$=proper(doc_title$)  # "Invoice"
			#
			if earca_formtype$="8.5x11":
				earca_docid$=get(52,6,8,"y")
				earca_docdate$=get(63,6,8,"y")
				earca_custid$=get(6,10,6,"y")
				earca_custname$=get(6,12,30,"y")
				earca_oid$=get(38,22,8,"y")
				earca_slsp1$="Slsp "+get(2,22,5,"y")
				earca_slsp2$="Slsp "+get(8,22,5,"y")
			endif
			if earca_formtype$="laser":
				earca_docid$=get(112,7,8,"y")
				earca_docdate$=get(112,6,8,"y")
				earca_custid$=get(10,10,6,"y")
				earca_custname$=get(10,12,30,"y")
				earca_oid$=get(62,22,8,"y")
				earca_slsp1$="Slsp "+get(2,22,5,"y")
				earca_slsp2$="Slsp "+get(8,22,5,"y")
			endif
			if earca_formtype$="plain":
				earca_docid$=get(107,17,8,"y")
				earca_docdate$=get(13,17,8,"y")
				earca_custid$=get(21,7,6,"y")
				earca_custname$=get(21,10,30,"y")
				earca_oid$=get(40,17,8,"y")
				earca_slsp1$="Slsp "+get(31,17,5,"y")
				# earca_slsp2$="Slsp "+get(8,22,5,"y")
			endif
			if earca_formtype$="std":
				earca_docid$=get(84,10,8,"y")
				earca_docdate$=get(1,10,8,"y")
				earca_custid$=get(8,2,6,"y")
				earca_custname$=get(8,4,30,"y")
				earca_oid$=get(21,10,8,"y")
				earca_slsp1$="Slsp "+get(13,10,5,"y")
				# earca_slsp2$="Slsp "+get(8,22,5,"y")
			endif
			#
			earca_subid$=""
			earca_orderid$="Order "+earca_oid$
			if earca_docdate$="" then earca_docdate$=dte(0:"%Mz/%Dz/%Yz")
			if trim(earca_orderid$)="Order" then earca_orderid$="Order (none)"
			if trim(earca_slsp1$)="Slsp" then earca_slsp1$=""
			if trim(earca_slsp2$)="Slsp" then earca_slsp2$=""
			#
			earca_title$=earca_custid$+": "+earca_custname$+" "+earca_orderid$
			if earca_slsp1$<>"":
				earca_title$+=" "+earca_slsp1$
			endif
			if earca_slsp2$<>"":
				earca_title$+=" "+earca_slsp2$
			endif
			earca_yyyy$=dte(earca_docdate$:"%Ys")
			earca_mmm$=dte(earca_docdate$:earca_momask$)
			earca_dd$=dte(earca_docdate$:"%Dz")
			earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
			earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
			earca_cats$="Customer|Id|"+earca_custid$+" "+earca_custname$+"|"+earca_yyyymmm$+";"
			earca_cats$+="Customer|Name|"+earca_custname$+"|"+earca_yyyymmm$+";"
			earca_cats$+="OrderId|Customer Id|"+earca_custid$+" "+earca_custname$+"|"+earca_orderid$+";"
			earca_cats$+="OrderId|Customer Name|"+earca_custname$+"|"+earca_orderid$+";"
			if earca_slsp1$<>"":
				earca_cats$+="Salesperson|"+earca_slsp1$+"|Customer Id|"+earca_custid$+" "+earca_custname$+"|"+earca_yyyy$+";"
				earca_cats$+="Salesperson|"+earca_slsp1$+"|Customer Name|"+earca_custname$+"|"+earca_yyyy$+";"
			endif
			if earca_slsp2$<>"":
				earca_cats$+="Salesperson|"+earca_slsp2$+"|Customer Id|"+earca_custid$+" "+earca_custname$+"|"+earca_yyyy$+";"
				earca_cats$+="Salesperson|"+earca_slsp2$+"|Customer Name|"+earca_custname$+"|"+earca_yyyy$+";"
			endif
			# see add'l date categories at bottom of rule-set
			earca_xty$="Forms"
			earca_args$="-ce 1"
			earca_dtm$=""
			earca_subtitle$=""
			earca_mm$=dte(earca_docdate$:"%Mz")
			earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
			earca_notes$=""
			earca_keywords$="*;"
			earca_links$=""
			earca_entid$=earca_custid$
			if earca_oid$<>"":
				targLib$=earca_library$
				targDocid$=earca_oid$
				targDoctys$="Picking List,Packing List,Picking Slip"
				w=1
				while w<4
					targDocty$=parse(targDoctys$,w,",")
					w+=1
					if docidexists(targLib$,targDocty$,targDocid$) then:
						# assign forward link
						earca_links$=targLib$+"|"+targDocty$+"|"+targDocID$+"|"+"@"
						arcRevLink$=earca_Library$+"|"+earca_DocType$+"|"+earca_DocID$+"|"+"@"
						# update reverse Link
						x=fnUpdateLink(targLib$,targDocty$,targDocid$,arcRevLink$)
					endif
				wend
			endif
		break
		case "statement"
			day_format "MM/DD/YYYY"
			earca_library$="Accounting"
			earca_libcoabrsub=EARC_LIBCOABRSUB
			if earca_libcoabrsub:
				earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
			endif
			earca_doctype$="Statement"
			#
			if earca_formtype$="8.5x11":
				# handle extra linefeed at top of page 2 and greater
				# here in case of re-indexing from master ruleset
				if mask(text$[8]," DATEMASK")=49:
					for i=2 to 66
						text$[i-1]=text$[i],text$[i]=""
					next i
				endif
				earca_docdate$=get(50,7,10,"y")
				earca_custid$=get(62,7,6,"y")
				earca_custname$=get(4,11,35,"y")
				earca_args$="-r AR_Statement8.5x11"
			endif
			if earca_formtype$="laser":
				earca_docdate$=get(62,6,10,"y")
				earca_custid$=get(66,7,6,"y")
				earca_custname$=get(4,11,35,"y")
			endif
			if earca_formtype$="plain":
				earca_docdate$=get(60,9,10,"y")
				earca_custid$=get(47,9,6,"y")
				earca_custname$=get(4,11,35,"y")
			endif
			if earca_formtype$="std":
				earca_docdate$=get(60,6,10,"y")
				earca_custid$=get(47,6,6,"y")
				earca_custname$=get(12,8,35,"y")
			endif
			#
			if earca_docdate$="" then earca_docdate$=dte(0:"%Mz/%Dz/%Yz")
			earca_yyyy$=dte(earca_docdate$:"%Ys")
			earca_mmm$=dte(earca_docdate$:earca_momask$)
			earca_mm$=dte(earca_docdate$:"%Mz")
			earca_dd$=dte(earca_docdate$:"%Dz")
			earca_docid$=earca_custid$+"-"+earca_yyyy$+upper(earca_mm$)+earca_dd$
			earca_subid$=""
			earca_title$=earca_custid$+": "+earca_custname$
			earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
			earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
			earca_cats$="Customer|Id|"+earca_custid$+"|"+earca_yyyy$+";"
			earca_cats$+="Customer|Name|"+earca_custname$+"|"+earca_yyyy$+";"
			# see add'l date categories at bottom of rule-set
			earca_xty$="Forms"
			earca_links$=""
			earca_args$+=" -ce 1"
			earca_mm$=dte(earca_docdate$:"%Mz")
			earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
			earca_subtitle$=""
			earca_subdtm$=""
			earca_notes$=""
			earca_keywords$="*;"
			earca_entid$=earca_custid$
		break
	
		case "apcheck"
			day_format "EARCA_DATEFMT"
			earca_library$="Accounting"
			earca_libcoabrsub=EARC_LIBCOABRSUB
			if earca_libcoabrsub:
				earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
			endif
			earca_doctype$="A/P Check"
			if earca_formtype$="blank":
				earca_docid$=str(num(get(54,8,7,"y")):fill(7,"0"))
				earca_docdate$=get(43,8,10,"y")
				earca_vendid$=get(25,23,6,"y")
				earca_vendname$=get(36,23,30,"y")
			endif
			if earca_formtype$="laser":
				earca_docid$=str(num(get(43,8,7,"y")):fill(7,"0"))
				earca_docdate$=get(51,8,10,"y")
				earca_vendid$=get(25,22,6,"y")
				earca_vendname$=get(36,22,30,"y")
			endif
			if earca_formtype$="preprinted":
				earca_docid$=str(num(get(54,8,7,"y")):fill(7,"0"))
				earca_docdate$=get(43,8,10,"y")
				earca_vendid$=get(34,23,6,"y")
				earca_vendname$=get(48,23,30,"y")
			endif
			earca_subid$=""
			earca_title$=earca_vendid$+":"+earca_vendname$
			earca_yyyy$=dte(earca_docdate$:"%Ys")
			earca_mmm$=dte(earca_docdate$:earca_momask$)
			earca_dd$=dte(earca_docdate$:"%Dz")
			earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
			earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
			earca_cats$="Vendor|Id|"+earca_vendid$+":"+earca_vendname$+"|"+earca_yyyymmm$+";"
			earca_cats$+="Vendor|Name|"+earca_vendname$+"|"+earca_yyyymmm$+";"
			# see add'l date categories at bottom of rule-set
			earca_xty$="Forms"
			earca_links$=""
			earca_args$="-ce 1"
			earca_mm$=dte(earca_docdate$:"%Mz")
			earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
			earca_subtitle$=""
			earca_subdtm$=""
			earca_notes$=""
			earca_keywords$="*;"
			earca_entid$=earca_vendid$
		break
		case "prcheck"
			earca_library$="Payroll"
			earca_libcoabrsub=EARC_LIBCOABRSUB
			if earca_libcoabrsub:
				earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
			endif
			# check
			if arcdtype$="check":
				day_format "MM/DD/YY"
				earca_doctype$="P/R Check"
				if earca_formtype$="blank":
					earca_docid$=str(num(get(58,10,7,"y")):fill(8,"0"))
					earca_docdate$=get(46,10,8,"y")
					earca_empid$=get(1,24,6)
					earca_empname$=get(15,24,30,"y")
				endif
				if earca_formtype$="laser":
					earca_docid$=str(num(get(64,22,7,"y")):fill(8,"0"))
					earca_docdate$=get(53,8,8,"y")
					earca_empid$=get(1,22,6)
					earca_empname$=get(15,22,30,"y")
				endif
				if earca_formtype$="preprinted":
					earca_docid$=str(num(get(63,2,7,"y")):fill(8,"0"))
					earca_docdate$=get(58,27,8,"y")
					earca_empid$=get(1,2,6)
					earca_empname$=get(15,2,30,"y")
				endif
				earca_subid$="@unform*"
				earca_title$=earca_empid$+" "+earca_empname$
				earca_yyyy$=dte(earca_docdate$:"%Ys")
				earca_mmm$=dte(earca_docdate$:earca_momask$)
				earca_dd$=dte(earca_docdate$:"%Dz")
				earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
				earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
				earca_cats$="Employee|Id|"+earca_empid$+":"+earca_empname$+"|"+earca_yyyy$+";"
				earca_cats$+="Employee|Name|"+earca_empname$+"|"+earca_yyyy$+";"
				# see add'l date categories at bottom of rule-set
				earca_xty$="Forms"
				earca_links$=""
				earca_args$="-ce 1"
				earca_mm$=dte(earca_docdate$:"%Mz")
				earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
				earca_subtitle$=""
				earca_subdtm$=""
				earca_notes$=""
				earca_keywords$="*;"
			endif
			# payroll summary
			if arcdtype$="summary":
				day_format "MM/DD/YYYY"
				earca_doctype$="P/R Check Summary"
				earca_docid$=""
				earca_subid$=""
				if earca_formtype$="blank":
					earca_docdate$=get(36,3,10,"y")
					earca_args$="-r PR_CheckBlank" # "-ce 2"
				endif
				if earca_formtype$="laser":
					earca_docdate$=get(36,3,10,"y")
					earca_args$="-r PR_CheckLaser" # "-ce 2"
				endif
				if earca_formtype$="preprinted":
					earca_docdate$=get(36,4,10,"y")
					earca_args$="-r PR_CheckPreprinted" # "-ce 2"
				endif
				earca_title$=earca_docdate$
				earca_yyyy$=dte(earca_docdate$:"%Ys")
				earca_mmm$=dte(earca_docdate$:earca_momask$)
				earca_dd$=dte(earca_docdate$:"%Dz")
				earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
				earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
				earca_cats$=""
				# see add'l date categories at bottom of rule-set
				earca_xty$="Forms"
				earca_links$=""
				earca_mm$=dte(earca_docdate$:"%Mz")
				earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
				earca_subtitle$=""
				earca_subdtm$=""
				earca_notes$=""
				earca_keywords$="*;"
			endif
		break
		case "ddvouch"
			if not(sumpage): 	# protect against laser summary page with no date getting thru
				earca_library$="Payroll"
				earca_libcoabrsub=EARC_LIBCOABRSUB
				if earca_libcoabrsub:
					earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
				endif
				day_format "MM/DD/YY"
				earca_doctype$="D/D Voucher"
				if earca_formtype$="blank":
					earca_docid$=str(num(get(63,25,8,"y")):fill(8,"0"))
					earca_subid$="@unform*"
					earca_docdate$=get(60,8,8,"y")
					earca_empid$=get(1,25,6)
					earca_empname$=get(15,25,30,"y")
				endif
				if earca_formtype$="laser":
					earca_docid$=str(num(get(68,22,8,"y")):fill(8,"0"))
					earca_subid$="@unform*"
					earca_docdate$=get(60,8,8,"y")
					earca_empid$=get(1,22,6)
					earca_empname$=get(15,22,30,"y")
				endif
				if earca_formtype$="preprinted":
					earca_docid$=str(num(get(63,25,8,"y")):fill(8,"0"))
					earca_subid$="@unform*"
					earca_docdate$=get(60,8,8,"y")
					earca_empid$=get(1,25,6)
					earca_empname$=get(15,25,30,"y")
				endif
				earca_title$=earca_empid$+" "+earca_empname$
				earca_yyyy$=dte(earca_docdate$:"%Ys")
				earca_mmm$=dte(earca_docdate$:earca_momask$)
				earca_dd$=dte(earca_docdate$:"%Dz")
				earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
				earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
				earca_cats$="Employee|Id|"+earca_empid$+":"+earca_empname$+"|"+earca_yyyy$+";"
				earca_cats$+="Employee|Name|"+earca_empname$+"|"+earca_yyyy$+";"
				# see add'l date categories at bottom of rule-set
				earca_xty$="Forms"
				earca_links$=""
				earca_args$="-ce 1"
				earca_mm$=dte(earca_docdate$:"%Mz")
				earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
				earca_subtitle$=""
				earca_subdtm$=""
				earca_notes$=""
				earca_keywords$="*;"
			endif
		break
		case "bill of lading"
			day_format "MM/DD/YY"
			earca_library$="Sales"
			earca_libcoabrsub=EARC_LIBCOABRSUB
			if earca_libcoabrsub:
				earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
			endif
			earca_doctype$="Bill of Lading"
			earca_docid$=get(122,2,8,"y")
			earca_subid$=""
			earca_docdate$=get(99,2,12,"y")
			if earca_docdate$="" then earca_docdate$=dte(0:"%Mz/%Dz/%Yz")
			earca_custname$=get(83,9,35,"y")
			earca_title$=earca_custname$
			earca_yyyy$=dte(earca_docdate$:"%Ys")
			earca_mmm$=dte(earca_docdate$:earca_momask$)
			earca_dd$=dte(earca_docdate$:"%Dz")
			earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
			earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
			earca_cats$+="BOL Consignee|"+earca_custname$+"|"+earca_yyyymmm$+";"
			# see add'l date categories at bottom of rule-set
			earca_xty$="Forms"
			earca_links$=""
			earca_args$="-ce 1"
			earca_mm$=dte(earca_docdate$:"%Mz")
			earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
			earca_subtitle$=""
			earca_subdtm$=""
			earca_notes$=""
			earca_keywords$="*;"
			# form has no cust ID!
			# earca_entid$=earca_custid$
		break
	
		case "balance sheet"
			if pagenum=1:
				day_format "EARCA_DATEFMT"
				earca_library$="Financials"
				earca_libcoabrsub=EARC_LIBCOABRSUB
				if earca_libcoabrsub:
					earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
				endif
				earca_doctype$="Balance Sheet"
				earca_docid$=""
				earca_subid$=""
				#
				dd$=text$[4]
				pp=pos("AS OF"=dd$)
				# if pp=0 pp=pos("ENDED"=dd$)
				if pp=0 dd$=dte(0:"%Mz/%Dz/%Ys")
				if pp:
					dd$=dd$(pp+7),dd$=trim(sub(dd$,","," ")),dd$=sub(dd$,"  "," "),mo$=parse(dd$,1," ")
					savedd$=dd$
					newmo$=str(num(fnumo$(mo$)):"00"),da$=str(num(parse(dd$,2," ")):"00"),yr$=str(num(parse(dd$,3," ")):"0000")
					dd$=newmo$+"/"+da$+"/"+yr$
				endif
				earca_docdate$=dd$
				#
				earca_title$=trim(get(12,1,55))+", "+proper(trim(text$[3]))+" as of "+dd$
				earca_yyyy$=dte(earca_docdate$:"%Ys")
				earca_mmm$=dte(earca_docdate$:earca_momask$)
				earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
				earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
				# see add'l date categories at bottom of rule-set
				earca_xty$="Reports"
				earca_links$=""
				earca_args$="-ce 1"
				earca_mm$=dte(earca_docdate$:"%Mz")
				earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
				earca_subtitle$=""
				earca_subdtm$=""
				earca_notes$=""
				earca_keywords$="*;"
			endif
		break
	
		case "financials"
			if pagenum=1:
				day_format "MM/DD/YYYY"
				earca_library$="Financials"
				earca_libcoabrsub=EARC_LIBCOABRSUB
				if earca_libcoabrsub:
					earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
				endif
				if earca_formtype$="income statement" earca_doctype$="Income Statement"
				if earca_formtype$="balance sheet" earca_doctype$="Balance Sheet"
				if earca_formtype$="trial balance" earca_doctype$="Trial Balance"
				earca_docid$=""
				earca_subid$=""
				#
				if earca_formtype$<>"trial balance":
					dd$=text$[4]
					pp=pos("THROUGH"=dd$)
					if pp=0 pp=pos("ENDED"=dd$)
					if pp=0 pp=pos("AS OF"=dd$)
					if pp=0 dd$=dte(0:"%Mz/%Dz/%Ys")
					if pp:
						dd$=dd$(pp+7),dd$=trim(sub(dd$,","," ")),dd$=sub(dd$,"  "," "),mo$=parse(dd$,1," ")
						savedd$=dd$
						newmo$=str(num(fnumo$(mo$)):"00"),da$=str(num(parse(dd$,2," ")):"00"),yr$=str(num(parse(dd$,3," ")):"0000")
						dd$=newmo$+"/"+da$+"/"+yr$
					endif
				endif
				if earca_formtype$="trial balance":
					dd$=text$[4]
					dd$=mid(dd$,50,30),dd$=trim(sub(dd$,","," ")),dd$=sub(dd$,"  "," "),mo$=pad(parse(dd$,1," "),3)
					newmo$=str(num(fnumo$(mo$)):"00"),da$=str(num(parse(dd$,2," ")):"00"),yr$=str(num(parse(dd$,3," ")):"0000")
					dd$=newmo$+"/"+da$+"/"+yr$
				endif
				earca_docdate$=dd$
				#
				earca_title$=trim(get(12,1,105))+", "+proper(trim(mid(text$[3],10,120)))+" for "+dd$
				if earca_formtype$="trial balance":
						earca_period$=trim(get(1,2,80))
						earca_title$+=", "+earca_period$
				endif
				earca_yyyy$=dte(earca_docdate$:"%Ys")
				earca_mmm$=dte(earca_docdate$:earca_momask$)
				earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
				earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
				# see add'l date categories at bottom of rule-set
				earca_xty$="Reports"
				earca_links$=""
				earca_args$="-ce 1"
				earca_mm$=dte(earca_docdate$:"%Mz")
				earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
				earca_subtitle$=""
				earca_subdtm$=""
				earca_notes$=""
				earca_keywords$="*;"
			endif
		break
		case "ap aging"
			if pagenum=1:
				day_format "MM/DD/YYYY"
				earca_library$="Accounting"
				earca_libcoabrsub=EARC_LIBCOABRSUB
				if earca_libcoabrsub:
					earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
				endif
				earca_doctype$="A/P Aging"
				if earca_formtype$="detail" earca_doctype$+=" Detail"
				if earca_formtype$="summary" earca_doctype$+=" Summary"
				earca_docid$=""
				earca_subid$=""
				#
				dd$=text$[5]
				pp=pos("Aging Date:"=dd$)
				if pp=0 dd$=dte(0:"%Mz/%Dz/%Ys")
				if pp dd$=mid(dd$,pp+12,10)
				earca_docdate$=dd$
				#
				earca_title$=trim(get(12,1,100))+", "+proper(trim(text$[3]))+", "+proper(trim(text$[4]))+", "+proper(trim(text$[5]))
				earca_yyyy$=dte(earca_docdate$:"%Ys")
				earca_mmm$=dte(earca_docdate$:earca_momask$)
				earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
				earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
				# see add'l date categories at bottom of rule-set
				earca_xty$="Reports"
				earca_links$=""
				earca_args$="-ce 1"
				earca_mm$=dte(earca_docdate$:"%Mz")
				earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
				earca_subtitle$=""
				earca_subdtm$=""
				earca_notes$=""
				earca_keywords$="*;"
			endif
		break
		
		case "ar aging"
			if pagenum=1:
				day_format "MM/DD/YYYY"
				earca_library$="Accounting"
				earca_libcoabrsub=EARC_LIBCOABRSUB
				if earca_libcoabrsub:
					earca_library$="EARC_COABREVSUJ"+"_"+earca_library$
				endif
				earca_doctype$="A/R Aging"
				if earca_formtype$="detail" earca_doctype$+=" Detail"
				if earca_formtype$="summary" earca_doctype$+=" Summary"
				earca_docid$=""
				earca_subid$=""
				#
				earca_docdate$=dte(0:"%Mz/%Dz/%Ys")
				#
				earca_title$=trim(get(12,1,100))+", "+proper(trim(mid(text$[3],8,100)))+", "+proper(trim(text$[4]))
				earca_yyyy$=dte(earca_docdate$:"%Ys")
				earca_mmm$=dte(earca_docdate$:earca_momask$)
				earca_yyyymmmdd$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$+"|"+earca_yyyy$+" "+earca_mmm$+" "+earca_dd$
				earca_yyyymmm$=earca_yyyy$+"|"+earca_yyyy$+" "+earca_mmm$
				# see add'l date categories at bottom of rule-set
				earca_xty$="Reports"
				earca_links$=""
				earca_args$="-ce 1"
				earca_mm$=dte(earca_docdate$:"%Mz")
				earca_dtm$=earca_yyyy$+earca_mm$+earca_dd$
				earca_subtitle$=""
				earca_subdtm$=""
				earca_notes$=""
				earca_keywords$="*;"
			endif
		break
	endswitch
	
		# "CASE ALL"
		if (earca_xty$="Reports" and pagenum=1) or earca_xty$="Forms":
			earca_cats$+="by Year|"+fnearca_yyyy$(earca_docdate$)+";"
			earca_cats$+="by Month|"+fnearca_yyyymmm$(earca_docdate$)+";"
			earca_cats$+=earca_xty$+" By Type/Period|"+earca_doctype$+"|by Year|"+fnearca_yyyy$(earca_docdate$)+";"
			earca_cats$+=earca_xty$+" By Type/Period|"+earca_doctype$+"|by Month|"+fnearca_yyyymmm$(earca_docdate$)+";"
			earca_cats$+=earca_xty$+" By Period/Type|by Year|"+fnearca_yyyy$(earca_docdate$)+"|"+earca_doctype$+";"
			earca_cats$+=earca_xty$+" By Period/Type|by Month|"+fnearca_yyyymmm$(earca_docdate$)+"|"+earca_doctype$+";"
			if earca_xty$="Forms":
				earca_cats$+="by Day|"+fnearca_yyyymmmdd$(earca_docdate$)+";"
				earca_cats$+=earca_xty$+" By Type/Period|"+earca_doctype$+"|by Day|"+fnearca_yyyymmmdd$(earca_docdate$)+";"
				earca_cats$+=earca_xty$+" By Period/Type|by Day|"+fnearca_yyyymmmdd$(earca_docdate$)+"|"+earca_doctype$+";"
			endif
		endif
endif  # not(uf.arcjob)
# line label for postjob goto
skipcode1:
# note, a closing brace is an implicit 'return'
}
[8.0 zMrg PDFLinks v2]
# Implementation note: merge this near the top of a rule set
# that needs the embedded (annotation-based) links
# Use the fnCreateAnnotations$() function in precopy,
# not prepage, as the uf.cpi value it may rely on isn't
# updated until after prepage is run.
prejob {
js$=""
crlf$=$0d0a$
if uf.arcjob then:
	js$+="function showDoc(url,lb,dtp,did) {"+crlf$
	js$+=" var qpos=url.indexOf('?a=vw');"+crlf$
	js$+=" if (qpos<0) {"+crlf$
	js$+="  app.alert('This feature is only available when viewing this document via the UnForm archive browser interface.');"+crlf$
	js$+="  return;"+crlf$
	js$+=" }"+crlf$
	js$+=" var base=url.substr(0,qpos);"+crlf$
	js$+=" if (lb=='') {"+crlf$
	js$+="  var querystring=url.substr(qpos);"+crlf$
	js$+="  var lpos=querystring.indexOf('lb=');"+crlf$
	js$+="  lb=querystring.substr(lpos+3);"+crlf$
	js$+="  lpos=lb.indexOf('&');"+crlf$
	js$+="  lb=lb.substr(0,lpos);"+crlf$
	js$+="  lb=unescape(lb);"+crlf$
	js$+=" }"+crlf$
	js$+=" var myurl=base+'?a=vw&lb='+escape(lb)+'&doctype='+escape(dtp)+'&docid='+escape(did)+'&subid=@';"+crlf$
	js$+=" app.launchURL(myurl,true);"+crlf$
	js$+="}"+crlf$
end if
def fnCreateAnnotations$(local pattern$,local startcol,local startrow,local endcol,local endrow,local colshift,local rowshift,local idpfx$,local idsfx$,local fontinfo$,local lib$,local doctype$)
	# returns 'annotate' lines for inter-document links
	# mje 062810 added rowshift, mje 070610 added local targDocty$
	local annotations$,c,item,item$,cmd$,col,row,cols,pat$,width
	local fontname$,fontsize,fontattr,alignment$
	local x,x$,getofs,getcols,haveofs
	local expr$,ignore$
	local targDocty$
	if uf.arcjob then:
		fontinfo$=sub(lcs(fontinfo$),"fit","")
		fontinfo$=sub(fontinfo$,"wrap","")
		fontname$="Courier",fontsize=uf.cpi,fontattr=0
		c=count(fontinfo$,",")
		if c>0 then:
			for item=1 to c
				item$=parse(fontinfo$,item,",")
				if trim(item$)="" then continue
				fontsize=num(item$,err=*next);continue
				if lcs(item$)="bold" fontattr=fontattr+1;continue
				if lcs(item$)="italic" fontattr=fontattr+2;continue
				if lcs(item$)="center" or lcs(item$)="right" alignment$=lcs(item$);continue
				fontname$=item$
			next item
		end if
		# Pattern can contain control info
		# expression prefixed by ==
		# !! ignore word list (comma separated, case sensitive)
		x=pos("!!"=pattern$,-1)
		if x>0 then ignore$=pattern$(x+2),pattern$=pattern$(1,x-1)
		x=pos("=="=pattern$,-1)
		if x>0 then	expr$=pattern$(x+2),pattern$=pattern$(1,x-1)
		# offset cols, length prefixed by //
		x=pos("//"=pattern$,-1)
		if x>0 then :
			haveofs=1
			x$=pattern$(x+2),pattern$=pattern$(1,x-1)
			x=pos(","=x$)
			if x>0 then :
				getofs=num(x$(1,x-1))
				getcols=num(x$(x+1))
			else
				getofs=num(x$)
				getcols=1+endcol-startcol
			end if
		end if
		pat$=pattern$+"@"+str(startcol)+","+str(startrow)+","+str(endcol)+","+str(endrow)
		c=findpos(text$[],pat$,positions[])
		
		if c>0 then:
			for item=0 to c-1
				col=positions[item,0]
				row=positions[item,1]
				cols=1+endcol-startcol
				if haveofs then :
					col=col+getofs
					cols=getcols
				end if
				item$=get(col,row,cols)
				# Expression example: ==mid(item$,8,2)+$2D$+mid(item$,1,6)
				# To set a prefix and leave the link under a single column
				# use a compound statement starting with just item$ (becomes
				# item$=item$...  Also, you can manipulate col to adjust position
				# eg: item$,idpfx$=mid(item$,1,2),item$=mid(item$,3),col+=3
				if expr$>"" then execute "item$="+expr$
				if fontinfo$="" then:
					leftpad=pos(" "<>item$)
					if leftpad>0 then leftpad--
				end if
				item$=trim(item$)
				if ignore$>"" then if pos(","+item$+","=","+ignore$+",")>0 then continue
				width=textwidth(item$,fontname$,fontsize,fontattr)
				if alignment$="center" then col=col+(cols/2-width/2)
				if alignment$="right" then col=col+cols-width
				cmd$="annotate "+str(col-.5+colshift+leftpad)+","+str(rowshift+row-.5)+","+str(width)+",1,"+$22$+"javascript:showDoc(this.URL,"
				cmd$+="'"+lib$+"',"
				# mje 070610 allow comma-delim list of docty's to test existence before creating link
				if pos(","=doctype$):
					w=1
					while w<4
						targDocty$=parse(doctype$,w,",")
						w+=1
						if w=1 or docidexists(Lib$,targDocty$,item$) then:
							doctype$=targDocty$; break
						endif
					wend
				endif
				cmd$+="'"+doctype$+"',"
				cmd$+="'"+idpfx$+item$+idsfx$+"')"
				cmd$+=$22$+",link,style U,color blue"
				annotations$+=cmd$+$0a$
			next item
		end if
	end if
	return annotations$
end def
def fnAnnotation$(local col,local row,local fontinfo$,local lib$,local doctype$,local docid$,local idpfx$,local idsfx$,colshift)
	# returns 'annotate' lines for inter-document links
	local annotation$,c,item,item$,cmd$,cols,width
	local fontname$,fontsize,fontattr,alignment$,ofs
	local leftpad
	
	if uf.arcjob then:
		fontinfo$=sub(lcs(fontinfo$),"fit","")
		fontinfo$=sub(fontinfo$,"wrap","")
		fontname$="Courier",fontsize=uf.cpi,fontattr=0
		c=count(fontinfo$,",")
		if c>0 then:
			for item=1 to c
				item$=parse(fontinfo$,item,",")
				if trim(item$)="" then continue
				fontsize=num(item$,err=*next);continue
				if lcs(item$)="bold" fontattr=fontattr+1;continue
				if lcs(item$)="italic" fontattr=fontattr+2;continue
				if lcs(item$)="center" or lcs(item$)="right" alignment$=lcs(item$);continue
				fontname$=item$
			next item
		end if
		item$=docid$
		if fontinfo$="" then:
			leftpad=pos(" "<>item$)
			if leftpad>0 then leftpad--
		end if
		cols=len(item$)
		item$=trim(item$)
		width=textwidth(item$,fontname$,fontsize,fontattr)
		if alignment$="center" then ofs=cols/2-width/2
		if alignment$="right" then ofs=cols-width
		cmd$="annotate "+str(col+ofs+leftpad+colshift-.5)+","+str(row-.5)+","+str(width)+",1,"+$22$+"javascript:showDoc(this.URL,"
		cmd$+="'"+lib$+"',"
		cmd$+="'"+doctype$+"',"
		cmd$+="'"+idpfx$+item$+idsfx$+"');"
		cmd$+=$22$+",link,style U,color blue"
		annotation$=cmd$
	end if
	return annotation$
end def
}
javascript {js$}
[8.0 EDM6 BOOK]
# address method 6 "Address Book"
prepage {
	if lower(edel$)="y":
		if not(uf.subjob):
			edocid$=trim(edocid$)
			dlm$="|"
			eAddrEnt$=trim(eAddrEnt$)
			book$="osas"
			# if eDocty$="Invoice" book$="osas-customers"
			# if eDocty$="purchase order" book$="osas-vendors"
	
			# As an example,
			# ASSUME a Hierarchy of address book entries to check
	
			# check with specific doctype
			doctype$=eDocty$
	
				prfx$="",sufx$="-E",entityid$=prfx$+eAddrEnt$+sufx$
				xx=getaddress(book$,entityid$,doctype$,address$)
					if not(xx):
						prfx$="",sufx$="-F",entityid$=prfx$+eAddrEnt$+sufx$
						xx=getaddress(book$,entityid$,doctype$,address$)
					endif
						if not(xx):
							prfx$="",sufx$="",entityid$=prfx$+eAddrEnt$+sufx$
							xx=getaddress(book$,entityid$,doctype$,address$)
						endif
		
				if not(xx):
					# check with null or hard-coded doctype
					doctype$=""
				
						prfx$="",sufx$="-E",entityid$=prfx$+eAddrEnt$+sufx$
						xx=getaddress(book$,entityid$,doctype$,address$)
							if not(xx):
								prfx$="",sufx$="-F",entityid$=prfx$+eAddrEnt$+sufx$
								xx=getaddress(book$,entityid$,doctype$,address$)
							endif
								if not(xx):
									prfx$="",sufx$="",entityid$=prfx$+eAddrEnt$+sufx$
									xx=getaddress(book$,entityid$,doctype$,address$)
								endif
				endif
	
			ex$="",fx$="",sx$="",yx$="",eaddr$=""
			
			if xx=1:
				yx$=address.sendto$
				# determine email versus fax
				if pos("@"=yx$):
						eaddr$=yx$
						einvno$="e"+edocid$
					else
						faddr$=yx$
						finvno$="f"+edocid$
						ftoco$=address.entityname$
						ftnam$=address.contactname$
				endif
			endif
		endif
	endif
}
	# do merge just for variable Inits
	merge "8.0 ED TAG PARSER"
# UnForm Address book template
# 	 address.entityid$ (key seg1)
#	 address.doctype$ (key seg2)
#	 address.entityname$
#	 address.contactname$
#	 address.sendto$
#	 address.combine
[8.0 ED TAG PARSER]
# Common delimited tag parsing routine
prepage {
	if lower(eDel$)="y":
		if not(skipInit):
			# reset tag variables for next Doc
			if not(uf.subjob):
					# email, ref tags in deliver.ini
					ecopy$="",efrom$="",esubj$="",ebody$=""
					etach$="",ecccc$="",ebbcc$="",eohdr$=""
					elogn$="",epswd$="",emime$=""
					eArg$=""
					# fax, ref tags in deliver.ini
					fcopy$="",ffrom$="",fsubj$="",fbody$=""
					ftach$="",fcovr$="" # ,ftnam$="",ftoco$=""
					ffrco$="",f11$="",f12$=""
					fArg$=""
					pcopy$=""
					if not(doing_method=6):
						ftnam$="",ftoco$=""
					endif
			endif
		endif
		
		okToParse=1
		if doing_method=1 okToParse=0
		if doing_method=6 okToParse=0
		if doing_method=8 okToParse=0
		if doing_method=4 and edocConnect_ok=0 then okToParse=0
		if doing_method=5 and pagenum<>1 then okToParse=0
		
		if okToParse:
			if not(uf.subjob):
				if ex$<>"":
					einvno$="e"+edocid$
					ecopy$=fnEq$(parse(ex$,1,dlm$))
					eaddr$=fnEq$(parse(ex$,2,dlm$))
					if eaddr$<>"":
						efrom$=fnEq$(parse(ex$,3,dlm$))
						esubj$=fnEq$(parse(ex$,4,dlm$))
						ebody$=fnEq$(parse(ex$,5,dlm$))
						etach$=fnEq$(parse(ex$,6,dlm$))
						ecccc$=fnEq$(parse(ex$,7,dlm$))
						ebbcc$=fnEq$(parse(ex$,8,dlm$))
						eohdr$=fnEq$(parse(ex$,9,dlm$))
						elogn$=fnEq$(parse(ex$,10,dlm$))
						epswd$=fnEq$(parse(ex$,11,dlm$))
						emime$=fnEq$(parse(ex$,12,dlm$))
						pcopy$=fnEq$(parse(ex$,13,dlm$))
						# LONG BODY, unique to method 5
						if doing_method=5:
							lbrk$="
" # "\n" for regular text, "
" for mime text/html
							ebody$=""
							for rw=14 to 60
								ebody$+=lbrk$+fnEq$(parse(ex$,rw,dlm$))
							next rw
							mlf$=lbrk$+lbrk$+lbrk$
							while pos(mlf$=ebody$)
								ebody$=sub(ebody$,mlf$,lbrk$)
							wend
						endif
					endif
				endif
				if fx$<>"":
					finvno$="f"+edocid$
					fcopy$=fnEq$(parse(fx$,1,dlm$))
					faddr$=fnEq$(parse(fx$,2,dlm$))
					if faddr$<>"":
						ffrom$=fnEq$(parse(fx$,3,dlm$))
						fsubj$=fnEq$(parse(fx$,4,dlm$))
						fbody$=fnEq$(parse(fx$,5,dlm$))
						ftach$=fnEq$(parse(fx$,6,dlm$))
						fcovr$=fnEq$(parse(fx$,7,dlm$))
						ftnam$=fnEq$(parse(fx$,8,dlm$))
						ftoco$=fnEq$(parse(fx$,9,dlm$))
						ffrco$=fnEq$(parse(fx$,10,dlm$))
						f11$=fnEq$(parse(fx$,11,dlm$))
						f12$=fnEq$(parse(fx$,12,dlm$))
						pcopy$=fnEq$(parse(fx$,13,dlm$))
						# LONG BODY, unique to method 5
						if doing_method=5:
							lbrk$="\n"
							fbody$=""
							for rw=14 to 60
								fbody$+=lbrk$+fnEq$(parse(fx$,rw,dlm$))
							next rw
							mlf$=lbrk$+lbrk$+lbrk$
							while pos(mlf$=fbody$)
								fbody$=sub(fbody$,mlf$,lbrk$)
							wend
						endif
					endif
				endif
				
				# for method 2; if a print| line exists, use it
				if sx$<>"" pcopy$=parse(sx$,1,dlm$)
		
			endif
		endif
	endif
		
	# allow "tag=value" format
	def fnEq$(q2$)
		q2$=sub(q2$,QUO,"")
		if pos("="=q2$):
			q2$=parse(q2$,2,"=")
		endif
		return q2$
	end def
}
[8.0 ED Selective Copy Printing]
precopy {
	if lower(edel$)="y":
		if not(uf.subjob) then :
			# selective copy printing from pcopy$ in eDel merges;
			# note new pcopy$ option in email and fax delimited lines
			# to eliminate need for separate 'print|' line in method 2
			# re pcopy$ variable in eDel merges:
			# pcopy$ is print copy field, 0=suppress print, or see scopy options
		
			if pcopy$<>"":
				switch lower(pcopy$)
					case "none","0",""
						skip=1
					break
					case "all"
					break
					default
					if pos(","+str(copy)+","=","+pcopy$+",")=0 then :
						skip=1
					endif
				end switch
			endif
		endif	#
	endif
	
}
[zMrgMultiPageXofY]
# v8.0
# This merge rule set will determine the # of pages
# for each document in the text stream,
# and using a look ahead methodology
# display Page X of Y on the row specified using
# the font & justification specified
#
# copy the following global constant to the globals
# area of the rule file, for the purpose of making the
# font used standard for all rule sets, if it doesn't
# already exist. Un-comment and adjust as needed.
#global XOFYM_FONT="univers,10,bold,left"
# copy the following code from feature comment to merge
# command, to the bottom of the rule set being changed
# Un-comment and adjust as needed.
# ok to remove if not needed or already set
# Page X of Y feature
# change XOFYM_COPIES to "0" to turn off
#local MAXCOLS   	=80			# adjust as needed
#local MAXROWS   	=66			# adjust as needed
#local XOFYM_COPIES="ALL"		# or copy #'s to display
#local XOFYM_FONT 	="XOFYM_FONT"	# use global or ???
# if not using justification, set XOFYM_DCOL to start col
#local XOFYM_DCOL	=10
#local XOFYM_DROW 	=MAXROWS+.5	# row to display title
# location of unique doc id
#local XOFYM_COL  	=70			# adjust as needed
#local XOFYM_ROW  	=5				# adjust as needed
#local XOFYM_NCOLS	=10			# adjust as needed
#merge "zMrgMultiPageXofY"
prepage {
	# check ahead to see if same doc id
	lastpgdocid$=get(XOFYM_COL,XOFYM_ROW,XOFYM_NCOLS,"Y",pagenum-1)
	thispgdocid$=trim(get(XOFYM_COL,XOFYM_ROW,XOFYM_NCOLS))
	nextpgdocid$=get(XOFYM_COL,XOFYM_ROW,XOFYM_NCOLS,"Y",pagenum+1)
	# only run when on the first page
	# of a new document in the stream
	if thispgdocid$<>"" and thispgdocid$<>lastpgdocid$ then:
		xofym_maxpgs=1  # reset total pages for doc
		xofym_pageno=0  # reset doc page counter
		checkpage=pagenum
		checknextpgdocid$=nextpgdocid$
		while checknextpgdocid$=thispgdocid$
			checkpage+=1,xofym_maxpgs+=1
			checknextpgdocid$=get(XOFYM_COL,XOFYM_ROW,XOFYM_NCOLS,"Y",checkpage+1)
		wend
	endif
	# set page #
	xofym_pageno+=1
	# find start col & # of cols from justification
	xofym_font$=lower("XOFYM_FONT")
	xofym_dcol=0
	# left justification
	if pos("left"=xofym_font$) then :
		xofym_dcol=2,xofym_dcols=MAXCOLS
	endif
	# center justification
	if pos("center"=xofym_font$) then :
		xofym_dcol=1,xofym_dcols=MAXCOLS
	endif
	# right justification
	if pos("right"=xofym_font$) then :
		xofym_dcol=1,xofym_dcols=MAXCOLS-1
	endif
	# no justification, use XOFY_DCOL
	if xofym_dcol=0 then xofym_dcol=XOFYM_DCOL
	if xofym_dcol=0 then xofym_dcol=1
	
	# setup X of Y cmd
	xofym_cmd$ ="text "+str(xofym_dcol)+","+str(XOFYM_DROW)+","
	xofym_cmd$+=quo+"Page "+str(xofym_pageno)+" of "
	xofym_cmd$+=str(xofym_maxpgs)+quo
	xofym_cmd$+=","+xofym_font$+",cols="+str(xofym_dcols)
}
precopy {
	if pos(str(copy)="XOFYM_COPIES") or "XOFYM_COPIES"="ALL" then :
		# display page x of y
		exec(xofym_cmd$)
	endif
}
# end zMrgMultiPageXofY
[zMrgSinglePageXofY]
# v8.0
# This merge rule set will use the internal variables
# pagenum, for the current page # and
# uf.maxpage, for the total # of pages
# for this single document text stream and
# display Page X of Y on the row specified using
# the font & justification specified
# copy the following global constant to the globals
# area of the rule file, for the purpose of making the
# font used standard for all rule sets, if it doesn't
# already exist. Un-comment and adjust as needed.
#global XOFYS_FONT="univers,10,bold,left"
# copy the following code from feature comment to merge
# command, to the bottom of the rule set being changed
# Un-comment and adjust as needed.
# ok to remove if not needed or already set
# Page X of Y feature
# change XOFYS_COPIES to "0" to turn off
#local MAXCOLS   	=80				# adjust as needed
#local MAXROWS			=66				# adjust as needed
#local XOFYS_COPIES="ALL"			# or copy #'s to display
#local XOFYS_FONT 	="XOFYS_FONT"	# use global or ???
# if not using justification, set XOFYS_DCOL to start col
#local XOFYS_DCOL	=10
#local XOFYS_DROW	=MAXROWS+.5		# row to display title
#merge "zMrgSinglePageXofY"
prepage {
	# find start col & # of cols from justification
	xofy_font$=lower("XOFYS_FONT")
	xofy_dcol=0
	# left justification
	if pos("left"=xofy_font$) then :
		xofy_dcol=2,xofy_dcols=MAXCOLS
	endif
	# center justification
	if pos("center"=xofy_font$) then :
		xofy_dcol=1,xofy_dcols=MAXCOLS
	endif
	# right justification
	if pos("right"=xofy_font$) then :
		xofy_dcol=1,xofy_dcols=MAXCOLS-1
	endif
	# no justification, use XOFYS_DCOL
	if xofy_dcol=0 then xofy_dcol=XOFYS_DCOL
	if xofy_dcol=0 then xofy_dcol=1
	
	# setup X of Y cmd
	xofy_cmd$ ="text "+str(xofy_dcol)+","+str(XOFYS_DROW)+","
	xofy_cmd$+=quo+"Page "+str(pagenum)+" of "
	xofy_cmd$+=str(uf.maxpage)+quo
	xofy_cmd$+=","+xofy_font$+",cols="+str(xofy_dcols)
}
precopy {
	if pos(str(copy)="XOFYS_COPIES") or "XOFYS_COPIES"="ALL" then :
		# display page x of y
		exec(xofy_cmd$)
	endif
}
# end zMrgSinglePageXofY
[Drop In Code Sample]
# Invoice Laser code as Drop In Code Sample
# Section above archiving section is from "old" code block that
# needed to be before archiving for timing purposes, rest of
# old code is at bottom (except it was removed for sample) :)
# ----------------------------------------------------------------------
prepage {
	# get invoice title
	doc_title$="INVOICE",reprint$=""
	# get title from body of invoice, if available.
	# Must handle credit memo text/quote.
	x$=trim(cut(18,10,26,""))
	x=pos("REPRINT"=x$)
	if x then reprint$="REPRINT"
	x=pos("C R E D I T"=X$)
	if x then doc_title$="CREDIT MEMO"
	x=pos("Q U O T E"=X$)
	if x then doc_title$="QUOTE"
}
# --- 8.0 ARCHIVING ----------------------------------------------------
	
	const ARCRULE="invoice"
	prepage {
	noarchive=1
	earc$="EARC_INVOICE",doing_recat=0
	earca_formtype$="laser"
	if lower(earc$)="y":
		noarchive=0
		if not(uf.subjob):
			gosub process_arcProps  # see 8.0 zMrg ArcProps ruleset
		endif
	endif
	}
	merge "8.0 zMrg ArcProps"
	if uf.arcenabled
		ARCHIVE {earca_library$},{earca_doctype$},{earca_docid$},subid {earca_subid$},title {earca_title$},notes {earca_notes$},keywords {earca_keywords$},categories {earca_cats$},links {earca_links$},args {earca_args$},dtm {earca_dtm$},subtitle {earca_subtitle$},subdtm {earca_subdtm$},entityid {earca_entid$}
	endif
	
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
	#	# mje 062810 disabled due to different order doc types
	#	merge "8.0 zMrg PDFLinks v2"
	#	prepage {
	#		exec(fnCreateAnnotations$("~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ",61,22,70,22,0,"","","DBCFONT","EARC_ORDLINKLIB","EARC_ORDLINKDOCTY"))
	#	}
# --- SCANNING BARCODE --------------------------------------------------
	prepage {
		bcod_docid$=get(112,7,8,"y")
	}
	
	precopy {
		# Add barcodes for scanning interface.
		bcod$="BCOD_INVOICE"			# Y/N Switch from global section
		bcod_Copies$="2"	# which copy(s) get barcode
		if lower(bcod$)="y" then:
			if pos(str(copy)=bcod_Copies$):
				bcod_docty$="SOINV"
				rows$=str(MAXROWS+7)
				cmd$="text 2,"+str(MAXROWS+1.5)+","+$22$+"Do not write below this line"+$22$+",cgtimes,10,italic"
				cmd$+=$0a$+"cbox LEFTCOL,"+str(MAXROWS+2)+",RIGHTCOL,"+str(MAXROWS+2)
				cmd$+=$0a$+"barcode "+str(inchtocols(.5))+","+str(MAXROWS+4)+","+$22$+bcod_docty$+$22$+",BCSYMB,18.0,6,text"
				cmd$+=$0a$+"barcode "+str(inchtocols(3.5))+","+str(MAXROWS+4)+","+$22$+bcod_DocID$+$22$+",BCSYMB,18.0,6,text"
				exec(cmd$)
			end if
		end if
	}
	
# --- PAGE X of Y FEATURE -----------------------------------------------
	# Page X of Y feature
	# change XOFYM_COPIES to "0" to turn off
	local XOFYM_COPIES="ALL"		# or copy #'s to display
	local XOFYM_DROW 	=MAXROWS+.5	# row to display title
	# location of unique doc id
	local XOFYM_COL  	=112			# adjust as needed
	local XOFYM_ROW  	=7				# adjust as needed
	local XOFYM_NCOLS	=8			# adjust as needed
	global XOFYM_FONT="univers,10,bold,left"
	merge "zMrgMultiPageXofY"
# --- 8.0 DELIVER ------------------------------------------------------
	
	# deliver email command - no change needed, ref tags in deliver.ini
	deliver {eaddr$},{einvno$},args {eArg$},from {efrom$},cc {ecccc$},bcc {ebbcc$},subject {esubj$},note {ebody$},login {elogn$},password {epswd$},attach {etach$},otherhead {eohdr$},bodymime {emime$},combine {eCombine$}
	# deliver fax command - no change needed, ref tags in deliver.ini
	deliver {faddr$},{finvno$},args {fArg$},fromname {ffrom$},subject {fsubj$},note {fbody$},coverpage {fcovr$},attach {ftach$},toname {ftnam$},tocompany {ftoco$},fromcompany {ffrco$},combine {fCombine$}
	prepage {
	# form-based data locations
	edel$="EDEL_INVOICE"
	if lower(edel$)="y":
		eDocid$=get(112,7,8,"y")		# Required ALL methods
		# Method 6: Address Book doc type, or subject component
		eDocty$="Invoice"
		# Method 6: Address entity ID for lookup
		eAddrEnt$=get(10,10,6,"y")
	endif
	}
	# ADDRESS RETRIVAL METHOD, set in global section!
	merge "EDEL_METHOD"
	# EMAIL defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if eAddr$<>"":
					# email, ref tags in deliver.ini
					if ecopy$="" ecopy$="1"
					if efrom$="" efrom$=""
					if esubj$="" esubj$=eDocty$+" "+eDocid$
					if ebody$="" ebody$="\nThank you for your business.\n\nThe Management"
					if etach$="" etach$=""
					if ecccc$="" ecccc$=""
					if ebbcc$="" ebbcc$=""
					if eohdr$="" eohdr$=""
					if elogn$="" elogn$=""
					if epswd$="" epswd$=""
					if emime$="" emime$="" # "text/html"
					if pcopy$="" pcopy$=""
					eArg$="-ce "+ecopy$
					eCombine$="no"
				endif
			endif
		endif
		}
	
	# FAX defaults or overrides, remove conditional for override
	prepage {
		if lower(edel$)="y":
			if not(uf.subjob):
				if fAddr$<>"":
					# fax, ref tags in deliver.ini
					if fcopy$="" fcopy$="1"
					if ffrom$="" ffrom$=""
					if fsubj$="" fsubj$=eDocty$+" "+eDocid$
					if fbody$="" fbody$=""
					if ftach$="" ftach$=""
					if fcovr$="" fcovr$=""  # Fax Pkg cover page
					if ftnam$="" ftnam$=""
					if ftoco$="" ftoco$=""
					if ffrco$="" ffrco$=""
					if pcopy$="" pcopy$=""
					fArg$="-ce "+fcopy$
					fCombine$="no"
				endif
			endif
		endif
		}
	
	# remark this to ALWAYS print ALL copies of a delivered document
	merge "8.0 ED Selective Copy Printing"
	
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
# --- 8.0 ARCHIVING ----------------------------------------------------
# --- PDF HYPERLINK FOR ARCHIVING --------------------------------------
# --- SCANNING BARCODE --------------------------------------------------
# --- PAGE X of Y FEATURE -----------------------------------------------
# --- 8.0 DELIVER ------------------------------------------------------
# --- ATTACH SCANNED IMAGES ---------------------------------------------
# --- ORIGINAL CODE-BLOCK SECTION ---------------------------------------
[-------]
[zMrg Form Header]
LOGO_IMAGE 1,1,{logocols},{logorows},"COMP_LOGO"
text 1,2.25,{doc_title$},HBRFONT,16,cols=MAXRCOLS
text 1,3.25,{reprint$},HRFONT,12,cols=MAXRCOLS
text 1,2.25,{comp_name$},HBCFONT,14,cols=MAXRCOLS
text 1,3.25,{comp_addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.25,{comp_addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.25,{comp_addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.25,"COMP_PHONES",HCFONT,12,cols=MAXRCOLS
text 1,7.25,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.25,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
[zMrg get company info]
if xcol>0 and xrow>0 and trim(get(xcol,xrow,40))<>"" then :
	comp_name$=trim(get(xcol,xrow,40))
	comp_addr1$=trim(get(xcol,xrow+1,40))
	comp_addr2$=trim(get(xcol,xrow+2,40))
	comp_addr3$=trim(get(xcol,xrow+3,40))
endif
if xcol=0 or xrow=0 or trim(get(xcol,xrow,40))="" then :
	comp_name$="COMP_NAME"
	comp_addr1$="COMP_ADDR1"
	comp_addr2$="COMP_ADDR2"
	comp_addr3$="COMP_ADDR3"
endif
[zMrg 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:
[zMrg get zip]
shipzip$=""
# Retrieve the zip code from either xrow or xrow-1
#x=mask(left(text$[xrow],xcols),"[0-9][0-9][0-9][0-9][0-9]")
if x>0 then shipzip$=get(x,xrow,10,1)
#if x=0 then x=mask(trim(left(text$[xrow-1],xcols)),"[0-9][0-9][0-9][0-9][0-9]")
if x=0 then x=mask(left(text$[xrow-1],xcols),"[0-9][0-9][0-9][0-9][0-9]")
if shipzip$="" then if x>0 then shipzip$=get(x,xrow-1,10,1)
shipzip$=sub(shipzip$,"-","")
[zMrg load rpt header]
rptdate$=trim(get(1,1,10))
x=pos("  Page "=text$[1])
compname$=trim(get(20,1,x-1-20))
pageno$=trim(get(x,1,20))
time$=trim(get(1,2,8))
title$=trim(get(20,2,150))
opt1$=trim(get(20,3,150))
if brow>=4 then opt2$=trim(get(20,4,150))
if brow>=5 then opt3$=trim(get(20,5,150))
if brow>=6 then opt4$=trim(get(20,6,150))
[zMrg Report Header]
cerase 1,1,MAXCOLS,{brow}
cbox LEFTCOL,.5,RIGHTCOL,{brow+1.25},MBOXSIZE,HSHADE
text 2,1.5,{rptdate$},HFONT,black
text 2,2.5,{time$},HFONT,black
text 1,1.5,{pageno$},HRFONT,cols=MAXRCOLS,black
text 1,1.5,{compname$},HBCFONT,14,cols=MAXCOLS,black
text 1,2.75,{title$},HBCFONT,12,cols=MAXCOLS,black
text 1,3.69,{opt1$},HCFONT,9,cols=MAXCOLS,black
text 1,4.88,{opt2$},HCFONT,9,cols=MAXCOLS,black
text 1,5.82,{opt3$},HCFONT,9,cols=MAXCOLS,black
text 1,6.75,{opt4$},HCFONT,9,cols=MAXCOLS,black
[zMrg Report Header 2]
cerase 1,1,MAXCOLS,{brow}
cbox LEFTCOL,.5,RIGHTCOL,{brow+1.25},MBOXSIZE,HSHADE
text 2,1.5,{rptdate$},HFONT,black
text 2,2.5,{time$},HFONT,black
text 1,1.5,{pageno$},HRFONT,cols=MAXRCOLS,black
text 1,1.5,{compname$},HBCFONT,14,cols=MAXCOLS,black
text 1,2.82,{title$},HBCFONT,12,cols=MAXCOLS,black
text 1,3.95,{opt1$},HCFONT,9,cols=MAXCOLS,black
text 1,4.87,{opt2$},HCFONT,9,cols=MAXCOLS,black
text 1,5.72,{opt3$},HCFONT,9,cols=MAXCOLS,black
text 1,6.65,{opt4$},HCFONT,9,cols=MAXCOLS,black
b  	2