FUNCTION EnterDetails()
local  response prec# y
'   x = keybox("1Normal 1Cash˙Sales 1Zero˙rate","Enter type of Sale")
  x = keybox("1Normal 1Zero˙rate","Enter type of Sale")
  if x = -1
    return (-1)
  end if
  $saltype = ptstr
  r1 = 8
  r2 = r1+6
  c1 = 17
  c2 = c1+48
  cl1 = 14
  cl2 = 3

  $newstat = "A"
  $method = "Cheque"
  if $saltype == "n"
    #vat = vatrate
    $vat = "S"
  elseif $saltype == "z"
    $vat = "Z"
    #vat = 0
  end if
  x = EnterCustName()
  if x = -1
    return (1)
  end if
'   progress(15,10," Please wait ... checking Job Nr ",0)
  vloadif(dpath|"cust_ord.vws")
  order change key "[Job_Nr]"
  data find "[Job_Nr]" equal jobnr options ""
  if cerror                               '   if none - then return
  else
    messbox(" Job Nr"&jobnr&"already used, creating another ",0,1,1)
    while true
      lastjob=right(jobnr,5)
      jobnr=left(jobnr,1)|right("00000"|str(value(lastjob)+1),5) 'message "jobnr is:"&str(jobnr)
      data find "[Job_Nr]" equal jobnr options ""
      if cerror                               '   if none - then return
        exit while
      else
        continue while
      end if
    end while
  end if
  data enter lock
    [Job_Nr]             = jobnr
    [Branch]             = left(jobnr,1)
    [CustOrd_Name]       = custname
    [Delivery_Address_1] = deladdr1
    [Abbrv_Name]         = left(custname,7)
    [Date_Of_Order]      = today
    [VAT]                = $vat
    [Updated_By]         = userid
    [Last_Update]        = today
'     [Parent]             = $parent
  write-record
  recnr = precord
  EnterDetails2()

  vloadif(dpath|"cust_ord.vws")
  $type  = case left(jobnr,1)("C","S")("R","S")("S","S")("F","S")("P","F")("W","H")("T","H")("Y","H")
  $sales = case left(jobnr,1)("C","X")("R","R")("S","S")("F","F")("P","P")("W","W")("T","T")("Y","Y")
  if len(custname) = 0
    messboxwait(" Customer's name has been omitted - pls contact David @ HO ",0,0,1)
  end if
  if len(abbrv_name) = 0
    messboxwait(" Customer's abbrv'd name has been omitted - pls contact David @ HO ",0,0,1)
  end if
  #netinv = round(invtot*100/(100+#vat),2)

  data goto record record-number recnr
  lock-record
    [SalesAnalysis]      = $sales
    [Type_Branch]        = $type
    [Delivery_Address_1] = deladdr1
    [Invoice_Total]      = 0
    [Net_Invoice]        = 0
    [Balance_Due]        = 0
    [Customer_Code]      = custcode
    [Updated_By]         = userid
    [Last_Update]        = today
    [Order_Status]       = $newstat
    [PDA]                = "Y"
    [Origin]             = $origin
    [Completed]          = "N"
  write-record

  recnr = precord
  $status = "A"
  if $menu = "boss"
    $allreas = $reas1&$reas2&$reas3&$reas4&$reas5
  else
    $allreas = $reas1&$reas2&$reas3&$reas4
  end if
  while true
    x = popuplist(8,15,14,$allreas,"",1,0)
    if x = -1
      continue while
    elseif x = 0
      exit while
    end if
  end while
  if ptstr = $reas5
    while true
      x = entryline(" Variation description - the Customer reads this! ",50,"",$free,21,6,71)
      if x = -1
        return (-1)
      elseif x = 0
        if ptstr = ""
          continue while
        end if
        $reas = ptstr
        exit while
      end if
    end while
  else
    $reas = ptstr
  end if
  AddVarn(jobnr|"-00",invtot,$reas,"Original","Original",today)
  Background()
  messbox(" Print interim confirmation? (y/n) ",1,1,1)
  if ptstr == "y"
    PrintInterimOrder()
  end if
  AddToArray()
END FUNCTION 'EnterDetails()
