
FUNCTION zile_supl(tnIdMes)
	LOCAL lnzilesupl,lnIdMes
	lnzilesupl = 0
	lcIdMes = ALLTRIM(STR(tnIdMes))

	lcSQl = [select s.zilesupl_co from ] + gcs + [.sal_vnom_mes s where s.id_meseria =] + lcIdMes
	lcCursor = 'v_mes'
	lnSucces = goExecutor.oExecute(lcSQl,lcCursor)

	IF lnSucces < 0
		MESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
		RETURN lnzilecuv
	ENDIF
	SELECT v_mes
	lnzilesupl = v_mes.zilesupl_co

	RETURN lnzilesupl


	****************************************************************************************************


PROCEDURE viz_pers
	LOCAL llEroare
	llEroare = .F.
	PRIVATE poper,pcschema1,pcselect1,pcfiltru1,pcorder1				&&personal
	STORE '' TO poper,pcschema1,pcselect1,pcfiltru1,pcorder1

	pcschema1 =['nr n(10),id_salariat n(10),nume c(50),prenume c(50),marca n(10),codpers c(30),judet c(32),localitate c(32),sector n(2),'+] + ;
		['strada c(64),numar c(16),bloc c(16),scara c(16),etaj c(4),apart c(10),codpostal n(10),vechimei n(10),modincadr c(32),cmseria c(16),'+] + ;
		['cmnr c(16),locnastere c(32),id_nationalit n(5),cetatenie c(24),biserianr c(30),bieliberat c(32),bidata d,sitmil c(32),livretmil c(32),'+] +;
		['id_profesie n(5),specializ c(32),data_vech d,stareciv n(5),numesot c(32),numetata c(32),numemama c(32),starecivil c(16),id_stat n(10),'+] +;
		['id_meserie n(5),id_formatie n(5),profesia c(64),meseria c(64),formatia c(64),dataang d,datalic d,datasfctr d,'+]+;
		['id_tipctr n(5),tip_contract c(64),id_handicap n(10),handicap c(64),id_cas n(10),'+]+;
		['grupacas c(64),id_caseasig n(10), casaasig c(64),nrctrm n(10),datactrm d,nrctr n(10),datactr d,gradmil c(32),specmil c(32),tarifar n(16,4),'+]+;
		['SECTIE c(30),fractie n(1),orenorm n(1),plcas n(1),plsomaj n(1),pensionar n(1),plimpozit n(1),functiebaza n(1),cod c(10),'+]+;
		['id_clasasal n(5),contiban c(50),vechime n(10),id_banca n(5),banca c(64),c_vechime n(5,3),in_tura n(1),'+] + ;
		['id_judet n(10),id_loc n(10),id_part n(10),id_modlic n(2),modlic c(64),motivlic c(128),biseria c(2),binr c(8),'+]+;
		['nationalitate c(64),id_cetatenie n(3),id_tip_act n(3),tip_act c(64),id_sectie n(5),elev n(1),zilecofix n(3),somaj_tehnic n(1), datast1 d, datast2 d,stare_contract n(1),'+]+;
		['datainceputs d,datasfarsits d,dataincetares d,id_parts n(10),denumires c(250),id_taras n(10),taras c(250),codcetatenie c(50),'+] + ;
		['id_temeis n(10),explicaties c(250),id_tipautorizatie n(10),tipautorizatie c(250),datainceputautorizatie d,datasfarsitautorizatie d,id_stare_ctr n(10),'+]+;
		['id_tip_norma n(10),nume_tip_norma c(200),id_durata_munca n(10),nume_durata_munca c(200),'+]+;
		['id_repartizare_munca n(10),nume_repartizare_munca c(200),id_interval_munca n(10),nume_interval_munca c(200),id_sal_ctr n(10),id_tipapatrid n(3),apatrid c(48),codapatrid c(24),'+]+;
		['cassalmin n(1),scutireimpozit c(250),oug114 n(1),studiisup n(1), sc_general c(100),sc_prof c(100),licprofil c(100),licspec c(100),sc_maistri c(100),sc_post c(100),'+]+;
		['specializare c(100),codacc c(32),telefon c(32),codcod c(32),nrctrmchr c(64)']
	pcselect1 = ['select 0000000000,id_salariat,nume ,prenume ,marca ,codpers ,judet ,localitate ,sector,strada,numar,bloc,scara,etaj,'+] + ;
		['apart ,codpostal ,vechimei ,modincadr,cmseria ,cmnr ,locnastere ,id_nationalit ,cetatenie ,biserianr ,'+] + ;
		['bieliberat ,bidata ,sitmil ,livretmil ,id_profesie ,specializ ,data_vech ,stareciv,numesot,numetata,'+] + ;
		['numemama,starecivil,id_stat,id_meserie,id_formatie,profesia,meseria,formatia,dataang,datalic,datasfctr,'+]+;
		['id_tipctr,tip_Contract,id_handicap,handicap,id_cas,'+]+;
		['grupacas,id_caseasig,casaasig,nrctrm,datactrm,nrctr,datactr,gradmil,specmil,tarifar,sectie,fractie,orenorm,plcas,plsomaj,'+] +;
		['pensionar,plimpozit,functiebaza,cod,id_clasasal,contiban,vechime,id_banca,banca,c_vechime,in_tura,'+] +;
		['id_judet,id_loc,id_part,id_modlic,modlic,motivlic,biseria,binr,nationalitate,id_cetatenie,id_tip_act,tip_act,id_sectie,elev,zilecofix,'+]+;
		['somaj_tehnic,datast1,datast2,stare_contract,datainceputs,datasfarsits,dataincetares,id_parts,denumires,id_taras,taras,codcetatenie,id_temeis,explicaties,'+]+;
		['id_tipautorizatie,tipautorizatie,datainceputautorizatie,datasfarsitautorizatie,id_stare_ctr,'+]+;
		['id_tip_norma,nume_tip_norma,id_durata_munca,nume_durata_munca,'+]+;
		['id_repartizare_munca,nume_repartizare_munca,id_interval_munca,nume_interval_munca,id_sal_ctr,id_tipapatrid,apatrid,codapatrid,'+]+;
		['cassalmin ,scutireimpozit,oug114+1 as oug114,studiisup, sc_general,sc_prof,licprofil,licspec,sc_maistri,sc_post,specializare,codacc,telefon,codcod,nrctrmchr   '+]+;
		[' from ] + gcs + [.sal_vnom_pers where 1=2']

	pcorder1=[nume,prenume]
	pcfiltru1 = [1=2]
	llAfiseaza = .F.

	gencursor('poper','v_personal',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
	poper.ca_baza1.afisare()

	SELECT v_personal
	SCATTER NAME popers
	SCATTER NAME popers_orig		&&	modificare v 2.0.0
	*******************************************************
	*!*	modificare	v 2.0.8
	lcSQl = [select id_tip_norma,nume_tip_norma from syn_sal_nom_tip_norme]
	lnSucces = goExecutor.oExecute(lcSQl,[crsnomtipn])
	IF lnSucces < 0
		amessagebox(goExecutor.cEroare,16,"Eroare")
		llEroare = .T.
	ENDIF

	lcSQl = [select id_durata_munca,nume_durata_munca,id_tip_norma from syn_sal_nom_durata_munca ] + ;
		[where NVL(data_inactiv,to_date('209912','YYYYMM')) > to_date('] + ALLTRIM(STR(gnAn)) + ALLTRIM(STR(gnLuna)) + [','YYYYMM')]
	lnSucces = goExecutor.oExecute(lcSQl,[crsnomduratam])
	IF lnSucces < 0
		amessagebox(goExecutor.cEroare,16,"Eroare")
		llEroare = .T.
	ENDIF

	lcSQl = [select id_repartizare_munca,nume_repartizare_munca from syn_sal_nom_repartizare_munca ] + ;
		[where NVL(data_inactiv,to_date('209912','YYYYMM')) > to_date('] + ALLTRIM(STR(gnAn)) + ALLTRIM(STR(gnLuna)) + [','YYYYMM')]
	lnSucces = goExecutor.oExecute(lcSQl,[crsnomrepartm])
	IF lnSucces < 0
		amessagebox(goExecutor.cEroare,16,"Eroare")
		llEroare = .T.
	ENDIF

	lcSQl = [select id_interval_munca,nume_interval_munca from syn_sal_nom_intervale_munca ] + ;
		[where NVL(data_inactiv,to_date('209912','YYYYMM')) > to_date('] + ALLTRIM(STR(gnAn)) + ALLTRIM(STR(gnLuna)) + [','YYYYMM')]
	lnSucces = goExecutor.oExecute(lcSQl,[crsnomintm])
	IF lnSucces < 0
		amessagebox(goExecutor.cEroare,16,"Eroare")
		llEroare = .T.
	ENDIF
	*!*	modificare	v 2.0.8	^
	*******************************************************

	PRIVATE pointr,pcschema2,pcselect2,pcfiltru2,pcorder2				&&persoane in intretinere
	STORE '' TO pointr,pcschema2,pcselect2,pcfiltru2,pcorder2

	pcschema2 = []
	pcselect2 = ['select * from ] + gcs + [.sal_vintret where 1=2']
	pcfiltru2 = [id_persoana = ] + ALLTRIM(STR(popers.id_salariat))
	pcorder2=[nume,prenume]
	llAfiseaza = .F.

	gencursor('pointr','v_nom_intret',pcselect2,pcfiltru2,pcschema2,pcorder2,llAfiseaza)
	pointr.ca_baza1.afisare()
	*******************************************************

	PRIVATE pocop,pcschema3,pcselect3,pcfiltru3,pcorder3				&&copii
	STORE '' TO pocop,pcschema3,pcselect3,pcfiltru3,pcorder3

	pcschema3 = ['nume c(64),prenume c(64),codpers n(13),datanast d,id_copil n(5),id_persoana n(10)']
	pcselect3 = ['select nume,prenume,codpers,datanast,id_copil,id_persoana from ] + gcs + [.sal_vcopii where 1=2']
	pcfiltru3 = [id_persoana = ] + ALLTRIM(STR(popers.id_salariat))
	pcorder3=[nume,prenume]
	llAfiseaza = .F.

	gencursor('pocop','v_copii',pcselect3,pcfiltru3,pcschema3,pcorder3,llAfiseaza)
	pocop.ca_baza1.afisare()

	*******************************************************

	PRIVATE pobazacm,pcschema4,pcselect4,pcfiltru4,pcorder4					&&baza_cm
	STORE '' TO pobazacm,pcschema4,pcselet4,pcfiltru4,pcorder4

	pcschema4 = []
	pcselect4 = ['select * from ] + gcs + [.sal_vbaze_cm where 1=2']
	pcfiltru4 = [id_stat = ] + ALLTRIM(STR(popers.id_stat))
	pcorder4  = [an*12+luna]
	llAfiseaza = .f.

	gencursor('pobazacm','v_bazacm',pcselect4,pcfiltru4,pcschema4,pcorder4,llAfiseaza)
	pobazacm.ca_baza1.afisare()
	*******************************************************

	PRIVATE pocalif,pcschema5,pcselect5,pcfiltru5,pcorder5					&&limbi straine
	STORE '' TO pocalif,pcschema5,pcselect5,pcfiltru5,pcorder5
	pcschema5=[]
	pcselect5=['select * from ] + gcs + [.sal_vnom_limbi where 1=2']
	pcfiltru5 = [id_persoana = ] + ALLTRIM(STR(popers.id_salariat))
	pcorder5 = [denumire]
	llAfiseaza = .f.

	gencursor('pocalif','v_calif',pcselect5,pcfiltru5,pcschema5,pcorder5,llAfiseaza)
	pocalif.ca_baza1.afisare()
	*******************************************************

	PRIVATE pocurs,pcschema6,pcselect6,pcfiltru6,pcorder6					&&cursuri calificare
	STORE '' TO pocurs,pcschema6,pcselect6,pcfiltru6,pcorder6
	pcschema6 =  ['id_curs n(5),data d,nota c(16),test c(64),id_persoana n(5),id_c n(5)'+] + ;
		[',sters n(1), denumire c(64)']
	pcselect6 = ['select c.id_curs,c.data,c.nota,c.test,c.id_persoana,c.id_c'+] + ;
		[',c.sters,c.denumire from ] + gcs + [.sal_vcurs c where 1=2']
	pcfiltru6 = [id_persoana = ] + ALLTRIM(STR(popers.id_salariat))
	pcorder6 = [denumire]
	llAfiseaza = .f.

	gencursor('pocurs','v_curs_calif',pcselect6,pcfiltru6,pcschema6,pcorder6,llAfiseaza)
	pocurs.ca_baza1.afisare()

	*******************************************************

	PRIVATE postud,pcschema7,pcselect7,pcfiltru7,pcorder7					&&studii
	STORE '' TO postud,pcschema7,pcselect7,pcfiltru7,pcorder7
	pcschema7=[]
	pcselect7=['select * from ] + gcs + [.sal_studii where 1=2']
	pcfiltru7 = [id_persoana = ] + ALLTRIM(STR(popers.id_salariat)) + [ and sters=0]
	pcorder7 = [scoala]
	llAfiseaza = .f.

	gencursor('postud','v_studii',pcselect7,pcfiltru7,pcschema7,pcorder7,llAfiseaza)
	postud.ca_baza1.afisare()
	*******************************************************

	PRIVATE poechip,pcschema8,pcselect8,pcfiltru8,pcorder8					&&echipament (optional)
	STORE '' TO poechip,pcschema8,pcselect8,pcfiltru8,pcorder8
	pcschema8=[]
	pcselect8=['select * from ] + gcs + [.sal_vechip where 1=2']
	pcfiltru8 = [id_part = ] + ALLTRIM(STR(popers.id_part))
	pcorder8 = [numar]
	llAfiseaza = .f.

	gencursor('poechip','v_echip',pcselect8,pcfiltru8,pcschema8,pcorder8,llAfiseaza)
	poechip.ca_baza1.afisare()
	*******************************************************


	PRIVATE poact,pcschema9,pcselect9,pcfiltru9,pcorder9					&&acte aditionale
	STORE '' TO poact,pcschema9,pcselect9,pcfiltru9,pcorder9
	pcschema9=[]
	pcselect9=['select * from ] + gcs + [.sal_vjurnal_contracte where 1=2']
	pcfiltru9 = [angajatid = ] +ALLTRIM(STR(VAL(popers.codpers),13))
	pcorder9 = []
	llAfiseaza = .f.

	gencursor('poact','v_jurnal',pcselect9,pcfiltru9,pcschema9,pcorder9,llAfiseaza)
	poact.ca_baza1.afisare()
	*******************************************************                 &&documente atasate
	PRIVATE poatas,pcschema10,pcselect10,pcfiltru10,pcoreder10
	STORE '' TO poatas,pcschema10,pcselect10,pcfiltru10,pcoreder10
	pcschema10=[]
	pcselect10=['select * from ]+ gcs + [.sal_vatasamente where 1=2']
	pcfiltru10=[id_persoana = ] + ALLTRIM(STR(popers.id_salariat)) + [ and sters=0]
	pcorder10= []
	llAfiseaza=.f.
	gencursor('poatas','v_atas',pcselect10,pcfiltru10,pcschema10,pcorder10,llAfiseaza)
	poatas.ca_baza1.afisare()
	************************************************************
		*******************************************************

	PRIVATE poavize,pcschema11,pcselect11,pcfiltru11,pcorder11					&&avize
	STORE '' TO poavize,pcschema11,pcselet11,pcfiltru11,pcorder11


	pcschema11 = ['aviz c(64),data1 d,data2 d,id_aviz n(5),id_persoana n(5)']
	pcselect11 = ['select aviz,data1,data2,id_aviz,id_persoana from ] + gcs + [.sal_avize where 1=2']
	pcfiltru11 = [id_persoana = ] + ALLTRIM(STR(popers.id_salariat))+[ and sters = 0]
	pcorder11  = [data2 desc]
	llAfiseaza = .f.

	gencursor('poavize','v_avize',pcselect11,pcfiltru11,pcschema11,pcorder11,llAfiseaza)
	poavize.ca_baza1.afisare()
	*******************************************************
			*******************************************************

	PRIVATE poCalendar,pcschema12,pcselect12,pcfiltru12,pcorder12,pnCalendarOug114					&&sal_calendar
	STORE '' TO poCalendar,pcschema12,pcselect12,pcfiltru12,pcorder12


	pcschema12 = ['oug114_2018 n(1)']
	pcselect12 = ['select oug114_2018 from sal_calendar where 1=2']
	pcfiltru12 = [luna = pack_sesiune.getluna() and an = pack_sesiune.getan()]
	pcorder12  = []
	llAfiseaza = .f.

	gencursor('poCalendar','v_calendar',pcselect12,pcfiltru12,pcschema12,pcorder12,llAfiseaza)
	poCalendar.ca_baza1.afisare()
	SELECT v_calendar
	pnCalendarOug114 = NVL(v_calendar.oug114_2018,0)
	pnCalendarOug114 = NVL(pnCalendarOug114,0)
	*******************************************************
	update_hand()
	EXTERNAL ARRAY tasc
	DIMENSION tasc[1,1]
	tasc = caut_alfa_beta('v_personal','nume:C;marca:N:0:999999999;formatia:C;codpers:C;tarifar:N:0:999999999;meseria:C',1)   	&&cautare noua

	EXTERNAL ARRAY taSqlReg		&&array registru salariati
	DIMENSION taSqlReg[7]

	SELECT v_personal

	***********************************************variabile_registru*************************************
	*!*	modificare ROARES v 1.0.49 : am adaugat si campul datactr
	SCATTER NAME poRegAms FIELDS id_meserie,; &&meserie
	datalic,;	  &&incetare contract
	dataang,datasfctr,fractie,id_tipctr,; &&Tipul Contractului
	nrctr,datactr,nrctrm,datactrm,; &&Numar/Data Contract
	id_sectie,; && Loc de munca
	nume,prenume,id_cetatenie,id_nationalit,id_tip_act,; &&date personale
	codpers,cmseria,cmnr,id_loc,strada,numar,bloc,scara,etaj,apart blank

	***********************************************variabile_registru*************************************
	If !llEroare
		opers = Createobject('frm_opersonal')
		opers.WindowState=2
		opers.clienttoptabs1._container1.lblHeader.Caption=Alltrim(Str(popers.marca)) + " - " + Alltr(popers.nume)+" " +Alltr(popers.prenume)
		opers.Show(1)
		Release opers
	Endif
	RELEASE pcschema1, pcselect1
	IF USED('v_hand')
		USE IN v_hand
	ENDIF
	IF USED('v_personal')
		USE IN v_personal
	ENDIF
	IF USED('v_copii')
		USE IN v_copii
	ENDIF
	IF USED('v_nom_intret')
		USE IN v_nom_intret
	ENDIF
	IF USED('v_bazacm')
		USE IN v_bazacm
	ENDIF
	IF USED('v_calif')
		USE IN v_calif
	ENDIF
	IF USED('v_studii')
		USE IN v_studii
	ENDIF
	IF USED('v_curs_calif')
		USE IN v_curs_calif
	ENDIF
	IF USED('v_dif_part')
		USE IN v_dif_part
	ENDIF
	IF USED('v_echip')
		USE IN v_echip
	ENDIF
	IF USED('v_jurnal')
		USE IN v_jurnal
	ENDIF
	IF USED('crsModlic')
		USE IN crsModlic
	ENDIF
	IF USED('crsTemei')
		USE IN crsTemei
	ENDIF
	*!*	modificare	ROARES v 2.0.8
	IF USED('crsnomtipn')
		USE IN crsnomtipn
	ENDIF
	IF USED('crsnomduratam')
		USE IN crsnomduratam
	ENDIF
	IF USED('crsnomrepartm')
		USE IN crsnomrepartm
	ENDIF
	IF USED('crsnomintm')
		USE IN crsnomintm
	ENDIF
	*!*	modificare	ROARES v 2.0.8	^
	IF USED('v_calendar')
		USE IN v_calendar
	ENDIF 
ENDPROC


**********************************************************
PROCEDURE update_dedsupl

	If Used('v_dedsupl')
		Use In v_dedsupl
	Endif

	lcSQl = [select * from ] + gcs + [.sal_vnom_dedsupl]
	lcCursor = [v_dedsupl]
	lnSucces = goExecutor.oExecute(lcSQl,lcCursor)
	goExecutor.oReset()

	Return lnSucces

ENDPROC

**********************************************************


*!*	PROCEDURE update_hand

*!*	If Used('v_hand')
*!*		Use In v_hand
*!*	Endif

*!*	lcSql = [select * from ] + gcS + [.sal_vnom_handicap]
*!*	lcCursor = [v_hand]
*!*	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
*!*	goExecutor.oReset()

*!*	Return lnSucces

*!*	ENDPROC

**********************************************************
PROCEDURE update_mes

	If Used('v_meseria')
		Use In v_meseria
	Endif

	lcSQl = [select * from ] + gcs + [.sal_vnom_mes]
	lcCursor = [v_meseria]
	lnSucces = goExecutor.oExecute(lcSQl,lcCursor)
	goExecutor.oReset()

	Return lnSucces

ENDPROC

********************************************************
PROCEDURE update_form

	If Used('v_formatia')
		Use In v_formatia
	Endif

	lcSQl = [select * from ] + gcs + [.sal_vnom_formatii]
	lcCursor = [v_formatia]
	lnSucces = goExecutor.oExecute(lcSQl,lcCursor)
	goExecutor.oReset()

	Return lnSucces

ENDPROC

**************************************************************
PROCEDURE update_limbi

	If Used('v_limba')
		Use In v_limba
	Endif

	lcSQl = [select * from ] + gcs + [.sal_vnom_limb]
	lcCursor = [v_limba]
	lnSucces = goExecutor.oExecute(lcSQl,lcCursor)
	goExecutor.oReset()

	Return lnSucces

ENDPROC

****************************************************
******************************************* INCEPUT: caut_limba *******************************************
Procedure caut_limba
	Lparameters tlNou
	Local loHash, loCauta
	loHash = GetHash()
	With loHash
		.SetValue("cSelect", [select * from sal_vnom_limb])
		.SetValue("cOrder", "denumire")
		.SetValue("cColoana", "denumire,id_limba")
		.SetValue("cTitlu", "Alegeti limba straina")
		.SetValue("cTitluColoana", "Denumire,Id_limba")
		.SetValue("cFiltruOriginal", "2=2")
		.SetValue("cFiltru", "2=2")
		If tlNou
			.SetValue("cNumeProc", "nom_limbi")
		Endif
	Endwith
	loCauta = cauta_alfa_hash(loHash)
	Return Iif(gnButon = 2, Null, loCauta)
Endproc && caut_limba
***************************************** SFARSIT: caut_limba*******************************************
******************************************* INCEPUT: caut_limba *******************************************
Procedure caut_curs
	Lparameters tlNou
	Local loHash, loCauta
	loHash = GetHash()
	With loHash
		.SetValue("cSelect", [select * from sal_vnom_curs])
		.SetValue("cOrder", "denumire")
		.SetValue("cColoana", "denumire,id_c")
		.SetValue("cTitlu", "Alegeti cursul")
		.SetValue("cTitluColoana", "Denumire,Id_curs")
		.SetValue("cFiltruOriginal", "2=2")
		.SetValue("cFiltru", "2=2")
		If tlNou
			.SetValue("cNumeProc", "nom_cursuri")
		Endif
	Endwith
	loCauta = cauta_alfa_hash(loHash)
	Return Iif(gnButon = 2, Null, loCauta)
Endproc && caut_limba
***************************************** SFARSIT: caut_limba*******************************************

PROCEDURE update_curs

	If Used('v_curs')
		Use In v_curs
	Endif

	lcSQl = [select * from ] + gcs + [.sal_vnom_curs]
	lcCursor = [v_curs]
	lnSucces = goExecutor.oExecute(lcSQl,lcCursor)
	goExecutor.oReset()

	Return lnSucces

ENDPROC

****************************************************

PROCEDURE update_stud

	If Used('v_stud')
		Use In v_stud
	Endif

	lcSQl = [select * from ] + gcs + [.sal_vnom_stud]
	lcCursor = [v_stud]
	lnSucces = goExecutor.oExecute(lcSQl,lcCursor)
	goExecutor.oReset()

	Return lnSucces

ENDPROC

*******************************************
* PROCEDURE proc_sitco(  )
* Date : 11/17/05, 15:00:59
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
*******************************************
PROCEDURE proc_sitco(  )
	ofrm_list_avans = CREATEOBJECT('frm_list_stat')
	ofrm_list_avans.clistare = [sitco]
	ofrm_list_avans.lb_titlu_alb_b121.caption = 'LISTARE PRIME'
	ofrm_list_avans.show(1)

ENDPROC
*----------------------------------sfarsit procedura proc_sitco----------------------------------


*********************************INCEPUT REDESCHIDERE LUNA***********************************************
PROCEDURE redeschidere_comun

	PRIVATE oredes

	buton = 2


	EXTERNAL ARRAY taOpt
	DIMENSION taOpt[10] &&1 - tip redeschidere,2-state,3-pontaje,4-persintret,5-popriri,6-sporuri,7-co
	taOpt[1]=1
	FOR i=2 TO 10
		taOpt[i]=1
	ENDFOR

	oredes = CREATEOBJECT('frm_redeschidere',@taOpt)
	if gcAppName = "ROARES"
		oredes.redOpt.option1.Enabled=.f.
		oredes.page_detalii.page1.Enabled=.f.
	ENDIF 
	oredes.show(1)
	RELEASE oredes

	IF buton = 2
		RETURN
	ENDIF

	IF amessagebox('Doriti sa redeschideti luna '+ALLTRIM(STR(gnLuna)) + '/'+ALLTRIM(STR(gnAn)) +' ?',4+32,'Confirmare')=7
		RETURN
	ENDIF

	LOCAL lcOpt
	lcOpt=''
	FOR i=2 TO 10
		lcOpt = lcOpt+ALLTRIM(STR(taOpt[i]))+';'
	ENDFOR
	IF taOpt[1]=2
		taOpt[1]=0
	ENDIF
	WAIT WINDOW "Asteptati, se redeschide luna... " NOWAIT

	*!*	modificare	v 2.0.22 : am modificat apelul din redeschidere_sal in redeschidere_sal_audit
	lcSQl = [begin PACK_SALARII.redeschidere_sal_audit('] + gcs +[',]+ALLTRIM(STR(taOpt[1]))+[,']+lcOpt+[',]+;
		ALLTRIM(STR(gnAn))+[,]+ALLTRIM(STR(gnLuna))+[); end;]
	If goExecutor.oExecuta(lcSQl)
		amessagebox('Redeschiderea s-a incheiat!',48,'Redeschidere luna')
	Endif
ENDPROC
*********************************SFARSIT REDESCHIDERE LUNA***********************************************
PROCEDURE sal_modlic_nou

	PRIVATE pomodlic,pcschema1,pcselect1
	STORE '' TO pomodlic
	pcschema1 = ['']
	pcselect1=['select * from ] + gcs + [.sal_nom_modlic where 1=2']
	pcorder1=[modlic]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('pomodlic','v_modlic_nou',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
	pomodlic.ca_baza1.afisare()
	***
	SELECT v_modlic_nou
	SCATTER NAME loRec BLANK
	DO Adauga_Modifica_Inregistrare WITH 'modlic',loRec,,"INSERT"
	USE IN v_modlic_nou

ENDPROC
*************************************************************
***======================================================================================

PROCEDURE sal_tipctr_nou

	PRIVATE poctr,pcschema1,pcselect1

	STORE '' TO poctr
	pcschema1 = ['']
	pcselect1=['select * from ] + gcs + [.sal_nom_tipctr where 1=2']
	pcorder1=[tip_contract]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('poctr','v_ctr_nou',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
	poctr.ca_baza1.afisare()
	***

	Do update_ore In update_roadef_sal.prg
	SELECT v_ctr_nou
	SCATTER NAME loRec BLANK
	ADDPROPERTY(loRec,'ore','')
	DO Adauga_Modifica_Inregistrare WITH 'tipctr',loRec,,"INSERT"
	USE IN v_ctr_nou
	USE IN v_nomore


ENDPROC
***======================================================================================
FUNCTION verifica_adaugare_parteneri
	LPARAMETERS tnTip		&&parametru diferit de 1 = inchid cursor
	LOCAL lflag
	lflag=.f.
	IF TYPE('podif')='U'		&&verific variabila ( doar in cazul apelarii cu parametru)
		PRIVATE podif
		STORE '' TO podif
	ENDIF
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcs + [.sal_vdif_part where 1=1']
	lcCursor = [v_dif_part]
	pcorder1 = [nume,prenume]
	pcfiltru1 = [nume is not null]
	llAfiseaza = .f.
	gencursor('podif','v_dif_part',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
	podif.ca_baza1.afisare()
	IF RECCOUNT('v_dif_part')>0
		lflag=.t.
		SELECT v_dif_part
		replace ALL nr WITH RECNO()
		GO TOP
	ENDIF
	IF PCOUNT()=1
		USE IN v_dif_part
		RELEASE podif
	ENDIF

	RETURN lflag

	****************************************************
	***======================================================================================
PROCEDURE res_adauga_parteneri

	pcschema1 = ['']
	pcselect1 = ['select id_part,nume,cod_fiscal,reg_comert,prenume,strada,numar,bloc,scara,etaj,'+] +;
		['apart,id_loc,localitate,judet,id_judet,000000 as nr,id_adresa from ] + gcs + [.vnom_parteneri where 1=1']
	lcCursor = [v_dif_part]
	pcorder1 = [nume,prenume]
	pcfiltru1 = [1=2]
	llAfiseaza = .t.
	gencursor('podif','v_dif_part',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
	podif.ca_baza1.afisare()

ENDPROC

****************************************************

PROCEDURE update_echip

	If Used('v_echipament')
		Use In v_echipament
	Endif

	lcSQl = [select * from ] + gcs + [.sal_vnecesar]
	lcCursor = [v_echipament]
	lnSucces = goExecutor.oExecute(lcSQl,lcCursor)
	goExecutor.oReset()

	Return lnSucces

ENDPROC

****************************************************
PROCEDURE conditii_articole

	PRIVATE pocond,pcschema1,pcselect1,pcfiltru1,pcorder1					&&Conditii din nomenclator
	STORE '' TO pocond,pcschema1,pcselect1,pcfiltru1,pcorder1

	pcschema1 = ['']
	pcselect1 = ['select id_conditie,denumire,conditie,00000 as nr from ] + gcs + [.sal_vnom_cond where 1=1']
	lcCursor = [v_conditii]
	pcorder1 = [denumire]
	pcfiltru1 = [2=2]
	llAfiseaza = .t.
	gencursor('pocond',lcCursor,pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
	pocond.ca_baza1.afisare()
	IF RECCOUNT('v_conditii')>0
		SELECT v_conditii
		replace ALL nr WITH RECNO()
		GO TOP
	ENDIF
	SELECT v_conditii
	SCATTER NAME poconditii MEMO

	EXTERNAL ARRAY taCompun   && pt compunere conditie
	DIMENSION taCompun[1,3]

	EXTERNAL ARRAY taElemente
	DIMENSION taElemente[4,5] &&1 - camp,2-Descriere camp,3-Camp Id,4-Valoare camp Id,5-Tabela
	taElemente[1,1] = 'Sectia'
	taElemente[1,2] = 'sectie'
	taElemente[1,3] = 'id_sectie'
	taElemente[1,5] = 'vnom_sectii'

	taElemente[2,1] = 'Formatia'
	taElemente[2,2] = 'denumire'
	taElemente[2,3] = 'id_formatia'
	taElemente[2,5] = 'sal_vnom_formatii'

	taElemente[3,1] = 'Meseria'
	taElemente[3,2] = 'meserie'
	taElemente[3,3] = 'id_meseria'
	taElemente[3,5] = 'sal_vnom_mes'

	taElemente[4,1] = 'Sex'
	taElemente[4,2] = 'sex'
	taElemente[4,3] = ':distinct'
	taElemente[4,5] = 'sal_vstat'



	PRIVATE poart,pcschema2,pcselect2,pcfiltru2,pcorder2					&&Articole
	STORE '' TO poart,pcschema2,pcselect2,pcfiltru2,pcorder2
	pcschema2 =  ['']
	pcselect2 = ['select c.id_nec,c.id_articol,c.id_conditie,c.denumire,c.articol,c.codmat,c.um,c.cantitate'+] + ;
		[' from sal_vcond_echip c where 1=2']
	pcfiltru2 = [id_conditie = ] + ALLTRIM(STR(v_conditii.id_conditie))
	pcorder2 = [articol]
	llAfiseaza = .t.

	gencursor('poart','v_articole',pcselect2,pcfiltru2,pcschema2,pcorder2,llAfiseaza)
	poart.ca_baza1.afisare()


	PRIVATE poper,pcschema3,pcselect3,pcfiltru3,pcorder3					&&Persoane
	STORE '' TO poper,pcschema3,pcselect3,pcfiltru3,pcorder3
	pcschema3 =  ['']
	pcselect3 = ['select s.id_part,s.marca,s.nume,s.prenume from sal_vstat s '+] + ;
		[' where 1=2']
	pcfiltru3 = [1=2]
	pcorder3 = [nume,prenume]
	llAfiseaza = .t.

	gencursor('poper','v_pers',pcselect3,pcfiltru3,pcschema3,pcorder3,llAfiseaza)
	poper.ca_baza1.afisare()


	PRIVATE poarticole,pcschema4,pcselect4,pcfiltru4,pcorder4					&&Articole
	STORE '' TO poarticole,pcschema4,pcselect4,pcfiltru4,pcorder4
	pcschema4 =  ['']
	pcselect4 = ['select a.id_part,a.articol,a.id_articol from sal_vechip a '+] + ;
		[' where 1=2']
	pcfiltru4 = [1=2]
	pcorder4 = [articol]
	llAfiseaza = .t.

	gencursor('poarticole','v_art_pers',pcselect4,pcfiltru4,pcschema4,pcorder4,llAfiseaza)
	poarticole.ca_baza1.afisare()


	SELECT v_conditii

	ocond = CREATEOBJECT('frm_conditii',@taElemente,@taCompun)
	ocond.show(1)
	RELEASE ocond,poconditii

	IF USED('v_conditii')
		USE IN v_conditii
	ENDIF

ENDPROC

*************************************************
*!*	modificare	v 2.0.3 : am mutat-o in registru.prg
*!*	Procedure registru_unic
*!*		Private pcschema1,pcselect1,pojur
*!*		Store '' To pcschema1,pcselect1,pojur
*!*		*!*	pcschema1 =['dataschimbare d,obiectschimbare c(24),tipoperatie c(1),explicatie c(64),angajat c(128),numar c(12),'+] + ;
*!*		*!*			   ['numaritm c(12),datacontract d,tipcontract n(1),norma n(1),ocupatie c(6),datainceput d,'+] + ;
*!*		*!*			   ['datasfarsit d,dataincetarii d,temeiincetare c(128),datareactivare d,cnp c(13),'+] +;
*!*		*!*		       ['cetatenie c(2),judetangajat c(32),'+] +;
*!*		*!*			   ['localitateangajat c(32),adresaangajat c(255),angajator c(128),cui c(64),judetangajator c(32),'+]+;
*!*		*!*			   ['localitateangajator c(64),adresaangajator c(128)']
*!*		pcschema1 = ['']
*!*		pcselect1 = ['select ales,dataschimbare ,obiectschimbare ,tipoperatie ,explicatie ,angajat ,numar ,'+] + ;
*!*			['numaritm ,datacontract ,tipcontract ,norma ,ocupatie ,datainceput ,'+] + ;
*!*			['datasfirsit ,dataincetarii ,temeiincetare ,datareactivare ,cnp ,'+] + ;
*!*			['cetatenie ,judetangajat,'+]+;
*!*			['localitateangajat ,adresaangajat ,angajator ,cui ,judetangajator ,'+]+;
*!*			['localitateangajator ,adresaangajator,cheie_angajator,cheie_angajat,cheie_ctr  from sal_vregistru_unic where 1=2']
*!*		pcorder1=[]
*!*		pcfiltru1 = [2=2]
*!*		llAfiseaza = .F.

*!*		gencursor('pojur','v_jurnal',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
*!*		pojur.ca_baza1.afisare()


*!*		ojur = Createobject('frm_registru_unic')
*!*		ojur.WindowState=2
*!*		ojur.Show(1)
*!*		Release ojur,pcschema1,pcselect1
*!*	Endproc
*!*	modificare	v 2.0.3	^
*******************************************
* PROCEDURE calcul_sumaore( tnTarifOra, tnNrOre, tnprocent  )
* Date : 09/10/05, 10:47:38
* author : liana.macinic
* description:

****** PARAMETER BLOCK **************
* Parameters : 3
* Parameter 1:
* Parameter 2:
* Parameter 3:
*
*******************************************
PROCEDURE calcul_sumaore( tnTarifOra, tnNrOre, tnprocent)
*!*		IF EMPTY(tnprocent)
*!*			STORE 1 TO tnprocent
*!*		ENDIF

	LOCAL lnSuma

	lnSuma = tnTarifOra * tnNrOre * tnprocent

	RETURN ROUND(lnSuma,2)

ENDPROC
*----------------------------------sfarsit procedura calcul_sumaore----------------------------------
*!*	EndProc
*-------------------------------------------------------------------


	*******************************************
	* PROCEDURE calcul_sumaore( tnTarifOra, tnNrOre, tnprocent  )
	* Date : 09/10/05, 10:47:38
	* author : liana.macinic
	* description:

	****** PARAMETER BLOCK **************
	* Parameters : 3
	* Parameter 1:
	* Parameter 2:
	* Parameter 3:
	*
	*******************************************
	*!*	PROCEDURE calcul_sumaore( tnTarifOra, tnNrOre, tnprocent)
	*!*	IF EMPTY(tnProcent)
	*!*		STORE 1 TO tnProcent
	*!*	ENDIF

	*!*	LOCAL lnSuma

	*!*	lnSuma = tnTarifOra * tnNrOre * tnProcent

	*!*	RETURN ROUND(lnSuma,2)

	*!*	ENDPROC
	*----------------------------------sfarsit procedura calcul_sumaore----------------------------------

PROCEDURE template_configureaza
	LOCAL loFrm
	loFrm = CREATEOBJECT("frm_configurare_doc")
	loFrm.show(1)
	RELEASE loFrm
ENDPROC
******************************************************************************************************
Procedure template_selecteaza
	Lparameters tnTip,tcNume,tnId,tcCond
	Local lcNume, lnId, loRec, lcExplicatie
	If Empty(tcNume) Or Empty(tnId)
		If gnIdProgram = 75
			loCauta = caut_salariat_spec(0)
			If !Isnull(loCauta)
				AddProperty(loCauta,"id_salariat",loCauta.id_colaborator)
			Endif
			lcExplicatie = [colaboratorul]
		Else
			loCauta = caut_salariat()
			lcExplicatie = [salariatul]
		Endif
		Do Case
			Case gnButon = 2 OR ISNULL(loCauta)
				Return
			Case Empty(Nvl(loCauta.id_salariat,0))
				amessagebox("Nu ati ales "+lcExplicatie+"!",16,"Eroare")
				Return
			Otherwise
				lcNume=Alltrim(loCauta.nume)+'_'+Alltrim(loCauta.prenume)
				lnId = loCauta.id_salariat
		Endcase
	Else
		lcNume = tcNume
		lnId = tnId
	Endif
	loRec = template_citeste(tnTip)
	If !Isnull(loRec)
		template_completeaza(loRec,lcNume,lnId,tcCond)
	Endif
	Release lnConf, lcNume, lnId, loRec
Endproc
******************************************************************************************************
Function template_adauga
	Lparameters tnTipDocument,tnTip,tnIdEntitate,tnIdReferinta,tcDescriere,tcNumeFisier,tcCaleFisier
	Local llReturn
	Private pnIdAtas, pcNumeFisier, pcDescriere, pcFisier, pnTipDocument, pnTip, pnIdEntitate, pnIdReferinta
	llReturn = .T.
	If !File(tcCaleFisier)
		amessagebox("Nu exista fisierul "+tcCaleFisier+" !",48,"Atentie")
		llReturn = .F.
	Else
		pnIdAtas = 0
		pcNumeFisier = ALLTRIM(tcNumeFisier)
		pcDescriere = ALLTRIM(tcDescriere)
		pcFisier = Filetostr(tcCaleFisier)
		pnTipDocument = tnTipDocument
		pnTip = tnTip
		pnIdEntitate = tnIdEntitate
		pnIdReferinta = tnIdReferinta
		lnSucces2 = SQLSetprop(gnhandle,"Transactions",2)
		If lnSucces2 < 0
			amessagebox('Programul nu a reusit sa treaca pe tranzactie manuala. Reincercati!',0+48,'Atentie!')
			llReturn = .F.
		Else
			lcSql2 = [COMMIT]
			lcSQl = [insert into atas_atasamente(nume_fisier,descriere,fisier,id_util) ] + ;
				[values (?pcNumeFisier,?pcDescriere,?pcFisier,?gnIdUtil) ] + ;
				[returning id_atas into ?@pnIdAtas]
			lnSucces = goExecutor.oExecute(lcSQl)
			If lnSucces < 0
				amessagebox(goExecutor.cEroare,16,"Eroare")
				llReturn = .F.
				lcSql2 = [ROLLBACK]
			Else
				lcSQl = [begin pack_def.actualizeaza_referinte(?pnTipDocument,?pnTip,?pnIdAtas,] + ;
					[?pnIdEntitate,?pnIdReferinta,?gnIdProgram,?gnIdUtil); end;]
				lnSucces = goExecutor.oExecute(lcSQl)
				If lnSucces < 0
					amessagebox(goExecutor.cEroare,16,"Eroare")
					llReturn = .F.
					lcSql2 = [ROLLBACK]
				Endif
			Endif
			lnSucces2 = goExecutor.oExecute(lcSql2)
			If lnSucces2 < 0
				amessagebox(lcSql2 + Chr(13) + goExecutor.cEroare,0+16,"Eroare")
				llReturn = .F.
			Endif
			lnSucces2 = SQLSetprop(gnhandle,"Transactions",1)
			If lnSucces2 < 0
				amessagebox('Programul nu a reusit sa treaca pe tranzactie automata. Iesiti din program si intrati din nou!',0+48,'Atentie!')
				llReturn = .F.
			Endif
		Endif
	Endif
	Release pnIdAtas, pcNumeFisier, pcDescriere, pcFisier, pnTipDocument, pnTip, pnIdEntitate, pnIdReferinta
	Return llReturn
Endfunc
******************************************************************************************************
Function template_citeste
	Lparameters tnTip
	**	citeste din b.d.
	Private poDocument
	Store "" To poDocument
	Local loRec, lcSQl, lcCursor, lcFiltru, lcSchema, lcOrder, llAfisare, lcView
	lcCursor = [crstemplatedoc]
	If gnIdProgram = 75
		lcView = [sal_vdocumente_ss]		&&	ROASALSPEC	/	75
	Else
		lcView = [sal_vdocumente_ru]		&&	ROARES		/	4
	Endif
	lcSQl = [select NVL(c.fisier,e.fisier) as fisier,a.id_referinta,a.NUME_FISIER from ] + ;
		[(select id_referinta,tip,NUME_FISIER  from ] + lcView + [ where 1=2]
	lcFiltru = [id_referinta = ] + ALLTRIM(STR(tnTip)) + [) a ] + ;
		[left join syn_atas_referinte b on a.id_referinta = b.id_referinta and a.tip = 1 ] + ;
		[left join syn_atas_atasamente c on b.id_atas = c.id_atas ] + ;
		[left join atas_referinte d on a.id_referinta = d.id_referinta and a.tip = 2 ] + ;
		[left join atas_atasamente e on d.id_atas = e.id_atas]
	lcSchema = [fisier W,id_referinta N(10),NUME_FISIER c(200)]
	*!*		lcSql = [select b.descriere,b.nume_fisier,b.fisier,a.id_entitate,a.ordine,b.id_atas,a.id_referinta ] + ;
	*!*			[from (select * from syn_atas_referinte where 1=2 ]
	*!*		lcFiltru = [id_program = ?gnIdProgram and sters = 0 and id_referinta = ] + Alltrim(Str(tnTip)) + [) a ] + ;
	*!*			[left join syn_atas_atasamente b on a.id_atas = b.id_atas]
	*!*		lcSchema = [descriere C(200),nume_fisier C(200),fisier W,id_entitate N(10),ordine N(10),id_atas N(10),id_referinta N(10)]
	lcOrder = []
	llAfisare = .F.
	gencursor('poDocument',lcCursor,lcSQl,lcFiltru,lcSchema,lcOrder,llAfisare)
	poDocument.ca_baza1.afisare()
	If Used(lcCursor)
		Select (lcCursor)
		Scatter Name loRec MEMO
		Use In (lcCursor)
	Else
		loRec = Null
	Endif
	Release poDocument, lcSQl, lcCursor, lcFiltru, lcSchema, lcOrder, llAfisare
	Return loRec
Endfunc
******************************************************************************************************
Procedure template_completeaza
	Lparameters toObiect,tcNume,tnId,tcCond
	SET STEP on
	Local lcDocumentMarca,lcSQl,lcCursor,lnSucces
	Private poWord
	lcDocumentMarca = Addbs(gcTempPath) + Alltrim(tcNume)
	If File(lcDocumentMarca)
		Delete File (lcDocumentMarca)
	ENDIF
	*WAIT WINDOW 'pack_personal.contract_munca'
*!*		IF toObiect.id_referinta <> -7
		lcSQl = [{call pack_personal.contract_munca(?gcS,]+Alltrim(Str(tnId))+[,?gnIdFirma,']+IIF(!EMPTY(tcCond),ALLTRIM(tcCond),[])+[')}]
		lcCursor = [crs_test]
		If !goExecutor.oExecuta(lcSQl,lcCursor)
			Return
		ENDIF
*!*		ENDIF 
	SELECT (lcCursor)
*!*		BROWSE 
	*WAIT WINDOW 'end pack_personal.contract_munca'
	*!*	modificare pentru contract
	If toObiect.id_referinta = 20
		Local lcCursor1
		lcCursor1 = [crs_test1]
		Select * From (lcCursor) Into Cursor (lcCursor1) Readwrite
		Use In (lcCursor)
		lcCursor = lcCursor1
		Select (lcCursor)
		Locate For Alltrim(variabila)='S32'
		*!*	modificare	v 2.0.25
		*!*			If Found()
		*!*				If !Empty(Val(valoare))
		*!*					Replace valoare With '0' For Inlist(Alltrim(variabila),'S21','S34')
		*!*					Replace valoare With Alltrim(Str(5*Val(valoare))) For Alltrim(variabila)='S33'
		*!*				Endif
		*!*			Else
		*!*				Locate For Alltrim(variabila)='S21'
		*!*				If Found()
		*!*					If !Empty(Val(valoare))
		*!*						Replace valoare With '0' For Inlist(Alltrim(variabila),'S32','S33')
		*!*						Replace valoare With Alltrim(Str(5*Val(valoare))) For Alltrim(variabila)='S34'
		*!*					Endif
		*!*				Endif
		*!*			ENDIF
		If Found()
			lnNrOreNorma = Val(valoare)
		Else
			lnNrOreNorma = 0
		Endif
		Locate For Alltrim(variabila) = 'S21'
		If Found()
			lnNrOreFractie = Val(valoare)
		Else
			lnNrOreFractie = 0
		ENDIF
		Do Case
			Case lnNrOreNorma <> 0 And lnNrOreNorma = lnNrOreFractie
				Replace valoare With '0' For Inlist(Alltrim(variabila),'S21','S34')
				Replace valoare With Alltrim(Str(5*Val(valoare))) For Alltrim(variabila)='S33'
			Case lnNrOreNorma <> lnNrOreFractie
				Replace valoare With '0' For Inlist(Alltrim(variabila),'S32','S33')
				Replace valoare With Alltrim(Str(5*Val(valoare))) For Alltrim(variabila)='S34'
			Otherwise
				lnNrOreNorma = 0
		Endcase
		*!*	modificare	v 2.0.25	^
	ENDIF
	IF toObiect.id_referinta = -2
		DO updateNrData112

		WAIT WINDOW [Asteptati, se calculeaza datele...] NOWAIT 
		lcSQl = [{call pack_personal.adeverinta_somaj(]+Alltrim(Str(tnId))+[)}]
		If !goExecutor.oExecuta(lcSQl,[crs_venituri])
			RETURN
		ENDIF  
		WAIT CLEAR  
		lcSQl = [select a.datainceput as datainc, a.datasfarsit as datasf,upper(c.explicatie) as temei ]+;
       			[ from (select distinct id_sal_ctr,id_temei,datainceput, NVL(dataincetare, datasfarsit) as datasfarsit ]+;
                [ from sal_reges_stari_ctr ]+;
                [ where id_tip_stare = 3 and sters <> 2 and tip_modificare <> 1) a ]+;
       			[ left join (select nrctr, datactr, id_sal_ctr, id_salariat ]+;
                    [ from (select nrctr,datactr,id_sal_ctr, id_salariat, row_number() over(partition by id_sal_ctr order by dataconsemnare desc) as nr ]+;
                             [ from sal_reges_contracte where sters <> 2)]+;
                    [ where nr = 1) b ]+;
          		[ on a.id_sal_ctr = b.id_sal_ctr ]+;
        		[ left join syn_sal_nom_temei c on a.id_temei = c.id_temei ]+;
       			[ where b.id_salariat = ]+ALLTRIM(STR(tnId))+;
				[  union ]+;
       			[ select a.datainc,a.datasf , b.conc_med as temei ]+;
       			[ from sal_concmed a ]+;
      			[ left join sal_nom_cm b on a.id_cm = b.id_cm ]+;
       			[ where a.id_stat in (select id_stat from sal_stat where id_persoana =]+ALLTRIM(STR(tnId))+[) and a.id_cm <> 9 and a.sters = 0]+;
        		[ order by datainc]
        
		
		If !goExecutor.oExecuta(lcSQl,[crs_concediiSuspendari])
			RETURN
		ENDIF
	ENDIF 
	IF toObiect.id_referinta = -11
		DO updateNrData112
	SET STEP ON 
		WAIT WINDOW [Asteptati, se calculeaza datele...] NOWAIT 
		lcSQl = [{call pack_personal.adeverinta_somaj_2018(]+Alltrim(Str(tnId))+[)}]
		If !goExecutor.oExecuta(lcSQl,[crs_venituri])
			RETURN
		ENDIF  
		WAIT CLEAR  
		lcSQl = [select a.datainceput as datainc, a.datasfarsit as datasf,upper(c.explicatie) as temei ]+;
       			[ from (select distinct id_sal_ctr,id_temei,datainceput, NVL(dataincetare, datasfarsit) as datasfarsit ]+;
                [ from sal_reges_stari_ctr ]+;
                [ where id_tip_stare = 3 and sters <> 2 and tip_modificare <> 1) a ]+;
       			[ left join (select nrctr, datactr, id_sal_ctr, id_salariat ]+;
                    [ from (select nrctr,datactr,id_sal_ctr, id_salariat, row_number() over(partition by id_sal_ctr order by dataconsemnare desc) as nr ]+;
                             [ from sal_reges_contracte where sters <> 2)]+;
                    [ where nr = 1) b ]+;
          		[ on a.id_sal_ctr = b.id_sal_ctr ]+;
        		[ left join syn_sal_nom_temei c on a.id_temei = c.id_temei ]+;
       			[ where b.id_salariat = ]+ALLTRIM(STR(tnId))+;
				[  union ]+;
       			[ select a.datainc,a.datasf , b.conc_med as temei ]+;
       			[ from sal_concmed a ]+;
      			[ left join sal_nom_cm b on a.id_cm = b.id_cm ]+;
       			[ where a.id_stat in (select id_stat from sal_stat where id_persoana =]+ALLTRIM(STR(tnId))+[) and a.id_cm <> 9 and a.sters = 0]+;
        		[ order by datainc]
        
		
		If !goExecutor.oExecuta(lcSQl,[crs_concediiSuspendari])
			RETURN
		ENDIF
	ENDIF 
	IF INLIST(toObiect.id_referinta, -5,-12)
		
		lcSQl = [select a.orenoapte,b.an,b.luna, pack_normare.tarifar_ora_luna(b.id_persoana,b.luna,b.an) as tarif_ora,a.c_orenoapte,b.tarifar,b.totbrut ]+;
       				[ from sal_pontaje a ]+;
       				[ left join sal_stat b on a.id_stat = b.id_stat ]+;
       				[ left join sal_personal c on b.id_persoana = c.id_salariat ]+;
       				[ where a.sters = 0 and b.sters = 0 and b.id_persoana =  ]+ALLTRIM(STR(tnId))+;
       				[ order by an*12+luna ]
		If !goExecutor.oExecuta(lcSQl,[crs_venituri])
			RETURN
		ENDIF  
	ENDIF 	
	IF toObiect.id_referinta = -1
		lcSQl = [select a.an,a.luna,a.tarifar,a.totbrut,a.salnet as net,a.fractie from sal_vstattot a where an*12+luna >= 2011*12+1 and a.id_persoana = ]+ALLTRIM(STR(tnId))+[ order by an*12+luna ]
		If !goExecutor.oExecuta(lcSQl,[crs_venituri])
			RETURN
		ENDIF  
	ENDIF 
	IF toObiect.id_referinta = -13
		lcSQl = [select a.an,a.luna,a.totbrut,a.zileluc+a.zileco+a.zileces as zileluc,a.zilecm from sal_vstattot a ]+;
					[ where an*12+luna between pack_sesiune.getan()*12+pack_sesiune.getluna()-11 and pack_sesiune.getan()*12+pack_sesiune.getluna() ]+;
					[ and a.id_persoana = ]+ALLTRIM(STR(tnId))+[ order by an*12+luna ]
		If !goExecutor.oExecuta(lcSQl,[crs_bazeCM])
			RETURN
		ENDIF  
	ENDIF 
	IF toObiect.id_referinta = -6

*!*			lcSQl = [{call pack_personal.reges_citeste_vechime(]+Alltrim(Str(tnId,10))+[)}]
		lcSQl = [select contract,functie,tipdurata,dataang,dataincetare,nrCtr,]+;
				[to_char((case ]+;
				[	when nr = 1 then ]+;
				[	  greatest(dataang, to_date('01012011', 'DDMMYYYY')) ]+;
				[	else dataconsemnare end), ]+;
				[	'DD.MM.YYYY') || ' - ' || ]+;
				[ NVL(to_char(lead(dataconsemnare - 1)]+;
				[	over(partition by id_sal_ctr order by dataconsemnare),'DD.MM.YYYY'),]+;
				[  NVL(to_char(dataincetare, 'DD.MM.YYYY'),NVL(to_char(datasfctr, 'DD.MM.YYYY'), 'Prezent'))) as vechime,]+;
				[       salariu,tipactualizare,nractmodif,dataactmodif,tipactmodif,meserie,temeiincetare  ]+;
				[ from (select nrCtr,id_sal_ctr,connect_by_root(nr) as nr,connect_by_root(dataconsemnare) as dc,contract,functie,tipdurata,]+;
                [ dataconsemnare,dataang,datasfctr,dataincetare,salariu,(case when connect_by_root(nr) = 1 then 'Adaugare' else ]+;
                [ decode(tip_modificare,3,'Modificare',2,'Corectie','Adaugare')end) as tipactualizare,nractmodif,dataactmodif,tipactmodif,meserie,temeiincetare  ]+;
                [from (select nrCtr,id_sal_ctr,nr,(case when nr - lag(nr) over(partition by id_sal_ctr,nrctr,datactr,dataang,functie,datasfctr,dataincetare,]+;
                         [ salariu,id_tip_norma order by dataconsemnare,dataora,nrctr,datactr,dataang,functie,datasfctr,dataincetare,salariu,id_tip_norma) = 1 then ]+;
                         [ lag(nr) over(partition by id_sal_ctr,nrctr,datactr,dataang,functie,datasfctr,dataincetare,salariu,id_tip_norma order by dataconsemnare,]+;
                         [ dataora,nrctr,datactr,dataang,functie,datasfctr,dataincetare,salariu,id_tip_norma) else null end) as tata,]+;
                         [nrctr || '/' || to_char(datactr, 'DD.MM.YYYY') as contract,functie,nvl2(datasfctr, 'Determinata', 'Nedeterminata') as tipdurata,]+;
                         [ dataconsemnare,dataang,datasfctr,dataincetare,salariu,tip_modificare,nractmodif,dataactmodif,tipactmodif,meserie,temeiincetare  ]+;
                         [ from (select a.id_sal_ctr, ]+;
                         [ rank() over(partition by a.id_sal_ctr order by decode(a.tip_modificare, 4, to_date('01012011', 'DDMMYYYY'), a.dataconsemnare), a.dataora, ]+;
                         [ a.nrctr, a.datactr, a.dataang, c.cod || '( v' || c.versiune || ' ) - ' || c.denumire, a.datasfctr, d.dataincetare, a.tarifar, a.tip_modificare) as nr,]+;
                         [ a.nrctr,a.datactr,c.cod || '( v' || c.versiune || ' ) - ' ||c.denumire as functie,decode(a.tip_modificare,4,to_date('01012011', 'DDMMYYYY'),]+;
                         [ a.dataconsemnare) as dataconsemnare,a.dataang,a.datasfctr,d.dataincetare,a.dataora,a.tarifar as salariu,a.tip_modificare,a.nractmodif,a.dataactmodif,a.id_tip_norma,]+;
                         [ nom_acte.nume_act as tipactmodif,e.meserie,f.denumire as temeiincetare ]+;
                         	[ from sal_reges_contracte a left join syn_sal_cor c on a.cor = c.cod and a.versiune_cor = c.versiune ]+;
                            [ left join (select id_sal_ctr, dataincetare,id_temei  from sal_stare_ctr where id_tip_stare = 1 and sters = 0) d on a.id_sal_ctr = d.id_sal_ctr ]+;
                            [ left join syn_sal_nom_temei f on d.id_temei = f.id_temei ]+;
                          [ left join sal_nom_acte nom_acte on a.id_tipact = nom_acte.id_act ]+;
                          [ left join sal_nom_mes e on a.id_meserie = e.id_meseria ]+;
                         [ where a.id_salariat = ]+ALLTRIM(STR(tnId))+[ and a.tip_modificare <> 1 and a.sters <> 2 and a.tip_modificare <> 2) order by dataconsemnare,id_sal_ctr, nr) start with tata is null ]+;
        					[ connect by tata = prior nr) order by dataconsemnare, id_sal_ctr, nr]
				
		If !goExecutor.oExecuta(lcSQl,[crs_venituri])
			RETURN
		ENDIF  
*!*			lcSQl = [{call pack_personal.reges_citeste_suspendari(]+Alltrim(Str(tnId,10))+[)}]
*!*			If !goExecutor.oExecuta(lcSQl,[crsSuspendari])
*!*				RETURN
*!*			ENDIF  		
	ENDIF 
	IF toObiect.id_referinta = -14
		lcSQl = [select an,luna,id_colaborator,baza_cas,scas from spec_vtotvenituri a where a.scas >0 ]+;
					[ and a.id_colaborator = ]+ALLTRIM(STR(tnId))+[ order by an*12+luna ]
		If !goExecutor.oExecuta(lcSQl,[crs_bazeCAS])
			RETURN
		ENDIF  
	ENDIF 	
	IF UPPER(ALLTRIM(toObiect.nume_fisier)) = 'ADEVERINTA2.DOC'
		lcSQl = [select a.cod_cm as cod ,(cm.datasf - cm.datainc + 1) as zilecm,]+;
				[ to_char(cm.datainc, 'DD.MM.YYYY') || ' - ' ||to_char(cm.datasf, 'DD.MM.YYYY') as perioada,b.id_persoana,b.an,b.luna from SAL_CONCMED cm ]+;
				[ left join sal_nom_cm a on cm.id_cm = a.id_cm ]+;
				[ left join sal_stat b on cm.id_stat = b.id_stat ]+;
				[ where cm.sters =0 ]+;
				[ and cm.datainc between add_months(to_date(pack_sesiune.getan() ||pack_sesiune.getluna(),'YYYYMM'),-24) and ]+;
                               [ last_day(to_date(pack_sesiune.getan() || pack_sesiune.getluna(),'YYYYMM'))]+;                                     
								[ and a.cod_cm <> '00' and b.id_persoana = ]+ALLTRIM(STR(tnId)) +[ order by cm.datainc ]
		If !goExecutor.oExecuta(lcSQl,[crsCmuri])
			RETURN
		ENDIF  
	SELECT crsCmuri
	ENDIF 
	*!*		modificare pentru contract	^
	Strtofile(toObiect.fisier,lcDocumentMarca)
	Local xeroare As Exception
	TRY
		SET STEP ON
		poWord = Createobject('word.application')
		APPLICATION.OLERequestPendingTimeout = 0			&&	v 2.0.21
		poWord.visible = .t.
		loDocument = poWord.Documents.Open(lcDocumentMarca)
	Catch To xeroare
		If Type('poword')='O'
			poWord.Quit
			Release poWord
		Endif
		If xeroare.ErrorNo = 1429
			amessagebox('Fisierul ' + lcDocumentMarca+ ' este deja deschis!',16,"Eroare")
		Endif
	Finally
	Endtry

	If Type('xeroare') = 'O'
		Release xeroare
		Return
	Endif

	Local loSelection,lcVariabila,lcValoare,loDoc
	lcValoare = []
	loTherm = Newobject("_thermometer","_therm","","Completare document ...")
	lcTask = "Document ..."
	loDoc = Createobject('empty')
	With loTherm
		.AlwaysOnTop=.T.
		.Show()
		lnPercent = 5
		.Update(lnPercent, lcTask)

		For i= poWord.ActiveDocument.Fields.Count To 1 Step -1
			lnPercent = 100 / i
			.Update(lnPercent, lcTask)
			poWord.ActiveDocument.Fields(i).Select
			loSelection = poWord.Selection
			lcVariabila = loSelection.Text
			*!*	modificare	ROARES v 2.0.14
			*!*			If Type('loDoc.&cVariabila')='U'
			*!*				Select (lcCursor)
			*!*				Locate For Upper(Alltrim(variabila))=Upper(lcVariabila)
			*!*				If Found()
			*!*					lcValoare = Alltrim(valoare)
			*!*				Endif
			*!*				If Empty(NVL(lcValoare,[]))
			*!*					lcValoare = Replicate(Chr(95),13)
			*!*				Endif
			*!*				=AddProperty(loDoc,lcVariabila,lcValoare)
			*!*			Endif
			*!*			loSelection.Cut
			*!*			loSelection.InsertBefore(loDoc.&lcVariabila)
			If Type('loDoc.&cVariabila')='U'
				Select (lcCursor)
				Locate For Upper(Alltrim(variabila))=Upper(lcVariabila)
				If Found()
					lcValoare = Alltrim(valoare)
					If Empty(Nvl(lcValoare,[]))
						lcValoare = Replicate(Chr(95),13)
					Endif
					=AddProperty(loDoc,lcVariabila,lcValoare)
					loSelection.Cut
					loSelection.InsertBefore(loDoc.&lcVariabila)
				ELSE
					IF UPPER(lcVariabila)= 'TABLE'
					DO CASE 
						CASE toObiect.id_referinta = -2
							
								loselection.ConvertToTable(,1,7,,,,,,,,,,,2)
								loselection.Tables(1).Style = 'Table grid'
								loSelection.ParagraphFormat.Alignment = 2
								loselection.TypeText("An")
*!*									loselection.InsertColumnsRight
								loSelection.MoveRight
								loselection.TypeText("Luna")
								loSelection.MoveRight
								loselection.TypeText("Baza de calcul")
								loSelection.MoveRight
								loselection.TypeText("Contrib. individuala")
								loSelection.MoveRight
								loselection.TypeText("Contrib. angajator")
								loSelection.MoveRight
								loselection.TypeText("Nr. ireg delc.lunara")
								loSelection.MoveRight
								loselection.TypeText("Nat venituri baza calcul")
								
								loselection.InsertRowsBelow(1)
								loselection.TypeText("1")
								loSelection.MoveRight(1)
								loselection.TypeText("2")
								loSelection.MoveRight(1)
								loselection.TypeText("3")
								loSelection.MoveRight(1)
								loselection.TypeText("4")
								loSelection.MoveRight(1)
								loselection.TypeText("5")
								loSelection.MoveRight(1)
								loselection.TypeText("6")
								loSelection.MoveRight(1)
								loselection.TypeText("7")

								
								SELECT crs_venituri
								SCAN
								SCATTER NAME lovenit
									loselection.InsertRowsBelow(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.an)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.luna)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(NVL(loVenit.baza,0))))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(NVL(loVenit.somaj,0))))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(NVL(loVenit.somsoc,0))))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(NVL(loVenit.nrdata112,'')))
									loSelection.MoveRight(1)
									loselection.TypeText("Venituri din salarii")								
								ENDSCAN 
