*!* 19.02.2010
*!* marius.mutu
*!*	update_corespondente_cvc - finalizare aprovizionare - corespondenta cont_aprovizionare
*!* 3xx = 401 -> 3xx = 32x

*!* 22.03.2010
*!* marius.mutu
*!*	ccsectii, close_ccsectii

*!* 27.05.2011
*!* marius.mutu
*!*	update_parteneriemail

*!*	07.10.2016
*!*	marius.mutu
*!*	ccsectii - corectie sql

* PROCEDURE update_lunilean(  )
* Date : 06/10/2004, 13:27:54
* author : marius.mutu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:update_lunilean*******************************************
PROCEDURE update_lunilean(  )
	LOCAL lcSql, lcCursor, lnSucces
	lcSql = [select * from contafin_oracle.lunilean]
	lcCursor = [lunilean]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	goExecutor.oReset()

	RETURN lnSucces

ENDPROC
******************************************* SFARSIT: update_lunilean *******************************************


* PROCEDURE update_calendar(  )
* Date : 06/10/2004, 13:27:54
* author : marius.mutu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:update_calendar *******************************************
PROCEDURE update_calendar(  )

		LOCAL lcNumeCal
		STORE '' TO lcNumeCal
		lcSelect = [select varvalue, col_an, col_luna, tip_col_an, tip_col_luna from syn_optiuni_programe WHERE id_prg_owner = ]+ALLTRIM(STR(gnIdProgram)) +[ and UPPER(varname) = 'CALENDAR']
		lcCursor = [crsNumeCal]
		lnsucces = goExecutor.oExecute(lcSelect,lcCursor)
		IF lnsucces < 0
			aMESSAGEBOX('Eroare la selectie ' + goExecutor.cEroare,0+16,"Eroare")
			RETURN
		ENDIF

		SELECT crsNumeCal
		IF RECCOUNT() = 0
			lcNumeCal = 'CALENDAR'
			lcCol_an = 'an'
			lcCol_luna = 'luna'
			lcSel_Col_an = 'an'
			lcSel_Col_luna = ' to_char(' + lcCol_luna + ') '
		ELSE
			lcNumeCal = ALLTRIM(crsNumeCal.varvalue)
			lcCol_an = ALLTRIM(col_an) && an
			lcCol_luna = ALLTRIM(col_luna) && luna
			lctip_col_an = UPPER(ALLTRIM(tip_col_an)) && roaCont = C, roaSal = N
			lctip_col_luna = UPPER(ALLTRIM(tip_col_luna))
			
			DO case
			CASE lctip_col_an = 'N'
				lcSel_Col_an = ' to_char(' + lcCol_an + ') '
			CASE lctip_col_an = 'C'
				lcSel_Col_an = lcCol_an
			ENDCASE 
				
			DO CASE 
			CASE lctip_col_luna = 'N'
				lcSel_Col_luna = ' to_char(' + lcCol_luna + ') '
			CASE lctip_col_luna = 'C'
				lcSel_Col_luna = lcCol_luna
			ENDCASE 	
		ENDIF

		If lcNumeCal = 'CALENDAR'
			lcSelect = [select * from ] + gcS + [.calendar order by anul, luna]
		Else 
			lcSelect = [select ] + lcSel_Col_an + [ as an, ] + lcSel_Col_luna + [ as nl ] + ;
			[,0 as ctvai,0 as ctvam,0 as plafon_casa,0 as plafon_furnizori,0 as plafon_plati,]+;
				 lcCol_an+[ as anul,]+lcCol_luna+;
				[ as luna from ] + lcSchema + [.] + lcNumeCal +;
				 [ order by ] + lcCol_an + [ * 12 + ] + lcCol_luna
		EndIf 

		lcCursor = [calendar]
		lnsucces = goExecutor.oExecute(lcSelect,lcCursor)
	goExecutor.oReset()

	RETURN lnSucces


ENDPROC
******************************************* SFARSIT: update_calendar *******************************************


* PROCEDURE update_firme(  )
* Date : 06/10/2004, 13:27:08
* author : marius.mutu
* description:
******************************************* INCEPUT:update_firme *******************************************
PROCEDURE update_firme(  )

	*** selectez firmele
	LOCAL lcSql, llSucces
	lcSql = [select * from syn_nom_firme order by firma]	

	llSucces = goExecutor.oExecuta(lcSql,'crsFirmeTemp')
	IF llSucces
		SET TEXTMERGE ON TO memvar lcSql NOSHOW
		SELECT v_firme_temp
		SCAN
			\select CAST(<<ALLTRIM(UPPER(schema))>> as varchar2(50)) as schema, 
			\CAST(0 as Number(4)) as an1, CAST(0 as Number(2)) as luna1, min(anul*12+luna) as minanluna, 
			\CAST(0 as Number(4)) as an1, CAST(0 as Number(2)) as luna1, max(anul*12+luna) as maxanluna
			\from <<ALLTRIM(schema)>>.calendar
			\union 
		ENDSCAN
		SET TEXTMERGE TO 
		llSucces = goExecutor.oExecuta(lcSql,'crsFirmeLunaTemp') 
		IF llSucces
			UPDATE crsFirmeLunaTemp SET an2 = INT(maxanluna/12), luna2 = MOD(maxanluna,12), an1 = INT(minanluna/12), luna2 = MOD(minanluna,12)
			UPDATE crsFirmeLunaTemp SET an2 = an2 - 1, luna2 = 12 WHERE luna2 = 0
			UPDATE crsFirmeLunaTemp SET an1 = an1 - 1, luna1 = 12 WHERE luna1 = 0
						 
			SELECT a.*, b.an1, b.luna1, b.an2, b.luna2 from crsFirmeTemp a JOIN crsFirmeLunaTemp b ON PADR(UPPER(a.schema), 50, ' ') = PADR(UPPER(b.schema), 50, ' ') ;
				INTO CURSOR v_firme
		
			USE IN (SELECT('crsFirmeLunaTemp'))
		ENDIF
		USE IN (SELECT('crsFirmeLunaTemp')) 
	ENDIF 

	RETURN IIF(m.llSucces, 1, -1)
ENDPROC
******************************************* SFARSIT: update_firme *******************************************

* PROCEDURE update_firme_util_prog
* Date : 01/04/2005, 08:53:08
* author : marius.mutu
* description:
******************************************* INCEPUT:update_firme_util_prog *******************************************
PROCEDURE update_firme_util_prog
LPARAMETERS tnIdProgram, tnIdUtil

LOCAL lnSucces

PRIVATE pnIdProgram, pnIdUtil
pnIdProgram = tnIdProgram
pnIdUtil = tnIdUtil

