COMPILE SUBROUTINE Print_Shelf_Label(WONo)


DECLARE FUNCTION Msg, Printer_Select, Set_Printer, PopUp, Direct_Print, Environment_Services
DECLARE SUBROUTINE ErrMsg

$INSERT COMPANY_EQU
$INSERT WO_LOG_EQU
$INSERT OIPRINT_EQUATES
$INSERT POPUP_EQUATES
$INSERT LOGICAL


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(WONo))	THEN RETURN

WOStepKeys = XLATE('WO_LOG',WONo,WO_LOG_WO_STEP_KEY$,'X')
PrintSAPOrder = XLATE('WO_LOG', WONo, 'PROD_ORD_NO', 'X')				; * Xlate WO # into SAP Production Order #  dkk 6/18/15

IF INDEX(WOStepKeys,@VM,1) THEN
	TypeOver = ''
	TypeOver<PDISPLAY$> = WOStepKeys
	StepNo = Popup(@WINDOW,TypeOver,'WO_STEP_SELECT')
	
	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
		RETURN
	END
	IF StepNo = CHAR(27) OR StepNo = '' THEN RETURN
	MultiStep = 1
	WONo := '.':StepNo
END ELSE
	MultiStep = ''
END


LabelQty = Msg(@WINDOW,'','SHELF_LABEL_QTY')

IF LabelQty = CHAR(27) THEN RETURN


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

* This was AZBr3

PrinterID = '\\mesirwfp001\MESZBRPRT002'	;* Site specific label printer ID - Skips popup

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

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

FOR I = 1 TO LabelQty

	Str = '^XA^CFD'
	Str:= '^LH0,0'
	Str:= '^PR2' 		;* PRINT SPEED 2 INCHES PER SECOND
	Str:= '^LL325' 		;* LABEL LENGTH IN DOTS
	Str:= '^MD15' 		 ;* MEDIA DARKNESS
	Str:= '^MMT':CRLF$   ;* MEDIA MODE T=TEAR OFF MODE

	IF MultiStep > 0 THEN
		Str:= '^FO10,30^A0220,150^FD':PrintSAPOrder:'^FS':CRLF$	 		;* 5/21/2005 - JCH - Changed for Order Entry/Vision upgrade	/ Changed WONo to PrintSAPOrder/210 changed to 150	dkk 6/22/15
	END ELSE
		Str:= '^FO70,30^A0220,150^FD':PrintSAPOrder:'^FS':CRLF$			;* Changed WONo to PrintSAPOrder	dkk 6/22/15 		
	
	Str:= '^FO205,180^A080,100^FD':WONo:'^FS':CRLF$						;* Add WO # under ProdOrder #	dkk 6/22/15
	
	END

	* GET CUST ABBREV

	CustNo = xlate( 'WO_LOG', WONo[1,'.'], wo_log_cust_no$, 'X' )
	CustAbbrevOrName = xlate( 'COMPANY', CustNo, 'ABBREV_OR_CO_NAME', 'X' )

	
	Str:= '^FO30,295^A75,42^FD':CustAbbrevOrName:'^FS':CRLF$
	Str:= '^FO150,370^A080,50^FD':'Commit Date: ':oconv( xlate( 'WO_LOG', WONo[1,'.'], wo_log_commit_date$, 'X' ), 'D2/' ):'^FS':CRLF$
	Str:= '^XZ'

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


NEXT I

* * * * * *
OIPrint_Error:
* * * * * *

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

RETURN

