'test print program


external   vkeybox() sch scw progress() messbox() vloadif() base $menu userid process_create()
external   vunloadif() dpath fentrybox() chkdate() areas greeting cpath
external   popuplist() fgp bgp ChooseBranch() remove() Background() vatrate
external   _SWIP_Crystal() Xreppath X_path bpopdb() increment() messboxwait()

public     ptstr ptval
public     $shop_name $shop_init

global     x ReturnToMenu() Report() nr ProcessPayment() i


MAIN
  single-step off
  Background()
  file unload all
	_SWIP_Crystal(Xreppath|"X_stmtR","P",1,1,"")
message "Test print of petty cash listing"


'     x = Report()			' listing of P/cash NOT re-imbursed
'     if x=-1
'       continue while
'     elseif x=0				' draft correct
'       messbox(" Continue and process these payments? (y/n) ",1,1,1)
'       if ptstr == "y"
'          ProcessPayment()
'       else
'         continue while
'       end if
'     end if
'   end while
'
'   ReturnToMenu()

END MAIN


FUNCTION ReturnToMenu()
  Background()
  file unload all
  transfer cpath|"pm_menu.psl" in-memory
END FUNCTION ' ReturnToMenu()


FUNCTION Report()
  messbox(" List of unpaid petty cash for"&$shop_name&"? (y/n) ",1,1,1)
  if ptstr == "n"
    return (-1)
  else				'message "print list of unpaid items"
    vloadif(dpath|"pcsh_ent.vws")
    data query execute "pcshrep1.dfq" index "pcash1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' [Shop]=$shop_init
' and
' not (deleted)
' and
' [ProcessDate]=blank
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if cerror
      messboxwait(" No unpaid Petty Cash items for"&$shop_name,0,0,1)
    else
repaint on
repaint
single-step on
      remove(X_path|"Xpcshlst.*")
      data query execute "not_del.dfq" data-file X_path|"Xpcshlst" fields "[Date;ShopName;Shop;Ref_Nr;Category;SunCode;Narrative;VAT;Gross Amount]"
      vunloadif("Xpcshlst.vws")
      _SWIP_Crystal(Xreppath|"pcsh_lst","P",0,1,"")
    end if
  end if
  return (0)
END FUNCTION 'Report()


FUNCTION ProcessPayment()
'   vloadif(dpath|"pcshproc.vw")		'
  vloadif(dpath|"pcsh_ent.vws")		'
'   order change index "pcash1.idx"
for i=1 to records
lock-record
[ProcessDate]=today
write-record
data goto record next
End for

'   for i = 1 to records
'     lock-record                        ' update record with inv nr & date
'       [ProcessDate]=today
'     write-record
'     data goto record next
'   end for
message "check index"
'print file copy of report - ref nr on report will be shopinit & date (e.g. H040806)
  _SWIP_Crystal(Xreppath|"pcshproc","P",0,1,"")

'create text file for posting in SUN
END FUNCTION 'ProcessPayment()

