*!* 29.06.2018
*!* marius.mutu
*!* modificare_articole_gestiune - tratare modificare nota produse > vanzare 


*!* 31.12.2019
*!* marius.mutu
*!* viz_rulaje, viz_rulaje_obinv - optimizat selectia pentru cursorul poBon, poNir 

Procedure viz_rulaje
	Lparameters tnNrPag
	Private pcselect, pcschema, pcfiltru, pcorder, llAfiseaza, porulaje, ponir, pobon, pcvrul

	Local ofrmrulaje As "frm_rulaje"
	Local lcFiltruOriginal, lcgroup, llModParam
	Store '' To porulaje, ponir, pobon
	*!*	IF m.nivel=1

	pcschema = ['NRCRT n(10),ID_RUL n(20),AN n(4),LUNA n(2),COD n(20),NNIR n(20),SERIE_ACT C(10),NRACT n(14),UTILS c(50),DATAORAS t,ID_ARTICOL n(10),'+] + ;
		['DENUMIRE c(100),CODMAT c(50),SERIE c(100),UM c(6),ID_GESTIUNE n(5),CGEST c(20), nume_gestiune c(50), '+] + ;
		['PRET n(16,4),PRETV n(16,4),TVA n(16,4),TVAV n(16,4),CANT n(14,3),CANTE n(14,3),CONT c(4),'+] + ;
		['ADAOS n(14,4),ID_LUCRARE n(20),NRORD c(30),ID_RESPONSABIL n(5),NRESP c(30),DATAACT d,'+] + ;
		['PROCENT n(7,3),CURS n(14,4),PRETD n(14,4),ID_UTIL n(5),UTIL c(30),DATAORA t,'+] + ;
		['ID_SECTIE n(5),SECTIE c(30),ALCOOLTUTUN n(1),PRETVTVA n(14,4),'+] + ;
		['ACONT c(4),DATAIN d,DATAOUT d,PROC_DISC n(6,2),DISCUNITAR n(14,4),PROC_TVA n(5,2),PROC_TVAv n(5,2),ID_FACT n(20),STERS n(1), '+] + ;
		['ID_GESTIUNEC N(5), CGESTC C(20), ID_RESPONSABILC N(5), NRESPC C(30),ID_TIP_RULAJ N(10),TIP_RULAJ C(40),'+] + ;
		['um2 c(10),cant_bax n(9,4), id_grupa n(5), grupa c(100), id_subgrupa n(5), subgrupa c(100),'+] + ;
		['id_valuta n(5), nume_val c(4), codmatf c(50), lot c(50), adata_expirare T,'+] + ;
		['id_sucursala N(5),sucursala c(100),id_part_rez N(10),part_rez c(100),'+] + ;
		['id_lucrare_rez N(10),nrord_rez C(50), codbare c(100), id_set I, id_furnizor N(10), furnizor C(100), codnc8 C(20), greutate N(12,4), tara_origine C(100),'+] + ;
		['id_jtva_coloana N(20), explicatie_tva C(250), taxcode N(6), taxname C(250), fdoc C(30), id_fdoc I, ales N(1)']

	pcselect = ['select row_number() over (order by a.dataact,a.nnir) as nrcrt, '+] + ;
		['A.ID_RUL,A.AN,A.LUNA,A.COD,A.NNIR,A.SERIE_ACT,A.NRACT,A.UTILS,A.DATAORAS,A.ID_ARTICOL,A.DENUMIRE,A.CODMAT,A.SERIE,'+] + ;
		['A.UM,A.ID_GESTIUNE,A.cgest, a.nume_gestiune,A.PRET,A.PRETv,A.tva,A.tvav, ' + ] + ;
		['A.CANT,A.CANTE,A.CONT,A.ADAOS,A.ID_LUCRARE,A.NRORD,A.ID_RESPONSABIL,A.NRESP,A.DATAACT,A.PROCENT,A.curs, '+] + ;
		['A.PRETD,A.ID_UTIL,A.UTIL,A.DATAORA,A.ID_SECTIE,A.SECTIE,A.ALCOOLTUTUN, '+] + ;
		['A.pretvtva,A.ACONT,A.DATAIN,A.DATAOUT,A.PROC_DISC,A.DISCUNITAR,A.PROC_TVA,A.PROC_TVAV,A.ID_FACT,a.sters, '+] + ;
		['A.ID_GESTIUNEC, A.CGESTC, A.ID_RESPONSABILC, A.NRESPC, A.ID_TIP_RULAJ, A.TIP_RULAJ, '+] + ;
		['a.um2, a.cant_bax, a.id_grupa, a.grupa, a.id_subgrupa, a.subgrupa, a.id_valuta, a.nume_val, a.codmatf,' + ] + ;
		['a.lot, a.adata_expirare, a.id_sucursala, a.sucursala,a.id_part_rez,a.part_rez,a.id_lucrare_rez,a.nrord_rez, a.codbare, a.id_set, '+] + ;
		['a.id_furnizor, a.furnizor, a.codnc8, a.greutate, a.tara_origine, a.id_jtva_coloana, a.explicatie_tva, a.taxcode, a.taxname,a.fdoc, a.id_fdoc,0 as ales '+] + ;
		['from vrul_tot a where 1=2']

	pcvrul = '_tot'

	pcfiltru = [1=2]
	pcorder = [1]
	llAfiseaza = .F.
	gencursor('porulaje', 'crsrulx', pcselect, pcfiltru, pcschema, pcorder, llAfiseaza)
	porulaje.ca_baza1.afisare()

	pcschema = [NRCRT n(10),DENUMIRE c(100),CODMAT c(50),UM c(6),DATAACT D,PRET n(16,4),TVA n(16,4),PRETV n(16,4),TVAV n(16,4),CANT n(14,3),CANTE n(14,3),COD n(20),NNIR n(10), NRESP C(30),SERIE c(100)]
	Text To pcselect Noshow
 select row_number() over(order by b.denumire) as nrcrt,
        b.denumire,
        b.codmat,
        b.um,
        a.dataact,
        a.pret,
        a.tva,
        a.pretv,
		a.tvav,
        a.cant,
        a.cante,
        a.cod,
        a.nnir,
        c.denumire as nresp,
        a.serie
   FROM rul a left join nom_articole b on a.id_articol = b.id_articol
  left join nom_parteneri c on a.id_responsabil = c.id_part
	Endtext

	pcfiltru = [1=2]
	pcorder = [b.denumire]
	llAfiseaza = .F.
	lcgroup = []
	llModParam = .T.
	lcFiltruOriginal = [a.sters=0]
	gencursor('ponir', 'crsnir', m.pcselect, m.pcfiltru, m.pcschema, m.pcorder, m.llAfiseaza, m.lcgroup, m.llModParam, m.lcFiltruOriginal)
	gencursor('pobon', 'crsbon', m.pcselect, m.pcfiltru, m.pcschema, m.pcorder, m.llAfiseaza, m.lcgroup, m.llModParam, m.lcFiltruOriginal)

	Select crsRulX
	ofrmrulaje = Createobject("frm_rulaje", tnNrPag)
	*DO FORM frm_rulaje NAME ofrmrulaje NOSHOW 
	ofrmrulaje.lb_titlu_alb_b121.Caption = ofrmrulaje.lb_titlu_alb_b121.Caption + " LUNA " + Alltrim(Str(gnLuna)) + "/" + Alltrim(Str(gnAn))
	ofrmrulaje.Show(1)

	Release porulaje