*!*		lcSql = [select * from v_nom_firme where id_firma in ] + ;
*!*		[(select id_firma from vdef_util_firme where id_program = ?pnIdProgram and id_util = ?pnIdUtil) ] + ;
*!*		[order by firma]
	lcSql = [{call syn_pack_drepturi.citeste_firme_program(?pnIdProgram,?pnIdUtil)}]
	lcCursor = [v_firme]

	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		aMESSAGEBOX(goExecutor.cEroare,0 +16,'Eroare')
	ENDIF 
	goExecutor.oReset()

	RETURN lnSucces

ENDPROC
******************************************* SFARSIT: update_firme_util_prog *******************************************


* PROCEDURE update_utilizatori(  )
* Date : 06/10/2004, 13:26:23
* author : marius.mutu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:update_utilizatori *******************************************
PROCEDURE update_utilizatori(  )
	LOCAL lcSql, lcCursor, lnSucces
	lcSql = [SELECT * from utilizatori]
	lcCursor = [v_utilizatori]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	goExecutor.oReset()

	RETURN lnSucces

ENDPROC
******************************************* SFARSIT: update_utilizatori *******************************************

* PROCEDURE update_judete(  )
* Date : 11.10.2004, 15:24:02
* author : catalin.neagu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:update_judete *******************************************
PROCEDURE update_judete(  )
	LOCAL lcSql, lcCursor, lnSucces
	lcSql = [SELECT * from syn_vnom_judete order by judet]
	lcCursor = [v_jud]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	goExecutor.oReset()

	RETURN lnSucces
ENDPROC
******************************************* SFARSIT: update_judete *******************************************
**********************************************************************
PROCEDURE cccateg_ent
	LOCAL lcSql, lcCursor, lnSucces

	TEXT TO lcSql NOSHOW 
select 1 as ordine,
       CAST(null as number(10)) as id_categorie_entitate,
       CAST(null as varchar2(150)) as categorie_entitate
  from dual
union
select 2 as ordine, id_categorie_entitate, categorie_entitate
  from vnom_categorii_entitati
 where inactiv = 0
 order by ordine, categorie_entitate
	ENDTEXT 
	lcCursor = 'v_nom_categ_ent'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC
***********************************************************************PROCEDURE close_categ_ent
PROCEDURE close_categ_ent
	IF USED('v_nom_categ_ent')	
		USE IN v_nom_categ_ent
	ENDIF 
ENDPROC && close_categ_ent
**********************************************************************
PROCEDURE cclocalitati
	LOCAL lcSql, lcCursor, lnSucces
	lcSql = [select id_loc, localitate, id_judet, judet, id_tara, tara from syn_vnom_localitati where inactiv = 0 order by judet nulls last,tara,localitate]
	lcCursor = 'v_nom_localitati'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC
***********************************************************************PROCEDURE close_cclocalitati
PROCEDURE close_cclocalitati
	IF USED('v_nom_localitati')	
		USE IN v_nom_localitati
	ENDIF 
ENDPROC && close_cclocalitati
***********************************************************************
PROCEDURE ccJudete
	LOCAL lcSql, lcCursor, lnSucces
	lcSql = 'select id_judet, judet, indicativ from '+gcS+'.vnom_judete order by judet'
	lcCursor = 'v_nom_judete'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC && ccJudete
***********************************************************************
PROCEDURE close_ccJudete
	IF USED('v_nom_judete')
		USE IN v_nom_judete
	ENDIF 
ENDPROC && close_ccJudete
***********************************************************************
PROCEDURE ccTari
	LOCAL lcSql, lcCursor, lnSucces
	lcSql = [select null as id_tara, '' as tara, '' as prescurtare from dual union all] +;
	[ select id_tara, tara, prescurtare from syn_nom_tari order by tara nulls first]
	lcCursor = 'v_nom_tari'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC && ccTari
***********************************************************************
PROCEDURE close_ccTari
	IF USED('v_nom_tari')
		USE IN v_nom_tari
	ENDIF 
ENDPROC && close_ccTari
***********************************************************************
PROCEDURE cctipuri
	LOCAL lcSql, lcCursor, lnSucces
	lcSql='select id_tip_part,tip_partener from '+gcS+'.vnom_tip_parteneri order by tip_partener' &&id_tip_part'
	lcCursor = 'v_nom_tip_parteneri'

	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC
***********************************************************************
PROCEDURE close_cctipuri
	IF USED('v_nom_tip_parteneri')	
		USE IN v_nom_tip_parteneri
	ENDIF 
ENDPROC && close_cctipuri

***********************************************************************
PROCEDURE config_ireg
	LOCAL lcSql, lcCursor, lnSucces
	lcSql='select * from '+gcS+'.vconfig_cont_ireg order by cont'
	lcCursor = 'v_config_cont_ireg'

	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		aMESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
	ENDIF 
	
	RETURN lnSucces

ENDPROC && config_ireg
***********************************************************************
PROCEDURE close_config_ireg
	IF USED('v_config_cont_ireg')	
		USE IN v_config_cont_ireg
	ENDIF 
ENDPROC && close_config_ireg

***********************************************************************
* PROCEDURE update_coresp_tip_part(  )
* Date : 13/10/2004, 10:46:59
* author : marius.mutu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:update_coresp_tip_part*******************************************
PROCEDURE update_coresp_tip_part(  )

	*** deschid corespondentele parteneri
	lcSql = [select * from ] + gcS + [.coresp_tip_part]
	lcCursor = [coresp_tip_part]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC
******************************************* SFARSIT: update_coresp_tip_part*******************************************


* PROCEDURE update_coresp_tip_cont(  )
* Date : 13/10/2004, 10:49:03
* author : marius.mutu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:update_coresp_tip_cont *******************************************
PROCEDURE update_coresp_tip_cont(  )

	lcSql = [select * from ] + gcS + [.vcoresp_tip_cont]
	lcCursor = [coresp_tip_cont]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC
******************************************* SFARSIT: update_coresp_tip_cont *******************************************

PROCEDURE cctipuri_selectate
	LPARAMETERS tnId_part
	lnId_part = tnId_part

	lcSql='select id_tip_part,tip_partener from '+gcS+'.VCORESP_TIP_PART where id_part = '+ALLTRIM(STR(lnId_part))+ 'order by tip_partener '
	lcCursor = 'v_nom_tip_parteneri_selectati'

	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC

***********************************************************************
PROCEDURE close_cctipuri_selectate
	IF USED('v_nom_tip_parteneri_selectati')	
		USE IN v_nom_tip_parteneri_selectati
	ENDIF 
ENDPROC && close_cctipuri_selectate

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

