***************************************************************************************************************
****	Clasa:
****		oDateListare
****	Proceduri:
****		rap_avize
****		rap_facturi
****		rap_incasari
****		rap_articole
****		rap_articole_tr
****		rap_avize_transfer
****		rap_centralizator
****		rap_centr_subgrupe
***************************************************************************************************************
Define Class oDateListare As Custom
	datai			=	{}
	dataf	 		=	{}
	data_referinta	=	{}
	csql			=	[]
	id_client		=	Null
	nume_client		=	[]
	id_agent		=	Null
	nume_agent		=	[]
	id_delegat		=	Null
	nume_delegat	=	[]
	id_masina		=	Null
	nrinmat			=	[]
	categorie		=	[]
	id_categorie_entitate	=	Null
	denumire		=	[]
	id_articol		=	Null
	grupa			=	[]
	id_grupa		=	Null
	subgrupa		=	[]
	id_subgrupa		=	Null
	id_gestiune_sursa	= Null
	gestiune_sursa		= []
	id_gestiune_dest	= Null
	gestiune_dest		= []
	id_util				= Null
	utilizator			= []
	id_gestiune	= Null
	nume_gestiune		= []
	subgr_art			= []
	id_furnart 			= Null
	furnizor_art		= []
*!*		tip_raport		=	1
*!*		Dimension acoloane(30,4)	&&	1	-	nume_camp
*!*									&&	2	-	ordine la grupare
*!*									&&	3	-	ordine la order by
*!*									&&	4	-	sens la order by	(	1	-	ASC,	2	-	DESC	)
	Procedure Init
	With This
		ldData			=	Ttod(get_ora())
		If Year(ldData)*12+Month(ldData)<>gnAn*12+gnLuna
			.datai 		= Date(gnAn,gnLuna,1)
			.dataf		= Gomonth(Date(gnAn,gnLuna,1),1)-1
			.data_referinta = .dataf
		Else
			.dataf			=	ldData
			.data_referinta	=	ldData
			.datai			=	Date(Year(ldData),Month(ldData),1)
		Endif
	Endwith
	Endproc

Enddefine
***************************************************************************************************************
********************************************** INCEPUT: rap_avize *********************************************
Procedure rap_avize
Private poListare
poListare = Createobject("oDateListare")
ofrmdatelistare=Createobject("frm_date_rapoarte_avize")
ofrmdatelistare.Show(1)
Release poListare, ofrmdatelistare
Endproc &&	rap_avize
********************************************** SFARSIT: rap_avize *********************************************
********************************************* INCEPUT: rap_facturi ********************************************
Procedure rap_facturi
Private poListare
poListare = Createobject("oDateListare")
ofrmdatelistare=Createobject("frm_date_rapoarte_facturi")
ofrmdatelistare.Show(1)
Release poListare, ofrmdatelistare
Endproc &&	rap_facturi
********************************************** SFARSIT: rap_facturi *******************************************
******************************************** INCEPUT: rap_incasari ********************************************
Procedure rap_incasari
Private poListare
poListare = Createobject("oDateListare")
ofrmdatelistare=Createobject("frm_date_rapoarte_incasari")
ofrmdatelistare.Show(1)
Release poListare, ofrmdatelistare
Endproc	&&	rap_incasari
******************************************** SFARSIT: rap_incasari ********************************************
******************************************** INCEPUT: rap_articole ********************************************
Procedure rap_articole
Private poListare
poListare = Createobject("oDateListare")
ofrmdatelistare=Createobject("frm_date_rapoarte_articole")
ofrmdatelistare.Show(1)
Release poListare, ofrmdatelistare
Endproc	&&	rap_articole
******************************************** SFARSIT: rap_articole ********************************************
******************************************** INCEPUT: rap_articole_tr ********************************************
Procedure rap_articole_tr
Private poListare
poListare = Createobject("oDateListare")
ofrmdatelistare=Createobject("frm_date_rapoarte_articole_tr")
ofrmdatelistare.Show(1)
Release poListare, ofrmdatelistare
Endproc	&&	rap_articole_tr
******************************************** SFARSIT: rap_articole_tr ********************************************
******************************************** INCEPUT: rap_articole_v ********************************************
Procedure rap_articole_v
Private poListare
poListare = Createobject("oDateListare")
ofrmdatelistare=Createobject("frm_date_rapoarte_articole_v")
ofrmdatelistare.Show(1)
Release poListare, ofrmdatelistare
Endproc	&&	rap_articole_tr
******************************************** SFARSIT: rap_articole_v ********************************************
***************************************** INCEPUT: rap_avize_transfer *****************************************
Procedure rap_avize_transfer
Private poListare
poListare = Createobject("oDateListare")
ofrmdatelistare=Createobject("frm_date_rapoarte_avize_tr")
ofrmdatelistare.Show(1)
Release poListare, ofrmdatelistare
Endproc	&&	rap_avize_transfer
***************************************** SFARSIT: rap_avize_transfer *****************************************
***************************************** INCEPUT: rap_centralizator ******************************************
Procedure rap_centralizator
Private pcDataora,pcPerioada,pdDataI,pdDataF,pnTotalFTva1,pnTotalTva1,pnTotalFTva2,pnTotalTva2
Store {} To pdDataI,pdDataF
Store 0 To pnTotalFaraTva1,pnTotalTva1,pnTotalFaraTva2,pnTotalTva2
Local lcOrder,lcSql,lcFiltru,lnSucces,lnNefacturatFTva,lnNefacturatTva

