FUNCTION ChooseShop()
local leftjob currec
  s1 = "Warehouse"
  s2 = "Trade"
  s3 = "Fulham"
  s4 = "Raynes"
  s5 = "Sheen"
  s7 = "Putney"

  if $menu = "shop"              'message "base is:"&str(base)
    if base="F"
      $SHOP_NAME = PickShop(s3,s2)
      $shop = left($SHOP_NAME,1)

    elseif base="P"
      $shop = "P"
      $SHOP_NAME = "Putney"

    elseif base="S"
      $SHOP_NAME = PickShop(s5,s4)
      $shop = left($SHOP_NAME,1)

    elseif base="W"
      $shop = "W"
      $SHOP_NAME = "Warehouse"
    end if

  else
    $shop_name = ChooseBranch(8,33,1)
    $shop = upper(left($shop_name,1))  '
  end if
  vloadif(dpath|"ord_rep1.vw")
END FUNCTION ' ChooseShop()


FUNCTION Report()
  order change key "[Var_Nr]"
  progress(fgp,bgp," Creating report for"&$shop_name|" ... please wait ",0)
  data query execute "shops.dfq" INDEX "first.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³  left[Var_Nr,1]=$shop                                          ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No Sales this month at"&$shop_name|" ",0,0,1)
    return (1)
  end if
  data query execute "ord_rep.dfq" INDEX "second.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' º   right(date2([Date]),7) ! monthend                       º
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No Sales this month at"&$shop_name|" ",0,0,1)
    return (1)
  end if
  order sort execute "ord_rep.dfs" INDEX "sal_rep"
  screen clear box 1 1 sch scw 0 0 no-border
  p1 = "ord_rep1.dfr"
  PrintReport(p1,p2,p3,p4,p5,p6)
END FUNCTION 'Report()

FUNCTION PickShop(r1,r2)
  while true
    x = popuplist(8,57,15,r1&r2,"Order",1,0)
    if x = -1
      continue while
    end if
    $place=ptstr
    messbox(" Confirm"&upper($place)&"jobs? (y/n) ",1,1,1)
    if ptstr == "y"
      leftjob=left($place,1)
      return $place
    else
      continue while
    end if
   end while
END FUNCTION 'PickShop()
