'A_ORDSTA - view archive order details

external   fentrybox() messbox() vloadif() vunloadif() dpath scr shopmask
external   sch scw progress() fgp bgp messline() wraptext() popuplist() nr6
external   userid menuchoice cpath entryline() navrecs() messboxwait()
external   remove() makeidx() Background() posncolpopup() colpoplines()
external   chkstr() strcount() fm_busdate() colpopup() bpopdb()

public     invtot ptstr custcode dsa abbrv_name ptval jobnr $refnr psa a_jobnr
public     $dateftr $ftrcode

global     x i $dfa1 $ftrappts #ftrappts $fitter $day_1 ftrname $popstr df clb
global     ShowDeliveries() ReplaceHardSpace() ftrarray[1] ShowOrders() clf
global     Show1stCash() #1stbalance #1strecord Titles_1() $showdel $invoice
global     CheckNr() ShowAllReqs() S_details #count
global     ReturnToMenu() jobdesc ftgcomm ftginstr ftgscrn y z slotrec y1 y2 y3 y4
global     $ctgplan ftginit #lenareas #startc #startr
global     $instruct #upper #rem m1 m5 NavReqns() S_status
global     $delonly ftgplan ShowText() mess5 $ordstat EnterCustName() $invdate
global     custname navmess() bot psmode RecsScroll() NavMess_A() orddate
global     SetupDetails() GetCustDetails() ShowDetails() all NavMess_Arc()
global     custaddr1  custaddr2  custcity custpostcode deladdr1 deladdr2
global     deladdr3 deladdr4 cust_title custcontact offtel hometel $partaddr
global     offax mobile custaddr deladdr k CheckArcOrders() arc RecsScrollArc()
global     SearchAddress() ShowOrder() #prec CustScreenLine()
global     ReplaceCR() ShowFittings() varndes ShowReceipts() l #amount $invnr
global     $status ReplaceHardSpace2() ReqnLines() S_all
global     ShowComments()


MAIN
single-step off
  file unload all
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  error off
  bot = 7
  clb = 13
  clf = 10
  arc = 0
  $invoice = "N"

  while true
    window close
    if cerror
      exit while
    end if
  end while

  while true
    x = CheckNr()                          ' check Job Nr exists in CUST_ORD
    if x = -1
      exit while
    end if
  end while

  ReturnToMenu()

END MAIN


FUNCTION Titles_1()
local y1 y2 y3 y4 y5 y6 y7
  screen clear box 22 5 23 75 0 0 no-border
  y5 = format("Receipts - press any key to continue","M71")
  y6 = format("   Date     Amount  Method      Notes           Ent'd   Time  Posted","L71")
  screen print 9 5 fgp bgp y6
  screen print 22 5 fgp bgp y5
END FUNCTION ' Titles()


FUNCTION CheckNr()                     ' checks for JobNr - if not found
  while true
    z = 0
    arc = 0
    x = popuplist(9,30,13,"ÿCustomerÿName ÿÿÿÿÿJobÿNr Partialÿaddress","{Esc} to exit",1,0)
    if x = 0
      if ptstr = "ÿCustomerÿName"
        k=remove("all_req1.idx")
        x = EnterCustName(z)
        if x = -1
          continue while
        else
          vloadif(dpath|"a_ordst4.vw")
          order change key "[Job_Nr]"
          x = SetupDetails()
          if x = -1
            continue while
          end if
        end if

      elseif ptstr = "Partialÿaddress"
        k=remove("all_req1.idx")
'         vloadif(dpath|"a_ordst4.vw")
'         order change key "[Job_Nr]"
        x = fentrybox(" Enter partial address details or {Esc} to exit ",35,"","")
        if x = -1
          continue while
'           return (-1)
        elseif x = 0
          $partaddr = ptstr             '
' message "$partaddr is:"&str($partaddr)
          repaint off
          progress(15,10," Searching for `"|$partaddr|"' ",0)
          x = SearchAddress()
' message "x is:"&str(x)
          if x = 0
            vloadif(dpath|"a_ordst4.vw")
            order change key "[Job_Nr]"
            x = SetupDetails()
            if x = -1
              continue while
            end if
          end if
          Background()
          if x = -1
            continue while
          end if
        end if

      else
        k=remove("all_req1.idx")
        vloadif(dpath|"a_ordst4.vw")
        order change key "[Job_Nr]"
        x = fentrybox(" Enter Order Nr or {Esc} to exit ",6,shopmask,"")
        if x = -1
          continue while
'           return (-1)
        elseif x = 0
          jobnr = ptstr
          x = SetupDetails()
        end if
      end if

    elseif x = -1
      return (-1)
    end if
  end while
END FUNCTION ' CheckNr()