ofrmperioada=Createobject('frm_perioada_zzllaaaa')
ofrmperioada.Show(1)
If gnButon=2
	Return
Endif

pcPerioada = [Perioada ]+Dtoc(pdDataI)+[ - ]+Dtoc(pdDataF)

Create Cursor crsCentralizator(tip N(2),categorie c(100),valftva N(20,4),valtva N(20,4))
*!*	tip = 1	>>	nu afiseaza sumele
pcDataora = get_ora(2)

If Used('crsCentrTot')
	Use In crsCentrTot
Endif
lcSql1 = [select 1 as crs,tip,SUM(suma_fara_tva) as valftva,SUM(suma_tva) as valtva from ] + ;
	gcS + [.fact_vrap_centralizator_tipuri where data_act between ?pdDataI and ?pdDataF] + gcCondSucursala + ;
	[ group by tip]
lcSql2 = [select 2 as crs,null as tip,SUM(suma_fara_tva) as valftva,SUM(suma_tva) as valtva from ] + ;
	gcS + [.fact_vrap_centralizator_art where data_act between ?pdDataI and ?pdDataF] + gcCondSucursala
lcSql3 = [select 3 as crs,null as tip,SUM(suma_fara_tva) as valftva,SUM(suma_tva) as valtva from ] + ;
	gcS + [.fact_vrap_centralizator_rate where data_act between ?pdDataI and ?pdDataF] + gcCondSucursala
lcSql4 = [select 4 as crs,null as tip,SUM(disc_fara_tva) as valftva,SUM(disc_tva) as valtva from ] + ;
	gcS + [.fact_vrap_centralizator_fact where data_act between ?pdDataI and ?pdDataF] + gcCondSucursala
lcSql = lcSql1 + [ union all ] + lcSql2 + [ union all ] + lcSql3 + [ union all ] + lcSql4
lcCursor = [crsCentrTot]
lnSucces = goExecutor.oexecute(lcSql,lcCursor)
If lnSucces < 0
	amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
	Use In crsCentrTot
	Return
Endif

***	prelucrare raport
*!*	Facturi
Select crsCentralizator
Append Blank
Replace categorie With "1. FACTURI"
Select Sum(valftva) As valftva,Sum(valtva) As valtva From crsCentrTot Where tip < 20 And crs=1 Into Cursor crsTemp
Select crsTemp
Scatter Name poCentr
Select crsCentralizator
Replace valftva With Nvl(poCentr.valftva,0),valtva With Nvl(poCentr.valtva,0)
pnTotalFTva1 = Nvl(poCentr.valftva,0)
pnTotalTva1 = Nvl(poCentr.valtva,0)

