'OLDPURCH - lists purchase orders for all goods rec'd in last 30 days
'                sorted by Supplier & Date

external   dpath vloadif() sch scw bpopdb() vunloadif() scr fgp bgp progress() messboxwait()

' public     ptstr ptval

global     ReturnToMenu() Titles() OldOrders() x

MAIN
  single-step off
'   quiet off
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off

messboxwait(" Program not currently in use ",0,0,1)


'   OldOrders()

  ReturnToMenu()                        ' unload screens

END MAIN

FUNCTION OldOrders()
    progress(fgp,bgp," Preparing file ... please wait ",0)
    vloadif(dpath|"oldpurch.vw")
'     order change key "[Product_Code]"
    data query execute "oldpurch.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ [Date_Received] > days((today)-90)                                 ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    order sort execute dictionary "oldpurch.dfs" index "oldpurch"
    Titles()
    x = bpopdb("oldpurch",8,"","[Date_Supplier]","L36","[Product_Quant]","L44","[Product_Code]",8,1,22,79,"",0)
' message "x is:"&str(x)
    screen clear box 1 1 sch scw 0 0 no-border
    repaint off
    vunloadif("os_purch.vw")
END FUNCTION ' ListOrders()

FUNCTION ReturnToMenu()
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  vunloadif("os_purch.vw")
  transfer "pm_menu.psl" in-memory
END FUNCTION

FUNCTION Titles()
local a2 a3
  a2 = format("  Rec'd   Supplier                       Description             Length Width","M79")
' rdered  Supplier                       Description             Length ord'd","M79")
  screen print 7 1 15 1 a2
'   screen print 8 24 15 1 (format("Reservations to be deleted","M35"))
'   screen print 25 24 15 1 (format(" Press {Esc} to return ","M35"))
END FUNCTION