Endproc && viz_rulaje

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

Procedure viz_rulaje_obinv
	Private pcselect, pcschema, pcfiltru, pcorder, llAfiseaza, porulaje, ponir, pobon, pcvrul
	Local ofrmrulaje As "frm_rulaje_obinv"
	Local lcFiltruOriginal, lcgroup, llModParam
	Store '' To porulaje, ponir, pobon

	pcschema = ['']
	pcselect = ['select row_number() over (order by a.dataact,a.nnir) as nrcrt,a.*,0 as ales from vrul_obinv_tot a where 1=2']
	pcvrul = '_tot'


	pcfiltru = [1=2]
	pcorder = [1]
	llAfiseaza = .F.
	gencursor('porulaje', 'crsrul', pcselect, pcfiltru, pcschema, pcorder, llAfiseaza)
	porulaje.ca_baza1.afisare()

	*!*		pcschema = ['NRCRT n(10),DENUMIRE c(100),CODMAT c(50),UM c(6),PRET n(16,4),'+] + ;
	*!*			['TVA n(16,4),CANT n(14,3),COD n(20), NRESP C(30)']
	*!*		pcselect = ['select row_number() over (order by denumire) as nrcrt,a.denumire,a.codmat,'+] + ;
	*!*			['a.um,a.pret,a.tva,a.cant,a.cod, a.nresp from ] + gcS + [.vrul_obinv] + pcvrul + [ a '+] + ;
	*!*			['where 1=2']
	*!*		pcfiltru = [1=2]
	*!*		pcorder = [a.denumire]
	*!*		llAfiseaza = .F.
	*!*		gencursor('ponir', 'crsnir', pcselect, pcfiltru, pcschema, pcorder, llAfiseaza)

	*!*		pcschema = ['NRCRT n(10),DATAACT d,DENUMIRE c(100),UM c(6),PRETV n(16,4),CANTE n(14,3),NNIR n(10), NRESP C(30)']
	*!*		pcselect = ['select row_number() over (order by cod) as nrcrt,a.dataact,'+] + ;
	*!*			['a.denumire,a.um,a.pretv,a.cante,a.nnir, a.nresp from ] + gcS + [.vrul_obinv] + pcvrul + [ a '+] + ;
	*!*			['where 1=2']
	*!*		pcfiltru = [1=2]
	*!*		pcorder = [cod]
	*!*		llAfiseaza = .F.
	*!*		gencursor('pobon', 'crsbon', pcselect, pcfiltru, pcschema, pcorder, llAfiseaza)

	pcschema = [NRCRT n(10),DENUMIRE c(100),CODMAT c(50),UM c(6),DATAACT D,PRET n(16,4),TVA n(16,4),PRETV n(16,4),TVAV n(16,4),CANT n(14,3),CANTE n(14,3),COD n(20),NNIR n(10), NRESP C(30),SERIE c(100)]
	Text To pcselect Noshow
 select row_number() over(order by b.denumire) as nrcrt,
        b.denumire,
        b.codmat,
        b.um,
        a.dataact,
        a.pret,
        a.tva,
        a.pretv,
		a.tvav,
        a.cant,
        a.cante,
        a.cod,
        a.nnir,
        c.denumire as nresp,
        a.serie
   FROM rul_obinv a left join nom_articole b on a.id_articol = b.id_articol
  left join nom_parteneri c on a.id_responsabil = c.id_part
	Endtext

	pcfiltru = [1=2]
	pcorder = [b.denumire]
	llAfiseaza = .F.
	lcgroup = []
	llModParam = .T.
	lcFiltruOriginal = [a.sters=0]
	gencursor('ponir', 'crsnir', m.pcselect, m.pcfiltru, m.pcschema, m.pcorder, m.llAfiseaza, m.lcgroup, m.llModParam, m.lcFiltruOriginal)
	gencursor('pobon', 'crsbon', m.pcselect, m.pcfiltru, m.pcschema, m.pcorder, m.llAfiseaza, m.lcgroup, m.llModParam, m.lcFiltruOriginal)
	
	*DO FORM "frm_rulaje_obinv" NAME ofrmrulaje NOSHOW LINKED 
	ofrmrulaje = Createobject("frm_rulaje_obinv")
	ofrmrulaje.lb_titlu_alb_b121.Caption = "RULAJE OBIECTE DE INVENTAR IN FOLOSINTA * LUNA " + Alltrim(Str(gnLuna)) + "/" + Alltrim(Str(gnAn))
	ofrmrulaje.Show(1)

	Release porulaje

