'DLY_RTNS - Daily Goods Returned report

external   vkeybox() sch scw progress() messbox() vloadif() cpath PrintReport()
external   vunloadif() dpath fentrybox() chkdate() remove() messboxwait()

public     ptstr choice sum_date

global     x DailyRtns() ReturnToMenu() repdef p2 p3 p4 p5 p6 p1

MAIN
  single-step off
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off

  p1 = "dly_rtns.dfr"        ' p1 = report definition ("ord_stck.dfr")
  p2 = "Goods Returned"      ' p2 = title at top of choice popup ("LABEL")
  p3 = 1                     ' p3 = printer to be used (1=HPIII_QC; 2=GEN_EPSN etc)
  p4 = 1                     ' p4 = printer port to use (1,2 etc - network set to use 2=LASER; 3=LABEL)
  p5 = 3                     ' p5 = choose VIEW/PRINT 1=PRINT; 2=VIEW; 3=CHOOSE
  p6 = 1                     ' p6 = nr of copies

  DailyRtns()

  ReturnToMenu()

END MAIN


FUNCTION DailyRtns()
  vloadif(dpath|"dly_rtns.vw")
  order change physical

  while true
    x = fentrybox(" Confirm Date for Goods Returned Report ",10,"##\/##\/####",today)
    if x = 0
      sum_date = ptstr
      if chkdate(sum_date,1) = -1
        messbox(" Incorrect date - re-enter ",0,0,1)
        continue while
      end if
      exit while
    elseif x = -1
      return (-1)
    end if
  end while

  progress(15,10," Please wait ... preparing report ",0)
  data query execute "dly_rtns.dfq" index "goods.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ [Date_Out] = days(sum_date)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messboxwait(" No Goods Returned on"&date2(sum_date)|" ",0,0,1)
    return (0)
  end if
  order sort now dictionary "dly_rtns" fields "[Nickname]" ascending
  PrintReport(p1,p2,p3,p4,p5,p6)

END FUNCTION ' DailyRtns()


FUNCTION ReturnToMenu()
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  file unload all
  transfer cpath|"pm_menu.psl" in-memory
END FUNCTION ' ReturnToMenu()
