'CPL_PREP - new process for Cutting & Parts Lists, Fitters' Lists, Loading Sheets etc

external   fentrybox() messbox() progress() vloadif() vunloadif() chkdate()
external   dpath vloadexcif() chg_dsc() sch scw cpath remove() jobnr fgp bgp
external   mess4() PrintReport() shopmask makeidx() bgs fgs popuplist() dsa
external   messboxwait() increment() cplpath chkstr() addidxrec() strcount()
external   Background() userid bpopdb() getidxrecs() X_path _SWIP_Crystal() Xreppath

public     ftgdate ptstr job_names[1] prod_code[1] ftr_codes[1] ptval
public     jobsperftr[1] $itemtype ftrname custname deladdr1
public     deladdr2 deladdr3 deladdr4 offtel hometel ftginstr ftgcomm $repnr
public     cr_status mobile balancedue $carptitle ftrcode $nickname
public     #origsize $rollnr $refnr #out docref #newbal prodcode

global     CheckFitDate() ChkGdsOut() x ReturnToMenu() #ftrs
global     nrjobs nrftrs PrintJobList() gdsinstck apptsconfd
global     anclinstck nrcodes tot_need tot_avail $continue $temp $jobnrs
global     p1 p2 p3 p4 p5 p6 $comment cplrep i #jobnrs #prec $permit
global     PrintJobSheet() FittersLists() PreparationLists() $ftrs
global     PrintJobs() datenumber sr er PrepLists()


MAIN
local l1 l2 l3 l4 l5 l6 l2a l7 l8
single-step off
  Background()
  file unload all
  $permit = "TBELDI"
'   $permit = "DCOOPR"
' message "Change printer ports"

  $continue = "Y"
  p2 = ""               ' 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)
  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 = 1                ' p6 = nr of copies

'--------------------------------------suggest day to prepare list for
  CheckFitDate()
  if x = -1
    ReturnToMenu()
  end if

'--------------------------------------check recvd or allocated - else print list
  x = ChkGdsOut()                    ' 1=Not all rec'd; 0=OK
  if x = 1
    if userid = $permit
      messbox(" Do you want to continue? (y/n) ",1,0,1)
      if ptstr == "n"
        ReturnToMenu()
      end if
    end if
  elseif x = 2
    ReturnToMenu()
  end if

'----------------------------list of all jobs going out
'   progress(15,10," Please wait .... finding records ",0)
  vloadif(dpath|"goodsout.vws")
  order change index "todays1.idx"  'look at Job_Nrs in GOODSOUT/todays1.idx and remove duplicates
  data goto record first
  $jobnrs = [Job_Nr]
  data goto record next
  for i = 2 to records                 'create text string of Job Nrs
    x = chkstr([Job_Nr],$jobnrs)
    if x = -1
      $jobnrs = $jobnrs&[Job_Nr]
    end if
    data goto record next
  end for

'create index of CUST_ORD by stepping thro' text string and using ADDIDXRECS
  x=strcount($jobnrs)                  ' message "x is:"&str(x)
  #jobnrs = ptval
  vloadif(dpath|"cust_ord.vws")
  order change key "[Job_Nr]"
  remove("jobs2fit.idx")
  x = makeidx("cust_ord","jobs2fit","0",3)     'message "x is:"&str(x)
  for i = 1 to #jobnrs
    jobnr = group($jobnrs,i)
    data find "[Job_Nr]" equal jobnr options ""
    x = addidxrec("jobs2fit.idx",precord,7)    'message "x is:"&str(x)
  end for
  vunloadif("cust_ord.vws")

  l1 = "Job’List"
  l2 = "Preparation’Lists"
  l2a = "Imminent’Jobs"
  l3 = "Fitters'’Worksheets"
  l8 = "Unprocessed’Goodsout"

  l4 = "Cutting’List"
  l5 = "Bespoke’Items"
  l6 = "Ancillaries"
  l7 = "Fitter's’Lists"

  while true
'     x = popuplist(9,29,13,l1&l2&l2a&l3,"",1,0)
    x = popuplist(9,29,15,l1&l2&l3&l2a&l8,"",1,0)
    if x = -1
      exit while
    end if

    if ptstr = l1                      'l1 = "Job’List"
      PrintJobList()

    elseif ptstr = l2                  'l2 = "Preparation’Lists"
      while true
        x = popuplist(9,31,13,l4&l5&l6&l7,"",1,0)
        if x = -1
          exit while
        end if
        if ptstr = l4                    'l4 = "Cutting’List"
          PreparationLists(1,0)

        elseif ptstr = l5                'l5 = "Bespoke Items"
          PreparationLists(2,0)

        elseif ptstr = l6                'l6 = "Ancillaries"
          PreparationLists(3,0)

        elseif ptstr = l7              'l7 = "Fitters"
          PreparationLists(4,0)
        end if
      end while

    elseif ptstr = l3                  'l3 = "Fitters'’Worksheets"
      PrintJobs()

    elseif ptstr = l2a                 'l2a = "Imminent’Jobs"
      execute "imminent.rf3" in-memory

    elseif ptstr = l8                 'l8 = "Unprocessed’Goodsout"
      execute "oldgdout.rf3" in-memory

    end if

  end while

  ReturnToMenu()

