'FRAN_DRS - Full list for franchises

external   dpath sch scw vloadif() vunloadif() messbox() base progress()
external   cpath vkeybox() PrintReport() navrecs() progtag() fgi bgi
external   fentrybox() chkdate() popuplist() $menu messboxwait() ChooseShop()

public     ptstr $shop value1 $report_date $shop_name $month_txt $response
public     $branch ptval jobnr dsa orderdate

global     per9 per8 per7 per0 per1 $stat i ftgdate x ReturnToMenu()
global     $check SelectDrs() p1 p2 p3 p4 p5 p6


MAIN
single-step off
  quiet on
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  p2 = ""   ' p2 = title at top of choice popup ("LABEL")
  p3 = 1    ' p3 = printer to be used (1=HPIII_QC; 2=GEN_EPSN etc)
  p4 = 1
  p5 = 1    ' p5 = choose VIEW/PRINT 1=PRINT; 2=VIEW; 3=CHOOSE
  p6 = 1    ' p6 = nr of copies

  messboxwait(" No longer used ",0,0,1) ' chooseshop to alter

  orderdate = today
  $report_date = date3(orderdate)

  x = ChooseShop()
  if x = -1
    ReturnToMenu()
  else
    SelectDrs()
  end if

  ReturnToMenu()

END MAIN


FUNCTION SelectDrs()

  $MONTH_TXT = " showing ALL debts on "
  value1 = 0
  vloadif(dpath|"frandrs1.vw")
  order change key "[Branch]"
  progress(15,10," Please wait ... looking for debtors ",0)
  data query execute "frandrs1.dfq" INDEX "first.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [Branch]=$shop
'   and
'   not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No outstanding debtors at"&$shop_name|" ",0,0,1)
    transfer cpath|"pm_menu.psl" in-memory
  end if

  data query execute "frandrs2.dfq" INDEX "second.idx"   ' choose o/s balances
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   (days(today) - days([Date_Of_Order])) >= value1
'   and
'   days([Date_Of_Order]) >0
'   and
'   [Balance_Due] > 0.009
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No outstanding debtors at"&$shop_name|" ",0,0,1)
    return (1)
  end if
  order sort now "aged_drs.idx" fields "[Date_Of_Order]" ascending
  $branch      = $shop_name
  screen clear box 1 1 sch scw 0 0 no-border
  PrintReport("fran_drs.dfr","Aged Debtors",p3,p4,p5,p6)
END FUNCTION ' SelectDrs()


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()


' FUNCTION ChooseShop()
'   case base
'     when "P"
'       $shop = "P"
'       $shop_name = "Putney"
'
'     otherwise
'       messboxwait(" Shop not recognised ",0,0,1)
'       return (-1)
'   end case
' END FUNCTION ' ChooseShop()