*!*									loSelection.Tables(1).AutoFitBehavior(1)
							
						CASE toObiect.id_referinta = -11
							
								loselection.ConvertToTable(,1,6,,,,,,,,,,,2)
								loselection.Tables(1).Style = 'Table grid'
								loSelection.ParagraphFormat.Alignment = 2
								loselection.TypeText("Nr. Crt")
								loSelection.MoveRight								
								loselection.TypeText("Luna si Anul")
								loSelection.MoveRight
								loselection.TypeText("Baza de calcul contributie asiguratorie pentru munca (BC)")
								loSelection.MoveRight
								loselection.TypeText("Baza de calcul al indemnizatiei de somaj (BCIS)")
								loSelection.MoveRight
								loselection.TypeText("Numarul de inregistrare a declaratiei lunare validate")
								loSelection.MoveRight
								loselection.TypeText("Natura veniturilor din care este constituita baza de calcul al indemnizatiei de somaj")
								
								loselection.InsertRowsBelow(1)
								loselection.TypeText("1")
								loSelection.MoveRight(1)
								loselection.TypeText("2")
								loSelection.MoveRight(1)
								loselection.TypeText("3")
								loSelection.MoveRight(1)
								loselection.TypeText("4")
								loSelection.MoveRight(1)
								loselection.TypeText("5")
								loSelection.MoveRight(1)
								loselection.TypeText("6")
								lnNr = 0


								
								SELECT crs_venituri
								SCAN
								SCATTER NAME lovenit
								lnNr = lnNr +1 
									loselection.InsertRowsBelow(1)
									loselection.TypeText(ALLTRIM(STR(lnNr)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.luna))+"/ "+ALLTRIM(STR(loVenit.an)))
									loSelection.MoveRight(1)