Endproc && viz_rulaje_obinv


******************************************************
*
* Apelata din gestiuni_comun.vcx > afrulaje > but_modifica1
*
******************************************************
Procedure modificare_antet_gestiune
	Lparameters toActNou
	Local llSucces, lnCod, lnIdResp, lcSelect
	Local lcCursor, lcSql, llRul, lnReturn, lnSucces
	Local loActNou, loActOriginal
	Private pnCod
	Private pdDataOra
	pdDataOra = Null

	llSucces = .F.
	lcSelect = Select()
	loActNou = toActNou
	pnCod = loActNou.cod
	llRul = .T.

	lcSql = [select * from vact_tot where an = ?gnAn and luna = ?gnLuna and cod = ?pnCod]
	lcCursor = [actactan]
	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	If lnSucces < 0
		aMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
	Else
		Select actactan
		Go Top
		Scatter Name loActOriginal

		lcSql = [select * from vrul_tot where an = ?gnAn and luna = ?gnLuna and cod = ?pnCod]
		lcCursor = [rul_temp]

		lnSucces = goExecutor.oExecute(lcSql, lcCursor)
		If lnSucces < 0
			aMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
		Else
			lcSql = [select * from vrul_obinv_tot where an = ?gnAn and luna = ?gnLuna and cod = ?pnCod]
			lcCursor = [RUL_TEMP_OBINV]

			lnSucces = goExecutor.oExecute(lcSql, lcCursor)
			goExecutor.oReset()
			If m.lnSucces < 0
				aMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
			Endif && lnSucces
		Endif && lnSucces
	Endif && lnSucces

	If m.lnSucces > 0
		If loActNou.nract <> loActOriginal.nract
			Update actactan Set nract = loActNou.nract Where nract = loActOriginal.nract
			Update RUL_TEMP Set nract = loActNou.nract
			Update RUL_TEMP_OBINV Set nract = loActNou.nract
		Endif
		If loActNou.NNIR <> loActOriginal.NNIR
			Update actactan Set NNIR = loActNou.NNIR Where NNIR = loActOriginal.NNIR
			Update RUL_TEMP Set NNIR = loActNou.NNIR
			Update RUL_TEMP_OBINV Set NNIR = loActNou.NNIR
		Endif
		If loActNou.dataact <> Ttod(loActOriginal.dataact)
			Update actactan Set dataact = loActNou.dataact Where dataact = loActOriginal.dataact And nract = loActOriginal.nract
			Update RUL_TEMP Set dataact = loActNou.dataact
			Update RUL_TEMP_OBINV Set dataact = loActNou.dataact
		Endif
		If loActNou.dataireg <> Ttod(loActOriginal.dataireg)
			Update actactan Set dataireg = loActNou.dataireg Where dataireg = loActOriginal.dataireg
		Endif
		If Nvl(loActNou.id_sectie, 0) <> Nvl(loActOriginal.id_sectie, 0)
			Update actactan Set id_sectie = loActNou.id_sectie Where Nvl(id_sectie, 0) = Nvl(loActOriginal.id_sectie, 0)
			Update RUL_TEMP Set id_sectie = loActNou.id_sectie Where Nvl(id_sectie, 0) = Nvl(loActOriginal.id_sectie, 0)
			Update RUL_TEMP_OBINV Set id_sectie = loActNou.id_sectie Where Nvl(id_sectie, 0) = Nvl(loActOriginal.id_sectie, 0)
		Endif
		If Nvl(loActNou.id_responsabil, 0) <> Nvl(loActOriginal.id_responsabil, 0)
			Update actactan Set id_responsabil = loActNou.id_responsabil Where Nvl(id_responsabil, 0) = Nvl(loActOriginal.id_responsabil, 0)
			Update RUL_TEMP Set id_responsabil = loActNou.id_responsabil Where Left(Cont, 1) <> '8' && nu modific obiectele de inventar in folosinta
		Endif
		If Nvl(loActNou.id_lucrare, 0) <> Nvl(loActOriginal.id_lucrare, 0)
			Update actactan Set id_lucrare = loActNou.id_lucrare Where Nvl(id_lucrare, 0) = loActOriginal.id_lucrare
			Update RUL_TEMP Set id_lucrare = loActNou.id_lucrare Where Nvl(id_lucrare, 0) = loActOriginal.id_lucrare
			Update RUL_TEMP_OBINV Set id_lucrare = loActNou.id_lucrare Where Nvl(id_lucrare, 0) = loActOriginal.id_lucrare
		Endif

		If Nvl(loActNou.id_partener, 0) <> Nvl(loActOriginal.id_partc, 0)
			Update actactan Set id_partd = loActNou.id_partener Where Nvl(id_partd, 0) = Nvl(loActOriginal.id_partc, 0)
			Update actactan Set id_partc = loActNou.id_partener Where Nvl(id_partc, 0) = Nvl(loActOriginal.id_partc, 0)
		Endif

		If do_deschide_tranzactie()
			Select actactan
			lnSucces  = oscrie_in_fisiere(2, .T., m.llRul)

			If m.lnSucces > 0
				lnSucces  = oscrie_in_fisiere(0, .T., m.llRul)
			Endif

			If m.lnSucces > 0
				lcSql = [begin pack_contafin.finalizeaza_modificare_nota(?gnLuna,?gnAn,?pdDataOra,] + Alltrim(Str(loActOriginal.id_set)) + [,] + ;
					Alltrim(Str(m.pnCod)) + [,] + Alltrim(Str(loActOriginal.id_fact)) + [,] + Alltrim(Str(loActOriginal.id_fact)) + [,?gnIdUtil); end;]
				lnSucces = Iif(goExecutor.oExecuta(m.lcSql), 1, -1)
			Endif && lnSucces

			do_inchide_tranzactie(Iif(m.lnSucces < 0, 2, 1))
		Endif && deschide_Tranzactie
	Endif && lnSucces

	Use In (Select('actactan'))
	Use In (Select('RUL_TEMP'))
	Use In (Select('RUL_TEMP_OBINV'))

	m.llSucces = (m.lnSucces > 0)
	Select (m.lcSelect)
	Return m.llSucces
