
*!*********************************************************************
proc ucty_sum
PARAMETERS zformu
IF !zformu
	clos data
ENDIF 

sele md as ucet,  hs_md as hs,  sum(castka) as prachy_md group by 1, 2 ;
     from (m.gcucto_path + "u_ex_sum") into table (m.gcpri_path + "md")

sele dal as ucet, hs_dal as hs, sum(castka) as prachy_dal, 00000000.00 as prachy_md group by 1, 2 ;
     from (m.gcucto_path + "u_ex_sum") into table (m.gcpri_path + "ucty1")
appe from (m.gcpri_path + "md")

sele ucet, hs, sum(prachy_md) as prachy_md, sum(prachy_dal) as prachy_dal group by 1, 2 ;
     from (m.gcpri_path + "ucty1") into table (m.gcpri_path + "ucty")
do pr_report with "u_ex_uct"
IF !zformu
	clos data 
ELSE 
	USE IN u_ex_sum
	USE IN md
	USE IN ucty1
	USE IN ucty
ENDIF 

*!*********************************************************************
proc ucty
PARAMETERS zformu
IF !zformu
	clos data
ENDIF 
SELECT 0
use (m.gcucto_path + "u_ex_sum")
do pr_report with "u_ex_sum"
IF !zformu
	clos data
ELSE
	USE IN u_ex_sum 
ENDIF 

*!*********************************************************************
proc ucty_det
PARAMETERS zformu
IF !zformu
	clos data
ENDIF 
SELECT 0
use (m.gcucto_path + "u_ex")
do pr_report with "u_ex"
IF !zformu
	clos data
ELSE
	USE IN u_ex
ENDIF 

*!*********************************************************************
PROCEDURE vazby
PARAMETERS soubor, zformu
IF !zformu
	CLOSE DATABASES 
	USE (m.gcucto_path + m.soubor)
ELSE
	SELECT (m.soubor)
ENDIF 

IF !m.issql AND !m.zformu
	DO CASE 
		CASE "POL" $ UPPER(m.soubor)
	  		INDEX ON id_kas + id_man + cen_hlad + druh + STR(dan,5,3) TO (m.gcpri_path + "iiiiiiii")
		CASE "PLT" $ UPPER(m.soubor)
			INDEX ON id_kas + druh_pl TO (m.gcpri_path + "iiiiiiii")
		OTHERWISE 
			INDEX ON id_man + operace + cen_hlad + partner TO (m.gcpri_path + "iiiiiiii")
	ENDCASE 
ENDIF 
IF m.zformu
	DO CASE 
		CASE "POL" $ UPPER(m.soubor)
			DO pr_report WITH "u_ex_pol"
		CASE "PLT" $ UPPER(m.soubor)
			DO pr_report WITH "u_ex_plt"
		CASE "OBR" $ UPPER(m.soubor)
			DO pr_report WITH "u_ex_obr"
	ENDCASE 
ELSE 
	DO pr_report WITH m.soubor
ENDIF 

IF !zformu
	CLOSE DATABASES 
ELSE
	CLOSE INDEXES
	IF !m.issql
		ERASE  (m.gcpri_path + "iiiiiiii.idx")
	ENDIF
ENDIF 