*!*										loselection.TypeText(ALLTRIM(STR(NVL(loVenit.somsoc,0))))
									loselection.TypeText(ALLTRIM(STR(NVL(loVenit.baza,0))))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(NVL(loVenit.baza,0))))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(NVL(loVenit.nrdata112,'')))
									loSelection.MoveRight(1)
									loselection.TypeText("Venituri din salarii")								
								ENDSCAN 
*!*									loSelection.Tables(1).AutoFitBehavior(1)	

						CASE toObiect.id_referinta = -1
							
								loselection.ConvertToTable(,1,6,,,,,,,,,,,2)
								loselection.Tables(1).Style = 'Table grid'
								loSelection.ParagraphFormat.Alignment = 2
								loselection.TypeText("An")
								loSelection.MoveRight
								loselection.TypeText("Luna")
								loSelection.MoveRight
								loselection.TypeText("Salariu incadrare")
								loSelection.MoveRight
								loselection.TypeText("Brut")
								loSelection.MoveRight
								loselection.TypeText("Net")
								loSelection.MoveRight
								loselection.TypeText("Norma zilnica")
								SELECT crs_venituri
								SCAN
								SCATTER NAME lovenit
									loselection.InsertRowsBelow(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.an)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.luna)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.tarifar)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.totbrut)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.net)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(IIF(EMPTY(NVL(loVenit.fractie,0)),8,loVenit.fractie))))
								ENDSCAN 
								loSelection.Tables(1).AutoFitBehavior(1)
						CASE toObiect.id_referinta = -5
							
								loselection.ConvertToTable(,1,4,,,,,,,,,,,2)
								loselection.Tables(1).Style = 'Table grid'
								loSelection.ParagraphFormat.Alignment = 2
								loselection.TypeText("An")
								loSelection.MoveRight
								loselection.TypeText("Luna")
								loSelection.MoveRight
								loselection.TypeText("Ore noapte")
								loSelection.MoveRight
								loselection.TypeText("Spor noapte")
								SELECT crs_venituri
								SCAN
								SCATTER NAME lovenit
									loselection.InsertRowsBelow(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.an)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.luna)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.orenoapte)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(ROUND(calcul_sumaore(loVenit.tarif_ora,loVenit.orenoapte,loVenit.c_orenoapte),2),16,2)))
								ENDSCAN 
								loSelection.Tables(1).AutoFitBehavior(1)	
							CASE toObiect.id_referinta = -6
							
								loselection.ConvertToTable(,1,6,,,,,,,,,,,2)
								loselection.Tables(1).Style = 'Table grid'
								
								loselection.TypeText("Nr. Crt")
								loSelection.MoveRight
								loselection.TypeText("Mutatia Intervenita")
								loSelection.MoveRight
								loselection.TypeText("Zi/Luna/An")
								loSelection.MoveRight
								loselection.TypeText("Meseria / Functia")
								loSelection.MoveRight
								loSelection.ParagraphFormat.Alignment = 2
								loselection.TypeText("Salariu de baza, inclusiv sporurile care intra în calculul punctajului  mediu  anual")
								loSelection.MoveRight
								loselection.TypeText("Nr. si data actului  pe baza  caruia se face înscrierea si temeiul  legal")
								SELECT crs_venituri
								lnNr = 0
								SCAN FOR tipactualizare <> 'Corectie'
								lnNr = lnNr +1
								SCATTER NAME lovenit MEMO 
									loselection.InsertRowsBelow(1)
									loselection.TypeText(ALLTRIM(STR(lnNr)))
									loSelection.MoveRight(1)
									lcMotivatie = []