Endproc && modificare_antet_gestiune


*******************************************
Procedure do_deschide_tranzactie
	Local llReturn
	If Type('goExecutor') = 'O'
		goExecutor.oExecuta([select * from dual])
	Endif
	lnSucces = SQLSetprop(gnHandle, "Transactions", 2)
	If m.lnSucces < 0
		aMESSAGEBOX("Programul nu a reusit sa treaca pe tranzactie manuala! Reintrati in program si incercati din nou!", 48, "Atentie")
		llReturn = .F.
	Else
		llReturn = .T.
	Endif
	Return m.llReturn
Endproc && do_deschide_tranzactie

*******************************************
Procedure do_inchide_tranzactie
	Lparameters tnTip
	Local llReturn, lnSucces, lcExplicatie
	If tnTip = 1
		lnSucces = Sqlcommit(gnHandle)
		lcExplicatie = [COMMIT]
	Else
		lnSucces = Sqlrollback(gnHandle)
		lcExplicatie = [ROLLBACK]
	Endif
	If lnSucces < 0
		aMESSAGEBOX("Eroare la " + lcExplicatie + "!", 48, "Atentie")
		llReturn = .F.
	Else
		lnSucces = SQLSetprop(gnHandle, "Transactions", 1)
		If lnSucces < 0
			aMESSAGEBOX('Programul nu a reusit sa treaca pe tranzactie automata. Iesiti din program si intrati din nou!', 0 + 48, 'Atentie!')
			llReturn = .F.
		Else
			llReturn = .T.
		Endif
	Endif
	Return llReturn
