*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="ofacturare_rapoarte.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS frm_date_rapoarte_articole AS _frmbase OF "_frm_base.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="But_salveaza1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport.But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_perioada" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_articol" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_data_act" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_categ_ent" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_um" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_denumire" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_serie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_numar_act" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_cont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_categorie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_grupa" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_subgrupa" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adauga_filtru
		*m: do_cauta_articol
		*m: do_cauta_categorie
		*m: do_cauta_client
		*m: do_cauta_grupa
		*m: do_cauta_subgrupa
		*p: cfiltruarticol
	*</DefinedPropArrayMethod>

	*<PropValue>
		cfiltruarticol = 
		DoCreate = .T.
		Height = 470
		Name = "frm_date_rapoarte_articole"
		Width = 696
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 696
		_shape2.Height = 29
		_shape2.Left = 600
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 97
		Lb_titlu_alb_b121.Caption = "ARTICOLE"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 13
		BUT_TERMIN1.Left = 665
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 11
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Left = 480
		GRIDSORT1.Name = "GRIDSORT1"
		GRIDSORT1.Top = 36
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Left = 602, ;
		Name = "But_excel1", ;
		TabIndex = 9, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Left = 634, ;
		Name = "But_listare1", ;
		TabIndex = 10, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_salveaza1' AS but_salveaza WITH ;
		Left = 540, ;
		Name = "But_salveaza1", ;
		TabIndex = 12, ;
		Top = 0, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_perioada' AS clb_n1n2_simplu WITH ;
		Left = 383, ;
		Name = "Clb_perioada", ;
		TabIndex = 3, ;
		Top = 72, ;
		tx_n1.ControlSource = "poListare.datai", ;
		tx_n1.Left = 127, ;
		tx_n1.Name = "tx_n1", ;
		tx_n1.Top = 2, ;
		Lb_simplu1.Caption = "Data factura", ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		tx_n2.ControlSource = "poListare.dataf", ;
		tx_n2.Name = "tx_n2"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport' AS ct_clb_cautare WITH ;
		Height = 31, ;
		Left = 23, ;
		Name = "Ct_clb_raport", ;
		TabIndex = 1, ;
		Top = 36, ;
		Visible = .F., ;
		Width = 396, ;
		img_cautare.Height = 25, ;
		img_cautare.Left = 321, ;
		img_cautare.Name = "img_cautare", ;
		img_cautare.Top = 3, ;
		img_cautare.Width = 30, ;
		clb_tx_cautare.Lb_simplu1.Caption = "Raport", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.TabIndex = 1, ;
		clb_tx_cautare.Text_simplu1.Height = 23, ;
		clb_tx_cautare.Text_simplu1.Left = 71, ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1", ;
		clb_tx_cautare.Text_simplu1.Top = 3, ;
		clb_tx_cautare.Text_simplu1.Width = 239
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport.But_sterge1' AS but_sterge WITH ;
		Height = 27, ;
		Left = 361, ;
		Name = "But_sterge1", ;
		TabIndex = 2, ;
		Top = 1, ;
		Width = 30
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ct_opt_articol' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_articol, ;
		cvarfiltru = thisform.cfiltruarticol, ;
		cvar_afisata = poListare.denumire, ;
		Left = 383, ;
		Name = "Ct_opt_articol", ;
		TabIndex = 6, ;
		Top = 240, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Articol", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_categorie' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_categorie, ;
		cvarfiltru = poListare.id_categorie_entitate, ;
		cvar_afisata = poListare.categorie, ;
		Left = 383, ;
		Name = "Ct_opt_categorie", ;
		TabIndex = 5, ;
		Top = 170, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Categorie entitate", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_client' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_client, ;
		cvarfiltru = poListare.id_client, ;
		cvar_afisata = poListare.nume_client, ;
		Left = 383, ;
		Name = "Ct_opt_client", ;
		TabIndex = 4, ;
		Top = 100, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Client", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_grupa' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_grupa, ;
		cvarfiltru = poListare.id_grupa, ;
		cvar_afisata = poListare.grupa, ;
		Left = 383, ;
		Name = "Ct_opt_grupa", ;
		TabIndex = 7, ;
		Top = 310, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Grupa de articole", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_subgrupa' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_subgrupa, ;
		cvarfiltru = poListare.id_subgrupa, ;
		cvar_afisata = poListare.subgrupa, ;
		Left = 383, ;
		Name = "Ct_opt_subgrupa", ;
		TabIndex = 8, ;
		Top = 380, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Subgrupa de articole", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1' AS ct_selectie WITH ;
		ccoloanesuma = cantitate|valoare_ftva|valoare, ;
		clistacoloaneordine = 1,2, ;
		cnumecoloanesuma = Cantitate|Valoare fara TVA|Valoare cu TVA, ;
		cnumetabela = fact_vrap_fact_articole, ;
		Height = 384, ;
		Left = 24, ;
		Name = "Ct_selectie1", ;
		TabIndex = 2, ;
		Top = 72, ;
		Width = 332, ;
		Ct_grupare1.Height = 140, ;
		Ct_grupare1.lblAtentie.Name = "lblAtentie", ;
		Ct_grupare1.lb_grupare.Name = "lb_grupare", ;
		Ct_grupare1.Left = 5, ;
		Ct_grupare1.Name = "Ct_grupare1", ;
		Ct_grupare1.TabIndex = 11, ;
		Ct_grupare1.Top = 242, ;
		Ct_grupare1.Width = 320, ;
		Ct_grupare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_grupare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_grupare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		Ct_ordonare1.Height = 167, ;
		Ct_ordonare1.lb_ordonare.Name = "lb_ordonare", ;
		Ct_ordonare1.Left = 5, ;
		Ct_ordonare1.Name = "Ct_ordonare1", ;
		Ct_ordonare1.TabIndex = 10, ;
		Ct_ordonare1.Top = 76, ;
		Ct_ordonare1.Width = 320, ;
		Ct_ordonare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_ordonare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_ordonare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		lb_coloane.Left = 10, ;
		lb_coloane.Name = "lb_coloane", ;
		lb_coloane.TabIndex = 1, ;
		lb_coloane.Top = 2
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_categ_ent' AS ct_selectie_camp WITH ;
		ccamp = categorie_entitate, ;
		cnumecamp = Categorie, ;
		Left = 17, ;
		Name = "Ct_selectie_categ_ent", ;
		nid_container = 4, ;
		TabIndex = 6, ;
		Top = 57, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_cont' AS ct_selectie_camp WITH ;
		ccamp = cont, ;
		cnumecamp = Cont, ;
		Left = 120, ;
		Name = "Ct_selectie_cont", ;
		nid_container = 8, ;
		TabIndex = 9, ;
		Top = 57, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_data_act' AS ct_selectie_camp WITH ;
		ccamp = data_act, ;
		cnumecamp = Data factura, ;
		Left = 17, ;
		Name = "Ct_selectie_data_act", ;
		nid_container = 1, ;
		TabIndex = 2, ;
		Top = 15, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_denumire' AS ct_selectie_camp WITH ;
		ccamp = denumire, ;
		cnumecamp = Articol, ;
		Left = 120, ;
		Name = "Ct_selectie_denumire", ;
		nid_container = 5, ;
		TabIndex = 7, ;
		Top = 15, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_numar_act' AS ct_selectie_camp WITH ;
		ccamp = numar_act, ;
		cnumecamp = Nr.factura, ;
		Left = 17, ;
		Name = "Ct_selectie_numar_act", ;
		nid_container = 2, ;
		TabIndex = 3, ;
		Top = 29, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_client' AS ct_selectie_camp WITH ;
		ccamp = nume_client, ;
		cnumecamp = Nume client, ;
		Left = 17, ;
		Name = "Ct_selectie_nume_client", ;
		nid_container = 3, ;
		TabIndex = 5, ;
		Top = 42, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_serie' AS ct_selectie_camp WITH ;
		ccamp = serie, ;
		cnumecamp = Serie, ;
		Left = 120, ;
		Name = "Ct_selectie_serie", ;
		nid_container = 7, ;
		TabIndex = 9, ;
		Top = 42, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_um' AS ct_selectie_camp WITH ;
		ccamp = um, ;
		cnumecamp = U.M., ;
		Left = 120, ;
		Name = "Ct_selectie_um", ;
		nid_container = 6, ;
		TabIndex = 8, ;
		Top = 29, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />
	
	PROCEDURE do_adauga_filtru
		Lparameters lcSql
		lcFiltru = [WHERE DATA_ACT BETWEEN ?poListare.datai AND ?poListare.dataf] + gcCondSucursala
		If !Empty(Nvl(poListare.id_client,0))
			lcFiltru = lcFiltru + [ AND id_part ] + Iif(thisform.ct_opt_client.nvaloarecriteriu = 1,[=],[<>]) + [ ?poListare.id_client]
		Endif
		
		If !Empty(Nvl(Thisform.cfiltruarticol,[]))
			lcFiltru = lcFiltru + Thisform.cfiltruarticol
		Endif
		
		*!*	IF !EMPTY(NVL(poListare.id_articol,0))
		*!*		lcFiltru = lcFiltru + [ AND id_articol = ?poListare.id_articol]
		*!*	ENDIF
		
		If !Empty(Nvl(poListare.id_categorie_entitate,0))
			lcFiltru = lcFiltru + [ AND id_categorie_entitate ] + Iif(thisform.ct_opt_categorie.nvaloarecriteriu = 1,[=],[<>]) + [ ?poListare.id_categorie_entitate]
		Endif
		
		If !Empty(Nvl(poListare.id_grupa,0))
			lcFiltru = lcFiltru + [ AND id_grupa ] + Iif(thisform.ct_opt_grupa.nvaloarecriteriu = 1,[=],[<>]) + [ ?poListare.id_grupa]
		Endif
		
		If !Empty(Nvl(poListare.id_subgrupa,0))
			lcFiltru = lcFiltru + [ AND id_subgrupa ] + Iif(thisform.ct_opt_subgrupa.nvaloarecriteriu = 1,[=],[<>]) + [ ?poListare.id_subgrupa]
		Endif
		
		poListare.csql = Strtran(lcSql,[WHERE 1=2],lcFiltru)
		
		
	ENDPROC

	PROCEDURE do_cauta
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If Inlist(lccontrol,"TEXTBOX","EDITBOX","COMBOBOX")
			lcval=This.ActiveControl.ControlSource
			&lcval=Thisform.ActiveControl.Value
		Endif
		
		Do Case
		Case Empty(Nvl(poListare.datai,{}))
			amessagebox("Nu ati completat data initiala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n1.SetFocus()
			Return
		Case Empty(Nvl(poListare.dataf,{}))
			amessagebox("Nu ati completat data finala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n2.SetFocus()
			Return
		Case Empty(Nvl(poListare.data_referinta,{}))
			amessagebox("Nu ati completat data de referinta!",0+48,"Atentie")
			Thisform.clb_data_referinta.SetFocus()
			Return
		Otherwise
			With This.ct_selectie1
				.do_instructiune_sql()
				lcSql = .csql
			Endwith
			If Empty(lcSql)
				amessagebox("Nu ati ales coloane pentru selectie!",0+48,"Atentie")
				Thisform.ct_selectie1.SetFocus()
				Return
			Else
				This.do_adauga_filtru(lcSql)
			Endif
		Endcase
		
		lnSucces = goExecutor.oExecute(poListare.csql,'crsraport')
		If lnSucces < 0
			amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
		Endif
	ENDPROC

	PROCEDURE do_cauta_articol
		Private pcValoare1, pcValoare2, pcIntre, pnCriteriu, pnCriteriu2, pcFiltru, pcFiltruVFP && variabile pe care le completeaza forma frm_filtru_text
		pcValoare1 = []
		pcValoare2 = []
		pnCriteriu = 1
		pnCriteriu2 = 1
		pcIntre = []
		pcFiltru = []
		pcFiltruVFP = []
		lcExplicatie = [Articol]
		
		Do Form frm_filtru_text With [denumire],lcExplicatie,1,1 To lcFiltru
		
		If Empty(lcFiltru)
			Thisform.cfiltruarticol = []
			Thisform.ct_opt_articol.opt_cautare.Value = 1
			Thisform.ct_opt_articol.do_reset()
		Else
			Thisform.cfiltruarticol = lcFiltru
			lcTraducere = []
		&& TRADUCERE
			lcCriteriu = [ ]
			lcCriteriu2 = [ ]
			lcCIntre = []
			Do Case
			Case pnCriteriu= 1
				lcCriteriu = 'incepe cu... '
			Case pnCriteriu= 2
				lcCriteriu = 'este... '
			Case pnCriteriu= 3
				lcCriteriu = 'nu este... '
			Case pnCriteriu= 4
				lcCriteriu = 'contine... '
			Case pnCriteriu= 5
				lcCriteriu = 'nu contine... '
			Case pnCriteriu= 6
				lcCriteriu = 'nu are valori '
			Case pnCriteriu= 7
				lcCriteriu = 'are valori '
			Endcase
		
			Do Case
			Case pnCriteriu2= 1
				lcCriteriu2 = 'incepe cu... '
			Case pnCriteriu2= 2
				lcCriteriu2 = 'este... '
			Case pnCriteriu2= 3
				lcCriteriu2 = 'nu este... '
			Case pnCriteriu2= 4
				lcCriteriu2 = 'contine... '
			Case pnCriteriu2= 5
				lcCriteriu2 = 'nu contine... '
			Case lnCriteriu2 = 6
				lcCriteriu2 = 'nu are valori '
			Case pnCriteriu2= 7
				lcCriteriu2 = 'are valori '
			Endcase
		
			Do Case
			Case Alltrim(Upper(pcIntre)) = 'OR'
				lcCIntre = 'SAU'
			Case Alltrim(Upper(pcIntre)) = 'AND'
				lcCIntre = 'SI'
			Endcase
		
			If !Empty(pcIntre)
				lcTraducere = lcCriteriu + ['] + pcValoare1+ [' ] + lcCIntre + " " + lcCriteriu2 + ['] + pcValoare2 + [']
			Else
				lcTraducere = lcCriteriu + ['] + pcValoare1+ [']
			Endif
		
			poListare.denumire = lcTraducere
		Endif
		
		Thisform.ct_opt_articol.Refresh()
		Thisform.ct_opt_grupa.SetFocus()
		
		*!*	locauta=caut_articol()
		*!*	If !Empty(locauta.id_articol)
		*!*		poListare.denumire = Alltrim(locauta.denumire)
		*!*		poListare.id_articol = locauta.id_articol
		
		*!*		Thisform.ct_opt_articol.Refresh()
		*!*		thisform.ct_opt_grupa.SetFocus()
		*!*	Else
		*!*		If Empty(Nvl(poListare.denumire,[]))
		*!*			Thisform.ct_opt_articol.opt_cautare.Value = 1
		*!*		Endif
		*!*		Thisform.ct_opt_articol.SetFocus()
		*!*	Endif
		
	ENDPROC

	PROCEDURE do_cauta_categorie
		locauta=caut_categorie_entitate()
		If !Empty(locauta.id_categorie_entitate)
			poListare.categorie = Alltrim(locauta.categorie_entitate)
			poListare.id_categorie_entitate = locauta.id_categorie_entitate
		
			Thisform.ct_opt_categorie.Refresh()
			Thisform.ct_opt_articol.SetFocus()
		Else
			If Empty(Nvl(poListare.categorie,[]))
				Thisform.ct_opt_categorie.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_categorie.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_client
		Private pnIdPart,pcNumePart
		Store 0 To pnIdPart
		Store "" To pcNumePart
		If cauta_client(@pnIdPart,@pcNumePart)
			poListare.id_client = pnIdPart
			poListare.nume_client = pcNumePart
		
			Thisform.ct_opt_client.Refresh()
			thisform.ct_opt_categorie.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_client,[]))
				Thisform.ct_opt_client.opt_cautare.Value=1
			Endif
			Thisform.ct_opt_client.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_grupa
		locauta=caut_grupa_articole()
		If !Empty(locauta.id_grupa)
			poListare.grupa = Alltrim(locauta.grupa)
			poListare.id_grupa = locauta.id_grupa
		
			Thisform.ct_opt_grupa.Refresh()
		Else
			If Empty(Nvl(poListare.grupa,[]))
				Thisform.ct_opt_grupa.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_grupa.SetFocus()
		Endif
	ENDPROC

	PROCEDURE do_cauta_subgrupa
		locauta=caut_subgrupa_articole()
		If !Empty(locauta.id_subgrupa)
			poListare.subgrupa = Alltrim(locauta.subgrupa)
			poListare.id_subgrupa = locauta.id_subgrupa
		
			Thisform.ct_opt_subgrupa.Refresh()
			Thisform.but_listare1.SetFocus()
		Else
			If Empty(Nvl(poListare.subgrupa,[]))
				Thisform.ct_opt_subgrupa.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_subgrupa.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_excel
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
			If Reccount('crsraport')<>0
				If Used('crsexportexcel')
					Use In crsexportexcel
				Endif
				Dimension aColoane[1]
				lcSelect = [SELECT Iif(gid<>0,'TOTAL',Space(5)) As explicatie]
				Afields(aColoane,'crsraport')
				For i = 1 To Alen(aColoane,1)
					If Upper(Alltrim(aColoane[i,1])) <> 'GID'
						lcNumeColoana =  Upper(Alltrim(aColoane[i,1]))
						lcSelect = lcSelect + [,] + Iif(aColoane[i,2] = 'T', [TTOD(] + lcNumeColoana + [) as ] + ;
							lcNumeColoana, lcNumeColoana)
					Endif
				Endfor
				lcSelect = lcSelect + [	From crsraport Into Cursor crsexportexcel]
				&lcSelect
		
				export_xls('crsexportexcel')
				Use In crsexportexcel
			Else
				amessagebox("Nu exista rezultate pentru export in Excel!",0+48,"Atentie")
				Thisform.clb_perioada.SetFocus()
			Endif
		
			Use In crsraport
		Endif
		
	ENDPROC

	PROCEDURE do_listare
		Private pcTitlu
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
		*!*	modificare	v 2.0.46
		*!*		Private pcDataOra
		*!*		If Reccount('crsraport')>0
		*!*			lcTitlu = [Raport articole]+Iif(!Empty(Nvl(poListare.grupa,[])),[ grupa ]+Alltrim(poListare.grupa),[]) + ;
		*!*				IIF(!Empty(Nvl(poListare.subgrupa,[])),[ subgrupa ] + Alltrim(poListare.subgrupa),[])
		*!*			pcTitlu = ceretitlu_rap('Titlul Raportului',lcTitlu)
		*!*			pcDataora = get_ora(2)
			pcTitlu = [Raport articole]+Iif(!Empty(Nvl(poListare.grupa,[])),[ grupa ]+Alltrim(poListare.grupa),[]) + ;
				IIF(!Empty(Nvl(poListare.subgrupa,[])),[ subgrupa ] + Alltrim(poListare.subgrupa),[])
		*!*	modificare	v 2.0.46	^
		
			Thisform.AlwaysOnTop = .F.
		*!*	modificare	v 2.0.46
		*!*			Local loExport
		*!*			loExport = Createobject("oExportConfig")
		*!*			loExport.listareUserReport("crsraport","FRX","raport_articole",1,"RAPORT")
		*!*			Release loExport
		*	goExport.export2frx("crsraport","raport_articole",.T.,1,"RAPORT")	&&	, , , .T.)
			goExport.export2frx("crsraport","raport_articole",.T.,1,"RAPORT", , , .T.)
		*!*	modificare	v 2.0.46	^
		*!*			Keyboard "{ctrl+f10}"
		*!*			Select crsraport
		*!*			Report Form raport_articole To Printer Prompt Preview
			Thisform.AlwaysOnTop = .T.
		*!*	modificare	v 2.0.46
		*!*		Else
		*!*			amessagebox("Nu exista rezultate pentru listare!",0+48,"Atentie")
		*!*			Thisform.clb_perioada.SetFocus()
		*!*		Endif
			Thisform.clb_perioada.SetFocus()
		*!*	modificare	v 2.0.46
			Use In crsraport
		EndIf
		Release pcTitlu
	ENDPROC

	PROCEDURE Clb_perioada.tx_n1.Valid
		*!*
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_date_rapoarte_articole_tr AS frm_termin OF "_frm_child.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Ct_clb_raport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport.But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_perioada" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_articol" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_gest_dest" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_articol" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_furnizor" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_sursa" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_um" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_destinatie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_codmat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_pachi" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_camp1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_gest_sursa" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_furnizor" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_subgrupa" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_salveaza1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Optiongroup1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Optiongroup2" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adauga_filtru
		*m: do_cauta_artfurn
		*m: do_cauta_articol
		*m: do_cauta_gest_dest
		*m: do_cauta_gest_sursa
		*m: do_cauta_subgrupa
		*p: cfiltruarticol
		*p: nratavandabilitate
	*</DefinedPropArrayMethod>

	*<PropValue>
		cfiltruarticol = 
		DoCreate = .T.
		Height = 502
		Name = "frm_date_rapoarte_articole_tr"
		nratavandabilitate = 0
		Width = 545
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 708
		_shape2.Left = 647
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		Lb_titlu_alb_b121.Caption = "ARTICOLE TRANSFERATE"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 5
		BUT_TERMIN1.Left = 513
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Left = 448, ;
		Name = "But_excel1", ;
		TabIndex = 3, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Left = 480, ;
		Name = "But_listare1", ;
		TabIndex = 2, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_salveaza1' AS but_salveaza WITH ;
		Left = 386, ;
		Name = "But_salveaza1", ;
		TabIndex = 14, ;
		Top = 1, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_perioada' AS clb_n1n2_simplu WITH ;
		Left = 252, ;
		Name = "Clb_perioada", ;
		TabIndex = 8, ;
		Top = 75, ;
		tx_n1.ControlSource = "poListare.datai", ;
		tx_n1.Left = 127, ;
		tx_n1.Name = "tx_n1", ;
		tx_n1.Top = 2, ;
		LB_SIMPLU1.Caption = "Data factura", ;
		LB_SIMPLU1.Name = "LB_SIMPLU1", ;
		tx_n2.ControlSource = "poListare.dataf", ;
		tx_n2.Name = "tx_n2"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport' AS ct_clb_cautare WITH ;
		Height = 31, ;
		Left = 504, ;
		Name = "Ct_clb_raport", ;
		TabIndex = 6, ;
		Top = 36, ;
		Visible = .F., ;
		Width = 396, ;
		IMG_CAUTARE.Height = 25, ;
		IMG_CAUTARE.Left = 321, ;
		IMG_CAUTARE.Name = "IMG_CAUTARE", ;
		IMG_CAUTARE.Top = 3, ;
		IMG_CAUTARE.Width = 30, ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Caption = "Raport", ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Name = "LB_SIMPLU1", ;
		CLB_TX_CAUTARE.Name = "CLB_TX_CAUTARE", ;
		CLB_TX_CAUTARE.TabIndex = 1, ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Height = 23, ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Left = 71, ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Top = 3, ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Width = 239
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport.But_sterge1' AS but_sterge WITH ;
		Height = 27, ;
		Left = 361, ;
		Name = "But_sterge1", ;
		TabIndex = 2, ;
		Top = 1, ;
		Width = 30
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ct_opt_articol' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_articol, ;
		cvarfiltru = thisform.cfiltruarticol, ;
		cvar_afisata = poListare.denumire, ;
		Left = 252, ;
		Name = "Ct_opt_articol", ;
		TabIndex = 11, ;
		Top = 103, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		LB_EXPLICATIE.Caption = "Articol", ;
		LB_EXPLICATIE.Name = "LB_EXPLICATIE", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_furnizor' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_artfurn, ;
		cvarfiltru = poListare.id_furnart, ;
		cvar_afisata = poListare.furnizor_art, ;
		Left = 252, ;
		Name = "Ct_opt_furnizor", ;
		TabIndex = 12, ;
		Top = 383, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		LB_EXPLICATIE.Caption = "Furnizor", ;
		LB_EXPLICATIE.Name = "LB_EXPLICATIE", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_gest_dest' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_gest_dest, ;
		cvarfiltru = poListare.id_client, ;
		cvar_afisata = poListare.nume_client, ;
		Left = 252, ;
		Name = "Ct_opt_gest_dest", ;
		ntip = 2, ;
		TabIndex = 9, ;
		Top = 313, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		LB_EXPLICATIE.Caption = "Gestiune destinatie", ;
		LB_EXPLICATIE.Name = "LB_EXPLICATIE", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_gest_sursa' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_gest_sursa, ;
		cvarfiltru = poListare.id_gestiune, ;
		cvar_afisata = poListare.nume_gestiune, ;
		Left = 252, ;
		Name = "Ct_opt_gest_sursa", ;
		ntip = 2, ;
		TabIndex = 10, ;
		Top = 243, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		LB_EXPLICATIE.Caption = "Gestiune Sursa", ;
		LB_EXPLICATIE.Name = "LB_EXPLICATIE", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_subgrupa' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_subgrupa, ;
		cvarfiltru = poListare.id_subgrupa, ;
		cvar_afisata = poListare.subgrupa, ;
		Left = 252, ;
		Name = "Ct_opt_subgrupa", ;
		TabIndex = 13, ;
		Top = 173, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		LB_EXPLICATIE.Caption = "Subgrupa de articole", ;
		LB_EXPLICATIE.Name = "LB_EXPLICATIE", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1' AS ct_selectie WITH ;
		ccoloanesuma = adaos|cantitate|valoare_ftva|valoare|val_achizitie, ;
		clistacoloaneordine = 1,2,3,4, ;
		cnumecoloanesuma = Adaos|Cantitate|Valoare fara TVA|Valoare cu TVA|Valoare achizitie, ;
		cnumetabela = fact_vrap_articole_transfer, ;
		Height = 158, ;
		Left = 7, ;
		Name = "Ct_selectie1", ;
		TabIndex = 7, ;
		Top = 75, ;
		Width = 246, ;
		Ct_grupare1.Height = 150, ;
		Ct_grupare1.lblAtentie.Name = "lblAtentie", ;
		Ct_grupare1.lb_grupare.Name = "lb_grupare", ;
		Ct_grupare1.Left = 0, ;
		Ct_grupare1.Name = "Ct_grupare1", ;
		Ct_grupare1.TabIndex = 11, ;
		Ct_grupare1.Top = 157, ;
		Ct_grupare1.Width = 320, ;
		Ct_grupare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_grupare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_grupare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		Ct_ordonare1.Height = 201, ;
		Ct_ordonare1.lb_ordonare.Name = "lb_ordonare", ;
		Ct_ordonare1.Left = -12, ;
		Ct_ordonare1.Name = "Ct_ordonare1", ;
		Ct_ordonare1.TabIndex = 10, ;
		Ct_ordonare1.Top = 404, ;
		Ct_ordonare1.Width = 319, ;
		Ct_ordonare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_ordonare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_ordonare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		lb_coloane.Left = 10, ;
		lb_coloane.Name = "lb_coloane", ;
		lb_coloane.TabIndex = 1, ;
		lb_coloane.Top = 2
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_articol' AS ct_selectie_camp WITH ;
		ccamp = denumire, ;
		cnumecamp = Articol, ;
		Height = 19, ;
		Left = 16, ;
		Name = "Ct_selectie_articol", ;
		nid_container = 2, ;
		TabIndex = 2, ;
		Top = 31, ;
		Width = 213, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_camp1' AS ct_selectie_camp WITH ;
		ccamp = pret, ;
		cnumecamp = Pret vanzare cu TVA, ;
		Height = 19, ;
		Left = 16, ;
		Name = "Ct_selectie_camp1", ;
		nid_container = 7, ;
		TabIndex = 7, ;
		Top = 138, ;
		Width = 213, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_codmat' AS ct_selectie_camp WITH ;
		ccamp = codmat, ;
		cnumecamp = Cod articol, ;
		Height = 19, ;
		Left = 16, ;
		Name = "Ct_selectie_codmat", ;
		nid_container = 1, ;
		TabIndex = 3, ;
		Top = 13, ;
		Width = 213, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_destinatie' AS ct_selectie_camp WITH ;
		ccamp = nume_client, ;
		cnumecamp = Gest. dest., ;
		Height = 19, ;
		Left = 16, ;
		Name = "Ct_selectie_destinatie", ;
		nid_container = 6, ;
		TabIndex = 9, ;
		Top = 103, ;
		Width = 213, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_furnizor' AS ct_selectie_camp WITH ;
		ccamp = furnizor_art, ;
		cnumecamp = Furnizor, ;
		Height = 19, ;
		Left = 16, ;
		Name = "Ct_selectie_furnizor", ;
		nid_container = 4, ;
		TabIndex = 6, ;
		Top = 68, ;
		Width = 213, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_pachi' AS ct_selectie_camp WITH ;
		ccamp = pret_achizitie, ;
		cnumecamp = Pret achizitie, ;
		Height = 19, ;
		Left = 16, ;
		Name = "Ct_selectie_pachi", ;
		nid_container = 7, ;
		TabIndex = 7, ;
		Top = 120, ;
		Width = 213, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_sursa' AS ct_selectie_camp WITH ;
		ccamp = nume_gestiune, ;
		cnumecamp = Gest. sursa, ;
		Height = 19, ;
		Left = 16, ;
		Name = "Ct_selectie_sursa", ;
		nid_container = 5, ;
		TabIndex = 7, ;
		Top = 85, ;
		Width = 213, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_um' AS ct_selectie_camp WITH ;
		ccamp = um, ;
		cnumecamp = U.M., ;
		Height = 19, ;
		Left = 16, ;
		Name = "Ct_selectie_um", ;
		nid_container = 3, ;
		TabIndex = 5, ;
		Top = 50, ;
		Width = 213, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Label1' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Rata minima de vandabilitate:", ;
		Height = 17, ;
		Left = 35, ;
		Name = "Label1", ;
		TabIndex = 15, ;
		Top = 48, ;
		Width = 165
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Optiongroup1' AS optiongroup WITH ;
		AutoSize = .F., ;
		BackStyle = 0, ;
		ButtonCount = 2, ;
		Height = 45, ;
		Left = 7, ;
		Name = "Optiongroup1", ;
		SpecialEffect = 1, ;
		TabIndex = 16, ;
		Top = 232, ;
		Value = 1, ;
		Width = 246, ;
		Option1.AutoSize = .T., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "Top valoric", ;
		Option1.Height = 17, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option1.Value = 1, ;
		Option1.Width = 77, ;
		Option2.AutoSize = .T., ;
		Option2.BackStyle = 0, ;
		Option2.Caption = "Top cantitativ", ;
		Option2.Height = 17, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Top = 24, ;
		Option2.Width = 89
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'Optiongroup2' AS optiongroup WITH ;
		BackStyle = 0, ;
		ButtonCount = 4, ;
		Height = 84, ;
		Left = 7, ;
		Name = "Optiongroup2", ;
		SpecialEffect = 1, ;
		TabIndex = 17, ;
		Top = 276, ;
		Value = 1, ;
		Width = 246, ;
		Option1.AutoSize = .T., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "Articole transferate catre subunitati", ;
		Option1.Height = 17, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option1.Value = 1, ;
		Option1.Width = 207, ;
		Option2.AutoSize = .T., ;
		Option2.BackStyle = 0, ;
		Option2.Caption = "Articole transferate catre protocol", ;
		Option2.Height = 17, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Top = 24, ;
		Option2.Width = 197, ;
		Option3.AutoSize = .T., ;
		Option3.BackStyle = 0, ;
		Option3.Caption = "Articole transferate catre clientii debitori", ;
		Option3.Height = 17, ;
		Option3.Left = 5, ;
		Option3.Name = "Option3", ;
		Option3.Top = 43, ;
		Option3.Width = 232, ;
		Option4.AutoSize = .T., ;
		Option4.BackStyle = 0, ;
		Option4.Caption = "Toate cele de mai sus", ;
		Option4.Height = 17, ;
		Option4.Left = 5, ;
		Option4.Name = "Option4", ;
		Option4.Top = 62, ;
		Option4.Width = 140
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'Text1' AS textbox WITH ;
		ControlSource = "thisform.nratavandabilitate", ;
		Height = 23, ;
		InputMask = "999.99", ;
		Left = 204, ;
		Name = "Text1", ;
		TabIndex = 1, ;
		Top = 46, ;
		Width = 48
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE do_adauga_filtru
		Lparameters lcSql
		
		lcFiltru = [WHERE DATA_ACT BETWEEN ?poListare.datai AND ?poListare.dataf] + gcCondSucursala
		If !Empty(Nvl(poListare.id_client,0))
			lcFiltru = lcFiltru + [ AND id_client ] + Iif(Thisform.ct_opt_gest_dest.nvaloarecriteriu = 1,[=],[<>]) + [ ?poListare.id_client]
		Endif
		
		If !Empty(Nvl(Thisform.cfiltruarticol,[]))
			lcFiltru = lcFiltru + Thisform.cfiltruarticol
		Endif
		
		*!*	IF !EMPTY(NVL(poListare.id_articol,0))
		*!*		lcFiltru = lcFiltru + [ AND id_articol = ?poListare.id_articol]
		*!*	ENDIF
		
		If !Empty(Nvl(poListare.id_gestiune,0))
			lcFiltru = lcFiltru + [ AND id_gestiune ] + Iif(Thisform.ct_opt_gest_sursa.nvaloarecriteriu = 1,[=],[<>]) + [ ?poListare.id_gestiune]
		Endif
		
		If !Empty(Nvl(poListare.id_furnart,0))
			lcFiltru = lcFiltru + [ AND id_furnart= ?poListare.id_furnart]
		Endif
		
		If !Empty(Nvl(poListare.id_subgrupa,0))
			lcFiltru = lcFiltru + [ AND id_subgrupa = ?poListare.id_subgrupa]
		Endif
		Do Case
			Case Thisform.optiongroup2.Value = 1
				lcFiltru = lcFiltru + [ AND id_set in (25032,25034,25036,25039,25050,74,76,207,231,234,236,237,240,241,242,247,248,253,254,255,256,257)]
			Case Thisform.optiongroup2.Value = 2
				lcFiltru = lcFiltru + [ AND id_set in (230,232,233,243,261)]
			Case Thisform.optiongroup2.Value = 3
				lcFiltru = lcFiltru + [ AND id_set in (25037,25038)]
			Otherwise
				lcFiltru = lcFiltru + [ AND id_set in (25037,25038,230,232,233,243,261,] + ;
					[25032,25034,25036,25039,25050,74,76,207,231,234,236,237,240,241,242,247,248,253,254,255,256,257)]
		Endcase
		poListare.csql = Strtran(lcSql,[WHERE 1=2],lcFiltru)
		
	ENDPROC

	PROCEDURE do_cauta
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If Inlist(lccontrol,"TEXTBOX","EDITBOX","COMBOBOX")
			lcval=This.ActiveControl.ControlSource
			&lcval=Thisform.ActiveControl.Value
		Endif
		*!*	DEBUG
		*!*	SUSPEND 
		Do Case
		Case Empty(Nvl(poListare.datai,{}))
			amessagebox("Nu ati completat data initiala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n1.SetFocus()
			Return
		Case Empty(Nvl(poListare.dataf,{}))
			amessagebox("Nu ati completat data finala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n2.SetFocus()
			Return
		Case Empty(Nvl(poListare.data_referinta,{}))
			amessagebox("Nu ati completat data de referinta!",0+48,"Atentie")
			Thisform.clb_data_referinta.SetFocus()
			Return
		Otherwise
			With This.ct_selectie1
				.do_instructiune_sql()
				lcSql = .csql
			Endwith
			If Empty(lcSql)
				amessagebox("Nu ati ales coloane pentru selectie!",0+48,"Atentie")
				Thisform.ct_selectie1.SetFocus()
				Return
			Else
				This.do_adauga_filtru(lcSql)
			Endif
		Endcase
		
		lnSucces = goExecutor.oExecute(poListare.csql,'crsTmpRaport')
		If lnSucces < 0
			amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
			RETURN 
		ENDIF
		
		LOCAL lnValoare , lnCantitate,lnVal_achizitie,lnAdaos
		STORE 0 TO lnValoare,lnCantitate
		SELECT a.*,0000000.00 as procv,IIF(EMPTY(val_achizitie),0,ROUND((adaos / val_achizitie)*100 ,0)) as proca FROM crsTmpRaport a INTO CURSOR crsRaport1 READWRITE 
		SELECT crsRaport1
		SUM valoare TO lnValoare FOR gid=0
		SUM cantitate TO lnCantitate FOR gid=0
		SELECT crsRaport1
		SCAN FOR gid=0
			IF thisform.optiongroup1.Value = 1
				REPLACE procv WITH IIF(EMPTY(valoare),0, ROUND((valoare/lnValoare)*100,2))
			ELSE 
				REPLACE procv WITH IIF(EMPTY(cantitate),0,ROUND((cantitate/lnCantitate)*100,2))
			ENDIF 
		ENDSCAN 
		STORE 0 TO lnValoare , lnCantitate,lnVal_achizitie,lnAdaos
		
		SELECT crsRaport1
		SUM val_achizitie TO lnVal_achizitie FOR gid = 0 and procv >= thisform.nratavandabilitate
		SUM valoare TO lnValoare FOR gid = 0 AND procv >= thisform.nratavandabilitate
		SUM adaos TO lnAdaos FOR gid = 0 AND procv >= thisform.nratavandabilitate
		SUM cantitate TO lnCantitate FOR gid = 0 AND procv >= thisform.nratavandabilitate
		SELECT crsRaport1
		REPLACE val_achizitie WITH  lnVal_achizitie,valoare WITH lnValoare, adaos WITH  lnAdaos,cantitate WITH  lnCantitate ;
			FOR gid<>0
		SELECT * FROM crsRaport1 WITH (buffering = .t.) WHERE ( gid <> 0 or procv >= thisform.nratavandabilitate)  ORDER BY gid ASC ,procv DESC, val_achizitie DESC INTO CURSOR crsRaport
		
		
		*!*	DEBUG
		*!*	SUSPEND 
	ENDPROC

	PROCEDURE do_cauta_artfurn
		Local loCauta
		loCauta = CautPartenerContabilitate(GetHash([cTitlu=>Alegeti clientul??cCont=>401??lAdaugCorespondente=>1]))
		If !Empty(loCauta.id_part) And !Empty(loCauta.denumire)
			poListare.id_furnart= loCauta.id_part
			poListare.furnizor_art= Alltrim(loCauta.denumire)
			Thisform.ct_opt_furnizor.Refresh()
			Thisform.but_listare1.SetFocus()
		Else
			If Empty(Nvl(loCauta.denumire,[]))
				Thisform.ct_opt_furnizor.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_furnizor.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_articol
		Private pcValoare1, pcValoare2, pcIntre, pnCriteriu, pnCriteriu2, pcFiltru, pcFiltruVFP && variabile pe care le completeaza forma frm_filtru_text
		pcValoare1 = []
		pcValoare2 = []
		pnCriteriu = 1
		pnCriteriu2 = 1
		pcIntre = []
		pcFiltru = []
		pcFiltruVFP = []
		lcExplicatie = [Articol]
		
		Do Form frm_filtru_text With [denumire],lcExplicatie,1,1 To lcFiltru
		
		If Empty(lcFiltru)
			Thisform.cfiltruarticol = []
			Thisform.ct_opt_articol.opt_cautare.Value = 1
			Thisform.ct_opt_articol.do_reset()
		Else
			Thisform.cfiltruarticol = lcFiltru
			lcTraducere = []
		&& TRADUCERE
			lcCriteriu = [ ]
			lcCriteriu2 = [ ]
			lcCIntre = []
			Do Case
			Case pnCriteriu= 1
				lcCriteriu = 'incepe cu... '
			Case pnCriteriu= 2
				lcCriteriu = 'este... '
			Case pnCriteriu= 3
				lcCriteriu = 'nu este... '
			Case pnCriteriu= 4
				lcCriteriu = 'contine... '
			Case pnCriteriu= 5
				lcCriteriu = 'nu contine... '
			Case pnCriteriu= 6
				lcCriteriu = 'nu are valori '
			Case pnCriteriu= 7
				lcCriteriu = 'are valori '
			Endcase
		
			Do Case
			Case pnCriteriu2= 1
				lcCriteriu2 = 'incepe cu... '
			Case pnCriteriu2= 2
				lcCriteriu2 = 'este... '
			Case pnCriteriu2= 3
				lcCriteriu2 = 'nu este... '
			Case pnCriteriu2= 4
				lcCriteriu2 = 'contine... '
			Case pnCriteriu2= 5
				lcCriteriu2 = 'nu contine... '
			Case lnCriteriu2 = 6
				lcCriteriu2 = 'nu are valori '
			Case pnCriteriu2= 7
				lcCriteriu2 = 'are valori '
			Endcase
		
			Do Case
			Case Alltrim(Upper(pcIntre)) = 'OR'
				lcCIntre = 'SAU'
			Case Alltrim(Upper(pcIntre)) = 'AND'
				lcCIntre = 'SI'
			Endcase
		
			If !Empty(pcIntre)
				lcTraducere = lcCriteriu + ['] + pcValoare1+ [' ] + lcCIntre + " " + lcCriteriu2 + ['] + pcValoare2 + [']
			Else
				lcTraducere = lcCriteriu + ['] + pcValoare1+ [']
			Endif
		
			poListare.denumire = lcTraducere
		Endif
		
		Thisform.ct_opt_articol.Refresh()
		Thisform.ct_opt_subgrupa.SetFocus()
		
		*!*	locauta=caut_articol()
		*!*	If !Empty(locauta.id_articol)
		*!*		poListare.denumire = Alltrim(locauta.denumire)
		*!*		poListare.id_articol = locauta.id_articol
		
		*!*		Thisform.ct_opt_articol.Refresh()
		*!*		thisform.ct_opt_grupa.SetFocus()
		*!*	Else
		*!*		If Empty(Nvl(poListare.denumire,[]))
		*!*			Thisform.ct_opt_articol.opt_cautare.Value = 1
		*!*		Endif
		*!*		Thisform.ct_opt_articol.SetFocus()
		*!*	Endif
		
	ENDPROC

	PROCEDURE do_cauta_gest_dest
		Private pnIdPart,pcNumePart
		LOCAL locauta
		Store 0 To pnIdPart
		Store "" To pcNumePart
		*!*	If caut_gestiune(@pnIdPart,@pcNumePart)
		locauta =caut_gestiune_dest(0,'',1)
		If !Isnull(loCauta) And !Empty(NVL(loCauta.id_gestiune,0))
			poListare.id_client = locauta.id_gestiune
			poListare.nume_client = locauta.nume_gestiune
		
			Thisform.ct_opt_gest_dest.Refresh()
			Thisform.ct_opt_furnizor.SetFocus()	
		Else
			If Empty(Nvl(poListare.nume_client,[]))
				Thisform.ct_opt_gest_dest.opt_cautare.Value=1
			Endif
			Thisform.ct_opt_gest_dest.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_gest_sursa
		Private pnIdPart,pcNumePart
		LOCAL locauta
		Store 0 To pnIdPart
		Store "" To pcNumePart
		*!*	If caut_gestiune(@pnIdPart,@pcNumePart)
		locauta =caut_gestiune(0,gnIdUtil ,.f.)
		If !Isnull(loCauta) And !Empty(NVL(loCauta.id_gestiune,0))
			poListare.id_gestiune= locauta.id_gestiune
			poListare.nume_gestiune = locauta.nume_gestiune
		
			Thisform.ct_opt_gest_sursa.Refresh()
			Thisform.ct_opt_gest_dest.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_gestiune ,[]))
				Thisform.ct_opt_gest_sursa.opt_cautare.Value=1
			Endif
			Thisform.ct_opt_gest_sursa.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_subgrupa
		locauta=caut_subgrupa_articole()
		If !Empty(locauta.id_subgrupa)
			poListare.subgrupa = Alltrim(locauta.subgrupa)
			poListare.id_subgrupa = locauta.id_subgrupa
		
			Thisform.ct_opt_subgrupa.Refresh()
			thisform.ct_opt_gest_sursa.SetFocus()
		Else
			If Empty(Nvl(poListare.subgrupa,[]))
				Thisform.ct_opt_subgrupa.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_subgrupa.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_excel
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
			If Reccount('crsraport')<>0
				If Used('crsexportexcel')
					Use In crsexportexcel
				Endif
				Dimension aColoane[1]
				lcSelect = [SELECT Iif(gid<>0,'TOTAL',Space(5)) As explicatie]
				Afields(aColoane,'crsraport')
				For i = 1 To Alen(aColoane,1)
					If Upper(Alltrim(aColoane[i,1])) <> 'GID'
						lcNumeColoana =  Upper(Alltrim(aColoane[i,1]))
						lcSelect = lcSelect + [,] + Iif(aColoane[i,2] = 'T', [TTOD(] + lcNumeColoana + [) as ] + ;
							lcNumeColoana, lcNumeColoana)
					Endif
				Endfor
				lcSelect = lcSelect + [	From crsraport Into Cursor crsexportexcel]
				&lcSelect
		
				export_xls('crsexportexcel')
				Use In crsexportexcel
			Else
				amessagebox("Nu exista rezultate pentru export in Excel!",0+48,"Atentie")
				Thisform.clb_perioada.SetFocus()
			Endif
		
			Use In crsraport
		Endif
		
	ENDPROC

	PROCEDURE do_listare
		Private pcTitlu
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
		*!*	modificare	v 2.0.46
		*!*		If Reccount('crsraport')>0
		*!*				IF thisform.optiongroup1.Value=1
		*!*					lcTitlu = [TOP VALORIC ]
		*!*				ELSE
		*!*					lcTitlu= [TOP CANTITATIV ]
		*!*				ENDIF
		*!*			lcTitlu = lcTitlu+Iif(!Empty(Nvl(poListare.grupa,[])),[ grupa ]+Alltrim(poListare.grupa),[]) + ;
		*!*				IIF(!Empty(Nvl(poListare.subgrupa,[])),[ subgrupa ] + Alltrim(poListare.subgrupa),[])
		*!*			pcTitlu = ceretitlu_rap('Titlul Raportului',lcTitlu)
		*!*			pcDataora = get_ora(2)
		*!*			Thisform.AlwaysOnTop = .F.
		*!*			Local loExport
		*!*			loExport = Createobject("oExportConfig")
		*!*			loExport.listareUserReport("crsraport","FRX","raport_articole_transfer",1,"RAPORT")
		*!*			Release loExport
		*!*	*!*			Keyboard "{ctrl+f10}"
		*!*	*!*			Select crsraport
		*!*	*!*			Report Form raport_articole To Printer Prompt Preview
		*!*			Thisform.AlwaysOnTop = .T.
		*!*		Else
		*!*			amessagebox("Nu exista rezultate pentru listare!",0+48,"Atentie")
		*!*			Thisform.clb_perioada.SetFocus()
		*!*		Endif
			Thisform.AlwaysOnTop = .F.
			If Thisform.optiongroup1.Value=1
				pcTitlu = [TOP VALORIC ]
			Else
				pcTitlu= [TOP CANTITATIV ]
			Endif
			pcTitlu = pcTitlu + Iif(!Empty(Nvl(poListare.grupa,[])),[ grupa ]+Alltrim(poListare.grupa),[]) + ;
				IIF(!Empty(Nvl(poListare.subgrupa,[])),[ subgrupa ] + Alltrim(poListare.subgrupa),[])
			* goExport.export2frx("crsraport","raport_articole_transfer",.T.,1,"RAPORT")	&&	, , , .T.)
			goExport.export2frx("crsraport","raport_articole_transfer",.T.,1,"RAPORT", , , .T.)
			Use In crsraport
			Thisform.AlwaysOnTop = .T.
			Thisform.clb_perioada.SetFocus()
		*!*	modificare	v 2.0.46	^
		EndIf
		Release pcTitlu
	ENDPROC

	PROCEDURE Clb_perioada.tx_n1.Valid
		*!*
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_date_rapoarte_articole_v AS frm_termin OF "_frm_child.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Ct_clb_raport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport.But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_perioada" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_articol" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_data_act" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_categ_ent" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_um" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_denumire" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_serie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_numar_act" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_pret_achizitie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_pretv" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_adaos" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_procent_adaos" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_valoare_achizitie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_valoare_adaos" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_cont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_categorie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_grupa" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_subgrupa" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adauga_filtru
		*m: do_cauta_articol
		*m: do_cauta_categorie
		*m: do_cauta_client
		*m: do_cauta_grupa
		*m: do_cauta_subgrupa
		*p: cfiltruarticol
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cfiltruarticol = 
		DoCreate = .T.
		Height = 558
		Name = "frm_date_rapoarte_articole_v"
		Width = 685
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 684
		_shape2.Left = 608
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		Lb_titlu_alb_b121.Caption = "Articole vandute"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		BUT_TERMIN1.Anchor = 8
		BUT_TERMIN1.Left = 653
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Anchor = 8, ;
		Left = 590, ;
		Name = "But_excel1", ;
		TabIndex = 9, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Anchor = 8, ;
		Left = 622, ;
		Name = "But_listare1", ;
		TabIndex = 10, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_perioada' AS clb_n1n2_simplu WITH ;
		Anchor = 8, ;
		Left = 389, ;
		Name = "Clb_perioada", ;
		TabIndex = 3, ;
		Top = 73, ;
		tx_n1.ControlSource = "poListare.datai", ;
		tx_n1.Left = 127, ;
		tx_n1.Name = "tx_n1", ;
		tx_n1.Top = 2, ;
		Lb_simplu1.Caption = "Data factura", ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		tx_n2.ControlSource = "poListare.dataf", ;
		tx_n2.Name = "tx_n2"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport' AS ct_clb_cautare WITH ;
		Height = 31, ;
		Left = 3, ;
		Name = "Ct_clb_raport", ;
		TabIndex = 1, ;
		Top = 37, ;
		Visible = .F., ;
		Width = 396, ;
		img_cautare.Height = 25, ;
		img_cautare.Left = 321, ;
		img_cautare.Name = "img_cautare", ;
		img_cautare.Top = 3, ;
		img_cautare.Width = 30, ;
		clb_tx_cautare.Lb_simplu1.Caption = "Raport", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.TabIndex = 1, ;
		clb_tx_cautare.Text_simplu1.Height = 23, ;
		clb_tx_cautare.Text_simplu1.Left = 71, ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1", ;
		clb_tx_cautare.Text_simplu1.Top = 3, ;
		clb_tx_cautare.Text_simplu1.Width = 239
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport.But_sterge1' AS but_sterge WITH ;
		Height = 27, ;
		Left = 361, ;
		Name = "But_sterge1", ;
		TabIndex = 2, ;
		Top = 1, ;
		Width = 30
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ct_opt_articol' AS ct_opt_cautare WITH ;
		Anchor = 8, ;
		cprocedura = thisform.do_cauta_articol, ;
		cvarfiltru = thisform.cfiltruarticol, ;
		cvar_afisata = poListare.denumire, ;
		Left = 389, ;
		Name = "Ct_opt_articol", ;
		TabIndex = 6, ;
		Top = 241, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Articol", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_categorie' AS ct_opt_cautare WITH ;
		Anchor = 8, ;
		cprocedura = thisform.do_cauta_categorie, ;
		cvarfiltru = poListare.id_categorie_entitate, ;
		cvar_afisata = poListare.categorie, ;
		Left = 389, ;
		Name = "Ct_opt_categorie", ;
		TabIndex = 5, ;
		Top = 171, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Categorie entitate", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_client' AS ct_opt_cautare WITH ;
		Anchor = 8, ;
		cprocedura = thisform.do_cauta_client, ;
		cvarfiltru = poListare.id_client, ;
		cvar_afisata = poListare.nume_client, ;
		Left = 389, ;
		Name = "Ct_opt_client", ;
		TabIndex = 4, ;
		Top = 101, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Client", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_grupa' AS ct_opt_cautare WITH ;
		Anchor = 8, ;
		cprocedura = thisform.do_cauta_grupa, ;
		cvarfiltru = poListare.id_grupa, ;
		cvar_afisata = poListare.grupa, ;
		Left = 389, ;
		Name = "Ct_opt_grupa", ;
		TabIndex = 7, ;
		Top = 311, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Grupa de articole", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_subgrupa' AS ct_opt_cautare WITH ;
		Anchor = 8, ;
		cprocedura = thisform.do_cauta_subgrupa, ;
		cvarfiltru = poListare.id_subgrupa, ;
		cvar_afisata = poListare.subgrupa, ;
		Left = 389, ;
		Name = "Ct_opt_subgrupa", ;
		TabIndex = 8, ;
		Top = 381, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Subgrupa de articole", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1' AS ct_selectie WITH ;
		Anchor = 15, ;
		ccoloanesuma = cantitate|valoare_ftva|valoare, ;
		clistacoloaneordine = 1,2, ;
		cnumecoloanesuma = Cantitate|Valoare fara TVA| Valoare cu TVA, ;
		cnumetabela = fact_vrap_articole_vandute, ;
		Height = 479, ;
		Left = 4, ;
		Name = "Ct_selectie1", ;
		TabIndex = 2, ;
		Top = 73, ;
		Width = 382, ;
		Ct_grupare1.Anchor = 15, ;
		Ct_grupare1.Height = 185, ;
		Ct_grupare1.lblAtentie.Name = "lblAtentie", ;
		Ct_grupare1.lb_grupare.Name = "lb_grupare", ;
		Ct_grupare1.Left = 5, ;
		Ct_grupare1.Name = "Ct_grupare1", ;
		Ct_grupare1.TabIndex = 11, ;
		Ct_grupare1.Top = 290, ;
		Ct_grupare1.Width = 372, ;
		Ct_grupare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_grupare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_grupare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		Ct_ordonare1.Anchor = 11, ;
		Ct_ordonare1.Height = 215, ;
		Ct_ordonare1.lb_ordonare.Name = "lb_ordonare", ;
		Ct_ordonare1.Left = 5, ;
		Ct_ordonare1.Name = "Ct_ordonare1", ;
		Ct_ordonare1.TabIndex = 10, ;
		Ct_ordonare1.Top = 76, ;
		Ct_ordonare1.Width = 372, ;
		Ct_ordonare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_ordonare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_ordonare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		lb_coloane.Left = 10, ;
		lb_coloane.Name = "lb_coloane", ;
		lb_coloane.TabIndex = 1, ;
		lb_coloane.Top = 2
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_adaos' AS ct_selectie_camp WITH ;
		ccamp = adaos, ;
		cnumecamp = Adaos, ;
		Left = 248, ;
		Name = "Ct_selectie_adaos", ;
		nid_container = 10, ;
		TabIndex = 8, ;
		Top = 1, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_categ_ent' AS ct_selectie_camp WITH ;
		ccamp = categorie_entitate, ;
		cnumecamp = Categorie, ;
		Left = 4, ;
		Name = "Ct_selectie_categ_ent", ;
		nid_container = 4, ;
		TabIndex = 6, ;
		Top = 57, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_cont' AS ct_selectie_camp WITH ;
		ccamp = cont, ;
		cnumecamp = Cont, ;
		Left = 248, ;
		Name = "Ct_selectie_cont", ;
		nid_container = 15, ;
		TabIndex = 8, ;
		Top = 57, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_data_act' AS ct_selectie_camp WITH ;
		ccamp = data_act, ;
		cnumecamp = Data factura, ;
		Left = 4, ;
		Name = "Ct_selectie_data_act", ;
		nid_container = 1, ;
		TabIndex = 2, ;
		Top = 15, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_denumire' AS ct_selectie_camp WITH ;
		ccamp = denumire, ;
		cnumecamp = Articol, ;
		Left = 133, ;
		Name = "Ct_selectie_denumire", ;
		nid_container = 5, ;
		TabIndex = 7, ;
		Top = 1, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_numar_act' AS ct_selectie_camp WITH ;
		ccamp = numar_act, ;
		cnumecamp = Nr.factura, ;
		Left = 4, ;
		Name = "Ct_selectie_numar_act", ;
		nid_container = 2, ;
		TabIndex = 3, ;
		Top = 29, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_client' AS ct_selectie_camp WITH ;
		ccamp = nume_client, ;
		cnumecamp = Nume client, ;
		Left = 4, ;
		Name = "Ct_selectie_nume_client", ;
		nid_container = 3, ;
		TabIndex = 5, ;
		Top = 43, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_pret_achizitie' AS ct_selectie_camp WITH ;
		ccamp = pret_achizitie, ;
		cnumecamp = Pret achizitie, ;
		Left = 133, ;
		Name = "Ct_selectie_pret_achizitie", ;
		nid_container = 8, ;
		TabIndex = 8, ;
		Top = 43, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_pretv' AS ct_selectie_camp WITH ;
		ccamp = pretv_ftva, ;
		cnumecamp = Pret vanzare fara TVA, ;
		Left = 133, ;
		Name = "Ct_selectie_pretv", ;
		nid_container = 9, ;
		TabIndex = 8, ;
		Top = 57, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_procent_adaos' AS ct_selectie_camp WITH ;
		ccamp = procent_adaos, ;
		cnumecamp = Procent adaos, ;
		Left = 248, ;
		Name = "Ct_selectie_procent_adaos", ;
		nid_container = 11, ;
		TabIndex = 8, ;
		Top = 15, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_serie' AS ct_selectie_camp WITH ;
		ccamp = serie, ;
		cnumecamp = Serie, ;
		Left = 133, ;
		Name = "Ct_selectie_serie", ;
		nid_container = 7, ;
		TabIndex = 9, ;
		Top = 29, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_um' AS ct_selectie_camp WITH ;
		ccamp = um, ;
		cnumecamp = U.M., ;
		Left = 133, ;
		Name = "Ct_selectie_um", ;
		nid_container = 6, ;
		TabIndex = 8, ;
		Top = 15, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_valoare_achizitie' AS ct_selectie_camp WITH ;
		ccamp = valoare_achizitie, ;
		cnumecamp = Valoare achizitie, ;
		Left = 248, ;
		Name = "Ct_selectie_valoare_achizitie", ;
		nid_container = 12, ;
		TabIndex = 8, ;
		Top = 29, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_valoare_adaos' AS ct_selectie_camp WITH ;
		ccamp = valoare_adaos, ;
		cnumecamp = Valoare adaos, ;
		Left = 248, ;
		Name = "Ct_selectie_valoare_adaos", ;
		nid_container = 14, ;
		TabIndex = 8, ;
		Top = 43, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />
	
	PROCEDURE do_adauga_filtru
		Lparameters lcSql
		lcFiltru = [WHERE DATA_ACT BETWEEN ?poListare.datai AND ?poListare.dataf] + gcCondSucursala
		If !Empty(Nvl(poListare.id_client,0))
			lcFiltru = lcFiltru + [ AND id_part = ?poListare.id_client]
		Endif
		
		If !Empty(Nvl(Thisform.cfiltruarticol,[]))
			lcFiltru = lcFiltru + Thisform.cfiltruarticol
		Endif
		
		*!*	IF !EMPTY(NVL(poListare.id_articol,0))
		*!*		lcFiltru = lcFiltru + [ AND id_articol = ?poListare.id_articol]
		*!*	ENDIF
		
		If !Empty(Nvl(poListare.id_categorie_entitate,0))
			lcFiltru = lcFiltru + [ AND id_categorie_entitate = ?poListare.id_categorie_entitate]
		Endif
		
		If !Empty(Nvl(poListare.id_grupa,0))
			lcFiltru = lcFiltru + [ AND id_grupa = ?poListare.id_grupa]
		Endif
		
		If !Empty(Nvl(poListare.id_subgrupa,0))
			lcFiltru = lcFiltru + [ AND id_subgrupa = ?poListare.id_subgrupa]
		Endif
		
		poListare.csql = Strtran(lcSql,[WHERE 1=2],lcFiltru)
		
	ENDPROC

	PROCEDURE do_cauta
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If Inlist(lccontrol,"TEXTBOX","EDITBOX","COMBOBOX")
			lcval=This.ActiveControl.ControlSource
			&lcval=Thisform.ActiveControl.Value
		Endif
		
		Do Case
		Case Empty(Nvl(poListare.datai,{}))
			amessagebox("Nu ati completat data initiala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n1.SetFocus()
			Return
		Case Empty(Nvl(poListare.dataf,{}))
			amessagebox("Nu ati completat data finala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n2.SetFocus()
			Return
		Case Empty(Nvl(poListare.data_referinta,{}))
			amessagebox("Nu ati completat data de referinta!",0+48,"Atentie")
			Thisform.clb_data_referinta.SetFocus()
			Return
		Otherwise
			With This.ct_selectie1
				.do_instructiune_sql()
				lcSql = .csql
			Endwith
			If Empty(lcSql)
				amessagebox("Nu ati ales coloane pentru selectie!",0+48,"Atentie")
				Thisform.ct_selectie1.SetFocus()
				Return
			Else
				This.do_adauga_filtru(lcSql)
			Endif
		Endcase
		
		lnSucces = goExecutor.oExecute(poListare.csql,'crsraport')
		If lnSucces < 0
			amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
		Endif
	ENDPROC

	PROCEDURE do_cauta_articol
		Private pcValoare1, pcValoare2, pcIntre, pnCriteriu, pnCriteriu2, pcFiltru, pcFiltruVFP && variabile pe care le completeaza forma frm_filtru_text
		pcValoare1 = []
		pcValoare2 = []
		pnCriteriu = 1
		pnCriteriu2 = 1
		pcIntre = []
		pcFiltru = []
		pcFiltruVFP = []
		lcExplicatie = [Articol]
		
		Do Form frm_filtru_text With [denumire],lcExplicatie,1,1 To lcFiltru
		
		If Empty(lcFiltru)
			Thisform.cfiltruarticol = []
			Thisform.ct_opt_articol.opt_cautare.Value = 1
			Thisform.ct_opt_articol.do_reset()
		Else
			Thisform.cfiltruarticol = lcFiltru
			lcTraducere = []
		&& TRADUCERE
			lcCriteriu = [ ]
			lcCriteriu2 = [ ]
			lcCIntre = []
			Do Case
			Case pnCriteriu= 1
				lcCriteriu = 'incepe cu... '
			Case pnCriteriu= 2
				lcCriteriu = 'este... '
			Case pnCriteriu= 3
				lcCriteriu = 'nu este... '
			Case pnCriteriu= 4
				lcCriteriu = 'contine... '
			Case pnCriteriu= 5
				lcCriteriu = 'nu contine... '
			Case pnCriteriu= 6
				lcCriteriu = 'nu are valori '
			Case pnCriteriu= 7
				lcCriteriu = 'are valori '
			Endcase
		
			Do Case
			Case pnCriteriu2= 1
				lcCriteriu2 = 'incepe cu... '
			Case pnCriteriu2= 2
				lcCriteriu2 = 'este... '
			Case pnCriteriu2= 3
				lcCriteriu2 = 'nu este... '
			Case pnCriteriu2= 4
				lcCriteriu2 = 'contine... '
			Case pnCriteriu2= 5
				lcCriteriu2 = 'nu contine... '
			Case lnCriteriu2 = 6
				lcCriteriu2 = 'nu are valori '
			Case pnCriteriu2= 7
				lcCriteriu2 = 'are valori '
			Endcase
		
			Do Case
			Case Alltrim(Upper(pcIntre)) = 'OR'
				lcCIntre = 'SAU'
			Case Alltrim(Upper(pcIntre)) = 'AND'
				lcCIntre = 'SI'
			Endcase
		
			If !Empty(pcIntre)
				lcTraducere = lcCriteriu + ['] + pcValoare1+ [' ] + lcCIntre + " " + lcCriteriu2 + ['] + pcValoare2 + [']
			Else
				lcTraducere = lcCriteriu + ['] + pcValoare1+ [']
			Endif
		
			poListare.denumire = lcTraducere
		Endif
		
		Thisform.ct_opt_articol.Refresh()
		Thisform.ct_opt_grupa.SetFocus()
		
		*!*	locauta=caut_articol()
		*!*	If !Empty(locauta.id_articol)
		*!*		poListare.denumire = Alltrim(locauta.denumire)
		*!*		poListare.id_articol = locauta.id_articol
		
		*!*		Thisform.ct_opt_articol.Refresh()
		*!*		thisform.ct_opt_grupa.SetFocus()
		*!*	Else
		*!*		If Empty(Nvl(poListare.denumire,[]))
		*!*			Thisform.ct_opt_articol.opt_cautare.Value = 1
		*!*		Endif
		*!*		Thisform.ct_opt_articol.SetFocus()
		*!*	Endif
		
	ENDPROC

	PROCEDURE do_cauta_categorie
		locauta=caut_categorie_entitate()
		If !Empty(locauta.id_categorie_entitate)
			poListare.categorie = Alltrim(locauta.categorie_entitate)
			poListare.id_categorie_entitate = locauta.id_categorie_entitate
		
			Thisform.ct_opt_categorie.Refresh()
			Thisform.ct_opt_articol.SetFocus()
		Else
			If Empty(Nvl(poListare.categorie,[]))
				Thisform.ct_opt_categorie.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_categorie.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_client
		Private pnIdPart,pcNumePart
		Store 0 To pnIdPart
		Store "" To pcNumePart
		If cauta_client(@pnIdPart,@pcNumePart)
			poListare.id_client = pnIdPart
			poListare.nume_client = pcNumePart
		
			Thisform.ct_opt_client.Refresh()
			thisform.ct_opt_categorie.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_client,[]))
				Thisform.ct_opt_client.opt_cautare.Value=1
			Endif
			Thisform.ct_opt_client.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_grupa
		locauta=caut_grupa_articole()
		If !Empty(locauta.id_grupa)
			poListare.grupa = Alltrim(locauta.grupa)
			poListare.id_grupa = locauta.id_grupa
		
			Thisform.ct_opt_grupa.Refresh()
		Else
			If Empty(Nvl(poListare.grupa,[]))
				Thisform.ct_opt_grupa.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_grupa.SetFocus()
		Endif
	ENDPROC

	PROCEDURE do_cauta_subgrupa
		locauta=caut_subgrupa_articole()
		If !Empty(locauta.id_subgrupa)
			poListare.subgrupa = Alltrim(locauta.subgrupa)
			poListare.id_subgrupa = locauta.id_subgrupa
		
			Thisform.ct_opt_subgrupa.Refresh()
			Thisform.but_listare1.SetFocus()
		Else
			If Empty(Nvl(poListare.subgrupa,[]))
				Thisform.ct_opt_subgrupa.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_subgrupa.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_excel
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
			If Reccount('crsraport')<>0
				If Used('crsexportexcel')
					Use In crsexportexcel
				Endif
				Dimension aColoane[1]
				lcSelect = [SELECT Iif(gid<>0,'TOTAL',Space(5)) As explicatie]
				Afields(aColoane,'crsraport')
				For i = 1 To Alen(aColoane,1)
					If Upper(Alltrim(aColoane[i,1])) <> 'GID'
						lcNumeColoana =  Upper(Alltrim(aColoane[i,1]))
						lcSelect = lcSelect + [,] + Iif(aColoane[i,2] = 'T', [TTOD(] + lcNumeColoana + [) as ] + ;
							lcNumeColoana, lcNumeColoana)
					Endif
				Endfor
				lcSelect = lcSelect + [	From crsraport Into Cursor crsexportexcel]
				&lcSelect
		
				export_xls('crsexportexcel')
				Use In crsexportexcel
			Else
				amessagebox("Nu exista rezultate pentru export in Excel!",0+48,"Atentie")
				Thisform.clb_perioada.SetFocus()
			Endif
		
			Use In crsraport
		Endif
		
	ENDPROC

	PROCEDURE do_listare
		Private pcTitlu
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
		*!*		If Reccount('crsraport')>0
		*!*			lcTitlu = [Raport articole]+Iif(!Empty(Nvl(poListare.grupa,[])),[ grupa ]+Alltrim(poListare.grupa),[]) + ;
		*!*				IIF(!Empty(Nvl(poListare.subgrupa,[])),[ subgrupa ] + Alltrim(poListare.subgrupa),[])
		*!*			pcTitlu = ceretitlu_rap('Titlul Raportului',lcTitlu)
		*!*			pcDataora = get_ora(2)
		
		*!*			Thisform.AlwaysOnTop = .F.
		*!*			Local loExport
		*!*			loExport = Createobject("oExportConfig")
		*!*			loExport.listareUserReport("crsraport","FRX","raport_articole",1,"RAPORT")
		*!*			Release loExport
		*!*	*!*			Keyboard "{ctrl+f10}"
		*!*	*!*			Select crsraport
		*!*	*!*			Report Form raport_articole To Printer Prompt Preview
		*!*			Thisform.AlwaysOnTop = .T.
		*!*		Else
		*!*			amessagebox("Nu exista rezultate pentru listare!",0+48,"Atentie")
		*!*			Thisform.clb_perioada.SetFocus()
		*!*		Endif
			pcTitlu = [Raport articole]+Iif(!Empty(Nvl(poListare.grupa,[])),[ grupa ]+Alltrim(poListare.grupa),[]) + ;
				IIF(!Empty(Nvl(poListare.subgrupa,[])),[ subgrupa ] + Alltrim(poListare.subgrupa),[])
			Thisform.AlwaysOnTop = .F.
			*goExport.export2frx("crsraport","raport_articole",.T.,1,"RAPORT")	&&	, , , .T.)
			goExport.export2frx("crsraport","raport_articole",.T.,1,"RAPORT", , , .T.)
			Thisform.clb_perioada.SetFocus()
			Thisform.AlwaysOnTop = .T.
			Use In crsraport
		EndIf
		Release pcTitlu
	ENDPROC

	PROCEDURE Clb_perioada.tx_n1.Valid
		*!*
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_date_rapoarte_avize AS _frmbase OF "_frm_base.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="But_salveaza1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport.But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_perioada" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_agent" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_masina" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_delegat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nract" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_agent" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_delegat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nrinmat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_dataact" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_categorie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_categorie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_tip_aviz" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_fact_nefact" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adauga_filtru
		*m: do_cauta_agent
		*m: do_cauta_categorie
		*m: do_cauta_client
		*m: do_cauta_delegat
		*m: do_cauta_masina
		*p: ctitluraport
	*</DefinedPropArrayMethod>

	*<PropValue>
		ctitluraport = 
		DoCreate = .T.
		Height = 520
		Name = "frm_date_rapoarte_avize"
		Width = 696
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 696
		_shape2.Height = 29
		_shape2.Left = 604
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 90
		Lb_titlu_alb_b121.Caption = "AVIZE"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 14
		BUT_TERMIN1.Left = 666
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 13
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Left = 480
		GRIDSORT1.Name = "GRIDSORT1"
		GRIDSORT1.Top = 36
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Left = 605, ;
		Name = "But_excel1", ;
		TabIndex = 15, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Left = 636, ;
		Name = "But_listare1", ;
		TabIndex = 12, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_salveaza1' AS but_salveaza WITH ;
		Left = 528, ;
		Name = "But_salveaza1", ;
		TabIndex = 11, ;
		Top = 0, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_perioada' AS clb_n1n2_simplu WITH ;
		Left = 383, ;
		Name = "Clb_perioada", ;
		TabIndex = 3, ;
		Top = 72, ;
		tx_n1.ControlSource = "poListare.datai", ;
		tx_n1.Left = 127, ;
		tx_n1.Name = "tx_n1", ;
		tx_n1.Top = 2, ;
		Lb_simplu1.Caption = "Data aviz", ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		tx_n2.ControlSource = "poListare.dataf", ;
		tx_n2.Name = "tx_n2"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport' AS ct_clb_cautare WITH ;
		Height = 31, ;
		Left = 23, ;
		Name = "Ct_clb_raport", ;
		TabIndex = 1, ;
		Top = 36, ;
		Visible = .F., ;
		Width = 396, ;
		img_cautare.Height = 25, ;
		img_cautare.Left = 321, ;
		img_cautare.Name = "img_cautare", ;
		img_cautare.Top = 3, ;
		img_cautare.Width = 30, ;
		clb_tx_cautare.Lb_simplu1.Caption = "Raport", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.TabIndex = 1, ;
		clb_tx_cautare.Text_simplu1.Height = 23, ;
		clb_tx_cautare.Text_simplu1.Left = 71, ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1", ;
		clb_tx_cautare.Text_simplu1.Top = 3, ;
		clb_tx_cautare.Text_simplu1.Width = 239
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport.But_sterge1' AS but_sterge WITH ;
		Height = 27, ;
		Left = 361, ;
		Name = "But_sterge1", ;
		TabIndex = 2, ;
		Top = 1, ;
		Width = 30
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ct_opt_agent' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_agent, ;
		cvarfiltru = poListare.id_agent, ;
		cvar_afisata = poListare.nume_agent, ;
		Left = 383, ;
		Name = "Ct_opt_agent", ;
		TabIndex = 5, ;
		Top = 170, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Agent", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_categorie' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_categorie, ;
		cvarfiltru = poListare.id_categorie_entitate, ;
		cvar_afisata = poListare.categorie, ;
		Left = 383, ;
		Name = "Ct_opt_categorie", ;
		TabIndex = 8, ;
		Top = 380, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Categorie entitate", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_client' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_client, ;
		cvarfiltru = poListare.id_client, ;
		cvar_afisata = poListare.nume_client, ;
		Left = 383, ;
		Name = "Ct_opt_client", ;
		TabIndex = 4, ;
		Top = 100, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Client", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_delegat' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_delegat, ;
		cvarfiltru = poListare.id_delegat, ;
		cvar_afisata = poListare.nume_delegat, ;
		Left = 383, ;
		Name = "Ct_opt_delegat", ;
		TabIndex = 6, ;
		Top = 240, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Delegat", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_masina' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_masina, ;
		cvarfiltru = poListare.id_masina, ;
		cvar_afisata = poListare.nrinmat, ;
		Left = 383, ;
		Name = "Ct_opt_masina", ;
		TabIndex = 7, ;
		Top = 310, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Masina", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1' AS ct_selectie WITH ;
		ccoloanesuma = avizat|facturat, ;
		clistacoloaneordine = 1, ;
		cnumecoloanesuma = Valoare avizata|Valoare facturata, ;
		cnumetabela = fact_vrap_avize_fact, ;
		Height = 408, ;
		Left = 24, ;
		Name = "Ct_selectie1", ;
		TabIndex = 2, ;
		Top = 72, ;
		Width = 332, ;
		Ct_grupare1.lblAtentie.Name = "lblAtentie", ;
		Ct_grupare1.lb_grupare.Name = "lb_grupare", ;
		Ct_grupare1.Left = 5, ;
		Ct_grupare1.Name = "Ct_grupare1", ;
		Ct_grupare1.TabIndex = 10, ;
		Ct_grupare1.Top = 263, ;
		Ct_grupare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_grupare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_grupare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		Ct_ordonare1.Height = 169, ;
		Ct_ordonare1.lb_ordonare.Name = "lb_ordonare", ;
		Ct_ordonare1.Left = 5, ;
		Ct_ordonare1.Name = "Ct_ordonare1", ;
		Ct_ordonare1.TabIndex = 9, ;
		Ct_ordonare1.Top = 95, ;
		Ct_ordonare1.Width = 320, ;
		Ct_ordonare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_ordonare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_ordonare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		lb_coloane.Name = "lb_coloane", ;
		lb_coloane.TabIndex = 1
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_categorie' AS ct_selectie_camp WITH ;
		ccamp = categorie_entitate, ;
		cnumecamp = Categorie, ;
		Left = 180, ;
		Name = "Ct_selectie_categorie", ;
		TabIndex = 8, ;
		Top = 51, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_dataact' AS ct_selectie_camp WITH ;
		ccamp = dataact, ;
		cnumecamp = Data aviz, ;
		Left = 17, ;
		Name = "Ct_selectie_dataact", ;
		nid_container = 2, ;
		TabIndex = 3, ;
		Top = 36, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nract' AS ct_selectie_camp WITH ;
		ccamp = nract, ;
		cnumecamp = Nr. aviz, ;
		Left = 17, ;
		lgrupare = .F., ;
		Name = "Ct_selectie_nract", ;
		nid_container = 1, ;
		TabIndex = 2, ;
		Top = 22, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nrinmat' AS ct_selectie_camp WITH ;
		ccamp = nrinmat, ;
		cnumecamp = Masina, ;
		Left = 180, ;
		Name = "Ct_selectie_nrinmat", ;
		TabIndex = 7, ;
		Top = 36, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_agent' AS ct_selectie_camp WITH ;
		ccamp = nume_agent, ;
		cnumecamp = Agent, ;
		Left = 17, ;
		Name = "Ct_selectie_nume_agent", ;
		nid_container = 5, ;
		TabIndex = 5, ;
		Top = 65, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_client' AS ct_selectie_camp WITH ;
		ccamp = nume_client, ;
		cnumecamp = Client, ;
		Left = 17, ;
		Name = "Ct_selectie_nume_client", ;
		nid_container = 4, ;
		TabIndex = 4, ;
		Top = 51, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_delegat' AS ct_selectie_camp WITH ;
		ccamp = nume_delegat, ;
		cnumecamp = Delegat, ;
		Left = 180, ;
		Name = "Ct_selectie_nume_delegat", ;
		TabIndex = 6, ;
		Top = 22, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'opt_fact_nefact' AS _optiongrup WITH ;
		AutoSize = .F., ;
		ButtonCount = 3, ;
		Height = 27, ;
		Left = 374, ;
		Name = "opt_fact_nefact", ;
		TabIndex = 10, ;
		Top = 476, ;
		Value = 1, ;
		Width = 314, ;
		OPTION1.AutoSize = .T., ;
		OPTION1.Caption = "Toate", ;
		OPTION1.Left = 5, ;
		OPTION1.Name = "OPTION1", ;
		OPTION1.Top = 5, ;
		OPTION1.Value = 1, ;
		OPTION2.AutoSize = .T., ;
		OPTION2.Caption = "Facturate", ;
		OPTION2.Left = 62, ;
		OPTION2.Name = "OPTION2", ;
		OPTION2.Top = 5, ;
		OPTION2.Value = 0, ;
		Option3.AutoSize = .T., ;
		Option3.BackStyle = 0, ;
		Option3.Caption = "Nefacturate", ;
		Option3.Height = 17, ;
		Option3.Left = 191, ;
		Option3.Name = "Option3", ;
		Option3.Top = 5, ;
		Option3.Width = 81
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />

	ADD OBJECT 'opt_tip_aviz' AS _optiongrup WITH ;
		ButtonCount = 3, ;
		Height = 27, ;
		Left = 374, ;
		Name = "opt_tip_aviz", ;
		TabIndex = 9, ;
		Top = 451, ;
		Value = 1, ;
		Width = 314, ;
		OPTION1.AutoSize = .T., ;
		OPTION1.Caption = "Toate", ;
		OPTION1.Left = 5, ;
		OPTION1.Name = "OPTION1", ;
		OPTION1.Top = 5, ;
		OPTION1.Value = 1, ;
		OPTION2.AutoSize = .T., ;
		OPTION2.Caption = "Doar avize de retur", ;
		OPTION2.Left = 62, ;
		OPTION2.Name = "OPTION2", ;
		OPTION2.Top = 5, ;
		OPTION2.Value = 0, ;
		Option3.AutoSize = .T., ;
		Option3.BackStyle = 0, ;
		Option3.Caption = "Fara avize de retur", ;
		Option3.Height = 17, ;
		Option3.Left = 191, ;
		Option3.Name = "Option3", ;
		Option3.Top = 5, ;
		Option3.Width = 118
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />
	
	PROCEDURE do_adauga_filtru
		Lparameters lcSql
		lcFiltru = [WHERE DATAACT BETWEEN ?poListare.datai AND ?poListare.dataf] + gcCondSucursala
		
		If !Empty(Nvl(poListare.id_client,0))
			lcFiltru = lcFiltru + [ AND id_part = ?poListare.id_client]
		Endif
		
		If !Empty(Nvl(poListare.id_agent,0))
			lcFiltru = lcFiltru + [ AND id_agent = ?poListare.id_agent]
		Endif
		
		If !Empty(Nvl(poListare.id_delegat,0))
			lcFiltru = lcFiltru + [ AND id_delegat = ?poListare.id_delegat]
		Endif
		
		If !Empty(Nvl(poListare.id_masina,0))
			lcFiltru = lcFiltru + [ AND id_masina = ?poListare.id_masina]
		Endif
		
		If !Empty(Nvl(poListare.id_categorie_entitate,0))
			lcFiltru = lcFiltru + [ AND id_categorie_entitate = ?poListare.id_categorie_entitate]
		Endif
		
		lnTipAviz = This.opt_tip_aviz.Value
		This.ctitluraport = [AVIZE]
		Do Case
		Case lnTipAviz = 2
			This.ctitluraport = [AVIZE DE RETUR]
			lcFiltru = lcFiltru + [ AND avizat < 0 ]
		Case lnTipAviz = 3
			This.ctitluraport = [AVIZE (FARA CELE DE RETUR)]
			lcFiltru = lcFiltru + [ AND avizat > 0 ]
		Endcase
		
		lnFactNefact = This.opt_fact_nefact.Value
		Do Case
		Case lnFactNefact = 2
			This.ctitluraport = This.ctitluraport + [ FACTURATE]
			lcFiltru = lcFiltru + [ AND avizat = facturat]
		Case lnFactNefact = 3
			This.ctitluraport = This.ctitluraport + [ NEFACTURATE]
			lcFiltru = lcFiltru + [ AND avizat > facturat ]
		Endcase
		
		poListare.csql = Strtran(lcSql,[WHERE 1=2],lcFiltru)
		
	ENDPROC

	PROCEDURE do_cauta
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If Inlist(lccontrol,"TEXTBOX","EDITBOX","COMBOBOX")
			lcval=This.ActiveControl.ControlSource
			&lcval=Thisform.ActiveControl.Value
		Endif
		
		Do Case
		Case Empty(Nvl(poListare.datai,{}))
			amessagebox("Nu ati completat data initiala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n1.SetFocus()
			Return
		Case Empty(Nvl(poListare.dataf,{}))
			amessagebox("Nu ati completat data finala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n2.SetFocus()
			Return
		Case Empty(Nvl(poListare.data_referinta,{}))
			amessagebox("Nu ati completat data de referinta!",0+48,"Atentie")
			Thisform.clb_data_referinta.SetFocus()
			Return
		Otherwise
			With This.ct_selectie1
				.do_instructiune_sql()
				lcSql = .csql
			Endwith
			If Empty(lcSql)
				amessagebox("Nu ati ales coloane pentru selectie!",0+48,"Atentie")
				Thisform.ct_selectie1.SetFocus()
				Return
			Else
				This.do_adauga_filtru(lcSql)
			Endif
		Endcase
		
		lnSucces = goExecutor.oExecute(poListare.csql,'crsraport')
		If lnSucces < 0
			amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
		Endif
	ENDPROC

	PROCEDURE do_cauta_agent
		Private pnIdPart,pcNumePart
		lcTitlu=[ALEGETI AGENTUL]
		pnIdPart=0
		pcNumePart=[]
		
		If caut_partener_dupa_tip(gnIdTipAgenti,lcTitlu,@pnIdPart,@pcNumePart)
			poListare.id_agent = pnIdPart
			poListare.nume_agent = Alltrim(pcNumePart)
			Thisform.ct_opt_agent.Refresh()
			Thisform.ct_opt_delegat.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_agent,[]))
				Thisform.ct_opt_agent.opt_cautare.Value=1
			Endif
			Thisform.ct_opt_agent.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_categorie
		locauta=caut_categorie_entitate()
		If !Empty(locauta.id_categorie_entitate)
			poListare.categorie = Alltrim(locauta.categorie_entitate)
			poListare.id_categorie_entitate = locauta.id_categorie_entitate
		
			Thisform.ct_opt_categorie.Refresh()
			Thisform.opt_tip_aviz.option1.SetFocus()
		Else
			If Empty(Nvl(poListare.categorie,[]))
				Thisform.ct_opt_categorie.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_categorie.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_client
		Private pnIdPart,pcNumePart
		Store 0 To pnIdPart
		Store "" To pcNumePart
		If cauta_client(@pnIdPart,@pcNumePart)
			poListare.id_client = pnIdPart
			poListare.nume_client = pcNumePart
		
			Thisform.ct_opt_client.Refresh()
			Thisform.ct_opt_agent.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_client,[]))
				Thisform.ct_opt_client.opt_cautare.Value=1
			Endif
			Thisform.ct_opt_client.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_delegat
		Local loCauta
		loCauta=caut_delegati()
		If !Empty(loCauta.id_responsabil)
			poListare.id_delegat = loCauta.id_responsabil
			poListare.nume_delegat = Alltrim(loCauta.nume)
			Thisform.ct_opt_delegat.Refresh()
			Thisform.ct_opt_masina.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_delegat,[]))
				Thisform.ct_opt_delegat.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_delegat.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_masina
		locauta=caut_masina_gs()
		If !Empty(locauta.id_masina)
			poListare.nrinmat = Alltrim(locauta.nrinmat)
			poListare.id_masina = locauta.id_masina
		
			Thisform.ct_opt_masina.Refresh()
			Thisform.ct_opt_categorie.SetFocus()
		Else
			If Empty(Nvl(poListare.nrinmat,[]))
				Thisform.ct_opt_masina.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_masina.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_excel
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
			If Reccount('crsraport')<>0
				If Used('crsexportexcel')
					Use In crsexportexcel
				Endif
				Dimension aColoane[1]
				lcSelect = [SELECT Iif(gid<>0,'TOTAL',Space(5)) As explicatie]
				Afields(aColoane,'crsraport')
				For i = 1 To Alen(aColoane,1)
					If Upper(Alltrim(aColoane[i,1])) <> 'GID'
						lcNumeColoana =  Upper(Alltrim(aColoane[i,1]))
						lcSelect = lcSelect + [,] + Iif(aColoane[i,2] = 'T', [TTOD(] + lcNumeColoana + [) as ] + ;
							lcNumeColoana, lcNumeColoana)
					Endif
				Endfor
				lcSelect = lcSelect + [	From crsraport Into Cursor crsexportexcel]
				&lcSelect
		
				export_xls('crsexportexcel')
				Use In crsexportexcel
			Else
				amessagebox("Nu exista rezultate pentru export in Excel!",0+48,"Atentie")
				thisform.clb_perioada.SetFocus()		
			Endif
		
			Use In crsraport
		Endif
		
	ENDPROC

	PROCEDURE do_listare
		Private pcTitlu
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
		*!*	modificare	v 2.0.46
		*!*		Private pcDataora
		*!*		If Reccount('crsraport')>0
		*!*			lcTitlu = Thisform.ctitluraport
		*!*			pcTitlu = ceretitlu_rap('Titlul Raportului',lcTitlu)
		*!*			pcDataora = get_ora(2)
		
		*!*			Thisform.AlwaysOnTop = .F.
		*!*			Local loExport
		*!*			loExport = Createobject("oExportConfig")
		*!*			loExport.listareUserReport("crsraport","FRX","raport_avize",1,"RAPORT")
		*!*			Release loExport
		*!*	*!*			Keyboard "{ctrl+f10}"
		*!*	*!*			Select crsraport
		*!*	*!*			Report Form raport_avize To Printer Prompt Preview
		*!*			Thisform.AlwaysOnTop = .T.
		*!*		Else
		*!*			amessagebox("Nu exista rezultate pentru listare!",0+48,"Atentie")
		*!*			thisform.clb_perioada.SetFocus()
		*!*		Endif
			Thisform.AlwaysOnTop = .F.
			pcTitlu = Thisform.ctitluraport
			goExport.export2frx("crsraport","raport_avize",.T.,1,"RAPORT")	&&	, , , .T.)
			Thisform.clb_perioada.SetFocus()
			Thisform.AlwaysOnTop = .T.
		*!*	modificare	v 2.0.46	^
			Use In crsraport
		EndIf
		Release pcTitlu
	ENDPROC

	PROCEDURE Clb_perioada.tx_n1.Valid
		*!*
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_date_rapoarte_avize_tr AS _frmbase OF "_frm_base.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="But_salveaza1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport.But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_perioada" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_gestiune_dest" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_masina" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_delegat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_gestiune_sursa" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nract" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_gestiune_dest" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_delegat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nrinmat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_gestiune_sursa" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_dataact" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adauga_filtru
		*m: do_cauta_categorie
		*m: do_cauta_delegat
		*m: do_cauta_gestiune_dest
		*m: do_cauta_gestiune_sursa
		*m: do_cauta_masina
		*p: ctitluraport
	*</DefinedPropArrayMethod>

	*<PropValue>
		ctitluraport = Avize de transfer intre subunitati
		DoCreate = .T.
		Height = 520
		Name = "frm_date_rapoarte_avize_tr"
		Width = 696
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 696
		_shape2.Height = 29
		_shape2.Left = 604
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 90
		Lb_titlu_alb_b121.Caption = "AVIZE DE TRANSFER INTRE SUBUNITATI"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 14
		BUT_TERMIN1.Left = 666
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 13
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Left = 480
		GRIDSORT1.Name = "GRIDSORT1"
		GRIDSORT1.Top = 36
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Left = 605, ;
		Name = "But_excel1", ;
		TabIndex = 15, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Left = 636, ;
		Name = "But_listare1", ;
		TabIndex = 12, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_salveaza1' AS but_salveaza WITH ;
		Left = 528, ;
		Name = "But_salveaza1", ;
		TabIndex = 11, ;
		Top = 0, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_perioada' AS clb_n1n2_simplu WITH ;
		Left = 383, ;
		Name = "Clb_perioada", ;
		TabIndex = 3, ;
		Top = 72, ;
		tx_n1.ControlSource = "poListare.datai", ;
		tx_n1.Left = 127, ;
		tx_n1.Name = "tx_n1", ;
		tx_n1.Top = 2, ;
		Lb_simplu1.Caption = "Data aviz", ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		tx_n2.ControlSource = "poListare.dataf", ;
		tx_n2.Name = "tx_n2"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport' AS ct_clb_cautare WITH ;
		Height = 31, ;
		Left = 23, ;
		Name = "Ct_clb_raport", ;
		TabIndex = 1, ;
		Top = 36, ;
		Visible = .F., ;
		Width = 396, ;
		img_cautare.Height = 25, ;
		img_cautare.Left = 321, ;
		img_cautare.Name = "img_cautare", ;
		img_cautare.Top = 3, ;
		img_cautare.Width = 30, ;
		clb_tx_cautare.Lb_simplu1.Caption = "Raport", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.TabIndex = 1, ;
		clb_tx_cautare.Text_simplu1.Height = 23, ;
		clb_tx_cautare.Text_simplu1.Left = 71, ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1", ;
		clb_tx_cautare.Text_simplu1.Top = 3, ;
		clb_tx_cautare.Text_simplu1.Width = 239
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport.But_sterge1' AS but_sterge WITH ;
		Height = 27, ;
		Left = 361, ;
		Name = "But_sterge1", ;
		TabIndex = 2, ;
		Top = 1, ;
		Width = 30
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ct_opt_delegat' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_delegat, ;
		cvarfiltru = poListare.id_delegat, ;
		cvar_afisata = poListare.nume_delegat, ;
		Left = 383, ;
		Name = "Ct_opt_delegat", ;
		TabIndex = 6, ;
		Top = 240, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Delegat", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_gestiune_dest' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_gestiune_dest, ;
		cvarfiltru = poListare.id_gestiune_dest, ;
		cvar_afisata = poListare.gestiune_dest, ;
		Left = 383, ;
		Name = "Ct_opt_gestiune_dest", ;
		ntip = 2, ;
		TabIndex = 5, ;
		Top = 170, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Gestiune destinatie", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_gestiune_sursa' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_gestiune_sursa, ;
		cvarfiltru = poListare.id_gestiune_sursa, ;
		cvar_afisata = poListare.gestiune_sursa, ;
		Left = 383, ;
		Name = "Ct_opt_gestiune_sursa", ;
		ntip = 2, ;
		TabIndex = 4, ;
		Top = 100, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Gestiune sursa", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_masina' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_masina, ;
		cvarfiltru = poListare.id_masina, ;
		cvar_afisata = poListare.nrinmat, ;
		Left = 383, ;
		Name = "Ct_opt_masina", ;
		TabIndex = 7, ;
		Top = 310, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Masina", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1' AS ct_selectie WITH ;
		ccoloanesuma = avizat, ;
		clistacoloaneordine = 1, ;
		cnumecoloanesuma = Valoare avizata|Valoare facturata, ;
		cnumetabela = fact_vrap_avize_transfer, ;
		Height = 408, ;
		Left = 24, ;
		Name = "Ct_selectie1", ;
		TabIndex = 2, ;
		Top = 72, ;
		Width = 332, ;
		Ct_grupare1.lblAtentie.Name = "lblAtentie", ;
		Ct_grupare1.lb_grupare.Name = "lb_grupare", ;
		Ct_grupare1.Left = 5, ;
		Ct_grupare1.Name = "Ct_grupare1", ;
		Ct_grupare1.TabIndex = 10, ;
		Ct_grupare1.Top = 263, ;
		Ct_grupare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_grupare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_grupare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		Ct_ordonare1.Height = 169, ;
		Ct_ordonare1.lb_ordonare.Name = "lb_ordonare", ;
		Ct_ordonare1.Left = 5, ;
		Ct_ordonare1.Name = "Ct_ordonare1", ;
		Ct_ordonare1.TabIndex = 9, ;
		Ct_ordonare1.Top = 95, ;
		Ct_ordonare1.Width = 320, ;
		Ct_ordonare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_ordonare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_ordonare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		lb_coloane.Name = "lb_coloane", ;
		lb_coloane.TabIndex = 1
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_dataact' AS ct_selectie_camp WITH ;
		ccamp = dataact, ;
		cnumecamp = Data aviz, ;
		Left = 17, ;
		Name = "Ct_selectie_dataact", ;
		nid_container = 2, ;
		TabIndex = 3, ;
		Top = 36, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_gestiune_dest' AS ct_selectie_camp WITH ;
		ccamp = gestiune_dest, ;
		cnumecamp = Gestiune destinatie, ;
		Height = 19, ;
		Left = 17, ;
		Name = "Ct_selectie_gestiune_dest", ;
		nid_container = 5, ;
		TabIndex = 5, ;
		Top = 65, ;
		Width = 163, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_gestiune_sursa' AS ct_selectie_camp WITH ;
		ccamp = gestiune_sursa, ;
		cnumecamp = Gestiune sursa, ;
		Height = 19, ;
		Left = 17, ;
		Name = "Ct_selectie_gestiune_sursa", ;
		nid_container = 4, ;
		TabIndex = 4, ;
		Top = 51, ;
		Width = 139, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nract' AS ct_selectie_camp WITH ;
		ccamp = nract, ;
		cnumecamp = Nr. aviz, ;
		Left = 17, ;
		lgrupare = .F., ;
		Name = "Ct_selectie_nract", ;
		nid_container = 1, ;
		TabIndex = 2, ;
		Top = 22, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nrinmat' AS ct_selectie_camp WITH ;
		ccamp = nrinmat, ;
		cnumecamp = Masina, ;
		Left = 180, ;
		Name = "Ct_selectie_nrinmat", ;
		TabIndex = 7, ;
		Top = 36, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_delegat' AS ct_selectie_camp WITH ;
		ccamp = nume_delegat, ;
		cnumecamp = Delegat, ;
		Left = 180, ;
		Name = "Ct_selectie_nume_delegat", ;
		TabIndex = 6, ;
		Top = 22, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />
	
	PROCEDURE do_adauga_filtru
		Lparameters lcSql
		lcFiltru = [WHERE DATAACT BETWEEN ?poListare.datai AND ?poListare.dataf] + gcCondSucursala
		
		If !Empty(Nvl(poListare.id_gestiune_sursa,0))
			lcFiltru = lcFiltru + [ AND id_gestiune_sursa ] + Iif(thisform.ct_opt_gestiune_sursa.nvaloarecriteriu = 1,[=],[<>]) + [ ?poListare.id_gestiune_sursa]
		Endif
		
		If !Empty(Nvl(poListare.id_gestiune_dest,0))
			lcFiltru = lcFiltru + [ AND id_gestiune_dest ] + Iif(thisform.ct_opt_gestiune_dest.nvaloarecriteriu = 1,[=],[<>]) + [ ?poListare.id_gestiune_dest]
		Endif
		
		If !Empty(Nvl(poListare.id_delegat,0))
			lcFiltru = lcFiltru + [ AND id_delegat = ?poListare.id_delegat]
		Endif
		
		If !Empty(Nvl(poListare.id_masina,0))
			lcFiltru = lcFiltru + [ AND id_masina = ?poListare.id_masina]
		Endif
		
		poListare.csql = Strtran(lcSql,[WHERE 1=2],lcFiltru)
		
	ENDPROC

	PROCEDURE do_cauta
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If Inlist(lccontrol,"TEXTBOX","EDITBOX","COMBOBOX")
			lcval=This.ActiveControl.ControlSource
			&lcval=Thisform.ActiveControl.Value
		Endif
		
		Do Case
		Case Empty(Nvl(poListare.datai,{}))
			amessagebox("Nu ati completat data initiala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n1.SetFocus()
			Return
		Case Empty(Nvl(poListare.dataf,{}))
			amessagebox("Nu ati completat data finala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n2.SetFocus()
			Return
		Case Empty(Nvl(poListare.data_referinta,{}))
			amessagebox("Nu ati completat data de referinta!",0+48,"Atentie")
			Thisform.clb_data_referinta.SetFocus()
			Return
		Otherwise
			With This.ct_selectie1
				.do_instructiune_sql()
				lcSql = .csql
			Endwith
			If Empty(lcSql)
				amessagebox("Nu ati ales coloane pentru selectie!",0+48,"Atentie")
				Thisform.ct_selectie1.SetFocus()
				Return
			Else
				This.do_adauga_filtru(lcSql)
			Endif
		Endcase
		
		lnSucces = goExecutor.oExecute(poListare.csql,'crsraport')
		If lnSucces < 0
			amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
		Endif
	ENDPROC

	PROCEDURE do_cauta_categorie
		locauta=caut_categorie_entitate()
		If !Empty(locauta.id_categorie_entitate)
			poListare.categorie = Alltrim(locauta.categorie_entitate)
			poListare.id_categorie_entitate = locauta.id_categorie_entitate
		
			Thisform.ct_opt_categorie.Refresh()
			Thisform.opt_tip_aviz.option1.SetFocus()
		Else
			If Empty(Nvl(poListare.categorie,[]))
				Thisform.ct_opt_categorie.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_categorie.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_delegat
		Local loCauta
		loCauta=caut_delegati()
		If !Empty(loCauta.id_responsabil)
			poListare.id_delegat = loCauta.id_responsabil
			poListare.nume_delegat = Alltrim(loCauta.nume)
			Thisform.ct_opt_delegat.Refresh()
			Thisform.ct_opt_masina.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_delegat,[]))
				Thisform.ct_opt_delegat.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_delegat.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_gestiune_dest
		loCauta = caut_gestiune()
		
		If !Empty(Nvl(loCauta.id_gestiune,0))
			poListare.id_gestiune_dest = loCauta.id_gestiune
			poListare.gestiune_dest = Alltrim(loCauta.nume_gestiune)
			Thisform.ct_opt_gestiune_dest.Refresh()
			Thisform.ct_opt_delegat.SetFocus()
		Else
			If Empty(Nvl(poListare.id_gestiune_dest,0))
				Thisform.ct_opt_gestiune_dest.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_gestiune_dest.Refresh()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_gestiune_sursa
		loCauta = caut_gestiune()
		
		If !EMPTY(NVL(loCauta.id_gestiune,0))
			poListare.id_gestiune_sursa = loCauta.id_gestiune
			poListare.gestiune_sursa = Alltrim(loCauta.nume_gestiune)
			Thisform.ct_opt_gestiune_sursa.Refresh()
			Thisform.ct_opt_gestiune_dest.SetFocus()
		Else
			If Empty(Nvl(poListare.id_gestiune_sursa,0))
				Thisform.ct_opt_gestiune_sursa.opt_cautare.value = 1
			Endif
			Thisform.ct_opt_gestiune_sursa.Refresh()
		Endif
	ENDPROC

	PROCEDURE do_cauta_masina
		locauta=caut_masina_gs()
		If !Empty(NVL(locauta.id_masina,0))
			poListare.nrinmat = Alltrim(locauta.nrinmat)
			poListare.id_masina = locauta.id_masina
		
			Thisform.ct_opt_masina.Refresh()
			Thisform.ct_opt_categorie.SetFocus()
		Else
			If Empty(Nvl(poListare.nrinmat,[]))
				Thisform.ct_opt_masina.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_masina.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_excel
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
			If Reccount('crsraport')<>0
				If Used('crsexportexcel')
					Use In crsexportexcel
				Endif
				Dimension aColoane[1]
				lcSelect = [SELECT Iif(gid<>0,'TOTAL',Space(5)) As explicatie]
				Afields(aColoane,'crsraport')
				For i = 1 To Alen(aColoane,1)
					If Upper(Alltrim(aColoane[i,1])) <> 'GID'
						lcNumeColoana =  Upper(Alltrim(aColoane[i,1]))
						lcSelect = lcSelect + [,] + Iif(aColoane[i,2] = 'T', [TTOD(] + lcNumeColoana + [) as ] + ;
							lcNumeColoana, lcNumeColoana)
					Endif
				Endfor
				lcSelect = lcSelect + [	From crsraport Into Cursor crsexportexcel]
				&lcSelect
		
				export_xls('crsexportexcel')
				Use In crsexportexcel
			Else
				amessagebox("Nu exista rezultate pentru export in Excel!",0+48,"Atentie")
				thisform.clb_perioada.SetFocus()		
			Endif
		
			Use In crsraport
		Endif
		
	ENDPROC

	PROCEDURE do_listare
		Private pcTitlu
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
		*!*		If Reccount('crsraport')>0
		*!*			Private pcDataora
		*!*			lcTitlu = Thisform.ctitluraport
		*!*			pcTitlu = ceretitlu_rap('Titlul Raportului',lcTitlu)
		*!*			pcDataora = get_ora(2)
		
		*!*			Thisform.AlwaysOnTop = .F.
		*!*			Local loExport
		*!*			loExport = Createobject("oExportConfig")
		*!*			loExport.listareUserReport("crsraport","FRX","raport_avize_transfer",1,"RAPORT")
		*!*			Release loExport
		*!*	*!*			Keyboard "{ctrl+f10}"
		*!*	*!*			Select crsraport
		*!*	*!*			Report Form raport_avize_transfer To Printer Prompt Preview
		*!*			Thisform.AlwaysOnTop = .T.
		*!*		Else
		*!*			amessagebox("Nu exista rezultate pentru listare!",0+48,"Atentie")
		*!*			Thisform.clb_perioada.SetFocus()
		*!*		Endif
			pcTitlu = Thisform.ctitluraport
			Thisform.AlwaysOnTop = .F.
			goExport.export2frx("crsraport","raport_avize_transfer",.T.,1,"RAPORT")	&&	, , , .T.)
			Thisform.clb_perioada.SetFocus()
			Thisform.AlwaysOnTop = .T.
			Use In crsraport
		EndIf
		Release pcTitlu
	ENDPROC

	PROCEDURE Clb_perioada.tx_n1.Valid
		*!*
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_date_rapoarte_facturi AS _frmbase OF "_frm_base.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="But_salveaza1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport.But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_perioada" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_agent" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_masina" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_delegat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nract" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_datascad" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_agent" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_delegat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nrinmat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_dataact" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_categorie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_utilizator" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_tip_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_cod_fiscal_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_tip_facturi" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_categorie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_utilizatori" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adauga_filtru
		*m: do_cauta_agent
		*m: do_cauta_categorie
		*m: do_cauta_client
		*m: do_cauta_delegat
		*m: do_cauta_masina
		*m: do_cauta_utilizator
		*p: ctitluraport
	*</DefinedPropArrayMethod>

	*<PropValue>
		ctitluraport = 
		DoCreate = .T.
		Height = 532
		Name = "frm_date_rapoarte_facturi"
		Width = 696
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 696
		_shape2.Height = 29
		_shape2.Left = 604
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 90
		Lb_titlu_alb_b121.Caption = "FACTURI"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 14
		BUT_TERMIN1.Left = 666
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 13
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Left = 480
		GRIDSORT1.Name = "GRIDSORT1"
		GRIDSORT1.Top = 36
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Left = 605, ;
		Name = "But_excel1", ;
		TabIndex = 15, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Left = 636, ;
		Name = "But_listare1", ;
		TabIndex = 12, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_salveaza1' AS but_salveaza WITH ;
		Left = 528, ;
		Name = "But_salveaza1", ;
		TabIndex = 11, ;
		Top = 0, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_perioada' AS clb_n1n2_simplu WITH ;
		Left = 383, ;
		Name = "Clb_perioada", ;
		TabIndex = 4, ;
		Top = 72, ;
		tx_n1.ControlSource = "poListare.datai", ;
		tx_n1.Left = 127, ;
		tx_n1.Name = "tx_n1", ;
		tx_n1.Top = 2, ;
		Lb_simplu1.Caption = "Data factura", ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		tx_n2.ControlSource = "poListare.dataf", ;
		tx_n2.Name = "tx_n2"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport' AS ct_clb_cautare WITH ;
		Height = 31, ;
		Left = 9, ;
		Name = "Ct_clb_raport", ;
		TabIndex = 1, ;
		Top = 36, ;
		Visible = .F., ;
		Width = 396, ;
		img_cautare.Height = 25, ;
		img_cautare.Left = 321, ;
		img_cautare.Name = "img_cautare", ;
		img_cautare.Top = 3, ;
		img_cautare.Width = 30, ;
		clb_tx_cautare.Lb_simplu1.Caption = "Raport", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.TabIndex = 1, ;
		clb_tx_cautare.Text_simplu1.Height = 23, ;
		clb_tx_cautare.Text_simplu1.Left = 71, ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1", ;
		clb_tx_cautare.Text_simplu1.Top = 3, ;
		clb_tx_cautare.Text_simplu1.Width = 239
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport.But_sterge1' AS but_sterge WITH ;
		Height = 27, ;
		Left = 361, ;
		Name = "But_sterge1", ;
		TabIndex = 2, ;
		Top = 1, ;
		Width = 30
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ct_opt_agent' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_agent, ;
		cvarfiltru = poListare.id_agent, ;
		cvar_afisata = poListare.nume_agent, ;
		Left = 383, ;
		Name = "Ct_opt_agent", ;
		TabIndex = 6, ;
		Top = 170, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Agent", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_categorie' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_categorie, ;
		cvarfiltru = poListare.id_categorie_entitate, ;
		cvar_afisata = poListare.categorie, ;
		Left = 383, ;
		Name = "Ct_opt_categorie", ;
		TabIndex = 9, ;
		Top = 380, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Categorie entitate", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_client' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_client, ;
		cvarfiltru = poListare.id_client, ;
		cvar_afisata = poListare.nume_client, ;
		Left = 383, ;
		Name = "Ct_opt_client", ;
		TabIndex = 5, ;
		Top = 100, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Client", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_delegat' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_delegat, ;
		cvarfiltru = poListare.id_delegat, ;
		cvar_afisata = poListare.nume_delegat, ;
		Left = 383, ;
		Name = "Ct_opt_delegat", ;
		TabIndex = 7, ;
		Top = 240, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Delegat", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_masina' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_masina, ;
		cvarfiltru = poListare.id_masina, ;
		cvar_afisata = poListare.nrinmat, ;
		Left = 383, ;
		Name = "Ct_opt_masina", ;
		TabIndex = 8, ;
		Top = 310, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Masina", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_utilizatori' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_utilizator, ;
		cvarfiltru = poListare.id_util, ;
		cvar_afisata = poListare.utilizator, ;
		Left = 383, ;
		Name = "Ct_opt_utilizatori", ;
		TabIndex = 10, ;
		Top = 450, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		LB_EXPLICATIE.Caption = "Utilizator", ;
		LB_EXPLICATIE.Name = "LB_EXPLICATIE", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1' AS ct_selectie WITH ;
		ccoloanesuma = facturat|incasat, ;
		clistacoloaneordine = 1, ;
		cnumecoloanesuma = Valoare facturata|Valoare incasata, ;
		cnumetabela = fact_vrap_fact_incasari, ;
		Height = 444, ;
		Left = 24, ;
		Name = "Ct_selectie1", ;
		TabIndex = 2, ;
		Top = 72, ;
		Width = 332, ;
		Ct_grupare1.Height = 147, ;
		Ct_grupare1.lblAtentie.Name = "lblAtentie", ;
		Ct_grupare1.lb_grupare.Name = "lb_grupare", ;
		Ct_grupare1.Left = 5, ;
		Ct_grupare1.Name = "Ct_grupare1", ;
		Ct_grupare1.TabIndex = 11, ;
		Ct_grupare1.Top = 292, ;
		Ct_grupare1.Width = 320, ;
		Ct_grupare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_grupare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_grupare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		Ct_ordonare1.Height = 190, ;
		Ct_ordonare1.lb_ordonare.Name = "lb_ordonare", ;
		Ct_ordonare1.Left = 5, ;
		Ct_ordonare1.Name = "Ct_ordonare1", ;
		Ct_ordonare1.TabIndex = 10, ;
		Ct_ordonare1.Top = 103, ;
		Ct_ordonare1.Width = 320, ;
		Ct_ordonare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_ordonare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_ordonare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		lb_coloane.Name = "lb_coloane", ;
		lb_coloane.TabIndex = 1
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_categorie' AS ct_selectie_camp WITH ;
		ccamp = categorie_entitate, ;
		cnumecamp = Categorie, ;
		Left = 180, ;
		Name = "Ct_selectie_categorie", ;
		TabIndex = 9, ;
		Top = 71, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_cod_fiscal_client' AS ct_selectie_camp WITH ;
		ccamp = cod_fiscal_client, ;
		cnumecamp = Cod fiscal client, ;
		Height = 19, ;
		Left = 180, ;
		Name = "Ct_selectie_cod_fiscal_client", ;
		nid_container = 5, ;
		TabIndex = 5, ;
		Top = 14, ;
		Width = 143, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_dataact' AS ct_selectie_camp WITH ;
		ccamp = dataact, ;
		cnumecamp = Data factura, ;
		Height = 19, ;
		Left = 17, ;
		Name = "Ct_selectie_dataact", ;
		nid_container = 2, ;
		TabIndex = 3, ;
		Top = 40, ;
		Width = 143, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_datascad' AS ct_selectie_camp WITH ;
		ccamp = datascad, ;
		cnumecamp = Data scadenta, ;
		Height = 19, ;
		Left = 17, ;
		Name = "Ct_selectie_datascad", ;
		nid_container = 3, ;
		TabIndex = 4, ;
		Top = 55, ;
		Width = 143, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nract' AS ct_selectie_camp WITH ;
		ccamp = nract, ;
		cnumecamp = Nr. factura, ;
		Height = 19, ;
		Left = 17, ;
		lgrupare = .F., ;
		Name = "Ct_selectie_nract", ;
		nid_container = 1, ;
		TabIndex = 2, ;
		Top = 26, ;
		Width = 143, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nrinmat' AS ct_selectie_camp WITH ;
		ccamp = nrinmat, ;
		cnumecamp = Masina, ;
		Left = 180, ;
		Name = "Ct_selectie_nrinmat", ;
		TabIndex = 8, ;
		Top = 56, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_agent' AS ct_selectie_camp WITH ;
		ccamp = nume_agent, ;
		cnumecamp = Agent, ;
		Left = 180, ;
		Name = "Ct_selectie_nume_agent", ;
		nid_container = 6, ;
		TabIndex = 6, ;
		Top = 28, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_client' AS ct_selectie_camp WITH ;
		ccamp = nume_client, ;
		cnumecamp = Client, ;
		Height = 19, ;
		Left = 17, ;
		Name = "Ct_selectie_nume_client", ;
		nid_container = 4, ;
		TabIndex = 5, ;
		Top = 69, ;
		Width = 143, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_delegat' AS ct_selectie_camp WITH ;
		ccamp = nume_delegat, ;
		cnumecamp = Delegat, ;
		Left = 180, ;
		Name = "Ct_selectie_nume_delegat", ;
		TabIndex = 7, ;
		Top = 42, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_tip_client' AS ct_selectie_camp WITH ;
		ccamp = ctip_client, ;
		cnumecamp = Tip client (PJ/PF), ;
		Height = 19, ;
		Left = 17, ;
		Name = "Ct_selectie_tip_client", ;
		nid_container = 5, ;
		TabIndex = 5, ;
		Top = 84, ;
		Width = 143, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_utilizator' AS ct_selectie_camp WITH ;
		ccamp = utilizator, ;
		cnumecamp = Utilizator, ;
		Left = 180, ;
		Name = "Ct_selectie_utilizator", ;
		TabIndex = 9, ;
		Top = 85, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'opt_tip_facturi' AS _optiongrup WITH ;
		ButtonCount = 3, ;
		Height = 27, ;
		Left = 383, ;
		Name = "opt_tip_facturi", ;
		TabIndex = 3, ;
		Top = 47, ;
		Value = 2, ;
		Width = 301, ;
		OPTION1.AutoSize = .T., ;
		OPTION1.Caption = "Toate", ;
		OPTION1.Left = 5, ;
		OPTION1.Name = "OPTION1", ;
		OPTION1.Top = 5, ;
		OPTION1.Value = 0, ;
		OPTION2.AutoSize = .T., ;
		OPTION2.Caption = "Facturi neincasate", ;
		OPTION2.Left = 62, ;
		OPTION2.Name = "OPTION2", ;
		OPTION2.Top = 5, ;
		OPTION2.Value = 1, ;
		Option3.AutoSize = .T., ;
		Option3.BackStyle = 0, ;
		Option3.Caption = "Facturi incasate", ;
		Option3.Height = 17, ;
		Option3.Left = 191, ;
		Option3.Name = "Option3", ;
		Option3.Top = 5, ;
		Option3.Width = 105
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />
	
	PROCEDURE do_adauga_filtru
		Lparameters lcSql
		lcFiltru = [WHERE DATAACT BETWEEN ?poListare.datai AND ?poListare.dataf] + gcCondSucursala
		
		If !Empty(Nvl(poListare.id_client,0))
			lcFiltru = lcFiltru + [ AND id_part = ?poListare.id_client]
		Endif
		
		If !Empty(Nvl(poListare.id_agent,0))
			lcFiltru = lcFiltru + [ AND id_agent = ?poListare.id_agent]
		Endif
		
		If !Empty(Nvl(poListare.id_delegat,0))
			lcFiltru = lcFiltru + [ AND id_delegat = ?poListare.id_delegat]
		Endif
		
		If !Empty(Nvl(poListare.id_masina,0))
			lcFiltru = lcFiltru + [ AND id_masina = ?poListare.id_masina]
		Endif
		
		If !Empty(Nvl(poListare.id_categorie_entitate,0))
			lcFiltru = lcFiltru + [ AND id_categorie_entitate = ?poListare.id_categorie_entitate]
		Endif
		
		If !Empty(Nvl(poListare.id_util,0))
			lcFiltru = lcFiltru + [ AND id_util = ?poListare.id_util]
		Endif
		
		lnTipFactura = This.opt_tip_facturi.Value
		This.ctitluraport = [FACTURI]
		Do Case
		Case lnTipFactura = 2
			This.ctitluraport = [FACTURI NEINCASATE]
			lcFiltru = lcFiltru + [ AND facturat <> incasat ]
		Case lnTipFactura = 3
			This.ctitluraport = [FACTURI INCASATE]
			lcFiltru = lcFiltru + [ AND facturat = incasat ]
		Endcase
		*!*	If !Empty(Nvl(poListare.nume_client,[]))
		*!*		lcFiltru = lcFiltru + [ AND nume_client = ?poListare.nume_client]
		*!*	Endif
		
		*!*	If !Empty(Nvl(poListare.nume_agent,[]))
		*!*		lcFiltru = lcFiltru + [ AND nume_agent = ?poListare.nume_agent]
		*!*	Endif
		
		*!*	If !Empty(Nvl(poListare.nume_delegat,[]))
		*!*		lcFiltru = lcFiltru + [ AND nume_delegat = ?poListare.nume_delegat]
		*!*	Endif
		
		*!*	If !Empty(Nvl(poListare.nrinmat,[]))
		*!*		lcFiltru = lcFiltru + [ AND nrinmat = ?poListare.nrinmat]
		*!*	Endif
		poListare.csql = Strtran(lcSql,[WHERE 1=2],lcFiltru)
		
	ENDPROC

	PROCEDURE do_cauta
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If Inlist(lccontrol,"TEXTBOX","EDITBOX","COMBOBOX")
			lcval=This.ActiveControl.ControlSource
			&lcval=Thisform.ActiveControl.Value
		Endif
		
		Do Case
		Case Empty(Nvl(poListare.datai,{}))
			amessagebox("Nu ati completat data initiala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n1.SetFocus()
			Return
		Case Empty(Nvl(poListare.dataf,{}))
			amessagebox("Nu ati completat data finala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n2.SetFocus()
			Return
		Case Empty(Nvl(poListare.data_referinta,{}))
			amessagebox("Nu ati completat data de referinta!",0+48,"Atentie")
			Thisform.clb_data_referinta.SetFocus()
			Return
		Otherwise
			With This.ct_selectie1
				.do_instructiune_sql()
				lcSql = .csql
			Endwith
			If Empty(lcSql)
				amessagebox("Nu ati ales coloane pentru selectie!",0+48,"Atentie")
				Thisform.ct_selectie1.SetFocus()
				Return
			Else
				This.do_adauga_filtru(lcSql)
			Endif
		Endcase
		
		lnSucces = goExecutor.oExecute(poListare.csql,'crsraport')
		If lnSucces < 0
			amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
		Endif
	ENDPROC

	PROCEDURE do_cauta_agent
		Private pnIdPart,pcNumePart
		lcTitlu=[ALEGETI AGENTUL]
		pnIdPart=0
		pcNumePart=[]
		
		If caut_partener_dupa_tip(gnIdTipAgenti,lcTitlu,@pnIdPart,@pcNumePart)
			poListare.id_agent = pnIdPart
			poListare.nume_agent = Alltrim(pcNumePart)
			Thisform.ct_opt_agent.Refresh()
			Thisform.ct_opt_delegat.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_agent,[]))
				Thisform.ct_opt_agent.opt_cautare.Value=1
			Endif
			Thisform.ct_opt_agent.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_categorie
		locauta=caut_categorie_entitate()
		If !Empty(locauta.id_categorie_entitate)
			poListare.categorie = Alltrim(locauta.categorie_entitate)
			poListare.id_categorie_entitate = locauta.id_categorie_entitate
		
			Thisform.ct_opt_categorie.Refresh()
			Thisform.ct_opt_utilizatori.SetFocus()
		Else
			If Empty(Nvl(poListare.categorie,[]))
				Thisform.ct_opt_categorie.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_categorie.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_client
		Private pnIdPart,pcNumePart
		Store 0 To pnIdPart
		Store "" To pcNumePart
		If cauta_client(@pnIdPart,@pcNumePart)
			poListare.id_client = pnIdPart
			poListare.nume_client = pcNumePart
		
			Thisform.ct_opt_client.Refresh()
			Thisform.ct_opt_agent.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_client,[]))
				Thisform.ct_opt_client.opt_cautare.Value=1
			Endif
			Thisform.ct_opt_client.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_delegat
		Local loCauta
		loCauta=caut_delegati()
		If !Empty(loCauta.id_responsabil)
			poListare.id_delegat = loCauta.id_responsabil
			poListare.nume_delegat = Alltrim(loCauta.nume)
			Thisform.ct_opt_delegat.Refresh()
			Thisform.ct_opt_masina.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_delegat,[]))
				Thisform.ct_opt_delegat.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_delegat.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_masina
		locauta=caut_masina_gs()
		If !Empty(locauta.id_masina)
			poListare.nrinmat = Alltrim(locauta.nrinmat)
			poListare.id_masina = locauta.id_masina
		
			Thisform.ct_opt_masina.Refresh()
			thisform.ct_opt_categorie.SetFocus()
		Else
			If Empty(Nvl(poListare.nrinmat,[]))
				Thisform.ct_opt_masina.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_masina.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_utilizator
		Local loCauta
		loCauta = caut_utilizator_facturare()
		If !Empty(loCauta.id_util)
			poListare.id_util = loCauta.id_util
			poListare.utilizator = Alltrim(loCauta.utilizator)
			Thisform.ct_opt_utilizatori.Refresh()
			Thisform.but_listare1.SetFocus()
		Else
			If Empty(Nvl(poListare.utilizator,[]))
				Thisform.ct_opt_utilizatori.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_utilizatori.SetFocus()
		Endif
	ENDPROC

	PROCEDURE do_excel
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
			If Reccount('crsraport')<>0
				If Used('crsexportexcel')
					Use In crsexportexcel
				Endif
				Dimension aColoane[1]
				lcSelect = [SELECT Iif(gid<>0,'TOTAL',Space(5)) As explicatie]
				Afields(aColoane,'crsraport')
				For i = 1 To Alen(aColoane,1)
					If Upper(Alltrim(aColoane[i,1])) <> 'GID'
						lcNumeColoana =  Upper(Alltrim(aColoane[i,1]))
						lcSelect = lcSelect + [,] + Iif(aColoane[i,2] = 'T', [TTOD(] + lcNumeColoana + [) as ] + ;
							lcNumeColoana, lcNumeColoana)
					Endif
				Endfor
				lcSelect = lcSelect + [	From crsraport Into Cursor crsexportexcel]
				&lcSelect
		
				export_xls('crsexportexcel')
				Use In crsexportexcel
			Else
				amessagebox("Nu exista rezultate pentru export in Excel!",0+48,"Atentie")
				thisform.clb_perioada.SetFocus()		
			Endif
		
			Use In crsraport
		Endif
		
	ENDPROC

	PROCEDURE do_listare
		Private pcTitlu
		If Used('crsraport')
			Use In crsraport
		Endif
		
		This.do_cauta()
		If Used('crsraport')
		*!*	modificare	v 2.0.46
		*!*		If Reccount('crsraport')>0
		*!*			lcTitlu = Thisform.ctitluraport
		*!*			pcTitlu = ceretitlu_rap('Titlul Raportului',lcTitlu)
		*!*			pcDataora = get_ora(2)
		
		*!*			Thisform.AlwaysOnTop = .F.
		*!*			Local loExport
		*!*			loExport = Createobject("oExportConfig")
		*!*			loExport.listareUserReport("crsraport","FRX","raport_facturat",1,"RAPORT")
		*!*			Release loExport
		*!*	*!*			Keyboard "{ctrl+f10}"
		*!*	*!*			Select crsraport
		*!*	*!*			Report Form raport_facturat To Printer Prompt Preview
		*!*			Thisform.AlwaysOnTop = .T.
		*!*		Else
		*!*			amessagebox("Nu exista rezultate pentru listare!",0+48,"Atentie")
		*!*			thisform.clb_perioada.SetFocus()
		*!*		Endif
			Thisform.AlwaysOnTop = .F.
			pcTitlu = Thisform.ctitluraport
			goExport.export2frx("crsraport","raport_facturat",.T.,1,"RAPORT")	&&	, , , .T.)
			Thisform.clb_perioada.SetFocus()
			Thisform.AlwaysOnTop = .T.
		*!*	modificare	v 2.0.46	^
			Use In crsraport
		EndIf
		Release pcTitlu
	ENDPROC

	PROCEDURE Clb_perioada.tx_n1.Valid
		*!*
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_date_rapoarte_incasari AS _frmbase OF "_frm_base.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="But_salveaza1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_raport.But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_perioada" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_agent" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nrincas" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_tip_cont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_agent" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nrfact" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_datafact" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_nume_client" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_dataincas" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_facturat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_selectie1.Ct_selectie_categorie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_tip_cont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_tip_cont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_opt_categorie" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adauga_filtru
		*m: do_cauta_agent
		*m: do_cauta_categorie
		*m: do_cauta_client
		*m: do_raport_comision_incasari_agenti
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 492
		Name = "frm_date_rapoarte_incasari"
		Width = 696
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 696
		_shape2.Height = 29
		_shape2.Left = 600
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 97
		Lb_titlu_alb_b121.Caption = "INCASARI"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 12
		BUT_TERMIN1.Left = 665
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 10
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Left = 480
		GRIDSORT1.Name = "GRIDSORT1"
		GRIDSORT1.Top = 36
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Left = 602, ;
		Name = "But_excel1", ;
		TabIndex = 8, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Left = 634, ;
		Name = "But_listare1", ;
		TabIndex = 9, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_salveaza1' AS but_salveaza WITH ;
		Left = 540, ;
		Name = "But_salveaza1", ;
		TabIndex = 11, ;
		Top = 0, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_perioada' AS clb_n1n2_simplu WITH ;
		Left = 383, ;
		Name = "Clb_perioada", ;
		TabIndex = 3, ;
		Top = 72, ;
		tx_n1.ControlSource = "poListare.datai", ;
		tx_n1.Left = 127, ;
		tx_n1.Name = "tx_n1", ;
		tx_n1.Top = 2, ;
		Lb_simplu1.Caption = "Data incasare", ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		tx_n2.ControlSource = "poListare.dataf", ;
		tx_n2.Name = "tx_n2"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport' AS ct_clb_cautare WITH ;
		Height = 31, ;
		Left = 23, ;
		Name = "Ct_clb_raport", ;
		TabIndex = 1, ;
		Top = 36, ;
		Visible = .F., ;
		Width = 396, ;
		img_cautare.Height = 25, ;
		img_cautare.Left = 321, ;
		img_cautare.Name = "img_cautare", ;
		img_cautare.Top = 3, ;
		img_cautare.Width = 30, ;
		clb_tx_cautare.Lb_simplu1.Caption = "Raport", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.TabIndex = 1, ;
		clb_tx_cautare.Text_simplu1.Height = 23, ;
		clb_tx_cautare.Text_simplu1.Left = 71, ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1", ;
		clb_tx_cautare.Text_simplu1.Top = 3, ;
		clb_tx_cautare.Text_simplu1.Width = 239
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_raport.But_sterge1' AS but_sterge WITH ;
		Height = 27, ;
		Left = 361, ;
		Name = "But_sterge1", ;
		TabIndex = 2, ;
		Top = 1, ;
		Width = 30
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ct_opt_agent' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_agent, ;
		cvarfiltru = poListare.id_agent, ;
		cvar_afisata = poListare.nume_agent, ;
		Left = 383, ;
		Name = "Ct_opt_agent", ;
		TabIndex = 5, ;
		Top = 170, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Agent", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_categorie' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_categorie, ;
		cvarfiltru = poListare.id_categorie_entitate, ;
		cvar_afisata = poListare.categorie, ;
		Left = 383, ;
		Name = "Ct_opt_categorie", ;
		TabIndex = 6, ;
		Top = 240, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Categorie entitate", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_opt_client' AS ct_opt_cautare WITH ;
		cprocedura = thisform.do_cauta_client, ;
		cvarfiltru = poListare.id_client, ;
		cvar_afisata = poListare.nume_client, ;
		Left = 383, ;
		Name = "Ct_opt_client", ;
		TabIndex = 4, ;
		Top = 100, ;
		opt_cautare.Name = "opt_cautare", ;
		opt_cautare.OPTION1.Left = 5, ;
		opt_cautare.OPTION1.Name = "OPTION1", ;
		opt_cautare.OPTION1.Top = 5, ;
		opt_cautare.OPTION2.Left = 5, ;
		opt_cautare.OPTION2.Name = "OPTION2", ;
		opt_cautare.OPTION2.Top = 24, ;
		tx_cautare.Name = "tx_cautare", ;
		lb_explicatie.Caption = "Client", ;
		lb_explicatie.Name = "lb_explicatie", ;
		criteriu.Name = "criteriu"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1' AS ct_selectie WITH ;
		ccoloanesuma = incasat, ;
		clistacoloaneordine = 1, ;
		cnumecoloanesuma = Valoare incasata, ;
		cnumetabela = fact_vrap_incasari_fact, ;
		Height = 408, ;
		Left = 24, ;
		Name = "Ct_selectie1", ;
		TabIndex = 2, ;
		Top = 72, ;
		Width = 332, ;
		Ct_grupare1.Height = 125, ;
		Ct_grupare1.lblAtentie.Name = "lblAtentie", ;
		Ct_grupare1.lb_grupare.Name = "lb_grupare", ;
		Ct_grupare1.Left = 5, ;
		Ct_grupare1.Name = "Ct_grupare1", ;
		Ct_grupare1.TabIndex = 12, ;
		Ct_grupare1.Top = 275, ;
		Ct_grupare1.Width = 320, ;
		Ct_grupare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_grupare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_grupare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		Ct_ordonare1.Height = 179, ;
		Ct_ordonare1.lb_ordonare.Name = "lb_ordonare", ;
		Ct_ordonare1.Left = 5, ;
		Ct_ordonare1.Name = "Ct_ordonare1", ;
		Ct_ordonare1.TabIndex = 11, ;
		Ct_ordonare1.Top = 97, ;
		Ct_ordonare1.Width = 320, ;
		Ct_ordonare1._scrollcontainer1.But_jos1.Name = "But_jos1", ;
		Ct_ordonare1._scrollcontainer1.But_sus1.Name = "But_sus1", ;
		Ct_ordonare1._scrollcontainer1.Name = "_scrollcontainer1", ;
		lb_coloane.Left = 10, ;
		lb_coloane.Name = "lb_coloane", ;
		lb_coloane.TabIndex = 1, ;
		lb_coloane.Top = 4
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_categorie' AS ct_selectie_camp WITH ;
		ccamp = categorie_entitate, ;
		cnumecamp = Categorie, ;
		Left = 180, ;
		Name = "Ct_selectie_categorie", ;
		TabIndex = 7, ;
		Top = 20, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_datafact' AS ct_selectie_camp WITH ;
		ccamp = datafact, ;
		cnumecamp = Data factura, ;
		Left = 180, ;
		Name = "Ct_selectie_datafact", ;
		TabIndex = 9, ;
		Top = 49, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_dataincas' AS ct_selectie_camp WITH ;
		ccamp = dataincas, ;
		cnumecamp = Data incasare, ;
		Left = 17, ;
		Name = "Ct_selectie_dataincas", ;
		nid_container = 2, ;
		TabIndex = 3, ;
		Top = 34, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_facturat' AS ct_selectie_camp WITH ;
		ccamp = facturat, ;
		cnumecamp = Facturat, ;
		Left = 180, ;
		lgrupare = .F., ;
		lordine = .F., ;
		Name = "Ct_selectie_facturat", ;
		TabIndex = 10, ;
		Top = 64, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nrfact' AS ct_selectie_camp WITH ;
		ccamp = nrfact, ;
		cnumecamp = Nr. factura, ;
		Left = 180, ;
		lgrupare = .F., ;
		Name = "Ct_selectie_nrfact", ;
		TabIndex = 8, ;
		Top = 34, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nrincas' AS ct_selectie_camp WITH ;
		ccamp = nrincas, ;
		cnumecamp = Nr. incasare, ;
		Left = 17, ;
		lgrupare = .F., ;
		Name = "Ct_selectie_nrincas", ;
		nid_container = 1, ;
		TabIndex = 2, ;
		Top = 20, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_agent' AS ct_selectie_camp WITH ;
		ccamp = nume_agent, ;
		cnumecamp = Agent, ;
		Left = 17, ;
		Name = "Ct_selectie_nume_agent", ;
		nid_container = 5, ;
		TabIndex = 6, ;
		Top = 80, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_nume_client' AS ct_selectie_camp WITH ;
		ccamp = nume_client, ;
		cnumecamp = Client, ;
		Left = 17, ;
		Name = "Ct_selectie_nume_client", ;
		nid_container = 4, ;
		TabIndex = 5, ;
		Top = 64, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_selectie1.Ct_selectie_tip_cont' AS ct_selectie_camp WITH ;
		ccamp = tip_cont, ;
		cnumecamp = Tip cont, ;
		Left = 17, ;
		Name = "Ct_selectie_tip_cont", ;
		nid_container = 3, ;
		TabIndex = 4, ;
		Top = 49, ;
		ck_camp.Alignment = 0, ;
		ck_camp.Name = "ck_camp"
		*< END OBJECT: ClassLib="orapoarte.vcx" BaseClass="container" />

	ADD OBJECT 'lb_tip_cont' AS lb_simplu WITH ;
		Caption = "Tip cont", ;
		Left = 384, ;
		Name = "lb_tip_cont", ;
		TabIndex = 13, ;
		Top = 318
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'opt_tip_cont' AS _optiongrup WITH ;
		ButtonCount = 4, ;
		Height = 27, ;
		Left = 384, ;
		Name = "opt_tip_cont", ;
		TabIndex = 7, ;
		Top = 338, ;
		Width = 289, ;
		OPTION1.AutoSize = .T., ;
		OPTION1.Caption = "Toate", ;
		OPTION1.Left = 5, ;
		OPTION1.Name = "OPTION1", ;
		OPTION1.Top = 5, ;
		OPTION2.AutoSize = .T., ;
		OPTION2.Caption = "Casa", ;
		OPTION2.Left = 83, ;
		OPTION2.Name = "OPTION2", ;
		OPTION2.Top = 5, ;
		Option3.AutoSize = .T., ;
		Option3.BackStyle = 0, ;
		Option3.Caption = "Banca", ;
		Option3.Height = 17, ;
		Option3.Left = 153, ;
		Option3.Name = "Option3", ;
		Option3.Top = 5, ;
		Option3.Width = 53, ;
		Option4.AutoSize = .T., ;
		Option4.BackStyle = 0, ;
		Option4.Caption = "Alt tip", ;
		Option4.Height = 17, ;
		Option4.Left = 237, ;
		Option4.Name = "Option4", ;
		Option4.Top = 5, ;
		Option4.Width = 47
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />
	
	PROCEDURE do_adauga_filtru
		Lparameters lcSql
		lnValoare = This.opt_tip_cont.Value
		lcFiltru = [WHERE DATAINCAS BETWEEN ?poListare.datai AND ?poListare.dataf] + gcCondSucursala
		If !Empty(Nvl(poListare.id_client,0))
			lcFiltru = lcFiltru + [ AND id_part = ?poListare.id_client]
		Endif
		
		If !Empty(Nvl(poListare.nume_agent,[]))
			lcFiltru = lcFiltru + [ AND id_agent = ?poListare.id_agent]
		Endif
		
		If !Empty(Nvl(poListare.id_categorie_entitate,0))
			lcFiltru = lcFiltru + [ AND id_categorie_entitate = ?poListare.id_categorie_entitate]
		Endif
		*!*	If !Empty(Nvl(poListare.nume_client,[]))
		*!*		lcFiltru = lcFiltru + [ AND nume_client = ?poListare.nume_client]
		*!*	Endif
		
		*!*	If !Empty(Nvl(poListare.nume_agent,[]))
		*!*		lcFiltru = lcFiltru + [ AND nume_agent = ?poListare.nume_agent]
		*!*	Endif
		
		Do Case
		Case lnValoare = 2
			lcFiltru = lcFiltru + [ AND tip_cont = 'CASA']
		Case lnValoare = 3
			lcFiltru = lcFiltru + [ AND tip_cont = 'BANCA']
		Case lnValoare = 4
			lcFiltru = lcFiltru + [ AND tip_cont = 'ALT TIP']
		Endcase
		
		poListare.csql = Strtran(lcSql,[WHERE 1=2],lcFiltru)
		
	ENDPROC

	PROCEDURE do_cauta
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If Inlist(lccontrol,"TEXTBOX","EDITBOX","COMBOBOX")
			lcval=This.ActiveControl.ControlSource
			&lcval=Thisform.ActiveControl.Value
		Endif
		
		Do Case
		Case Empty(Nvl(poListare.datai,{}))
			amessagebox("Nu ati completat data initiala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n1.SetFocus()
			Return
		Case Empty(Nvl(poListare.dataf,{}))
			amessagebox("Nu ati completat data finala!",0+48,"Atentie")
			Thisform.clb_perioada.tx_n2.SetFocus()
			Return
		Case Empty(Nvl(poListare.data_referinta,{}))
			amessagebox("Nu ati completat data de referinta!",0+48,"Atentie")
			Thisform.clb_data_referinta.SetFocus()
			Return
		Otherwise
			With This.ct_selectie1
				.do_instructiune_sql()
				lcSql = .csql
			Endwith
			If Empty(lcSql)
				amessagebox("Nu ati ales coloane pentru selectie!",0+48,"Atentie")
				Thisform.ct_selectie1.SetFocus()
				Return
			Else
				This.do_adauga_filtru(lcSql)
			Endif
		Endcase
		
		lnSucces = goExecutor.oExecute(poListare.csql,'crsraport')
		If lnSucces < 0
			amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
		ENDIF
		RETURN (m.lnSucces > 0)
	ENDPROC

	PROCEDURE do_cauta_agent
		Private pnIdPart,pcNumePart
		lcTitlu=[ALEGETI AGENTUL]
		pnIdPart=0
		pcNumePart=[]
		
		If caut_partener_dupa_tip(gnIdTipAgenti,lcTitlu,@pnIdPart,@pcNumePart)
			poListare.id_agent = pnIdPart
			poListare.nume_agent = Alltrim(pcNumePart)
			Thisform.ct_opt_agent.Refresh()
			Thisform.ct_opt_categorie.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_agent,[]))
				Thisform.ct_opt_agent.opt_cautare.Value=1
			Endif
			Thisform.ct_opt_agent.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_categorie
		locauta=caut_categorie_entitate()
		If !Empty(locauta.id_categorie_entitate)
			poListare.categorie = Alltrim(locauta.categorie_entitate)
			poListare.id_categorie_entitate = locauta.id_categorie_entitate
		
			Thisform.ct_opt_categorie.Refresh()
			Thisform.opt_tip_cont.option1.SetFocus()
		Else
			If Empty(Nvl(poListare.categorie,[]))
				Thisform.ct_opt_categorie.opt_cautare.Value = 1
			Endif
			Thisform.ct_opt_categorie.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_client
		Private pnIdPart,pcNumePart
		Store 0 To pnIdPart
		Store "" To pcNumePart
		If cauta_client(@pnIdPart,@pcNumePart)
			poListare.id_client = pnIdPart
			poListare.nume_client = pcNumePart
		
			Thisform.ct_opt_client.Refresh()
			Thisform.ct_opt_agent.SetFocus()
		Else
			If Empty(Nvl(poListare.nume_client,[]))
				Thisform.ct_opt_client.opt_cautare.Value=1
			Endif
			Thisform.ct_opt_client.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_excel
		Local lcCursor, lcNumeColoana, lcRaport, lcSelect, lnOptiune, i
		*:Global aColoane[1]
		lnOptiune = xmenu('\<Incasari criterii selectate;\<Comision incasari agenti')
		
		lcCursor = "crsRaport"
		Use In (Select(m.lcCursor))
		Do Case
			Case m.lnOptiune = 1
				lcCursor = [crsexportexcel]
				This.do_cauta()
		
				If Used('crsraport')
					If Reccount('crsraport') <> 0
						Use In (SELECT('crsexportexcel'))
		
						Dimension aColoane[1]
						lcSelect = [SELECT Iif(gid<>0,'TOTAL',Space(5)) As explicatie]
						Afields(aColoane, 'crsraport')
						For i = 1 To Alen(aColoane, 1)
							If Upper(Alltrim(aColoane[i, 1])) <> 'GID'
								lcNumeColoana =  Upper(Alltrim(aColoane[i, 1]))
								lcSelect = lcSelect + [,] + Iif(aColoane[i, 2] = 'T', [TTOD(] + lcNumeColoana + [) as ] + ;
									  lcNumeColoana, lcNumeColoana)
							Endif
						Endfor
						lcSelect = lcSelect + [	From crsraport Into Cursor ] + m.lcCursor
						&lcSelect
		
					ENDIF && Reccount('crsraport')<>0
				ENDIF && Used('crsraport')
			Case m.lnOptiune = 2
				This.do_raport_comision_incasari_agenti(.T.)
				lcCursor = "crsRaport"
		ENDCASE
		
		If Used(m.lcCursor)
			If Reccount(m.lcCursor) <> 0
				export_xls(m.lcCursor)
			Else
				amessagebox("Nu exista rezultate pentru export in Excel!", 0 + 48, "Atentie")
				thisform.clb_perioada.SetFocus()
			Endif
		
			Use In (SELECT(m.lcCursor))
		Endif
		
	ENDPROC

	PROCEDURE do_listare
		LOCAL lnOptiune, lcRaport
		Private pcTitlu
		lnOptiune = 0
		lcRaport = ''
		pcTitlu = ''
		
		lnOptiune = xmenu('\<Incasari criterii selectate;Comision incasari agenti')
		
		Use In (Select('crsraport'))
		Do Case
			Case m.lnOptiune = 1
				This.do_cauta()
				pcTitlu = "Incasari"
				lcRaport = "raport_incasat"
			Case m.lnOptiune = 2
				This.do_raport_comision_incasari_agenti(.F.)
				pcTitlu = "Comision incasari agenti"
				lcRaport = "raport_comision_incasari_agenti"		
		Endcase
		
		If Used('crsraport')
			Thisform.AlwaysOnTop = .F.
			goExport.export2frx("crsraport", m.lcRaport, .T., 1, "RAPORT")	&&	, , , .T.)
		
			Thisform.clb_perioada.SetFocus()
			Thisform.AlwaysOnTop = .T.
			Use In (Select('crsraport'))
		Endif
		
		Release pcTitlu
		
	ENDPROC

	PROCEDURE do_raport_comision_incasari_agenti
		Lparameters tlExcel
		Local lccontrol, lcval, llSucces, lnValoare
		
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If Inlist(lccontrol, "TEXTBOX", "EDITBOX", "COMBOBOX")
			lcval = This.ActiveControl.ControlSource
			&lcval = Thisform.ActiveControl.Value
		Endif
		
		Do Case
			Case Empty(Nvl(poListare.datai, {}))
				amessagebox("Nu ati completat data initiala!", 0 + 48, "Atentie")
				Thisform.clb_perioada.tx_n1.SetFocus()
				Return
			Case Empty(Nvl(poListare.dataf, {}))
				amessagebox("Nu ati completat data finala!", 0 + 48, "Atentie")
				Thisform.clb_perioada.tx_n2.SetFocus()
				Return
			Case Empty(Nvl(poListare.data_referinta, {}))
				amessagebox("Nu ati completat data de referinta!", 0 + 48, "Atentie")
				Thisform.clb_data_referinta.SetFocus()
				Return
			Otherwise
				Private pcSql
				pcSql = ""
				lnSucces = goExecutor.oSelect2Value("Select cSql from rapoarte where LOWER(denumire) = 'comision incasari agenti' and rownum = 1", @pcSql)
				If lnSucces < 0
					amessagebox(goExecutor.oPrelucrareEroare(), 16, "Eroare")
					Thisform.ct_selectie1.SetFocus()
					Return
				Else
					If Empty(NVL(m.pcSql, ''))
						amessagebox("Nu exista raportul 'Comision incasari agenti' in baza de date!", 0 + 48, "Atentie")
						Thisform.ct_selectie1.SetFocus()
						Return
					Else
		* Completare filtre
						pcSql = Strtran(m.pcSql, [<%=SUCURSALA%>], NVL(m.gcCondSucursala, ''))
						pcSql = Strtran(m.pcSql, [<%=CLIENT%>], Iif(!Empty(Nvl(poListare.id_client, 0)), [ AND id_part = ?poListare.id_client], []))
						pcSql = Strtran(m.pcSql, [<%=AGENT%>], Iif(!Empty(Nvl(poListare.nume_agent, [])), [ AND id_agent = ?poListare.id_agent], []))
						pcSql = Strtran(m.pcSql, [<%=CATEGORIE%>], Iif(!Empty(Nvl(poListare.id_categorie_entitate, 0)), [ AND id_categorie_entitate = ?poListare.id_categorie_entitate], []))
		
						lnValoare = This.opt_tip_cont.Value
						pcSql = Strtran(m.pcSql, [<%=TIPCONT%>], Iif(m.lnValoare =  2, [ AND tip_cont = 'CASA'], Iif(m.lnValoare =  3, [ AND tip_cont = 'BANCA'], Iif(m.lnValoare =  4, [ AND tip_cont = 'ALT TIP'], []))))
					Endif
				Endif
		Endcase
		
		
		llSucces = IIF(Empty(Nvl(pcSql, '')), .F., goExecutor.oExecuta(m.pcSql, 'crsraport'))
		
		RETURN m.llSucces 
	ENDPROC

	PROCEDURE Clb_perioada.tx_n1.Valid
		*!*
	ENDPROC

ENDDEFINE