*!*										v2.1.7 - nu punea corect "incheiere CIM"
*!*										lcMotivatie = IIF(lnNr =1,IIF(YEAR(lovenit.dataang)*12+MONTH(lovenit.dataang)<=VAL(ALLTRIM(SUBSTR(lovenit.VECHIME,7,4)))*12+VAL(ALLTRIM(SUBSTR(lovenit.VECHIME,4,2))),'Continuare CIM','Incheiere CIM'),IIF(ALLTRIM(SUBSTR(lovenit.VECHIME,1,10)) = ALLTRIM(SUBSTR(lovenit.VECHIME,13,11)),'Incetare CIM','Modificare CIM'))
									lcMotivatie = IIF(lnNr =1,IIF(YEAR(lovenit.dataang)*12+MONTH(lovenit.dataang)<=2011*12+1,'Continuare CIM','Incheiere CIM'),;
										IIF(YEAR(lovenit.dataincetare)*12+MONTH(lovenit.dataincetare) = VAL(ALLTRIM(SUBSTR(lovenit.VECHIME,20,4)))*12+VAL(ALLTRIM(SUBSTR(lovenit.VECHIME,17,2))) and ;
										DAY(lovenit.dataincetare) = VAL(ALLTRIM(SUBSTR(lovenit.VECHIME,14,2))),'Incetare CIM','Modificare CIM'))
									
									IF ALLTRIM(SUBSTR(lovenit.VECHIME,1,10)) = ALLTRIM(SUBSTR(lovenit.VECHIME,13,11))
												lcMotivatie = lcMotivatie + [ cf. ]+NVL(ALLTRIM(lovenit.temeiincetare)	,[ ])	+[ din Codul Muncii]						
									ENDIF 
									SELECT crs_venituri
									loselection.TypeText(ALLTRIM(lcMotivatie))
									loSelection.MoveRight(1)
									loselection.TypeText(IIF(YEAR(lovenit.dataincetare) = VAL(ALLTRIM(SUBSTR(lovenit.VECHIME,20,4))) and ;
															MONTH(lovenit.dataincetare) = VAL(ALLTRIM(SUBSTR(lovenit.VECHIME,17,2)));
															and DAY(lovenit.dataincetare) = VAL(ALLTRIM(SUBSTR(lovenit.VECHIME,14,2))),SUBSTR(lovenit.VECHIME,14,10),SUBSTR(lovenit.VECHIME,1,10)))
									loSelection.MoveRight(1)
									loselection.TypeText(PROPER(ALLTRIM(loVenit.meserie)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(TRANSFORM(loVenit.salariu)))
									loSelection.MoveRight(1)
									IF lnNr = 1 
										loselection.TypeText(NVL(ALLTRIM(loVenit.tipactmodif),[CONTRACT ])+[ nr: ]+;
											IIF(!EMPTY(ALLTRIM(TRANSFORM(loVenit.nractmodif))),NVL(ALLTRIM(TRANSFORM(loVenit.nractmodif)),ALLTRIM(STR(NVL(loVenit.nrCtr,0)))),ALLTRIM(STR(NVL(loVenit.nrCtr,0))))+;
											[ / ]+IIF(!EMPTY(ALLTRIM(TRANSFORM(TTOD(loVenit.dataactmodif)))),NVL(ALLTRIM(TRANSFORM(TTOD(loVenit.dataactmodif))),NVL(ALLTRIM(TRANSFORM(TTOD(loVenit.dataang))),[])),;
											NVL(ALLTRIM(TRANSFORM(TTOD(loVenit.dataang))),[])))

									ELSE 
										loselection.TypeText(NVL(ALLTRIM(loVenit.tipactmodif),[])+[ nr: ]+NVL(ALLTRIM(TRANSFORM(loVenit.nractmodif)),[])+[ / ]+NVL(ALLTRIM(TRANSFORM(TTOD(loVenit.dataactmodif))),[]))
									ENDIF 
								ENDSCAN 
								loSelection.Tables(1).AutoFitBehavior(1)		
							CASE  toObiect.id_referinta = -7		
								loselection.Font.Color = -603914241
								SELECT crsmoditarifar
								SCAN 
								SCATTER NAME lovenit
									loselection.InsertRowsBelow(1)
									loselection.TypeText(ALLTRIM(STR(RECNO())))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(loVenit.nume)+[ ]+ALLTRIM(loVenit.prenume))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(loVenit.codpers))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(NVL(loVenit.tarifar_nou,0))))							
								ENDSCAN 
							CASE toObiect.id_referinta = -12
							
								loselection.ConvertToTable(,1,4,,,,,,,,,,,2)
								loselection.Tables(1).Style = 'Table grid'
								loSelection.ParagraphFormat.Alignment = 2
								loselection.TypeText("An")
								loSelection.MoveRight
								loselection.TypeText("Luna")
								loSelection.MoveRight
								loselection.TypeText("Salariu de baza")
								loSelection.MoveRight
								loselection.TypeText("Total brut")
								SELECT crs_venituri
								SCAN
								SCATTER NAME lovenit
									loselection.InsertRowsBelow(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.an)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.luna)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.tarifar)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.totbrut)))
								ENDSCAN 
								loSelection.Tables(1).AutoFitBehavior(1)
							CASE toObiect.id_referinta = -13
							
								loselection.ConvertToTable(,1,5,,,,,,,,,,,2)
								loselection.Tables(1).Style = 'Table grid'
								loSelection.ParagraphFormat.Alignment = 2
								loselection.TypeText("An")
								loSelection.MoveRight
								loselection.TypeText("Luna")
								loSelection.MoveRight
								loselection.TypeText("Total brut")
								loSelection.MoveRight
								loselection.TypeText("Zile lucrate")
								loSelection.MoveRight
								loselection.TypeText("Zile CM")
								SELECT crs_bazeCM
								SCAN
								SCATTER NAME lovenit
									loselection.InsertRowsBelow(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.an)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.luna)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.totbrut)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.zileluc)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.zilecm)))
								ENDSCAN 
								*loSelection.Tables(1).AutoFitBehavior(1)
								CASE toObiect.id_referinta = -14
							
								loselection.ConvertToTable(,1,4,,,,,,,,,,,2)
								loselection.Tables(1).Style = 'Table grid'
								loSelection.ParagraphFormat.Alignment = 2
								loselection.TypeText("An")
								loSelection.MoveRight
								loselection.TypeText("Luna")
								loSelection.MoveRight
								loselection.TypeText("Baza de calcul")
								loSelection.MoveRight
								loselection.TypeText("CAS")

								SELECT crs_bazeCas
								SCAN
								SCATTER NAME lovenit
									loselection.InsertRowsBelow(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.an)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.luna)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.baza_cas)))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loVenit.scas)))

								ENDSCAN 
								loSelection.Tables(1).AutoFitBehavior(1)
						CASE UPPER(ALLTRIM(toObiect.nume_fisier)) = 'ADEVERINTA2.DOC'		
								
								loselection.ConvertToTable(,1,3,,,,,,,,,,,2)
								loselection.Tables(1).Style = 'Table grid'
								loSelection.ParagraphFormat.Alignment = 2
								loselection.TypeText("Cod de indemnizatie")
								loSelection.MoveRight
								loselection.TypeText("Numar zile concediu medical în ultimele 12/24 luni")
								loSelection.MoveRight
								loselection.TypeText("Seria si numarul certificatului de concediu medical anterior****), pentru codul de diagnostic . . . . . . . . , valabil pâna la . . . . . . . . . . ")
								SELECT crsCmuri
								SCAN
								SCATTER NAME loCM
									loselection.InsertRowsBelow(1)
									loselection.TypeText(ALLTRIM(loCM.cod))
									loSelection.MoveRight(1)
									loselection.TypeText(ALLTRIM(STR(loCM.zilecm)))
									loSelection.MoveRight(1)
