FUNCTION  OrderSheet()
local $index $file p1 p2 p3 p4 p5 p6
  p2 = "Confirmation"   ' p2 = title at top of choice popup ("LABEL")
  p3 = 1                ' p3 = printer to be used (1=HPIII_QC; 2=GEN_EPSN etc)
  p4 = 1                ' p4 = printer port to use (1,2 etc - network set to use 2=LASER; 3=LABEL)
  p5 = 1                ' p5 = choose VIEW/PRINT 1=PRINT; 2=VIEW; 3=CHOOSE
  p6 = 2                ' p6 = nr of copies


  Background()
  $index = "onlyone.idx"
  $file = "cust_ord"
  remove($index)
  x = makeidx($file,$index,str(precord),3)    '   message "x is:"&str(x)
  vloadif(dpath|"intordr1.vw")
  order change index $index
  if [ConfPrt]="Y"
    return (1)
  end if
  #due = [Balance_Due]                 '
  if #due > 0
    #due = "˙Balance due"&currency(#due)
  elseif #due = 0
    #due = "˙˙˙Order paid in full"
  end if
  #gross = [Invoice_Total]             '
  #receipts = "˙˙Payments received by"&date2(today)&"˙˙"&currency(tablesum([Amount_Received]))
  #net = #gross/((100+vatrate)/100)    'message "#net is:"&str(#net)
  #vat = #gross - #net                 'message "#vat is:"&str(#vat)
'   #net   = currency(#net)
'   #gross = currency(#gross)
'   #vat   = currency(#vat)
  #net   = "Net:"&currency(#net)
  #gross = "Total Order value:"&currency(#gross)
  #vat   = "VAT at 17.5%:"&currency(#vat)

'choose type of report

  x = popuplist(8,53,13,"Brief˙report Full˙details","",1,0)
  if ptstr = "Brief˙report"
    messboxwait(" Insert Logo'd paper for Order Confirmation ",0,1,1)
    while true
      p1 = "ord_conf.dfr"   ' p1 = report definition ("ord_stck.dfr")
      PrintReport(p1,p2,p3,p4,p5,p6)
      messbox(" Has Order Nr"&jobnr&"printed correctly? (y/n) ",1,1,1)
      if ptstr == "y"                      '  store file & exit
        lock-record                        ' update record with inv nr & date
          [ConfPrt]="Y"
        write-record
        return (0)
      else
        messbox(" Abandon and print later? (y/n) ",1,1,1)
        if ptstr == "y"                      '  store file & exit
          return (0)
        else
          continue while
        end if
      end if
    end while
  elseif ptstr = "Full˙details"
    vloadif(dpath|"intordr2.vw")
    order change index $index
    messboxwait(" Insert Logo'd paper for Order Confirmation ",0,1,1)
    while true
      p1 = "ordconf2.dfr"   ' p1 = report definition ("ord_stck.dfr")
      PrintReport(p1,p2,p3,p4,p5,p6)
      messbox(" Has Order Nr"&jobnr&"printed correctly? (y/n) ",1,1,1)
      if ptstr == "y"                      '  store file & exit
      lock-record                        ' update record with inv nr & date
        [ConfPrt]="Y"
      write-record
      return (0)
    else
      messbox(" Abandon and print later? (y/n) ",1,1,1)
      if ptstr == "y"                      '  store file & exit
        return (0)
      else
        continue while
      end if
    end if
  end while

  end if
END FUNCTION ' OrderSheet()
