*!*****************************************************************************
*!       Procedure : PR_REPORT
*!*****************************************************************************
*PROCEDURE pr_report
PARAMETERS repo_name, doxff, ibazobraz
PRIVATE oldnull, lcrepo_path
* z autoexecovace se reporty netisknou, aby program nezustal zaseknut pri bezuzivatelskem spusteni
IF VARTYPE(m.repo_txt)<>"C"
	m.repo_txt=""
ENDIF 
IF EMPTY(m.doxff)
	IF ATC("autoexec", PROGRAM(1)+PROGRAM(2)+PROGRAM(3)+PROGRAM(4)+PROGRAM(5)+PROGRAM(6)+PROGRAM(7)+PROGRAM(8)) > 0
	    MESSAGEBOX("vytisknete si report " + UPPER( m.repo_name) + " rucne",1+64,"",3333)
	    RETURN 
	ENDIF 
ENDIF 


* tohle slouzi k tomu, aby food nebyl predcasne ukoncen pri zdanlive necinnosti, kdyz si budou vyjizdet postupne spoustu sestav
cas_posledni_cinnosti = TIME()
* tohle slouzi k tomu, aby food nebyl predcasne ukoncen pri zdanlive necinnosti, kdyz si budou vyjizdet postupne spoustu sestav


DO nastav_exportpath
IF VARTYPE(m.repo_name)=="C"
    prrexp_filename = STRTR(m.repo_name, "@", "_")
    IF AT("@", m.repo_name) > 1
        repo_name = LEFT(m.repo_name, AT("@", repo_name)-1)
    ENDIF 
ELSE 
    prrexp_filename="report_kongres"