PROCEDURE cctipuri_selectate_NOU
	LPARAMETERS tnId_TIP_part
	
	IF PCOUNT()<1 OR TYPE('tnId_TIP_part')#'N'
		RETURN -1
	ENDIF 
	
	lnId_TIP_part = tnId_TIP_part
	
	lcSql='select id_tip_part,tip_partener from '+gcS+'.VNOM_TIP_PARTENERI where id_TIP_part = '+ALLTRIM(STR(lnId_TIP_part))+ 'order by tip_partener '
	lcCursor = 'v_nom_tip_parteneri_selectati'

	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC


***********************************************************************
PROCEDURE close_cctipuri_selectate_NOU
	IF USED('v_nom_tip_parteneri_selectati')	
		USE IN v_nom_tip_parteneri_selectati
	ENDIF 
ENDPROC && close_cctipuri_selectate_NOU

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

PROCEDURE ccvalute

	lcSql='select id_valuta,nume_val from '+gcS+'.vnom_valute order by nume_val'
	lcCursor = 'v_nom_valute'

	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC




******************************************* SFARSIT: update_parteneri *******************************************
* PROCEDURE update_actper(  )
* Date : 09.11.2004, 09:33:32
* author : catalin.neagu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:update_actper *******************************************
PROCEDURE update_actper(tnCod)

	lcCod = ALLTRIM(STR(tnCod))
	lcSql = [SELECT * from ] + gcS + [.vact where cod = ] + lcCod
	lcCursor = [ACTACT]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	goExecutor.oReset()

	IF lnSucces>0
		SELECT * FROM actact INTO CURSOR actactan READWRITE
	ENDIF
	IF USED('actact')
		USE IN actact
	ENDIF
	RETURN lnSucces

ENDPROC
******************************************* SFARSIT: update_actper *******************************************


* PROCEDURE Get_Lista_Act
* Date : 09/11/2004, 15:05:42
* author : marius.mutu
* description: creeaza o lista cu campurile din act

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:Get_Lista_Act*******************************************
PROCEDURE Get_Lista_Act
	LOCAL lcLista
	lcLista = []

	lcSql = [select * from ] + gcS + [.ACT WHERE 1=2]
	lcCursor = [CRS_ACT]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	goExecutor.oReset()
	IF lnSucces < 0
		aMESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
	ENDIF
	IF lnSucces > 0
		SELECT CRS_ACT
		lnCount = FCOUNT()
		FOR i = 1 TO lnCount
			SELECT CRS_ACT
			lcFieldName = UPPER(ALLTRIM(FIELD(i)))
			lcLista = lcLista + [,] + lcFieldName
		ENDFOR
		lcLista = SUBSTR(lcLista,2)
	ENDIF
	IF USED('crs_Act')
		USE IN CRS_ACT
	ENDIF

	RETURN lcLista
ENDPROC
******************************************* SFARSIT: Get_Lista_Act *******************************************


* PROCEDURE update_optiuni(  )
* Date : 15.11.2004, 10:08:49
* author : catalin.neagu
* description: 

****** PARAMETER BLOCK **************
* Parameters : 0
* 
******************************************* INCEPUT:update_optiuni *******************************************
PROCEDURE update_optiuni(  )

	lcSql='select * from '+gcS+'.optiuni order by varname'
	lcCursor = 'v_optiuni'

	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC
******************************************* SFARSIT: update_optiuni *******************************************

******************************************* INCEPUT:update_exceptii_ireg **************************************
PROCEDURE update_exceptii_ireg(  )

	lcSql = [select * from ] + gcS + [.exceptii_ireg]
	lcCursor = [exceptii_ireg]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC
******************************************* SFARSIT:update_exceptii_ireg ***************************************

******************************************* INCEPUT:update_cote_TVA **************************************
PROCEDURE update_cote_TVA(  )
	
	IF USED('cote_TVA')
		USE IN cote_TVA
	ENDIF 
	
	lcSql = [select * from ] + gcS + [.cote_TVA where an =?gnAn and luna = ?gnLuna]

	lcCursor = [cote_TVA]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces

ENDPROC
******************************************* SFARSIT:update_cote_TVA ***************************************

******************************************* INCEPUT:update_jtva_coloane **************************************
Procedure update_jtva_coloane
	Lparameters tcTipJ,tcNumeCursor,tnTip
	*!*	tcTipJ 	> [JC]
	*!*			> [JV]
	*!*	tnTip	>	0	-	arata doar baza si neimpozabile
	*!*			>	1	-	arata baza,tva si neimpozabile
	*!*			>	2	-	arata doar baza si neimpozabile	-	fara neexigibile
	*!*			>	3	-	arata baza,tva si neimpozabile	-	fara neexigibile
	*!*			>	4	-	arata doar baza si neimpozabile	-	fara exigibile
	*!*			>	5	-	arata baza,tva si neimpozabile	-	fara exigibile
	*!* 		>   6   -   arata tot
	Local lcFiltru, lcNumeCursor, lnTip
	If Empty(tcNumeCursor)
		lcNumeCursor = [jtva_coloane]
	Else
		lcNumeCursor = tcNumeCursor
	Endif
	If Used(lcNumeCursor)
		Use In (lcNumeCursor)
	Endif
	*!*	modificare	ROAFACTURARE v 2.2.0
	lnTip = iif(empty(tnTip),0,tnTip)
	If inlist(lnTip,0,2,4)
	*!*	If Empty(tnTip)
	*!*	modificare	ROAFACTURARE v 2.2.0	^
		lcFiltru = [where afisat > 0 and id_jtva_coloana > 0]
	ELSE
		IF m.lnTip  = 6
			lcFiltru = [where 1=1]	
		ELSE 	
			lcFiltru = [where id_jtva_coloana > 0]
		ENDIF 
	Endif
	*!*	modificare	ROAFACTURARE v 2.2.0
	do case
		case inlist(lnTip,2,3)
			lcFiltru = lcFiltru + [ and id_jtva_ex is null]
		case inlist(lnTip,4,5)
			lcFiltru = lcFiltru + [ and id_jtva_neex is null]
		otherwise
			lcFiltru = lcFiltru
	endcase
	*!*	modificare	ROAFACTURARE v 2.2.0	^
	*!*	modificare 12.07.2010
	lcFiltru = lcFiltru + [ and cota_tva in (select procent from cote_tva where sters = 0 and an = ?gnAn and luna = ?gnLuna)]
	*!*	modificare 12.07.2010	^
	If !Empty(tcTipJ)
		lcFiltru = lcFiltru + [ and ] + Alltrim(tcTipJ) + [ = 1]
	Endif

	lcSql = [select * from vjtva_coloane ] + lcFiltru + [ order by ordine]
	lnSucces = goExecutor.oExecute(lcSql,lcNumeCursor)
	If lnSucces < 0
		amessagebox(goExecutor.cEroare,16,"Eroare")
	ELSE
		SELECT (m.lcNumeCursor)
		INDEX on id_jtva_coloana TAG id_jtva	
	Endif
	goExecutor.oReset()
	Return lnSucces

