compile SUBROUTINE Print_Ship_CheckList( ShipNo )

declare function security_check, set_printer, get_printer, msg, fieldcount, entid, repository, Printer_Select
DECLARE FUNCTION obj_Install
declare subroutine security_err_msg

$insert security_rights_equ
$insert oiprint_equates
$insert msg_equates
$insert prod_spec_equates
$insert rds_equates

$insert quote_equ
$insert order_equ

$INSERT COC_EQUATES
$INSERT WO_LOG_EQUATES
$INSERT WO_STEP_EQU
$INSERT CUST_EPI_PART_EQUATES

EQU PI$LEFT		TO 1
EQU PI$TOP		TO 2
EQU PI$RIGHT	TO 3
EQU PI$BOTTOM	TO 4
EQU PI$WIDTH	TO 5
EQU PI$HEIGHT	TO 6
EQU PI$SIZE		TO 7


IF NOT(ASSIGNED(ShipNo)) THEN RETURN

ShipRec = XLATE('COC',ShipNo,'','X')

IF ShipRec = '' THEN RETURN

* * *   PRINT SETUP   * * *

PageInfo			= ''
PageInfo<PI$LEFT>	= 0.5		;* Margins
PageInfo<PI$TOP>	= 1.35
PageInfo<PI$RIGHT>	= 0.5
PageInfo<PI$BOTTOM>	= 0.25

PageSetup	= 0					;* 1 = Landscape mode
PrintSetup	= 0					;* 0 = Print to printer without Preview

stat = Set_Printer("INIT",'Printing','Packing Slip',PageInfo,PageSetup,PrintSetup)


font = 'Arial'		;* Font basics
font<2> = 10
font<4> = 0

stat = Set_Printer('FONTHEADFOOT', font)

*stat = Set_Printer('FOOTER',"Page 'P'":@VM:@VM:"'T' 'D'")

stat = Set_Printer('LINESTYLE', PS_SOLID:@FM:2)
stat = Set_Printer('LINE', -0.1:@FM:-1.2:@FM:7.5:@FM:-1.2, 1)
stat = Set_Printer('LINE', -0.1:@FM:-0.1:@FM:7.5:@FM:-0.1, 1)
 
location = -.15:@fm:-1.150:@fm:1.57:@fm:1
stat = Set_Printer('BMP',obj_Install('Get_Prop','ColorBMP'),location, 0,1)


* * * *  Added 10/8/2015 JCH - Updated 'CONFIG','COMPANY'  * * * *

InstDat		= obj_Install('Get_Prop','Company':@FM:'Division')
Company		= InstDat<1>
Division	= InstDat<2>
	
font	= 'Arial'
font<2>	= '12'		;* Big type
font<4>	= 1			;* Bold on
font<5> = 0			;* Italics

stat = Set_Printer('TEXTXY',Company,5.7:@FM:-1.15,font,1)
stat = Set_Printer('TEXTXY',Division,5.7:@FM:-0.970,font,1)

font<2> = 10	;* 10 point font
font<4> = 0		;* Bold off
font<5> = 0		;* Italics Off

stat = Set_Printer('TEXTXY',obj_Install('Get_Prop','Address'), 5.7:@fm:-0.775, font,1)
stat = Set_Printer('TEXTXY',obj_Install('Get_Prop','CSZC'), 5.7:@fm:-0.625, font,1)
stat = Set_Printer('TEXTXY','Tel:      ':obj_Install('Get_Prop','Phone'), 5.7:@fm:-0.475, font, 1)
stat = Set_Printer('TEXTXY','FAX:    ':obj_Install('Get_Prop','FAX'), 5.7:@fm:-0.325, font, 1)

* * * *  End of changes 10/8/2015 JCH  * * * *


stat = Set_Printer('TEXTXY','Shipment No: ':ShipNo,3.0:@FM:-0.325,font,1)

SAPDelNo = ShipRec<COC_SAP_DEL_NO$>

IF SAPDelNo NE '' THEN
	SAPDelNo = '12345678'
	stat = Set_Printer('TEXTXY','SAP Delivery No: ':SAPDelNo,2.8:@FM:-0.525,font,1)
END

font<2>	= '18'		;* Big type
font<4>	= 1			;* Bold on
font<5> = 1			;* Italics

