'CHK_AREA - show which stock carpets exceed an area inputted by Shop

external   fentrybox() dpath cpath vloadif() vunloadif() remove() Background()
external   fgp bgp sch scw
'  scr navrecs() popuplist() entryline()
external   bpopdb() messbox() messboxwait() WC() messline() psa fgi bgi

public     ptstr ptval dsa #areareqd

' global     oldlimit newlimit x abbrv_name ChangeLimit() $chg $profile idxname
' global     BrowseCustomers() SelectProfile() NewProfile() SetupScreens() po1 po2 po3
' global     po4 po5 PermitCollections() Collections() ChkDeleted() vkeybox()

global     x LoadScreens()


MAIN
  file unload all
  single-step off
'enter area req'd
  Background()
  while true
    x = fentrybox(" Enter Total area of carpet required ",5,"","")
    if ptstr = ""
'     continue while
    end if
    #areareqd = value(ptstr)           'message "#areareqd is:"&str(#areareqd)
    vloadif(dpath|"chkarea1.vw")
    remove(dpath|"$chkarea.*")
    data query execute "chkarea1" Smart4 dpath|"$chkarea" fields "[Product_Code;CodeDesc;ProdDesc;Balance;Width;CCW_Code;RollNr;Area]"
'     data query execute "chkarea1.dfq" index "chkarea1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' [Item_Type]="C"
' and
' [Balance]>0
' and
' not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if cerror
      messboxwait(" Printing SAT note for ",0,0,1)
      exit while
    end if
    remove(dpath|"chk_area.*")
    data cross-tab execute "chkarea1.dfw" Smart4 dpath|"chk_area"
    order sort now dictionary "cd" fields "[_Area_]" ascending
    data query execute "chkarea2.dfq" index "chkarea2.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' [F0003]>#areareqd
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if cerror
      messboxwait(" Insufficient carpet in stock for this query ",0,0,1)
      exit while
    end if

repaint on
repaint
single-step on
'     LoadScreens()
  end while
  screen clear box 1 1 sch scw 0 0 no-border
  file unload all
  transfer cpath|"pm_menu.psl" in-memory
END MAIN


FUNCTION LoadScreens()
  error off
  window split horizontal 10
  data goto window 2
  vloadif(dpath|"UAR_B_J.vw")
  if cerror
    return (-3)
  end if
  data goto window 2
  vloadif(dpath|"rolmetDJ.vw")
  if cerror
    return (-3)
  end if
  data goto window 1
  window split horizontal 20
  data goto window 3
  vloadif(dpath|"UAR_DESC.vw")
  data goto window 2
  error off
  window link "[Product_Code]" "UAR_DESC.vw" "[Product_Code]"
  data goto window 1
END FUNCTION ' LoadScreens()

' window split horizontal 8
' data query execute "chkarea1" data-file "$chkarea" fields "[Product_Code;CodeDesc;ProdDesc;Balance;Width;CCW_Code;RollNr;Area]"
' window split horizontal 7
' data goto window 2
' data goto view "$chkarea.vws"
' data goto window 1
' window link "[chkarea1]" "$chkarea.vws" "[ProdDesc]"
' data goto window 2
' order key add "[CodeDesc]"
' data goto window 1
' window link "[chkarea1]" "$chkarea.vws" "[CodeDesc]"