*!*										loselection.TypeText(ALLTRIM(loCM.perioada))
									loselection.TypeText(" ")

								ENDSCAN 
								loSelection.Tables(1).AutoFitBehavior(1)	
						OTHERWISE 
						1=1
							

					ENDCASE 

					ENDIF
					IF UPPER(lcVariabila)= 'TABLE2'
					*----------
						DO CASE 
							CASE INLIST(toObiect.id_referinta ,-2,-11)
								
									loselection.ConvertToTable(,1,3,,,,,,,,,,,2)
									loselection.Tables(1).Style = 'Table grid'
									loSelection.ParagraphFormat.Alignment = 2
									loselection.TypeText("Data inceput")
	*!*									loselection.InsertColumnsRight
									loSelection.MoveRight
									loselection.TypeText("Data sfarsit")
									loSelection.MoveRight
									loSelection.ParagraphFormat.Alignment = 0
									loselection.TypeText("Motiv suspendare")

									
									SELECT crs_concediiSuspendari
									SCAN
									SCATTER NAME loSuspendare MEMO 
										loselection.InsertRowsBelow(1)
										loselection.TypeText(NVL(ALLTRIM(TRANSFORM(TTOD(loSuspendare.datainc))),[]))
										loSelection.MoveRight(1)
										loselection.TypeText(NVL(ALLTRIM(TRANSFORM(TTOD(loSuspendare.datasf))),[]))
										loSelection.MoveRight(1)
										loselection.TypeText(PROPER(ALLTRIM(loSuspendare.temei)))								
									ENDSCAN 
									RELEASE loSuspendare
									USE IN crs_concediiSuspendari
	*!*									loSelection.Tables(1).AutoFitBehavior(1)
						OTHERWISE 
							1 = 1
						ENDCASE 
									
						*-----------
					ENDIF 												
				Endif
			ELSE

				loSelection.Cut
				loSelection.InsertBefore(loDoc.&lcVariabila)
			Endif
			*!*	modificare	ROARES v 2.0.14	^
		Endfor
		If Used(lcCursor)
			Use In (lcCursor)
		ENDIF
		lnPercent = 100
		.Update(lnPercent, lcTask)
		.Complete()
		.AlwaysOnTop=.F.
	Endwith
	Release loTherm
	_Screen.MousePointer= 0

	poWord.Visible =.T.
	poWord = .Null.
	Release poWord,lcVariabila,lcValoare,loSelection,lcDocumentMarca,lcSQl,lcCursor,lnSucces,loDoc