IF SAPDelNo = '' THEN
	stat = Set_Printer('TEXTXY','Shipping Check List',2.5:@FM:-0.80,font,0)
END ELSE
	stat = Set_Printer('TEXTXY','Shipping Check List',2.5:@FM:-1.00,font,0)
END


Void = set_printer( 'TEXT', '' )
Void = set_printer( 'TEXT', '' )

* pull off all variables
* run data sheet id is passed via the calling program and this code will pick up 
* the rest via translation

WONo			= ShipRec<COC_WO$>
WORec			= XLATE('WO_LOG',WONo,'','X')

ProdOrdNo = WORec<WO_LOG_PROD_ORD_NO$>


IF ProdOrdNo NE '' THEN
	CustNo = WORec<WO_LOG_CUST_NO$>
	CustName =  XLATE('COMPANY',CustNo,4,'X')
	QuoteShipInst = ''
	ShipVia	= ''
	AcctNo = ''
END ELSE

	CustName 		= XLATE('WO_LOG',WONo,'XCUST_NAME','X')
	OrderNo			= WORec<WO_LOG_ORDER_NO$>
	OrderRec		= XLATE( 'ORDER', OrderNo, '', 'X' )

	ShipVia			= OrderRec<ORDER_SHIP_VIA$>
	AcctNo			= OrderRec<ORDER_ACCOUNT_NO$>

	QuoteNo			= WORec<WO_LOG_QUOTE_NO$>
	QuoteShipInst	= XLATE( 'QUOTE', QuoteNo, QUOTE_SPEC_SHIP_INST$, 'X' )
END

WOStepKeys		= WORec<WO_LOG_WO_STEP_KEY$>
PSNId			= XLATE('WO_STEP',LastWOStepKey,WO_STEP_PROD_SPEC_ID$,'X')
PSNRec			= XLATE('PROD_SPEC',PSNId,'','X')


EpiPartNo		= WORec<WO_LOG_EPI_PART_NO$>
CustEpiPartRec = XLATE('CUST_EPI_PART',CustNo:'*':EpiPartNo,'','X')

PSNShipInst				= CustEpiPartRec<CUST_EPI_PART_SHIP_INST$>
TRSRP					= CustEpiPartRec<CUST_EPI_PART_TR_SRP$>
TRSRPWWafer				= CustEpiPartRec<CUST_EPI_PART_TR_SRP_WWAFER$>
TRFTIR					= CustEpiPartRec<CUST_EPI_PART_TR_FTIR$>
TRHgProbe				= CustEpiPartRec<CUST_EPI_PART_TR_HGPROBE$>
TRTencor				= CustEpiPartRec<CUST_EPI_PART_TR_TENCOR$>
TRStress				= CustEpiPartRec<CUST_EPI_PART_TR_STRESS$>
TRTestWafer				= CustEpiPartRec<CUST_EPI_PART_TR_TEST_WAFER$>
TR4PP					= CustEpiPartRec<CUST_EPI_PART_TR_4PP$>
CustRDS					= CustEpiPartRec<CUST_EPI_PART_SHIP_CUST_RDS$>
CustRDSCleanRoomPaper	= CustEpiPartRec<CUST_EPI_PART_CUST_RDS_CLEANROOM_PAPER$>
COCFront				= CustEpiPartRec<CUST_EPI_PART_SHIP_COC_FRONT$>
COCFrontCopies			= CustEpiPartRec<CUST_EPI_PART_SHIP_COC_FRONT_COPIES$>
COCBack					= CustEpiPartRec<CUST_EPI_PART_SHIP_COC_BACK$>
COCBackCopies			= CustEpiPartRec<CUST_EPI_PART_SHIP_COC_BACK_COPIES$>
NCRRej					= CustEpiPartRec<CUST_EPI_PART_SHIP_NCR_REJ$>
PartialShip				= CustEpiPartRec<CUST_EPI_PART_SHIP_PARTIAL$>
FullShipType			= CustEpiPartRec<CUST_EPI_PART_SHIP_FULL_TYPE$>
BagReq					= CustEpiPartRec<CUST_EPI_PART_SHIP_BAG_REQ$>

Font = "Times New Roman"
Font<2> = 16
Font<3> = 'C'
Font<4> = 1

