'FTRPAYDX - creates indices of records for PRN_FTRS.PF3

external  dpath cpath vloadif() bpopdb() vunloadif() Background() fentrybox()
external  chkdate() messbox() messboxwait() progress() popuplist() messline()
external  increment() userid PrintReport() ftrpaytpath progtag() fgi bgi

public    ptstr dsa ftgdate datecode ftrcode psa ptval $nickname

global    x ChooseFitter() ProcessFitter() i $ftrname


MAIN
single-step off
  Background()
  file unload all
  ftgdate = days(today) - 1
  if dayname(date2(today)) == "Monday"
    ftgdate = days(today) - 2
  end if
  x = ChooseFitter("a")
  file unload all
END MAIN


FUNCTION ChooseFitter(t)
  vloadif(dpath|"ftr_list.vws")
  order sort now dictionary "nickname" fields "[Fitter_Name]" ascending
  while record<=records
    progress(15,10," Creating completed fitting appt's index for ",1)
    ftrcode   = [Fitter_Code]
    $nickname = [Nickname]
    $ftrname  = [Fitter_Name]          ' message "$ftrname is:"&str($ftrname)
' message "ftrcode is:"&str(ftrcode)
    progtag(fgi,bgi,$ftrname)
    ProcessFitter()
    vloadif(dpath|"ftr_list.vws")
    data goto record next
  end while
END FUNCTION  ' ChooseFitter()


FUNCTION ProcessFitter() 'find all unprocessed records (ie. those without docref)
local recnr jobseq ord bl m1
  repaint off
  vloadif(dpath|"chkpayt1.vw")
  order change key "[FtrCode]"
  data query execute "dateout2.dfq" index "da2.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [FtrCode]=ftrcode
'   and
'   not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No records found for"&$ftrname,0,0,1)
    return (1)
  end if
  data query execute "dateout3.dfq" index "da3.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   left([Job_Nr],1)<>"P"
'   and
'   [Itemtype]="F"
'   and
'   not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No records found for"&$ftrname,0,0,1)
    return (1)
  end if
  data query execute "dateout4.dfq" index "da4.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ len([Document]) = 0
'   and not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No fittings to be checked for"&$ftrname,0,0,1)
    return (1)
  end if
  data query execute "dateout5.dfq" index ftrpaytpath|ftrcode|".idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ days([[Date_Out]) >= days(ftgdate)
'   and not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messboxwait(" No fitting records for"&date2(ftgdate),0,0,1)
    return (1)
  end if
  order change physical
END FUNCTION ' ProcessFitter()