Endproc
******************************************************************************************************
Procedure template_citeste_meniu
	Lparameters tnTip
	SET STEP ON 
	Local lcSQl, lnSucces, lcNumeCursor, lcMeniu, lnOptiune, lcView
	lcNumeCursor = [crsmeniutempl]
	If gnIdProgram = 75
		lcView = [sal_vdocumente_ss]		&&	ROASALSPEC	/	75
	Else
		lcView = [sal_vdocumente_ru]		&&	ROARES		/	4
	Endif
	lcSQl = [select row_number() over(order by ordine) as nr, id_referinta, descriere from ] + lcView + [ ] + ;
		[where id_entitate = ] + ALLTRIM(STR(tnTip)) + [ order by ordine]
	lnSucces = goExecutor.oExecute(lcSQl,lcNumeCursor)
	If lnSucces < 0
		amessagebox(goExecutor.cEroare,16,"Eroare")
	Else
		If Reccount(lcNumeCursor) > 0
			lcMeniu = []
			Select (lcNumeCursor)
			Scan
				lcMeniu = lcMeniu + [;] + Alltrim(descriere)
			Endscan
			lnOptiune = xmenu(SUBSTR(lcMeniu,2))
			Select (lcNumeCursor)
			Locate For nr = lnOptiune
			If Found()
				template_selecteaza(id_referinta)
			Endif
		Else
			amessagebox("Nu ati definit alte formulare!",48,"Atentie")
		Endif
		Use In (lcNumeCursor)
	Endif
	Release lcSQl, lnSucces, lcNumeCursor, lcMeniu, lnOptiune
Endproc
******************************************************************************************************
*!*	&& ------------------------------INCEPUT: Fise_personal------------------------------
*!*	*!* Procedura:  Fise_personal
*!*	*!* Parametri: tcFile,tcPath,tcFileName,tcSelect
*!*	*!* Data/Ora generarii: 04/09/06 01:40:26 PM
*!*	*!* Autor: NEAGU.CATALIN
*!*	Procedure  fise_personal
*!*		Lparameters tcFile,tcPath,tcNume,tnid,tcCond
*!*
*!*		IF TYPE('tcCond') <> 'C'
*!*			tcCond = ''
*!*		ENDIF
*!*
*!*		Local lcDocument,lnid