*!*	Avize catre clienti
Select crsCentralizator
Append Blank
Replace categorie With "2. AVIZE CATRE CLIENTI",tip With 1

*!*	Valoare totala
Append Blank
Replace categorie With Space(5)+"a) Valoare totala"
Select Sum(valftva) As valftva,Sum(valtva) As valtva From crsCentrTot Where Inlist(tip,21,22) And crs=1 Into Cursor crsTemp
Select crsTemp
Scatter Name poCentr
Select crsCentralizator
Replace valftva With Nvl(poCentr.valftva,0),valtva With Nvl(poCentr.valtva,0)
lnNefacturatFTva = Nvl(poCentr.valftva,0)
lnNefacturatTva = Nvl(poCentr.valtva,0)

*!*	Valoare facturata
Append Blank
Replace categorie With Space(5)+"b) Valoare facturata"
Select Sum(valftva) As valftva,Sum(valtva) As valtva From crsCentrTot Where tip = 4 And crs=1 Into Cursor crsTemp
Select crsTemp
Scatter Name poCentr
Select crsCentralizator
Replace valftva With Nvl(poCentr.valftva,0),valtva With Nvl(poCentr.valtva,0)
lnNefacturatFTva = lnNefacturatFTva - Nvl(poCentr.valftva,0)
lnNefacturatTva = lnNefacturatTva - Nvl(poCentr.valtva,0)

*!*	Valoare retururi
Append Blank
Replace categorie With Space(5)+"c) Valoare retururi"
Select Sum(valftva) As valftva,Sum(valtva) As valtva From crsCentrTot Where tip = 24 And crs=1 Into Cursor crsTemp
Select crsTemp
Scatter Name poCentr
Select crsCentralizator
Replace valftva With Nvl(poCentr.valftva,0),valtva With Nvl(poCentr.valtva,0)
lnNefacturatFTva = lnNefacturatFTva + Nvl(poCentr.valftva,0)
lnNefacturatTva = lnNefacturatTva + Nvl(poCentr.valtva,0)

*!*	Valoare nefacturata
Append Blank
Replace categorie With Space(5)+"d) Valoare nefacturata (a-b+c)"
Replace valftva With lnNefacturatFTva,valtva With lnNefacturatTva
pnTotalFTva1 = pnTotalFTva1 + lnNefacturatFTva
pnTotalTva1 = pnTotalTva1 + lnNefacturatTva

*!*	Transferuri intre subunitati
Select crsCentralizator
Append Blank
Replace categorie With "3. TRANSFERURI INTRE SUBUNITATI"
Select Sum(valftva) As valftva,Sum(valtva) As valtva From crsCentrTot Where tip = 23 And crs=1 Into Cursor crsTemp
Select crsTemp
Scatter Name poCentr
Select crsCentralizator
Replace valftva With Nvl(poCentr.valftva,0),valtva With Nvl(poCentr.valtva,0)
pnTotalFTva1 = pnTotalFTva1 + Nvl(poCentr.valftva,0)
pnTotalTva1 = pnTotalTva1 + Nvl(poCentr.valtva,0)

*!*	Articole
Select crsCentralizator
Append Blank
Replace categorie With "4. TOTAL ARTICOLE VANDUTE"
Select crsCentrTot
Locate For crs=2
Scatter Name poCentr
Select crsCentralizator
Replace valftva With Nvl(poCentr.valftva,0),valtva With Nvl(poCentr.valtva,0)
pnTotalFTva2 = Nvl(poCentr.valftva,0)
pnTotalTva2 = Nvl(poCentr.valtva,0)

