COMPILE SUBROUTINE Print_Small_Loc_Label(WhCd,LocCd,LocRec)

/*
	Print a label to the Zebra 105-s printer
    
    12/04/2000 JCH - Initial coding -  J.C.Henry, Inc. 2000
    
*/


DECLARE FUNCTION 	Set_Printer, Get_Printer, Get_Status, Msg, RGB, Printer_Select,Get_Property,Print_Init,Print_End,Print_Text
DECLARE FUNCTION 	obj_Install, Direct_Print, Environment_Services
DECLARE SUBROUTINE  Set_Status, ErrMsg, Msg

$INSERT OIPRINT_EQUATES
$INSERT MSG_EQUATES
$INSERT LOCATION_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

ErrorTitle = 'Error in Stored Procedure "PRINT_SMALL_LOC_LABEL"'

IF NOT(ASSIGNED(WhCd))		THEN RETURN
IF NOT(ASSIGNED(LocCd))		THEN RETURN
IF NOT(ASSIGNED(LocRec))	THEN LocRec = ''

IF LocRec = '' THEN
	LocRec = XLATE("LOCATION",WhCd:'*':LocCd,'','X')
END


BitMap = obj_Install('Get_Prop','ZebraGRF')						;* Substitute company logo converted to .GRF (Zebra graphics format)
OSREAD ImageData FROM BitMap ELSE
	ErrMsg('Unable to Read ':BitMap:' graphic for use on Carton Labels.')
END
GRFName = FIELD(BitMap,'.',1)


* * * * * * * * * * * *
*Start Printing Process
* * * * * * * * * * * *


FileName 	= "Printing Label"
Title       = "Printing Label"	;* Initialize Printing

FileName 	= "Printing Label"
Title       = "Printing Label"	;* Initialize Printing

PageInfo			= ''
PageInfo<PI$LEFT>	= 0.1
PageInfo<PI$TOP>	= 0.1
PageInfo<PI$RIGHT>	= 0.1
PageInfo<PI$BOTTOM>	= 0.1

PageSetup	= '1' 							;* Landscape
PrintSetup  = ''							;* Preview

*PrinterID = '\\FMSA001\PMSAZ_BR2'			;* Printer Server change
PrinterID = '\\mesirwfp002.irworld.irf.com\MESZBRPRT002'	;* Site specific label printer ID - Skips popup


*MESZBRPRT002 on mesirwfp002.irworld.irf.com


PrintPath	= Printer_Select(PrinterID)		;* Select printer - Displays popup if PrinterPort not found 

IF PrintPath = '' THEN
	Def = ""
	Def<MTYPE$> = "TA3"
	Def<MTEXT$> = 'Destination Printer not Selected..'
	Def<MCAPTION$> = ''
	Def<MICON$> = '*'
	Msg(@WINDOW, Def, '')
	RETURN
END

If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
    stat = Set_Printer("INIT",FileName,Title,PageInfo,PageSetup,PrintSetup,PrintPath)
end else
    stat = Direct_Print('START', PrintPath<1>, '', '')
end

IF stat < 0 THEN GOTO OIPrint_Err

LocDesc	= LocRec<LOCATION_DESC$>

Nomenclature = FMT(LocDesc,'T#18')
NomenLine1 = FIELD(Nomenclature,@TM,1)
NomenLine2 = FIELD(Nomenclature,@TM,2)
NomenLine3 = FIELD(Nomenclature,@TM,3)


* Label is 1218 x 812 dots at 8dots/mm (203 dots/inch)
* Leave periodic spaces in Label String - OIPrint interface wraps text on spaces and will cut off 
* the LabelString if there aren't any spaces.  Printer Width needs to be set to 132 or greater

LabelString = ImageData
stat = Set_Printer('TEXT',ImageData)
If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
    stat = Set_Printer('TEXT',ImageData)
end else
    stat = Direct_Print('PRINT', ImageData)
end

LabelString  = '^XA'										;* Start of label format
*LabelString := '^FWR'										;* Field orientation rotated 90

LabelString := '^LH30,30'									;* Label home for 'Landscape' printing

*LabelString := '^FO0,0^XGR:':GRFName:',1,1^FS'				;* Logo

Company = 'IFX Epi Services'								;* Changed to hardcoded 10/25/2016 dkk
LabelString := '^FO20,0^A0,,36^FD':Company:'^FS'

LabelString := '^FO450,0^GB0,100,4,B^FS':CRLF$				;* Vertical Before Lot data

LabelString := '^FO20,100^GB1150,0,4,B^FS':CRLF$			;* Line under Warehouse & Logo

LabelString := '^FO20,115^AF,40^FD':NomenLine1:'^FS':CRLF$
LabelString := '^FO20,175^AF,40^FD':NomenLine2:'^FS':CRLF$
LabelString := '^FO20,235^AF,40^FD':NomenLine3:'^FS':CRLF$


BCString = WhCd:'*':LocCd
SWAP '*' WITH '/J' IN BCString

NarrowBarWidth = 2
LabelString := '^FO424,110^BY':NarrowBarWidth:',,^B3,N,150,Y,^FD':BCString:'^FS':CRLF$	;* BarCode		;* Original dkk: '^FO624,110^BY':NarrowBarWidth:',,^B3,N,150,Y,^FD'

LabelString := '^FO20,300^A0,40^FDWarehouse: ^FS':CRLF$		;* Warehouse Label
LabelString := '^FO230,300^A0,40^FD':WhCd:'^FS':CRLF$		;* Warehouse Data							;*Original dkk: '^FO270,300^A0,40^FD':WhCd:'^FS':CRLF$ 

LabelString := '^FO450,300^A0,40^FDLocation: ^FS':CRLF$													;*Original dkk: '^FO550,300^A0,40^FDLocation: ^FS':CRLF$
LabelString := '^FO620,300^A0,40^FD':LocCd:'^FS':CRLF$													;*Original dkk: '^FO740,300^A0,40^FD':LocCd:'^FS':CRLF$

LabelString := '^FO20,340^GB1150,0,4,B^FS':CRLF$				;* Line 1.25" down the label
LabelString := '^FO20,580^GB1150,0,4,B^FS':CRLF$				;* Line 1.25" down the label


LabelString := '^XZ':CRLF$

If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
    stat = Set_Printer('TEXT',LabelString)
end else
    stat = Direct_Print('PRINT', LabelString)
end

* * * * * * *
OIPrint_Err:
* * * * * * *


If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
    stat = Set_Printer("TERM")
end else
    stat = Direct_Print('STOP')
end

RETURN