END MAIN


FUNCTION CheckFitDate()
  while true
    ftgdate = days(today) + 1
    if dayname(date2(ftgdate)) == "Saturday"
      ftgdate = days(today) + 3
    end if
    if dayname(date2(ftgdate)) == "Sunday"
      ftgdate = days(today) + 2
    end if
    fentrybox(" Confirm date for CPL lists ",10,"##\/##\/####",date2(ftgdate))
    if x = -1
      return (-1)
    end if
    ftgdate = ptstr
    if chkdate(ftgdate,1) = -1
      messbox(" Incorrect date - re-enter ",0,0,1)
      continue while
    end if
    exit while
  end while
END FUNCTION ' CheckFitDate()


FUNCTION ChkGdsOut()
  vloadif(dpath|"goodsout.vws")
  order change key "[Date_Out]"
  data query execute "cplprep1.dfq" index "todays1.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
'   [Date_Out]=days(ftgdate)
'   and
'   not (deleted)
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
  if cerror
    messboxwait(" No goods due for despatch on"&date2(ftgdate),0,0,1)
    return (2)
  end if

'check that all records for Stock or Bespoke have been alloc'd/rec'd
  data query execute "cplprep2.dfq" index "todays2.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
' ³ [RollNr] = "00000/00"
'   or
' ³ [RollNr] = "BESPOK"
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
  if cerror
    return (0)
  else
    data query execute "notype_o.dfq" index "unalloc.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
'   [Itemtype] <> "O"
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
    if cerror
      return (0)
    else
      messbox(" Not all goods for despatch have been received or allocated ",0,0,1)
      repaint off
      order change physical
      vloadif(dpath|"notrecvd.vw")
      order change index "unalloc.idx"
      order sort now dictionary "notrecvd.idx" fields "[Job_Nr]" ascending
      p1 = "notrecvd.dfr"   ' p1 = report definition ("ord_stck.dfr")
      PrintReport(p1,"Not Received",p3,p4,p5,p6)
      return (1)
    end if
  end if
END FUNCTION ' ChkGdsOut()


FUNCTION ReturnToMenu()
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  file unload all
  transfer cpath|"pm_menu.psl" in-memory
END FUNCTION ' ReturnToMenu()


FUNCTION FittersLists(pl)
local y
'----------------------------list all fitters going out
'   progress(15,10," Please wait .... finding records ",0)
  vloadif(dpath|"lststk_G.vw")
  order change index "todays1.idx"  'look at FtrCode in GOODSOUT/todays1.idx and remove duplicates
  data goto record first
  while true
    if chkstr(mid([FtrCode],2,1),"1 2 3 4 5 6 7 8 9 0") = 0
      messbox(" Not text’",0,0,1)
      data goto record next
    else
      $ftrs = [FtrCode]
      exit while
    end if
    if record = records
      return (-1)
    end if
  end while

  data goto record next
  for i = 2 to records                 'create text string of Job Nrs
    x = chkstr([FtrCode],$ftrs)
    if x = -1
      if chkstr(mid([FtrCode],2,1),"1 2 3 4 5 6 7 8 9 0") = 0
        messbox(" Not text’",0,0,1)
        data goto record next
      else
        $ftrs = $ftrs&[FtrCode]
'         $ftrs = [FtrCode]
'         exit while
      end if
    end if
    data goto record next
  end for
' message "$ftrs is:"&str($ftrs)

'create index of FTR_LIST by stepping thro' text string and using ADDIDXRECS
  x=strcount($ftrs)                    'message "x is:"&str(x)
  #ftrs = ptval                        'message "#ftrs is:"&str(#ftrs)
  vloadif(dpath|"ftr_list.vws")
  order change key "[Fitter_Code]"
  remove("ftrlist.idx")
  x = makeidx("ftr_list","ftrlist","0",3)     'message "x is:"&str(x)
  for i = 1 to #ftrs
    ftrcode = group($ftrs,i)
    data find "[Fitter_Code]" equal ftrcode options ""
    x = addidxrec("ftrlist.idx",precord,7)    'message "x is:"&str(x)
    if x<>0
      messboxwait(" Fitters index not building correctly [L270] ",0,0,1)
      return (-1)
    end if
  end for
  order change index "ftrlist.idx"
  order sort now dictionary "fitters.idx" fields "[Nickname]" ascending
  sr = @if(records<18,11-int(records/2),3) 'message "sr is:"&str(sr)
  er = @if(records<18,sr+records+1,20)     'message "er is:"&str(er)
  while true
    x = bpopdb("ftr_list",8,"","[Nickname]","L8","[Fitter_Name]","L0","[Fitter_Code]",sr,35,er,45,"",0)
    if x = -1
      screen clear box 1 1 sch scw 0 0 no-border
      repaint off
      exit while
    else
      ftrcode = [Fitter_Code]          'message "ftrcode is:"&str(ftrcode)
      $nickname = [Nickname]
      PrepLists()
      vloadif(dpath|"ftr_list.vws")
    end if
  end while
