'VATZERO - temp for Zero-rate sales summary

external   dpath PrintReport() sch scw vloadif() progress() progtag() fgi bgi
external   vatrate remove() makeidx() fentrybox() chkdate() messbox() cpath
external   nr8 messboxwait() dly_pstgpath vunloadif()

public     ptstr rel_date from_date chk_cb end_date strt_date

global     x Sales() SelectDates() p1 p2 p3 p4 p5 p6 #chk #chk1

MAIN
single-step off
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  file unload all
  p1 = "zerorate.dfr"   ' p1 = report definition ("ord_stck.dfr")
  p2 = ""               ' p2 = title at top of choice popup ("LABEL")
  p3 = 1                ' p3 = printer to be used (1=HPIII_QC; 2=GEN_EPSN etc)
  p4 = 2                ' p4 = printer port to use (1,2 etc - network set to use 2=LASER; 3=LABEL)
  p5 = 1                ' p5 = choose VIEW/PRINT 1=PRINT; 2=VIEW; 3=CHOOSE
  p6 = 1                ' p6 = nr of copies

  SelectDates()

  progress(15,10," Preparing data for Sales Summary ",1)

  x = Sales()

  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  file unload all

END MAIN


FUNCTION SelectDates()
local mth ld

  while true
    x = fentrybox(" Enter Start Date for Sales Summary ",10,"##\/##\/####",strt_date)
    if x = 0
      strt_date = ptstr
      if chkdate(strt_date,1) = -1
        messbox(" Incorrect date - re-enter ",0,0,1)
        continue while
      end if
    end if
    exit while
  end while

  while true
    x = fentrybox(" Enter End Date for Sales Summary ",10,"##\/##\/####",end_date)
    if x = 0
      end_date = ptstr
      if chkdate(end_date,1) = -1
        messbox(" Incorrect date - re-enter ",0,0,1)
        continue while
      end if
    end if
    exit while
  end while

END FUNCTION ' SelectDate()


FUNCTION Sales()
local q
  progtag(fgi,bgi," Selecting Sales Orders ")
  vloadif(dpath|"cust_ord.vws")
'   from_date = date2(filemax([Posted])+1)
'   from_date = @if(days(from_date)>=days(rel_date),rel_date,from_date)
  data query execute "sal_summ.dfq" index "z.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   days([Date_Of_Order]) <= days(end_date) and
'   days([Date_Of_Order]) >= days(strt_date)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    return(0)
  end if

  data query execute "zerorate.dfq" index "zerorate.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [Invoice_Total] = [Net_Invoice]
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messboxwait(" No ZERO rated Sales in period from"&date2(strt_date)&"to"&date2(end_date)|"ÿ",0,1,1)
  end if
inchar
'print list
  PrintReport(p1,p2,p3,p4,p5,p6)

END FUNCTION ' Sales()

