FUNCTION Confirm_yn()     'Obtain reference & show confirmation box
  if upd_new = "NEW"
    #reqnrec = 0
  end if
  while true
    $unit = [Unit_Desc]
    $uos  = [Unit_Of_Sale]
    #area = #ordlength*#ordwidth
    if $uos = "U3"
      if $backing = "COMM"
        $mess3 = " Commission of "|fixed(#ordlength,2)|"? (y/n/Esc) "
      else
        if $itemtype = "F"
          $mess3 = prodMRC&"for "|fixed(#ordlength,2)|"? (y/n/Esc) "
        else
          $mess3 = prodMRC&"of "|fixed(#ordlength,2)|" from"&suppname|"? (y/n/Esc) "
        end if
      end if

    else
      $text1 = " Confirm "|fixed(#ordlength,2)&$unit&"(total area "|fixed(#area,2)|"sq m)? (y/n/Esc) "
      $text2 = " Confirm quantity "|fixed(#ordlength,2)|"? (y/n/Esc) "
      $text3 = " Confirm "|fixed(#ordlength,2)|"? (y/n/Esc) "

      $mess3 = case $itemtype ("B",$text1)("C",$text1)("V",$text1)("W",$text1)\
      ("A",$text2)("F",$text3)("J",$text2)("S",$text2)("T",$text2)("O",$text3) else $text1

    end if

    x = messline($mess3,1,1,0,21,5,72)
    if x = 0
      if ptstr == "n"
        screen clear box 22 5 22 77 0 0 no-border
        return (1)
      elseif ptstr == "y"
        screen clear box 22 5 22 77 0 0 no-border
        repaint off
        exit while
      end if
    elseif x = -1
      screen clear box 22 5 22 77 0 0 no-border
      return (-1)
    end if
  end while
  repaint off
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ Create Purchase order for bespoke & check prices                   ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if $itemtype = "B"
    x = EnterPurchord()           	' returns #unitcost
    if x = -1
      return (-1)
    end if

  elseif $itemtype = "J"
    x = EnterPurchord()           	' returns #unitcost
    if x = -1
      return (-1)
    end if

  elseif $itemtype = "T"
    x = EnterPurchord()           	' returns #unitcost
    if x = -1
      return (-1)
    end if

  elseif $itemtype = "W"
    x = EnterPurchord()           	' returns #unitcost
    if x = -1
      return (-1)
    end if

  elseif $itemtype = "O"
    #unitcost = 1
    if $backing = "OVER"
      x = EnterOverride()           	'
      if x = -1
        return (-1)
      end if
    elseif $backing = "COMM"
      x = EnterCommission()           	'
      if x = -1
        return (-1)
      end if
    end if
  else
'   ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   ³ Calculate which Price to use - (SMLR - disc) at date of order    ³
'   ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if days(custorderdate) < days($effecdate)
      #unitcost = round($prev_R*(1-($disc/100)),2)	' ROLL price used for all other prods
    else
      #unitcost = round($smlr*(1-($disc/100)),2)
    end if
  end if

' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³  Calculate req'n cost                                              ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if $uos = "U3"
    #reqncost = value(#ordlength)
  elseif $uos = "U1"
    #reqncost = value(#ordlength)*value(#unitcost)
  elseif $uos = "U2"
    #reqncost = value(#ordlength)*value(#ordwidth)*value(#unitcost)
  end if

  $auth = @if(priceauthority = blank,"None",priceauthority)
  if #reqnrec = 0
    CreateReqn()
  else
    vloadif(dpath|"cus_ent7.vw")
  ' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  ' ³ Assign revised figures to REQUSN & PURCHORD                        ³
  ' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
'     $ccw = prodcode&desMRC&"Y"&str(format(#ordwidth,"2r"))
    if $itemtype = "C"
      $rollnr = "00000/00"
    elseif $itemtype = "B"
      $rollnr = "BESPOK"
    else
      $rollnr = "NA"
    end if
' message "1725-prodcode is:"&str(prodcode)
    while true
      lock-record
        [Product_Code]       = prodcode
        [Product_MRC]        = prodMRC
        [Description_MRC]    = desMRC
        [Item_Type]          = $itemtype
        [Status]             = "I"
        [Length_Quantity]    = #ordlength
        [Date_Requisitioned] = today
        [Cost]               = fixed(#reqncost,2)
        [Comment]            = $auth
        [Width]              = #ordwidth
        [Created/Changed_By] = userid
        [CCW_Code]           = $ccwcode
        [RollNr]            = $rollnr
        [R_Backing]          = $backing
        [prodrec]            = #prodrec
      write-record
' repaint on
' repaint
' single-step on
      UpdGdsOut($rollnr,refcode)

      #prec = str(precord)

      vloadif(dpath|"requsn.vws")
      order change physical
      vloadif(dpath|"cus_ent4.vw")
      exit while
    end while
  end if
END FUNCTION ' Confirm_yn()


FUNCTION  Title_B()
local f1 f2 f3 y1 y2 y3
  y1 = format(" R E V I E W   S C R E E N ","M72")
  y2 = format(left(jobnr&"-"&custname&"@"&deladdr1,72),"M72")
  y3 = format("  Description                    Colour              Length Width Bckg","L72")
  repaint on
  repaint
  screen print 4 5 15 12   y1
  screen print 5 5 15 12   y2
  screen print 6 5 fdp bbd y3
  y2 = format("{R}eallocate - {U}pdate reqn - {D}elete reqn - {F10} finishes","M72")
  screen print 21 5 fgp bbd y2
END FUNCTION   'Title_B()
