*!* 11.11.2009
*!* marius.mutu
*!* alocare, dezalocare numere inventar

*!* 18.10.2021
*!* marius.mutu
*!* preluare_imob, verificare_balanta se verifica contul 303 in functie de optiunea IMOB_OBI

#Define CRLF	Chr(13) + Chr(10)

Procedure viz_jurnal
	Local lcFiltru, lcFiltruOriginal, lcGroup, lcOrder, lcSchema, lcSelect, llAfisare, llModParam
	PRIVATE poLista

	Store '' To poLista
	Store '' To ofrmviz

	If Used('crsjurnal')
		Use In crsjurnal
	Endif

	lcSchema = []
	lcSelect = [select * from imob_vjurnal2]
	lcOrder = [denumire,id_mf,id_operatie_mf]
	lcFiltru = [1=2]
	lcFiltruOriginal = []
	llModParam = .T.
	lcGroup = []
	llAfisare = .F.
	gencursor('poLista', 'crsjurnal', lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcGroup, llModParam, lcFiltruOriginal)
	poLista.ca_baza1.afisare()
	Select crsjurnal

	ofrmviz = Createobject('frm_jurnal')
	ofrmviz.Show(1)

	Release ofrmviz, poLista

	If Used('crsjurnal')
		Use In crsjurnal
	Endif

Endproc	&&	viz_jurnal
*************************************************************************************************************
Procedure introducere_imob_corp
	Lparameters toMF
	Local lnButon
	lnButon = 2

	lnButon = introducere_imob(1, toMF)

	Return lnButon
Endproc &&	introducere_imob_corp
*************************************************************************************************************
Procedure introducere_imob_necorp
	Lparameters toMF
	Local lnButon
	lnButon = 2

	lnButon = introducere_imob(2, toMF)

	Return lnButon
Endproc &&	introducere_imob_necorp
*************************************************************************************************************
Procedure introducere_imob
	Parameters tnTip, toMF
	&& tnTip: 1 = corporale; 2 = necorporale
	&& toMF - folosit la preluarea din contabilitate - vine completat cu nract, dataact, valoare



	Private pnButon
	Local lcMesaj, lnRaspuns
	Store '' To ofrmintro

	lcMesaj = "Nu puteti face introduceri"
	If !verificare_luna_inchisa(lcMesaj)
		Return
	Endif

	= cctipuri_amort()
	= update_cote_TVA()

	lnRaspuns = 6
	pnButon = 1

	*!* 11.11.2009
	Local lnRezultat, lnIdTipDocNrInv
	Private poGeneratorNumere
	lnIdTipDocNrInv = 18
	poGeneratorNumere = Createobject('oGeneratorNumere')
	*!* 11.11.2009 ^

	Do While lnRaspuns = 6 And pnButon = 1
		*!* 11.11.2009
		poGeneratorNumere.ResetAll()
		lnRezultat = poGeneratorNumere.creeaza_cursor_serii(m.lnIdTipDocNrInv)
		*!* 11.11.2009 ^	
		ofrmintro = Createobject('frm_introducere', tnTip, 1, toMF)
		ofrmintro.Show(1)
		Release ofrmintro

		If pnButon = 1
			lnRaspuns = aMESSAGEBOX("Doriti sa continuati introducerile?", 4 + 32, "Confirmare")
		Else
			*!* 11.11.2009
			poGeneratorNumere.dezaloca_numere()
			*!* 11.11.2009 ^
		Endif
	Enddo

	If Used('v_tipuri_amort')
		Use In v_tipuri_amort
	Endif

	*!*	modificare	v 2.0.18
	If Used('cote_TVA')
		Use In cote_TVA
	Endif
	*!*	modificare	v 2.0.18	^

	Return pnButon