Void = set_printer( 'FONT', Font )

TableColInfo = '<_3630':@vm:'<_3630':@vm:'<_3630'
PrintTbl = 'Customer':@vm:'WO':@vm:'PSN#'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 1, TB_NONE )	;* Heading

Font<2> = 12
Font<4> = 0
Void = set_printer( 'FONT', Font )

PrintTbl = CustName:@vm:WONo:@vm:PSNId
Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 1, TB_ALL )		;* Data
Void = set_printer( 'TEXT', '' )

if QuoteShipInst then
   * shipping instructions for this quote that will override the
   * psn shipping instructions - but print both anyway
   
	Font<2> = 14
	Font<4> = 1
	Void = set_printer( 'FONT', Font )
   
   Void = set_printer( 'TEXT', 'Quotation Special Shipping Instruction' )
	TableColInfo = '<_10890'
	convert @tm to ' ' in QuoteShipInst
	
	Font<2> = 12
	Font<4> = 0
	Void = set_printer( 'FONT', Font )
   
	Void = set_printer( 'ADDTABLE', TableColInfo, '', QuoteShipInst, '', '', 1, TB_ALL )
	Void = set_printer( 'TEXT', '' )	 
end
* 

IF ProdOrdNo = '' THEN
	TableColInfo = '<_5445':@vm:'<_5445'
	PrintTbl = 'Ship Via':@vm:'Account No'

	Font<2> = 14
	Font<4> = 1
	Void = set_printer( 'FONT', Font )

	Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 1, TB_NONE ) 
	PrintTbl = ShipVia:@vm:AcctNo

	Font<2> = 12
	Font<4> = 0
	Void = set_printer( 'FONT', Font )

	Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 1, TB_ALL )
	Void = set_printer( 'TEXT', '' ) 
END
*
if PSNShipInst then
	* Shipping instructions for this PSN

	Font<2> = 14
	Font<4> = 1
	Void = set_printer( 'FONT', Font )

	Void = set_printer( 'TEXT', 'PSN Special Shipping Instruction' )
	TableColInfo = '<_10890'
	convert @tm to ' ' in PSNShipInst
	OsWrite PSNShipInst To "C:\PSN.txt"

	Font<2> = 12
	Font<4> = 0
	Void = set_printer( 'FONT', Font )
	Void = set_printer( 'ADDTABLE', TableColInfo, '', PSNShipInst, '', '', 1, TB_ALL )
	Void = set_printer( 'TEXT', '' )	 
end 


Font<2> = 14
Font<4> = 1
Void = set_printer( 'FONT', Font )

Void = set_printer( 'TEXT', 'Test Results Required' )
Font<2> = 10
Font<4> = 0
Void = set_printer( 'FONT', Font )

* JOHN TRUELOVE'S MODS 5/3/01
TableColInfo = ''
TableColInfo := '^_360':@vm:'<_1195' ;* TRHgProbe
TableColInfo := @vm
TableColInfo := '^_360':@vm:'<_1195' ;* TRSRP
TableColInfo := @vm
TableColInfo := '^_360':@vm:'<_1195' ;* TRSRPWWafer
TableColInfo := @vm
TableColInfo := '^_360':@vm:'<_1195' ;* TRTestWafer 
TableColInfo := @vm

TRSRP        = oconv( TRSRP, 'BX ' )
TRSRPWWafer  = oconv( TRSRPWWafer, 'BX ' )
TRFTIR       = oconv( TRFTIR, 'BX ' )
TRHgProbe    = oconv( TRHgProbe, 'BX ' )
TRTencor     = oconv( TRTencor, 'BX ' )
TRStress     = oconv( TRStress, 'BX ' )
TRTestWafer  = oconv( TRTestWafer, 'BX ' )
TR4PP        = oconv( TR4PP, 'BX ' )

PrintTbl = TRHgProbe:@vm:'Hg Probe':@vm
PrintTbl:= TRSRP:@vm:'SRP':@vm
PrintTbl:= TRSRPWWafer:@vm:'w/Wafer':@vm

PrintTbl:= TRTestWafer:@vm:'Test Wafer':@vm

Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 1, TB_ALL )