FUNCTION GetCustDetails()
'   $credit      = [Credit_Status]
'   $showdel     = [PDA]
  cust_title   = [Title]
  custaddr1    = [Address_1]
  custaddr2    = [Address_2]
  custcity     = [City/Town]
  custpostcode = [Postcode]
  deladdr1     = [Delivery_Address_1]
  deladdr2     = [Delivery_Address_2]
  deladdr3     = [Del_City]
  deladdr4     = [Del_Postcode]
  custcode     = [Customer_Code]
  custname     = [Customer_Name]
  custcontact  = [Contact_Name]
  offtel       = [Office_Tel]
  hometel      = [Home_Tel]
  offax        = [Office_Fax]
  mobile       = [Mobile/Other_Nr]
  $status = case [Credit_Status] ("A","Account") ("C","Cash only") ("D","Delayed") ("N","No deliveries!!")
END FUNCTION ' GetCustDetails()


FUNCTION ShowCustomer()
local c1 c2 c3 c4 d1 d2 d3 d4 cc1 cr1 cc2 cr2 dc1 dr1 dc2 dr2 pc1 pr1 pc2 pr2 \
      ordets p1 p2 p3 p4 p5 p6 p7 p8 df

'   screen save 1 1 sch scw S_all
'   clb = 13
'   clf = 10
  cr1 = 8
  cc1 = 2
  cr2 = cr1+5
  cc2 = cc1+37
  dr1 = cr1
  dc1 = 42
  dr2 = cr2
  dc2 = dc1+37
  pr1 = cr2+1
  pc1 = cc1+14
  pr2 = pr1+8
  pc2 = pc1+50
'   if $showdel = "Y"
    df  = clf
'   else
'     df  = 8
'   end if

