' BACSDRCT	printout per shop of all "direct to Bank" receipts for that day

external   vkeybox() sch scw progress() messbox() vloadif() cpath br_name $branch
external   vunloadif() dpath fentrybox() chkdate() remove() areas greeting
external   base findpopup() messboxwait() $drive Background()
external   X_path _SWIP_Crystal() Xreppath

public     ptstr choice sum_date psa dsa #banking

global     x DailyBACS() ReturnToMenu() p1 p2 p3 p4 p5 p6 Place_Paid() $place i


MAIN
single-step off
	Background()

  	DailyBACS()

  	Background()

  	ReturnToMenu()

END MAIN


FUNCTION DailyBACS()     ' show keybox() listing each shop (& ALL)
local br_dir repdate cashrep

'   	br_name = $place
  	choice = left(br_name,1)             'message "choice is:"&str(choice)
  	vloadif(dpath|"bacsdrct.vw")
  	order change physical
  	if areas ! upper(choice)
   		sum_date=today
    		progress(15,10," Please wait ... preparing report ",0)
    		data query execute "totcash5.dfq" index "totcash2.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' [Banked]=blank and [SalAnal]=choice
' and
' [Abbrv_M] <> "O"
' and
' [Method_Of_Payment]="Direct"
' and
' not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    		if cerror
      		messboxwait(" No BACS/Direct received ",0,0,1)
      		return (1)
    		end if
    		#banking=filesum([Amount_Received],[Abbrv_M]="D") ' D=Direct message "#banking is:"&str(#banking)
    		order sort execute dictionary "totcash.dfs" index "totcash.idx"
    		while true
      		vunloadif("X_cshrcd.vws")
      		remove(X_path|"X_cshrcd.*")
      		data query execute "not_del.dfq" Smart4 X_path|"X_cshrcd" fields "[Customer_Code|Br_KA]"
      		vunloadif("X_cshrcd.vws")
      		_SWIP_Crystal(Xreppath|"bacsrcvd","S",0,1,"") ' VIEW ONLY report
      		vloadif(dpath|"cshrcvd1.vw")
      		messbox(" Has the BACS/Direct Report printed correctly? (y/n) ",1,1,1)
      		if ptstr == "y"                      '  store file & exit
         			exit while
      		else
        			messbox(" Abandon and print later? (y/n) ",1,1,1)
        			if ptstr == "y"                      '  store file & exit
          			return (-1)
        			else
          			continue while
        			end if
      		end if
    		end while
  	else
    		messbox(greeting|", you do not have access rights for this report ",0,0,1)
  	end if
  	screen clear box 1 1 sch scw 0 0 no-border
' if shop selection is not included in "areas" on oldpurch.vws refuse access
' if "areas" allow 2 areas, then only one report to be done at any one time (DG excepted)
' print report listing all cash rec'd for selected shop(s)
END FUNCTION ' DailyCash()


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 Place_Paid()
local s1 s2 s3 s4 s5 s6 $locn s7
  	$locn = case base ("R","Raynes")("P","Putney")("S","Sheen")("F","Fulham") else "HeadÿOffice"
  	s1 = "Fulham"
  	s2 = "HeadÿOffice"
  	s3 = "Raynes"
  	s4 = "Sheen"
  	s7 = "Putney"
  	while true
    		x = findpopup(8,60,15,s1&s7&s2&s3&s4,$locn,"Place",1,0)
    		if x = -1
      		return (-1)
    		end if
    		$place = ptstr                     'message "$place is:"&str($place)
    		return (0)
  	end while
END FUNCTION 'Place_Paid()