Font<2> = 14
Font<4> = 1
Void = set_printer( 'FONT', Font )
Void = set_printer( 'TEXT', '' )
*
Void = set_printer( 'TEXT', 'Forms Required' )
Font<2> = 12
Font<4> = 0
Void = set_printer( 'FONT', Font )
CustRDS = oconv( CustRDS, 'BX ' )
CustRDSCleanRoomPaper = oconv( CustRDSCleanRoomPaper, 'BX ' )        
COCFront = oconv( COCFront, 'BX ' )     
COCBack = oconv( COCBack, 'BX ' )
if COCFrontCopies > 1 then
   COCFrontCopies:= ' Copies of '
end else
   if COCFrontCopies then
      COCFrontCopies:= ' Copy of '
   end
end
if COCBackCopies > 1 then
   COCBackCopies:= ' Copies of '
end else
   if COCBackCopies then
      COCBackCopies:= ' Copy of '
   end
end
TableColInfo = '^_360':@vm:'<_3270':@vm:'^_360':@vm:'<_3270'
PrintTbl = CustRDS:@vm:'Customer RDSs':@vm:CustRDSCleanRoomPaper:@vm:'RDSs on Cleanroom Paper':@fm
PrintTbl:= COCFront:@vm:COCFrontCopies:'COC FRONT page':@vm:COCBack:@vm:COCBackCopies:'COC BACK page'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 1, TB_ALL )
TableColInfo = '^_360':@vm:'<_6180'
if NCRRej = '' then
   * DONT CHECK IT CAUSE IT IS NULL
   NCRRejCheck = ''
end else
   * SIMPLY CHECK IT CAUSE IT IS NOT NULL
   NCRRejCheck = 'X'
end
PrintTbl = NCRRejCheck:@vm:'Ship NCRs after ':NCRRej:' rejects':@vm
Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 1, TB_ALL )
Font<2> = 14
Font<4> = 1
Void = set_printer( 'FONT', Font )
Void = set_printer( 'TEXT', '' )

Void = set_printer( 'TEXT', 'Bagging Required' )
TableColInfo = '<_7245'
PrintTbl = 'Bagging Requirements: ':BagReq
Font<2> = 12
Font<4> = 0
Void = set_printer( 'FONT', Font )
Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 1, TB_ALL )
Font<2> = 14
Font<4> = 1
Void = set_printer( 'FONT', Font )
Void = set_printer( 'TEXT', '' )
*
Void = set_printer( 'TEXT', 'Customer Shipment Frequency' )
Font<2> = 12
Font<4> = 0
Void = set_printer( 'FONT', Font )
PartialShip = oconv( PartialShip, 'BX ' )
swap 'WO' with 'Work Order' in FullShipType
swap 'PO' with 'Purchase Order' in FullShipType
FullShipDesc = ''
if FullShipType then
   FullShipDesc = 'Only ship when ':FullShipType:' is complete.'
end
* WILL BE EITHER WO OR PO - GOT THAT SHMO
TableColInfo = '<_360':@vm:'<_4959':@vm:'<_5551'
PrintTbl = PartialShip:@vm:'Customer Accepts Partial Shipments':@vm:FullShipDesc
Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 1, TB_ALL )
Void = set_printer( 'TEXT', '' )
Void = set_printer( 'TEXT', '' )
*
Font<2> = 12
Font<4> = 1
Void = set_printer( 'FONT', Font )

TableColInfo	= '<_3600'
PrintTbl		= 'Signature:'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 0, TB_BOTTOM:@fm:'R' )
Void = set_printer( 'TEXT', '' )

TableColInfo	= '<_1080':@vm:'^_2520'
PrintTbl		= 'Date:':@vm:fmt( oconv( date(), 'D2/' ), 'R#15' )
Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 0, TB_BOTTOM:@fm:'R' )
Void = set_printer( 'TEXT', '' )

PrintTbl = 'Time:':@vm:fmt( oconv( time(), 'MTH' ), 'R#15' )
Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 0, TB_BOTTOM:@fm:'R' )

id = set_printer( 'TEXT', '' )
TableColInfo	= '<_3600'
PrintTbl		= 'AWB Verified Against PL:':@FM:@FM:'AWB#:'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PrintTbl, '', '', 0, TB_BOTTOM:@fm:'R' )



* termination

	stat = set_printer( 'TERM' )

RETURN


