

FUNCTION SelectOrigin()
  while true
    x = popuplist(11,60,22,"˙˙˙˙˙˙˙˙ Recommendation Not˙known Other Advertisement Passing Exhibition","",1,0)
    $origin = case ptstr ("Recommendation","R")("Not˙known","N")("Other","O")("Advertisement","A")("Passing","P")("Exhibition","X")("Trade˙Contact","T")("˙˙˙˙˙˙˙˙","$")
    if $origin = "$"    ' HARD spaces
      continue while
    else
      exit while
    end if
  end while
END FUNCTION 'SelectOrigin()


FUNCTION PrintInterimOrder()
local $index $file scrn
  scrn=apinfo(ap_filex)         'message "Screen is:"&str(x)
  Background()
  vloadif(dpath|"intorder.vw")
  data goto record record-number recnr
  $index = "onlyone.idx"
  $file = "cust_ord"
  remove($index)
  x = makeidx($file,$index,str(precord),3)    '   message "x is:"&str(x)
  order change index $index
  p3 = 1                               '
  p1 = "INTORDER.dfr"   ' p1 = report definition ("ord_stck.dfr")
  PrintReport(p1,p2,p3,p4,p5,p6)
  vloadif(dpath|scrn)
END FUNCTION ' PrintInterimOrder()


FUNCTION NewJobNr()
local leftjob currec
  s1 = "Warehouse"
  s2 = "Trade"
  s3 = "Fulham"
  s4 = "Raynes"
  s5 = "Sheen"
  s7 = "Putney"

  if base="O"                         ' choice of Warehouse etc
    leftjob=Job_Locn()

  elseif base="F"
    while true
      x = popuplist(8,57,15,s3&S7&s2,"Order",1,0)
      if x = -1
        continue while
      end if
      $place = ptstr
      messbox(" Confirm"&upper($place)&"job? (y/n) ",1,1,1)
      if ptstr == "y"
        leftjob=left($place,1)
        exit while
      else
        continue while
      end if
    end while

'     messbox(" Confirm FULHAM job? (y/n) ",1,1,1)
'     if ptstr == "y"
'       leftjob = base
'     else
'       leftjob=Job_Locn()
'     end if

  elseif base="S"
    while true
      x = popuplist(8,57,15,s5&s4,"Order",1,0)
      if x = -1
        continue while
      end if
      $place = ptstr
      messbox(" Confirm"&upper($place)&"job? (y/n) ",1,1,1)
      if ptstr == "y"
        leftjob=left($place,1)
        exit while
      else
        continue while
      end if
    end while

'     messbox(" Confirm SHEEN job? (y/n) ",1,1,1)
'     if ptstr == "y"
'       leftjob = base
'     else
'       leftjob=Job_Locn()
'     end if

  else
    leftjob=Job_Locn()
  end if

  vloadif(dpath|"cust_ord.vws")
  data goto record last
  while true
    if left([Job_Nr],1)=leftjob
      lastjob=right([Job_Nr],5)
      jobnr=leftjob|right("00000"|str(value(lastjob)+1),5)
      currec=precord
      data find "[Job_Nr]" equal jobnr options "g"
      if cerror                               '   if none - then return
        exit while
      else
        data goto record record-number currec
        data goto record previous
      end if
    else
      data goto record previous
    end if
  end while
END FUNCTION 'NewJobNr()