*!*		Private oWord
*!*		lcDocument = tcFile
*!*		cDocument = tcPath
*!*		lnid=tnid

*!*		cDocumMarca = Addbs(gcTempPath) + Alltrim(tcNume)
*!*		If !File(cDocument)
*!*			If File(lcDocument)
*!*				Copy File (lcDocument) To (cDocument)
*!*			Else
*!*				aMessagebox("Nu exista fisierul "+lcDocument,16,"Eroare")
*!*				Return
*!*			Endif
*!*		Endif

*!*		If File(cDocumMarca)
*!*			Delete File (cDocumMarca)
*!*		Endif
*!*		Copy File (cDocument) To (cDocumMarca)	&&


*!*		*!*	STRTOFILE(gcs+';'+ALLTRIM(STR(lcid))+';'+ALLTRIM(STR(pnId_F_contract)),'c:\conpressh.txt')
*!*		*!*	RETURN
*!*		lcSQl = [{call pack_personal.contract_munca(?gcS,]+ALLTRIM(STR(lnid))+[,?pnId_F_contract,']+ALLTRIM(tcCond)+[')}]

*!*		lcCursor = 'crs_test'
*!*		lnSucces = goExecutor.oExecute(lcSQl,lcCursor)

*!*		If lnSucces < 0
*!*			aMessagebox(goExecutor.cEroare,0+16,"Eroare")
*!*		ENDIF
*!*		Local xeroare As Exception

*!*		Try
*!*			oWord = Createobject('word.application')
*!*			oDocument = oWord.Documents.Open(cDocumMarca)
*!*			oWord.Caption = "Contract de munca"
*!*		Catch To xeroare
*!*			If Type('oword')='O'
*!*				oWord.Quit
*!*				Release oWord
*!*			Endif
*!*			If xeroare.ErrorNo = 1429
*!*				aMessagebox('Fisierul ' + cDocumMarca + ' este deja deschis!',16,"Eroare")
*!*			Endif

*!*		Finally
*!*		Endtry


*!*		If Type('xeroare') = 'O'
*!*			Release xeroare
*!*			Return
*!*		Endif


*!*		Local lncount,lObj,lcValoare
*!*		lcValoare=''
*!*		lncount=0
*!*		Doc = Createobject('empty')

*!*		lncount = oWord.ActiveDocument.Fields.Count
*!*		For i=lncount To 1 Step -1
*!*			oWord.ActiveDocument.Fields(i).Select
*!*			loSelection=oWord.Selection
*!*			lcVariabila=loSelection.Text
*!*			If Type('Doc.&lcValoare')='U'
*!*				Select crs_test
*!*				Locate For Upper(Alltrim(variabila))=Upper(lcVariabila)
*!*				If Found()
*!*					lcValoare = Alltrim(valoare)
*!*				Endif
*!*				If Empty(lcValoare) Or Isnull(lcValoare)
*!*					lcValoare = Replicate(Chr(95),13)
*!*				Endif
*!*				=AddProperty(Doc,lcVariabila,lcValoare)
*!*			Endif
*!*			loSelection.Cut
*!*			loSelection.InsertBefore(Doc.&lcVariabila)

*!*		Endfor


*!*		oWord.Visible =.T.


*!*		*!*	wordFindAndreplace("s1","Costica Popescu") && Exemplu
*!*		*!*	oWord.QUIT
*!*		oWord = .Null.
*!*		Release oWord
*!*		Release Doc,loSelection

*!*		Return && de facut: scrie valoare de retur

*!*	Endproc
&& ------------------------------SFARSIT: Fise_personal------------------------------


********************************************************
PROCEDURE update_tichete

	If Used('v_tichetemasa')
		Use In v_formatia
	Endif

	lcSQl = [select * from ] + gcs + [.sal_vnom_tichete where inactiv = 0]
	lcCursor = [v_tichete]
	lnSucces = goExecutor.oExecute(lcSQl,lcCursor)
	goExecutor.oReset()

	Return lnSucces

ENDPROC
********************************************************
Procedure config_campdoc
	Private pcschema1,pcselect1
	Store '' To pcschema1,pcselect1
	pcschema1=['']
	pcselect1=['select * from ] + gcs + [.sal_v_contract where 1=2']
	ocon = Createobject('frm_campdoc')
	With ocon.ct_grid_search1
		.cSelect = pcselect1
		.cSchema = pcschema1
		.cTitlu_coloane = 'Reper,Descriere,Valoare,Tabela,Camp_id,DinSchema'
		.cNume_coloane = 'variabila;descriere;valoare;tabela;camp_id;dinschema'
		.cMask = '[1]=;[2]=;[3]=;[4]=;[5]=;[6]=replicate([9],1)'
		IF gnIdProgram = 75
			.cFiltruOriginal = "REGEXP_LIKE(variabila, '^N|SS')"		&&	N, SS
		ELSE
			.cFiltruOriginal = "REGEXP_LIKE(variabila, '^[SN][0-9]')"	&&	N, S
		ENDIF
		*!*			.cFiltruOriginal = [2=2]
		.cOrder = 'descriere'
		.cTitlu = 'Configurare'
	Endwith
	ocon.Show(1)
	Release ocon

Endproc
***************************************************************