Endproc &&	introducere_imob
*************************************************************************************************************
Procedure introducere_imob_in_curs
	Lparameters toMF

	&& toMF - folosit la preluarea din contabilitate - vine completat cu nract, dataact, valoare

	Private pnButon
	Local lcMesaj, lnRaspuns
	Store '' To ofrmintroc

	lcMesaj = "Nu puteti face introduceri"
	If !verificare_luna_inchisa(lcMesaj)
		Return
	Endif

	lnRaspuns = 6
	pnButon = 1

	*!* 11.11.2009
	Local lnRezultat, lnIdTipDocNrInv
	Private poGeneratorNumere
	lnIdTipDocNrInv = 18
	poGeneratorNumere = Createobject('oGeneratorNumere')
	*!* 11.11.2009 ^


	Do While lnRaspuns = 6 And pnButon = 1
		*!* 11.11.2009
		poGeneratorNumere.ResetAll()
		lnRezultat = poGeneratorNumere.creeaza_cursor_serii(m.lnIdTipDocNrInv)
		*!* 11.11.2009 ^
		ofrmintroc = Createobject('frm_introducere_curs', .F., toMF)
		ofrmintroc.Show(1)
		Release ofrmintroc
		If pnButon = 1
			lnRaspuns = aMESSAGEBOX("Doriti sa continuati introducerile?", 4 + 32, "Confirmare")
		Else
			*!* 11.11.2009
			poGeneratorNumere.dezaloca_numere()
			*!* 11.11.2009 ^			
		Endif
	Enddo

	Return pnButon
Endproc &&	introducere_imob_in_curs

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