*!*	Articole
Select crsCentralizator
Append Blank
Replace categorie With "5. TOTAL RATE CONTRACTE"
Select crsCentrTot
Locate For crs=3
Scatter Name poCentr
Select crsCentralizator
Replace valftva With Nvl(poCentr.valftva,0),valtva With Nvl(poCentr.valtva,0)
pnTotalFTva2 = pnTotalFTva2 + Nvl(poCentr.valftva,0)
pnTotalTva2 = pnTotalTva2 + Nvl(poCentr.valtva,0)

*!*	Discount-uri globale
Select crsCentralizator
Append Blank
Replace categorie With "6. TOTAL DISCOUNT GLOBAL"
Select crsCentrTot
Locate For crs=4
Scatter Name poCentr
Select crsCentralizator
Replace valftva With Nvl(poCentr.valftva,0),valtva With Nvl(poCentr.valtva,0)
pnTotalFTva2 = pnTotalFTva2 - Nvl(poCentr.valftva,0)
pnTotalTva2 = pnTotalTva2 - Nvl(poCentr.valtva,0)

Release poCentr
Use In crsTemp

If Used('crsCentrTot')
	Use In crsCentrTot
Endif

If Reccount('crsCentralizator') > 0
	Keyboard "{ctrl+f10}"
	Select crsCentralizator
	Report Form raport_centralizator To Printer Prompt Preview
Else
	amessagebox("Nu exista inregistrari pentru listare!",0+48,"Atentie")
Endif

If Used('crsCentralizator')
	Use In crsCentralizator
Endif

Release pcDataora,pcPerioada,pdDataI,pdDataF,pnTotalFTva1,pnTotalTva1,pnTotalFTva2,pnTotalTva2
Endproc	&&	rap_centralizator
***************************************** SFARSIT: rap_centralizator ******************************************
***************************************** INCEPUT: rap_centr_subgrupe *****************************************
Procedure rap_centr_subgrupe
Local lcSql,lnSucces,lcCursor
Private pcDataora,pcPerioada,pdDataI,pdDataF,pcTitlu
Store {} To pdDataI,pdDataF
lcCursor = [crscentrsubgr]

ofrmperioada=Createobject('frm_perioada_zzllaaaa')
ofrmperioada.Show(1)
If gnButon=1
	pcPerioada = [Perioada ] + Dtoc(pdDataI) + [ - ] + Dtoc(pdDataF)
Else
	Return
Endif

lcXMLGestiune = caut_gestiune_xml(2)
If !Empty(lcXMLGestiune) And gnButon = 1
	Xmltocursor(lcXMLGestiune, "crsGestTemp")
	If Reccount('crsGestTemp') = 0
		amessagebox('Nu ati selectat nici o gestiune!',0+48,'Inventar')
		Return
	Endif
	pcTitlu = [CENTRALIZATOR VALORI PE SUBGRUPE DE ARTICOLE]
	lcListaIdGestiuni = cursor2lista("crsGestTemp", "id_gestiune", ",")
	Use In crsGestTemp
Else
	Return
Endif

If Used(lcCursor)
	Use In (lcCursor)
Endif
lcSql = [select subgrupa,nume_gestiune,id_gestiune,Sum(val_ach) as val_ach,Sum(val_vanz) as val_vanz from ] + gcS + [.fact_vcentr_val_subgrupe ] + ;
	[where data_act between ?pdDataI and ?pdDataF and id_gestiune in (] + lcListaIdGestiuni + [) ] + ;
	[group by id_gestiune,nume_gestiune,subgrupa ] + ;
	[order by nume_gestiune,subgrupa]
lnSucces = goExecutor.oexecute(lcSql,lcCursor)
If lnSucces < 0
	amessagebox(goExecutor.cEroare,16,"Eroare")
Else
	goExport.export2frx(lcCursor,[rap_centr_val_subgrupe])
Endif
If Used(lcCursor)
	Use In (lcCursor)
Endif

Release lcSql,lnSucces,pcDataora,pcPerioada,pdDataI,pdDataF,pcTitlu
Endproc	&&	rap_centr_subgrupe
***************************************** SFARSIT: rap_centr_subgrupe *****************************************
Procedure centr_avize_ruta