ENDIF 
lcrepo_path=m.gcrepo_path
IF VARTYPE(m.gcrepo_special)=="C" AND !EMPTY(m.gcrepo_special) AND VARTYPE(m.repo_name)=="C"
    IF FILE(m.gcrepo_path+m.gcrepo_special+"\"+m.repo_name+".frx")
        m.lcrepo_path=m.gcrepo_path+m.gcrepo_special+"\"
    ENDIF 
ENDIF 
oldnull=SET("NULL")
oldsysmenu=SET("SYSMENU")
gcrepo_table=SELECT()
IF (FILE(m.gcini_path+"xfrx\zlib.dll") .AND. FILE(m.gcini_path+"xfrx\hndlib.dll") .AND. FILE(m.gcini_path+"xfrx\xfrxlib.fll") .AND. m.gnprintprompt >= 0 .AND. m.gcxfrx="1")
    PRIVATE boltool,oldsele, boltoolskl
    boltool=.F.
    boltoolskl=.F.
    oldsele=SELECT()
    IF VARTYPE('tbscreen') = 'O' THEN
		tbscreen.timer1.enabled=.f.
        tbscreen.HIDE()
        boltool=.T.
    ENDIF
    IF VARTYPE('tbscreenskl') = 'O' THEN
        IF tbscreenskl.VISIBLE
            tbscreenskl.HIDE()
        ENDIF
        tbscreenskl.TAG="pr_report"
        m.boltoolskl=.T.
    ENDIF
    IF m.ibazobraz .OR. FILE (m.lcrepo_path + m.repo_name + ".frx")
        IF m.doxff
            losession.processreport(m.lcrepo_path + m.repo_name,, .not. EMPTY(m.gctxt_summary))
        ELSE
            IF !m.ibazobraz
                SET PROCEDURE TO (m.gcini_path+"libs\utilityReportListener.prg") ADDITIVE
                SET CLASSLIB TO xfrxlib ADDITIVE
                LOCAL losession, lnretval, loxff, lopreview, loscripts
                losession=EVALUATE('xfrx("XFRX#INIT")')

                loprogress = CREATEOBJECT("progress")
                lnretval = losession.setparams(,,,,,,"XFF")
            ELSE
                m.lnretval=0
            ENDIF
            IF lnretval = 0
                IF !m.ibazobraz
                    m.loHACK=CREATEOBJECT("_XFRXHACK",m.loSession)   
                    losession.setotherparams("HORIZONTAL_ADJUSTMENT",1000) && default value = 76
                    losession.setotherparams("VERTICAL_ADJUSTMENT",1000) && default value = 180
                    losession.setprogressobj(loprogress,2)
					losession.lAbsoluteHackAllowed=.F.
                    *!*                        losession.shrinkheight(30000)
					* losession.processreport(m.lcrepo_path + m.repo_name,,IIF(EMPTY(m.gctxt_summary),.F.,.T.))
                    losession.processreport(m.lcrepo_path + m.repo_name,, .not. EMPTY(m.gctxt_summary))
                    losession.setpdfa(.T.)
                    loxff = losession.finalize ()
                    RELEASE m.loHACK 
                ELSE
                    loxff=m.repo_name
                    m.repo_name="xx"
                ENDIF
                SET PROCEDURE TO (m.gcini_path+"libs\utilityReportListener") ADDITIVE
                SET CLASSLIB TO xfrxlib ADDITIVE
                lopreview = CREATEOBJECT("frmMPPreviewer")
                m.gcklient=getklient()
                IF EMPTY(m.gcklient)
                    lopreview.iemail = 0 && show the email icon
                ELSE
                    lopreview.iemail = 1 && show the email icon
                ENDIF
                lopreview.oextensionhandler = CREATEOBJECT("SampleExtensionHandler")
                lopreview.WINDOWTYPE = 1
                lopreview.itool = 2 && embedded toolbar

                DO CASE 
                CASE gcjazyk > "1"
                    * nic - pouzije se defaultni anglictina
                CASE m.slovenskaverzia
                    lopreview.setlanguage("SK")
                OTHERWISE 
                    lopreview.setlanguage("CSY")
                ENDCASE 

                IF m.ibazobraz
                    lopreview.odisplaydefaults.defaultoutputfilename = m.gcexportpath+"kongres_"+m.gcpgm_id+"_"+DTOS(DATE())+"_"+STRTRAN(TIME(),":","")
                ELSE
                    lopreview.odisplaydefaults.defaultoutputfilename = m.gcexportpath+m.repo_name+"_"+m.gcpgm_id+"_"+DTOS(DATE())+"_"+STRTRAN(TIME(),":","")
                    IF "zrc"$LOWER(m.repo_name)
                        lopreview.odisplaydefaults.zoomfactor=125
                    ENDIF
                ENDIF
                lopreview.iBook=0
                lopreview.previewxff(loxff)
                lopreview.SHOW(1)
            ENDIF
            IF "xfrxlib_sk"$LOWER(SET("classlib"))
				TRY 
	                RELEASE CLASSLIB xfrxlib_sk	
	            CATCH
	            ENDTRY 
            ENDIF
            IF "xfrxlib_csy"$LOWER(SET("classlib"))
				TRY 
	                RELEASE CLASSLIB xfrxlib_csy
	            CATCH
	            ENDTRY 
            ENDIF
            IF "xfrxlib"$LOWER(SET("classlib"))
				TRY 
	                RELEASE CLASSLIB xfrxlib
	            CATCH
	            ENDTRY 
            ENDIF
            TRY 
	            RELEASE PROCEDURE (m.gcini_path+"libs\utilityReportListener")
	        CATCH
	        ENDTRY 
            SET NULL &oldnull
            SET SYSMENU &oldsysmenu
        ENDIF
    ENDIF
    IF m.boltool
		tbscreen.timer1.enabled=.t.
        tbscreen.SHOW()
    ENDIF
    IF m.boltoolskl
        IF tbscreenskl.TAG="pr_report"
            tbscreenskl.SHOW()
        ENDIF
        tbscreenskl.TAG=""
    ENDIF
    SELECT (m.oldsele)
ELSE
    DO prreport WITH m.repo_name
ENDIF
