PUBLIC gcCondLuna
*!*	gcCondLuna = [((((extract(month from datafact) =]+Alltrim(Str(gnLuna))+;
*!*			[ and extract(year from datafact) =]+Alltrim(Str(gnAn))+[) or (datafact is null ));
*!*			 and ]+;
*!*			[ (extract (month from datai)<=]+Alltrim(Str(gnLuna)) + [ and extract(year from datai)<= ]+Alltrim(Str(gnAn))+[))]+;
*!*			[ or ((extract (month from dataoravalid)>= ]+Alltrim(Str(gnLuna))+[ and extract(year from dataoravalid)>=]+Alltrim(Str(gnAn)) +[)]+;
*!*			[ and id_tip > 1)]+ [)]

*!* 30.06
*!*	lcDataFact= [ (a.facturat=1 and (extract(month from a.datafact) =]+Alltrim(Str(gnLuna))+[ and extract(year from a.datafact) =]+Alltrim(Str(gnAn))+[))]
*!*	lcDataValid = [ (a.validat=1 and (extract (month from a.dataoravalid)>= ]+Alltrim(Str(gnLuna))+[ and extract(year from a.dataoravalid)>=]+Alltrim(Str(gnAn)) +[)) ]		
*!*	gcCondLuna = [ ((extract (month from a.datai)=]+Alltrim(Str(gnLuna)) + [ and extract(year from a.datai)= ]+Alltrim(Str(gnAn))+[) or ]+;
*!*					[ (a.id_tip=1 and (a.facturat=0 or ] + lcDataFact + [) ) or (a.id_tip>1 and (a.validat=0 or ] + lcDataValid + [))) ]
lcDataFact= [ (a.facturat=1 and (extract(month from a.datafact) =]+Alltrim(Str(gnLuna))+[ and extract(year from a.datafact) =]+Alltrim(Str(gnAn))+[))]
lcDataValid = [ (a.validat=1 and (extract (month from a.dataoravalid)+extract(year from a.dataoravalid)*12=]+Alltrim(Str(gnLuna+gnAn*12)) +[)) ]		
gcCondLuna = [ ((extract (month from a.datai)+extract(year from a.datai)*12=]+Alltrim(Str(gnLuna+gnAn*12))+[) or ]+;
		[ ((extract (month from a.datai)+extract(year from a.datai)*12<]+Alltrim(Str(gnLuna+gnAn*12))+[) and ]+;
		[ ((a.inch_validare=0 and (a.facturat=0 or ] + lcDataFact + [) ) or (a.inch_validare=1 and (a.validat=0 or ] + lcDataValid + [))))) ]
*!*	If Nvl(gnDev_valregie,1) = 1
*!*		gcCondLuna = [ ((extract (month from a.datai)+extract(year from a.datai)*12=]+Alltrim(Str(gnLuna+gnAn*12))+[) or ]+;
*!*			[ ((extract (month from a.datai)+extract(year from a.datai)*12<]+Alltrim(Str(gnLuna+gnAn*12))+[) and ]+;
*!*			[ ((a.id_tip=1 and (a.facturat=0 or ] + lcDataFact + [) ) or (a.id_tip>1 and (a.validat=0 or ] + lcDataValid + [))))) ]
*!*	Else
*!*		gcCondLuna = [ ((extract (month from a.datai)+extract(year from a.datai)*12=]+Alltrim(Str(gnLuna+gnAn*12))+[) or ]+;
*!*			[ ((extract (month from a.datai)+extract(year from a.datai)*12<]+Alltrim(Str(gnLuna+gnAn*12))+[) and ]+;
*!*			[ ((a.id_tip in (1,3) and (a.facturat=0 or ] + lcDataFact + [) ) or (a.id_tip not in (1,3) and (a.validat=0 or ] + lcDataValid + [))))) ]
*!*	Endif
******************************************************************************************************************
PUBLIC gcGestPermis, gcGrupePermis,gnTipGest,gcGestPermis_Nume,gcGrupePermis_Nume
STORE '' TO gcGestPermis,gcGrupePermis,gcGestPermis_Nume,gcGrupePermis_Nume
STORE 0 TO gnTipGest

lcSql = [select * from ] + gcs + [.VGEST_CORESP_UTIL_GRUPE where id_util =] + ALLTRIM(STR(gnIdUtil)) 
lcCursor = [GRUPE_permis]
lnSucces = goExecutor.oExecute(lcSql,lcCursor)
goExecutor.oReset()
IF lnSucces > 0	
	SELECT grupe_permis
	SCAN 
		gcGrupePermis = gcGrupePermis + ',' + ALLTRIM(STR(id_grupe))
		gcGrupePermis_nume = gcGrupePermis_nume + ',' + ALLTRIM(nume_grupa)
	ENDSCAN
	gcGrupePermis = SUBSTR(gcGrupePermis,2)
	gcGrupePermis_nume = SUBSTR(gcGrupePermis_nume,2)
	USE IN grupe_permis
ENDIF 

IF '-1' $ gcGrupePermis
	gcGestPermis = '-1'
ELSE 
	lcSql = [SELECT * FROM ] + gcs + [.VGEST_CORESP_GRUPE_GESTIUNI A JOIN ] + gcs + [.VGEST_CORESP_UTIL_GRUPE B ]+ ;
	[ON A.ID_GRUPE = B.ID_GRUPE WHERE B.ID_UTIL = ] + ALLTRIM(STR(gnIdUtil))
	lcCursor = [gest_permis]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	goExecutor.oReset()
	IF lnSucces > 0
		SELECT gest_permis
		SCAN 
			gcGestPermis = gcGestPermis + ',' + ALLTRIM(STR(id_gestiune))
			gcGestPermis_nume = gcGestPermis_nume + ',' + ALLTRIM(nume_gestiune)
		ENDSCAN
		gcGestPermis = SUBSTR(gcGestPermis,2)
		gcGestPermis_nume = SUBSTR(gcGestPermis_nume,2)
		USE IN gest_permis
	ENDIF 
ENDIF 

* initializare variabile publice gnInchidereValidare1/2/3/4/5/6/7
=cctipuri_deviz()
SELECT crstipuri_deviz
SCAN
	lcVariabila = 'gnInchidereValidare' + ALLTRIM(STR(id_tip))
	PUBLIC &lcVariabila && gnInchidereValidare1 = 0/1
	&lcVariabila = NVL(inch_validare, 0)				
ENDSCAN 

USE IN (Select('crstipuri_deviz'))

	