'CHK_LIST - shows items relating to given docref

external  dpath Background() sch scw cpath fentrybox() messboxwait() vloadif()
external  progress() bpopdb() chkstr() vunloadif()

public    ptstr $sch $date

global    ShowDocrefs() ReturnToMenu() x


MAIN
single-step off
  Background()
  file unload all

  ShowDocrefs()

  ReturnToMenu()

END MAIN


FUNCTION ReturnToMenu()
  Background()
  file unload all
  transfer cpath|"pm_menu.psl" in-memory
END FUNCTION ' ReturnToMenu()


FUNCTION ShowDocrefs()
local $ftr $ftgdate y2 $list $chk y1
  while true
    x = fentrybox(" Enter Collection reference ",8,"*8#","")
    if x = -1
      return (-1)
    end if
    $sch = ptstr
    progress(15,10," Please wait .... finding records ",0)
    vloadif(dpath|"chklist1.vw")
    data query execute "chklist1.dfq" index "chklist1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ [Document] == $sch
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if cerror
      messboxwait(" No records found for reference"&str($sch)&" ",0,0,1)
      continue while
    else
      order change physical
      vloadif(dpath|"chklist2.vw")
      order change index "chklist1.idx"
      order sort now dictionary "chklist2.idx" fields "[Lst_Stck;ViewDesc]" ascending
      $list = case [Program] ("Loading","Loading list")("trd_ancl","Collection")("collect1","Collection") else ""
      $ftgdate = [Date_Out]
      $ftr = [FtrCode]
      $chk = mid($ftr,2,1)                    'message "$chk is:"&str($chk)
      if chkstr($chk,"1 2 3 4 5 6 7 8 9 0")=0 'message " Not Fitterÿ"
        vloadif(dpath|"customer.vws")
        $ftr = filelookup([Customer_Code],[Customer_Name],$ftr)
        vunloadif("customer.vws")
        vloadif(dpath|"chklist2.vw")
      else
        $ftr = [Nickname]
      end if
      Background()
      y1 = "ÿ"|$ftr|"'s"&$list&"on"&date2($ftgdate)
      y2 = "(prep'd by"&[Creator]&"on"&date2([Dated])|")"
      screen print 6 9 15 1 format "M65" y1
      screen print 7 9 15 1 format "M65" y2
      x = bpopdb("chklist2",6,"","[ViewDesc]","L64","[QuantOut]","R0","[Date_Out]",8,9,20,73,"",0)
      Background()
    end if
  end while
END FUNCTION ' ShowDocrefs()