Procedure preluare_imob
	Lparameters tnTip

	Local lcSql, lcCondSucursala, lnSucces, llSucces, lcFiltru, llExperimental, llImobObiecteInventar
	Private pdDataI, pdDataF, pcCond, pnFiscala

	pdDataI = Date(gnAn, gnLuna, 1)
	pdDataF = pdDataI
	pcCond = []
	pnFiscala = 0
	llImobObiecteInventar = (TYPE('gnIMOB_OBI') = 'N' and m.gnIMOB_OBI = 1)

	lcCondSucursala = Strtran(gcCondSucursala, "id_sucursala", "a.id_sucursala", 1, 1, 1)

	&& SELECTIE DIN ACT PENTRU CONTURILE IMOBILIZARI CORPORALE/NECORPORALE/CURS
	Text To lcSql Textmerge Noshow
		SELECT dataact,
		       nract,
		       scd as cont,
		       max(P.DENUMIRE) as part,
		       max(explicatia) as explicatia,
		       sum(suma) as suma_act,
		       Cast(0 as number(18,4)) as suma_imob
		  FROM ACT A
		  JOIN IMOB_CONTURI I ON A.SCD = I.CONT AND I.ID_TIP_IMOBILIZARE = <<tnTip>> <<IIF(!m.llImobObiecteInventar, [ and i.cont <> '303'], [])>>
		  LEFT JOIN NOM_PARTENERI P ON A.ID_PARTC = P.ID_PART
		 WHERE A.STERS = 0 AND A.AN = <<m.gnAn>> AND A.LUNA = <<m.gnLuna>> <<m.lcCondSucursala>> <<Iif(m.tnTip <> 3, [ AND A.SCC NOT IN (SELECT CONT FROM IMOB_CONTURI WHERE ID_TIP_IMOBILIZARE = 3)], [])>>
		 group by dataact, nract, scd
	Endtext

	lnSucces = goExecutor.oExecute(lcSql, "cListaAct")
	If lnSucces < 0
		aMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
		Return
	Endif

	lcCursor = 'crsImobPreluare'
	If tnTip = 3 && IMOBILIZARI IN CURS
		lcSel = [select 3 as id_tip_imobilizare, 0 as iesit_din_gest, cont, nract,data_achizitie, valoare ] + ;
			[ from imob_vlista_curs WHERE TO_CHAR(DATA_ACHIZITIE,'MM/YYYY') = '] + Padl(gnLuna, 2, '0') + '/' + Padl(gnAn, 4, '0') + ['] + gcCondSucursala
		llSucces = goExecutor.oExecuta(lcSel, lcCursor)
	ELSE
		llExperimental = .T. && 25.11.2021 llExperimental = (goApp.nExperimental = 1)
		If m.llExperimental
			* EXPERIMENTAL SELECTIE DIN IMOB_VSITUATIE_LUNARA IN LOC DE PACK_IMOB.CALCUL_SITUATIE_LUNARA()
			* Setez luna pentru view
			lcFiltru = [id_tip_imobilizare = ] + ALLTRIM(STR(m.tnTip)) + m.gcCondSucursala
			llSucces = goExecutor.oExecuta('begin pack_imob.setlunacurenta(?pdDataI); end;')
			IF m.llSucces
				lcSel = [SELECT * FROM ] + IIF(m.pnFiscala = 0, [imob_vsituatie_lunara], [imobf_vsituatie_lunara]) + [ WHERE ] + m.lcFiltru
				llSucces = goExecutor.oExecuta(m.lcSel, m.lcCursor)		
			ENDIF 
		ELSE	
			lcSel = [{call pack_imob.CALCUL_SITUATIE_LUNARA(?pdDataI,?pdDataF,?pcCond,?pnFiscala,?gnIdSucursala)}]
			llSucces = goExecutor.oExecuta(lcSel, lcCursor)
		ENDIF 	
	Endif


	If m.llSucces
		Select Cont, nract, data_achizitie, Sum(valoare) As valinv ;
			From crsImobPreluare ;
			Where ID_TIP_IMOBILIZARE = tnTip And iesit_din_gest = 0 And ;
			Year(data_achizitie) * 12 + Month(data_achizitie) = m.gnAn * 12 + m.gnLuna ;
			Group By Cont, nract, data_achizitie ;
			Into Cursor cListaImob

		Use In (Select('crsImobPreluare'))

		Select tnTip As tip, Ttod(a.dataact) As dataact, a.nract, a.Part, a.Cont, a.explicatia, a.suma_act, Nvl(i.valinv, Cast(0 As N(18, 4)))  As suma_imob, (a.suma_act = Nvl(i.valinv, 0)) As introdus ;
			From cListaAct a Left Join cListaImob i On a.nract = i.nract And ;
			Ttod(a.dataact) = Ttod(i.data_achizitie) And ALLTRIM(a.Cont) == ALLTRIM(i.Cont) ;
			Order By 1, 2, 3 ;
			Into Cursor crsPreluare Readwrite

		Use In (Select('cListaImob'))
		Use In (Select('cListaAct'))
		loFrmPreluare = Createobject("frm_preluare")
		loFrmPreluare.Show(1)

		Use In (Select('crsPreluare'))
	Endif

Endproc && preluare_imob

*************************************************************************************************************
Procedure vizualizare_lista_imob_corp
	Parameters tnFiscala
	vizualizare_lista_imob(1, tnFiscala)
Endproc &&	vizualizare_lista_imob_necorp
*************************************************************************************************************
Procedure vizualizare_lista_imob_necorp
	Parameters tnFiscala
	vizualizare_lista_imob(2, tnFiscala)