END FUNCTION ' FittersLists()


FUNCTION PrintJobList()
'----------------------------list of all jobs going out
  progress(15,10," Please wait .... finding jobs ",0)
  vloadif(dpath|"jobs2fit.vw")
  order change index "jobs2fit.idx"
  order sort now dictionary "lstjobs.idx" fields "[CustOrd_Name]" ascending
  p1 = "listjobs.dfr"
  PrintReport(p1,"Job List",p3,p4,p5,p6)
'   StoreReport(p1,"001")
END FUNCTION 'PrintJobList()


FUNCTION PreparationLists(list,mark)   ' 1=Stock Cutting List only; 0=enter CPL_ref & print all
local $datafile
  vloadif(dpath|"lststk_G.vw")
  order change index "todays1.idx"
  if list = 1
'----------------------------total list for stock carpet, tiles etc
'     while true
    data query execute "ctg_list.dfq" index "list.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
' ³ [Itemtype] = "C"                                                   ³
' ³ or                                                                 ³
' ³ [Itemtype] = "S"                                                   ³
' ³ or                                                                 ³
' ³ [Itemtype] = "V"                                                   ³
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
    if cerror
      messboxwait(" No carpets to cut or stock tiles/vinyl to prepare ",0,0,1)
      return (1)
    end if
    order sort now dictionary "listcarp.idx" fields "[ViewDesc]" ascending
    $carptitle = "STOCK"
    remove(X_path|"X_lstcrp.*")
    data query execute "not_del.dfq" data-file X_path|"X_lstcrp" fields "[Reference_Nr|Location]"
    data query execute "not_del.dfq" Smart4 X_path|"X_lstcrp" fields "[Reference_Nr|Location]"

    order sort now dictionary "lstcarp.idx" fields "[Job_Nr;RollNr]" ascending

    vunloadif("X_lstcrp.vws")
    _SWIP_Crystal(Xreppath|"X_lstcrp","P",0,1,"")

'     p1 = "listcarp.dfr"
'     $refnr = [Reference_Nr]
'     PrintReport(p1,$carptitle&"Carpet list",p3,p4,p5,p6)
'     StoreReport(p1,"005")
    file unload all

  elseif list = 2
'----------------------------total list for Bespoke carpet, tiles etc
    vloadif(dpath|"lststk_G.vw")
    order change index "todays1.idx"
    data query execute "listbesp.dfq" index "list.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
'   [Item_Type]="B" or [Item_Type]="J" or [Item_Type]="T" or [Item_Type]="W"
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
    if cerror
      messbox(" No Bespoke items to list ",0,0,1)
    else
      order sort now dictionary "listbesp.idx" fields "[ViewDesc]" ascending
      $carptitle = "BESPOKE"
      p1 = "listbesp.dfr"
      PrintReport(p1,$carptitle&"Carpet list",p3,p4,p5,p6)
'       StoreReport(p1,"002")
    end if

  elseif list = 3
'----------------------------total list for Ancillaries
    vloadif(dpath|"stk_ancl.vws")
    vloadif(dpath|"lststk_G.vw")
    order change index "todays1.idx"
    data query execute "listANCL.dfq" index "list.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
'   [Itemtype]="A"
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
    if cerror
      messbox(" No Ancillary items to list ",0,0,1)
      message "Index error @ L.288"
    else
      $datafile = dpath|"ANCLLIST"     'message "$datafile is:"&str($datafile)
      remove($datafile|".*")
      data cross-tab execute "listancl.dfw" data-file $datafile
      vloadif(dpath|"anclist1.vw")
      order sort now dictionary "listancl" fields "[Product_MRC]" ascending ' CURRENT month
      p1 = "listancl.dfr"                  'message "p1) is:"&str(p1)
      PrintReport(p1,"Ancillary list",p3,p4,p5,p6)     'breakdown by Product_Code
'       StoreReport(p1,"003")
      vloadif(dpath|"lststk_G.vw")
    end if

  elseif list = 4
    FittersLists("P")
  end if
END FUNCTION ' PreparationLists()