Endproc
******************************************* SFARSIT:update_jtva_coloane ***************************************

PROCEDURE update_saft_taxtable
	LPARAMETERS tcNumeCursor

	Local lcSelect, lcNumeCursor, lcNumeCursorTemp, lcSql, llSucces
	lcSelect = SELECT()

	lcNumeCursor = IIF(!EMPTY(m.tcNumeCursor), m.tcNumeCursor, 'saft_taxtable')
	lcNumeCursorTemp = SYS(2015)
	CREATE cursor (m.lcNumeCursor) (taxname C(250) null, typename C(250) null, taxcode N(6) null, taxtype N(3) null, descriere C(250) null, tip C(100) null, descriere_tip C(250) null, ;
		procent_taxa N(7,2) null, procent_prorata N(7,2) null, inactiv N(1) null, tva N(1) null, wht N(1) null, tva_achizitii N(1) null, tva_livrari N(1) null)

	* adaug o inregistrare goala pentru a putea alege fara taxcode
	INSERT INTO (m.lcNumeCursor) (taxname, taxcode, descriere, procent_taxa, tva, wht, tva_achizitii, tva_livrari) VALUES ('', 0, '', 0, 1, 1, 1, 1)

	lcSql = [select * from vsaft_taxtable order by tva, tva_livrari, tva_achizitii, wht, taxcode]
	llSucces = goExecutor.oExecuta(m.lcSql, m.lcNumeCursorTemp)

	SELECT (m.lcNumeCursor)
	APPEND FROM DBF(m.lcNumeCursorTemp)
	INDEX on taxcode TAG taxcode

	USE IN (SELECT(m.lcNumeCursorTemp))

	SELECT (m.lcSelect)
	RETURN m.llSucces
ENDPROC 

PROCEDURE update_saft_mecanisme_plati
	LPARAMETERS tcNumeCursor

	Local lcSelect, lcNumeCursor, lcSql, llSucces
	lcSelect = SELECT()
	lcNumeCursor = IIF(!EMPTY(m.tcNumeCursor), m.tcNumeCursor, 'saft_mecanisme_plati')
	lcNumeCursorTemp = SYS(2015)

	CREATE cursor (m.lcNumeCursor) (mechanismcode C(9) null, name C(250) null, methodcode C(9) null, methodname C(250) null, paymentname C(250) null, afisat N(1) null, ordine N(3) null)
	* adaug o inregistrare goala pentru a putea alege fara mechanismcode
	INSERT INTO (m.lcNumeCursor) (mechanismcode, name, methodcode,methodname,afisat,ordine) VALUES ('','','','',1,0)
		
	lcSql = [select * from vsaft_mecanisme_plati order by ordine]
	llSucces = goExecutor.oExecuta(m.lcSql, m.lcNumeCursorTemp)
	
	SELECT (m.lcNumeCursor)
	APPEND FROM DBF(m.lcNumeCursorTemp)
	INDEX on mechanismcode TAG mcode

	USE IN (SELECT(m.lcNumeCursorTemp))
		
	SELECT (m.lcSelect)
	RETURN m.llSucces
ENDPROC && update_saft_mecanisme_plati

PROCEDURE update_saft_tip_facturi
	LPARAMETERS tcNumeCursor

	Local lcSelect, lcNumeCursor, lcSql, llSucces
	lcSelect = SELECT()
	lcNumeCursor = IIF(!EMPTY(m.tcNumeCursor), m.tcNumeCursor, 'saft_tip_facturi')
	lcNumeCursorTemp = SYS(2015)

	CREATE cursor (m.lcNumeCursor) (cod N(3) null, tip_saftname C(200) null)
	* adaug o inregistrare goala pentru a putea alege fara mechanismcode
	INSERT INTO (m.lcNumeCursor) (cod, tip_saftname) VALUES (null,'')
		
	lcSql = [select * from vsaft_tip_facturi order by tip_saftname]
	llSucces = goExecutor.oExecuta(m.lcSql, m.lcNumeCursorTemp)
	
	SELECT (m.lcNumeCursor)
	APPEND FROM DBF(m.lcNumeCursorTemp)
	INDEX on cod TAG cod
	
	USE IN (SELECT(m.lcNumeCursorTemp))
		
	SELECT (m.lcSelect)
	RETURN m.llSucces
ENDPROC && update_saft_tip_facturi

PROCEDURE update_um
	LPARAMETERS tcNumeCursor

	Local lcSelect, lcNumeCursor, lcSql, llSucces
	lcSelect = SELECT()
	lcNumeCursor = IIF(!EMPTY(m.tcNumeCursor), m.tcNumeCursor, 'vnom_um')
	lcSql = [select * from vnom_um]
	llSucces = goExecutor.oExecuta(m.lcSql, m.lcNumeCursor)
	
	SELECT (m.lcNumeCursor)
	INDEX on UM TAG UM
	
	SELECT (m.lcSelect)
	RETURN m.llSucces
ENDPROC && update_um

PROCEDURE update_um_iso
	LPARAMETERS tcNumeCursor

	Local lcSelect, lcNumeCursor, lcSql, llSucces
	lcSelect = SELECT()
	lcNumeCursor = IIF(!EMPTY(m.tcNumeCursor), m.tcNumeCursor, 'vnom_um_iso')
	lcSql = [select * from syn_vnom_um_iso ORDER BY um_iso]
	llSucces = goExecutor.oExecuta(m.lcSql, m.lcNumeCursor)
	
	SELECT (m.lcNumeCursor)
	INDEX on cod_um_iso TAG cod_um_iso
	SET ORDER TO
	SELECT (m.lcSelect)
	RETURN m.llSucces
ENDPROC && update_um_iso


***************************************** INCEPUT:update_corespondente_cvc ************************************
Procedure update_corespondente_cvc
	If Used('crsconfigcvc')
		Use In crsconfigcvc
	Endif
	*!* 19.02.2010
	lcSql = [select cont,cont_chelt,cont_venit, cont_aprovizionare, cont_diferente from vcoresp_cont_venchelt order by cont]
	*!* 19.02.2010 ^
	lnSucces = goExecutor.oExecute(lcSql,[crsconfigcvc])
	If lnSucces < 0
		amessagebox(goExecutor.cEroare,16,"Eroare")
	Endif
	goExecutor.oReset()
	Return lnSucces

