COMPILE SUBROUTINE PRINT_BARCODE_LABEL( Method, Parms )
#pragma precomp SRP_PreCompiler

$INSERT LSL_USERS_EQUATES
Declare function Set_Printer, Printer_Select , Direct_Print
Declare function Environment_Services, SRP_Math
Declare subroutine Msg

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


FileName 	= "Printing Label"
Title		= "Printing Label"

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 = 'MESZBRPRT008'    

PrintPath	= Printer_Select(PrinterID)												;* Popup is skipped IF Printer ID is passed

If PrintPath NE '' then
 	
 	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_Error
 	
 	EQU DosPath$ TO 'C:\WINDOWS\OIZPL.TXT'				;* remove jch
 	
 	CLOrientation = '' ;* used for printing on cleanroom labels
	
BEGIN CASE
	CASE Method = 'EmployeeBadge'	; Gosub Print2DEmployeeBadgeLabel
	CASE Method = '2DEmployeeBadge'	; Gosub Print2DEmployeeBadgeLabel
	CASE 1
		NULL

END CASE

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


PrintEmployeeBadgeLabel:

	EmpRec = XLATE('LSL_USERS', Parms, '', 'X')
	*debug
	For Each User in Parms using @VM
		*User = Parms
		Pwd = EmpRec<LSL_USERS_PASSWORD$>

		UserPrefix	= '1H'
		PwdPrefix	= 'PWD'
		FName		= EmpRec<1>
		LName		= EmpRec<2>
		Name = FName:' ':LName[1,1]
		UserLen		= Len(UserPrefix) + Len(User)
		UserLen1	= 150 - SRP_MATH('ROUND', UserLen * 10, '', 0)
		PwdLen		= Len(PwdPrefix) + Len(Pwd) 
		PwdLen1		= 150 - SRP_MATH('ROUND', PwdLen * 10, '', 0)
		Header		= ''
		Body1		= ''
		Body2		= ''
		Footer		= ''
		
		Header = '^XA'
		Header := '^LH10,10'
		Header := '^PR1'		;* Print speed 2 inches per second
		Header := '^LL203'		;* Label length @203 dpi
		Header := '^PW406'		;* Print Width @203 dpi
		Header := '^MD2'		;* Media darkness							
		Header := '^MMT'		;* Media mode t=tear off mode
		Header := '^PQ2'		;* Print 2 labels for each pass through here
		
		Body1 := '^FO0,30^BCN,100,N^FD':UserPrefix:User:'^FS'
		Body1 := '^FO20,140^A0,30^FB400,1,0,C^FD':Name:'^FS'
		
		Body2 := '^FO0,30^BCN,100,N^FD':PwdPrefix:Pwd:'^FS'
		Body2 := '^FO20,140^A0,30^FB400,1,0,C^FDPASSWORD^FS'
		
		Footer := '^XZ'
		
		labelString = Header : Body1 : Footer : Header : Body2 : Footer
		
		If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
			stat = Set_Printer('TEXT',labelString)
		end else
			stat = Direct_Print('PRINT', labelString)
		end
	Next User

return
	
	
Print2DEmployeeBadgeLabel:
		EmpRec = XLATE('LSL_USERS', Parms, '', 'X')
	For Each User in Parms using @VM
		*User = Parms
		Pwd = EmpRec<LSL_USERS_PASSWORD$>

		UserPrefix	= '1H'
		PwdPrefix	= 'PWD'
		FName		= EmpRec<1>
		LName		= EmpRec<2>
		Name = FName:' ':LName[1,1]
		Header		= ''
		Body1		= ''
		Body2		= ''
		Footer		= ''
		
		Header = '^XA'
		Header := '^LH10,10'
		Header := '^PR1'		;* Print speed 2 inches per second
		Header := '^LL203'		;* Label length @203 dpi
		Header := '^PW406'		;* Print Width @203 dpi
		Header := '^MD2'		;* Media darkness							
		Header := '^MMT'		;* Media mode t=tear off mode
		Header := '^PQ2'		;* Print 2 labels for each pass through here
		
		Body1 := '^FO30,50^BXN,3,200,N^FD':UserPrefix:User:'^FS'
		Body1 := '^FO130,50^BXN,3,200,N^FD':UserPrefix:User:'^FS'
		Body1 := '^FO230,50^BXN,3,200,N^FD':UserPrefix:User:'^FS'
		Body1 := '^FO330,50^BXN,3,200,N^FD':UserPrefix:User:'^FS'
		Body1 := '^FO20,140^A0,30^FB400,1,0,C^FD':Name:'^FS'
		
		Body2 := '^FO30,50^BXN,3,200,N^FD':PwdPrefix:Pwd:'^FS'
		Body2 := '^FO130,50^BXN,3,200,N^FD':PwdPrefix:Pwd:'^FS'
		Body2 := '^FO230,50^BXN,3,200,N^FD':PwdPrefix:Pwd:'^FS'
		Body2 := '^FO330,50^BXN,3,200,N^FD':PwdPrefix:Pwd:'^FS'
		Body2 := '^FO20,140^A0,30^FB400,1,0,C^FDPASSWORD^FS'
		
		Footer := '^XZ'
		
		labelString = Header : Body1 : Footer : Header : Body2 : Footer
		
		If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
			stat = Set_Printer('TEXT',labelString)
		end else
			stat = Direct_Print('PRINT', labelString)
		end
	Next User
return