Endproc &&	vizualizare_lista_imob_necorp
*************************************************************************************************************
Procedure vizualizare_lista_imob
	Parameters tnTip, tnFiscala
	****
	* 1) imob.corporale
	* 2) imob.necorporale
	****
	Private poLista, pcSchema, pcSelect, pcOrder, pdDataI, pdDataF, pcCond, pnFiscala
	Local lcFiltru, llSucces, llExperimental
	poLista = NUll
	llExperimental = .T. && 25.11.2021 llExperimental = (goApp.nExperimental = 1)
	Use In (SELECT('crslista'))

	pdDataI = Date(gnAn, gnLuna, 1)
	pdDataF = pdDataI
	*pcCond = [id_tip_imobilizare = ] + ALLTRIM(STR(tnTip)) && merge fffff greu
	pcCond = [1=2]
	If Empty(tnFiscala)
		pnFiscala = 0
	Else
		pnFiscala = tnFiscala
	Endif
	lcCursor = 'crsLista'

	If m.llExperimental
		* EXPERIMENTAL SELECTIE DIN IMOB_VSITUATIE_LUNARA IN LOC DE PACK_IMOB.CALCUL_SITUATIE_LUNARA()
		* Setez luna pentru view
		llSucces = goExecutor.oExecuta('begin pack_imob.setlunacurenta(?pdDataI); end;')
		IF m.llSucces
			* se mai face o data selectia din baza de date in frm_lista.show(), asa ca nu iau date acum
			lcSel = [SELECT * FROM ] + IIF(m.pnFiscala = 0, [imob_vsituatie_lunara], [imobf_vsituatie_lunara]) + [ WHERE 1=2 order by data_pif, nr_inventar]
			llSucces = goExecutor.oExecuta(m.lcSel, m.lcCursor)		
		ENDIF 
	ELSE 		
		lcSel = [{call pack_imob.CALCUL_SITUATIE_LUNARA(?pdDataI,?pdDataF,?pcCond,?pnFiscala,?gnIdSucursala)}]
		lcSchema = ['']  &&['ceck n(1),totdebit n(16,gnPa),totcredit n(16,gnPa),id_fact n(10),id_part n(10),nume c(50),dataact D,dataireg D,nract n(14),datascad D,cont c(4),acont c(4)']


		llSucces = goExecutor.oExecuta(lcSel, lcCursor)
		IF m.llSucces
			Select crslista
			Index On Dtos(data_PIF) + Str(nr_inventar) Tag ordine
		ENDIF 	
	ENDIF && llExperimental	

	IF m.llSucces
		poLista= Createobject('frm_lista', m.tnTip, m.pnFiscala)
		poLista.cnumecursor = m.lcCursor
		poLista.Show(1)
		Clear Class 'frm_lista'
		Use In (SELECT('crslista'))
	ENDIF 	

	Release poLista
Endproc &&	vizualizare_lista_imob
*************************************************************************************************************
Procedure vizualizare_lista_imob_in_curs
	Private poLista, pcSchema, pcSelect, pcOrder, pcFiltru
	Local llAfiseaza
	Store '' To poLista
	Store '' To ofrmvizc
	Local lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcGroup, llModParam, lcFiltruOriginal
	Store '' To lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcGroup, llModParam, lcFiltruOriginal
	If Used('crslista')
		Use In crslista
	Endif

	lcSchema = []
	lcSelect = [select id_mf,id_lista_mf,nrord,nract,id_lucrare,id_responsabil,id_gestiune,] + ;
		[id_sectie,data_achizitie,nr_inventar,denumire,explicatia,] + ;
		[valoare,valoare_ramasa,cgest,gestiune,sectie,responsabil,cont, acont, utilizator,dataora,id_operatie_mf, an, luna, an_exp, luna_exp, id_sucursala, sucursala, CAST(0 as Number(16,4)) as valoareretinuta, 0 as ales ] + ;
		[from imob_vlista_curs]
	lcOrder = [data_achizitie,nr_inventar]
	lcFiltru = []
	*!* 10.04.2008 
	*!* din contafin am preluat imobilizari in curs cu valoare < 0 (o factura de stornare) si nu apareau in roa
	*!*		lcFiltruOriginal = [ valoare>0 ] + gcCondSucursala
	lcFiltruOriginal = Iif(!Empty(gcCondSucursala), Substr(gcCondSucursala, 6), '')
	*!* 10.04.2008 ^
	llAfisare = .F.
	llModParam = .T.
	lcGroup = []
	gencursor('poLista', 'crslista', lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcGroup, llModParam, lcFiltruOriginal)
	poLista.ca_baza1.afisare()

	Select crslista
	ofrmvizc = Createobject('frm_lista_curs')
	ofrmvizc.Show(1)

	If Used('crslista')
		Use In crslista
	Endif

	Release ofrmvizc