Endproc
***************************************** SFARSIT:update_corespondente_cvc *************************************
******************************************* INCEPUT:update_modele_masini **************************************
Procedure update_modele_masini
Lparameters tnIdMarcaMasina
If Used('crsmodelemasini')
	Use In crsmodelemasini
Endif
If Empty(tnIdMarcaMasina)
	lcConditie=[]
Else
	lcConditie=[where id_marca_masina=]+Alltrim(Str(tnIdMarcaMasina))
Endif
lcSql = [select * from ] + gcS + [.vnom_modele_masini ]+lcConditie+[ order by model_masina]
lcCursor = [crsmodelemasini]
lnSucces = goExecutor.oExecute(lcSql,lcCursor)
If lnSucces < 0
	amessagebox(goExecutor.cEroare,16,"Eroare")
Endif
goExecutor.oReset()

Return lnSucces
Endproc	&&	update_modele_masini
******************************************* SFARSIT:update_modele_masini **************************************

********************* INCEPUT Get_programid **********************
* PROCEDURE Get_programid( tcProgramName )
* Date : 04/01/05, 10:02:08
* author : marius.mutu
* description: 
PROCEDURE Get_programId
LPARAMETERS  tcProgramName
LOCAL lnProgramId
lnProgramId = -1

PRIVATE lcProgramName
lcProgramName = UPPER(ALLTRIM(tcProgramName))

lnSucces = goExecutor.oExecute('SELECT IDE_PROGRAM FROM vdef_programe WHERE UPPER(NUME) = ?lcProgramName','crsProgram')
IF lnSucces < 0
	aMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
ENDIF 
SELECT crsProgram
IF RECCOUNT() > 0
	GO top
	lnProgramId = ide_program
ENDIF 		
IF USED('crsProgram')
	USE IN crsProgram
ENDIF 
RETURN lnProgramId

ENDPROC
********************* SFARSIT Get_programid **********************


********************* INCEPUT Acces_program_util **********************
* PROCEDURE Acces_program_util( tnProgramId, tnUtilId )
* Date : 04/01/05, 10:18:14
* author : marius.mutu
* description: 
PROCEDURE acces_program_util( tnProgramId, tnUtilId )
*!* tnProgramId = identificatorul de program
*!* tnUtilId = id utilizator

LOCAL llAcces
llAcces = .F.

Private lnProgramId,lnUtilId
lnProgramId = tnProgramId
lnUtilId = tnUtilId
*!* MODIFICAT 03.11.2005
*!* MARIUS.MUTU
lnSucces = goExecutor.oExecute('SELECT count(*) as acces FROM vdef_util_programe WHERE ID_UTIL = ?lnUtilId and ID_PROGRAM = ?lnProgramId','crsAcces')
IF lnSucces < 0
	aMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
ENDIF 
SELECT crsAcces
IF RECCOUNT() > 0
	GO top
	IF acces >= 1
		llAcces = .T.
	ENDIF 	
ENDIF 		
IF USED('crsAcces')
	USE IN crsAcces
ENDIF 
RETURN llAcces

ENDPROC
********************* SFARSIT Acces_program_util **********************


********************* INCEPUT GetAcces **********************
* PROCEDURE GetAcces( tnIdProgram, tnIdUtil, tnIdFirma )
* Date : 04/01/05, 10:18:14
* author : marius.mutu
* description: 
PROCEDURE GetAcces(tnIdProgram, tnIdUtil, tnIdFirma)

LOCAL lnAcces
lnAcces = -1

Private lnIdProgram, lnIdUtil, lnIdFirma
lnIdProgram = tnIdProgram
lnIdUtil = tnIdUtil
lnIdFirma = tnIdFirma

lnSucces = goExecutor.oExecute('SELECT acces FROM vutil_drept WHERE ID_UTIL = ?lnIdUtil and ID_PROG = ?lnIdProgram and id_firma = ?lnIdFirma','crsAcces')
IF lnSucces < 0
	aMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
ENDIF 
SELECT crsAcces
IF RECCOUNT() > 0
	GO top
	lnAcces = acces
ENDIF 		
IF USED('crsAcces')
	USE IN crsAcces
ENDIF 
RETURN lnAcces

ENDPROC
********************* SFARSIT GetAcces **********************

********************* INCEPUT GetNivel **********************
* PROCEDURE GetNivel(tnIdProgram, tnIdUtil, tnIdFirma)
* Date : 04/01/05, 10:18:14
* author : marius.mutu
* description: 
PROCEDURE GetNivel(tnIdProgram, tnIdUtil, tnIdFirma)

LOCAL lnNivel
lnNivel = -1

Private lnIdProgram, lnIdUtil, lnIdFirma
lnIdProgram = tnIdProgram
lnIdUtil = tnIdUtil
lnIdFirma = tnIdFirma

lnSucces = goExecutor.oExecute('SELECT nivel FROM vutil_drept WHERE ID_UTIL = ?lnIdUtil and ID_PROG = ?lnIdProgram and id_firma = ?lnIdFirma','crsNivel')
IF lnSucces < 0
	aMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
ENDIF 
SELECT crsNivel
IF RECCOUNT() > 0
	GO top
	lnNivel = nivel
ENDIF 		
IF USED('crsNivel')
	USE IN crsNivel
ENDIF 
RETURN lnNivel

ENDPROC
********************* SFARSIT GetNivel **********************

********************* INCEPUT Get_id_prg_owner **********************
PROCEDURE Get_id_prg_owner(tnId_program)

PRIVATE pnId_program
pnId_program = tnId_program

LOCAL lnIde_program 
lnIde_program = -1

lnSucces = goExecutor.oExecute('SELECT IDE_PROGRAM FROM vprograme WHERE ID_PROG = ?pnId_program','crsProgram')
IF lnSucces < 0
	aMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
ENDIF 
SELECT crsProgram
IF RECCOUNT() > 0
	GO top
	lnIde_program = ide_program
ENDIF 		
IF USED('crsProgram')
	USE IN crsProgram
ENDIF 
RETURN lnIde_program 

ENDPROC && Get_id_prg_owner
********************* SFARSIT Get_id_prg_owner **********************

*******************************************
* PROCEDURE IS_LUNA_BLOCATA(  )
* Date : 01/11/2005, 14:34:03
* author : marius.mutu
* description: 
*******************************************
PROCEDURE IS_LUNA_BLOCATA
PARAMETERS tcS, tnIdePrg, tnAn, tnLuna