lcFiltru = [2=2]
lcSchema = [id_lucrare n(10),nrord c(100)]
lcOrder = [nrord]
lccoloane = [nrord]
lcTitlu = [ALEGETI LUCRAREA]
lcTitluColoane = [Lucrare]
*!*	llMaiMulteMasini = tlMaiMulteMasini
lcSelect = [select id_lucrare,nrord  from vnom_lucrari]
lcFiltruOriginal = [inactiv = 0]
*!*	lcNumeProc = [nom_nomrute]
llToateIreg = .F.
lcPrimaColoana = [nrord]
lnPornire = 1
*!*	lnTipReturn = Iif(tlMaiMulteMasini, 1, 0)
lcIdColumn = "id_lucrare"
loCauta = cauta_alfa(lcSelect, lcFiltru, lcSchema, lcOrder, lccoloane, lcTitlu, lcTitluColoane, , llToateIreg, lcFiltruOriginal)&&, lcPrimaColoana, lnPornire, , lcIdColumn)
*!*	loCauta = cauta_alfa(lcSelect, lcFiltru, lcSchema, lcOrder, lccoloane, lcTitlu, lcTitluColoane, lcNumeProc, tlToateIreg, lcFiltruOriginal)		&& 11.07.2007


If Empty(loCauta.id_lucrare) Or Isnull(loCauta.id_lucrare)
	Return
Endif



lcSql = [ select * from fact_vrap_avize_ruta where id_lucrare = ]+Alltrim(Str(loCauta.id_lucrare))+[ order by ruta,data_act,numar_act]
lcCursor = [crsavizeruta]
lnSucces = goExecutor.oexecute(lcSql,lcCursor)
If lnSucces < 0
	amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
	Use In crsavizeruta
	Return
Endif
Select crsavizeruta
If Reccount() < 1
	amessagebox('Nu exista date pentru comanda selectata!',0+64,'Atentie')
	Use In crsavizeruta

	Return
Endif
Private pcDataora
pcDataora = get_ora(2)
Select crsavizeruta
Report Form  rap_avizerute To Printer Prompt Preview

Use In crsavizeruta
Endproc


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

Procedure centr_art_ruta


lcFiltru = [2=2]
lcSchema = [id_lucrare n(10),nrord c(100)]
lcOrder = [nrord]
lccoloane = [nrord]
lcTitlu = [ALEGETI LUCRAREA]
lcTitluColoane = [Lucrare]
*!*	llMaiMulteMasini = tlMaiMulteMasini
lcSelect = [select id_lucrare,nrord  from vnom_lucrari]
lcFiltruOriginal = [inactiv = 0]
*!*	lcNumeProc = [nom_nomrute]
llToateIreg = .F.
lcPrimaColoana = [nrord]
lnPornire = 1
*!*	lnTipReturn = Iif(tlMaiMulteMasini, 1, 0)
lcIdColumn = "id_lucrare"
loCauta = cauta_alfa(lcSelect, lcFiltru, lcSchema, lcOrder, lccoloane, lcTitlu, lcTitluColoane, , llToateIreg, lcFiltruOriginal)&&, lcPrimaColoana, lnPornire, , lcIdColumn)
*!*	loCauta = cauta_alfa(lcSelect, lcFiltru, lcSchema, lcOrder, lccoloane, lcTitlu, lcTitluColoane, lcNumeProc, tlToateIreg, lcFiltruOriginal)		&& 11.07.2007


If Empty(loCauta.id_lucrare) Or Isnull(loCauta.id_lucrare)
	Return
Endif



lcSql = [ select * from fact_vrap_art_ruta where id_lucrare = ]+Alltrim(Str(loCauta.id_lucrare))+[ order by ruta,subgrupa,denumire]
lcCursor = [crsartruta]
lnSucces = goExecutor.oexecute(lcSql,lcCursor)
If lnSucces < 0
	amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
	Use In crsartruta
	Return