Endproc &&	introducere_imob_in_curs
*************************************************************************************************************
Procedure MESAJ
	Parameters m1
	ot = Createobject('frm_mesaj', 'Atentie', 'pericol.ico', 'AVERTIZARE', m1, ' ')

	ot.Show(1)
	Return

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


Procedure modif_operatii_rate
	Parameters tnTipImob, tnFiscala, poMF

	If Empty(poMF.id_mf)
		Return
	Endif

	Private pnIdMf, pnTip, pnIdOperatie
	Store 0 To pnIdMf, pnTip, pnIdOperatie

	pnIdMf = poMF.id_mf

	If Empty(tnTipImob)
		pnTip = 1 && corporale
	Else
		pnTip = tnTipImob
	Endif

	*** pageframe1
	lcSqlOperatii = ['select * from ] + Iif(tnFiscala = 0, [imob_voperatii_mf], [imobf_voperatii_mf]) + [ where 1=2']

	lcSqlRate = ['select * from ] + Iif(tnFiscala = 0, [imob_vcalcul_rate ], [imobf_vcalcul_rate ]) + [ where 1=2']

	If Used('crsOperatii')
		Use In crsOperatii
	Endif

	Private poOperatii
	poOperatii = ''

	pcFiltru = [id_mf = ?pnIdMF ]
	pcSchema = []
	pcOrder = [data_operatie, id_operatie_mf]
	llAfiseaza = .F.

	gencursor('poOperatii', 'crsOperatii', lcSqlOperatii, pcFiltru, pcSchema, pcOrder, llAfiseaza)
	poOperatii.ca_baza1.afisare()

	Select crsOperatii
	Locate
	pnIdOperatie = id_operatie_mf

	Private poRate
	poRate = ''

	If Used('crsRate')
		Use In crsRate
	Endif
	pcFiltru2 = [id_mf = ?pnIdMF and id_operatie_mf = ?pnIdOperatie]
	pcSchema2 = []
	pcOrder2 = [id_calcul_rate]
	llAfiseaza = .F.
	gencursor('poRate', 'crsRate', lcSqlRate, pcFiltru2, pcSchema2, pcOrder2, llAfiseaza)
	poRate.ca_baza1.afisare()


	*** vizualizare
	Select crsOperatii
	omodif = Createobject('frm_operatii_rate')
	omodif.omf = poMF
	omodif.nFiscala = tnFiscala
	omodif.Show()

	If Used('crsOperatii')
		Use In crsOperatii
	Endif
	If Used('crsRate')
		Use In crsRate
	Endif
Endproc && modif_operatii_rate


&& IAU SOLDURILE DIN BALANTA DE VERIFICARE PENTRU CONTURILE DE IMOBLIZARI SI AMORTIZARI
&& SI LE COMPAR CU VALOAREA DE INVENTAR SI AMORTIZAREA TOTALA DIN IMOBILIZARI CORPORALE/NECORPORALE CONTABIL
Procedure verificare_balanta(tnTip, tnAn, tnLuna)
	Private pdDataI, pdDataF, pcCond, pnFiscala, pnIdTipImobilizare
	Local lcSql, lnSucces, lcMesaj, lnAn, lnLuna, lnTipImobilizare, lcCondSucursala, lcBal, lcImob, lcDif
	LOCAL llSucces, llExperimental, llImobObiecteInventar
	lcMesaj = ''
	llImobObiecteInventar = .F. && daca verific si contul 303 (obiecte de inventar)

	lnTipImobilizare = Iif(Type('tnTip') <> 'N', 1, Iif(Inlist(tnTip, 1, 2), tnTip, 1))

	If Pcount() < 3
		lnAn = gnAn
		lnLuna = gnLuna
	Else
		lnAn = tnAn
		lnLuna = tnLuna
	Endif

	pdDataI = Date(lnAn, lnLuna, 1)
	pdDataF = pdDataI
	pcCond = []
	pnFiscala = 0
	llImobObiecteInventar = (TYPE('gnIMOB_OBI') = 'N' and m.gnIMOB_OBI = 1)
	
	lcCondSucursala = Strtran(gcCondSucursala, "id_sucursala", "b.id_sucursala", 1, 1, 1)

	Text To lcSql Textmerge Noshow
