*!* 19.03.2015
*!* marius.mutu
*!* VIZ_LUNI_BLOCATE - se afiseaza doar programele pe care are utilizatorul dreptul

*** OPROCEDURI_ROADEF
**************************************** INCEPUT: viz_categorii_entitati ******************************
Procedure viz_categorii_entitati
Private poCategorii_entitati,pcSchema,pcSelect
Store '' To poCategorii_entitati
If Used('crsCategorii_entitati')
	Use In crsCategorii_entitati
Endif

llAfisare=.F.
pcSchema = ['']
pcSelect=['select * from ] + gcS + [.vnom_categorii_entitati where 1=2']
pcOrder=[categorie_entitate]
pcFiltru = [1=2]
gencursor('poCategorii_entitati','crsCategorii_entitati',pcSelect,pcFiltru,pcSchema,pcOrder,llAfisare)
poCategorii_entitati.ca_baza1.afisare()
ofrmcategorii=Createobject('frm_categorii_entitati')
ofrmcategorii.Show(1)
Release poCategorii_entitati,ofrmcategorii
Endproc
**************************************** SFARSIT: viz_categorii_entitati ******************************
*******************************************
* PROCEDURE VIZ_LUNI_BLOCATE
* Date : 28/10/2005, 10:27:42
* author : marius.mutu
* description:
*******************************************
Procedure VIZ_LUNI_BLOCATE

Local lcObiect, lcCursor, lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcGroup, llModParam, lcFiltruOriginal, lcSeconds
lnSucces = 1

lcSeconds = SET("Seconds")
SET SECONDS ON 
Private poPrograme
poPrograme = .F.
lcObiect = "poPrograme"
lcCursor = "crsPrograme"
*!*	lcSelect = "select ide_program, explicatie as denumire from contafin_oracle.vdef_programe"

TEXT TO lcSelect NOSHOW 
select distinct p.ide_program, p.nume as denumire, p.instalat
  from contafin_oracle.vDEF_UTIL_GRUP ug
  join contafin_oracle.def_grup_drept gd on ug.id_grup = gd.id_grup
  join contafin_oracle.vdef_programe p on gd.id_program = p.ide_program
ENDTEXT 

lcFiltru = ""
lcSchema = ""
lcOrder = "nume"
llAfisare = .F.
lcGroup = ""
llModParam = .T.
lcFiltruOriginal = "ug.id_util = ?gnIdUtil and ug.id_firma = ?gnIdFirma and gd.sters = 0 and p.instalat = 1 and p.nume not in ('INDEX.HTM', 'ROADEF', 'ROADEFSALARII', 'ROASUPORT', 'ROADECL', 'ROAMANAGER', 'ROASITFIN', 'ROAOFERTARE', 'ROAJURIDIC', 'ROAPRETURI')"
gencursor(lcObiect, lcCursor, lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcGroup, llModParam, lcFiltruOriginal)
poPrograme.ca_baza1.lAfisare = .T.
poPrograme.ca_baza1.afisare()
If !Used('crsPrograme')
	lnSucces = -1
Endif


If lnSucces > 0

	Private poBlocat
	poBlocat = .F.
	lcObiect = "poBlocat"
	lcCursor = "crsLuniAn"
	lcSelect = "select * from blocatprogramluni"
	
TEXT TO lcSelect NOSHOW 
select an, luna, ide_program, blocat, id_util, utilizator, stare, dataora from
 (select b.an,
         b.luna,
         b.ide_program,
         b.blocat,
         l1.id_log,
         l1.id_util,
         u.utilizator,
         l1.stare,
         l1.dataora,
         max(l1.id_log) OVER(PARTITION BY l1.id_tabel) as idlogmax
    from blocatprogramluni b
    left join (select l.id_log,
                l.tabel,
                l.id_tabel,
                l.camp,
                l.ID_UTIL,
                DECODE(VALOAREN, 1, 'BLOCAT', 'DEBLOCAT') AS STARE,
                l.dataora
           from LOG l) l1
      on l1.ID_TABEL = b.ide_program || b.an || lpad(b.luna, 2, '0')
     and l1.tabel = 'BLOCATPROGRAMLUNI'
     and l1.camp = 'BLOCAT'
     and l1.id_util <> 2
    left join syn_utilizatori u
      on l1.id_util = u.id_util)