Endif
Select crsartruta
If Reccount() < 1
	amessagebox('Nu exista date pentru comanda selectata!',0+64,'Atentie')
	Use In crsartruta

	Return
Endif
Private pcDataora
pcDataora = get_ora(2)
Select crsartruta
Report Form  rap_ARTrute To Printer Prompt Preview

Use In crsartruta
Endproc

*---------------------------------------------------------------------------
Procedure rap_factav_doc && lansat din rap_listfactav_centr, lansat la randul lui din frm_facturi (ofacturare.vcx)
Local lnNrIreg,lcFiltruInit,lnRecSel
Store 0 To lnNrIreg,lnRecSel
Store '' To lcFiltruInit

Select crsfacturi
lcFiltruInit = Set("Filter")
lnRecSel = Recno()
Set Filter To ales = 1

Count For ales = 1 To lnNrIreg
*!*	modificare	v 2.0.40
*!*	If Reccount() <1
If lnNrIreg < 1
*!*	modificare	v 2.0.40	^
	amessagebox('Nu ati selectat vreun document!',0+48,'Atentie')
*!*	modificare	v 2.0.40
*!*		Return
*!*	EndIf
Else
*!*	modificare	v 2.0.40	^
	Private pcDataora
	pcDataora = get_ora(2)
	Select crsfacturi
	Report Form rap_avizedoc To Printer Prompt Preview
*!*	modificare	v 2.0.40
Endif
*!*	modificare	v 2.0.40	^
Select crsfacturi
Set Filter To &lcFiltruInit
If lnRecSel>0
	Goto lnRecSel
Endif
Endproc
*---------------------------------------------------------------------------
Procedure rap_factav_art	&& lansat din rap_listfactav_centr, lansat la randul lui din frm_facturi (ofacturare.vcx)
Local lcidvanzari,lcSql,lnSucces
Store '' To lcidvanzari
Local lnNrIreg,lcFiltruInit,lnRecSel
Store 0 To lnNrIreg,lnRecSel
Store '' To lcFiltruInit

Select crsfacturi
lcFiltruInit = Set("Filter")
lnRecSel = Recno()
Set Filter To ales = 1

Count For ales = 1 To lnNrIreg
*!*	modificare	v 2.0.40
*!*	If Reccount() <1
If lnNrIreg < 1
*!*	modificare	v 2.0.40	^
	amessagebox('Nu ati selectat vreun document!',0+48,'Atentie')
*!*	modificare	v 2.0.40
*!*		Return
*!*	EndIf
Else
*!*	modificare	v 2.0.40
	Select crsfacturi
	Scan
		lcidvanzari = lcidvanzari + [, ]+Alltrim(Str(crsfacturi .id_vanzare))
		Select crsfacturi
	Endscan
	lcidvanzari = Substr(lcidvanzari,2)

	lcSql = [select a.codmat,a.denumire,a.pret_achizitie,a.pret,a.subgrupa,sum(cantitate) as cantitate from fact_vfacturi_detalii a ]+;
		[ where a.id_vanzare in (]+Alltrim(lcidvanzari)+[)]+;
		[ group by a.codmat,a.denumire,a.pret_achizitie,a.pret,a.subgrupa]+;
		[ order by a.codmat, a.denumire ]

	lnSucces = goExecutor.oexecute(lcSql,'crsfactdetaliiartrap')
	If lnSucces < 0
		amessagebox(goExecutor.cEroare,0+16,"Eroare")
*!*	modificare	v 2.0.40
*!*			Return
*!*		Endif
	Else
*!*	modificare	v 2.0.40	^
		Private pcDataora
		pcDataora = get_ora(2)
		Select crsfactdetaliiartrap
		Report Form rap_artdoc To Printer Prompt Preview
*!*	modificare	v 2.0.40
	Endif
Endif
*!*	modificare	v 2.0.40	^
Select crsfacturi
Set Filter To &lcFiltruInit
If lnRecSel>0
	Goto lnRecSel