'   screen clear box cr1 cc1 cr2 cc2 15 1
  screen clear box cr1 cc1 cr2 cc2 clf clb
  c1 = left(custaddr1|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  c2 = left(custaddr2|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  c3 = left(custcity|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  c4 = left(custpostcode|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  screen print cr1 cc1+1 clf clb "ÿCustomer addressÿ(Acc Nr"&custcode|")ÿ"
  screen print cr1+1 cc1+2 clf clb c1
  screen print cr1+2 cc1+2 clf clb c2
  screen print cr1+3 cc1+2 clf clb c3
  screen print cr1+4 cc1+2 clf clb c4
  screen save cr1 cc1 cr2 cc2 custaddr
'
  screen clear box dr1 dc1 dr2 dc2 df clb
'   screen clear box dr1 dc1 dr2 dc2 clf clb
  d1 = left(deladdr1|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  d2 = left(deladdr2|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  d3 = left(deladdr3|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  d4 = left(deladdr4|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  screen print dr1 dc1+1 df clb "ÿDelivery addressÿ"
  screen print dr1+1 dc1+2 df clb d1
  screen print dr1+2 dc1+2 df clb d2
  screen print dr1+3 dc1+2 df clb d3
  screen print dr1+4 dc1+2 df clb d4
  screen save dr1 dc1 dr2 dc2 deladdr
'   if $showdel = "N"
'     screen print dr2 dc1+1 df clb "ÿNot to be shown on invoiceÿ"
'   end if
  screen save dr1 dc1 dr2 dc2 deladdr

  screen clear box pr1 pc1 pr2 pc2 clf clb
  p1 = format("Title:  ÿ   "|left(cust_title|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p2 = format("Name:     ÿ "|left(custname|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p3 = format("Contact:   ÿ"|left(custcontact|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p4 = format("Office tel:ÿ"|left(offtel|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p5 = format("Home tel:  ÿ"|left(hometel|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p6 = format("Fax nr:ÿÿ  ÿ"|left(offax|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p7 = format("Mobile nr: ÿ"|left(mobile|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p8 = " press any key to continue ... "
'   screen print pr1 pc1+1 clf clb "ÿSundry detailsÿ"
  screen print pr1 pc1+1 clf clb "ÿACCOUNT STATUS:"&$status|"ÿ"
'   screen print pr1 dc1+1 df clb $status
  screen print pr1+1 pc1+2 clf clb p1
  screen print pr1+2 pc1+2 clf clb p2
  screen print pr1+3 pc1+2 clf clb p3
  screen print pr1+4 pc1+2 clf clb p4
  screen print pr1+5 pc1+2 clf clb p5
  screen print pr1+6 pc1+2 clf clb p6
  screen print pr1+7 pc1+2 clf clb p7
  screen print pr1+8 pc1+19 clf clb p8
'   screen print dr2 dc1+1 df clb "ÿNot to be shown on invoiceÿ"
  inchar
'   repaint off
END FUNCTION ' ShowCustomer()


FUNCTION ShowFittings2()
local $ftgstr $fname d
  $ftgstr = ""
  repaint off
  vloadif(dpath|"ftr_list.vws")
  vloadif(dpath|"appntmnt.vws")
  order change physical
  data query execute "job_reqn.dfq" index "job_reqn.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ QUERY is:  [Job_Nr] = jobnr and not (deleted)                      ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No appointments for this job ",0,0,1)
    return (1)
  end if
  $dfa1 = ""
  $ftrappts = ""

'--------------------------------------search to remove duplicate days
  if records > 1
    data goto record first
    for i = 1 to records
      $dfa1 = left([DFA],11)
      x = chkstr($dfa1,$ftrappts)
      if x = -1
        $ftrappts = $ftrappts&$dfa1
      end if
      data goto record next
    end for
    x=strcount($ftrappts)                'message "x is:"&str(x)
    #ftrappts = ptval                    '
  else
    $ftrappts = left([DFA],11)
    #ftrappts = 1                   '
  end if
  redimension ftrarray[#ftrappts]
  for i = 1 to #ftrappts
'     x = fm_busdate(left(group($ftrappts,i),5))   'message "x) is:"&str(x)
'     $day_1 = ptstr                     '
    d = days(left(group($ftrappts,i),5))
    $day_1 = left(date2([Date]),6)|right(date2([Date]),2)
message "$day_1 is:"&str($day_1)
    $fitter = right(group($ftrappts,i),6) 'message "$fitter) is:"&str($fitter)
    $fname = filelookup([FTR_LIST.Fitter_Code],[FTR_LIST.Nickname],$fitter)
    ftrname = ReplaceHardSpace2($fname,len($fname))
    $ftgstr = $ftgstr&$day_1|"ÿ"|left(ftrname|"ÿÿÿÿÿÿÿÿ",8)     ' HARD space
    ftrarray[i] = $fitter
  end for

  while true
    x = posncolpopup(5,10,20,$ftgstr,"",1,0,clf,clb,0,7,0)  'highlight date & press {Enter} to show deliveries
    $dateftr = ptstr
    if x = -1
      repaint off
      exit while
    end if
    screen shortrestore dsa
    $ftrcode = ftrarray[ptval]
    ShowDeliveries()
  end while

  vunloadif("appntmnt.vws")
  vunloadif("delivr_1.vw")
  vunloadif("ftr_list.vws")

END FUNCTION ' ShowFittings2()


FUNCTION ShowDeliveries()
  progress(15,10," Please wait ... finding deliveries ",0)
  fgp = clf
  bgp = clb
  repaint off
  vloadif(dpath|"delivr_1.vw")
  order change key "[Job_Nr]"
  data query execute "job_reqn.dfq" index "sd1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [Job_Nr] = jobnr
'   and
'   not(deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    screen shortrestore psa
    messboxwait(" NO deliveries booked ",0,0,1)
    fgp = fgpleasing
    bgp = bgpleasing
    return (1)
  end if
  data query execute "showdel1.dfq" index "sd2.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [Date_Out] = date2(left($dateftr,8))
'   and
'   [Fitter_Code]=$ftrcode
'   and
'   not(deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    screen shortrestore psa
    messboxwait(" NO deliveries booked ",0,0,1)
    fgp = fgpleasing
    bgp = bgpleasing
    return (1)
  end if
  screen shortrestore psa

  x = bpopdb("delivr_1",6,"","[ScrollView]","L45","[FtrCode]","L6","[Job_Nr]",5,31,20,78,"",0)
  fgp = fgpleasing
  bgp = bgpleasing
END FUNCTION ' ShowDeliveries()


FUNCTION ShowOrders()
local $ordstr
  $ordstr = ""
  repaint off
  vloadif(dpath|"variat_n.vws")
  order change physical
  data query execute "job_reqn.dfq" index "job_reqn.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ QUERY is:  [Job_Nr] = jobnr and not (deleted)                      ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" Job Nr not found ",0,0,1)
    return (1)
  end if
  for i = 1 to records
    #amount=right("ÿÿÿÿÿÿÿÿÿÿ"|currency([Amount_Gross]),10)
    varndes = ReplaceHardSpace2(date2([Date])&format([Reason],"L50")&#amount,70)
    $ordstr = $ordstr&varndes          'message "$popstr is:"&str($popstr)
    data goto record next
  end for
  vunloadif("variat_n.vws")
  while true
    x = colpoplines(10,5,23,$ordstr,"",1,0,clf,clb,14,3)  'highlight date & press {Enter} to show deliveries
    if x = -1
      exit while
    end if
    screen shortrestore dsa
  end while
END FUNCTION ' ShowOrders()


FUNCTION ShowReceipts()
local rcptdes $rcpstr
  $rcpstr = ""
  repaint off
  ptval=0
  vloadif(dpath|"A_rcpts.vw")
  order change key "[Job_Nr]"
  data query execute "vu_cash" index  "#1stcash.idx"
' ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
'   [Job_Nr] = jobnr
' ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ¼
  if cerror
    messbox(" No cash received for this order ",0,0,1)
    vunloadif("A_rcpts.vw")
    return (0)
  end if
  for i = 1 to records
    #amount=right("ÿÿÿÿÿÿÿÿÿÿÿÿ"|currency([Amount_Received]),12)
    rcptdes = ReplaceHardSpace(date2([Date_Of_Receipt])&format([Method_Of_Payment],"L6")&[Entered_By]&format([Authorisation],"L20")&#amount)
    $rcpstr = $rcpstr&rcptdes          'message "$popstr is:"&str($popstr)
    data goto record next
  end for
  vunloadif("A_rcpts.vw")
  x = colpoplines(10,5,20,$rcpstr,"",1,0,clf,clb,14,3)  'highlight date & press {Enter} to show deliveries
  screen shortrestore dsa
  inchar
END FUNCTION ' ShowReceipts()


FUNCTION NavReqns()
local x psmode pd pq
  ReqnLines()
  screen save scrheight 1 scrheight scrwidth bot
  smartpeek $_spndmes psmode
  if psmode = 1
    smartpoke $_spndmes 0
  end if

  NavMess()
  while TRUE
    x = inchar
    if x = {Down}
      data goto record next
      NavMess()

    elseif x = {Up}
      data goto record previous
      NavMess()

    elseif x = {PgDn}
      data goto page next
      NavMess()

    elseif x = {PgUp}
      data goto page previous
      NavMess()

    elseif x = {^End}
      data goto record last
      NavMess()

    elseif x = {^Home}
      data goto record first
      NavMess()

    else
      exit while
    end if
  end while
  if psmode = 1
    smartpoke $_spndmes 1
  end if
  return (x)
END FUNCTION   'Navreqns()


FUNCTION NavMess()
local col1 pd pq pr psc psn psr psp y2a pq1
'   if [Item_Type] = "B" or [Item_Type]="W" or [Item_Type]="J" or [Item_Type]="T" or [Item_Type]="O"
'     pr = [Date_Allocated]              'message "pr is:"&date2(pr)
'     $refnr = [Reference_Nr]            'message "$refnr is:"&str($refnr)
'     error off
'     while true
'       pd = filelookup([purchord.Order_Nr],[purchord.Date_Ordered],$refnr)
'       if cerror
'         col1 = 12
'         y2 = format("Order not held in Purchase Order file ","M78")
'         y2a = format(" ","M78")   'message "len(y2)) is:"&str(len(y2))
'         exit while
'       else
'         pq  = filelookup([purchord.Order_Nr],[purchord.Delivery_Quoted],$refnr)
'         pq1 = @if(pq=null,"N/Q",pq)    'message "pq1 is:"&str(pq1)
'         psc = filelookup([purchord.Order_Nr],[purchord.Supplier_Code],$refnr)
'         psr = filelookup([purchord.Order_Nr],[purchord.Order_Reference],$refnr)
'         psn = filelookup([supplier.Supplier_Code],[supplier.Name],psc)
'         psp = filelookup([supplier.Supplier_Code],[supplier.Telephone],psc)
'         col1 = 1
'         if value(pr)=0
'           y2 = format("Ordered on"&date2(pd)&"- for delivery:"&pq1,"M78")
'           y2a = format(left("(from:"&psn&"(ref:"|psr|")-"&psp|")",78),"M78")   'message "len(y2)) is:"&str(len(y2))
'         else
'           y2 = format(left("Order received on"&date2(pr)|"ÿ",71),"M78")
'           y2a = format(left("(from:"&psn&"(ref:"|psr|")-"&psp|")",78),"M78")   'message "len(y2)) is:"&str(len(y2))
'         end if
'       end if
'       exit while
'     end while
'     screen print 22 2 15 col1 y2
'     screen print 23 2 15 col1 y2a
'   else
'     col1 = 1
'     y2 = format("ÿ","M78")
'     y2a = format("ÿ","M78")
'     screen print 22 2 15 col1 y2
'     screen print 23 2 15 col1 y2a
'   end if
END FUNCTION   'NavMess()


FUNCTION ReqnLines()
  y3 = format("ÿ"|chr(24)&chr(25)&"req'ns ("|str(#count)|")   {Esc} when finished ","M78")
  screen print 9 2 15 1 y3
END FUNCTION ' ReqnLines()


FUNCTION SetupDetails()
local $chstr
  data find "[Job_Nr]" equal jobnr options "gw"
  if cerror                               '   if none - then return
    messbox(" Job not found ",1,0,0)
    return (-1)
  else
    jobdesc  = [Description]
    ftginstr = [Instructions]
    ftgcomm  = [Fitting_Comment]
    jobdesc  = @if(len(jobdesc)=0,"Not known",jobdesc)
    ftginstr = @if(len(ftginstr)=0,"Not known",ftginstr)
    ftgcomm  = @if(len(ftgcomm)=0,"Not known",ftgcomm)
    slotrec  = [Appt_Slots]
    $ordstat = [Order_Status]
'     $invoice = [Completed]
'     $invnr   = [Inv_Nr]
'     $invdate = [Invoice_Date]
  end if
  repaint on
  repaint
  screen save 1 1 6 scw S_all
  repaint off
  vunloadif("a_ordst4.vw")
  $chstr = "Customer Fittings Instructions Orders Requisitions Receipts"
  while true
    screen shortrestore S_all
    x = colpopup(8,31,20,$chstr,"{Esc} to exit",1,0,clf,clb,0,7)  'highlight date & press {Enter} to show deliveries
    if x = -1
      Background()
      return (-1)
    end if

    if ptstr = "Instructions"
      ShowComments()                ' {I}nstructions
      screen shortrestore S_all
'       inchar

    elseif ptstr = "Receipts"
      #1stbalance = 0
      ShowReceipts()
      screen shortrestore S_all

    elseif ptstr = "Customer"
      repaint off
      vloadif(dpath|"a_ordst4.vw")
      order change key "[Job_Nr]"
      data find "[Job_Nr]" equal jobnr options ""
      GetCustDetails()
      vunloadif("a_ordst4.vw")
      ShowCustomer()
      screen shortrestore S_all

    elseif ptstr = "Fittings"
      x = ShowFittings2()
      screen shortrestore S_all

    elseif ptstr = "Orders"
      x = ShowOrders()
'       inchar
      screen shortrestore S_all

    elseif ptstr = "Requisitions"
      x = ShowAllReqs()

    end if
  end while

END FUNCTION ' SetupDetails()


FUNCTION ShowText()
  x=wraptext(9,14,13,66,15,1,jobdesc,"L",1,0,0)  '   message "x is:"&str(x)
  mess5 = "Job details"|@if(slotrec=0,""," - (timeslots"&str(slotrec)|")")
  screen print  9 16 15 1 mess5

  x = wraptext(14,14,17,66,15,1,ftginstr,"L",1,0,0)
  screen print 14 16 15 1 "Other comments (eg appointment times etc)"

  x = wraptext(18,14,21,66,15,1,ftgcomm,"L",1,0,0)
  screen print 18 16 15 1 "Comments re Fitting"
END FUNCTION ' ShowText()


FUNCTION ReturnToMenu()
  file unload all
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  transfer cpath|"pm_menu.psl" in-memory
END FUNCTION ' ReturnToMenu()


FUNCTION ReplaceCR(str1)
local j r m bw l_last #addn l
  m = ""
  for j = 1 to len(str1)
    r = mid(str1,j,1)
    if r = "~"
      r = ""                          ' replace soft space
    end if
    m = m|r
  end for
  return (m)
END FUNCTION ' ReplaceCR()


FUNCTION RecsScroll()
local x bot psmode
  screen save scrheight 1 scrheight scrwidth bot
  smartpeek $_spndmes psmode
  if psmode = 1
    smartpoke $_spndmes 0
  end if
  while TRUE
    NavMess_A()
    x = inchar
    if x = {Down}
      data goto record next
      NavMess_A()

    elseif x = {Up}
      data goto record previous
      NavMess_A()

    elseif x = {PgDn}
      data goto page next
      NavMess_A()

    elseif x = {PgUp}
      data goto page previous
      NavMess_A()

    elseif x = {^End}
      data goto record last
      NavMess_A()

    elseif x = {^Home}
      data goto record first
      NavMess_A()

    elseif x = {Home}
      suspendone
      keys Home,F8
      screen shortrestore bot
      NavMess_A()

    elseif x = {End}
      suspendone
      keys End,F8
      screen shortrestore bot
      NavMess_A()

    else
      exit while
    end if
  end while
  if psmode = 1
    smartpoke $_spndmes 1
  end if
  return (x)
END FUNCTION ' RecsScroll()


FUNCTION NavMess_A()
local ftgdate ordstat mess1 col1 mess2
  col1 = 12
  ftgdate = [Fitting_Date]             'message "ftgdate) is:"&date2(ftgdate)
  ordstat = [Order_Status]             ' message "ordstat) is:"&str(ordstat)
  jobnr   = [Job_Nr]                   ' message "jobnr) is:"&str(jobnr)
  mess1   =  format("Job Nr"&[Job_Nr]&"- Ftg Date:"&format(@if([Fitting_Date]=blank,"NONE!",date2([Fitting_Date])),"L8")&"- Status:"&[$case],"M71")
  if [Invoice_Total] < 0
    mess2 =  format("Credit note for:"&currency(abs([Invoice_Total]))&"- balance o/s:"&currency([Balance_Due]),"M71")
  else
    mess2 =  format("Order value:"&currency([Invoice_Total])&"- balance o/s:"&format(currency([Balance_Due]),"R8"),"M71")
  end if
  screen print 19 6 15 col1 mess1
  if arc = 0
    screen print 20 6 15 col1 mess2
  end if
END FUNCTION   'NavMess_A()


FUNCTION ShowDetails()
local c1 c2 c3 c4 d1 d2 d3 d4 cc1 cr1 cc2 cr2 dc1 dr1 dc2 dr2 pc1 pr1 pc2 pr2 \
      ordets p1 p2 p3 p4 p5 p6 p7 p8 clf clb df

  clb = 13
  clf = 10
  cr1 = 8
  cc1 = 2
  cr2 = cr1+5
  cc2 = cc1+37
  dr1 = cr1
  dc1 = 42
  dr2 = cr2
  dc2 = dc1+37
  pr1 = cr2+1
  pc1 = cc1+14
  pr2 = pr1+8
  pc2 = pc1+50
'   if $showdel = "Y"
    df  = clf
'   else
'     df  = 8
'   end if

'   screen clear box cr1 cc1 cr2 cc2 15 1
  screen clear box cr1 cc1 cr2 cc2 clf clb
  c1 = left(custaddr1|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  c2 = left(custaddr2|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  c3 = left(custcity|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  c4 = left(custpostcode|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  screen print cr1 cc1+1 clf clb "ÿCustomer's addressÿ"
  screen print cr1+1 cc1+2 clf clb c1
  screen print cr1+2 cc1+2 clf clb c2
  screen print cr1+3 cc1+2 clf clb c3
  screen print cr1+4 cc1+2 clf clb c4
  screen save cr1 cc1 cr2 cc2 custaddr
'
  screen clear box dr1 dc1 dr2 dc2 df clb
'   screen clear box dr1 dc1 dr2 dc2 clf clb
  d1 = left(deladdr1|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  d2 = left(deladdr2|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  d3 = left(deladdr3|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  d4 = left(deladdr4|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35)
  screen print dr1 dc1+1 df clb "ÿDelivery addressÿ"
  screen print dr1+1 dc1+2 df clb d1
  screen print dr1+2 dc1+2 df clb d2
  screen print dr1+3 dc1+2 df clb d3
  screen print dr1+4 dc1+2 df clb d4
  screen save dr1 dc1 dr2 dc2 deladdr
'   if $showdel = "N"
'     screen print dr2 dc1+1 df clb "ÿNot to be shown on invoiceÿ"
'   end if
  screen save dr1 dc1 dr2 dc2 deladdr

  screen clear box pr1 pc1 pr2 pc2 clf clb
  p1 = format("Title:  ÿ   "|left(cust_title|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p2 = format("Name:     ÿ "|left(custname|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p3 = format("Contact:   ÿ"|left(custcontact|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p4 = format("Office tel:ÿ"|left(offtel|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p5 = format("Home tel:  ÿ"|left(hometel|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p6 = format("Fax nr:ÿÿ  ÿ"|left(offax|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p7 = format("Mobile nr: ÿ"|left(mobile|"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",35),"L47")
  p8 = " press any key to continue ... "
  screen print pr1 pc1+1 clf clb "ÿACCOUNT STATUS:"&$status|"ÿ"
  screen print pr1+1 pc1+2 clf clb p1
  screen print pr1+2 pc1+2 clf clb p2
  screen print pr1+3 pc1+2 clf clb p3
  screen print pr1+4 pc1+2 clf clb p4
  screen print pr1+5 pc1+2 clf clb p5
  screen print pr1+6 pc1+2 clf clb p6
  screen print pr1+7 pc1+2 clf clb p7
  screen print pr1+8 pc1+19 clf clb p8
  inchar
  repaint off
END FUNCTION ' ShowDetails()


FUNCTION CheckArcOrders()
  while true
    repaint on
    repaint
    ptval=0
    y4 = format(" ****************************************************","M71")
    y3 = format(" *****************  ARCHIVED  ORDERS  ***************","M71")
    y1 = format(" Name                                Delivery Address","L71")
    y2 = format(" {Enter} selects - {Esc} exits ","M71")
    screen print 1 6 fgp 13 y4
    screen print 2 6 fgp 13 y3
    screen print 3 6 fgp 13 y4
    screen print 4 6 fgp bgp y1
    screen print 18 6 fgp bgp y2
    screen print 20 6 fgp 13 y4
    screen print 21 6 fgp 13 y3
'     screen print 22 6 fgp 13 y4

    while true
      ptval = RecsScrollArc()

      if ptval = {Enter}
        repaint off
        jobnr = [Job_Nr]
        arc   = 1
        return (0)

      elseif ptval = {Esc}
        screen clear box 1 1 sch scw 0 0 no-border
        repaint off
        return (-1)
      end if
    end while
  end while
END FUNCTION ' CheckArcOrders()


FUNCTION EnterCustName(z)
  while true
    if z = 0
      while true
        x = fentrybox(" Enter first 7 letters of Name (inc. capitals) - {Esc} ",7,"","")
        if x = 0
          if len(ptstr)=0
            continue while
          end if
          exit while
        elseif x = -1
          return (-1)
        end if
      end while
      abbrv_name = ptstr
      vloadif(dpath|"a_ordst2.vw")
      order change key "[Abbrv_Name]"
      data find "[Abbrv_Name]" equal abbrv_name options ""
      if cerror
        messbox(" Name"&chr(34)|abbrv_name|chr(34)|" not in archive file - re-enter? (y/n) ",1,1,1)
        if ptstr == "n"
          return (-1)
        else
          continue while
        end if
      else
        arc = 1
        x = CheckArcOrders()
        if x = -1
          return (-1)
        else
          return (0)
        end if
      end if
    end if
  end while
END FUNCTION 'EnterCustName()


FUNCTION RecsScrollArc()
local x bot psmode
  screen save scrheight 1 scrheight scrwidth bot
  smartpeek $_spndmes psmode
  if psmode = 1
    smartpoke $_spndmes 0
  end if
  while TRUE
    NavMess_Arc()
    x = inchar
    if x = {Down}
      data goto record next
      NavMess_Arc()

    elseif x = {Up}
      data goto record previous
      NavMess_Arc()

    elseif x = {PgDn}
      data goto page next
      NavMess_Arc()

    elseif x = {PgUp}
      data goto page previous
      NavMess_Arc()

    elseif x = {^End}
      data goto record last
      NavMess_Arc()

    elseif x = {^Home}
      data goto record first
      NavMess_Arc()

    elseif x = {Home}
      suspendone
      keys Home,F8
      screen shortrestore bot
      NavMess_Arc()

    elseif x = {End}
      suspendone
      keys End,F8
      screen shortrestore bot
      NavMess_Arc()

    else
      exit while
    end if
  end while
  if psmode = 1
    smartpoke $_spndmes 1
  end if
  return (x)
END FUNCTION ' RecsScrollArc()


FUNCTION NavMess_Arc()
local ftgdate ordstat mess1 col1 mess2
  col1 = 12
  orddate = [Date_Of_Order]
  ftgdate = [Fitting_Date]             'message "ftgdate) is:"&date2(ftgdate)
  ordstat = [Order_Status]             ' message "ordstat) is:"&str(ordstat)
  jobnr   = [Job_Nr]                   ' message "jobnr) is:"&str(jobnr)
  mess1   =  format("Job Nr"&[Job_Nr]&"- Ftg Date:"&format(@if([Fitting_Date]=blank,"NONE!",date2([Fitting_Date])),"L8")&"- Status:"&[$case],"M71")
  if [Invoice_Total] < 0
    mess2 =  format("Order date:"&date2(orddate)&"Credit note for:"&currency(abs([Invoice_Total])),"M71")
  else
    mess2 =  format("Order date:"&date2(orddate)&"-"&"Order value:"&format(currency([Invoice_Total]),"R8"),"M71")
  end if
  screen print 19 6 15 col1 mess1
  if arc = 0
    screen print 20 6 15 col1 mess2
  end if
END FUNCTION   'NavMess_A()


FUNCTION Show1stCash()
local $puar
  ptval=0
  repaint off
  vloadif(dpath|"os_rcpts.vw")
  order change key "[Job_Nr]"
  data query execute "vu_cash" index  "#1stcash.idx"
' ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
'   [Job_Nr] = jobnr
' ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ¼
  if cerror
    messbox(" No cash received for this order ",0,0,1)
    return (-1)
  end if
  repaint on
  repaint
  screen shortrestore S_details
  Titles_1()
  inchar
  return (-1)
END FUNCTION ' Show1stCash()


FUNCTION SearchAddress()
  vloadif(dpath|"A_ordst5.vw")
  data goto record first
  while true
    data find "[Delivery_Address_1]" partial $partaddr options "fi"
    if cerror
      data goto record first
      while true
' message "$partaddr is:"&str($partaddr)
        data find "[Delivery_Address_2]" partial $partaddr options "fi"
        if cerror
          messboxwait(" `"|$partaddr|"' not found in Customer Order's file ",0,0,1)
          Background()
          return (1)
        else
          #prec = precord
          x = ShowOrder()              'message "x is:"&str(x)
          if x = 0
            return (0)     ' correct found & SEEN!
          end if
        end if
      end while
    else
      #prec = precord
      x = ShowOrder()                  'message "x is:"&str(x)
      if x = 0
        return (0)     ' correct found & SEEN!
      elseif x = -1
        return (-1)     '
      end if
    end if
  end while
END FUNCTION ' SearchAddress()


FUNCTION ShowOrder()
  vloadif(dpath|"a_ordst4.vw")
' message "#prec) is:"&str(#prec)
  data goto record record-number #prec
  repaint on
  repaint
  x = messbox(" Is this the order? (y/n) ",1,1,0)
  if x = -1
    return (-1)
  else
    if ptstr == "y"
      repaint off
      jobnr    = [Job_Nr]
      jobdesc  = [Description]
      ftginstr = [Instructions]
      ftgcomm  = [Fitting_Comment]
      jobdesc  = @if(len(jobdesc)=0,"Not known",jobdesc)
      ftginstr = @if(len(ftginstr)=0,"Not known",ftginstr)
      ftgcomm  = @if(len(ftgcomm)=0,"Not known",ftgcomm)
      slotrec  = [Appt_Slots]
      $ordstat = [Order_Status]
'       $invoice = [Completed]
'       $invdate = [Invoice_Date]
'       $invnr   = [Inv_Nr]
      repaint on
      repaint
      screen save 1 1 8 scw S_details
      repaint off
'       x = ShowAllReqs()
'       if x = -1
'         screen clear box 1 1 sch scw 0 0 no-border
'         repaint off
'         return (0)                 ' = exit
'       end if
    else
      repaint off
      progress(15,10," Searching for `"|$partaddr|"' ",0)
      vloadif(dpath|"A_ordst5.vw")
      data goto record next
      return (1)
    end if
  end if
END FUNCTION ' ShowOrder()


FUNCTION CustScreenLine()
  repaint on
  repaint
  ptval=0
  y1 = format(" Name                                Delivery Address","L71")
  y2 = format(" {A}rchived orders - {Enter} selects - {Esc} exits ","M71")
  screen print 4 6 fgp bgp y1
  screen print 18 6 fgp bgp y2
END FUNCTION ' CustScreenLine()


FUNCTION ShowFittings()
local d
  $popstr = ""
  repaint off
  vloadif(dpath|"ftr_list.vws")
  vloadif(dpath|"appntmnt.vws")
  order change physical
  data query execute "job_reqn.dfq" index "job_reqn.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ QUERY is:  [Job_Nr] = jobnr and not (deleted)                      ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No appointments for this job ",0,0,1)
    return (1)
  end if
  $dfa1 = ""
  $ftrappts = ""

'--------------------------------------search to remove duplicate days
  if records > 1
    data goto record first
    for i = 1 to records
      $dfa1 = left([DFA],11)
      x = chkstr($dfa1,$ftrappts)
      if x = -1
        $ftrappts = $ftrappts&$dfa1
      end if
      data goto record next
    end for
    x=strcount($ftrappts)                'message "x is:"&str(x)
    #ftrappts = ptval                    '
  else
    $ftrappts = left([DFA],11)
    #ftrappts = 1                   '
  end if
  redimension ftrarray[#ftrappts]
  for i = 1 to #ftrappts
    d = days(left(group($ftrappts,i),5))
    $day_1 = left(date2([Date]),6)|right(date2([Date]),2) 'message "$day_1 is:"&str($day_1)
    $fitter = right(group($ftrappts,i),6) 'message "$fitter) is:"&str($fitter)
'     $fname = filelookup([FTR_LIST.Fitter_Code],[FTR_LIST.Nickname],$fitter)
'     $fitter = right(group($ftrappts,i),6) 'message "$fitter) is:"&str($fitter)
    ftrname = ReplaceHardSpace(filelookup([FTR_LIST.Fitter_Code],[FTR_LIST.Nickname],$fitter))
    $popstr = $popstr&$day_1|"ÿ"|left(ftrname|"ÿÿÿÿÿÿÿÿ",8)     ' HARD space
    ftrarray[i] = $fitter
  end for

  while true
    x = posncolpopup(5,10,20,$popstr,"",1,0,12,13,0,7,0)  'highlight date & press {Enter} to show deliveries
    $dateftr = ptstr
    if x = -1
      repaint off
      exit while
    end if
    screen shortrestore dsa
    $ftrcode = ftrarray[ptval]
    ShowDeliveries()
  end while
  vloadif(dpath|"appntmnt.vws")
  order change physical
END FUNCTION ' ShowFittings()


FUNCTION ReplaceHardSpace(str1)
local j r m bw l_last #addn
  m = ""
  for j = 1 to len(str1)
    r = mid(str1,j,1)
    if r = " "
      r = "ÿ"                          ' replace hard space
    end if
    m = m|r
  end for
  m = m|repeat("ÿ",#addn)
  return (m)
END FUNCTION ' ReplaceHardSpace()


FUNCTION ReplaceHardSpace2(str1,bw)
local j r m l_last #addn
  m = ""
  for j = 1 to len(str1)
    r = mid(str1,j,1)
    if r = " "
      r = "ÿ"                          ' replace hard space
    end if
    m = m|r
  end for

  if len(m) < bw
    #addn = bw-len(m)
  else
    #addn = mod(len(m),bw)
  end if
  m = m|repeat("ÿ",#addn)
  return (m)
END FUNCTION ' ReplaceHardSpace2()


FUNCTION ShowComments()
  x=wraptext(8,14,12,66,clf,clb,jobdesc,"L",1,0,0)  '   message "x is:"&str(x)
  mess5 = "Job details"|@if(slotrec=0,""," - (timeslots"&str(slotrec)|")")
  screen print  8 16 clf clb mess5
  x = wraptext(13,14,16,66,clf,clb,ftginstr,"L",1,0,0)
  screen print 13 16 clf clb "Other comments (eg appointment times etc)"
  x = wraptext(17,14,20,66,clf,clb,ftgcomm,"L",1,0,0)
  screen print 17 16 clf clb "Comments re Fitting"
  inchar
  screen clear box 7 1 sch scw 0 0 no-border
END FUNCTION ' ShowComments()


FUNCTION ShowAllReqs()
local y2 y1 y3 y4
  progress(15,10," Please wait ... finding requisitions ",0)
  repaint off
'   vloadif(dpath|"supplier.vws")
'   vloadif(dpath|"purchord.vws")
  vloadif(dpath|"A_allreq.vw")
  order change key "[Job_Nr]"
  data query execute "A_allreq.dfq" index "all_req1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ QUERY is:  [Job_Nr] = jobnr                                        ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    x = remove("all_reqn.idx")                ' create temp index for allocation
    x = makeidx("A_requsn","all_reqn.idx","0",1)
    if x = -1
      message "makeidx() failed"
    end if
    y4 = format("ÿNo requisitions entered for this job ","M71")
    screen print 10 5 15 12 y4
  else                               ' order by ListOrder & prodMRC
    order sort now dictionary "all_reqn.idx" fields "[Lst_Stck;Product_MRC]" ascending
    #count = records
    repaint on
    repaint
    screen shortrestore S_all
  end if
  ptval=0
  while true
    ptval = navreqns()
    if ptval = {Esc}
      repaint off
      vunloadif("A_allreq.vw")
      screen clear box 7 1 sch scw 0 0 no-border
      return (-1)
    end if
  end while
  repaint off
END FUNCTION ' ShowAllReqs()

