'NODEPSTS - Ad-hoc report to show Jobs to be fitted in next 3 days but
'           NO deposit received (ignores SAT & SUN)

external   dpath sch scw vloadif() vunloadif() messbox() base progress()
external   cpath vkeybox() PrintReport() navrecs() progtag() fgi bgi
external   fentrybox() chkdate() popuplist() ChooseBranch() $menu
external   messboxwait() Background()

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     ChooseShop() $check SelectOrders()
global     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)
  p5 = 1    ' p5 = choose VIEW/PRINT 1=PRINT; 2=VIEW; 3=CHOOSE
'   p5 = 3    ' p5 = choose VIEW/PRINT/FILE;  1=PRINT; 2=VIEW; 3=CHOOSE
  p6 = 1    ' p6 = nr of copies

  p4 = 1

  x = ChooseShop()
  if x = -1
  else
    SelectOrders()
  end if

  ReturnToMenu()

END MAIN


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()
  if $menu = "shop"              'message "base is:"&str(base)
    case base
      when "F"
        $SHOP = "F"
        $SHOP_NAME = "Fulham"
      when "P"
        $SHOP = "P"
        $SHOP_NAME = "Putney"
      when "R"
        $SHOP = "R"
        $SHOP_NAME = "Raynes"
      when "S"
        $SHOP = "S"
        $SHOP_NAME = "Sheen"
      when "T"
        $SHOP = "T"
        $SHOP_NAME = "Trade"
      when "W"
        $SHOP = "W"
        $SHOP_NAME = "Warehouse"
    end case
  else
    while true
      $shop_name = ChooseBranch(8,33,1)
      $shop      = upper(left($shop_name,1))
      if $shop_name = -1
        return (-1)
      end if
      screen shortrestore dsa
      vloadif(dpath|"cust_ord.vws")
      SelectOrders()
      screen clear box 1 1 sch scw 0 0 no-border
      repaint off
    end while
  end if
END FUNCTION ' ChooseShop()


FUNCTION SelectOrders()
  Background()
  $branch = $shop_name
  Background()
  vloadif(dpath|"cust_ord.vws")
'   order change key "[Job_Nr]"
  progress(15,10," Please wait ... looking for imminent fittings ",0)
'   order change key "[SalesAnalysis]"
  data query execute "nodepst1.dfq" INDEX "first.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' days([Invoice_Date])<=days(orderdate) and
' [SalesAnalysis]=$shop
' and not (deleted)
' and
' days([Invoice_Date]) > 0
' and
' abs([Balance_Due]) > 0.009
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messboxwait(" No outstanding debtors at"&$shop_name|" ",0,0,1)
  else
    order sort now "aged_drs" fields "[Invoice_Date]" ascending
    screen clear box 1 1 sch scw 0 0 no-border
    PrintReport("mr_drs1.dfr","Aged Debtors",p3,p4,p5,p6)
  end if

END FUNCTION ' SelectDrs()