select 1 as tip, c.cont, c.cont_amortizare,
  b.SOLDDEB as sold
  from imob_conturi c
  left join <<Iif(glEMama,'vbalmama','vbal')>> b on c.cont = b.cont <<lcCondSucursala>> <<Iif(!glEMama, ' and b.an = ' + Alltrim(Str(lnAn)) + ' and b.luna = ' + Alltrim(Str(lnLuna)),'')>>
  where c.id_tip_imobilizare = <<lnTipImobilizare>> <<IIF(!m.llImobObiecteInventar, [ and c.cont <> '303'], [])>>
union
select 2 as tip, c.cont, c.cont_amortizare,
  b.soldcred as sold
  from imob_conturi c
  left join <<Iif(glEMama,'vbalmama','vbal')>> b on c.cont_amortizare = b.cont <<lcCondSucursala>> <<Iif(!glEMama, ' and b.an = ' + Alltrim(Str(lnAn)) + ' and b.luna = ' + Alltrim(Str(lnLuna)),'')>>
 where c.id_tip_imobilizare = <<lnTipImobilizare>> <<IIF(!m.llImobObiecteInventar, [ and c.cont <> '303'], [])>>
order by 1,2

	Endtext

	llSucces = goExecutor.oExecuta(lcSql, "crsConturiVerificare")
	If !m.llSucces 
		Return
	Endif
	lcCursor = 'crslistaVerificare'
	
	llExperimental = .T. && 25.11.2021 llExperimental = (goApp.nExperimental = 1)
	If m.llExperimental
		* EXPERIMENTAL SELECTIE DIN IMOB_VSITUATIE_LUNARA IN LOC DE PACK_IMOB.CALCUL_SITUATIE_LUNARA()
		* Setez luna pentru view
		lcFiltru = [id_tip_imobilizare = ] + ALLTRIM(STR(m.lnTipImobilizare)) + m.gcCondSucursala
		llSucces = goExecutor.oExecuta('begin pack_imob.setlunacurenta(?pdDataI); end;')
		IF m.llSucces
			lcSel = [SELECT * FROM ] + IIF(m.pnFiscala = 0, [imob_vsituatie_lunara], [imobf_vsituatie_lunara]) + [ WHERE ] + m.lcFiltru
			llSucces = goExecutor.oExecuta(m.lcSel, m.lcCursor)		
		ENDIF 
	ELSE
		lcSel = [{call pack_imob.CALCUL_SITUATIE_LUNARA(?pdDataI,?pdDataF,?pcCond,?pnFiscala,?gnIdSucursala)}]
		llSucces = goExecutor.oExecuta(lcSel, lcCursor)
	ENDIF 	

	If m.llSucces
		Select Cont, Sum(valoare) As valinv, Sum(amort_prec + rata) As amorttot ;
			From crsListaVerificare ;
			Where ID_TIP_IMOBILIZARE = lnTipImobilizare And iesit_din_gest = 0;
			Group By Cont ;
			Into Cursor cImobilizari

		Use In (Select('crsListaVerificare'))

		&& V.TIP: 1 = CONTURI IMOBILIZARI; 2 = CONTURI AMORTIZARI
		Select v.tip, v.Cont, Nvl(v.sold, Cast(0 As N(18, 4))) As bal_valoare, Nvl(i.valinv, Cast(0 As N(18, 4))) As imob_valoare;
			From crsConturiVerificare v Full Join cImobilizari i On v.Cont = i.Cont ;
			Where v.tip = 1 ;
			Union ;
			Select v.tip, v.cont_amortizare As Cont, Nvl(v.sold, Cast(0 As N(18, 4))) As bal_valoare, Sum(Nvl(i.amorttot, Cast(0 As N(18, 4)))) As imob_valoare ;
			From crsConturiVerificare v Full Join cImobilizari i On v.Cont = i.Cont ;
			Where v.tip = 2 ;
			Group By v.tip, v.cont_amortizare, v.sold ;
			Into Cursor cVerificareImob ;
			Order By 1, 2

		Use In (Select('crsConturiVerificare'))
		Use In (Select('cImobilizari'))

		Set Textmerge On To Memvar lcMesaj Noshow

		Select cVerificareImob
		Scan For Abs(Round(bal_valoare - imob_valoare, gnPA)) > 0.00
			lcImob = Padl(Alltrim(Transform(imob_valoare, GET_MASK(16, gnPA))), 20, ' ')
			lcBal = Padl(Alltrim(Transform(bal_valoare, GET_MASK(16, gnPA))), 20, ' ')
			lcDif = Padl(Alltrim(Transform(imob_valoare - bal_valoare, GET_MASK(16, gnPA))), 20, ' ')

			\<<Cont>>:	imobilizari: <<m.lcImob>>	Balanta: <<m.lcBal>>	Diferenta: <<m.lcDif>>
		Endscan

		Use In (Select('cVerificareImob'))
		Set Textmerge To

		If !Empty(m.lcMesaj)
			lcMesaj = 'Diferente valori imobilizari - balanta verificare' + CRLF + m.lcMesaj
			aMESSAGEBOX(lcMesaj, 0 + 48, 'Verificare')
		Else
			aMESSAGEBOX('Nu sunt diferente!', 0 + 48, 'Verificare')
		Endif

	Endif