Endif
Endproc
*---------------------------------------------------------------------------
Procedure rap_factav_docart && lansat din rap_listfactav_centr, lansat la randul lui din frm_facturi (ofacturare.vcx)

Select a.*,1 As g1 From crsfacturi a With (Buffering = .T.) Where ales = 1 Into Cursor crsDocArt NOFILTER Readwrite
Select crsDocArt
If Reccount() <1
	amessagebox('Nu ati selectat nici un document!',0+48,'Atentie')
*!*	modificare	v 2.0.40
*!*		Return
*!*	EndIf
Else
*!*	modificare	v 2.0.40	^

	Local lcidvanzari,lcSql,lnSucces
	Store '' To lcidvanzari

	Select crsDocArt
	Scan
		lcidvanzari = lcidvanzari + [, ]+Alltrim(Str(crsDocArt.id_vanzare))
		Select crsDocArt
	Endscan
	lcidvanzari = Substr(lcidvanzari,2)

	lcSql = [select a.codmat,a.denumire,a.pret_achizitie,a.pret,a.subgrupa,sum(cantitate) as cantitate from fact_vfacturi_detalii a ]+;
		[ where a.id_vanzare in (]+Alltrim(lcidvanzari)+[)]+;
		[ group by a.codmat,a.denumire,a.pret_achizitie,a.pret,a.subgrupa]+;
		[ order by a.codmat, a.denumire ]

	lnSucces = goExecutor.oexecute(lcSql,'crsfactdetaliiartrap')
	If lnSucces < 0
		amessagebox(goExecutor.cEroare,0+16,"Eroare")
*!*	modificare	v 2.0.40
*!*		Return
*!*	EndIf
	Else
*!*	modificare	v 2.0.40	^
		Private pcDataora
		pcDataora = get_ora(2)
		Select crsfactdetaliiartrap
		Report Form rap_artdoc To Printer Prompt Preview
*!*	modificare	v 2.0.40
	Endif
Endif
*!*	modificare	v 2.0.40	^
Select crsfacturi
Set Filter To &lcFiltruInit
If lnRecSel>0
	Goto lnRecSel
Endif
Endproc
*----------------------------------------------------------------------------------------------
Procedure rap_transf_art
Local lcidvanzari,lcSql,lnSucces
Store '' To lcidvanzari

Select * From crsfacturi With (Buffering = .T.) Where ales = 1 Into Cursor crsTmp
If Reccount() <1
	amessagebox('Nu ati selectat vreun document!',0+48,'Atentie')
*!*	modificare	v 2.0.40
*!*		Return
*!*	EndIf
Else
*!*	modificare	v 2.0.40	^
	Select crsTmp
	Scan
		lcidvanzari = lcidvanzari + [, ]+Alltrim(Str(crsTmp.id_vanzare))
		Select crsTmp
	Endscan
	Use In crsTmp
	lcidvanzari = Substr(lcidvanzari,2)
	lcSql = [select a.codmat,a.denumire,a.pret_achizitie,a.pret,a.subgrupa,sum(cantitate) as cantitate,client from fact_vfacturi_detalii a ]+;
		[ where a.id_vanzare in (]+Alltrim(lcidvanzari)+[)]+;
		[ group by a.codmat,a.denumire,a.pret_achizitie,a.pret,a.subgrupa,client]+;
		[ order by a.codmat, a.denumire ]
	lnSucces = goExecutor.oexecute(lcSql,'crssitconsum')
	If lnSucces < 0
		amessagebox(goExecutor.cEroare,0+16,"Eroare")
*!*	modificare	v 2.0.40
*!*			Return
*!*		Endif
	Else
*!*	modificare	v 2.0.40	^
		Private pcDataora
		pcDataora = get_ora(2)
		Select crssitconsum
		Report Form rap_transferart To Printer Prompt Preview
*!*	modificare	v 2.0.40
	Endif
Endif
*!*	modificare	v 2.0.40	^
Select crsfacturi
Endproc &&rap_transf_art