'ROLLHIST - shows history of roll

' v1.0 101300A MAY

external   messbox() fentrybox() dpath vloadif() sch scw vunloadif() scr
external   pagerec() rollmask progress() popuplist()

public     ptstr $rollnr prodMRC $ordernr $filenr

global     ChooseRoll() $old_bal ReturnToMenu() x prodcode $width desMRC
global     $backing a2 a3 a1 Balance()


MAIN
	single-step off
  	quiet on
  	screen clear box 1 1 sch scw 0 0 no-border
  	repaint off
  	error off
  	vloadif(dpath|"products.vws")

  	while true
    		x = ChooseRoll()
    		if x = -1
      		exit while
    		end if
  	end while

	ReturnToMenu()                        ' unload screens

END MAIN


FUNCTION ChooseRoll()
	while true
  		while true
    			vloadif(dpath|"STK_CARP.vws")
    			x = fentrybox(" Enter Roll Nr to view - {Esc} to finish ",8,rollmask,"")
    			if x = 0
      			$rollnr = ptstr                      'message "$rollnr) is:"&str($rollnr)
      			data find "[RollNr]" equal $rollnr options "gw"
      			if cerror
        				messbox(" Roll Nr not found - re-enter ",0,1,1)
        				return (0)
      			else
        				$filenr  = precord
        				$ordernr = [StockOrder]
				     $old_bal = [Balance]
        				prodcode = [Product_Code]
        				desMRC   = [Description_MRC]
        				$width   = [Width]
        				$backing = filelookup([products.Product_Code],[products.Backing],prodcode)
$backing = case $backing ("ACTI","Action")("JUTE","Jute")("FOAM","Foam")("WAFF","Waffle")("GELL","Gel")("VINY","Vinyl")("STND","Stnd'd")("WOVE","Woven")("IMPV","Impvd")("FELT","Felt")("LATX","Stnd'd")("OVER","Over")("NONE","None")
        				prodMRC  = filelookup([products.Product_Code],[products.Product_MRC],prodcode)
      			end if
			     Balance()
			     exit while
    			elseif x = -1
      			return (-1)
    			else
      			screen clear box 1 1 sch scw 0 0 no-border
      			repaint off
      			return (-1)
    			end if
  		end while
	end while
END FUNCTION  ' ChooseRoll()


FUNCTION Balance()
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ Find req'ns for roll chosen                                   ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
	a1 = format("Code:"&prodcode,"M30")
  	a2 = format(left(prodMRC,30),"M30")
  	a3 = format(desMRC&" ("|$backing|")","M30")
  	vloadif(dpath|"vu_roll.vw")
  	data goto record record-number $filenr
  	if cerror
    		messbox(" No requisitions yet for roll nr"&$rollnr|" ",0,1,1)
  	end if
  	repaint on
  	repaint
  	inchar
  	screen clear box 1 1 sch scw 0 0 no-border
  	repaint off
END FUNCTION  ' Balance()


FUNCTION ReturnToMenu()
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  file unload all
  transfer "pm_menu.psl" in-memory
END FUNCTION