PROCEDURE actualizez_coeficienti_xml
	PARAMETERS tlupdate
	SET STEP ON 
	DO CASE
		CASE m.GnAn * 12 + m.GnLuna >= 2019*12+1
			PRIVATE poCoef,pozile
			LOCAL lnCaen,lnNr,llGasit,lnLungime,lcString,llCaenGasit
			Store '' To pozile
			pcschema2=['']
			pcselect2=[select * from ] + gcS + [.sal_calendar where 1=2]
			pcorder2=[luna,an]
			pcfiltru2 = [luna = ] + Alltrim(Str(GnLuna)) + [ and an = ]+Alltrim(Str(GnAn))
			llAfiseaza = .F.
			gencursor('pozile','v_coef',pcselect2,pcfiltru2,pcschema2,pcorder2,llAfiseaza)
			pozile.ca_baza1.afisare()
			Select v_coef
			Scatter Name poCoef
			Use In (Select('v_coef'))

			LOCAL llUpdate,lcFisierXML,lnPos,lcComunPath  ,llSucces ,lcPath ,llOpen ,lcXML ,lnLunaCoeficientiXml,lnc_faambp
			Local loXMLRequest as "Msxml2.xmlhttp"

			IF PCOUNT() <> 1
				llUpdate = .t.
			ELSE
				llUpdate = tlupdate
			ENDIF

			lnPos = Rat("\", Addbs(m.gcAppPath), 2)
			If lnPos > 0
				lcComunPath = Left(m.gcAppPath, lnPos)
			ENDIF


			lcComunPath = lcComunPath + Iif(gcAppName = "CONSAL", "COMUNCONTAFIN\", "COMUNROA\") && d:\contafin\comuncontafin\

			lcFisierXML= Alltrim(Transform(m.lcComunPath + "coeficienti.xml"))


			lcPath = Addbs(Justpath(m.lcFisierXML))
			llOpen = .F.
			llSucces = DownloadSupportFile("coeficienti.xml", m.lcPath, m.llOpen) && proceduri_comune.prg

			If m.llSucces
				lcMesaj = m.lcFisierXML+ ' Actualizare cu succes.'
			Else
				lcMesaj = m.lcFisierXML+ ' ATENTIE: Nu s-a actualizat!'
			Endif && m.llSucces

			IF !FILE(m.lcFisierXML)
				RETURN
			ENDIF
			XMLTOCURSOR(m.lcFisierXML,"crsCoeficientiXML",512)
			SELECT crsCoeficientiXML
			*!*			BROWSE

			select MAX(an*12+luna) as luna from crsCoeficientiXML WHERE an*12+luna <= m.GnAn*12+m.GnLuna INTO CURSOR crsCoeficientiDinLuna
			SELECT crsCoeficientiDinLuna
			lnLunaCoeficientiXml = crsCoeficientiDinLuna.luna
			Use In (Select('crsCoeficientiDinLuna'))

			*!*			loXMLRequest = CreateObject("Msxml2.xmlhttp")
			Try
				loXMLRequest = CreateObject("MSXML2.XMLHTTP.6.0")
			Catch
				loXMLRequest = CreateObject("MSXML2.XMLHTTP.3.0")
			Endtry
			loXMLRequest.open("GET", m.lcFisierXML, .F.)
			loXMLRequest.send(.null.)
			lcXML = loXMLRequest.responseText
			lnNrCoeficienti = OCCURS([<v_coef>], lcXML)


			FOR lnI = 1 TO lnNrCoeficienti


				SELECT crsCoeficientiXML
				GOTO lnI
				IF an*12+luna = lnLunaCoeficientiXml
					SCATTER NAME localen
					IF GnAn*12+GnLuna > 2018*12+12 && incepand cu 2018 nu mai exista fond de risc si accidente, iar deducerile le actualizez prin script
						lcExtract = [<v_coef>] + STREXTRACT(lcXML, '<coef_2>', '</coef_2>', lnI) + [</v_coef>]
						XMLTOCURSOR(lcExtract, 'crsCoef_diferiti')
						SELECT crsCoef_diferiti
						IF ISNULL(poCoef.oug114_2018)
							LOCATE FOR UPPER(ALLTRIM(constructii)) = "T"
							IF FOUND()
								*------------cauta caenul firmei in lista predefinita din xml
								lnNr = OCCURS(",",crsCoef_diferiti.caen)
								lnCaen = ALLTRIM(TRANSFORM(gofirma.caen))
								FOR  i=0 TO lnNr-1
									IF i=0
										lcString=left(crsCoef_diferiti.caen,AT(',',crsCoef_diferiti.caen,1)-1)
									ELSE

										lcString=SUBSTR(crsCoef_diferiti.caen,AT(',',crsCoef_diferiti.caen,i)+1,AT(',',crsCoef_diferiti.caen,i+1)-AT(',',crsCoef_diferiti.caen,i)-1)
									ENDIF
									lnLungime = LEN(lcString)
									IF LEFT(lnCaen,lnLungime )= lcString
										llCaenGasit = .t.
										IF aMESSAGEBOX('Codului Caen: '+lnCaen +' i se pot aplica prevederile OUG 114/28.12.2018?',4,'Atentie!') = 6
											poCoef.oug114_2018 = 1
										ELSE
											poCoef.oug114_2018 = 0
										ENDIF
										EXIT
									ENDIF

								ENDFOR
								IF !llCaenGasit
									poCoef.oug114_2018 = 0
								ENDIF
								*------------cauta caenul firmei in lista predefinita din xml


							ENDIF

							*!*					04.01.2016 - introducere deduceri in xml

*!*								Use In (Select('crsDeduceri'))
*!*								lcExtract = [<v_coef>] + STREXTRACT(lcXML, '<tabdeduceri>', '</tabdeduceri>', lnI) + [</v_coef>]
*!*								XMLTOCURSOR(lcExtract, 'crsDeduceri')
*!*								SELECT crsDeduceri
							*!*				^	04.01.2016 - introducere deduceri in xml
							lnc_faambp = 0
						ELSE
							lnc_faambp = 0
						ENDIF
						ADDPROPERTY(poCoef,'impozit',0.1)

						SELECT crsCoef_diferiti
						LOCATE FOR UPPER(ALLTRIM(constructii)) = IIF(poCoef.oug114_2018=1,'T','F')
						IF FOUND()
							poCoef.c_soms = crsCoef_diferiti.c_soms
							poCoef.salmin= crsCoef_diferiti.salmin
							poCoef.c_casp = crsCoef_diferiti.c_casp
							poCoef.c_medp= crsCoef_diferiti.c_medp
							poCoef.impozit = crsCoef_diferiti.impozit
						ENDIF
						Use In (Select('crsCoef_diferiti'))

						EXIT
					ENDIF

				ENDIF
			ENDFOR

			Use In (Select('crsCoeficientiXML'))
			IF llUpdate
				poCoef.orestas = localen.orestas && nu se actualizeaza prin oproceduri_roadef_sal.prg , am pus-o sa fie &&v2.0.53
				poCoef.c_meds = localen.c_meds
				poCoef.c_somp = localen.c_somp
				poCoef.salmed = localen.salmed
				poCoef.c_munca = IIF(TYPE('localen.c_munca')='L',IIF(localen.c_munca,1,0),localen.c_munca)
				poCoef.dedl1 = localen.dedl1
				poCoef.dedl2 = localen.dedl2
				poCoef.dedper = localen.dedper  && nu se foloseste in calcul salarii, nu se actualizeaza INCA &&v2.0.53
				poCoef.c_dedper = localen.c_dedper  && nu se foloseste in calcul salarii, nu se actualizeaza INCA &&v2.0.53
				poCoef.c_cheltpro = localen.c_cheltpro && nu se foloseste in calcul salarii, nu se actualizeaza INCA &&v2.0.53
				poCoef.c_faambp = lnc_faambp
				poCoef.zilecmplang = localen.zilecmplang
				poCoef.zilecmplangf		 = localen.zilecmplangf
				poCoef.BAZA_INGR = IIF(TYPE('localen.BAZA_INGR')='L',IIF(localen.BAZA_INGR,1,0),localen.BAZA_INGR)
				poCoef.c_cas1 = localen.c_cas1
				poCoef.c_cas2 = localen.c_cas2
				poCoef.c_cas3 = localen.c_cas3
				poCoef.FD_FNUASS = localen.FD_FNUASS
				poCoef.C_FDGARANT = localen.C_FDGARANT
				poCoef.diurnaneimp = localen.diurnaneimp
				poCoef. salminstudii = localen. salminstudii
				DO sal_coef IN oproceduri_roadef_sal.prg WITH .t.
			ENDIF
			Use In (Select('crsDeduceri'))

		CASE  m.GnAn * 12 + m.GnLuna >= 2013*12+7 && este prima luna cu coeficienti in xml si nu as vrea sa suprascriu coeficientii pentru lunile mai vechi
			PRIVATE poCoef,pozile
			Store '' To pozile
			pcschema2=['']
			pcselect2=[select * from ] + gcS + [.sal_calendar where 1=2]
			pcorder2=[luna,an]
			pcfiltru2 = [luna = ] + Alltrim(Str(GnLuna)) + [ and an = ]+Alltrim(Str(GnAn))
			llAfiseaza = .F.
			gencursor('pozile','v_coef',pcselect2,pcfiltru2,pcschema2,pcorder2,llAfiseaza)
			pozile.ca_baza1.afisare()
			Select v_coef
			Scatter Name poCoef
			Use In (Select('v_coef'))

			LOCAL llUpdate,lcFisierXML,lnPos,lcComunPath  ,llSucces ,lcPath ,llOpen ,lcXML ,lnLunaCoeficientiXml,lnc_faambp
			Local loXMLRequest as "Msxml2.xmlhttp"

			IF PCOUNT() <> 1
				llUpdate = .t.
			ELSE
				llUpdate = tlupdate
			ENDIF

			lnPos = Rat("\", Addbs(m.gcAppPath), 2)
			If lnPos > 0
				lcComunPath = Left(m.gcAppPath, lnPos)
			ENDIF


			lcComunPath = lcComunPath + Iif(gcAppName = "CONSAL", "COMUNCONTAFIN\", "COMUNROA\") && d:\contafin\comuncontafin\

			lcFisierXML= Alltrim(Transform(m.lcComunPath + "coeficienti.xml"))


			lcPath = Addbs(Justpath(m.lcFisierXML))
			llOpen = .F.
			llSucces = DownloadSupportFile("coeficienti.xml", m.lcPath, m.llOpen) && proceduri_comune.prg

			If m.llSucces
				lcMesaj = m.lcFisierXML+ ' Actualizare cu succes.'
			Else
				lcMesaj = m.lcFisierXML+ ' ATENTIE: Nu s-a actualizat!'
			Endif && m.llSucces

			IF !FILE(m.lcFisierXML)
				RETURN
			ENDIF
			XMLTOCURSOR(m.lcFisierXML,"crsCoeficientiXML",512)
			SELECT crsCoeficientiXML
			*!*			BROWSE

			select MAX(an*12+luna) as luna from crsCoeficientiXML WHERE an*12+luna <= m.GnAn*12+m.GnLuna INTO CURSOR crsCoeficientiDinLuna
			SELECT crsCoeficientiDinLuna
			lnLunaCoeficientiXml = crsCoeficientiDinLuna.luna
			Use In (Select('crsCoeficientiDinLuna'))

			*!*			loXMLRequest = CreateObject("Msxml2.xmlhttp")
			Try
				loXMLRequest = CreateObject("MSXML2.XMLHTTP.6.0")
			Catch
				loXMLRequest = CreateObject("MSXML2.XMLHTTP.3.0")
			Endtry
			loXMLRequest.open("GET", m.lcFisierXML, .F.)
			loXMLRequest.send(.null.)
			lcXML = loXMLRequest.responseText
			lnNrCoeficienti = OCCURS([<v_coef>], lcXML)


			FOR lnI = 1 TO lnNrCoeficienti


				SELECT crsCoeficientiXML
				GOTO lnI
				IF an*12+luna = lnLunaCoeficientiXml
					SCATTER NAME localen
					IF GnAn*12+GnLuna < 2018*12+1 && incepand cu 2018 nu mai exista fond de risc si accidente, iar deducerile le actualizez prin script
						lcExtract = [<v_coef>] + STREXTRACT(lcXML, '<c_faambp>', '</c_faambp>', lnI) + [</v_coef>]
						XMLTOCURSOR(lcExtract, 'crsfaambp')
						SELECT crsFaambp
						LOCATE FOR ALLTRIM(TRANSFORM(caen)) = ALLTRIM(TRANSFORM(gofirma.caen))
						IF FOUND()
							lnc_faambp = coef
						ELSE
							lnc_faambp = 0 &&15.01.2015 - dadea eroare daca firma nu avea completat codul caen
						ENDIF
						Use In (Select('crsfaambp'))

						*!*					04.01.2016 - introducere deduceri in xml

						Use In (Select('crsDeduceri'))
						lcExtract = [<v_coef>] + STREXTRACT(lcXML, '<tabdeduceri>', '</tabdeduceri>', lnI) + [</v_coef>]
						XMLTOCURSOR(lcExtract, 'crsDeduceri')
						SELECT crsDeduceri
						*!*				^	04.01.2016 - introducere deduceri in xml
						EXIT
					ELSE
						lnc_faambp = 0
					ENDIF

					
				ENDIF


			ENDFOR

			Use In (Select('crsCoeficientiXML'))
			IF llUpdate
				poCoef.orestas = localen.orestas && nu se actualizeaza prin oproceduri_roadef_sal.prg , am pus-o sa fie &&v2.0.53
				poCoef.c_meds = localen.c_meds
				poCoef.c_medp = localen.c_medp
				poCoef.c_soms = localen.c_soms
				poCoef.c_somp = localen.c_somp
				poCoef.c_casp = localen.c_casp
				poCoef.salmin = localen.salmin
				poCoef.salmed = localen.salmed
				poCoef.c_munca = IIF(TYPE('localen.c_munca')='L',IIF(localen.c_munca,1,0),localen.c_munca)
				poCoef.dedl1 = localen.dedl1
				poCoef.dedl2 = localen.dedl2
				poCoef.dedper = localen.dedper  && nu se foloseste in calcul salarii, nu se actualizeaza INCA &&v2.0.53
				poCoef.c_dedper = localen.c_dedper  && nu se foloseste in calcul salarii, nu se actualizeaza INCA &&v2.0.53
				poCoef.c_cheltpro = localen.c_cheltpro && nu se foloseste in calcul salarii, nu se actualizeaza INCA &&v2.0.53
				poCoef.c_faambp = lnc_faambp
				poCoef.zilecmplang = localen.zilecmplang
				poCoef.zilecmplangf		 = localen.zilecmplangf
				poCoef.BAZA_INGR = IIF(TYPE('localen.BAZA_INGR')='L',IIF(localen.BAZA_INGR,1,0),localen.BAZA_INGR)
				poCoef.c_cas1 = localen.c_cas1
				poCoef.c_cas2 = localen.c_cas2
				poCoef.c_cas3 = localen.c_cas3
				poCoef.FD_FNUASS = localen.FD_FNUASS
				poCoef.C_FDGARANT = localen.C_FDGARANT
				poCoef.diurnaneimp = localen.diurnaneimp
				ADDPROPERTY(poCoef,'impozit',0)
				poCoef.impozit=0
				DO sal_coef IN oproceduri_roadef_sal.prg WITH .t.
			ENDIF
			Use In (Select('crsDeduceri'))
		OTHERWISE
			1=1
	ENDCASE
ENDPROC &&actualizez_coeficienti_xml

********************************************************
PROCEDURE updateNrData112

	If Used('crs112')
		Use In crs112
	Endif

*!*		lcSQl = [select id_calendar,an,luna,nrdata112 from sal_calendar order by an desc,luna desc]
*!*		lcCursor = [crs112]
*!*		lnSucces = goExecutor.oExecuta(lcSQl,lcCursor)
	Private pod112,pcschema1,pcselect1
	Store '' To pod112
	pcschema1=['']
	pcselect1=['select id_calendar,an,luna,nrdata112 from sal_calendar where 1=2']
	pcorder1=[an desc,luna desc]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('pod112','crs112',pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
	pod112.ca_baza1.afisare()
	
	oNrData112 = Createobject('frm_completeznrdata112')
	oNrData112.show(1)
	

	If Used('crs112')
		Use In crs112
	ENDIF
	RELEASE pod112
ENDPROC


*******************************************
* PROCEDURE config_spor(  )
* Date : 08/15/05, 13:44:09
* author : liana.macinic
* description: 

****** PARAMETER BLOCK **************
* Parameters : 0
* 
*******************************************
PROCEDURE config_spor(  )
DO update_nom_sporuri IN update_salarii.prg
SELECT v_nomspor

ofrm_spor = CREATEOBJECT('frm_conf_spor')
ofrm_spor.show(1)


ENDPROC
*----------------------------------sfarsit procedura config_spor----------------------------------

*******************************************
* PROCEDURE config_popr(  )
* Date : 08/15/05, 15:26:08
* author : liana.macinic
* description: 

****** PARAMETER BLOCK **************
* Parameters : 0
* 
*******************************************
PROCEDURE config_popr(  )
DO update_nom_popr IN update_salarii.prg
SELECT v_nompopr

ofrm_spor = CREATEOBJECT('frm_conf_popr')
ofrm_spor.show(1)

ENDPROC
*----------------------------------sfarsit procedura config_popr----------------------------------
****************************************************
PROCEDURE update_sal_sarbat
	If Used('sal_sarbat')
		Use In sal_sarbat
	ENDIF
	


	lcSQl = [select data,sarbatoare,id_sarbat from ] + gcS + [.sal_nom_sarbatori where sters = 0 ]
	lcCursor = [sal_sarbat]
	lnSucces = goExecutor.oExecute(lcSQl,lcCursor)
	goExecutor.oReset()

	Return lnSucces

ENDPROC

*------------------------
Function GetPozaFile
	Lparameters  tcFileName
	* tcTip (sectiunea de unde se citesc directorul pdf): factura/contract => email_factura/email_contract
	* tcFileName (numele fisierului): 20160210_123456
	* tcDefaultPrefix: daca se ataseaza un prefix la tcFileName. Se suprascrie cu cel din din setting.ini
	* tcDefaultSufix: daca se ataseaza un sufix la tcFileName. Se suprascrie cu cel din din setting.ini

	Local lcDestinationFile, lcSection, lcFileName
	Local lcPicturePath

	lcFileName = Iif(!Empty(m.tcFileName), Lower(Transform(m.tcFileName)), Sys(2015))
	lcSection = 'cale_poza_legitimatie'  && [cale_poza_legitimatie] / [pdf_recapitulatia_acn]
	lcPicturePath = goApp.ReadIni(m.lcSection, "pozapath")


	If Empty(m.lcPicturePath)
		lcPicturePath = Getdir("", "Alege director pentru stocarea imaginilor de pe legitimatie", "Director imagini", 64)
		If Empty(m.lcPicturePath)
			m.lcPicturePath = m.gcTempPath
		Endif
		goApp.WriteIni(m.lcSection, "pozapath", m.lcPicturePath)
	Endif

	lcDestinationFile = Addbs(m.lcPicturePath)  + m.lcFileName  && contine si extensia
	Return m.lcDestinationFile
Endfunc && GetPDFFile
*------------------------------------



****************************************************************************
* Salveaza o imagine (ex: logo.jpg) in baza de date pentru a fi folosita la rapoarte
****************************************************************************
PROCEDURE Image2Database
	PARAMETERS tnIdPersoana
	lcInputFile = GETFILE('Images:jpg,jpeg,bmp,png,gif,tiff', 'Alege un fisier', 'Alege',0, 'Alege un fisier')
	lnId = 0
	llSucces = .F.
	IF !EMPTY(m.lcInputFile)
		lnId = File2Atasament(m.lcInputFile,,m.tnIdPersoana)
		llSucces = (m.lnId > 0)
	ENDIF 
	AMESSAGEBOX(IIF(m.llSucces, 'Imaginea s-a salvat cu succes in baza de date.','Imaginea NU s-a salvat in baza de date!'),0+64,_screen.Caption)
	RETURN m.llSucces
ENDPROC && Image2Database


***************************************************
* Citeste fisierul de pe disk si adauga atasament in baza de date atas_atasamente
* Se apeleaza cu calea completa a fisierului
* Intoarce id-ul atasamentului
***************************************************
Function File2Atasament
	Lparameters tcFile, tcDescriere,tnIdPersoana

	Private pcFileName, pnId, pcFile, pcDescriere

	Local lcSql, lcSqlIns, lcSqlUpd, llSucces
	pnId = 0
	If !File(m.tcFile)
		tcFile = GETFILE('','Alege un fisier','Alege',0,'Alege un fisier')
		IF EMPTY(m.tcFile)
			Return m.pnId
		ENDIF 	
	Endif

	pcFile = Filetostr(m.tcFile)
	pcFileName = Lower(Justfname(m.tcFile))
	pcDescriere = Iif(!Empty(m.tcDescriere), Alltrim(m.tcDescriere), '')

	
	lcSql = [SELECT id_legitimatie FROM sal_legitimatii WHERE id_salariat = ]+ALLTRIM(STR(tnIdPersoana))+[ and sters = 0]
	lcSqlIns = [insert into sal_legitimatii (id_salariat ,fisier) values (?pcFile, ]+ALLTRIM(STR(tnIdPersoana))+[) returning id_legitimatie into ?@pnId]
	lcSqlUpd = [UPDATE sal_legitimatii SET fisier = ?pcFile, id_salariat = ]+ALLTRIM(STR(tnIdPersoana))+[ WHERE id_legitimatie = ?pnId]

	llSucces = goExecutor.oExecuta(m.lcSql, 'crsAtasamenteTemp')
	If m.llSucces
		Do Case
			Case Reccount('crsAtasamenteTemp') > 1
				amessagebox('Sunt mai multe inregistrari cu acelasi nume de fisier! Nu se salveaza!', 0 + 16, _Screen.Caption)
			Case Reccount('crsAtasamenteTemp') = 1
				pnId = crsAtasamenteTemp.id_atas
		Endcase
		Use In (Select('crsAtasamenteTemp'))

		If Empty(m.pnId)
			llSucces = goExecutor.oExecuta(m.lcSqlIns)
		Else
			llSucces = goExecutor.oExecuta(m.lcSqlUpd)
			pnId = IIF(m.llSucces, m.pnId, 0)
		Endif
	Endif

	Return m.pnId

Endfunc && File2Atasament