ENDTEXT 	
	lcFiltru = "1 = 2"
	lcSchema = ""
	lcOrder = "ide_program, an desc, luna desc"
	llAfisare = .F.
	lcGroup = ""
	llModParam = .T.
	lcFiltruOriginal = "nvl(id_log,0) = nvl(idlogmax,0)"
	gencursor(lcObiect, lcCursor, lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcGroup, llModParam, lcFiltruOriginal)
	poBlocat.ca_baza1.lAfisare = .T.
	poBlocat.ca_baza1.afisare()
	If !Used('crsLuniAn')
		lnSucces = -1
	Endif
Endif

If lnSucces > 0
	ovizblocate=Createobject('frm_viz_blocate')
	ovizblocate.Show(1)
Endif

If Used('crsPrograme')
	Use In crsPrograme
Endif

If Used('crsFirme')
	Use In crsFirme
Endif

If Used('crsLuniAn')
	Use In crsLuniAn
Endif
SET SECONDS &lcSeconds
Endproc
*----------------------------------sfarsit procedura VIZ_LUNI_BLOCATE----------------------------------

Procedure viz_firme
Private pofirme,pcschema1,pcselect1
Store '' To pofirme
If Used('v_firme')
	Use In v_firme
Endif

llAfisare=.F.
pcschema1 = ['']
pcselect1=['select * from syn_v_nom_firme where 1=2']
pcorder1=[firma]
pcfiltru1 = [sters=0 and id_firma = ] + Alltrim(Str(gofirma.id_firma))
gencursor('pofirme','v_firme',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfisare)
pofirme.ca_baza1.afisare()

*!*	Select v_firme
*!*	Scatter Name poRec
*!*	ofrmfirme=Createobject("frm_firme")
*!*	ofrmfirme.Show(1)

If Reccount('v_firme')>0
	gnButon=1
	Select v_firme
	Scatter Name loRec
*!*	modificare 11.08
	AddProperty(loRec,"modificare_schema",0)
*!*	modificare 11.08	^
*!*	modificare	ROADEF v 2.1.2
*!*		*!*	modificare	ROADEF v 2.0.23
*!*		lnCodSiruta = 0
*!*		If !Empty(Nvl(loRec.id_loc,0))
*!*			lcSql = [select siruta from syn_vnom_localitati where id_loc = ] + Alltrim(Str(loRec.id_loc))
*!*			lcCursor = [crstmpsiruta]
*!*			If goExecutor.oExecuta(lcSql,lcCursor)
*!*				Select (lcCursor)
*!*				lnCodSiruta = siruta
*!*				Use In (Select(lcCursor))
*!*			Endif
*!*		Endif
*!*		AddProperty(loRec,"siruta",lnCodSiruta)
*!*		*!*	modificare	ROADEF v 2.0.23	^	
*!*	modificare	ROADEF v 2.1.2	^
*!* 07.02.2008
*!*		Do Adauga_Modifica_Inregistrare With "firme",loRec,loRec.id_firma,"UPDATE"
	Private poRec
	poRec = loRec
	loAdModFirme = Createobject("frm_firme_nou_desktopf",loRec,loRec.id_firma,"UPDATE")
	loAdModFirme.Show(1)
	llRet = gnButon
*!* 07.02.2008 ^
Endif
*!*	Release ofrmfirme
Release pofirme
Endproc && viz_firme

*******************************************
* PROCEDURE def_calculatoare(  )
* Date : 08/24/06, 11:57:53
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
Procedure def_calculatoare(  )

