'DLY_INVD - lists all invoices printed for given day

external   vkeybox() sch scw progress() messbox() vloadif() cpath PrintReport()
external   vunloadif() dpath fentrybox() chkdate() remove() greeting
external   base findpopup() messboxwait() $menu

public     ptstr choice sum_date br_name psa dsa

global     x DailyInvoices() ReturnToMenu() p1 p2 p3 p4 p5 p6


MAIN
single-step off
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
'   screen shortrestore dsa
  p1 = "dly_invd.dfr"
  p2 = ""   ' p2 = title at top of choice popup ("LABEL")
  p3 = 1    ' p3 = printer to be used (1=HPIII_QC; 2=GEN_EPSN etc)
  p5 = 1    ' p5 = choose VIEW/PRINT 1=PRINT; 2=VIEW; 3=CHOOSE
  p6 = 1    ' p6 = nr of copies

  case base              ' p4 = printer port to use (1,2 etc - network set to use 2=LASER; 3=LABEL)
    when "O"
      p4 = 2
    when "W"
      p4 = 2
    otherwise
      p4 = 1
  end case

  if $menu = "offc" or $menu = "boss"
  else
    messboxwait(" Head office use only ",0,0,1)
    ReturnToMenu()
  end if

  DailyInvoices()

  ReturnToMenu()

END MAIN


FUNCTION DailyInvoices()     ' show keybox() listing each shop (& ALL)
  while true
    x = fentrybox(" Confirm Date for Invoice list ",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)
  vloadif(dpath|"dly_invd.vw")
'   order change physical
  data query execute "dlyinvd1.dfq" index "dlyinvd1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [Invoice_Date] = days(sum_date)
'   and
'   not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messboxwait(" No Invoices printed today ",0,0,1)
    return (1)
  end if
  order sort now dictionary "dly_invd.idx" fields "[Inv_Nr]" ascending
  PrintReport(p1,p2,p3,p4,p5,p6)
  screen clear box 1 1 sch scw 0 0 no-border
END FUNCTION ' DailyCash()


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()