PRIVATE pcS, pnIdePrg, pnAn, pnLuna, pnLunaBlocata
pcS = tcS
pnIdePrg = tnIdePrg
pnAn = tnAn
pnLuna = tnLuna
pnLunaBlocata = 0


lcSql = [begin PACK_FIRMA.IS_LUNA_BLOCATA(?pcS, ?pnIdePrg, ?pnAn, ?pnLuna, ?@pnLunaBlocata); end;]
*!*lcSql = [begin PACK_FIRMA.IS_LUNA_BLOCATA(?gcS, ?gnId_prg_owner, ?gnAn, ?gnLuna, ?@pnLunaBlocata); end;]
lnSucces = goExecutor.oexecute(lcSql)
IF lnSucces < 0
	aMESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
ENDIF 

RETURN IIF(pnLunaBlocata = 1, .T., .F.)

ENDPROC
*----------------------------------sfarsit procedura IS_LUNA_BLOCATA----------------------------------




*----------------------------------inceput procedura update_placont----------------------------------
*!*	 	PARAMETRII: CONT SINTETIC / NIMIC, ANUL 
*!*		CREEAZA UN CURSOR CU CONTUL / CONTURILE SINTETICE DIN PLANUL DE CONTURI
*!*		RETURN - NUMELE CURSORULUI

PROCEDURE update_plcont
LPARAMETERS tcCont, tnAn

	LOCAL lcCont, lcReturn, lnSucces, lnAn, lcCursor
	lcCont = ALLTRIM(tcCont)
	lcReturn = ""
	lnAn = tnAn
	
	IF !EMPTY(lcCont)
		lcSql=[select id_plcont,cont,tip_sold from ] + gcS + [.Vplcont_sintetic where cont = '] + lcCont + [' and an = ] + ALLTRIM(STR(tnAn)) + [ order by cont]
	ELSE
		lcSql=[select id_plcont,cont,tip_sold from ] + gcS + [.Vplcont_sintetic WHERE an = ] + ALLTRIM(STR(gnan)) + [ order by cont]	
	ENDIF 	

	lcCursor = 'v_nom_cont'
	IF USED(lcCursor)	
		USE IN (lcCursor)
	ENDIF 
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	
	IF lnSucces < 0
		aMESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
	ENDIF 
	
	&& INTORC NUMELE CURSORULUI DACA SUCCES
	IF lnSucces > 0
		lcReturn = "v_nom_cont"
	ENDIF 
	
	RETURN lcReturn

ENDPROC && get_cont
*----------------------------------sfarsit procedura update_placont----------------------------------

*----------------------------------inceput procedura update_placont----------------------------------
*!*	 	PARAMETRII: CONT SINTETIC, ANUL 
*!*		CREEAZA UN CURSOR CU CONTUL / CONTURILE SINTETICE DIN PLANUL DE CONTURI
*!*		RETURN - NUMELE CURSORULUI