Endproc && do_inchide_tranzactie
******************************************************
*
* Apelata din gestiuni_comun.vcx > afrulaje > but_modifica1
*
******************************************************
Procedure modificare_articole_gestiune
	Lparameters tnCod, tnIdSet

	Private pnCod
	Local lcColumnId, lcColumnValue, lcCont, lcFisLista, lcIdFisier, lcMemoryVarId, lcMemoryVarValue
	Local lcSelect, lcSql, lcVarItem, lcWhere, llContinua, llPartener, llSucces, llVerificaAcont
	Local lnButon, lnIdSet, lnIdValue, lnItem, lnSucces, lnVariabile, luValue, lcCgest, lnIdGestiune
	Local loAct As "empty"
	Local lcNumeGestiune, lcResponsabil, lnIdResponsabil
	lnVariabile = 0
	llSucces = .F.
	lcSelect = Select()
	pnCod = m.tnCod
	lnIdSet = m.tnIdSet
	lcCgest = ""
	lnIdGestiune = 0

	*** Initializez variabilele din xrequest
	lcSql = [select * From VACT a Where an = ] + Alltrim(Str(m.gnAn)) + [ and luna = ] + Alltrim(Str(m.gnLuna)) + [ and cod = ] + Alltrim(Str(m.pnCod))
	lnSucces = goExecutor.oExecute(m.lcSql, 'ACT_TEMP')

	If m.lnSucces < 0
		aMESSAGEBOX(goExecutor.cEroare, 0 + 48, _Screen.Caption)
	Else

		lcSql = [select r.*, g.nume_gestiune, g.cgest, p.denumire as responsabil From rul r Left Join vnom_gestiuni g On r.id_gestiune = g.id_gestiune left join vnom_parteneri p on r.id_responsabil = p.id_part Where an = ] + Alltrim(Str(m.gnAn)) + [ and luna = ] + Alltrim(Str(m.gnLuna)) + [ and cod = ] + Alltrim(Str(m.pnCod))
		lnSucces = goExecutor.oExecute(m.lcSql, 'RUL_TEMP')
		If m.lnSucces < 0
			aMESSAGEBOX(goExecutor.cEroare, 0 + 48, _Screen.Caption)
		Endif
	Endif && m.lnSucces < 0

	If m.lnSucces < 0
		Use In (Select('ACT_TEMP'))
		Use In (Select('RUL_TEMP'))
		Return
	Endif

	Select scd As Cont, id_partd As id_part, partd As partener ;
		From ACT_TEMP ;
		Where !Empty(Nvl(id_partd, 0)) ;
		Union ;
		Select scc As Cont, id_partc As id_part, partc As partener ;
		From ACT_TEMP ;
		Where !Empty(Nvl(id_partc, 0)) ;
		Into Cursor cParteneriTemp

	Select a.Cont, a.id_part, b.partener ;
		From (Select Cont, Max(id_part) As id_part From cParteneriTemp Group By Cont) a Left Join ;
		(Select Distinct id_part, partener From cParteneriTemp) b On a.id_part = b.id_part ;
		Into Cursor cParteneriAct
	Use In (Select('cParteneriTemp'))

	Text To lcSql Noshow Textmerge
	Select i.id_item, i.var_item, i.fis_lista, i.id_fisier 
		From xrequest r Join xitems i On r.id_item = i.id_item 
		Where r.id_set = <<m.tnIdSet>>
		Union 
		Select id_item, var_item, fis_lista, id_fisier 
		From xitems 
		Where id_item = 16 
	Endtext
	lnSucces = goExecutor.oExecute(m.lcSql, 'crsVariabileTemp')
	If lnSucces > 0
		Select Padr(Cont, 4) As var_item, 'parteneri' As fis_lista From cParteneriAct Into Cursor cVariabileParteneri

		Select crsVariabileTemp
		Append From Dbf('cVariabileParteneri')
		Use In (Select('cVariabileParteneri'))
	Else
		aMESSAGEBOX(goExecutor.cEroare)
		Create Cursor crsVariabileTemp (id_item I, var_item C(20), fis_lista C(20), id_fisier C(20))
	Endif


	loAct = Createobject("empty")
	AddProperty(loAct, 'lCorectie', .T.)
	AddProperty(loAct, 'nCod', m.pnCod)

	Select crsVariabileTemp
	Scan
		llPartener = Alltrim(Lower(Nvl(fis_lista, ''))) = 'parteneri' && variabila partener
		lcVarItem = Lower(Alltrim(Nvl(var_item, '')))
		lcFisLista = Lower(Alltrim(Nvl(fis_lista, '')))
		lcIdFisier = Lower(Alltrim(Nvl(id_fisier, '')))
		lcColumnValue = 'act_temp.' + lcVarItem
		lcColumnId = Iif(!Empty(m.lcIdFisier), 'act_temp.' + lcIdFisier, '')


		Do Case
			Case m.llPartener && parteneri
				lcCont = Alltrim(Nvl(var_item, ''))

				Select cParteneriAct
				Locate For Alltrim(Nvl(Cont, '')) = m.lcCont
				If Found()
					luValue = Alltrim(partener)
					lnIdValue = id_part
					AddProperty(loAct, 'v' + Lower(m.lcCont), m.luValue) && loAct.v4111
					AddProperty(loAct, 'id_vv' + Lower(m.lcCont), m.lnIdValue) && loAct.id_vv4111
				Endif


			Case Inlist(m.lcVarItem, "gestin", "gestout") && numele gestiunii
				* gestiunea o iau din rulaje, daca sunt mai multe gestiuni nu completez variabila
				Select Distinct id_gestiune, nume_gestiune, cgest From RUL_TEMP Into Cursor crsGestiuniTemp
				If _Tally = 1
					Go Top In crsGestiuniTemp

					lcNumeGestiune = Alltrim(crsGestiuniTemp.nume_gestiune)
					lnIdGestiune = crsGestiuniTemp.id_gestiune
					lcCgest = Alltrim(Nvl(crsGestiuniTemp.cgest, ''))
					AddProperty(loAct, m.lcVarItem, m.lcNumeGestiune) && loAct.gestin
					AddProperty(loAct, 'id_' + m.lcVarItem, m.lnIdGestiune) && loAct.id_gestin
					AddProperty(loAct, "nume_gestiune", m.lcNumeGestiune) && loAct.nume_gestiune
					AddProperty(loAct, "cgest", m.lcCgest) && loAct.cgest
					AddProperty(loAct, 'id_gestiune', m.lnIdGestiune) && loAct.id_gestin
				Endif

				Use In (Select('crsGestiuniTemp'))
			Case m.lcVarItem = 'nresp' And m.lcFisLista = 'vnom_responsabili' && responsabil/respons sau achizitor/achit_542
				lcWhere = Iif(lnIdSet = 89, [cante <> 0], [1=1]) && la transfer intre persoane ma intereseaza persoana de la care se transfera
				Select Distinct id_responsabil, responsabil From RUL_TEMP Where &lcWhere Into Cursor crsResponsabiliTemp
				If _Tally = 1
					Go Top In crsResponsabiliTemp
					lcResponsabil = Alltrim(crsResponsabiliTemp.responsabil)
					lnIdResponsabil = crsResponsabiliTemp.id_responsabil
					AddProperty(loAct, m.lcVarItem, m.lcResponsabil) && loAct.nresp
					AddProperty(loAct, 'id_' + m.lcVarItem, m.lnIdResponsabil) && loAct.id_responsabil
				Endif
				Use In (Select('crsResponsabiliTemp'))

			Otherwise
				If Type(m.lcColumnValue) <> 'U'
					Select ACT_TEMP
					Calculate Max(&lcVarItem) To luValue
					If Inlist(m.lcVarItem, 'dataact', 'dataireg', 'datascad') And Type('luvalue') = 'T'
						luValue = Ttod(m.luValue)
					Endif
					AddProperty(loAct, m.lcVarItem, m.luValue) && loAct.sectie/dataact/nract

					If !Empty(m.lcColumnId) And Type(m.lcColumnId) <> 'U'
						Locate For &lcVarItem = luValue
						If Found()
							luValue = Evaluate(m.lcColumnId)
							AddProperty(loAct, m.lcIdFisier, m.luValue) && loAct.id_sectie
						Endif
					Endif
				Endif
		Endcase
	Endscan && crsVariabileTemp

	Use In (Select('crsVariabileTemp'))
	Use In (Select('act_temp'))
	Use In (Select('rul_temp'))

	*** UTILIZATORUL FACE MODIFICARI ASUPRA ARTICOLELOR IN INTRARI/IESIRI
	llContinua = .F.
	llVerificaAcont = .T.
	If Inlist(m.tnIdSet, 79, 83, 271, 225, 272) && produse > vanzare en-gros, en-detail
		llSucces = initializeaza_vanzare_din_stoc(m.tnIdSet, loAct)
		lnButon = Iif(m.llSucces, 1, 2)
	Else
		lnButon = lans(m.tnIdSet, m.llContinua, m.llVerificaAcont, .F., .F., loAct)
	Endif
	*!*		Do Case
	*!*			Case Inlist(m.lnIdSet, 92, 104) && NIR IMPORT MATERIALE/MARFA
	*!*				lnButon = importmat(m.lnIdSet, loDateSuplimentare) && procmenu.prg
	*!*			Otherwise
	*!*				lnButon = lans(m.tnIdSet, m.llContinua, m.llVerificaAcont, @laValori)
	*!*		Endcase
	llSucces = (m.lnButon <> 2)


	Select (m.lcSelect)
	Return m.llSucces
Endproc &&modificare_antet_gestiune