lcOldAlias=Alias()

*-------------------------------------------------------------------

*-- COMPLETEZ FISIERUL DE OPTIUNI cu valorile default (OPTIUNILE SE AFLA ACUM IN DIRGEN\PROGRAM\, AR PUTEA SA SE AFLE SI IN FIRMA\DATEAN)
LCFIS_OPT_P="OPTIUNI_PROGRAM"
LCFIS_OPT_F="OPTIUNI_FIRMA"
LCFIS_OPT_L="OPTIUNI_LOCAL"


IF !USED(LCFIS_OPT_P) OR !USED(LCFIS_OPT_F) OR !USED(LCFIS_OPT_L)
	DO mesaj WITH 'Nu exista fisierele '+ LCFIS_OPT_P + ' ' + LCFIS_OPT_F + ' ' + LCFIS_OPT_L,'Sugeram iesirea din program!'
	QUIT 
ENDIF 

	Select (LCFIS_OPT_P)


	*** variabile care se reinitializeaza la inceputul programului automat
	Loca For Allt(Lower(varname))='eroripath'
	If !Found()
		Appe Blan
	Endif
	Repl varname With 'EroriPath',Vartype With "CHARACTER",varvalue With gcAppPath+"Erori\",vardesc With "Calea catre tabelul <erori.dbf>"

	lcDir=gcAppPath+"Erori"
	If !Directory(lcDir)
		Md (lcDir)
	Endif