Endproc && verificare_balanta
*----------------------------------------------------------------------------------------
Procedure viz_bunuri_capital
	Private poBunCapital
	Store [] To poBunCapital
	Local lcSchema, lcSelect, lcOrder, lcFiltru, lcFiltruOriginal, llAfisare, llModMaram, lcGroup

	lcSchema = []
	lcSelect = [select *  ] + ;
		[from imob_vbunuricapital]
	lcOrder = [denumire,datadoc]
	lcFiltru = []
	*!*		lcFiltruOriginal = Iif(!Empty(gcCondSucursala), Substr(gcCondSucursala,6), '')
	lcFiltruOriginal = []

	llAfisare = .F.
	llModParam = .T.
	lcGroup = []
	gencursor('poBunCapital', 'crsBunCapital', lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcGroup, llModParam, lcFiltruOriginal)
	poBunCapital.ca_baza1.afisare()
	Select crsBunCapital

	frm_buncpital = Createobject('frm_bunuri_capital')
	frm_buncpital.Show(1)

Endproc &&viz_bunuri_capital



**************************************
* Intoarce .T. daca numarul de inventar este duplicat
**************************************
function VerificaNumarInventar
	LPARAMETERS tnNumarInventar, tnTip

	PRIVATE pnNumarInventar, pdData, pnTip, pnRec
	LOCAL llDuplicat, lcSql, llSucces

	llDuplicat = .F.
	
	pdData = Date(gnAn, gnLuna, 1)
	pnNumarInventar = IIF(TYPE('tnNumarInventar') = 'N', m.tnNumarInventar, 0)
	pnTip = IIF(TYPE('tnTip') = 'N', m.tnTip, 1)

	IF !EMPTY(m.pnNumarInventar)
		lcSql = [select pack_imob.verifica_nr_inventar(?pnNumarInventar,?pdData, ?pnTip) as nr from dual]
		pnRec = 0
		
		llSucces = goExecutor.oSelecteaza2Value(m.lcSql, @pnRec)
		IF m.llSucces
			llDuplicat = (m.pnRec > 0)
		ENDIF 
	ENDIF 	
	RETURN m.llDuplicat
	
ENDfunc 

	
	 