FUNCTION PrepLists()
  repaint off
  vloadif(dpath|"ftrslist.vw")
  order change index "todays1.idx"
  data query execute "ftrlist1.dfq" index "loading1.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
' ³ [FtrCode] = ftrcode
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
  if cerror
  end if
  data query execute "ftrlist2.dfq" index "loading2.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
'   [Item_Type]="B" or [Item_Type]="J" or [Item_Type]="T" or [Item_Type]="W" OR [Item_Type]="C" or [Item_Type]="S" or [Item_Type]="V"
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
  order sort now dictionary "loading3.idx" fields "[Product_Code]" ascending
' message "inchar"
  p1 = "ftr_jobF.dfr"
  PrintReport(p1,"Loading for"&$nickname,p3,p4,p5,p6)
END FUNCTION ' PrepLists()


FUNCTION PrintJobs()
  vloadif(dpath|"jobs2fit.vw")
  order change index "jobs2fit.idx"
  order sort now dictionary "lstjobs.idx" fields "[CustOrd_Name]" ascending
  sr = @if(records<18,11-int(records/2),3) 'message "sr is:"&str(sr)
  er = @if(records<18,sr+records+1,20)     'message "er is:"&str(er)
  while true
    x = bpopdb("jobs2fit",6,"","[$desc]","L78","[Job_Nr]","L0","[Job_Nr]",sr,2,er,79,"",0)
    screen shortrestore dsa
    repaint off
    if x = -1
      screen clear box 1 1 sch scw 0 0 no-border
      repaint off
      return (-1)
    else
      jobnr = [Job_Nr]               'message "jobnr is:"&str(jobnr)
      PrintJobSheet()
      vloadif(dpath|"jobs2fit.vw")
    end if
  end while
END FUNCTION 'PrintJobs()


FUNCTION PrintJobSheet()
  custname  = [CustOrd_Name]
  deladdr1  = [Delivery_Address_1]
  deladdr2  = [Delivery_Address_2]
  deladdr3  = [Del_City]
  deladdr4  = [Del_Postcode]
  offtel    = [Office_Tel]
  hometel   = [Home_Tel]
  ftginstr  = [Instructions]
  ftgcomm   = [Fitting_Comment]
  cr_status = [Credit_Status]
  mobile    = [Mobile/Other_Nr]
  balancedue= [Balance_Due]

' find req'ns (not deleted) for jobnr & fitter
  vloadif(dpath|"lststk_G.vw")
  order change index "todays1.idx"
  data query execute "jobsheet.dfq" index "job_reqn.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
'   [Job_Nr] = jobnr
'   and
'   [Itemtype] <> "O"
'   and
'   not(deleted)
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
  if cerror
    messboxwait(" No goods to despatch for job"&jobnr|" ",0,0,1)
    return (0)
  end if
  order sort execute dictionary "lst_stck.dfs" index "lst_stck"
  data goto record first
  $ftrs = [FtrCode]
  data goto record next
  for i = 2 to records                 'create text string of Job Nrs
    x = chkstr([FtrCode],$ftrs)
    if x = -1
      $ftrs = $ftrs&[FtrCode]
    end if
    data goto record next
  end for
' message "472\$ftrs is:"&str($ftrs)
  x=strcount($ftrs)                    'message "x is:"&str(x)
  #ftrs = ptval                        'message "#ftrs is:"&str(#ftrs)
  for i = 1 to #ftrs
    ftrcode = group($ftrs,i)           '
    vloadif(dpath|"ftr_list.vws")
    ftrname = filelookup([Fitter_Code],[Nickname],ftrcode)
    vloadif(dpath|"lststk_G.vw")
    data query execute "ftrsheet.dfq" index "ftrsheet.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
'   [FtrCode] = ftrcode
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
' sort by LstOrder
    order sort execute dictionary "lst_stck" index "lststck1"
'     remove(X_path|"X_jobwks.*")
'     data query execute "not_del.dfq" data-file X_path|"X_jobwks" fields "[Fitting_Date|Width]"
'     vunloadif("X_jobwks.vws")
'     ClearHardSpaces()
'     _SWIP_Crystal(Xreppath|"X_jobwks","P",0,1,"")
'     vloadif(dpath|"lststk_G.vw")
'     vloadif(dpath|"lststk_a.vw")
'     vloadif(dpath|"ftrwks_X.vw")
'   PrintReport("ftrwks_F.dfr","Job Worksheet",p3,p4,p5,p6)
'     return (0)
    p1 = "ftrwks_g.dfr"
    PrintReport(p1,"Worksheet"&jobnr,p3,p4,p5,p6)
    order change index "lst_stck.idx"
  end for
  vunloadif("ftr_list.vws")
  return (0)
END FUNCTION 'PrintJobSheet()