**** OPTIUNI LOCALE

	Select (LCFIS_OPT_L)

	***
	Loca For Allt(Lower(varname))='nl'
	If !Found()
		Appe Blan
	Endif
	Repl varname With 'NL',Vartype With "CHARACTER",varvalue With m.nl,vardesc With "Luna contabila curenta"
	***
	Loca For Allt(Lower(varname))='an'
	If !Found()
		Appe Blan
	Endif
	Repl varname With 'AN',Vartype With "CHARACTER",varvalue With m.an,vardesc With "Anul contabil curent"

	***


	Loca For Allt(Lower(varname))='date'
	If !Found()
		Appe Blan
	Endif
	Repl varname With 'Date',Vartype With "CHARACTER",varvalue With Addbs(Strtran(Allt(Date),"\\","\")),vardesc With "Directorul cu datele lunare"

	Loca For Allt(Lower(varname))='datean'
	If !Found()
		Appe Blan
	Endif
	Repl varname With 'Datean',Vartype With "CHARACTER",varvalue With Addbs(Strtran(Allt(datean),"\\","\")),vardesc With "Directorul cu datele generale"

	Loca For Allt(Lower(varname))='calefirma'
	If !Found()
		Appe Blan
	Endif
	Repl varname With 'calefirma',Vartype With "CHARACTER",varvalue With Addbs(Strtran(Allt(calefirma),"\\","\")),vardesc With "Directorul firmei"

	Loca For Allt(Lower(varname))='fscurt'
	If !Found()
		Appe Blan
	Endif
	Repl varname With 'fscurt',Vartype With "CHARACTER",varvalue With ALLTRIM(nfscurt),vardesc With "Directorul firmei"


	Loca For Allt(Lower(varname))='caletempo'
	If !Found()
		Appe Blan
	Endif
	Repl varname With 'caletempo',Vartype With "CHARACTER",varvalue With Addbs(Strtran(ALLTRIM(loc)+"\"+ALLTRIM(nfscurt)+"\tempo\","\\","\")),vardesc With "Directorul \temp\firma\tempo"

	Loca For Allt(Lower(varname))='caletemp'
	If !Found()
		Appe Blan
	Endif
	Repl varname With 'caletemp',Vartype With "CHARACTER",varvalue With Addbs(ALLTRIM(loc)),vardesc With "Directorul \temp\"

**** OPTIUNI FIRMA

	Select (LCFIS_OPT_F)

	LOCATE FOR LOWER(ALLTRIM(varname))='campsectie'
	If !Found()
		Appe Blan
		Repl varname With 'CampSectie',Vartype With "LOGICAL",varvalue With "T",vardesc With "Daca se introduce campul 'sectie'"
	ENDIF
	
	LOCATE FOR LOWER(ALLTRIM(varname))='imobindependent'
	If !Found()
		Appe Blan
		Repl varname With 'ImobIndependent',Vartype With "LOGICAL",varvalue With "F",vardesc With "Daca Imob independent de Cont"
	ENDIF
	
	LOCATE FOR LOWER(ALLTRIM(varname))='dataron'
	If !Found()
		Appe Blan
		Repl varname With 'dataRON',Vartype With "CHARACTER",varvalue With "07-2005",vardesc With "Data trecerii la leul greu"
		lcDataRon = [07-2005]
	ELSE 
		lcDataRon = ALLTRIM(varvalue)
	ENDIF

*!*		IF 12*VAL(SUBSTR(lcDataRon,4,4))+VAL(LEFT(lcDataRon,2))  <= 12*VAL(m.an)+VAL(m.nl)
*!*			lnValue = 2
*!*		ELSE 
*!*			lnValue = 0
*!*		ENDIF 
*!*		PUBLIC gnz
*!*		gnz=lnValue		
	
lnnr_fis=3
Dimension a[lnnr_fis]
a[1]=LCFIS_OPT_P
a[2]=LCFIS_OPT_F
a[3]=LCFIS_OPT_L
*!*	a[4]=LCFIS_OPT_FL

For i=1 To lnnr_fis
	*-- DECLAR VARIABILELE PUBLICE SI LE INITIALIZEZ ex: pcEroriPath,pcServerPath
	lcfis=a[i]

	Select(lcfis)
	Scan For !Empty(varname)
		lcvarname = Alltrim(&LCFIS..varname)
		lcvartype = Upper(Alltrim(&LCFIS..Vartype))
		Do Case
			Case lcvartype = "CHARACTER"
				Public gc&lcvarname.
				luvarvalue = Alltrim(&LCFIS..varvalue)
				gc&lcvarname. = luvarvalue
			Case lcvartype = "CURRENCY"
				Public gy&lcvarname.
				luvarvalue = Ntom(Val(&LCFIS..varvalue))
				gy&lcvarname. = luvarvalue
			Case lcvartype = "NUMERIC"
				Public gn&lcvarname.
				luvarvalue = Val(&LCFIS..varvalue)
				gn&lcvarname. = luvarvalue
			Case lcvartype = "DATETIME"
				Public gt&lcvarname.
				luvarvalue = Ctot(&LCFIS..varvalue)
				gt&lcvarname. = luvarvalue
			Case lcvartype = "DATE"
				Public gd&lcvarname.
				luvarvalue = Ctod(&LCFIS..varvalue)
				gd&lcvarname. = luvarvalue
			Case lcvartype = "LOGICAL"
				Public gl&lcvarname.
				luvarvalue = Iif(Inlist(Upper(Left(&LCFIS..varvalue, 1)), "T", "Y"), .T., .F.)
				gl&lcvarname. = luvarvalue
			Otherwise
				pcmsgbuff = "Tip de variabila globala invalid!"
				pcmsgbuff = pcmsgbuff + Chr(13) + Chr(13) + "Numele variabilei: " + lcvarname
				pcmsgbuff = pcmsgbuff + Chr(13) + "Tipul variabilei: " + lcvartype
				pcmsgbuff = pcmsgbuff + Chr(13) + Chr(13) + "Contactati suportul tehnic."
				=Messagebox(pcmsgbuff, 48)
				pcmsgbuff = ""
		Endcase
	Endscan
Endfor

PUBLIC gnZ, gnPcurs, gnPpret

IF 12*VAL(SUBSTR(gcDataRon,4,4))+VAL(LEFT(gcDataRon,2))  <= 12*VAL(m.an)+VAL(m.nl)
	IF 12*VAL(SUBSTR(gcDataRon,4,4))+VAL(LEFT(gcDataRon,2))  = 12*VAL(m.an)+VAL(m.nl) AND !verific_rolronsnr(gcCalefirma)
		lnValue = 0
		gnPcurs = 0
	ELSE
		lnValue = 2
		gnPcurs = 4
	ENDIF 	
ELSE 
	lnValue = 0
	gnPcurs = 0
ENDIF 	
gnPpret = 3
gnZ=lnValue

IF !EMPTY(lcOldAlias)
	Select (lcOldAlias)
ENDIF 