PROCEDURE update_placont
	LPARAMETERS tcCont, tnAn
	
	LOCAL lcCont, lcReturn, lnSucces, lnAn, lcCursor
	
	lcCont = ALLTRIM(tcCont)
	lnAn = tnAn
	lcReturn = ""	

	lcSql = [select acont, acont || ' - ' || explicatie as denumire from ] + gcs + [.vplcont_analitic where cont = ']+;
	lcCont + [' and an = ] + ALLTRIM(STR(lnAn)) + [ order by acont]
	lcCursor = 'v_nom_acont'
	
	IF USED(lcCursor)	
		USE IN (lcCursor)
	ENDIF 	
	
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	
	IF lnSucces < 0
		aMESSAGEBOX(goExecutor.cEroare,16,'Eroare')
	ENDIF 		
	

	IF USED('v_acont_tot')	
		USE IN v_acont_tot
	ENDIF 	
	
	CREATE CURSOR v_acont_tot (acont c(4), denumire c(100))
	INSERT INTO v_acont_tot (acont, denumire) values('-1', "<TOATE ANALITICELE>")

	IF USED('v_nom_acont')
		SELECT v_acont_tot
		APPEND FROM DBF('v_nom_acont')	
		USE IN v_nom_acont
	ENDIF	
	
	&& INTORC NUMELE CURSORULUI DACA SUCCES
	IF lnSucces > 0
		lcReturn = "v_acont_tot"
	ENDIF 
		
	RETURN lcReturn		

ENDPROC && update_placont
*---------------------------------- sfarsit procedura update_placont----------------------------------

PROCEDURE ccsucursale_mama

	LOCAL lcSql, lcCursor, lnSucces
	lcSql = 'select id_sucursala,sucursala from vnom_sucursale where id_mama = ?gnIdFirma order by sucursala'
	lcCursor = 'vnom_sucursale_mama'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		AMESSAGEBOX(goExecutor.oPrelucrareEroare(),0+16,'Eroare')
	ENDIF 	
	RETURN lnSucces
ENDPROC && ccsucursale_mama
**********************************************************************
PROCEDURE close_ccsucursale_mama
	USE IN (SELECT('vnom_sucursale_mama'))
ENDPROC && close_ccsucursale_mama

**********************************************************************
PROCEDURE ccsucursale

	LOCAL lcSql, lcCursor, lnSucces
	*!*	modificare ROADEF v 2.0.11 : am adaugat e_mama
	*!* modificare ROADEF v 2.0.16 : am adaugat filtrul inactiv = 0
	lcSql = 'select id_sucursala,sucursala,e_mama from vnom_sucursale where inactiv=0 order by sucursala'
	lcCursor = 'vnom_sucursale'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		AMESSAGEBOX(goExecutor.oPrelucrareEroare(),0+16,'Eroare')
	ENDIF 	
	RETURN lnSucces

ENDPROC && ccsucursale
***********************************************************************PROCEDURE close_cclocalitati
PROCEDURE close_ccsucursale
	IF USED('vnom_sucursale')	
		USE IN vnom_sucursale
	ENDIF 
ENDPROC && close_ccsucursale


**********************************************************************
PROCEDURE cctipuri_gestiuni
	LOCAL lcSql, lcCursor, lnSucces
	lcSql = 'select nume_tip,id_tipgest from vtipuri_gestiuni where id_tipgest <> 0 order by id_tipgest'
	lcCursor = 'vtipuri_gestiuni'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		AMESSAGEBOX(goExecutor.oPrelucrareEroare(),0+16,'Eroare')
	ENDIF 	
	RETURN lnSucces

ENDPROC && cctipuri_gestiuni

***********************************************************************
PROCEDURE close_cctipuri_gestiuni
	IF USED('vtipuri_gestiuni')	
		USE IN vtipuri_gestiuni
	ENDIF 
ENDPROC && close_cctipuri_gestiuni


**********************************************************************
PROCEDURE ccgrupuri_utilizatori

	LOCAL lcSql, lcCursor, lnSucces
	lcSql = 'select id_grup, id_tata, denumire_grup, inactiv, nume_parinte from vgrupuri_utilizatori where inactiv = 0 order by denumire_grup'
	lcCursor = 'vgrupuri_utilizatori'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		AMESSAGEBOX(goExecutor.oPrelucrareEroare(),0+16,'Eroare')
	ENDIF 	
	RETURN lnSucces

ENDPROC && ccgrupuri_utilizatori

***********************************************************************
PROCEDURE close_ccgrupuri_utilizatori
	IF USED('vgrupuri_utilizatori')	
		USE IN vgrupuri_utilizatori
	ENDIF 
ENDPROC && close_ccgrupuri_utilizatori


**********************************************************************
*!* utilizatorii cu acces pe firma curenta
PROCEDURE ccutilizatori

	LOCAL lcSql, lcCursor, lnSucces
*!*	modificare ROADEF v 2.0.16 : am adaugat filtrul inactiv = 0
	lcSql = [select distinct a.id_util,a.utilizator from syn_vutilizatori a join syn_vdef_util_firme b on a.id_util = b.id_util ] + ;
		[WHERE b.id_firma = ?gnIdFirma and a.inactiv = 0 order by a.utilizator]
	lcCursor = 'vutilizatori'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		AMESSAGEBOX(goExecutor.oPrelucrareEroare(),0+16,'Eroare')
	ENDIF 	
	RETURN lnSucces

ENDPROC && ccutilizatori
***********************************************************************
PROCEDURE close_ccutilizatori
	IF USED('vutilizatori')	
		USE IN vutilizatori
	ENDIF 
ENDPROC && close_ccutilizatori

***********************************************************************
*** intoarce loMonedaNationala.id_valuta, .nume_valuta
PROCEDURE GetMonedaNationala
	LOCAL lcSelect, lcSql, lcCursor, lnSucces

	lcSelect = SELECT()
	
	lcSql = [SELECT id_valuta, nume_val FROM nom_valute WHERE sters = 0 AND inactiv = 0 AND (id_valuta = 0 or moneda_nationala = 1) AND rownum = 1]
	lcCursor = SYS(2015)
	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	IF lnSucces < 0 
		AMESSAGEBOX(goExecutor.oPrelucrareEroare(),0+16,'Eroare')
	
		loValuta = GetHash()
		loValuta.SetValue("id_valuta",0)
		loValuta.SetValue("nume_val","LEI")		
	ELSE
		IF RECCOUNT(lcCursor) < 1
			loValuta = GetHash()
			loValuta.SetValue("id_valuta",0)
			loValuta.SetValue("nume_val","LEI")		
		ELSE 
			SELECT (lcCursor)
			SCATTER NAME loValuta
		ENDIF 	
	ENDIF 	
	IF USED(lcCursor)
		USE IN (lcCursor)
	ENDIF 
		
	SELECT (lcSelect)
	RETURN loValuta
ENDPROC && GetMonedaNationala


**********************************************************************
PROCEDURE cccalculatoare

	LOCAL lcSql, lcCursor, lnSucces
	lcSql = 'select id_calc, id_sucursala, denumire, inactiv, descriere, sucursala from vcalculatoare where inactiv = 0 order by denumire'
	lcCursor = 'vcalculatoare'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		AMESSAGEBOX(goExecutor.oPrelucrareEroare(),0+16,'Eroare')
	ENDIF 	
	RETURN lnSucces

ENDPROC && cccalculatoare

***********************************************************************
PROCEDURE close_cccalculatoare
	IF USED('vcalculatoare')	
		USE IN vcalculatoare
	ENDIF 
ENDPROC && close_cccalculatoare

**********************************************************************
PROCEDURE ccsetari

	LOCAL lcSql, lcCursor, lnSucces
	lcSql = 'select id, setare, descriere, tip, enums, tabel, coloane, schema, titlucoloane, idcoloana, resultcoloana, titlu, filtru, filtruoriginal, ordine from setari order by setare'
	lcCursor = 'vsetari'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		AMESSAGEBOX(goExecutor.oPrelucrareEroare(),0+16,'Eroare')
	ENDIF 	
	RETURN lnSucces

ENDPROC && ccsetari

***********************************************************************
PROCEDURE close_ccsetari
	IF USED('vsetari')	
		USE IN vsetari
	ENDIF 
ENDPROC && close_ccsetari

***********************************************************************
&&Cod Ocupatie
PROCEDURE update_cor

If Used('v_cor')
	Use In v_cor
Endif

lcSql = [select a.*,row_number() over(order by cod) as rown from sal_vcor a order by cod]
lcCursor = [v_cor]
lnSucces = goExecutor.oExecute(lcSql,lcCursor)
goExecutor.oReset()

Return lnSucces

ENDPROC 

PROCEDURE update_marci

	lcSql = [SELECT * from ] + gcS + [.vnom_marci_masini]
	lcCursor = [v_marci]
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	goExecutor.oReset()

	RETURN lnSucces
ENDPROC

Procedure Update_GrupUtilAnalitice
	LOCAL lcSql, lcCursor, lnSucces
	
	lcSql = "select ga.cont, ga.acont ;
				from config_gruputil_analitice ga join utilizatori_rol_intern u on ga.id_grup = u.id_grup ;
				where u.id_util = ?gnIdUtil"
	
	lcCursor = 'crsGrupUtilAnalitice'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
	ENDIF 	

	RETURN lnSucces
EndProc && Update_GrupUtilAnalitice

*******************************************
Procedure Update_TVAAnalitice
	LOCAL lcSql, lcCursor, lnSucces

TEXT TO lcSql NOSHOW
select c.id_jtva_coloana,
       c.explicatie_tva,
       c.cont,
       c.acont,
       c.id_grup,
       c.denumire_grup,
       c.id_sucursala,
       c.sucursala,
       c.id_util,
       c.utilizator,
       c.dataora
  from vconfig_tva_analitice c
  left join utilizatori_rol_intern u on (c.id_grup = u.id_grup and u.sters = 0)
  where c.id_grup is null or u.id_util = ?gnIdUtil or c.id_sucursala is null or c.id_sucursala = ?gnIdSucursala
ENDTEXT   
	
	lcCursor = 'crsTVAAnalitice'
	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	IF lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
	ENDIF 	

	RETURN lnSucces
EndProc && Update_TVAAnalitice

*******************************************
PROCEDURE update_optiuni_util(  )
	IF USED('v_optiuni_util')
		USE IN v_optiuni_util
	ENDIF

	lcSql='select * from optiuni_util where id_util = '+ALLTRIM(STR(gnIdUtil)) + [ or id_util = 0  order by varname]
	lcCursor = 'v_optiuni_util'

	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
*!*		MESSAGEBOX('v_optiuni_util')
	RETURN lnSucces
	
ENDPROC

**********************************************************************
PROCEDURE ccsectii
	lparameters tlBlank
	*** tlBlank: .T. daca se adauga o inregistrare goala la inceputul cursorului pentru cazul in care nu este obligatorie completarea sectiei (ex: nom_gestiuni.id_sectie)
	
	LOCAL lcSql, lcCursor, llSucces, lcSqlBlank
	
	text to lcSqlBlank noshow
select cast(NULL AS NUMBER(5)) as id_sectie,
       rpad(' ', 50, ' ') as sectie,
       cast(0 as NUMBER(20)) as id_mod,
       0 as inactiv,
       0 as nsectie,
       rpad(' ', 10, ' ') as csectie,
       cast(0 as NUMBER(5)) as id_sucursala,
       rpad(' ', 100, ' ') as sucursala,
       rpad(' ', 10, ' ') as caen
  from dual
  endtext
  	
	lcSql = ' select id_sectie, sectie, id_mod, inactiv, nsectie, csectie, id_sucursala, sucursala, caen from vnom_sectii where inactiv=0 order by sectie'
	lcSql = iif(m.tlBlank, m.lcSqlBlank + ' UNION ALL ', '') + m.lcSql

	lcCursor = 'vnom_sectii'
	llSucces = goExecutor.oExecuta(lcSql,lcCursor)

	RETURN iif(m.llSucces, 1, -1)

ENDPROC && ccsectii
***********************************************************************PROCEDURE close_cclocalitati
PROCEDURE close_ccsectii
	USE IN (SELECT('vnom_sectii'))
ENDPROC && close_ccsucursale

***********************************************************************PROCEDURE close_cclocalitati
PROCEDURE update_parteneriemail
	LOCAL lcSql, lcCursor, lnSucces
	
	lcSql='select p.denumire, a.email, substr(a.adresa,1,250) as adresa from nom_parteneri p join vadrese_parteneri a on p.id_part = a.id_part where p.sters = 0 and p.inactiv = 0 and a.email is not null'
	lcCursor = 'cparteneriemail'

	lnSucces = goExecutor.oExecute(lcSql,lcCursor)
	RETURN lnSucces
ENDPROC && update_parteneriemail

***********************************************************************
PROCEDURE close_parteneriemail
	IF USED('cparteneriemail')	
		USE IN (SELECT('cparteneriemail'))
	ENDIF 
ENDPROC && close_parteneriemail

***********************************************************************
procedure update_grupe_art
	Local lcCursor, lcSel, lnsucces
	Use In (select('crs_grupe_art'))

	lcSel	 = [select grupa,id_grupa from vgest_art_gr order by grupa]
	lcCursor = [crs_grupe_art]
	lnsucces = goExecutor.oExecuta(m.lcSel, m.lccursor)
endproc && update_grupe_art

***********************************************************************
PROCEDURE close_grupe_art
	USE IN (SELECT('crs_grupe_art'))
ENDPROC && close_grupe_art

***********************************************************************
procedure update_subgrupe_art
	Local lccursor, lcsel, lnsucces
	Use In (select('crs_subgrupe_art'))

	lcsel	 = [select subgrupa,id_subgrupa,id_grupa,indicativ from vgest_art_sbgr order by subgrupa]
	lccursor = [crs_subgrupe_art]
	lnsucces = goExecutor.oExecute(m.lcsel, m.lccursor) 
endproc && update_subgrupe_art
 
***********************************************************************
PROCEDURE close_subgrupe_art
	USE IN (SELECT('crs_subgrupe_art'))
ENDPROC && close_subgrupe_art

***********************************************************************
procedure update_tip_doc
	LPARAMETERS tlBlank
	* tlBlank - se adauga o inregistrare goala
	
	Local lccursor, lcsel, llsucces
	Use In (select('crsTipDoc'))

	lcsel	 = IIF(m.tlBlank, [select '' as tip, '--' as descriere from dual UNION ALL ], []) + [select tip, descriere from nom_tip_doc order by descriere]
	lccursor = [crsTipDoc]
	llsucces = goExecutor.oExecuta(m.lcsel, m.lccursor) 
	RETURN llSucces
endproc && update_tip_doc

***********************************************************************
PROCEDURE close_tip_doc
	USE IN (SELECT('crsTipDoc'))
ENDPROC && close_tip_doc

***********************************************************************
procedure update_fdoc
	LPARAMETERS tcFilter, tcAlias
	Local lccursor, lcsel, llsucces
	lccursor = IIF(!EMPTY(tcAlias), m.tcAlias, [crsFDoc])
	Use In (select(m.lccursor))

	lcsel	 = [select id_fdoc, fel_document, tip_doc, descriere, paymentcode from vnom_fdoc ] + IIF(!EMPTY(m.tcFilter), [where ] + m.tcFilter , []) + [ order by fel_document]
	llsucces = goExecutor.oExecuta(m.lcsel, m.lccursor) 
	RETURN llSucces
endproc && update_fdoc

***********************************************************************
PROCEDURE close_fdoc
	USE IN (SELECT('crsFDoc'))
ENDPROC && close_fdoc


***********************************************************************
procedure update_serii
	LPARAMETERS tlBlank, tcFilter, tcAlias
	* tlBlank - se adauga o inregistrare goala
	
	Local lccursor, lcsel, llsucces

	lccursor = IIF(!EMPTY(tcAlias), m.tcAlias, [crsSerii])
	Use In (select(m.lccursor))

	lcsel = IIF(m.tlBlank, [select 0 as id_serie, '--' as serie, 0 as an, 0 as luna, 0 as lungime, 0 as inactiv, '' as resetare, '' as exemplu, 0 as isautofactura, 0 as isbeneficiari, 0 as isterti, 0 as isfurnizori from dual UNION ALL ], []) + ;
		[select id_serie, serie, an, luna, lungime, inactiv, resetare, exemplu, isautofactura, isbeneficiari, isterti, isfurnizori from vserii ] + IIF(!EMPTY(m.tcFilter), [where ] + m.tcFilter , []) + [ order by serie]
	llsucces = goExecutor.oExecuta(m.lcsel, m.lccursor) 
	RETURN llSucces
endproc && update_serii

***********************************************************************
PROCEDURE close_serii
	USE IN (SELECT('crsSerii'))
ENDPROC && close_serii
 