Private pocalc,pcschema1,pcselect1
Store '' To pocalc
*!*	pcschema1=['id_gestiune n(5),nume_gestiune c(50),cgest c(4),cont_gestiune c(4),ngest c(10),nrg n(4),ascd c(4),nr_grupa n(4),gest n(3)']
pcschema1 = ['']
pcselect1=['select * from ] + gcS + [.vcalculatoare where 1=2']
pcorder1=[denumire]
pcfiltru1 = [2=2]
llAfiseaza = .F.
gencursor('pocalc','crsCalc',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
pocalc.ca_baza1.afisare()
ofrmgest=Createobject('frm_calc')
ofrmgest.Show(1)
Release pocalc

Endproc
*----------------------------------sfarsit procedura def_calculatoare----------------------------------

*******************************************
* PROCEDURE set_calculatoare(  )
* Date : 08/24/06, 12:01:59
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
Procedure set_calculatoare(  )

Private pocalc,pcschema1,pcselect1
Store '' To pocalc
lcSchema = [SUCURSALA C(100), ID_SUCURSALA N(10), CALCULATOR C(100), COLOANE C(100), EXPLICATIA C(100), IDCOLOANA C(50), ] + [ID_CALC N(10), ID_CALCSETARE N(10), RESULTCOLOANA C(50), SETARE C(100), TABEL C(50), TIP C(10), TITLU C(100), TITLUCOLOANE C(100), VALOARE C(64), VALOARE_TEXT C(200)]
lcSelect=[SELECT SUCURSALA, ID_SUCURSALA, CALCULATOR, COLOANE, EXPLICATIA, IDCOLOANA, ID_CALC, ID_CALCSETARE, RESULTCOLOANA, SETARE, TABEL, TIP, TITLU, TITLUCOLOANE, VALOARE, VALOARE_TEXT FROM VCALC_SETARI]

lcOrder=[sucursala,calculator,setare]
lcFiltru = []
lcFiltruOriginal = []
llAfiseaza = .F.
llModParam = .T.
lcGroup = []
gencursor('pocalc','crsCalcsetari', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza, lcGroup,  llModParam, lcFiltruOriginal)
pocalc.ca_baza1.afisare()
ofrmgest=Createobject('frm_calcsetari')
ofrmgest.Show(1)
Release pocalc


Endproc
*----------------------------------sfarsit procedura set_calculatoare----------------------------------

*******************************************
* PROCEDURE grupuri_util(  )
* Date : 08/24/06, 15:15:22
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
Procedure grupuri_util(  )
Private pogrup,pcschema1,pcselect1
Store '' To pogrup
*!*	pcschema1=['id_gestiune n(5),nume_gestiune c(50),cgest c(4),cont_gestiune c(4),ngest c(10),nrg n(4),ascd c(4),nr_grupa n(4),gest n(3)']
pcschema1 = ['']
pcselect1=['select * from ] + gcS + [.vgrupuri_utilizatori where 1=2']
pcorder1=[denumire_grup]
pcfiltru1 = [2=2]
llAfiseaza = .F.
gencursor('pogrup','crsGrup',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
pogrup.ca_baza1.afisare()
ofrmgest=Createobject('frm_grupUtil')
ofrmgest.Show(1)
Release pogrup


Endproc
*----------------------------------sfarsit procedura grupuri_util----------------------------------

*******************************************
* PROCEDURE util_rol_intern(  )
* Date : 08/24/06, 15:15:38
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
Procedure util_rol_intern(  )

Private poutil,pcschema1,pcselect1
Store '' To poutil
*!*	pcschema1=['id_gestiune n(5),nume_gestiune c(50),cgest c(4),cont_gestiune c(4),ngest c(10),nrg n(4),ascd c(4),nr_grupa n(4),gest n(3)']
pcschema1 = ['']
pcselect1=['select * from ] + gcS + [.vutilizatori_rol_intern where 1=2']
pcorder1=[sucursala, denumire_grup, utilizator, partener, contact]
pcfiltru1 = [2=2]
llAfiseaza = .F.
*!*	modificare v 2.0.11
lcFiltruOriginal = Substr(gcCondSucursala,5)
llModParam = .F.
lcGroup = []
gencursor('poutil','crsUtil',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza,  lcgroup, llModParam, lcFiltruOriginal)
*!*	gencursor('poutil','crsUtil',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
*!*	modificare v 2.0.11	^
poutil.ca_baza1.afisare()
ofrmgest=Createobject('frm_Utilizatori')
ofrmgest.Show(1)
Release poutil

Endproc
*----------------------------------sfarsit procedura util_rol_intern----------------------------------

*******************************************
* PROCEDURE list_utilizatori(  )
* Date : 08/25/06, 13:41:16
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
Procedure list_utilizatori(  )
Local lcSelect, lcFiltru, lcSchema, lcOrder, lccoloane, lcTitlu, lcTitluColoane, lcFiltruOriginal, lcNumeProc
lcSelect = [select * FROM vNOM_SUCURSALE]
lcFiltru = [1=2]
lcSchema = []
lcOrder = [sucursala]
lccoloane = [sucursala]
lcTitlu = [Alegeti sucursala]
lcTitluColoane = [Sucursala]
lcFiltruOriginal = []
lcNumeProc = ""
lnPornire = 6
llDesktop = .T.
locauta = cauta_alfa(lcSelect, lcFiltru, lcSchema, lcOrder, lccoloane, lcTitlu, lcTitluColoane, lcNumeProc, .F., lcFiltruOriginal,,lnPornire,,,llDesktop)
If buton=2
	Return
Endif

lcSelect = [select * from vutilizatori_rol_intern ]+;
	IIF(!Empty(locauta.id_sucursala) And !Isnull(locauta.id_sucursala), [where id_sucursala = ]+Alltrim(Str(locauta.id_sucursala)),[])
lcCursor = [crsUtilizatori]
lnSucces = goExecutor.oExecute(lcSelect,lcCursor)
If lnSucces < 0
	aMessagebox(goExecutor.cEroare,16,"Eroare")
	Exit
Endif

*!*		MESSAGEBOX(locauta.id_sucursala)

Select crsUtilizatori
Report Form util To Printer Prompt Preview

Endproc
*----------------------------------sfarsit procedura list_utilizatori----------------------------------

*******************************************
* PROCEDURE list_calculatoare(  )
* Date : 08/25/06, 13:41:31
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
Procedure list_calculatoare(  )
Local lcSelect, lcFiltru, lcSchema, lcOrder, lccoloane, lcTitlu, lcTitluColoane, lcFiltruOriginal, lcNumeProc
lcSelect = [select * FROM vNOM_SUCURSALE]
lcFiltru = [1=2]
lcSchema = []
lcOrder = [sucursala]
lccoloane = [sucursala]
lcTitlu = [Alegeti sucursala]
lcTitluColoane = [Sucursala]
lcFiltruOriginal = []
lcNumeProc = ""
lnPornire = 6
llDesktop = .T.
locauta = cauta_alfa(lcSelect, lcFiltru, lcSchema, lcOrder, lccoloane, lcTitlu, lcTitluColoane, lcNumeProc, .F., lcFiltruOriginal,,lnPornire,,,llDesktop)
If buton=2
	Return
Endif

lcSelect = [select * from vcalculatoare ]+;
	IIF(!Empty(locauta.sucursala), [where id_sucursala = ]+Alltrim(Str(locauta.id_sucursala)),[])+[ order by sucursala]
lcCursor = [crsCalc]
lnSucces = goExecutor.oExecute(lcSelect,lcCursor)
If lnSucces < 0
	aMessagebox(goExecutor.cEroare,16,"Eroare")
	Exit
Endif


Select crsCalc
Report Form calculatoare To Printer Prompt Preview
Endproc
*----------------------------------sfarsit procedura list_calculatoare----------------------------------

*******************************************
* PROCEDURE list_gestiuni(  )
* Date : 08/25/06, 13:42:03
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
Procedure list_gestiuni(  )
Local lcSelect, lcFiltru, lcSchema, lcOrder, lccoloane, lcTitlu, lcTitluColoane, lcFiltruOriginal, lcNumeProc
lcSelect = [select * FROM vNOM_SUCURSALE]
lcFiltru = [1=2]
lcSchema = []
lcOrder = [sucursala]
lccoloane = [sucursala]
lcTitlu = [Alegeti sucursala]
lcTitluColoane = [Sucursala]
lcFiltruOriginal = []
lcNumeProc = ""
lnPornire = 6
llDesktop = .T.
locauta = cauta_alfa(lcSelect, lcFiltru, lcSchema, lcOrder, lccoloane, lcTitlu, lcTitluColoane, lcNumeProc, .F., lcFiltruOriginal,,lnPornire,,,llDesktop)
If buton=2
	Return
Endif

lcSelect = [select * from vnom_gestiuni order by sucursala,nume_gestiune]
*!*	+;
*!*		IIF(!EMPTY(locauta.sucursala), [where id_sucursala = ]+ALLTRIM(STR(locauta.id_sucursala)),[])
lcCursor = [crsGest]
lnSucces = goExecutor.oExecute(lcSelect,lcCursor)
If lnSucces < 0
	aMessagebox(goExecutor.cEroare,16,"Eroare")
	Exit
Endif

Select crsGest
Report Form gestiuni To Printer Prompt Preview

Endproc
*----------------------------------sfarsit procedura list_gestiuni----------------------------------

*******************************************
* PROCEDURE list_org_calc(  )
* Date : 08/25/06, 13:42:24
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
Procedure list_org_calc(  )
&&code goes here


Endproc
*----------------------------------sfarsit procedura list_org_calc----------------------------------

*******************************************
* PROCEDURE list_org_gest(  )
* Date : 08/25/06, 13:42:41
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
Procedure list_org_gest(  )
&&code goes here


Endproc
*----------------------------------sfarsit procedura list_org_gest----------------------------------
*******************************************
* PROCEDURE list_org_util(  )
* Date : 08/25/06, 13:42:58
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
Procedure list_org_util(  )
ofrmgest=Createobject('frm_listutil')
ofrmgest.Show(1)

Endproc
*----------------------------------sfarsit procedura list_org_util----------------------------------

*!*	iif(lower(pcPctLucru)='sucursala','Punct de lucru',IIF(LOWER(pcPctLucru) = 'partener',[Partener],'Grup')) + [: ]+ iif(allt(pcPctLucru) = 'sucursala',allt(sucursala),IIF(ALLT(pcPctLucru) = 'partener',ALLT(partener),allt(denumire_grup)))

*---------------------------------- inceput procedura asociere_parteneri_sectii ----------------------------------
Procedure asociere_parteneri_sectii
Parameters tnTip

If Empty(tnTip) Or Isnull(tnTip)
	Return
Endif

Private pnTip_asociere
pnTip_asociere = tnTip

Private poAsociere
Local lcSchema, lcSelect, lcFiltru, lcOrder, llAfiseaza, lcGroup, llModParam, lcFiltruOriginal
Store '' To poAsociere

lcSchema = []
lcSelect=[select * from vasociere_parteneri_sectii]
lcOrder=[denumire]
lcFiltru = []
llAfiseaza = .F.
lcGroup = ""
llModParam = .T.
lcFiltruOriginal = [id_tip=]+Alltrim(Str(pnTip_asociere))

gencursor('poAsociere','crsAsociere',lcSelect,lcFiltru,lcSchema,lcOrder,llAfiseaza, lcGroup, llModParam, lcFiltruOriginal)
poAsociere.ca_baza1.afisare()

lops = Createobject('frm_parteneri_sectii')
lops.Show(1)

If Used('crsAsociere')
	Use In crsAsociere
Endif

Endproc && asociere_parteneri_sectii
*----------------------------------sfarsit procedura asociere_parteneri_sectii ----------------------------------

*---------------------------------- inceput procedura asociere_parteneri_gestiuni ----------------------------------
Procedure asociere_parteneri_gestiuni
Parameters tnTip

If Empty(tnTip) Or Isnull(tnTip)
	Return
Endif

Private pnTip_asociere
pnTip_asociere = tnTip

Private poAsociere
Local lcSchema, lcSelect, lcFiltru, lcOrder, llAfiseaza, lcGroup, llModParam, lcFiltruOriginal
Store '' To poAsociere

lcSchema = []
lcSelect=[select id_asociere, id_part, denumire, id_gestiune, nume_gestiune, cont, id_util, dataora from vasociere_parteneri_gestiuni]
lcOrder=[cont,denumire,nume_gestiune]
lcFiltru = []
llAfiseaza = .F.
lcGroup = ""
llModParam = .T.
lcFiltruOriginal = [id_tip=]+Alltrim(Str(pnTip_asociere))

gencursor('poAsociere','crsAsociere',lcSelect,lcFiltru,lcSchema,lcOrder,llAfiseaza, lcGroup, llModParam, lcFiltruOriginal)
poAsociere.ca_baza1.afisare()

lops = Createobject('frm_parteneri_gestiuni')
lops.Show(1)

If Used('crsAsociere')
	Use In crsAsociere
Endif

Endproc && asociere_parteneri_gestiuni
*----------------------------------sfarsit procedura asociere_parteneri_gestiuni ----------------------------------
Procedure viz_log_redeschid

*!*	lcSelect = [select * from vlog_redeschid ]
*!*	lcCursor = [crsLog_redeschid]
*!*	lnSucces = goExecutor.oExecute(lcSelect,lcCursor)
*!*	If lnSucces < 0
*!*		aMessagebox(goExecutor.cEroare,16,"Eroare")
*!*	Endif

PRIVATE poLog_redeschid
STORE '' TO poLog_redeschid

Local lcSchema, lcSelect, lcOrder, lcFiltru, lcFiltruOriginal, llAfiseaza, lcGroup, lcFiltruOriginal
lcSchema = []
lcSelect = [select * from vlog_redeschid]
lcOrder = []
lcGroup = []
lcFiltru = []
lcFiltruOriginal = []
llModParam = .T.
llAfiseaza = .F.

gencursor('poLog_redeschid','crsLog_redeschid', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza,  lcGroup, llModParam, lcFiltruOriginal)
poLog_redeschid.ca_baza1.afisare()

Create Cursor crsLog_luni (perioada c(22), anul N(4), luna N(2))
Insert Into crsLog_luni (perioada) Values ("<Toate inregistrarile>")

Select distinct Alltrim(Str(anul))+'-'+Alltrim(Str(luna)) As perioada, anul, luna ;
	from crsLog_redeschid ;
	into Cursor crsLog_luni2 ;
	ORDER BY anul desc, luna desc

Select crsLog_luni
Append From Dbf("crsLog_luni2")
If Used("crsLog_luni2")
	Use In crsLog_luni2
ENDIF

SELECT crsLog_luni 
GO TOP 

Select crsLog_redeschid

lolr = Createobject('frm_log_redeschid')
lolr.Show(1)

If Used('crsLog_redeschid')
	Use In crsLog_redeschid
Endif

If Used('crsLog_luni')
	Use In crsLog_luni
Endif

Endproc && viz_log_redeschid
*----------------------------------sfarsit procedura viz_log_redeschid ----------------------------------
